@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.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _$1 from 'lodash';
|
|
2
2
|
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, keys, sortBy, compact, toArray, mergeWith, isBoolean, omitBy, isNil, isString, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, has, filter, startsWith } from 'lodash';
|
|
3
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
4
3
|
import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
|
|
4
|
+
import isPlainObject from 'lodash/isPlainObject';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* @Author: baozhoutao@steedos.com
|
|
@@ -652,11 +652,7 @@ function getRecordPermissionsTemplate(){
|
|
|
652
652
|
}
|
|
653
653
|
|
|
654
654
|
async function getFindOneQuery$1(object, recordId, fields, options){
|
|
655
|
-
let queryOptions = ""
|
|
656
|
-
|
|
657
|
-
if(recordId){
|
|
658
|
-
queryOptions = `(filters:["${object.idFieldName}", "=", "${recordId}"])`;
|
|
659
|
-
}
|
|
655
|
+
let queryOptions = `(filters:["${object.idFieldName}", "=", "\${recordId}"])`;
|
|
660
656
|
let alias = "data";
|
|
661
657
|
if(options){
|
|
662
658
|
if(options.alias){
|
|
@@ -1365,8 +1361,8 @@ var config = {
|
|
|
1365
1361
|
/*
|
|
1366
1362
|
* @Author: baozhoutao@steedos.com
|
|
1367
1363
|
* @Date: 2022-11-01 15:51:00
|
|
1368
|
-
* @LastEditors:
|
|
1369
|
-
* @LastEditTime: 2023-
|
|
1364
|
+
* @LastEditors: Please set LastEditors
|
|
1365
|
+
* @LastEditTime: 2023-04-08 12:05:19
|
|
1370
1366
|
* @Description:
|
|
1371
1367
|
*/
|
|
1372
1368
|
|
|
@@ -1384,6 +1380,32 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1384
1380
|
if (payload && payload.schema) {
|
|
1385
1381
|
formSchema = _.isString(payload.schema) ? JSON.parse(payload.schema) : payload.schema;
|
|
1386
1382
|
}
|
|
1383
|
+
|
|
1384
|
+
const _master = api.body._master;
|
|
1385
|
+
if(_master && _master._isRelated){
|
|
1386
|
+
const relatedKey = _master.relatedKey;
|
|
1387
|
+
const masterObjectName = _master.objectName;
|
|
1388
|
+
const recordId = _master.recordId;
|
|
1389
|
+
const fields = ${JSON.stringify(uiSchema.fields)};
|
|
1390
|
+
const relatedField = fields[relatedKey];
|
|
1391
|
+
let defaultData = {};
|
|
1392
|
+
let relatedKeyValue;
|
|
1393
|
+
if(!_.isString(relatedField.reference_to)){
|
|
1394
|
+
relatedKeyValue = { o: masterObjectName, ids: [recordId] };
|
|
1395
|
+
}else if (relatedField.multiple) {
|
|
1396
|
+
relatedKeyValue = [recordId];
|
|
1397
|
+
} else {
|
|
1398
|
+
relatedKeyValue = recordId;
|
|
1399
|
+
}
|
|
1400
|
+
defaultData[relatedKey]=relatedKeyValue;
|
|
1401
|
+
if(payload.schema){
|
|
1402
|
+
// 表单微页面第一层要求是page
|
|
1403
|
+
formSchema.data.defaultData = defaultData;
|
|
1404
|
+
}else{
|
|
1405
|
+
formSchema.defaultData = defaultData;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1387
1409
|
return {
|
|
1388
1410
|
data: formSchema
|
|
1389
1411
|
};
|
|
@@ -1407,6 +1429,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1407
1429
|
"data": {
|
|
1408
1430
|
"$master": "$$",
|
|
1409
1431
|
"_master": "${_master}",
|
|
1432
|
+
"_master._isRelated": "${_isRelated}",
|
|
1433
|
+
"_master.relatedKey": "${relatedKey}",
|
|
1410
1434
|
"defaultData": "${defaultData}",
|
|
1411
1435
|
"appId": "${appId}",
|
|
1412
1436
|
"objectName": "${objectName}",
|
|
@@ -1425,7 +1449,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1425
1449
|
"messages": {},
|
|
1426
1450
|
"schemaApi": {
|
|
1427
1451
|
"data": {
|
|
1428
|
-
"isLookup": "${isLookup}"
|
|
1452
|
+
"isLookup": "${isLookup}",
|
|
1453
|
+
"_master": "${_master}"
|
|
1429
1454
|
},
|
|
1430
1455
|
"url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
|
|
1431
1456
|
"method": "get",
|
|
@@ -1548,8 +1573,8 @@ const getSchema$3 = async (uiSchema, ctx) => {
|
|
|
1548
1573
|
/*
|
|
1549
1574
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
1550
1575
|
* @Date: 2023-03-22 09:31:21
|
|
1551
|
-
* @LastEditors:
|
|
1552
|
-
* @LastEditTime: 2023-
|
|
1576
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
1577
|
+
* @LastEditTime: 2023-04-06 16:04:20
|
|
1553
1578
|
*/
|
|
1554
1579
|
const getSchema$2 = (uiSchema)=>{
|
|
1555
1580
|
return {
|
|
@@ -1579,15 +1604,11 @@ const getSchema$2 = (uiSchema)=>{
|
|
|
1579
1604
|
},
|
|
1580
1605
|
"adaptor": `
|
|
1581
1606
|
if(payload.errors){
|
|
1582
|
-
|
|
1583
|
-
|
|
1607
|
+
payload.status = 2;
|
|
1608
|
+
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
1584
1609
|
}
|
|
1585
1610
|
return payload;
|
|
1586
1611
|
`,
|
|
1587
|
-
},
|
|
1588
|
-
"messages": {
|
|
1589
|
-
"success": "删除成功",
|
|
1590
|
-
"failed": "删除失败"
|
|
1591
1612
|
}
|
|
1592
1613
|
},
|
|
1593
1614
|
"actionType": "ajax"
|
|
@@ -1950,7 +1971,7 @@ const StandardButtons = {
|
|
|
1950
1971
|
getStandardNew: async (uiSchema, ctx)=>{
|
|
1951
1972
|
return {
|
|
1952
1973
|
type: 'amis_button',
|
|
1953
|
-
amis_schema: await getSchema$4()
|
|
1974
|
+
amis_schema: await getSchema$4(uiSchema)
|
|
1954
1975
|
}
|
|
1955
1976
|
},
|
|
1956
1977
|
getStandardEdit: async (uiSchema, ctx)=>{
|
|
@@ -2034,7 +2055,7 @@ function getButtonVisibleOn$1(button){
|
|
|
2034
2055
|
if(visible.trim().startsWith('function')){
|
|
2035
2056
|
return `${visible}.apply({
|
|
2036
2057
|
object: uiSchema
|
|
2037
|
-
}, [objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2058
|
+
}, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`
|
|
2038
2059
|
}
|
|
2039
2060
|
return visible;
|
|
2040
2061
|
}
|
|
@@ -3164,9 +3185,8 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3164
3185
|
|
|
3165
3186
|
let body = [
|
|
3166
3187
|
{
|
|
3167
|
-
"type": "
|
|
3168
|
-
"
|
|
3169
|
-
data: { "&":"$$", objectName: name, _id: recordId, recordPermissions: "${record.recordPermissions}", uiSchema: objectSchema},
|
|
3188
|
+
"type": "wrapper",
|
|
3189
|
+
"className": "p-0",
|
|
3170
3190
|
"body": [
|
|
3171
3191
|
{
|
|
3172
3192
|
"type": "grid",
|
|
@@ -3174,14 +3194,14 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3174
3194
|
"className": "flex justify-between"
|
|
3175
3195
|
}
|
|
3176
3196
|
],
|
|
3177
|
-
"messages": {},
|
|
3178
3197
|
"hiddenOn": "${recordLoaded != true}"
|
|
3179
3198
|
}
|
|
3180
3199
|
];
|
|
3181
3200
|
|
|
3182
3201
|
if(showRecordTitle){
|
|
3183
3202
|
body.push({
|
|
3184
|
-
"type": "
|
|
3203
|
+
"type": "wrapper",
|
|
3204
|
+
"className": "p-0",
|
|
3185
3205
|
"body": [
|
|
3186
3206
|
{
|
|
3187
3207
|
"type": "grid",
|
|
@@ -3189,16 +3209,15 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3189
3209
|
"className": "flex justify-between"
|
|
3190
3210
|
}
|
|
3191
3211
|
],
|
|
3192
|
-
"messages": {},
|
|
3193
3212
|
"hiddenOn": "${recordLoaded == true}"
|
|
3194
3213
|
});
|
|
3195
3214
|
}
|
|
3196
3215
|
|
|
3197
3216
|
return {
|
|
3198
3217
|
type: 'service',
|
|
3199
|
-
|
|
3218
|
+
id: `page_readonly_${name}_header`,
|
|
3200
3219
|
name: `page`,
|
|
3201
|
-
data: {
|
|
3220
|
+
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
3202
3221
|
body: body,
|
|
3203
3222
|
className: ''
|
|
3204
3223
|
}
|
|
@@ -3253,7 +3272,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
3253
3272
|
"body": [
|
|
3254
3273
|
{
|
|
3255
3274
|
"type": "tpl",
|
|
3256
|
-
"tpl": `<a class="text-black text-base font-bold" href="/app/\${appId}/\${
|
|
3275
|
+
"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>`,
|
|
3257
3276
|
"inline": false,
|
|
3258
3277
|
"wrapperComponent": "",
|
|
3259
3278
|
"className": "",
|
|
@@ -3294,17 +3313,22 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
3294
3313
|
async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
|
|
3295
3314
|
}
|
|
3296
3315
|
|
|
3297
|
-
const getDisplayAsButton = function(showDisplayAs){
|
|
3316
|
+
const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
3317
|
+
let displayAs = Router$1.getTabDisplayAs(objectName);
|
|
3298
3318
|
let buttons = [
|
|
3299
3319
|
{
|
|
3300
3320
|
"type": "button",
|
|
3301
3321
|
"label": "表格",
|
|
3302
|
-
"onClick": "
|
|
3322
|
+
"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');",
|
|
3323
|
+
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
3324
|
+
"rightIconClassName": "m-l-sm"
|
|
3303
3325
|
},
|
|
3304
3326
|
{
|
|
3305
3327
|
"type": "button",
|
|
3306
3328
|
"label": "分栏视图",
|
|
3307
|
-
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);"
|
|
3329
|
+
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
3330
|
+
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
3331
|
+
"rightIconClassName": "m-l-sm"
|
|
3308
3332
|
}
|
|
3309
3333
|
];
|
|
3310
3334
|
return {
|
|
@@ -3446,7 +3470,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
3446
3470
|
}
|
|
3447
3471
|
}
|
|
3448
3472
|
},
|
|
3449
|
-
showDisplayAs? getDisplayAsButton() : {}
|
|
3473
|
+
showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
|
|
3450
3474
|
]
|
|
3451
3475
|
}else {
|
|
3452
3476
|
return [
|
|
@@ -3527,7 +3551,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
3527
3551
|
}
|
|
3528
3552
|
}
|
|
3529
3553
|
},
|
|
3530
|
-
showDisplayAs? getDisplayAsButton() : {}
|
|
3554
|
+
showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
|
|
3531
3555
|
// {
|
|
3532
3556
|
// "type": "search-box",
|
|
3533
3557
|
// "align": "right",
|
|
@@ -3817,13 +3841,14 @@ function getLookupSapceUserTreeSchema(){
|
|
|
3817
3841
|
"headers": {
|
|
3818
3842
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
3819
3843
|
},
|
|
3820
|
-
"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
|
|
3844
|
+
"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 ",
|
|
3821
3845
|
"requestAdaptor": "\n ",
|
|
3822
3846
|
"data": {
|
|
3823
3847
|
"query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
|
|
3824
3848
|
},
|
|
3825
3849
|
"messages": {
|
|
3826
|
-
}
|
|
3850
|
+
},
|
|
3851
|
+
"cache": 300000
|
|
3827
3852
|
},
|
|
3828
3853
|
"onEvent": {
|
|
3829
3854
|
"change": {
|
|
@@ -4214,20 +4239,20 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
4214
4239
|
|
|
4215
4240
|
if(referenceTo){
|
|
4216
4241
|
// 字段值单独走一个请求合并到source的同一个GraphQL接口中
|
|
4217
|
-
const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null,
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4242
|
+
const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
|
|
4243
|
+
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
4244
|
+
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
4245
|
+
], {
|
|
4221
4246
|
alias: "defaultValueOptions",
|
|
4222
4247
|
filters: "{__options_filters}",
|
|
4223
4248
|
count: false
|
|
4224
4249
|
});
|
|
4225
4250
|
apiInfo = await getApi$1({
|
|
4226
4251
|
name: referenceTo.objectName
|
|
4227
|
-
}, null,
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4252
|
+
}, null, [
|
|
4253
|
+
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
4254
|
+
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
4255
|
+
], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`, moreQueries: [defaultValueOptionsQueryData.query]});
|
|
4231
4256
|
|
|
4232
4257
|
apiInfo.adaptor = `
|
|
4233
4258
|
const data = payload.data;
|
|
@@ -5388,8 +5413,9 @@ function getReadonlyFormAdaptor(fields){
|
|
|
5388
5413
|
async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
5389
5414
|
return {
|
|
5390
5415
|
method: "post",
|
|
5391
|
-
url: getApi$2()+"
|
|
5416
|
+
url: getApi$2()+"&recordId=${recordId}",
|
|
5392
5417
|
cache: API_CACHE,
|
|
5418
|
+
// requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
|
|
5393
5419
|
adaptor: getReadonlyFormAdaptor(fields),
|
|
5394
5420
|
data: await getFindOneQuery$1(object, recordId, fields, options),
|
|
5395
5421
|
headers: {
|
|
@@ -5496,6 +5522,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
5496
5522
|
data.global = "${global}";
|
|
5497
5523
|
data.context = "${context}";
|
|
5498
5524
|
data.defaultData = "${defaultData}";
|
|
5525
|
+
|
|
5499
5526
|
return {
|
|
5500
5527
|
method: "post",
|
|
5501
5528
|
url: getApi$2(),
|
|
@@ -5864,7 +5891,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
5864
5891
|
keepItemSelectionOnPageChange: true,
|
|
5865
5892
|
api: await getTableApi(objectSchema, fields, options),
|
|
5866
5893
|
hiddenOn: options.tableHiddenOn,
|
|
5867
|
-
autoFillHeight: true,
|
|
5894
|
+
autoFillHeight: options.isRelated ? false : true,
|
|
5868
5895
|
className: `flex-auto ${crudClassName || ""}`,
|
|
5869
5896
|
crudClassName: crudClassName,
|
|
5870
5897
|
},
|
|
@@ -5907,11 +5934,11 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
5907
5934
|
id: `service_${id}`,
|
|
5908
5935
|
name: `page`,
|
|
5909
5936
|
data: {
|
|
5910
|
-
objectName: objectSchema.name,
|
|
5911
|
-
_id: null,
|
|
5937
|
+
// objectName: objectSchema.name,
|
|
5938
|
+
// _id: null,
|
|
5912
5939
|
recordPermissions: objectSchema.permissions,
|
|
5913
5940
|
uiSchema: objectSchema,
|
|
5914
|
-
loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
5941
|
+
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
5915
5942
|
},
|
|
5916
5943
|
body: body
|
|
5917
5944
|
}
|
|
@@ -6024,6 +6051,10 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
6024
6051
|
"objectName": "${_master.objectName}"
|
|
6025
6052
|
},
|
|
6026
6053
|
"expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
|
|
6054
|
+
},
|
|
6055
|
+
{
|
|
6056
|
+
"args": {},
|
|
6057
|
+
"actionType": "closeDialog"
|
|
6027
6058
|
}
|
|
6028
6059
|
]
|
|
6029
6060
|
}
|
|
@@ -6370,7 +6401,7 @@ function getButtonVisibleOn(button){
|
|
|
6370
6401
|
// return 'false';
|
|
6371
6402
|
// }
|
|
6372
6403
|
if(visible.trim().startsWith('function')){
|
|
6373
|
-
return `${visible}(objectName, _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6404
|
+
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
6374
6405
|
}
|
|
6375
6406
|
return visible;
|
|
6376
6407
|
}
|
|
@@ -6535,6 +6566,11 @@ async function getTableApi(mainObject, fields, options){
|
|
|
6535
6566
|
|
|
6536
6567
|
let valueField = mainObject.key_field || '_id';
|
|
6537
6568
|
const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
6569
|
+
|
|
6570
|
+
if(options.isRelated){
|
|
6571
|
+
api.url += "&recordId=${recordId}";
|
|
6572
|
+
}
|
|
6573
|
+
|
|
6538
6574
|
api.data.$term = "$term";
|
|
6539
6575
|
api.data.$self = "$$";
|
|
6540
6576
|
api.data.filter = "$filter";
|
|
@@ -6654,11 +6690,36 @@ async function getTableApi(mainObject, fields, options){
|
|
|
6654
6690
|
if(!_.isEmpty(systemFilters)){
|
|
6655
6691
|
filters = systemFilters;
|
|
6656
6692
|
};
|
|
6657
|
-
|
|
6658
6693
|
if(api.data.$self.additionalFilters){
|
|
6659
6694
|
userFilters.push(api.data.$self.additionalFilters)
|
|
6660
6695
|
}
|
|
6661
6696
|
|
|
6697
|
+
if(api.data.$self._isRelated){
|
|
6698
|
+
const self = api.data.$self;
|
|
6699
|
+
const relatedKey = self.relatedKey;
|
|
6700
|
+
const recordId = self.recordId;
|
|
6701
|
+
const refField = self.uiSchema.fields[relatedKey];
|
|
6702
|
+
const masterRecord = self._master.record;
|
|
6703
|
+
const masterObjectName = self._master.objectName;
|
|
6704
|
+
let relatedValue = recordId;
|
|
6705
|
+
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
6706
|
+
relatedValue = masterRecord[refField.reference_to_field]
|
|
6707
|
+
}
|
|
6708
|
+
let relatedFilters;
|
|
6709
|
+
if (
|
|
6710
|
+
refField._reference_to ||
|
|
6711
|
+
(refField.reference_to && !_.isString(refField.reference_to))
|
|
6712
|
+
) {
|
|
6713
|
+
relatedFilters = [
|
|
6714
|
+
[relatedKey + "/o", "=", masterObjectName],
|
|
6715
|
+
[relatedKey + "/ids", "=", relatedValue],
|
|
6716
|
+
];
|
|
6717
|
+
} else {
|
|
6718
|
+
relatedFilters = [relatedKey, "=", relatedValue];
|
|
6719
|
+
}
|
|
6720
|
+
userFilters.push(relatedFilters)
|
|
6721
|
+
}
|
|
6722
|
+
|
|
6662
6723
|
if(!_.isEmpty(userFilters)){
|
|
6663
6724
|
if(_.isEmpty(filters)){
|
|
6664
6725
|
filters = userFilters;
|
|
@@ -6781,7 +6842,7 @@ async function getApi(object, recordId, fields, options){
|
|
|
6781
6842
|
const data = await getFindQuery(object, recordId, fields, options);
|
|
6782
6843
|
return {
|
|
6783
6844
|
method: "post",
|
|
6784
|
-
url: getApi$2(),
|
|
6845
|
+
url: getApi$2(), // + "&recordId=${recordId}"
|
|
6785
6846
|
data: data,
|
|
6786
6847
|
headers: {
|
|
6787
6848
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -7415,8 +7476,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
7415
7476
|
/*
|
|
7416
7477
|
* @Author: baozhoutao@steedos.com
|
|
7417
7478
|
* @Date: 2022-07-05 15:55:39
|
|
7418
|
-
* @LastEditors:
|
|
7419
|
-
* @LastEditTime: 2023-
|
|
7479
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
7480
|
+
* @LastEditTime: 2023-04-08 18:14:55
|
|
7420
7481
|
* @Description:
|
|
7421
7482
|
*/
|
|
7422
7483
|
|
|
@@ -7488,7 +7549,7 @@ async function getObjectRelatedList(
|
|
|
7488
7549
|
|
|
7489
7550
|
// 获取单个相关表
|
|
7490
7551
|
async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObjectName, relatedKey, ctx){
|
|
7491
|
-
let { top, perPage,
|
|
7552
|
+
let { top, perPage, appId, relatedLabel, className, columns, sort, filters, visible_on } = ctx;
|
|
7492
7553
|
// console.log('getRecordDetailRelatedListSchema==>',objectName,recordId,relatedObjectName)
|
|
7493
7554
|
const relatedObjectUiSchema = await getUISchema(relatedObjectName);
|
|
7494
7555
|
if(!relatedObjectUiSchema){
|
|
@@ -7523,6 +7584,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7523
7584
|
relatedKey = mainRelated[relatedObjectName];
|
|
7524
7585
|
}
|
|
7525
7586
|
let globalFilter = null;
|
|
7587
|
+
// TODO: refField变量去掉,写到amis运行时脚本中,uiSchema.fields[relatedKey];可以取到
|
|
7526
7588
|
const refField = await getField(relatedObjectName, relatedKey);
|
|
7527
7589
|
|
|
7528
7590
|
if(!refField){
|
|
@@ -7538,23 +7600,23 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7538
7600
|
}
|
|
7539
7601
|
}
|
|
7540
7602
|
|
|
7541
|
-
let relatedValue = recordId;
|
|
7542
|
-
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
}
|
|
7603
|
+
let relatedValue = "${recordId}";
|
|
7604
|
+
// if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7605
|
+
// const masterRecord = await getRecord(objectName, recordId, [refField.reference_to_field]);
|
|
7606
|
+
// relatedValue = masterRecord[refField.reference_to_field]
|
|
7607
|
+
// }
|
|
7546
7608
|
|
|
7547
|
-
if (
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
) {
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
} else {
|
|
7556
|
-
|
|
7557
|
-
}
|
|
7609
|
+
// if (
|
|
7610
|
+
// refField._reference_to ||
|
|
7611
|
+
// (refField.reference_to && !isString(refField.reference_to))
|
|
7612
|
+
// ) {
|
|
7613
|
+
// globalFilter = [
|
|
7614
|
+
// [`${relatedKey}/o`, "=", objectName],
|
|
7615
|
+
// [`${relatedKey}/ids`, "=", relatedValue],
|
|
7616
|
+
// ];
|
|
7617
|
+
// } else {
|
|
7618
|
+
// globalFilter = [`${relatedKey}`, "=", relatedValue];
|
|
7619
|
+
// }
|
|
7558
7620
|
const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
|
|
7559
7621
|
const componentId = `steedos-record-related-list-${relatedObjectName}`;
|
|
7560
7622
|
const options = {
|
|
@@ -7579,9 +7641,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7579
7641
|
top: top,
|
|
7580
7642
|
perPage: perPage,
|
|
7581
7643
|
setDataToComponentId: componentId,
|
|
7582
|
-
tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
7644
|
+
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
7583
7645
|
appId: appId,
|
|
7584
|
-
crudClassName: 'border-t border-slate-300',
|
|
7646
|
+
crudClassName: 'border-t border-slate-300 hidden',
|
|
7585
7647
|
...ctx
|
|
7586
7648
|
};
|
|
7587
7649
|
const amisSchema= (await getRelatedListSchema(relatedObjectName, 'all', options)).amisSchema;
|
|
@@ -7593,15 +7655,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7593
7655
|
amisSchema: {
|
|
7594
7656
|
type: "service",
|
|
7595
7657
|
id: componentId,
|
|
7596
|
-
className: `steedos-record-related-list rounded border border-slate-300 bg-gray-100 mb-4 ${className}`,
|
|
7658
|
+
className: `steedos-record-related-list ${componentId} rounded border border-slate-300 bg-gray-100 mb-4 ${className}`,
|
|
7597
7659
|
data: {
|
|
7598
|
-
"&": "$$",
|
|
7599
|
-
appId: "${appId}",
|
|
7600
|
-
app_id: "${appId}",
|
|
7601
|
-
masterObjectName: objectName,
|
|
7602
|
-
masterRecordId: "${recordId}",
|
|
7603
7660
|
relatedKey: relatedKey,
|
|
7604
|
-
objectName: relatedObjectName,
|
|
7605
7661
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
7606
7662
|
_isRelated: true
|
|
7607
7663
|
},
|
|
@@ -7609,12 +7665,6 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
7609
7665
|
{
|
|
7610
7666
|
...amisSchema,
|
|
7611
7667
|
data: {
|
|
7612
|
-
"&": "$$",
|
|
7613
|
-
appId: "${appId}",
|
|
7614
|
-
app_id: "${appId}",
|
|
7615
|
-
relatedKey: relatedKey,
|
|
7616
|
-
objectName: "${objectName}",
|
|
7617
|
-
recordId: "${masterRecordId}",
|
|
7618
7668
|
defaultData: {
|
|
7619
7669
|
...{[relatedKey]: getRelatedFieldValue(objectName, relatedValue, relatedObjectUiSchema, relatedKey)}
|
|
7620
7670
|
}
|
|
@@ -7658,13 +7708,13 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
|
|
|
7658
7708
|
columns = getListViewColumns(listView, ctx.formFactor);
|
|
7659
7709
|
sort = getListViewSort(listView);
|
|
7660
7710
|
filter = getListViewFilter(listView);
|
|
7661
|
-
if(isArray(ctx.globalFilter) && ctx.globalFilter.length && isArray(filter) && filter.length){
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
}else if(ctx.globalFilter && (!filter || !filter.length)){
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
}
|
|
7711
|
+
// if(isArray(ctx.globalFilter) && ctx.globalFilter.length && isArray(filter) && filter.length){
|
|
7712
|
+
// // 都有值
|
|
7713
|
+
// filter = [ctx.globalFilter, 'and', filter]
|
|
7714
|
+
// }else if(ctx.globalFilter && (!filter || !filter.length)){
|
|
7715
|
+
// // globalFilter有值,filter无值
|
|
7716
|
+
// filter = ctx.globalFilter;
|
|
7717
|
+
// }
|
|
7668
7718
|
filtersFunction = listView && listView._filters;
|
|
7669
7719
|
}else {
|
|
7670
7720
|
const isNameField = find(
|
|
@@ -7674,9 +7724,9 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
|
|
|
7674
7724
|
}
|
|
7675
7725
|
);
|
|
7676
7726
|
columns = isNameField ? [isNameField.name] : ['name'];
|
|
7677
|
-
if(ctx.globalFilter){
|
|
7678
|
-
|
|
7679
|
-
}
|
|
7727
|
+
// if(ctx.globalFilter){
|
|
7728
|
+
// filter = ctx.globalFilter;
|
|
7729
|
+
// }
|
|
7680
7730
|
}
|
|
7681
7731
|
|
|
7682
7732
|
return {
|
|
@@ -7700,7 +7750,7 @@ function getRelatedListProps(uiSchema, listViewName, ctx) {
|
|
|
7700
7750
|
return {
|
|
7701
7751
|
columns: ctx.columns,
|
|
7702
7752
|
sort,
|
|
7703
|
-
filter: ctx.globalFilter,
|
|
7753
|
+
// filter: ctx.globalFilter,
|
|
7704
7754
|
filtersFunction: filtersFunction
|
|
7705
7755
|
}
|
|
7706
7756
|
} else {
|
|
@@ -7739,6 +7789,16 @@ async function getRelatedListSchema(
|
|
|
7739
7789
|
delete ctx.filters;
|
|
7740
7790
|
|
|
7741
7791
|
delete ctx.globalFilter;
|
|
7792
|
+
|
|
7793
|
+
const adaptor = `
|
|
7794
|
+
if(setDataToComponentId){
|
|
7795
|
+
if(payload.data.count){
|
|
7796
|
+
setTimeout(function(){
|
|
7797
|
+
window.$("." + setDataToComponentId + " .antd-Crud").removeClass("hidden");
|
|
7798
|
+
}, 10);
|
|
7799
|
+
}
|
|
7800
|
+
};
|
|
7801
|
+
`;
|
|
7742
7802
|
const amisSchema = {
|
|
7743
7803
|
"type": "steedos-object-table",
|
|
7744
7804
|
"objectApiName": objectName,
|
|
@@ -7747,6 +7807,8 @@ async function getRelatedListSchema(
|
|
|
7747
7807
|
"filters": listviewFilter,
|
|
7748
7808
|
"filtersFunction": filtersFunction,
|
|
7749
7809
|
"sort": listViewSort,
|
|
7810
|
+
"filterVisible": false,
|
|
7811
|
+
adaptor,
|
|
7750
7812
|
"ctx": ctx
|
|
7751
7813
|
};
|
|
7752
7814
|
// console.log(`getRelatedListSchema amisSchema`, amisSchema);
|
|
@@ -7759,8 +7821,8 @@ async function getRelatedListSchema(
|
|
|
7759
7821
|
/*
|
|
7760
7822
|
* @Author: baozhoutao@steedos.com
|
|
7761
7823
|
* @Date: 2022-07-05 15:55:39
|
|
7762
|
-
* @LastEditors:
|
|
7763
|
-
* @LastEditTime: 2023-
|
|
7824
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
7825
|
+
* @LastEditTime: 2023-04-08 17:31:57
|
|
7764
7826
|
* @Description:
|
|
7765
7827
|
*/
|
|
7766
7828
|
|
|
@@ -7932,14 +7994,14 @@ async function getField(objectName, fieldName) {
|
|
|
7932
7994
|
async function getFormSchema(objectName, ctx) {
|
|
7933
7995
|
const uiSchema = await getUISchema(objectName);
|
|
7934
7996
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
7935
|
-
|
|
7997
|
+
console.log(`getFormSchema====>`, amisSchema);
|
|
7936
7998
|
return {
|
|
7937
7999
|
uiSchema,
|
|
7938
8000
|
amisSchema,
|
|
7939
8001
|
};
|
|
7940
8002
|
}
|
|
7941
8003
|
|
|
7942
|
-
// 获取只读页面
|
|
8004
|
+
// 获取只读页面 recordId 已废弃, 函数签名保持不变, 但recordId变量不可再使用, 请使用运行时的${recordId}
|
|
7943
8005
|
async function getViewSchema(objectName, recordId, ctx) {
|
|
7944
8006
|
const uiSchema = await getUISchema(objectName);
|
|
7945
8007
|
const amisSchema = await getObjectDetail(uiSchema, recordId, ctx);
|
|
@@ -8124,6 +8186,7 @@ async function getTableSchema(
|
|
|
8124
8186
|
headerToolbarItems: ctx.headerToolbarItems,
|
|
8125
8187
|
buttons: await getListViewItemButtons(uiSchema, ctx)
|
|
8126
8188
|
});
|
|
8189
|
+
// console.log('getTableSchema====>amisSchema', amisSchema)
|
|
8127
8190
|
return {
|
|
8128
8191
|
uiSchema,
|
|
8129
8192
|
amisSchema,
|
|
@@ -8222,15 +8285,8 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
8222
8285
|
"data": {
|
|
8223
8286
|
"name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
8224
8287
|
"record": `\${event.data.record}`,
|
|
8225
|
-
"
|
|
8226
|
-
|
|
8227
|
-
},
|
|
8228
|
-
{
|
|
8229
|
-
"actionType": "reload",
|
|
8230
|
-
"componentId": `page_readonly_${objectName}_header`, //刷新标题, 详细页面header service 嵌套太多, 导致仅刷新第一层service无法更新recordName
|
|
8231
|
-
"data": {
|
|
8232
|
-
"name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
8233
|
-
"record": `\${event.data.record}`,
|
|
8288
|
+
"_id": "\${event.data.record._id}",
|
|
8289
|
+
"recordId": "\${event.data.record._id}",
|
|
8234
8290
|
"recordLoaded": true,
|
|
8235
8291
|
}
|
|
8236
8292
|
}
|
|
@@ -8240,10 +8296,10 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
8240
8296
|
},
|
|
8241
8297
|
content
|
|
8242
8298
|
],
|
|
8243
|
-
data: {
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
},
|
|
8299
|
+
// data: {
|
|
8300
|
+
// "_master.objectName": "${objectName}",
|
|
8301
|
+
// "_master.recordId": "${recordId}"
|
|
8302
|
+
// },
|
|
8247
8303
|
onEvent: {
|
|
8248
8304
|
"recordLoaded": {
|
|
8249
8305
|
"actions": [
|
|
@@ -8251,10 +8307,10 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
8251
8307
|
"actionType": "reload",
|
|
8252
8308
|
"data": {
|
|
8253
8309
|
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
8254
|
-
"_master.record": `\${record}`,
|
|
8255
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
8256
|
-
"_master.objectName": "${objectName}",
|
|
8257
|
-
"_master.recordId": "${recordId}"
|
|
8310
|
+
// "_master.record": `\${record}`,
|
|
8311
|
+
// // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
8312
|
+
// "_master.objectName": "${objectName}",
|
|
8313
|
+
// "_master.recordId": "${recordId}"
|
|
8258
8314
|
}
|
|
8259
8315
|
}
|
|
8260
8316
|
]
|
|
@@ -8265,51 +8321,6 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
8265
8321
|
}
|
|
8266
8322
|
}
|
|
8267
8323
|
|
|
8268
|
-
// export async function getRecordDetailRelatedListSchema(objectName,recordId,relatedObjectName){
|
|
8269
|
-
// // console.log('b==>',objectName,recordId,relatedObjectName)
|
|
8270
|
-
// const relatedObjectUiSchema = await getUISchema(relatedObjectName);
|
|
8271
|
-
// const { list_views, label , icon, fields } = relatedObjectUiSchema;
|
|
8272
|
-
// const firstListViewName = keys(list_views)[0];
|
|
8273
|
-
// const relatedKey = findKey(fields, function(field) {
|
|
8274
|
-
// return ["lookup","master_detail"].indexOf(field.type) > -1 && field.reference_to === objectName;
|
|
8275
|
-
// });
|
|
8276
|
-
// const globalFilter = [relatedKey,'=',recordId];
|
|
8277
|
-
// const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema);
|
|
8278
|
-
// const options = {
|
|
8279
|
-
// globalFilter,
|
|
8280
|
-
// defaults: {
|
|
8281
|
-
// listSchema: { headerToolbar:[],columnsTogglable:false },
|
|
8282
|
-
// headerSchema: recordRelatedListHeader
|
|
8283
|
-
// },
|
|
8284
|
-
// showHeader: true
|
|
8285
|
-
// }
|
|
8286
|
-
// const amisSchema= (await getListSchema(null, relatedObjectName, firstListViewName, options)).amisSchema;
|
|
8287
|
-
// return {
|
|
8288
|
-
// uiSchema: relatedObjectUiSchema,
|
|
8289
|
-
// amisSchema: {
|
|
8290
|
-
// type: "service",
|
|
8291
|
-
// data: {
|
|
8292
|
-
// masterObjectName: objectName,
|
|
8293
|
-
// masterRecordId: "${recordId}",
|
|
8294
|
-
// relatedKey: relatedKey,
|
|
8295
|
-
// objectName: relatedObjectName,
|
|
8296
|
-
// listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
8297
|
-
// },
|
|
8298
|
-
// body:[
|
|
8299
|
-
// {
|
|
8300
|
-
// ...amisSchema,
|
|
8301
|
-
// data: {
|
|
8302
|
-
// filter: ["${relatedKey}", "=", "${masterRecordId}"],
|
|
8303
|
-
// objectName: "${objectName}",
|
|
8304
|
-
// recordId: "${masterRecordId}",
|
|
8305
|
-
// ...{[relatedKey]: getRelatedFieldValue(objectName, "${recordId}", relatedSchema.uiSchema, relatedKey)}
|
|
8306
|
-
// }
|
|
8307
|
-
// }
|
|
8308
|
-
// ]
|
|
8309
|
-
// }
|
|
8310
|
-
// };
|
|
8311
|
-
// }
|
|
8312
|
-
|
|
8313
8324
|
|
|
8314
8325
|
// 获取单个相关表
|
|
8315
8326
|
async function getObjectRelated(
|