@steedos-widgets/amis-lib 1.2.0-beta.0 → 1.2.0-beta.1
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 +173 -162
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +173 -162
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +176 -165
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields/lookup.d.ts +1 -0
- package/dist/types/lib/converter/amis/header.d.ts +4 -21
- package/dist/types/lib/converter/amis/index.d.ts +0 -3
- package/dist/types/lib/objects.d.ts +6 -29
- package/dist/types/lib/objectsRelated.d.ts +4 -12
- package/dist/types/schema/standard_delete.amis.d.ts +0 -6
- package/dist/types/schema/standard_new.amis.d.ts +3 -0
- package/dist/types/standard/button.d.ts +3 -6
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'lodash', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["amis-lib"] = {}, global._$1, global.
|
|
5
|
-
})(this, (function (exports, _$1,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('@steedos-widgets/amis-lib'), require('lodash/isPlainObject')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash', '@steedos-widgets/amis-lib', 'lodash/isPlainObject'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["amis-lib"] = {}, global._$1, global.amisLib, global.isPlainObject));
|
|
5
|
+
})(this, (function (exports, _$1, amisLib, isPlainObject) {
|
|
6
6
|
const global = window;
|
|
7
7
|
|
|
8
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -678,11 +678,7 @@
|
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
async function getFindOneQuery$1(object, recordId, fields, options){
|
|
681
|
-
let queryOptions = ""
|
|
682
|
-
|
|
683
|
-
if(recordId){
|
|
684
|
-
queryOptions = `(filters:["${object.idFieldName}", "=", "${recordId}"])`;
|
|
685
|
-
}
|
|
681
|
+
let queryOptions = `(filters:["${object.idFieldName}", "=", "\${recordId}"])`;
|
|
686
682
|
let alias = "data";
|
|
687
683
|
if(options){
|
|
688
684
|
if(options.alias){
|
|
@@ -1391,8 +1387,8 @@
|
|
|
1391
1387
|
/*
|
|
1392
1388
|
* @Author: baozhoutao@steedos.com
|
|
1393
1389
|
* @Date: 2022-11-01 15:51:00
|
|
1394
|
-
* @LastEditors:
|
|
1395
|
-
* @LastEditTime: 2023-
|
|
1390
|
+
* @LastEditors: Please set LastEditors
|
|
1391
|
+
* @LastEditTime: 2023-04-08 12:05:19
|
|
1396
1392
|
* @Description:
|
|
1397
1393
|
*/
|
|
1398
1394
|
|
|
@@ -1410,6 +1406,32 @@
|
|
|
1410
1406
|
if (payload && payload.schema) {
|
|
1411
1407
|
formSchema = _.isString(payload.schema) ? JSON.parse(payload.schema) : payload.schema;
|
|
1412
1408
|
}
|
|
1409
|
+
|
|
1410
|
+
const _master = api.body._master;
|
|
1411
|
+
if(_master && _master._isRelated){
|
|
1412
|
+
const relatedKey = _master.relatedKey;
|
|
1413
|
+
const masterObjectName = _master.objectName;
|
|
1414
|
+
const recordId = _master.recordId;
|
|
1415
|
+
const fields = ${JSON.stringify(uiSchema.fields)};
|
|
1416
|
+
const relatedField = fields[relatedKey];
|
|
1417
|
+
let defaultData = {};
|
|
1418
|
+
let relatedKeyValue;
|
|
1419
|
+
if(!_.isString(relatedField.reference_to)){
|
|
1420
|
+
relatedKeyValue = { o: masterObjectName, ids: [recordId] };
|
|
1421
|
+
}else if (relatedField.multiple) {
|
|
1422
|
+
relatedKeyValue = [recordId];
|
|
1423
|
+
} else {
|
|
1424
|
+
relatedKeyValue = recordId;
|
|
1425
|
+
}
|
|
1426
|
+
defaultData[relatedKey]=relatedKeyValue;
|
|
1427
|
+
if(payload.schema){
|
|
1428
|
+
// 表单微页面第一层要求是page
|
|
1429
|
+
formSchema.data.defaultData = defaultData;
|
|
1430
|
+
}else{
|
|
1431
|
+
formSchema.defaultData = defaultData;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1413
1435
|
return {
|
|
1414
1436
|
data: formSchema
|
|
1415
1437
|
};
|
|
@@ -1433,6 +1455,8 @@
|
|
|
1433
1455
|
"data": {
|
|
1434
1456
|
"$master": "$$",
|
|
1435
1457
|
"_master": "${_master}",
|
|
1458
|
+
"_master._isRelated": "${_isRelated}",
|
|
1459
|
+
"_master.relatedKey": "${relatedKey}",
|
|
1436
1460
|
"defaultData": "${defaultData}",
|
|
1437
1461
|
"appId": "${appId}",
|
|
1438
1462
|
"objectName": "${objectName}",
|
|
@@ -1451,7 +1475,8 @@
|
|
|
1451
1475
|
"messages": {},
|
|
1452
1476
|
"schemaApi": {
|
|
1453
1477
|
"data": {
|
|
1454
|
-
"isLookup": "${isLookup}"
|
|
1478
|
+
"isLookup": "${isLookup}",
|
|
1479
|
+
"_master": "${_master}"
|
|
1455
1480
|
},
|
|
1456
1481
|
"url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
|
|
1457
1482
|
"method": "get",
|
|
@@ -1574,8 +1599,8 @@
|
|
|
1574
1599
|
/*
|
|
1575
1600
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
1576
1601
|
* @Date: 2023-03-22 09:31:21
|
|
1577
|
-
* @LastEditors:
|
|
1578
|
-
* @LastEditTime: 2023-
|
|
1602
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
1603
|
+
* @LastEditTime: 2023-04-06 16:04:20
|
|
1579
1604
|
*/
|
|
1580
1605
|
const getSchema$2 = (uiSchema)=>{
|
|
1581
1606
|
return {
|
|
@@ -1605,15 +1630,11 @@
|
|
|
1605
1630
|
},
|
|
1606
1631
|
"adaptor": `
|
|
1607
1632
|
if(payload.errors){
|
|
1608
|
-
|
|
1609
|
-
|
|
1633
|
+
payload.status = 2;
|
|
1634
|
+
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
1610
1635
|
}
|
|
1611
1636
|
return payload;
|
|
1612
1637
|
`,
|
|
1613
|
-
},
|
|
1614
|
-
"messages": {
|
|
1615
|
-
"success": "删除成功",
|
|
1616
|
-
"failed": "删除失败"
|
|
1617
1638
|
}
|
|
1618
1639
|
},
|
|
1619
1640
|
"actionType": "ajax"
|
|
@@ -1976,7 +1997,7 @@
|
|
|
1976
1997
|
getStandardNew: async (uiSchema, ctx)=>{
|
|
1977
1998
|
return {
|
|
1978
1999
|
type: 'amis_button',
|
|
1979
|
-
amis_schema: await getSchema$4()
|
|
2000
|
+
amis_schema: await getSchema$4(uiSchema)
|
|
1980
2001
|
}
|
|
1981
2002
|
},
|
|
1982
2003
|
getStandardEdit: async (uiSchema, ctx)=>{
|
|
@@ -2060,7 +2081,7 @@
|
|
|
2060
2081
|
if(visible.trim().startsWith('function')){
|
|
2061
2082
|
return `${visible}.apply({
|
|
2062
2083
|
object: uiSchema
|
|
2063
|
-
}, [objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2084
|
+
}, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2064
2085
|
}
|
|
2065
2086
|
return visible;
|
|
2066
2087
|
}
|
|
@@ -3190,9 +3211,8 @@
|
|
|
3190
3211
|
|
|
3191
3212
|
let body = [
|
|
3192
3213
|
{
|
|
3193
|
-
"type": "
|
|
3194
|
-
"
|
|
3195
|
-
data: { "&":"$$", objectName: name, _id: recordId, recordPermissions: "${record.recordPermissions}", uiSchema: objectSchema},
|
|
3214
|
+
"type": "wrapper",
|
|
3215
|
+
"className": "p-0",
|
|
3196
3216
|
"body": [
|
|
3197
3217
|
{
|
|
3198
3218
|
"type": "grid",
|
|
@@ -3200,14 +3220,14 @@
|
|
|
3200
3220
|
"className": "flex justify-between"
|
|
3201
3221
|
}
|
|
3202
3222
|
],
|
|
3203
|
-
"messages": {},
|
|
3204
3223
|
"hiddenOn": "${recordLoaded != true}"
|
|
3205
3224
|
}
|
|
3206
3225
|
];
|
|
3207
3226
|
|
|
3208
3227
|
if(showRecordTitle){
|
|
3209
3228
|
body.push({
|
|
3210
|
-
"type": "
|
|
3229
|
+
"type": "wrapper",
|
|
3230
|
+
"className": "p-0",
|
|
3211
3231
|
"body": [
|
|
3212
3232
|
{
|
|
3213
3233
|
"type": "grid",
|
|
@@ -3215,16 +3235,15 @@
|
|
|
3215
3235
|
"className": "flex justify-between"
|
|
3216
3236
|
}
|
|
3217
3237
|
],
|
|
3218
|
-
"messages": {},
|
|
3219
3238
|
"hiddenOn": "${recordLoaded == true}"
|
|
3220
3239
|
});
|
|
3221
3240
|
}
|
|
3222
3241
|
|
|
3223
3242
|
return {
|
|
3224
3243
|
type: 'service',
|
|
3225
|
-
|
|
3244
|
+
id: `page_readonly_${name}_header`,
|
|
3226
3245
|
name: `page`,
|
|
3227
|
-
data: {
|
|
3246
|
+
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
3228
3247
|
body: body,
|
|
3229
3248
|
className: ''
|
|
3230
3249
|
}
|
|
@@ -3279,7 +3298,7 @@
|
|
|
3279
3298
|
"body": [
|
|
3280
3299
|
{
|
|
3281
3300
|
"type": "tpl",
|
|
3282
|
-
"tpl": `<a class="text-black text-base font-bold" href="/app/\${appId}/\${
|
|
3301
|
+
"tpl": `<a class="text-black text-base font-bold" href="/app/\${appId}/\${_master.objectName}/\${_master.recordId}/\${objectName}/grid?related_field_name=\${relatedKey}">${relatedLabel}(\${$count})</a>`,
|
|
3283
3302
|
"inline": false,
|
|
3284
3303
|
"wrapperComponent": "",
|
|
3285
3304
|
"className": "",
|
|
@@ -3320,17 +3339,22 @@
|
|
|
3320
3339
|
async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
|
|
3321
3340
|
}
|
|
3322
3341
|
|
|
3323
|
-
const getDisplayAsButton = function(showDisplayAs){
|
|
3342
|
+
const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
3343
|
+
let displayAs = amisLib.Router.getTabDisplayAs(objectName);
|
|
3324
3344
|
let buttons = [
|
|
3325
3345
|
{
|
|
3326
3346
|
"type": "button",
|
|
3327
3347
|
"label": "表格",
|
|
3328
|
-
"onClick": "
|
|
3348
|
+
"onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
|
|
3349
|
+
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
3350
|
+
"rightIconClassName": "m-l-sm"
|
|
3329
3351
|
},
|
|
3330
3352
|
{
|
|
3331
3353
|
"type": "button",
|
|
3332
3354
|
"label": "分栏视图",
|
|
3333
|
-
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);"
|
|
3355
|
+
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
3356
|
+
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
3357
|
+
"rightIconClassName": "m-l-sm"
|
|
3334
3358
|
}
|
|
3335
3359
|
];
|
|
3336
3360
|
return {
|
|
@@ -3472,7 +3496,7 @@ setTimeout(()=>{
|
|
|
3472
3496
|
}
|
|
3473
3497
|
}
|
|
3474
3498
|
},
|
|
3475
|
-
showDisplayAs? getDisplayAsButton() : {}
|
|
3499
|
+
showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
|
|
3476
3500
|
]
|
|
3477
3501
|
}else {
|
|
3478
3502
|
return [
|
|
@@ -3553,7 +3577,7 @@ setTimeout(()=>{
|
|
|
3553
3577
|
}
|
|
3554
3578
|
}
|
|
3555
3579
|
},
|
|
3556
|
-
showDisplayAs? getDisplayAsButton() : {}
|
|
3580
|
+
showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
|
|
3557
3581
|
// {
|
|
3558
3582
|
// "type": "search-box",
|
|
3559
3583
|
// "align": "right",
|
|
@@ -3843,13 +3867,14 @@ setTimeout(()=>{
|
|
|
3843
3867
|
"headers": {
|
|
3844
3868
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
3845
3869
|
},
|
|
3846
|
-
"adaptor": " const records = payload.data.options;\n const treeRecords = [];\n const getChildren = (records, childrenIds) => {\n if (!childrenIds) {\n return;\n }\n const children = _.filter(records, (record) => {\n return _.includes(childrenIds, record.value)\n });\n _.each(children, (item) => {\n if (item.children) {\n item.children = getChildren(records, item.children)\n }\n })\n return children;\n }\n\n const getRoot = (records) => {\n for (var i = 0; i < records.length; i++){\n records[i].noParent = 0;\n if (!!records[i].parent) {\n biaozhi = 1\n for (var j = 0; j < records.length; j++){\n if (records[i].parent == records[j].value)\n biaozhi = 0;\n }\n if (biaozhi == 1) records[i].noParent = 1;\n } else records[i].noParent = 1;\n }\n }\n getRoot(records);\n console.log(records)\n\n _.each(records, (record) => {\n if (record.noParent ==1) {\n treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));\n }\n });\n console.log(treeRecords)\n\n payload.data.options = treeRecords;\n
|
|
3870
|
+
"adaptor": "if (payload.data.treeCache == true) {\n return payload;\n }\n const records = payload.data.options;\n const treeRecords = [];\n const getChildren = (records, childrenIds) => {\n if (!childrenIds) {\n return;\n }\n const children = _.filter(records, (record) => {\n return _.includes(childrenIds, record.value)\n });\n _.each(children, (item) => {\n if (item.children) {\n item.children = getChildren(records, item.children)\n }\n })\n return children;\n }\n\n const getRoot = (records) => {\n for (var i = 0; i < records.length; i++){\n records[i].noParent = 0;\n if (!!records[i].parent) {\n biaozhi = 1\n for (var j = 0; j < records.length; j++){\n if (records[i].parent == records[j].value)\n biaozhi = 0;\n }\n if (biaozhi == 1) records[i].noParent = 1;\n } else records[i].noParent = 1;\n }\n }\n getRoot(records);\n console.log(records)\n\n _.each(records, (record) => {\n if (record.noParent ==1) {\n treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));\n }\n });\n console.log(treeRecords)\n\n payload.data.options = treeRecords;\n payload.data.treeCache = true;\n return payload;\n ",
|
|
3847
3871
|
"requestAdaptor": "\n ",
|
|
3848
3872
|
"data": {
|
|
3849
3873
|
"query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
|
|
3850
3874
|
},
|
|
3851
3875
|
"messages": {
|
|
3852
|
-
}
|
|
3876
|
+
},
|
|
3877
|
+
"cache": 300000
|
|
3853
3878
|
},
|
|
3854
3879
|
"onEvent": {
|
|
3855
3880
|
"change": {
|
|
@@ -4240,20 +4265,20 @@ setTimeout(()=>{
|
|
|
4240
4265
|
|
|
4241
4266
|
if(referenceTo){
|
|
4242
4267
|
// 字段值单独走一个请求合并到source的同一个GraphQL接口中
|
|
4243
|
-
const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null,
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4268
|
+
const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
|
|
4269
|
+
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
4270
|
+
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
4271
|
+
], {
|
|
4247
4272
|
alias: "defaultValueOptions",
|
|
4248
4273
|
filters: "{__options_filters}",
|
|
4249
4274
|
count: false
|
|
4250
4275
|
});
|
|
4251
4276
|
apiInfo = await getApi$1({
|
|
4252
4277
|
name: referenceTo.objectName
|
|
4253
|
-
}, null,
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4278
|
+
}, null, [
|
|
4279
|
+
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
4280
|
+
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
4281
|
+
], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`, moreQueries: [defaultValueOptionsQueryData.query]});
|
|
4257
4282
|
|
|
4258
4283
|
apiInfo.adaptor = `
|
|
4259
4284
|
const data = payload.data;
|
|
@@ -5414,8 +5439,9 @@ setTimeout(()=>{
|
|
|
5414
5439
|
async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
5415
5440
|
return {
|
|
5416
5441
|
method: "post",
|
|
5417
|
-
url: getApi$2()+"
|
|
5442
|
+
url: getApi$2()+"&recordId=${recordId}",
|
|
5418
5443
|
cache: API_CACHE,
|
|
5444
|
+
// requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
|
|
5419
5445
|
adaptor: getReadonlyFormAdaptor(fields),
|
|
5420
5446
|
data: await getFindOneQuery$1(object, recordId, fields, options),
|
|
5421
5447
|
headers: {
|
|
@@ -5522,6 +5548,7 @@ setTimeout(()=>{
|
|
|
5522
5548
|
data.global = "${global}";
|
|
5523
5549
|
data.context = "${context}";
|
|
5524
5550
|
data.defaultData = "${defaultData}";
|
|
5551
|
+
|
|
5525
5552
|
return {
|
|
5526
5553
|
method: "post",
|
|
5527
5554
|
url: getApi$2(),
|
|
@@ -5890,7 +5917,7 @@ setTimeout(()=>{
|
|
|
5890
5917
|
keepItemSelectionOnPageChange: true,
|
|
5891
5918
|
api: await getTableApi(objectSchema, fields, options),
|
|
5892
5919
|
hiddenOn: options.tableHiddenOn,
|
|
5893
|
-
autoFillHeight: true,
|
|
5920
|
+
autoFillHeight: options.isRelated ? false : true,
|
|
5894
5921
|
className: `flex-auto ${crudClassName || ""}`,
|
|
5895
5922
|
crudClassName: crudClassName,
|
|
5896
5923
|
},
|
|
@@ -5933,11 +5960,11 @@ setTimeout(()=>{
|
|
|
5933
5960
|
id: `service_${id}`,
|
|
5934
5961
|
name: `page`,
|
|
5935
5962
|
data: {
|
|
5936
|
-
objectName: objectSchema.name,
|
|
5937
|
-
_id: null,
|
|
5963
|
+
// objectName: objectSchema.name,
|
|
5964
|
+
// _id: null,
|
|
5938
5965
|
recordPermissions: objectSchema.permissions,
|
|
5939
5966
|
uiSchema: objectSchema,
|
|
5940
|
-
loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
5967
|
+
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
5941
5968
|
},
|
|
5942
5969
|
body: body
|
|
5943
5970
|
}
|
|
@@ -6050,6 +6077,10 @@ setTimeout(()=>{
|
|
|
6050
6077
|
"objectName": "${_master.objectName}"
|
|
6051
6078
|
},
|
|
6052
6079
|
"expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
|
|
6080
|
+
},
|
|
6081
|
+
{
|
|
6082
|
+
"args": {},
|
|
6083
|
+
"actionType": "closeDialog"
|
|
6053
6084
|
}
|
|
6054
6085
|
]
|
|
6055
6086
|
}
|
|
@@ -6396,7 +6427,7 @@ setTimeout(()=>{
|
|
|
6396
6427
|
// return 'false';
|
|
6397
6428
|
// }
|
|
6398
6429
|
if(visible.trim().startsWith('function')){
|
|
6399
|
-
return `${visible}(objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6430
|
+
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6400
6431
|
}
|
|
6401
6432
|
return visible;
|
|
6402
6433
|
}
|
|
@@ -6561,6 +6592,11 @@ setTimeout(()=>{
|
|
|
6561
6592
|
|
|
6562
6593
|
let valueField = mainObject.key_field || '_id';
|
|
6563
6594
|
const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
6595
|
+
|
|
6596
|
+
if(options.isRelated){
|
|
6597
|
+
api.url += "&recordId=${recordId}";
|
|
6598
|
+
}
|
|
6599
|
+
|
|
6564
6600
|
api.data.$term = "$term";
|
|
6565
6601
|
api.data.$self = "$$";
|
|
6566
6602
|
api.data.filter = "$filter";
|
|
@@ -6680,11 +6716,36 @@ setTimeout(()=>{
|
|
|
6680
6716
|
if(!_.isEmpty(systemFilters)){
|
|
6681
6717
|
filters = systemFilters;
|
|
6682
6718
|
};
|
|
6683
|
-
|
|
6684
6719
|
if(api.data.$self.additionalFilters){
|
|
6685
6720
|
userFilters.push(api.data.$self.additionalFilters)
|
|
6686
6721
|
}
|
|
6687
6722
|
|
|
6723
|
+
if(api.data.$self._isRelated){
|
|
6724
|
+
const self = api.data.$self;
|
|
6725
|
+
const relatedKey = self.relatedKey;
|
|
6726
|
+
const recordId = self.recordId;
|
|
6727
|
+
const refField = self.uiSchema.fields[relatedKey];
|
|
6728
|
+
const masterRecord = self._master.record;
|
|
6729
|
+
const masterObjectName = self._master.objectName;
|
|
6730
|
+
let relatedValue = recordId;
|
|
6731
|
+
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
6732
|
+
relatedValue = masterRecord[refField.reference_to_field]
|
|
6733
|
+
}
|
|
6734
|
+
let relatedFilters;
|
|
6735
|
+
if (
|
|
6736
|
+
refField._reference_to ||
|
|
6737
|
+
(refField.reference_to && !_.isString(refField.reference_to))
|
|
6738
|
+
) {
|
|
6739
|
+
relatedFilters = [
|
|
6740
|
+
[relatedKey + "/o", "=", masterObjectName],
|
|
6741
|
+
[relatedKey + "/ids", "=", relatedValue],
|
|
6742
|
+
];
|
|
6743
|
+
} else {
|
|
6744
|
+
relatedFilters = [relatedKey, "=", relatedValue];
|
|
6745
|
+
}
|
|
6746
|
+
userFilters.push(relatedFilters)
|
|
6747
|
+
}
|
|
6748
|
+
|
|
6688
6749
|
if(!_.isEmpty(userFilters)){
|
|
6689
6750
|
if(_.isEmpty(filters)){
|
|
6690
6751
|
filters = userFilters;
|
|
@@ -6807,7 +6868,7 @@ setTimeout(()=>{
|
|
|
6807
6868
|
const data = await getFindQuery(object, recordId, fields, options);
|
|
6808
6869
|
return {
|
|
6809
6870
|
method: "post",
|
|
6810
|
-
url: getApi$2(),
|
|
6871
|
+
url: getApi$2(), // + "&recordId=${recordId}"
|
|
6811
6872
|
data: data,
|
|
6812
6873
|
headers: {
|
|
6813
6874
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -7441,8 +7502,8 @@ setTimeout(()=>{
|
|
|
7441
7502
|
/*
|
|
7442
7503
|
* @Author: baozhoutao@steedos.com
|
|
7443
7504
|
* @Date: 2022-07-05 15:55:39
|
|
7444
|
-
* @LastEditors:
|
|
7445
|
-
* @LastEditTime: 2023-
|
|
7505
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
7506
|
+
* @LastEditTime: 2023-04-08 18:14:55
|
|
7446
7507
|
* @Description:
|
|
7447
7508
|
*/
|
|
7448
7509
|
|
|
@@ -7514,7 +7575,7 @@ setTimeout(()=>{
|
|
|
7514
7575
|
|
|
7515
7576
|
// 获取单个相关表
|
|
7516
7577
|
async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObjectName, relatedKey, ctx){
|
|
7517
|
-
let { top, perPage,
|
|
7578
|
+
let { top, perPage, appId, relatedLabel, className, columns, sort, filters, visible_on } = ctx;
|
|
7518
7579
|
// console.log('getRecordDetailRelatedListSchema==>',objectName,recordId,relatedObjectName)
|
|
7519
7580
|
const relatedObjectUiSchema = await getUISchema(relatedObjectName);
|
|
7520
7581
|
if(!relatedObjectUiSchema){
|
|
@@ -7549,6 +7610,7 @@ setTimeout(()=>{
|
|
|
7549
7610
|
relatedKey = mainRelated[relatedObjectName];
|
|
7550
7611
|
}
|
|
7551
7612
|
let globalFilter = null;
|
|
7613
|
+
// TODO: refField变量去掉,写到amis运行时脚本中,uiSchema.fields[relatedKey];可以取到
|
|
7552
7614
|
const refField = await getField(relatedObjectName, relatedKey);
|
|
7553
7615
|
|
|
7554
7616
|
if(!refField){
|
|
@@ -7564,23 +7626,23 @@ setTimeout(()=>{
|
|
|
7564
7626
|
}
|
|
7565
7627
|
}
|
|
7566
7628
|
|
|
7567
|
-
let relatedValue = recordId;
|
|
7568
|
-
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
}
|
|
7629
|
+
let relatedValue = "${recordId}";
|
|
7630
|
+
// if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7631
|
+
// const masterRecord = await getRecord(objectName, recordId, [refField.reference_to_field]);
|
|
7632
|
+
// relatedValue = masterRecord[refField.reference_to_field]
|
|
7633
|
+
// }
|
|
7572
7634
|
|
|
7573
|
-
if (
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
) {
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
} else {
|
|
7582
|
-
|
|
7583
|
-
}
|
|
7635
|
+
// if (
|
|
7636
|
+
// refField._reference_to ||
|
|
7637
|
+
// (refField.reference_to && !isString(refField.reference_to))
|
|
7638
|
+
// ) {
|
|
7639
|
+
// globalFilter = [
|
|
7640
|
+
// [`${relatedKey}/o`, "=", objectName],
|
|
7641
|
+
// [`${relatedKey}/ids`, "=", relatedValue],
|
|
7642
|
+
// ];
|
|
7643
|
+
// } else {
|
|
7644
|
+
// globalFilter = [`${relatedKey}`, "=", relatedValue];
|
|
7645
|
+
// }
|
|
7584
7646
|
const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
|
|
7585
7647
|
const componentId = `steedos-record-related-list-${relatedObjectName}`;
|
|
7586
7648
|
const options = {
|
|
@@ -7605,9 +7667,9 @@ setTimeout(()=>{
|
|
|
7605
7667
|
top: top,
|
|
7606
7668
|
perPage: perPage,
|
|
7607
7669
|
setDataToComponentId: componentId,
|
|
7608
|
-
tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
7670
|
+
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
7609
7671
|
appId: appId,
|
|
7610
|
-
crudClassName: 'border-t border-slate-300',
|
|
7672
|
+
crudClassName: 'border-t border-slate-300 hidden',
|
|
7611
7673
|
...ctx
|
|
7612
7674
|
};
|
|
7613
7675
|
const amisSchema= (await getRelatedListSchema(relatedObjectName, 'all', options)).amisSchema;
|
|
@@ -7619,15 +7681,9 @@ setTimeout(()=>{
|
|
|
7619
7681
|
amisSchema: {
|
|
7620
7682
|
type: "service",
|
|
7621
7683
|
id: componentId,
|
|
7622
|
-
className: `steedos-record-related-list rounded border border-slate-300 bg-gray-100 mb-4 ${className}`,
|
|
7684
|
+
className: `steedos-record-related-list ${componentId} rounded border border-slate-300 bg-gray-100 mb-4 ${className}`,
|
|
7623
7685
|
data: {
|
|
7624
|
-
"&": "$$",
|
|
7625
|
-
appId: "${appId}",
|
|
7626
|
-
app_id: "${appId}",
|
|
7627
|
-
masterObjectName: objectName,
|
|
7628
|
-
masterRecordId: "${recordId}",
|
|
7629
7686
|
relatedKey: relatedKey,
|
|
7630
|
-
objectName: relatedObjectName,
|
|
7631
7687
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
7632
7688
|
_isRelated: true
|
|
7633
7689
|
},
|
|
@@ -7635,12 +7691,6 @@ setTimeout(()=>{
|
|
|
7635
7691
|
{
|
|
7636
7692
|
...amisSchema,
|
|
7637
7693
|
data: {
|
|
7638
|
-
"&": "$$",
|
|
7639
|
-
appId: "${appId}",
|
|
7640
|
-
app_id: "${appId}",
|
|
7641
|
-
relatedKey: relatedKey,
|
|
7642
|
-
objectName: "${objectName}",
|
|
7643
|
-
recordId: "${masterRecordId}",
|
|
7644
7694
|
defaultData: {
|
|
7645
7695
|
...{[relatedKey]: getRelatedFieldValue(objectName, relatedValue, relatedObjectUiSchema, relatedKey)}
|
|
7646
7696
|
}
|
|
@@ -7684,13 +7734,13 @@ setTimeout(()=>{
|
|
|
7684
7734
|
columns = getListViewColumns(listView, ctx.formFactor);
|
|
7685
7735
|
sort = getListViewSort(listView);
|
|
7686
7736
|
filter = getListViewFilter(listView);
|
|
7687
|
-
if(
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
}else if(ctx.globalFilter && (!filter || !filter.length)){
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
}
|
|
7737
|
+
// if(isArray(ctx.globalFilter) && ctx.globalFilter.length && isArray(filter) && filter.length){
|
|
7738
|
+
// // 都有值
|
|
7739
|
+
// filter = [ctx.globalFilter, 'and', filter]
|
|
7740
|
+
// }else if(ctx.globalFilter && (!filter || !filter.length)){
|
|
7741
|
+
// // globalFilter有值,filter无值
|
|
7742
|
+
// filter = ctx.globalFilter;
|
|
7743
|
+
// }
|
|
7694
7744
|
filtersFunction = listView && listView._filters;
|
|
7695
7745
|
}else {
|
|
7696
7746
|
const isNameField = _$1.find(
|
|
@@ -7700,9 +7750,9 @@ setTimeout(()=>{
|
|
|
7700
7750
|
}
|
|
7701
7751
|
);
|
|
7702
7752
|
columns = isNameField ? [isNameField.name] : ['name'];
|
|
7703
|
-
if(ctx.globalFilter){
|
|
7704
|
-
|
|
7705
|
-
}
|
|
7753
|
+
// if(ctx.globalFilter){
|
|
7754
|
+
// filter = ctx.globalFilter;
|
|
7755
|
+
// }
|
|
7706
7756
|
}
|
|
7707
7757
|
|
|
7708
7758
|
return {
|
|
@@ -7726,7 +7776,7 @@ setTimeout(()=>{
|
|
|
7726
7776
|
return {
|
|
7727
7777
|
columns: ctx.columns,
|
|
7728
7778
|
sort,
|
|
7729
|
-
filter: ctx.globalFilter,
|
|
7779
|
+
// filter: ctx.globalFilter,
|
|
7730
7780
|
filtersFunction: filtersFunction
|
|
7731
7781
|
}
|
|
7732
7782
|
} else {
|
|
@@ -7765,6 +7815,16 @@ setTimeout(()=>{
|
|
|
7765
7815
|
delete ctx.filters;
|
|
7766
7816
|
|
|
7767
7817
|
delete ctx.globalFilter;
|
|
7818
|
+
|
|
7819
|
+
const adaptor = `
|
|
7820
|
+
if(setDataToComponentId){
|
|
7821
|
+
if(payload.data.count){
|
|
7822
|
+
setTimeout(function(){
|
|
7823
|
+
window.$("." + setDataToComponentId + " .antd-Crud").removeClass("hidden");
|
|
7824
|
+
}, 10);
|
|
7825
|
+
}
|
|
7826
|
+
};
|
|
7827
|
+
`;
|
|
7768
7828
|
const amisSchema = {
|
|
7769
7829
|
"type": "steedos-object-table",
|
|
7770
7830
|
"objectApiName": objectName,
|
|
@@ -7773,6 +7833,8 @@ setTimeout(()=>{
|
|
|
7773
7833
|
"filters": listviewFilter,
|
|
7774
7834
|
"filtersFunction": filtersFunction,
|
|
7775
7835
|
"sort": listViewSort,
|
|
7836
|
+
"filterVisible": false,
|
|
7837
|
+
adaptor,
|
|
7776
7838
|
"ctx": ctx
|
|
7777
7839
|
};
|
|
7778
7840
|
// console.log(`getRelatedListSchema amisSchema`, amisSchema);
|
|
@@ -7785,8 +7847,8 @@ setTimeout(()=>{
|
|
|
7785
7847
|
/*
|
|
7786
7848
|
* @Author: baozhoutao@steedos.com
|
|
7787
7849
|
* @Date: 2022-07-05 15:55:39
|
|
7788
|
-
* @LastEditors:
|
|
7789
|
-
* @LastEditTime: 2023-
|
|
7850
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
7851
|
+
* @LastEditTime: 2023-04-08 17:31:57
|
|
7790
7852
|
* @Description:
|
|
7791
7853
|
*/
|
|
7792
7854
|
|
|
@@ -7958,14 +8020,14 @@ setTimeout(()=>{
|
|
|
7958
8020
|
async function getFormSchema(objectName, ctx) {
|
|
7959
8021
|
const uiSchema = await getUISchema(objectName);
|
|
7960
8022
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
7961
|
-
|
|
8023
|
+
console.log(`getFormSchema====>`, amisSchema);
|
|
7962
8024
|
return {
|
|
7963
8025
|
uiSchema,
|
|
7964
8026
|
amisSchema,
|
|
7965
8027
|
};
|
|
7966
8028
|
}
|
|
7967
8029
|
|
|
7968
|
-
// 获取只读页面
|
|
8030
|
+
// 获取只读页面 recordId 已废弃, 函数签名保持不变, 但recordId变量不可再使用, 请使用运行时的${recordId}
|
|
7969
8031
|
async function getViewSchema(objectName, recordId, ctx) {
|
|
7970
8032
|
const uiSchema = await getUISchema(objectName);
|
|
7971
8033
|
const amisSchema = await getObjectDetail(uiSchema, recordId, ctx);
|
|
@@ -8150,6 +8212,7 @@ setTimeout(()=>{
|
|
|
8150
8212
|
headerToolbarItems: ctx.headerToolbarItems,
|
|
8151
8213
|
buttons: await getListViewItemButtons(uiSchema, ctx)
|
|
8152
8214
|
});
|
|
8215
|
+
// console.log('getTableSchema====>amisSchema', amisSchema)
|
|
8153
8216
|
return {
|
|
8154
8217
|
uiSchema,
|
|
8155
8218
|
amisSchema,
|
|
@@ -8248,15 +8311,8 @@ setTimeout(()=>{
|
|
|
8248
8311
|
"data": {
|
|
8249
8312
|
"name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
8250
8313
|
"record": `\${event.data.record}`,
|
|
8251
|
-
"
|
|
8252
|
-
|
|
8253
|
-
},
|
|
8254
|
-
{
|
|
8255
|
-
"actionType": "reload",
|
|
8256
|
-
"componentId": `page_readonly_${objectName}_header`, //刷新标题, 详细页面header service 嵌套太多, 导致仅刷新第一层service无法更新recordName
|
|
8257
|
-
"data": {
|
|
8258
|
-
"name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
8259
|
-
"record": `\${event.data.record}`,
|
|
8314
|
+
"_id": "\${event.data.record._id}",
|
|
8315
|
+
"recordId": "\${event.data.record._id}",
|
|
8260
8316
|
"recordLoaded": true,
|
|
8261
8317
|
}
|
|
8262
8318
|
}
|
|
@@ -8266,10 +8322,10 @@ setTimeout(()=>{
|
|
|
8266
8322
|
},
|
|
8267
8323
|
content
|
|
8268
8324
|
],
|
|
8269
|
-
data: {
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
},
|
|
8325
|
+
// data: {
|
|
8326
|
+
// "_master.objectName": "${objectName}",
|
|
8327
|
+
// "_master.recordId": "${recordId}"
|
|
8328
|
+
// },
|
|
8273
8329
|
onEvent: {
|
|
8274
8330
|
"recordLoaded": {
|
|
8275
8331
|
"actions": [
|
|
@@ -8277,10 +8333,10 @@ setTimeout(()=>{
|
|
|
8277
8333
|
"actionType": "reload",
|
|
8278
8334
|
"data": {
|
|
8279
8335
|
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
8280
|
-
"_master.record": `\${record}`,
|
|
8281
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
8282
|
-
"_master.objectName": "${objectName}",
|
|
8283
|
-
"_master.recordId": "${recordId}"
|
|
8336
|
+
// "_master.record": `\${record}`,
|
|
8337
|
+
// // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
8338
|
+
// "_master.objectName": "${objectName}",
|
|
8339
|
+
// "_master.recordId": "${recordId}"
|
|
8284
8340
|
}
|
|
8285
8341
|
}
|
|
8286
8342
|
]
|
|
@@ -8291,51 +8347,6 @@ setTimeout(()=>{
|
|
|
8291
8347
|
}
|
|
8292
8348
|
}
|
|
8293
8349
|
|
|
8294
|
-
// export async function getRecordDetailRelatedListSchema(objectName,recordId,relatedObjectName){
|
|
8295
|
-
// // console.log('b==>',objectName,recordId,relatedObjectName)
|
|
8296
|
-
// const relatedObjectUiSchema = await getUISchema(relatedObjectName);
|
|
8297
|
-
// const { list_views, label , icon, fields } = relatedObjectUiSchema;
|
|
8298
|
-
// const firstListViewName = keys(list_views)[0];
|
|
8299
|
-
// const relatedKey = findKey(fields, function(field) {
|
|
8300
|
-
// return ["lookup","master_detail"].indexOf(field.type) > -1 && field.reference_to === objectName;
|
|
8301
|
-
// });
|
|
8302
|
-
// const globalFilter = [relatedKey,'=',recordId];
|
|
8303
|
-
// const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema);
|
|
8304
|
-
// const options = {
|
|
8305
|
-
// globalFilter,
|
|
8306
|
-
// defaults: {
|
|
8307
|
-
// listSchema: { headerToolbar:[],columnsTogglable:false },
|
|
8308
|
-
// headerSchema: recordRelatedListHeader
|
|
8309
|
-
// },
|
|
8310
|
-
// showHeader: true
|
|
8311
|
-
// }
|
|
8312
|
-
// const amisSchema= (await getListSchema(null, relatedObjectName, firstListViewName, options)).amisSchema;
|
|
8313
|
-
// return {
|
|
8314
|
-
// uiSchema: relatedObjectUiSchema,
|
|
8315
|
-
// amisSchema: {
|
|
8316
|
-
// type: "service",
|
|
8317
|
-
// data: {
|
|
8318
|
-
// masterObjectName: objectName,
|
|
8319
|
-
// masterRecordId: "${recordId}",
|
|
8320
|
-
// relatedKey: relatedKey,
|
|
8321
|
-
// objectName: relatedObjectName,
|
|
8322
|
-
// listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
8323
|
-
// },
|
|
8324
|
-
// body:[
|
|
8325
|
-
// {
|
|
8326
|
-
// ...amisSchema,
|
|
8327
|
-
// data: {
|
|
8328
|
-
// filter: ["${relatedKey}", "=", "${masterRecordId}"],
|
|
8329
|
-
// objectName: "${objectName}",
|
|
8330
|
-
// recordId: "${masterRecordId}",
|
|
8331
|
-
// ...{[relatedKey]: getRelatedFieldValue(objectName, "${recordId}", relatedSchema.uiSchema, relatedKey)}
|
|
8332
|
-
// }
|
|
8333
|
-
// }
|
|
8334
|
-
// ]
|
|
8335
|
-
// }
|
|
8336
|
-
// };
|
|
8337
|
-
// }
|
|
8338
|
-
|
|
8339
8350
|
|
|
8340
8351
|
// 获取单个相关表
|
|
8341
8352
|
async function getObjectRelated(
|