@steedos-widgets/amis-lib 1.2.0-beta.0 → 1.2.0-beta.2
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 +187 -189
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +187 -189
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +190 -192
- 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 +2 -35
- package/dist/types/lib/objectsRelated.d.ts +4 -17
- package/dist/types/schema/standard_delete.amis.d.ts +0 -6
- package/dist/types/schema/standard_new.amis.d.ts +3 -1
- package/dist/types/standard/button.d.ts +3 -7
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _$1 = require('lodash');
|
|
6
|
-
var isPlainObject = require('lodash/isPlainObject');
|
|
7
6
|
var amisLib = require('@steedos-widgets/amis-lib');
|
|
7
|
+
var isPlainObject = require('lodash/isPlainObject');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
|
@@ -361,7 +361,7 @@ const getSteedosAuth = () => {
|
|
|
361
361
|
* @Author: baozhoutao@steedos.com
|
|
362
362
|
* @Date: 2022-08-16 17:02:08
|
|
363
363
|
* @LastEditors: baozhoutao@steedos.com
|
|
364
|
-
* @LastEditTime: 2023-
|
|
364
|
+
* @LastEditTime: 2023-04-11 09:57:37
|
|
365
365
|
* @Description:
|
|
366
366
|
*/
|
|
367
367
|
|
|
@@ -388,10 +388,11 @@ const Router = {
|
|
|
388
388
|
},
|
|
389
389
|
getObjectDetailPath(props){
|
|
390
390
|
const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
|
|
391
|
+
// var urlParams = new URLSearchParams(window.location.search);
|
|
391
392
|
// if(objectName === 'instances'){
|
|
392
393
|
// return `/workflow/space/\${context.tenantId}/\${listName}/${recordId}`;
|
|
393
394
|
// }
|
|
394
|
-
const displayAs =
|
|
395
|
+
const displayAs = Router.getTabDisplayAs(objectName); //urlParams.get("display") ||
|
|
395
396
|
if(_templateType === 'JavaScript'){
|
|
396
397
|
return `/app/${appId}/${objectName}/view/${recordId}?display=${displayAs}&side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
397
398
|
}
|
|
@@ -407,7 +408,7 @@ const Router = {
|
|
|
407
408
|
* @Author: baozhoutao@steedos.com
|
|
408
409
|
* @Date: 2022-05-23 09:53:08
|
|
409
410
|
* @LastEditors: baozhoutao@steedos.com
|
|
410
|
-
* @LastEditTime: 2023-
|
|
411
|
+
* @LastEditTime: 2023-04-10 11:22:54
|
|
411
412
|
* @Description:
|
|
412
413
|
*/
|
|
413
414
|
|
|
@@ -602,6 +603,7 @@ async function getFieldTpl (field, options){
|
|
|
602
603
|
case 'number':
|
|
603
604
|
case 'currency':
|
|
604
605
|
return await getNumberTpl(field);
|
|
606
|
+
case 'percent':
|
|
605
607
|
case 'formula':
|
|
606
608
|
case 'summary':
|
|
607
609
|
return getUiFieldTpl(field)
|
|
@@ -634,7 +636,7 @@ async function getFieldsTemplate(fields, expand){
|
|
|
634
636
|
if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
635
637
|
fieldsName.push(`${field.name}`);
|
|
636
638
|
}
|
|
637
|
-
if(_$1.includes(['time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
639
|
+
if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
638
640
|
displayFields.push(`${field.name}`);
|
|
639
641
|
}
|
|
640
642
|
}
|
|
@@ -679,11 +681,7 @@ function getRecordPermissionsTemplate(){
|
|
|
679
681
|
}
|
|
680
682
|
|
|
681
683
|
async function getFindOneQuery$1(object, recordId, fields, options){
|
|
682
|
-
let queryOptions = ""
|
|
683
|
-
|
|
684
|
-
if(recordId){
|
|
685
|
-
queryOptions = `(filters:["${object.idFieldName}", "=", "${recordId}"])`;
|
|
686
|
-
}
|
|
684
|
+
let queryOptions = `(filters:["${object.idFieldName}", "=", "\${recordId}"])`;
|
|
687
685
|
let alias = "data";
|
|
688
686
|
if(options){
|
|
689
687
|
if(options.alias){
|
|
@@ -1392,8 +1390,8 @@ var config = {
|
|
|
1392
1390
|
/*
|
|
1393
1391
|
* @Author: baozhoutao@steedos.com
|
|
1394
1392
|
* @Date: 2022-11-01 15:51:00
|
|
1395
|
-
* @LastEditors:
|
|
1396
|
-
* @LastEditTime: 2023-
|
|
1393
|
+
* @LastEditors: Please set LastEditors
|
|
1394
|
+
* @LastEditTime: 2023-04-11 13:58:24
|
|
1397
1395
|
* @Description:
|
|
1398
1396
|
*/
|
|
1399
1397
|
|
|
@@ -1411,6 +1409,36 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1411
1409
|
if (payload && payload.schema) {
|
|
1412
1410
|
formSchema = _.isString(payload.schema) ? JSON.parse(payload.schema) : payload.schema;
|
|
1413
1411
|
}
|
|
1412
|
+
|
|
1413
|
+
const _master = api.body._master;
|
|
1414
|
+
if(_master && _master._isRelated){
|
|
1415
|
+
const relatedKey = _master.relatedKey;
|
|
1416
|
+
const masterObjectName = _master.objectName;
|
|
1417
|
+
const recordId = _master.recordId;
|
|
1418
|
+
let relatedKeySaveValue = recordId;
|
|
1419
|
+
const fields = ${JSON.stringify(uiSchema.fields)};
|
|
1420
|
+
const relatedField = fields[relatedKey];
|
|
1421
|
+
if(relatedField.reference_to_field && relatedField.reference_to_field !== '_id'){
|
|
1422
|
+
relatedKeySaveValue = _master.record[relatedField.reference_to_field];
|
|
1423
|
+
}
|
|
1424
|
+
let defaultData = {};
|
|
1425
|
+
let relatedKeyValue;
|
|
1426
|
+
if(!_.isString(relatedField.reference_to)){
|
|
1427
|
+
relatedKeyValue = { o: masterObjectName, ids: [relatedKeySaveValue] };
|
|
1428
|
+
}else if (relatedField.multiple) {
|
|
1429
|
+
relatedKeyValue = [relatedKeySaveValue];
|
|
1430
|
+
} else {
|
|
1431
|
+
relatedKeyValue = relatedKeySaveValue;
|
|
1432
|
+
}
|
|
1433
|
+
defaultData[relatedKey]=relatedKeyValue;
|
|
1434
|
+
if(payload.schema){
|
|
1435
|
+
// 表单微页面第一层要求是page
|
|
1436
|
+
formSchema.data.defaultData = defaultData;
|
|
1437
|
+
}else{
|
|
1438
|
+
formSchema.defaultData = defaultData;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1414
1442
|
return {
|
|
1415
1443
|
data: formSchema
|
|
1416
1444
|
};
|
|
@@ -1434,7 +1462,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1434
1462
|
"data": {
|
|
1435
1463
|
"$master": "$$",
|
|
1436
1464
|
"_master": "${_master}",
|
|
1437
|
-
"
|
|
1465
|
+
"_master._isRelated": "${_isRelated}",
|
|
1466
|
+
"_master.relatedKey": "${relatedKey}",
|
|
1438
1467
|
"appId": "${appId}",
|
|
1439
1468
|
"objectName": "${objectName}",
|
|
1440
1469
|
"context": "${context}",
|
|
@@ -1452,7 +1481,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1452
1481
|
"messages": {},
|
|
1453
1482
|
"schemaApi": {
|
|
1454
1483
|
"data": {
|
|
1455
|
-
"isLookup": "${isLookup}"
|
|
1484
|
+
"isLookup": "${isLookup}",
|
|
1485
|
+
"_master": "${_master}"
|
|
1456
1486
|
},
|
|
1457
1487
|
"url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
|
|
1458
1488
|
"method": "get",
|
|
@@ -1490,7 +1520,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1490
1520
|
* @Author: baozhoutao@steedos.com
|
|
1491
1521
|
* @Date: 2022-07-13 15:18:03
|
|
1492
1522
|
* @LastEditors: baozhoutao@steedos.com
|
|
1493
|
-
* @LastEditTime:
|
|
1523
|
+
* @LastEditTime: 2023-04-11 10:34:26
|
|
1494
1524
|
* @Description:
|
|
1495
1525
|
*/
|
|
1496
1526
|
|
|
@@ -1498,6 +1528,13 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
|
|
|
1498
1528
|
const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
|
|
1499
1529
|
const page = await fetchAPI(api);
|
|
1500
1530
|
if (page && page.schema) {
|
|
1531
|
+
page.schema = JSON.parse(page.schema);
|
|
1532
|
+
if(page.schema.data){
|
|
1533
|
+
delete page.schema.data.recordId;
|
|
1534
|
+
delete page.schema.data.objectName;
|
|
1535
|
+
delete page.schema.data.context;
|
|
1536
|
+
delete page.schema.data.global;
|
|
1537
|
+
}
|
|
1501
1538
|
return page;
|
|
1502
1539
|
}
|
|
1503
1540
|
}
|
|
@@ -1575,8 +1612,8 @@ const getSchema$3 = async (uiSchema, ctx) => {
|
|
|
1575
1612
|
/*
|
|
1576
1613
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
1577
1614
|
* @Date: 2023-03-22 09:31:21
|
|
1578
|
-
* @LastEditors:
|
|
1579
|
-
* @LastEditTime: 2023-
|
|
1615
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
1616
|
+
* @LastEditTime: 2023-04-06 16:04:20
|
|
1580
1617
|
*/
|
|
1581
1618
|
const getSchema$2 = (uiSchema)=>{
|
|
1582
1619
|
return {
|
|
@@ -1606,15 +1643,11 @@ const getSchema$2 = (uiSchema)=>{
|
|
|
1606
1643
|
},
|
|
1607
1644
|
"adaptor": `
|
|
1608
1645
|
if(payload.errors){
|
|
1609
|
-
|
|
1610
|
-
|
|
1646
|
+
payload.status = 2;
|
|
1647
|
+
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
1611
1648
|
}
|
|
1612
1649
|
return payload;
|
|
1613
1650
|
`,
|
|
1614
|
-
},
|
|
1615
|
-
"messages": {
|
|
1616
|
-
"success": "删除成功",
|
|
1617
|
-
"failed": "删除失败"
|
|
1618
1651
|
}
|
|
1619
1652
|
},
|
|
1620
1653
|
"actionType": "ajax"
|
|
@@ -1977,7 +2010,7 @@ const StandardButtons = {
|
|
|
1977
2010
|
getStandardNew: async (uiSchema, ctx)=>{
|
|
1978
2011
|
return {
|
|
1979
2012
|
type: 'amis_button',
|
|
1980
|
-
amis_schema: await getSchema$4()
|
|
2013
|
+
amis_schema: await getSchema$4(uiSchema)
|
|
1981
2014
|
}
|
|
1982
2015
|
},
|
|
1983
2016
|
getStandardEdit: async (uiSchema, ctx)=>{
|
|
@@ -2061,7 +2094,7 @@ function getButtonVisibleOn$1(button){
|
|
|
2061
2094
|
if(visible.trim().startsWith('function')){
|
|
2062
2095
|
return `${visible}.apply({
|
|
2063
2096
|
object: uiSchema
|
|
2064
|
-
}, [objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2097
|
+
}, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2065
2098
|
}
|
|
2066
2099
|
return visible;
|
|
2067
2100
|
}
|
|
@@ -3191,9 +3224,8 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3191
3224
|
|
|
3192
3225
|
let body = [
|
|
3193
3226
|
{
|
|
3194
|
-
"type": "
|
|
3195
|
-
"
|
|
3196
|
-
data: { "&":"$$", objectName: name, _id: recordId, recordPermissions: "${record.recordPermissions}", uiSchema: objectSchema},
|
|
3227
|
+
"type": "wrapper",
|
|
3228
|
+
"className": "p-0",
|
|
3197
3229
|
"body": [
|
|
3198
3230
|
{
|
|
3199
3231
|
"type": "grid",
|
|
@@ -3201,14 +3233,14 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3201
3233
|
"className": "flex justify-between"
|
|
3202
3234
|
}
|
|
3203
3235
|
],
|
|
3204
|
-
"messages": {},
|
|
3205
3236
|
"hiddenOn": "${recordLoaded != true}"
|
|
3206
3237
|
}
|
|
3207
3238
|
];
|
|
3208
3239
|
|
|
3209
3240
|
if(showRecordTitle){
|
|
3210
3241
|
body.push({
|
|
3211
|
-
"type": "
|
|
3242
|
+
"type": "wrapper",
|
|
3243
|
+
"className": "p-0",
|
|
3212
3244
|
"body": [
|
|
3213
3245
|
{
|
|
3214
3246
|
"type": "grid",
|
|
@@ -3216,16 +3248,15 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3216
3248
|
"className": "flex justify-between"
|
|
3217
3249
|
}
|
|
3218
3250
|
],
|
|
3219
|
-
"messages": {},
|
|
3220
3251
|
"hiddenOn": "${recordLoaded == true}"
|
|
3221
3252
|
});
|
|
3222
3253
|
}
|
|
3223
3254
|
|
|
3224
3255
|
return {
|
|
3225
3256
|
type: 'service',
|
|
3226
|
-
|
|
3257
|
+
id: `page_readonly_${name}_header`,
|
|
3227
3258
|
name: `page`,
|
|
3228
|
-
data: {
|
|
3259
|
+
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
3229
3260
|
body: body,
|
|
3230
3261
|
className: ''
|
|
3231
3262
|
}
|
|
@@ -3280,7 +3311,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
3280
3311
|
"body": [
|
|
3281
3312
|
{
|
|
3282
3313
|
"type": "tpl",
|
|
3283
|
-
"tpl": `<a class="text-black text-base font-bold" href="/app/\${appId}/\${
|
|
3314
|
+
"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>`,
|
|
3284
3315
|
"inline": false,
|
|
3285
3316
|
"wrapperComponent": "",
|
|
3286
3317
|
"className": "",
|
|
@@ -3321,17 +3352,22 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
3321
3352
|
async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
|
|
3322
3353
|
}
|
|
3323
3354
|
|
|
3324
|
-
const getDisplayAsButton = function(showDisplayAs){
|
|
3355
|
+
const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
3356
|
+
let displayAs = amisLib.Router.getTabDisplayAs(objectName);
|
|
3325
3357
|
let buttons = [
|
|
3326
3358
|
{
|
|
3327
3359
|
"type": "button",
|
|
3328
3360
|
"label": "表格",
|
|
3329
|
-
"onClick": "
|
|
3361
|
+
"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');",
|
|
3362
|
+
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
3363
|
+
"rightIconClassName": "m-l-sm"
|
|
3330
3364
|
},
|
|
3331
3365
|
{
|
|
3332
3366
|
"type": "button",
|
|
3333
3367
|
"label": "分栏视图",
|
|
3334
|
-
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);"
|
|
3368
|
+
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
3369
|
+
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
3370
|
+
"rightIconClassName": "m-l-sm"
|
|
3335
3371
|
}
|
|
3336
3372
|
];
|
|
3337
3373
|
return {
|
|
@@ -3473,7 +3509,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
3473
3509
|
}
|
|
3474
3510
|
}
|
|
3475
3511
|
},
|
|
3476
|
-
showDisplayAs? getDisplayAsButton() : {}
|
|
3512
|
+
showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
|
|
3477
3513
|
]
|
|
3478
3514
|
}else {
|
|
3479
3515
|
return [
|
|
@@ -3554,7 +3590,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
3554
3590
|
}
|
|
3555
3591
|
}
|
|
3556
3592
|
},
|
|
3557
|
-
showDisplayAs? getDisplayAsButton() : {}
|
|
3593
|
+
showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
|
|
3558
3594
|
// {
|
|
3559
3595
|
// "type": "search-box",
|
|
3560
3596
|
// "align": "right",
|
|
@@ -3844,13 +3880,14 @@ function getLookupSapceUserTreeSchema(){
|
|
|
3844
3880
|
"headers": {
|
|
3845
3881
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
3846
3882
|
},
|
|
3847
|
-
"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
|
|
3883
|
+
"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 ",
|
|
3848
3884
|
"requestAdaptor": "\n ",
|
|
3849
3885
|
"data": {
|
|
3850
3886
|
"query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
|
|
3851
3887
|
},
|
|
3852
3888
|
"messages": {
|
|
3853
|
-
}
|
|
3889
|
+
},
|
|
3890
|
+
"cache": 300000
|
|
3854
3891
|
},
|
|
3855
3892
|
"onEvent": {
|
|
3856
3893
|
"change": {
|
|
@@ -4241,20 +4278,20 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
4241
4278
|
|
|
4242
4279
|
if(referenceTo){
|
|
4243
4280
|
// 字段值单独走一个请求合并到source的同一个GraphQL接口中
|
|
4244
|
-
const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null,
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4281
|
+
const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
|
|
4282
|
+
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
4283
|
+
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
4284
|
+
], {
|
|
4248
4285
|
alias: "defaultValueOptions",
|
|
4249
4286
|
filters: "{__options_filters}",
|
|
4250
4287
|
count: false
|
|
4251
4288
|
});
|
|
4252
4289
|
apiInfo = await getApi$1({
|
|
4253
4290
|
name: referenceTo.objectName
|
|
4254
|
-
}, null,
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4291
|
+
}, null, [
|
|
4292
|
+
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
4293
|
+
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
4294
|
+
], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`, moreQueries: [defaultValueOptionsQueryData.query]});
|
|
4258
4295
|
|
|
4259
4296
|
apiInfo.adaptor = `
|
|
4260
4297
|
const data = payload.data;
|
|
@@ -5415,8 +5452,9 @@ function getReadonlyFormAdaptor(fields){
|
|
|
5415
5452
|
async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
5416
5453
|
return {
|
|
5417
5454
|
method: "post",
|
|
5418
|
-
url: getApi$2()+"
|
|
5455
|
+
url: getApi$2()+"&recordId=${recordId}",
|
|
5419
5456
|
cache: API_CACHE,
|
|
5457
|
+
// requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
|
|
5420
5458
|
adaptor: getReadonlyFormAdaptor(fields),
|
|
5421
5459
|
data: await getFindOneQuery$1(object, recordId, fields, options),
|
|
5422
5460
|
headers: {
|
|
@@ -5523,6 +5561,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
5523
5561
|
data.global = "${global}";
|
|
5524
5562
|
data.context = "${context}";
|
|
5525
5563
|
data.defaultData = "${defaultData}";
|
|
5564
|
+
|
|
5526
5565
|
return {
|
|
5527
5566
|
method: "post",
|
|
5528
5567
|
url: getApi$2(),
|
|
@@ -5891,7 +5930,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
5891
5930
|
keepItemSelectionOnPageChange: true,
|
|
5892
5931
|
api: await getTableApi(objectSchema, fields, options),
|
|
5893
5932
|
hiddenOn: options.tableHiddenOn,
|
|
5894
|
-
autoFillHeight: true,
|
|
5933
|
+
autoFillHeight: options.isRelated ? false : true,
|
|
5895
5934
|
className: `flex-auto ${crudClassName || ""}`,
|
|
5896
5935
|
crudClassName: crudClassName,
|
|
5897
5936
|
},
|
|
@@ -5934,11 +5973,11 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
5934
5973
|
id: `service_${id}`,
|
|
5935
5974
|
name: `page`,
|
|
5936
5975
|
data: {
|
|
5937
|
-
objectName: objectSchema.name,
|
|
5938
|
-
_id: null,
|
|
5976
|
+
// objectName: objectSchema.name,
|
|
5977
|
+
// _id: null,
|
|
5939
5978
|
recordPermissions: objectSchema.permissions,
|
|
5940
5979
|
uiSchema: objectSchema,
|
|
5941
|
-
loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
5980
|
+
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
5942
5981
|
},
|
|
5943
5982
|
body: body
|
|
5944
5983
|
}
|
|
@@ -6051,6 +6090,10 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
6051
6090
|
"objectName": "${_master.objectName}"
|
|
6052
6091
|
},
|
|
6053
6092
|
"expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
|
|
6093
|
+
},
|
|
6094
|
+
{
|
|
6095
|
+
"args": {},
|
|
6096
|
+
"actionType": "closeDialog"
|
|
6054
6097
|
}
|
|
6055
6098
|
]
|
|
6056
6099
|
}
|
|
@@ -6397,7 +6440,7 @@ function getButtonVisibleOn(button){
|
|
|
6397
6440
|
// return 'false';
|
|
6398
6441
|
// }
|
|
6399
6442
|
if(visible.trim().startsWith('function')){
|
|
6400
|
-
return `${visible}(objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6443
|
+
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6401
6444
|
}
|
|
6402
6445
|
return visible;
|
|
6403
6446
|
}
|
|
@@ -6562,6 +6605,11 @@ async function getTableApi(mainObject, fields, options){
|
|
|
6562
6605
|
|
|
6563
6606
|
let valueField = mainObject.key_field || '_id';
|
|
6564
6607
|
const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
6608
|
+
|
|
6609
|
+
if(options.isRelated){
|
|
6610
|
+
api.url += "&recordId=${recordId}";
|
|
6611
|
+
}
|
|
6612
|
+
|
|
6565
6613
|
api.data.$term = "$term";
|
|
6566
6614
|
api.data.$self = "$$";
|
|
6567
6615
|
api.data.filter = "$filter";
|
|
@@ -6681,11 +6729,36 @@ async function getTableApi(mainObject, fields, options){
|
|
|
6681
6729
|
if(!_.isEmpty(systemFilters)){
|
|
6682
6730
|
filters = systemFilters;
|
|
6683
6731
|
};
|
|
6684
|
-
|
|
6685
6732
|
if(api.data.$self.additionalFilters){
|
|
6686
6733
|
userFilters.push(api.data.$self.additionalFilters)
|
|
6687
6734
|
}
|
|
6688
6735
|
|
|
6736
|
+
if(api.data.$self._isRelated){
|
|
6737
|
+
const self = api.data.$self;
|
|
6738
|
+
const relatedKey = self.relatedKey;
|
|
6739
|
+
const recordId = self.recordId;
|
|
6740
|
+
const refField = self.uiSchema.fields[relatedKey];
|
|
6741
|
+
const masterRecord = self._master.record;
|
|
6742
|
+
const masterObjectName = self._master.objectName;
|
|
6743
|
+
let relatedValue = recordId;
|
|
6744
|
+
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
6745
|
+
relatedValue = masterRecord[refField.reference_to_field]
|
|
6746
|
+
}
|
|
6747
|
+
let relatedFilters;
|
|
6748
|
+
if (
|
|
6749
|
+
refField._reference_to ||
|
|
6750
|
+
(refField.reference_to && !_.isString(refField.reference_to))
|
|
6751
|
+
) {
|
|
6752
|
+
relatedFilters = [
|
|
6753
|
+
[relatedKey + "/o", "=", masterObjectName],
|
|
6754
|
+
[relatedKey + "/ids", "=", relatedValue],
|
|
6755
|
+
];
|
|
6756
|
+
} else {
|
|
6757
|
+
relatedFilters = [relatedKey, "=", relatedValue];
|
|
6758
|
+
}
|
|
6759
|
+
userFilters.push(relatedFilters)
|
|
6760
|
+
}
|
|
6761
|
+
|
|
6689
6762
|
if(!_.isEmpty(userFilters)){
|
|
6690
6763
|
if(_.isEmpty(filters)){
|
|
6691
6764
|
filters = userFilters;
|
|
@@ -6808,7 +6881,7 @@ async function getApi(object, recordId, fields, options){
|
|
|
6808
6881
|
const data = await getFindQuery(object, recordId, fields, options);
|
|
6809
6882
|
return {
|
|
6810
6883
|
method: "post",
|
|
6811
|
-
url: getApi$2(),
|
|
6884
|
+
url: getApi$2(), // + "&recordId=${recordId}"
|
|
6812
6885
|
data: data,
|
|
6813
6886
|
headers: {
|
|
6814
6887
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -7443,7 +7516,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
7443
7516
|
* @Author: baozhoutao@steedos.com
|
|
7444
7517
|
* @Date: 2022-07-05 15:55:39
|
|
7445
7518
|
* @LastEditors: Please set LastEditors
|
|
7446
|
-
* @LastEditTime: 2023-
|
|
7519
|
+
* @LastEditTime: 2023-04-11 13:13:00
|
|
7447
7520
|
* @Description:
|
|
7448
7521
|
*/
|
|
7449
7522
|
|
|
@@ -7515,7 +7588,7 @@ async function getObjectRelatedList(
|
|
|
7515
7588
|
|
|
7516
7589
|
// 获取单个相关表
|
|
7517
7590
|
async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObjectName, relatedKey, ctx){
|
|
7518
|
-
let { top, perPage,
|
|
7591
|
+
let { top, perPage, appId, relatedLabel, className, columns, sort, filters, visible_on } = ctx;
|
|
7519
7592
|
// console.log('getRecordDetailRelatedListSchema==>',objectName,recordId,relatedObjectName)
|
|
7520
7593
|
const relatedObjectUiSchema = await getUISchema(relatedObjectName);
|
|
7521
7594
|
if(!relatedObjectUiSchema){
|
|
@@ -7550,6 +7623,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7550
7623
|
relatedKey = mainRelated[relatedObjectName];
|
|
7551
7624
|
}
|
|
7552
7625
|
let globalFilter = null;
|
|
7626
|
+
// TODO: refField变量去掉,写到amis运行时脚本中,uiSchema.fields[relatedKey];可以取到
|
|
7553
7627
|
const refField = await getField(relatedObjectName, relatedKey);
|
|
7554
7628
|
|
|
7555
7629
|
if(!refField){
|
|
@@ -7564,24 +7638,22 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7564
7638
|
}
|
|
7565
7639
|
}
|
|
7566
7640
|
}
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
relatedValue = masterRecord[refField.reference_to_field];
|
|
7572
|
-
}
|
|
7641
|
+
// if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7642
|
+
// const masterRecord = await getRecord(objectName, recordId, [refField.reference_to_field]);
|
|
7643
|
+
// relatedValue = masterRecord[refField.reference_to_field]
|
|
7644
|
+
// }
|
|
7573
7645
|
|
|
7574
|
-
if (
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
) {
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
} else {
|
|
7583
|
-
|
|
7584
|
-
}
|
|
7646
|
+
// if (
|
|
7647
|
+
// refField._reference_to ||
|
|
7648
|
+
// (refField.reference_to && !isString(refField.reference_to))
|
|
7649
|
+
// ) {
|
|
7650
|
+
// globalFilter = [
|
|
7651
|
+
// [`${relatedKey}/o`, "=", objectName],
|
|
7652
|
+
// [`${relatedKey}/ids`, "=", relatedValue],
|
|
7653
|
+
// ];
|
|
7654
|
+
// } else {
|
|
7655
|
+
// globalFilter = [`${relatedKey}`, "=", relatedValue];
|
|
7656
|
+
// }
|
|
7585
7657
|
const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
|
|
7586
7658
|
const componentId = `steedos-record-related-list-${relatedObjectName}`;
|
|
7587
7659
|
const options = {
|
|
@@ -7606,9 +7678,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7606
7678
|
top: top,
|
|
7607
7679
|
perPage: perPage,
|
|
7608
7680
|
setDataToComponentId: componentId,
|
|
7609
|
-
tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
7681
|
+
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
7610
7682
|
appId: appId,
|
|
7611
|
-
crudClassName: 'border-t border-slate-300',
|
|
7683
|
+
crudClassName: 'border-t border-slate-300 hidden',
|
|
7612
7684
|
...ctx
|
|
7613
7685
|
};
|
|
7614
7686
|
const amisSchema= (await getRelatedListSchema(relatedObjectName, 'all', options)).amisSchema;
|
|
@@ -7620,33 +7692,14 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7620
7692
|
amisSchema: {
|
|
7621
7693
|
type: "service",
|
|
7622
7694
|
id: componentId,
|
|
7623
|
-
className: `steedos-record-related-list rounded border border-slate-300 bg-gray-100 mb-4 ${className}`,
|
|
7695
|
+
className: `steedos-record-related-list ${componentId} rounded border border-slate-300 bg-gray-100 mb-4 ${className}`,
|
|
7624
7696
|
data: {
|
|
7625
|
-
"&": "$$",
|
|
7626
|
-
appId: "${appId}",
|
|
7627
|
-
app_id: "${appId}",
|
|
7628
|
-
masterObjectName: objectName,
|
|
7629
|
-
masterRecordId: "${recordId}",
|
|
7630
7697
|
relatedKey: relatedKey,
|
|
7631
|
-
objectName: relatedObjectName,
|
|
7632
7698
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
7633
7699
|
_isRelated: true
|
|
7634
7700
|
},
|
|
7635
7701
|
body:[
|
|
7636
|
-
|
|
7637
|
-
...amisSchema,
|
|
7638
|
-
data: {
|
|
7639
|
-
"&": "$$",
|
|
7640
|
-
appId: "${appId}",
|
|
7641
|
-
app_id: "${appId}",
|
|
7642
|
-
relatedKey: relatedKey,
|
|
7643
|
-
objectName: "${objectName}",
|
|
7644
|
-
recordId: "${masterRecordId}",
|
|
7645
|
-
defaultData: {
|
|
7646
|
-
...{[relatedKey]: getRelatedFieldValue(objectName, relatedValue, relatedObjectUiSchema, relatedKey)}
|
|
7647
|
-
}
|
|
7648
|
-
}
|
|
7649
|
-
}
|
|
7702
|
+
amisSchema
|
|
7650
7703
|
]
|
|
7651
7704
|
}
|
|
7652
7705
|
};
|
|
@@ -7685,13 +7738,13 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
|
|
|
7685
7738
|
columns = getListViewColumns(listView, ctx.formFactor);
|
|
7686
7739
|
sort = getListViewSort(listView);
|
|
7687
7740
|
filter = getListViewFilter(listView);
|
|
7688
|
-
if(
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
}else if(ctx.globalFilter && (!filter || !filter.length)){
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
}
|
|
7741
|
+
// if(isArray(ctx.globalFilter) && ctx.globalFilter.length && isArray(filter) && filter.length){
|
|
7742
|
+
// // 都有值
|
|
7743
|
+
// filter = [ctx.globalFilter, 'and', filter]
|
|
7744
|
+
// }else if(ctx.globalFilter && (!filter || !filter.length)){
|
|
7745
|
+
// // globalFilter有值,filter无值
|
|
7746
|
+
// filter = ctx.globalFilter;
|
|
7747
|
+
// }
|
|
7695
7748
|
filtersFunction = listView && listView._filters;
|
|
7696
7749
|
}else {
|
|
7697
7750
|
const isNameField = _$1.find(
|
|
@@ -7701,9 +7754,9 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
|
|
|
7701
7754
|
}
|
|
7702
7755
|
);
|
|
7703
7756
|
columns = isNameField ? [isNameField.name] : ['name'];
|
|
7704
|
-
if(ctx.globalFilter){
|
|
7705
|
-
|
|
7706
|
-
}
|
|
7757
|
+
// if(ctx.globalFilter){
|
|
7758
|
+
// filter = ctx.globalFilter;
|
|
7759
|
+
// }
|
|
7707
7760
|
}
|
|
7708
7761
|
|
|
7709
7762
|
return {
|
|
@@ -7727,7 +7780,7 @@ function getRelatedListProps(uiSchema, listViewName, ctx) {
|
|
|
7727
7780
|
return {
|
|
7728
7781
|
columns: ctx.columns,
|
|
7729
7782
|
sort,
|
|
7730
|
-
filter: ctx.globalFilter,
|
|
7783
|
+
// filter: ctx.globalFilter,
|
|
7731
7784
|
filtersFunction: filtersFunction
|
|
7732
7785
|
}
|
|
7733
7786
|
} else {
|
|
@@ -7766,6 +7819,16 @@ async function getRelatedListSchema(
|
|
|
7766
7819
|
delete ctx.filters;
|
|
7767
7820
|
|
|
7768
7821
|
delete ctx.globalFilter;
|
|
7822
|
+
|
|
7823
|
+
const adaptor = `
|
|
7824
|
+
if(setDataToComponentId){
|
|
7825
|
+
if(payload.data.count){
|
|
7826
|
+
setTimeout(function(){
|
|
7827
|
+
window.$("." + setDataToComponentId + " .antd-Crud").removeClass("hidden");
|
|
7828
|
+
}, 10);
|
|
7829
|
+
}
|
|
7830
|
+
};
|
|
7831
|
+
`;
|
|
7769
7832
|
const amisSchema = {
|
|
7770
7833
|
"type": "steedos-object-table",
|
|
7771
7834
|
"objectApiName": objectName,
|
|
@@ -7774,6 +7837,8 @@ async function getRelatedListSchema(
|
|
|
7774
7837
|
"filters": listviewFilter,
|
|
7775
7838
|
"filtersFunction": filtersFunction,
|
|
7776
7839
|
"sort": listViewSort,
|
|
7840
|
+
"filterVisible": false,
|
|
7841
|
+
adaptor,
|
|
7777
7842
|
"ctx": ctx
|
|
7778
7843
|
};
|
|
7779
7844
|
// console.log(`getRelatedListSchema amisSchema`, amisSchema);
|
|
@@ -7786,8 +7851,8 @@ async function getRelatedListSchema(
|
|
|
7786
7851
|
/*
|
|
7787
7852
|
* @Author: baozhoutao@steedos.com
|
|
7788
7853
|
* @Date: 2022-07-05 15:55:39
|
|
7789
|
-
* @LastEditors:
|
|
7790
|
-
* @LastEditTime: 2023-
|
|
7854
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
7855
|
+
* @LastEditTime: 2023-04-11 11:28:11
|
|
7791
7856
|
* @Description:
|
|
7792
7857
|
*/
|
|
7793
7858
|
|
|
@@ -7959,14 +8024,14 @@ async function getField(objectName, fieldName) {
|
|
|
7959
8024
|
async function getFormSchema(objectName, ctx) {
|
|
7960
8025
|
const uiSchema = await getUISchema(objectName);
|
|
7961
8026
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
7962
|
-
|
|
8027
|
+
console.log(`getFormSchema====>`, amisSchema);
|
|
7963
8028
|
return {
|
|
7964
8029
|
uiSchema,
|
|
7965
8030
|
amisSchema,
|
|
7966
8031
|
};
|
|
7967
8032
|
}
|
|
7968
8033
|
|
|
7969
|
-
// 获取只读页面
|
|
8034
|
+
// 获取只读页面 recordId 已废弃, 函数签名保持不变, 但recordId变量不可再使用, 请使用运行时的${recordId}
|
|
7970
8035
|
async function getViewSchema(objectName, recordId, ctx) {
|
|
7971
8036
|
const uiSchema = await getUISchema(objectName);
|
|
7972
8037
|
const amisSchema = await getObjectDetail(uiSchema, recordId, ctx);
|
|
@@ -8151,6 +8216,7 @@ async function getTableSchema(
|
|
|
8151
8216
|
headerToolbarItems: ctx.headerToolbarItems,
|
|
8152
8217
|
buttons: await getListViewItemButtons(uiSchema, ctx)
|
|
8153
8218
|
});
|
|
8219
|
+
// console.log('getTableSchema====>amisSchema', amisSchema)
|
|
8154
8220
|
return {
|
|
8155
8221
|
uiSchema,
|
|
8156
8222
|
amisSchema,
|
|
@@ -8235,37 +8301,14 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
8235
8301
|
amisSchema: {
|
|
8236
8302
|
"type": "service",
|
|
8237
8303
|
"body": [
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
onEvent: {
|
|
8245
|
-
"recordLoaded": {
|
|
8246
|
-
"actions": [
|
|
8247
|
-
{
|
|
8248
|
-
"actionType": "reload",
|
|
8249
|
-
"data": {
|
|
8250
|
-
"name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
8251
|
-
"record": `\${event.data.record}`,
|
|
8252
|
-
"recordLoaded": true,
|
|
8253
|
-
}
|
|
8254
|
-
},
|
|
8255
|
-
{
|
|
8256
|
-
"actionType": "reload",
|
|
8257
|
-
"componentId": `page_readonly_${objectName}_header`, //刷新标题, 详细页面header service 嵌套太多, 导致仅刷新第一层service无法更新recordName
|
|
8258
|
-
"data": {
|
|
8259
|
-
"name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
8260
|
-
"record": `\${event.data.record}`,
|
|
8261
|
-
"recordLoaded": true,
|
|
8262
|
-
}
|
|
8263
|
-
}
|
|
8264
|
-
]
|
|
8265
|
-
}
|
|
8304
|
+
{
|
|
8305
|
+
"type": "steedos-record-detail-header",
|
|
8306
|
+
"label": "标题面板",
|
|
8307
|
+
"objectApiName": "${objectName}",
|
|
8308
|
+
"recordId": "${recordId}",
|
|
8309
|
+
"id": "u:48d2c28eb755"
|
|
8266
8310
|
},
|
|
8267
|
-
|
|
8268
|
-
content
|
|
8311
|
+
content
|
|
8269
8312
|
],
|
|
8270
8313
|
data: {
|
|
8271
8314
|
"_master.objectName": "${objectName}",
|
|
@@ -8292,51 +8335,6 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
8292
8335
|
}
|
|
8293
8336
|
}
|
|
8294
8337
|
|
|
8295
|
-
// export async function getRecordDetailRelatedListSchema(objectName,recordId,relatedObjectName){
|
|
8296
|
-
// // console.log('b==>',objectName,recordId,relatedObjectName)
|
|
8297
|
-
// const relatedObjectUiSchema = await getUISchema(relatedObjectName);
|
|
8298
|
-
// const { list_views, label , icon, fields } = relatedObjectUiSchema;
|
|
8299
|
-
// const firstListViewName = keys(list_views)[0];
|
|
8300
|
-
// const relatedKey = findKey(fields, function(field) {
|
|
8301
|
-
// return ["lookup","master_detail"].indexOf(field.type) > -1 && field.reference_to === objectName;
|
|
8302
|
-
// });
|
|
8303
|
-
// const globalFilter = [relatedKey,'=',recordId];
|
|
8304
|
-
// const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema);
|
|
8305
|
-
// const options = {
|
|
8306
|
-
// globalFilter,
|
|
8307
|
-
// defaults: {
|
|
8308
|
-
// listSchema: { headerToolbar:[],columnsTogglable:false },
|
|
8309
|
-
// headerSchema: recordRelatedListHeader
|
|
8310
|
-
// },
|
|
8311
|
-
// showHeader: true
|
|
8312
|
-
// }
|
|
8313
|
-
// const amisSchema= (await getListSchema(null, relatedObjectName, firstListViewName, options)).amisSchema;
|
|
8314
|
-
// return {
|
|
8315
|
-
// uiSchema: relatedObjectUiSchema,
|
|
8316
|
-
// amisSchema: {
|
|
8317
|
-
// type: "service",
|
|
8318
|
-
// data: {
|
|
8319
|
-
// masterObjectName: objectName,
|
|
8320
|
-
// masterRecordId: "${recordId}",
|
|
8321
|
-
// relatedKey: relatedKey,
|
|
8322
|
-
// objectName: relatedObjectName,
|
|
8323
|
-
// listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
8324
|
-
// },
|
|
8325
|
-
// body:[
|
|
8326
|
-
// {
|
|
8327
|
-
// ...amisSchema,
|
|
8328
|
-
// data: {
|
|
8329
|
-
// filter: ["${relatedKey}", "=", "${masterRecordId}"],
|
|
8330
|
-
// objectName: "${objectName}",
|
|
8331
|
-
// recordId: "${masterRecordId}",
|
|
8332
|
-
// ...{[relatedKey]: getRelatedFieldValue(objectName, "${recordId}", relatedSchema.uiSchema, relatedKey)}
|
|
8333
|
-
// }
|
|
8334
|
-
// }
|
|
8335
|
-
// ]
|
|
8336
|
-
// }
|
|
8337
|
-
// };
|
|
8338
|
-
// }
|
|
8339
|
-
|
|
8340
8338
|
|
|
8341
8339
|
// 获取单个相关表
|
|
8342
8340
|
async function getObjectRelated(
|