@steedos-widgets/amis-lib 1.3.4-beta.5 → 1.3.4-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +98 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +98 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +14 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/types/schema/standard_new.amis.d.ts +27 -2
- package/dist/types/standard/button.d.ts +27 -2
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -452,39 +452,39 @@ function getCreatedInfoTpl(formFactor){
|
|
|
452
452
|
const href = Router.getObjectDetailPath({
|
|
453
453
|
formFactor, appId: "admin", objectName: 'users', recordId: '${created_by._id}'
|
|
454
454
|
});
|
|
455
|
-
return `<
|
|
455
|
+
return `<span><a href='${href}'>\${_display.created_by.label}</a>\${_display.created}</span>`
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
function getModifiedInfoTpl(formFactor){
|
|
459
459
|
const href = Router.getObjectDetailPath({
|
|
460
460
|
formFactor, appId: "admin", objectName: 'users', recordId: '${modified_by._id}'
|
|
461
461
|
});
|
|
462
|
-
return `<
|
|
462
|
+
return `<span><a href='${href}'>\${_display.modified_by.label}</a>\${_display.modified}</span>`
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
function getNumberTpl(field){
|
|
466
|
-
return `<
|
|
466
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
function getTimeTpl(field){
|
|
470
|
-
return `<
|
|
470
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
function getDateTpl(field){
|
|
474
|
-
return `<
|
|
474
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
|
|
478
478
|
function getDateTimeTpl(field){
|
|
479
|
-
return `<
|
|
479
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
function getUiFieldTpl(field){
|
|
483
|
-
return `<
|
|
483
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
function getUiFileSizeTpl(field){
|
|
487
|
-
return `<
|
|
487
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
//TODO 处理name字段
|
|
@@ -495,7 +495,7 @@ async function getRefObjectNameFieldName(field){
|
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
function getSelectTpl(field){
|
|
498
|
-
return `<
|
|
498
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
499
499
|
}
|
|
500
500
|
function getSelectMap(selectOptions){
|
|
501
501
|
let map = {};
|
|
@@ -1830,7 +1830,7 @@ const parseSingleExpression = function (func, formData, dataPath, global, userSe
|
|
|
1830
1830
|
* @Author: baozhoutao@steedos.com
|
|
1831
1831
|
* @Date: 2022-11-01 15:51:00
|
|
1832
1832
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
1833
|
-
* @LastEditTime: 2023-
|
|
1833
|
+
* @LastEditTime: 2023-09-25 14:53:05
|
|
1834
1834
|
* @Description:
|
|
1835
1835
|
*/
|
|
1836
1836
|
|
|
@@ -1849,18 +1849,31 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
1849
1849
|
formSchema = _.isString(payload.schema) ? JSON.parse(payload.schema) : payload.schema;
|
|
1850
1850
|
}
|
|
1851
1851
|
|
|
1852
|
+
const fields = ${JSON.stringify(uiSchema.fields)};
|
|
1853
|
+
const selectedRowResponseResult = api.body.selectedRowResponseResult;
|
|
1854
|
+
let defaultData = {};
|
|
1855
|
+
|
|
1856
|
+
if(!_.isEmpty(selectedRowResponseResult)){
|
|
1857
|
+
const fieldsKeys = _.keys(fields);
|
|
1858
|
+
// 如果新建记录时复制的数据中有omit或其他不相关字段数据时不应该一起保存到数据库,
|
|
1859
|
+
// 原规则见:https://github.com/steedos/steedos-frontend/issues/297
|
|
1860
|
+
_.forEach(selectedRowResponseResult, (val, key) => {
|
|
1861
|
+
if (fieldsKeys.indexOf(key) > -1 && fields[key].omit !== true) {
|
|
1862
|
+
defaultData[key] = val;
|
|
1863
|
+
}
|
|
1864
|
+
})
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1852
1867
|
const _master = api.body._master;
|
|
1853
1868
|
if(_master && _master._isRelated){
|
|
1854
1869
|
const relatedKey = _master.relatedKey;
|
|
1855
1870
|
const masterObjectName = _master.objectName;
|
|
1856
1871
|
const recordId = _master.recordId;
|
|
1857
1872
|
let relatedKeySaveValue = recordId;
|
|
1858
|
-
const fields = ${JSON.stringify(uiSchema.fields)};
|
|
1859
1873
|
const relatedField = fields[relatedKey];
|
|
1860
1874
|
if(relatedField.reference_to_field && relatedField.reference_to_field !== '_id'){
|
|
1861
1875
|
relatedKeySaveValue = _master.record[relatedField.reference_to_field];
|
|
1862
1876
|
}
|
|
1863
|
-
let defaultData = {};
|
|
1864
1877
|
let relatedKeyValue;
|
|
1865
1878
|
if(!_.isString(relatedField.reference_to)){
|
|
1866
1879
|
relatedKeyValue = { o: masterObjectName, ids: [relatedKeySaveValue] };
|
|
@@ -1870,6 +1883,9 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
1870
1883
|
relatedKeyValue = relatedKeySaveValue;
|
|
1871
1884
|
}
|
|
1872
1885
|
defaultData[relatedKey]=relatedKeyValue;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
if(!_.isEmpty(defaultData)){
|
|
1873
1889
|
if(payload.schema){
|
|
1874
1890
|
// 表单微页面第一层要求是page
|
|
1875
1891
|
formSchema.data.defaultData = defaultData;
|
|
@@ -1892,6 +1908,18 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
1892
1908
|
});
|
|
1893
1909
|
}, 200);
|
|
1894
1910
|
`;
|
|
1911
|
+
const getSelectedRowsScript = `
|
|
1912
|
+
const isLookup = event.data.isLookup;
|
|
1913
|
+
if(isLookup){
|
|
1914
|
+
// lookup弹出窗口的新建功能不需要支持复制新建
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
const uiSchema = event.data.uiSchema;
|
|
1918
|
+
const objectName = event.data.objectName;
|
|
1919
|
+
const listViewRef = event.context.scoped.getComponentById("listview_" + objectName);
|
|
1920
|
+
const selectedItems = listViewRef && listViewRef.props.store.toJSON().selectedItems || [];
|
|
1921
|
+
event.data.selectedIds = _.map(selectedItems, uiSchema.idFieldName || '_id');
|
|
1922
|
+
`;
|
|
1895
1923
|
return {
|
|
1896
1924
|
"type": "service",
|
|
1897
1925
|
"body": [
|
|
@@ -1904,6 +1932,21 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
1904
1932
|
"click": {
|
|
1905
1933
|
"weight": 0,
|
|
1906
1934
|
"actions": [
|
|
1935
|
+
{
|
|
1936
|
+
"actionType": "custom",
|
|
1937
|
+
"script": getSelectedRowsScript
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
"actionType": "ajax",
|
|
1941
|
+
"outputVar": "selectedRowResponseResult",
|
|
1942
|
+
"args": {
|
|
1943
|
+
"api": {
|
|
1944
|
+
"url": "${context.rootUrl}/api/v1/${uiSchema.name}/${selectedIds|first}",
|
|
1945
|
+
"method": "get"
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
"expression": "${selectedIds.length > 0}"
|
|
1949
|
+
},
|
|
1907
1950
|
{
|
|
1908
1951
|
"actionType": "dialog",
|
|
1909
1952
|
"dialog": {
|
|
@@ -1921,7 +1964,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
1921
1964
|
"displayAs": "${displayAs}",
|
|
1922
1965
|
"uiSchema": "${uiSchema}",
|
|
1923
1966
|
"isLookup": "${isLookup}",
|
|
1924
|
-
"listName": "${listName}"
|
|
1967
|
+
"listName": "${listName}",
|
|
1968
|
+
"selectedRowResponseResult": "${selectedRowResponseResult}",
|
|
1925
1969
|
},
|
|
1926
1970
|
"title":i18next.t('frontend_form_new') + " ${uiSchema.label | raw}",
|
|
1927
1971
|
"body": [
|
|
@@ -1933,7 +1977,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
1933
1977
|
"data": {
|
|
1934
1978
|
"isLookup": "${isLookup}",
|
|
1935
1979
|
"_master": "${_master}",
|
|
1936
|
-
"url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}"
|
|
1980
|
+
"url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
|
|
1981
|
+
"selectedRowResponseResult": "${selectedRowResponseResult}"
|
|
1937
1982
|
},
|
|
1938
1983
|
"url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
|
|
1939
1984
|
"method": "get",
|
|
@@ -10176,17 +10221,26 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10176
10221
|
Authorization: "Bearer ${context.tenantId},${context.authToken}",
|
|
10177
10222
|
},
|
|
10178
10223
|
requestAdaptor: quickSaveApiRequestAdaptor,
|
|
10224
|
+
adaptor: `
|
|
10225
|
+
if(payload.errors){
|
|
10226
|
+
payload.status = 2;
|
|
10227
|
+
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
10228
|
+
}
|
|
10229
|
+
return payload;
|
|
10230
|
+
`
|
|
10179
10231
|
},
|
|
10180
10232
|
rowClassNameExpr: options.rowClassNameExpr
|
|
10181
10233
|
}, bodyProps);
|
|
10182
10234
|
|
|
10183
|
-
body = await getCrudSchemaWithDataFilter(body, { crudDataFilter, onCrudDataFilter, amisData, env });
|
|
10184
10235
|
}
|
|
10185
10236
|
|
|
10186
10237
|
const defaults = options.defaults;
|
|
10238
|
+
|
|
10239
|
+
const listSchema = (defaults && defaults.listSchema) || {};
|
|
10240
|
+
body = defaultsDeep({}, listSchema, body);
|
|
10241
|
+
body = await getCrudSchemaWithDataFilter(body, { crudDataFilter, onCrudDataFilter, amisData, env });
|
|
10242
|
+
|
|
10187
10243
|
if (defaults) {
|
|
10188
|
-
const listSchema = defaults.listSchema || {};
|
|
10189
|
-
body = defaultsDeep({}, listSchema, body);
|
|
10190
10244
|
const headerSchema = defaults.headerSchema;
|
|
10191
10245
|
const footerSchema = defaults.footerSchema;
|
|
10192
10246
|
if (headerSchema || footerSchema) {
|
|
@@ -10518,7 +10572,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
10518
10572
|
* @Author: baozhoutao@steedos.com
|
|
10519
10573
|
* @Date: 2022-07-05 15:55:39
|
|
10520
10574
|
* @LastEditors: liaodaxue
|
|
10521
|
-
* @LastEditTime: 2023-
|
|
10575
|
+
* @LastEditTime: 2023-09-25 17:18:08
|
|
10522
10576
|
* @Description:
|
|
10523
10577
|
*/
|
|
10524
10578
|
|
|
@@ -10694,6 +10748,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
10694
10748
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
10695
10749
|
appId: appId,
|
|
10696
10750
|
crudClassName: 'border-t border-gray-300 hidden',
|
|
10751
|
+
refField,
|
|
10697
10752
|
...ctx
|
|
10698
10753
|
};
|
|
10699
10754
|
const amisSchema= (await getRelatedListSchema(relatedObjectName, 'all', options)).amisSchema;
|
|
@@ -10808,10 +10863,33 @@ async function getRelatedListSchema(
|
|
|
10808
10863
|
ctx
|
|
10809
10864
|
) {
|
|
10810
10865
|
const uiSchema = await getUISchema(objectName);
|
|
10811
|
-
const listView =
|
|
10866
|
+
const listView = find(
|
|
10867
|
+
uiSchema.list_views,
|
|
10868
|
+
(listView, name) => {
|
|
10869
|
+
// 传入listViewName空值则取第一个
|
|
10870
|
+
if(!listViewName){
|
|
10871
|
+
listViewName = name;
|
|
10872
|
+
}
|
|
10873
|
+
return name === listViewName || listView._id === listViewName;
|
|
10874
|
+
}
|
|
10875
|
+
);
|
|
10812
10876
|
const listViewProps = getRelatedListProps(uiSchema,listViewName, ctx);
|
|
10813
10877
|
// console.log('listViewProps==>', listViewProps)
|
|
10814
10878
|
const {columns: listViewColumns, sort: listViewSort, filter: listviewFilter, filtersFunction } = listViewProps;
|
|
10879
|
+
|
|
10880
|
+
const refFieldName = ctx.refField && ctx.refField.name;
|
|
10881
|
+
|
|
10882
|
+
let relatedListColumns = listViewColumns;
|
|
10883
|
+
if(refFieldName){
|
|
10884
|
+
relatedListColumns = listViewColumns.filter(function(columnItem){
|
|
10885
|
+
if(typeof columnItem === "string"){
|
|
10886
|
+
return columnItem !== refFieldName;
|
|
10887
|
+
}
|
|
10888
|
+
else {
|
|
10889
|
+
return columnItem.field !== refFieldName;
|
|
10890
|
+
}
|
|
10891
|
+
});
|
|
10892
|
+
}
|
|
10815
10893
|
|
|
10816
10894
|
const defaults = ctx.defaults || {};
|
|
10817
10895
|
|
|
@@ -10849,7 +10927,7 @@ async function getRelatedListSchema(
|
|
|
10849
10927
|
const amisSchema = {
|
|
10850
10928
|
"type": "steedos-object-table",
|
|
10851
10929
|
"objectApiName": objectName,
|
|
10852
|
-
"columns":
|
|
10930
|
+
"columns": relatedListColumns,
|
|
10853
10931
|
"extraColumns": listView.extra_columns,
|
|
10854
10932
|
"filters": listviewFilter,
|
|
10855
10933
|
"filtersFunction": filtersFunction,
|