@steedos-widgets/amis-lib 1.1.7 → 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/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('lodash/isPlainObject'), require('@steedos-widgets/amis-lib')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash', 'lodash/isPlainObject', '@steedos-widgets/amis-lib'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["amis-lib"] = {}, global._$1, global.isPlainObject, global.amisLib));
5
- })(this, (function (exports, _$1, isPlainObject, amisLib) {
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: 殷亮辉 yinlianghui@hotoa.com
1395
- * @LastEditTime: 2023-03-27 15:42:24
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",
@@ -1972,7 +1997,7 @@
1972
1997
  getStandardNew: async (uiSchema, ctx)=>{
1973
1998
  return {
1974
1999
  type: 'amis_button',
1975
- amis_schema: await getSchema$4()
2000
+ amis_schema: await getSchema$4(uiSchema)
1976
2001
  }
1977
2002
  },
1978
2003
  getStandardEdit: async (uiSchema, ctx)=>{
@@ -2056,7 +2081,7 @@
2056
2081
  if(visible.trim().startsWith('function')){
2057
2082
  return `${visible}.apply({
2058
2083
  object: uiSchema
2059
- }, [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])`
2060
2085
  }
2061
2086
  return visible;
2062
2087
  }
@@ -3186,9 +3211,8 @@
3186
3211
 
3187
3212
  let body = [
3188
3213
  {
3189
- "type": "service",
3190
- "id": `page_readonly_${name}_header`,
3191
- data: { "&":"$$", objectName: name, _id: recordId, recordPermissions: "${record.recordPermissions}", uiSchema: objectSchema},
3214
+ "type": "wrapper",
3215
+ "className": "p-0",
3192
3216
  "body": [
3193
3217
  {
3194
3218
  "type": "grid",
@@ -3196,14 +3220,14 @@
3196
3220
  "className": "flex justify-between"
3197
3221
  }
3198
3222
  ],
3199
- "messages": {},
3200
3223
  "hiddenOn": "${recordLoaded != true}"
3201
3224
  }
3202
3225
  ];
3203
3226
 
3204
3227
  if(showRecordTitle){
3205
3228
  body.push({
3206
- "type": "service",
3229
+ "type": "wrapper",
3230
+ "className": "p-0",
3207
3231
  "body": [
3208
3232
  {
3209
3233
  "type": "grid",
@@ -3211,16 +3235,15 @@
3211
3235
  "className": "flex justify-between"
3212
3236
  }
3213
3237
  ],
3214
- "messages": {},
3215
3238
  "hiddenOn": "${recordLoaded == true}"
3216
3239
  });
3217
3240
  }
3218
3241
 
3219
3242
  return {
3220
3243
  type: 'service',
3221
- bodyClassName: '',
3244
+ id: `page_readonly_${name}_header`,
3222
3245
  name: `page`,
3223
- data: { "&":"$$", objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}"},
3246
+ data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
3224
3247
  body: body,
3225
3248
  className: ''
3226
3249
  }
@@ -3275,7 +3298,7 @@
3275
3298
  "body": [
3276
3299
  {
3277
3300
  "type": "tpl",
3278
- "tpl": `<a class="text-black text-base font-bold" href="/app/\${appId}/\${masterObjectName}/\${masterRecordId}/\${objectName}/grid?related_field_name=\${relatedKey}">${relatedLabel}(\${$count})</a>`,
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>`,
3279
3302
  "inline": false,
3280
3303
  "wrapperComponent": "",
3281
3304
  "className": "",
@@ -3316,17 +3339,22 @@
3316
3339
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3317
3340
  }
3318
3341
 
3319
- const getDisplayAsButton = function(showDisplayAs){
3342
+ const getDisplayAsButton = function(objectName, showDisplayAs){
3343
+ let displayAs = amisLib.Router.getTabDisplayAs(objectName);
3320
3344
  let buttons = [
3321
3345
  {
3322
3346
  "type": "button",
3323
3347
  "label": "表格",
3324
- "onClick": "const url = document.location.pathname + '?display=grid'; props.env.jumpTo(url);"
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"
3325
3351
  },
3326
3352
  {
3327
3353
  "type": "button",
3328
3354
  "label": "分栏视图",
3329
- "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"
3330
3358
  }
3331
3359
  ];
3332
3360
  return {
@@ -3468,7 +3496,7 @@ setTimeout(()=>{
3468
3496
  }
3469
3497
  }
3470
3498
  },
3471
- showDisplayAs? getDisplayAsButton() : {}
3499
+ showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
3472
3500
  ]
3473
3501
  }else {
3474
3502
  return [
@@ -3549,7 +3577,7 @@ setTimeout(()=>{
3549
3577
  }
3550
3578
  }
3551
3579
  },
3552
- showDisplayAs? getDisplayAsButton() : {}
3580
+ showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
3553
3581
  // {
3554
3582
  // "type": "search-box",
3555
3583
  // "align": "right",
@@ -3828,6 +3856,90 @@ setTimeout(()=>{
3828
3856
  }
3829
3857
  };
3830
3858
 
3859
+ function getLookupSapceUserTreeSchema(){
3860
+ const tree = [{
3861
+ "type": "input-tree",
3862
+ "className": "",
3863
+ "id": "u:7fd77b7915b0",
3864
+ "source": {
3865
+ "method": "post",
3866
+ "url": "${context.rootUrl}/graphql",
3867
+ "headers": {
3868
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3869
+ },
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 ",
3871
+ "requestAdaptor": "\n ",
3872
+ "data": {
3873
+ "query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
3874
+ },
3875
+ "messages": {
3876
+ },
3877
+ "cache": 300000
3878
+ },
3879
+ "onEvent": {
3880
+ "change": {
3881
+ "actions": [
3882
+ {
3883
+ "actionType": "custom",
3884
+ "script": `
3885
+ debugger;
3886
+ const scope = event.context.scoped;
3887
+ //TODO: 将form中的value一同加入筛选内
3888
+ // var filterForm = scope.parent.parent.getComponents().find(function(n){
3889
+ // return n.props.type === "form";
3890
+ // });
3891
+ // var filterFormValues = filterForm.getValues();
3892
+ filterFormValues={
3893
+ "__searchable__organizations_parents":event.data.value.value
3894
+ }
3895
+ var listView = scope.parent.getComponents().find(function(n){
3896
+ return n.props.type === "crud";
3897
+ });
3898
+ const removedValues = {};
3899
+ // for(var k in filterFormValues){
3900
+ // if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
3901
+ // removedValues[k] = "";
3902
+ // }
3903
+ // }
3904
+ listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
3905
+ `
3906
+ }
3907
+ ]
3908
+ }
3909
+ },
3910
+ "label": "",
3911
+ "name": "organizations",
3912
+ "multiple": false,
3913
+ "joinValues": false,
3914
+ "clearValueOnHidden": false,
3915
+ "fieldName": "organizations",
3916
+ "hideRoot": true,
3917
+ "initiallyOpen": false,
3918
+ "extractValue": true,
3919
+ "onlyChildren": true,
3920
+ "treeContainerClassName": "no-border",
3921
+ "showIcon": false,
3922
+ "enableNodePath": false,
3923
+ "autoCheckChildren": false,
3924
+ "searchable": true,
3925
+ "searchConfig": {
3926
+ "sticky": true
3927
+ },
3928
+ "unfoldedLevel": 2,
3929
+ "style": {
3930
+ "max-height": "100%",
3931
+ "position": "absolute",
3932
+ "left": "-190px",
3933
+ "width": "190px",
3934
+ "bottom": 0,
3935
+ "top": "0",
3936
+ "overflow": "auto",
3937
+ "min-height":"300px"
3938
+ },
3939
+ "originPosition": "left-top"
3940
+ }];
3941
+ return tree;
3942
+ }
3831
3943
 
3832
3944
  async function lookupToAmisPicker(field, readonly, ctx){
3833
3945
  let referenceTo = await getReferenceTo(field);
@@ -4070,7 +4182,16 @@ setTimeout(()=>{
4070
4182
  ...ctx
4071
4183
  });
4072
4184
 
4073
- pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor);
4185
+ var headerToolbarItems = [];
4186
+ const isMobile = window.innerWidth < 768;
4187
+ if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
4188
+ headerToolbarItems = getLookupSapceUserTreeSchema();
4189
+ pickerSchema["style"] = {
4190
+ "margin-left":"200px",
4191
+ "min-height": "300px"
4192
+ };
4193
+ }
4194
+ pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor, { headerToolbarItems });
4074
4195
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
4075
4196
  if (isAllowCreate) {
4076
4197
  const new_button = await getSchema$4(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
@@ -4078,15 +4199,18 @@ setTimeout(()=>{
4078
4199
  pickerSchema.headerToolbar.push(new_button);
4079
4200
  }
4080
4201
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
4081
- if(ctx.filterVisible !== false){
4082
- let filterLoopCount = ctx.filterLoopCount || 0;
4083
- filterLoopCount++;
4084
- // 可以传入filterVisible为false防止死循环
4085
- pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4086
- isLookup: true,
4087
- ...ctx,
4088
- filterLoopCount,
4089
- });
4202
+ //TODO: 等待放大镜bug修复,if会去掉,始终显示放大镜
4203
+ if(referenceTo.objectName != "space_users" || field.reference_to_field != "user"){
4204
+ if (ctx.filterVisible !== false) {
4205
+ let filterLoopCount = ctx.filterLoopCount || 0;
4206
+ filterLoopCount++;
4207
+ // 可以传入filterVisible为false防止死循环
4208
+ pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4209
+ isLookup: true,
4210
+ ...ctx,
4211
+ filterLoopCount,
4212
+ });
4213
+ }
4090
4214
  }
4091
4215
  pickerSchema.data = Object.assign({}, pickerSchema.data, {
4092
4216
  "&": "$$",
@@ -4334,7 +4458,7 @@ setTimeout(()=>{
4334
4458
  if(ctx.idsDependOn || field.amis){
4335
4459
  return await lookupToAmisIdsPicker(field, readonly, ctx);
4336
4460
  }
4337
- return await lookupToAmisSelectUser(field, readonly, ctx);
4461
+ // return await lookupToAmisSelectUser(field, readonly, ctx);
4338
4462
  }
4339
4463
 
4340
4464
  const refObject = await getUISchema(referenceTo.objectName);
@@ -5315,8 +5439,9 @@ setTimeout(()=>{
5315
5439
  async function getReadonlyFormInitApi(object, recordId, fields, options){
5316
5440
  return {
5317
5441
  method: "post",
5318
- url: getApi$2()+"?rf="+ (new Date()).getTime(),
5442
+ url: getApi$2()+"&recordId=${recordId}",
5319
5443
  cache: API_CACHE,
5444
+ // requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
5320
5445
  adaptor: getReadonlyFormAdaptor(fields),
5321
5446
  data: await getFindOneQuery$1(object, recordId, fields, options),
5322
5447
  headers: {
@@ -5423,6 +5548,7 @@ setTimeout(()=>{
5423
5548
  data.global = "${global}";
5424
5549
  data.context = "${context}";
5425
5550
  data.defaultData = "${defaultData}";
5551
+
5426
5552
  return {
5427
5553
  method: "post",
5428
5554
  url: getApi$2(),
@@ -5791,7 +5917,7 @@ setTimeout(()=>{
5791
5917
  keepItemSelectionOnPageChange: true,
5792
5918
  api: await getTableApi(objectSchema, fields, options),
5793
5919
  hiddenOn: options.tableHiddenOn,
5794
- autoFillHeight: true,
5920
+ autoFillHeight: options.isRelated ? false : true,
5795
5921
  className: `flex-auto ${crudClassName || ""}`,
5796
5922
  crudClassName: crudClassName,
5797
5923
  },
@@ -5834,11 +5960,11 @@ setTimeout(()=>{
5834
5960
  id: `service_${id}`,
5835
5961
  name: `page`,
5836
5962
  data: {
5837
- objectName: objectSchema.name,
5838
- _id: null,
5963
+ // objectName: objectSchema.name,
5964
+ // _id: null,
5839
5965
  recordPermissions: objectSchema.permissions,
5840
5966
  uiSchema: objectSchema,
5841
- loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
5967
+ // loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
5842
5968
  },
5843
5969
  body: body
5844
5970
  }
@@ -5951,6 +6077,10 @@ setTimeout(()=>{
5951
6077
  "objectName": "${_master.objectName}"
5952
6078
  },
5953
6079
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
6080
+ },
6081
+ {
6082
+ "args": {},
6083
+ "actionType": "closeDialog"
5954
6084
  }
5955
6085
  ]
5956
6086
  }
@@ -6297,7 +6427,7 @@ setTimeout(()=>{
6297
6427
  // return 'false';
6298
6428
  // }
6299
6429
  if(visible.trim().startsWith('function')){
6300
- 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)`
6301
6431
  }
6302
6432
  return visible;
6303
6433
  }
@@ -6462,6 +6592,11 @@ setTimeout(()=>{
6462
6592
 
6463
6593
  let valueField = mainObject.key_field || '_id';
6464
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
+
6465
6600
  api.data.$term = "$term";
6466
6601
  api.data.$self = "$$";
6467
6602
  api.data.filter = "$filter";
@@ -6581,11 +6716,36 @@ setTimeout(()=>{
6581
6716
  if(!_.isEmpty(systemFilters)){
6582
6717
  filters = systemFilters;
6583
6718
  };
6584
-
6585
6719
  if(api.data.$self.additionalFilters){
6586
6720
  userFilters.push(api.data.$self.additionalFilters)
6587
6721
  }
6588
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
+
6589
6749
  if(!_.isEmpty(userFilters)){
6590
6750
  if(_.isEmpty(filters)){
6591
6751
  filters = userFilters;
@@ -6708,7 +6868,7 @@ setTimeout(()=>{
6708
6868
  const data = await getFindQuery(object, recordId, fields, options);
6709
6869
  return {
6710
6870
  method: "post",
6711
- url: getApi$2(),
6871
+ url: getApi$2(), // + "&recordId=${recordId}"
6712
6872
  data: data,
6713
6873
  headers: {
6714
6874
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -7342,8 +7502,8 @@ setTimeout(()=>{
7342
7502
  /*
7343
7503
  * @Author: baozhoutao@steedos.com
7344
7504
  * @Date: 2022-07-05 15:55:39
7345
- * @LastEditors: Please set LastEditors
7346
- * @LastEditTime: 2023-03-30 17:44:53
7505
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7506
+ * @LastEditTime: 2023-04-08 18:14:55
7347
7507
  * @Description:
7348
7508
  */
7349
7509
 
@@ -7415,7 +7575,7 @@ setTimeout(()=>{
7415
7575
 
7416
7576
  // 获取单个相关表
7417
7577
  async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObjectName, relatedKey, ctx){
7418
- let { top, perPage, hiddenEmptyTable, appId, relatedLabel, className, columns, sort, filters, visible_on } = ctx;
7578
+ let { top, perPage, appId, relatedLabel, className, columns, sort, filters, visible_on } = ctx;
7419
7579
  // console.log('getRecordDetailRelatedListSchema==>',objectName,recordId,relatedObjectName)
7420
7580
  const relatedObjectUiSchema = await getUISchema(relatedObjectName);
7421
7581
  if(!relatedObjectUiSchema){
@@ -7450,6 +7610,7 @@ setTimeout(()=>{
7450
7610
  relatedKey = mainRelated[relatedObjectName];
7451
7611
  }
7452
7612
  let globalFilter = null;
7613
+ // TODO: refField变量去掉,写到amis运行时脚本中,uiSchema.fields[relatedKey];可以取到
7453
7614
  const refField = await getField(relatedObjectName, relatedKey);
7454
7615
 
7455
7616
  if(!refField){
@@ -7465,23 +7626,23 @@ setTimeout(()=>{
7465
7626
  }
7466
7627
  }
7467
7628
 
7468
- let relatedValue = recordId;
7469
- if(refField.reference_to_field && refField.reference_to_field != '_id'){
7470
- const masterRecord = await getRecord(objectName, recordId, [refField.reference_to_field]);
7471
- relatedValue = masterRecord[refField.reference_to_field];
7472
- }
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
+ // }
7473
7634
 
7474
- if (
7475
- refField._reference_to ||
7476
- (refField.reference_to && !_$1.isString(refField.reference_to))
7477
- ) {
7478
- globalFilter = [
7479
- [`${relatedKey}/o`, "=", objectName],
7480
- [`${relatedKey}/ids`, "=", relatedValue],
7481
- ];
7482
- } else {
7483
- globalFilter = [`${relatedKey}`, "=", relatedValue];
7484
- }
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
+ // }
7485
7646
  const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
7486
7647
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
7487
7648
  const options = {
@@ -7506,9 +7667,9 @@ setTimeout(()=>{
7506
7667
  top: top,
7507
7668
  perPage: perPage,
7508
7669
  setDataToComponentId: componentId,
7509
- tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
7670
+ // tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
7510
7671
  appId: appId,
7511
- crudClassName: 'border-t border-slate-300',
7672
+ crudClassName: 'border-t border-slate-300 hidden',
7512
7673
  ...ctx
7513
7674
  };
7514
7675
  const amisSchema= (await getRelatedListSchema(relatedObjectName, 'all', options)).amisSchema;
@@ -7520,15 +7681,9 @@ setTimeout(()=>{
7520
7681
  amisSchema: {
7521
7682
  type: "service",
7522
7683
  id: componentId,
7523
- 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}`,
7524
7685
  data: {
7525
- "&": "$$",
7526
- appId: "${appId}",
7527
- app_id: "${appId}",
7528
- masterObjectName: objectName,
7529
- masterRecordId: "${recordId}",
7530
7686
  relatedKey: relatedKey,
7531
- objectName: relatedObjectName,
7532
7687
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
7533
7688
  _isRelated: true
7534
7689
  },
@@ -7536,12 +7691,6 @@ setTimeout(()=>{
7536
7691
  {
7537
7692
  ...amisSchema,
7538
7693
  data: {
7539
- "&": "$$",
7540
- appId: "${appId}",
7541
- app_id: "${appId}",
7542
- relatedKey: relatedKey,
7543
- objectName: "${objectName}",
7544
- recordId: "${masterRecordId}",
7545
7694
  defaultData: {
7546
7695
  ...{[relatedKey]: getRelatedFieldValue(objectName, relatedValue, relatedObjectUiSchema, relatedKey)}
7547
7696
  }
@@ -7585,13 +7734,13 @@ setTimeout(()=>{
7585
7734
  columns = getListViewColumns(listView, ctx.formFactor);
7586
7735
  sort = getListViewSort(listView);
7587
7736
  filter = getListViewFilter(listView);
7588
- if(_$1.isArray(ctx.globalFilter) && ctx.globalFilter.length && _$1.isArray(filter) && filter.length){
7589
- // 都有值
7590
- filter = [ctx.globalFilter, 'and', filter];
7591
- }else if(ctx.globalFilter && (!filter || !filter.length)){
7592
- // globalFilter有值,filter无值
7593
- filter = ctx.globalFilter;
7594
- }
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
+ // }
7595
7744
  filtersFunction = listView && listView._filters;
7596
7745
  }else {
7597
7746
  const isNameField = _$1.find(
@@ -7601,9 +7750,9 @@ setTimeout(()=>{
7601
7750
  }
7602
7751
  );
7603
7752
  columns = isNameField ? [isNameField.name] : ['name'];
7604
- if(ctx.globalFilter){
7605
- filter = ctx.globalFilter;
7606
- }
7753
+ // if(ctx.globalFilter){
7754
+ // filter = ctx.globalFilter;
7755
+ // }
7607
7756
  }
7608
7757
 
7609
7758
  return {
@@ -7627,7 +7776,7 @@ setTimeout(()=>{
7627
7776
  return {
7628
7777
  columns: ctx.columns,
7629
7778
  sort,
7630
- filter: ctx.globalFilter,
7779
+ // filter: ctx.globalFilter,
7631
7780
  filtersFunction: filtersFunction
7632
7781
  }
7633
7782
  } else {
@@ -7666,6 +7815,16 @@ setTimeout(()=>{
7666
7815
  delete ctx.filters;
7667
7816
 
7668
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
+ `;
7669
7828
  const amisSchema = {
7670
7829
  "type": "steedos-object-table",
7671
7830
  "objectApiName": objectName,
@@ -7674,6 +7833,8 @@ setTimeout(()=>{
7674
7833
  "filters": listviewFilter,
7675
7834
  "filtersFunction": filtersFunction,
7676
7835
  "sort": listViewSort,
7836
+ "filterVisible": false,
7837
+ adaptor,
7677
7838
  "ctx": ctx
7678
7839
  };
7679
7840
  // console.log(`getRelatedListSchema amisSchema`, amisSchema);
@@ -7686,8 +7847,8 @@ setTimeout(()=>{
7686
7847
  /*
7687
7848
  * @Author: baozhoutao@steedos.com
7688
7849
  * @Date: 2022-07-05 15:55:39
7689
- * @LastEditors: baozhoutao@steedos.com
7690
- * @LastEditTime: 2023-03-11 17:02:30
7850
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7851
+ * @LastEditTime: 2023-04-08 17:31:57
7691
7852
  * @Description:
7692
7853
  */
7693
7854
 
@@ -7859,14 +8020,14 @@ setTimeout(()=>{
7859
8020
  async function getFormSchema(objectName, ctx) {
7860
8021
  const uiSchema = await getUISchema(objectName);
7861
8022
  const amisSchema = await getObjectForm(uiSchema, ctx);
7862
- // console.log(`getFormSchema====>`, amisSchema)
8023
+ console.log(`getFormSchema====>`, amisSchema);
7863
8024
  return {
7864
8025
  uiSchema,
7865
8026
  amisSchema,
7866
8027
  };
7867
8028
  }
7868
8029
 
7869
- // 获取只读页面
8030
+ // 获取只读页面 recordId 已废弃, 函数签名保持不变, 但recordId变量不可再使用, 请使用运行时的${recordId}
7870
8031
  async function getViewSchema(objectName, recordId, ctx) {
7871
8032
  const uiSchema = await getUISchema(objectName);
7872
8033
  const amisSchema = await getObjectDetail(uiSchema, recordId, ctx);
@@ -8051,6 +8212,7 @@ setTimeout(()=>{
8051
8212
  headerToolbarItems: ctx.headerToolbarItems,
8052
8213
  buttons: await getListViewItemButtons(uiSchema, ctx)
8053
8214
  });
8215
+ // console.log('getTableSchema====>amisSchema', amisSchema)
8054
8216
  return {
8055
8217
  uiSchema,
8056
8218
  amisSchema,
@@ -8149,15 +8311,8 @@ setTimeout(()=>{
8149
8311
  "data": {
8150
8312
  "name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
8151
8313
  "record": `\${event.data.record}`,
8152
- "recordLoaded": true,
8153
- }
8154
- },
8155
- {
8156
- "actionType": "reload",
8157
- "componentId": `page_readonly_${objectName}_header`, //刷新标题, 详细页面header service 嵌套太多, 导致仅刷新第一层service无法更新recordName
8158
- "data": {
8159
- "name": `\${event.data.record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
8160
- "record": `\${event.data.record}`,
8314
+ "_id": "\${event.data.record._id}",
8315
+ "recordId": "\${event.data.record._id}",
8161
8316
  "recordLoaded": true,
8162
8317
  }
8163
8318
  }
@@ -8167,10 +8322,10 @@ setTimeout(()=>{
8167
8322
  },
8168
8323
  content
8169
8324
  ],
8170
- data: {
8171
- "_master.objectName": "${objectName}",
8172
- "_master.recordId": "${recordId}"
8173
- },
8325
+ // data: {
8326
+ // "_master.objectName": "${objectName}",
8327
+ // "_master.recordId": "${recordId}"
8328
+ // },
8174
8329
  onEvent: {
8175
8330
  "recordLoaded": {
8176
8331
  "actions": [
@@ -8178,10 +8333,10 @@ setTimeout(()=>{
8178
8333
  "actionType": "reload",
8179
8334
  "data": {
8180
8335
  "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
8181
- "_master.record": `\${record}`,
8182
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8183
- "_master.objectName": "${objectName}",
8184
- "_master.recordId": "${recordId}"
8336
+ // "_master.record": `\${record}`,
8337
+ // // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8338
+ // "_master.objectName": "${objectName}",
8339
+ // "_master.recordId": "${recordId}"
8185
8340
  }
8186
8341
  }
8187
8342
  ]
@@ -8192,51 +8347,6 @@ setTimeout(()=>{
8192
8347
  }
8193
8348
  }
8194
8349
 
8195
- // export async function getRecordDetailRelatedListSchema(objectName,recordId,relatedObjectName){
8196
- // // console.log('b==>',objectName,recordId,relatedObjectName)
8197
- // const relatedObjectUiSchema = await getUISchema(relatedObjectName);
8198
- // const { list_views, label , icon, fields } = relatedObjectUiSchema;
8199
- // const firstListViewName = keys(list_views)[0];
8200
- // const relatedKey = findKey(fields, function(field) {
8201
- // return ["lookup","master_detail"].indexOf(field.type) > -1 && field.reference_to === objectName;
8202
- // });
8203
- // const globalFilter = [relatedKey,'=',recordId];
8204
- // const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema);
8205
- // const options = {
8206
- // globalFilter,
8207
- // defaults: {
8208
- // listSchema: { headerToolbar:[],columnsTogglable:false },
8209
- // headerSchema: recordRelatedListHeader
8210
- // },
8211
- // showHeader: true
8212
- // }
8213
- // const amisSchema= (await getListSchema(null, relatedObjectName, firstListViewName, options)).amisSchema;
8214
- // return {
8215
- // uiSchema: relatedObjectUiSchema,
8216
- // amisSchema: {
8217
- // type: "service",
8218
- // data: {
8219
- // masterObjectName: objectName,
8220
- // masterRecordId: "${recordId}",
8221
- // relatedKey: relatedKey,
8222
- // objectName: relatedObjectName,
8223
- // listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
8224
- // },
8225
- // body:[
8226
- // {
8227
- // ...amisSchema,
8228
- // data: {
8229
- // filter: ["${relatedKey}", "=", "${masterRecordId}"],
8230
- // objectName: "${objectName}",
8231
- // recordId: "${masterRecordId}",
8232
- // ...{[relatedKey]: getRelatedFieldValue(objectName, "${recordId}", relatedSchema.uiSchema, relatedKey)}
8233
- // }
8234
- // }
8235
- // ]
8236
- // }
8237
- // };
8238
- // }
8239
-
8240
8350
 
8241
8351
  // 获取单个相关表
8242
8352
  async function getObjectRelated(
@@ -11130,6 +11240,7 @@ setTimeout(()=>{
11130
11240
  exports.getListViewItemButtons = getListViewItemButtons;
11131
11241
  exports.getListViewSort = getListViewSort;
11132
11242
  exports.getListviewInitSchema = getListviewInitSchema;
11243
+ exports.getLookupSapceUserTreeSchema = getLookupSapceUserTreeSchema;
11133
11244
  exports.getNotifications = getNotifications;
11134
11245
  exports.getObjectDetailButtons = getObjectDetailButtons;
11135
11246
  exports.getObjectDetailMoreButtons = getObjectDetailMoreButtons;