@steedos-widgets/amis-lib 6.3.13-beta.3 → 6.10.1-beta.11

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.cjs.js CHANGED
@@ -532,8 +532,8 @@ function getComparableAmisVersion() {
532
532
  /*
533
533
  * @Author: baozhoutao@steedos.com
534
534
  * @Date: 2022-05-23 09:53:08
535
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
536
- * @LastEditTime: 2025-04-08 10:55:41
535
+ * @LastEditors: baozhoutao@steedos.com
536
+ * @LastEditTime: 2024-11-17 13:10:08
537
537
  * @Description:
538
538
  */
539
539
 
@@ -690,10 +690,9 @@ function getRelatedFieldTpl(field, ctx){
690
690
  const href = Router.getObjectDetailPath({
691
691
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
692
692
  });
693
- if (window.innerWidth >= 768) { //(ctx.isRelated || isObjectListview) && window.innerWidth >= 768
694
- // 相关表字段,包括列表视图、对象表格组件中的lookup/master_detail字段,在PC端显示时,点击字段值,不跳转到详情页而是右侧弹出drawer
693
+ if(ctx.isRelated && window.innerWidth >= 768){
695
694
  labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
696
- } else {
695
+ }else {
697
696
  labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
698
697
  }
699
698
 
@@ -1423,7 +1422,7 @@ const getAmisFileEditSchema = (steedosField)=>{
1423
1422
  receiver: {
1424
1423
  method: "post",
1425
1424
  dataType: "form-data",
1426
- url: `\${context.rootUrl}/s3/${tableName}`,
1425
+ url: `\${context.rootUrl}/api/v6/files/cfs.${tableName}.filerecord`,
1427
1426
  requestAdaptor: `
1428
1427
  const superData = (typeof context != 'undefined') ? context : api.body;
1429
1428
  const { _master, global } = superData;
@@ -1446,14 +1445,14 @@ const getAmisFileEditSchema = (steedosField)=>{
1446
1445
  adaptor: `
1447
1446
  const superData = (typeof context != 'undefined') ? context : api.body;
1448
1447
  const { context:pageContext } = superData;
1449
- var rootUrl = pageContext.rootUrl + "/api/files/${tableName}/";
1448
+ var rootUrl = pageContext.rootUrl + "/api/v6/files/download/cfs.${tableName}.filerecord/";
1450
1449
  payload = {
1451
1450
  status: response.status == 200 ? 0 : response.status,
1452
1451
  msg: response.statusText,
1453
1452
  data: {
1454
1453
  value: payload._id,
1455
1454
  name: payload.original.name,
1456
- url: rootUrl + payload._id,
1455
+ url: rootUrl + payload._id + "/" + payload.original.name,
1457
1456
  }
1458
1457
  }
1459
1458
  return payload;
@@ -1924,12 +1923,7 @@ async function getQuickEditSchema(object, columnField, options){
1924
1923
  if (field.disabled) {
1925
1924
  quickEditSchema = false;
1926
1925
  } else {
1927
- var fieldCtx = Object.assign({}, ___namespace.omit(options, 'buttons'), {
1928
- defaults: Object.assign({}, options.defaults, {
1929
- formSchema: quickEditSchema
1930
- })
1931
- });
1932
- var fieldSchema = await convertSFieldToAmisField(field, false, fieldCtx);
1926
+ var fieldSchema = await convertSFieldToAmisField(field, false, ___namespace.omit(options, 'buttons'));
1933
1927
  //存在属性上可编辑,实际不可编辑的字段,convertSFieldToAmisField函数可能会返回undefined,如summary
1934
1928
  if (!!fieldSchema) {
1935
1929
  quickEditSchema.body.push(fieldSchema);
@@ -2362,19 +2356,14 @@ function getFieldWidth(width){
2362
2356
  }
2363
2357
 
2364
2358
  async function getColumnItemOnClick(field, options){
2365
- let objectApiName = options.objectName;
2366
- if(!(field.is_name || field.name === options.labelFieldName)){
2367
- objectApiName = field.reference_to;
2368
- }
2369
- const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: objectApiName, formFactor: options.formFactor });
2359
+ const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
2370
2360
  const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
2371
2361
  "recordId": `\${${options.idFieldName}}`,
2372
2362
  "data": {
2373
2363
  ...recordPage.schema.data,
2374
2364
  "_inDrawer": true, // 用于判断是否在抽屉中
2375
2365
  "recordLoaded": false, // 重置数据加载状态
2376
- "recordId": `\${${options.idFieldName}}`,//审批微页面依赖了作用域中的recordId
2377
- "_tableObjectName": options.objectName
2366
+ "recordId": `\${${options.idFieldName}}`//审批微页面依赖了作用域中的recordId
2378
2367
  }
2379
2368
  }) : {
2380
2369
  "type": "steedos-record-detail",
@@ -2385,16 +2374,12 @@ async function getColumnItemOnClick(field, options){
2385
2374
  "data": {
2386
2375
  "_inDrawer": true, // 用于判断是否在抽屉中
2387
2376
  "recordLoaded": false, // 重置数据加载状态
2388
- "_tableObjectName": options.objectName
2389
2377
  }
2390
2378
  };
2391
2379
 
2392
2380
  if(!(field.is_name || field.name === options.labelFieldName)){
2393
2381
  drawerRecordDetailSchema.objectApiName = field.reference_to;
2394
2382
  drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
2395
- // if (recordPage){
2396
- // drawerRecordDetailSchema.data.recordId = `\${_display.${field.name}.value}`
2397
- // }
2398
2383
  }
2399
2384
  return {
2400
2385
  "click": {
@@ -2544,32 +2529,6 @@ async function getTableColumns(object, fields, options){
2544
2529
  static: true,
2545
2530
  }, fieldAmis, {name: field.name});
2546
2531
  }
2547
- else if(field.type === 'lookup' || field.type === 'master_detail'){
2548
- columnItem = Object.assign({}, {
2549
- type: "static-wrapper",
2550
- name: field.name,
2551
- label: field.label,
2552
- sortable: field.sortable,
2553
- width: getFieldWidth(field.width),
2554
- toggled: field.toggled,
2555
- className,
2556
- size: "none",
2557
- inputClassName: "inline",
2558
- body: {
2559
- type: "steedos-field",
2560
- static: true,
2561
- tableObjectName: options.objectName,
2562
- config: {
2563
- type: "lookup",
2564
- reference_to: field.reference_to,
2565
- name: field.name,
2566
- label: null,
2567
- multiple: field.multiple,
2568
- amis: Object.assign({}, fieldAmis, { label: null })
2569
- }
2570
- }
2571
- }, fieldAmis, {name: field.name});
2572
- }
2573
2532
  else {
2574
2533
  const tpl = await getFieldTpl(field, options);
2575
2534
  let type = 'static-text';
@@ -2618,20 +2577,10 @@ async function getTableColumns(object, fields, options){
2618
2577
  columnItem.defaultColor = null;
2619
2578
  }
2620
2579
 
2621
- let needClickEvent = false;
2622
- // if (options.isRelated){
2623
- // // 子表列表上,Lookup字段和名称字段都需要点击事件
2624
- // needClickEvent = ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && _.isString(field.reference_to) && field.multiple != true));
2625
- // }
2626
- // else {// if (isObjectListview)
2627
- // // 列表视图、对象表格中,Lookup字段需要点击事件
2628
- // needClickEvent = (field.type == 'lookup' || field.type == 'master_detail') && _.isString(field.reference_to) && field.multiple != true;
2629
- // }
2630
- // lookup字段走steedos-field组件了,所以这里只需要判断子表名称字段才额外加点击事件弹出右侧详情
2631
- needClickEvent = options.isRelated && (field.is_name || field.name === options.labelFieldName);
2632
- if(window.innerWidth >= 768 && needClickEvent){
2580
+ if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && ___namespace.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2633
2581
  columnItem.onEvent = await getColumnItemOnClick(field, options);
2634
2582
  }
2583
+
2635
2584
  }
2636
2585
  }
2637
2586
  if(columnItem){
@@ -2898,7 +2847,9 @@ function getButtonVisibleOn$1(button){
2898
2847
  // return 'false';
2899
2848
  // }
2900
2849
  if(visible.trim().startsWith('function')){
2901
- return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
2850
+ visible = visible.replace('function', 'function __visible');
2851
+ const visibleStr = `(function _visible(){try{return (${visible})(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)}catch(e){console.error(e)}})()`;
2852
+ return visibleStr;
2902
2853
  }
2903
2854
  return visible;
2904
2855
  }
@@ -3287,7 +3238,7 @@ async function getTableApi(mainObject, fields, options){
3287
3238
  const refField = self.uiSchema.fields[relatedKey];
3288
3239
  const masterRecord = self._master.record;
3289
3240
  const masterObjectName = self._master.objectName;
3290
- let relatedValue = self._master.recordId;
3241
+ let relatedValue = masterRecord._id;
3291
3242
  if(refField && refField.reference_to_field && refField.reference_to_field != '_id'){
3292
3243
  relatedValue = masterRecord[refField.reference_to_field]
3293
3244
  }
@@ -3328,6 +3279,7 @@ async function getTableApi(mainObject, fields, options){
3328
3279
  skip: skip,
3329
3280
  fields: ${JSON.stringify(___namespace.map(fields, 'name'))}
3330
3281
  }));
3282
+ // console.log('table requestAdaptor', api);
3331
3283
  return api;
3332
3284
  `;
3333
3285
  api.adaptor = `
@@ -3465,17 +3417,15 @@ async function getTableApi(mainObject, fields, options){
3465
3417
  }
3466
3418
  // 标记加载过,后续优先从本地存储中加载相关参数
3467
3419
  payload.data.loaded= true;
3468
-
3469
3420
  const setDataToComponentId = "${setDataToComponentId}";
3470
3421
  if(setDataToComponentId){
3471
3422
  //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
3472
- var scope = SteedosUI.getRef(api.body.$self.$scopeId);
3423
+ var scope = context._scoped;
3473
3424
  var scopeParent = scope && scope.parent;
3474
3425
  var setDataToComponent = scopeParent && scopeParent.getComponentById(setDataToComponentId);
3475
3426
  if(setDataToComponent){
3476
3427
  setDataToComponent.setData({$count: payload.data.count});
3477
3428
  }
3478
- // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
3479
3429
  };
3480
3430
  let formFactor = "${options.formFactor}";
3481
3431
  if(formFactor !== "SMALL"){
@@ -3588,6 +3538,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3588
3538
  payload.data.data = [emptyDoc];
3589
3539
  }
3590
3540
  else{
3541
+ console.log('无法找到记录', api, payload, context)
3591
3542
  return {
3592
3543
  status: 2,
3593
3544
  msg: "${i18next__default["default"].t('frontend_no_records_found')}"
@@ -3614,13 +3565,12 @@ function getReadonlyFormAdaptor(object, fields, options){
3614
3565
  console.error(e)
3615
3566
  }
3616
3567
  payload.data = data;
3617
- payload.data.__objectName = "${object.name}";
3618
3568
  payload.data.record = record;
3619
3569
  payload.data.NAME_FIELD_VALUE = ${nameLabel} || record.name;
3620
3570
  payload.data._master = {
3621
3571
  record: record,
3622
- objectName: "${object.name}",
3623
- recordId: record._id
3572
+ objectName: "\${objectName}",
3573
+ recordId: "\${recordId}"
3624
3574
  }
3625
3575
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3626
3576
  }
@@ -4529,6 +4479,11 @@ var __assign = function() {
4529
4479
  return t;
4530
4480
  };
4531
4481
  return __assign.apply(this, arguments);
4482
+ };
4483
+
4484
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
4485
+ var e = new Error(message);
4486
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4532
4487
  };
4533
4488
 
4534
4489
  /**
@@ -5178,8 +5133,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
5178
5133
  /*
5179
5134
  * @Author: 殷亮辉 yinlianghui@hotoa.com
5180
5135
  * @Date: 2023-03-22 09:31:21
5181
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5182
- * @LastEditTime: 2025-04-07 16:02:53
5136
+ * @LastEditors: baozhoutao@steedos.com
5137
+ * @LastEditTime: 2024-02-18 16:06:21
5183
5138
  */
5184
5139
  const getSchema$3 = (uiSchema)=>{
5185
5140
  return {
@@ -5239,17 +5194,6 @@ const getSchema$3 = (uiSchema)=>{
5239
5194
  "_isRelated": "${_isRelated}"
5240
5195
  },
5241
5196
  "expression": `\${_master.objectName != '${uiSchema.name}' && _master.objectName}`
5242
- },
5243
- // 列表视图、对象表格组件上的lookup字段,点开右侧弹出drawer窗口,删除记录后刷新列表
5244
- {
5245
- "actionType": "broadcast",
5246
- "args": {
5247
- "eventName": "@data.changed.${_tableObjectName}"
5248
- },
5249
- "data": {
5250
- "objectName": "${_tableObjectName}"
5251
- },
5252
- "expression": `\${_tableObjectName != '${uiSchema.name}' && _tableObjectName}`
5253
5197
  }
5254
5198
  ]
5255
5199
  }
@@ -5541,9 +5485,7 @@ const StandardButtons = {
5541
5485
  objectName,
5542
5486
  uiSchema
5543
5487
  } = this;
5544
- const scopeId = this.scopeId || `amis-${appId}-${objectName}-listview`;
5545
- const scope = this.scope || SteedosUI?.getRef(scopeId);
5546
- //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
5488
+ const scope = this.scope;
5547
5489
  const listViewRef = scope.parent?.getComponentById(`listview_${uiSchema.name}`);
5548
5490
  if(_.isEmpty(listViewRef.props.store.toJSON().selectedItems)){
5549
5491
  listViewRef.handleAction({}, {
@@ -5606,9 +5548,9 @@ function getButtonVisibleOn(button){
5606
5548
  // return 'false';
5607
5549
  // }
5608
5550
  if(visible.trim().startsWith('function')){
5609
- visible = `${visible}.apply({
5551
+ visible = `(function(){try{const fun = ${visible}; return fun.apply({
5610
5552
  object: uiSchema
5611
- }, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`;
5553
+ }, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])}catch(e){console.error(e)}})()`;
5612
5554
  }
5613
5555
  }
5614
5556
 
@@ -5906,7 +5848,7 @@ const execute = (button, props) => {
5906
5848
  ...props,
5907
5849
  action: button
5908
5850
  };
5909
- return button.todo.apply(todoThis, [todoThis.objectName, todoThis.recordId]);
5851
+ return button.todo.apply(todoThis, [todoThis.objectName, todoThis.recordId, props.record?.record?.recordPermissions, props.record]);
5910
5852
  }
5911
5853
  };
5912
5854
 
@@ -6403,21 +6345,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6403
6345
  let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service", {name: "service_object_table_crud"});
6404
6346
  crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
6405
6347
  `;
6406
- /**
6407
- 给lookup字段配置filter_form_data时可以配置为amis变量,也可以配置为事态key-value键值对象值:
6408
- ```
6409
- "filter_form_data": "${selectedPublicGroupFilterFormData|toJson}"
6410
- ```
6411
- or
6412
- ```
6413
- "filter_form_data": {
6414
- "public_group_ids": [
6415
- "67addbef39f9a4503789b38d"
6416
- ]
6417
- }
6418
- ```
6419
- */
6420
- const filterFormValues = ctx.filter_form_data;
6421
6348
  const dataProviderInited = `
6422
6349
  const searchableFields = ${JSON.stringify(searchableFields)};
6423
6350
  const autoOpenFilter = ${autoOpenFilter};
@@ -6455,16 +6382,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6455
6382
  }
6456
6383
  setData({ filterFormSearchableFields: defaultSearchableFields });
6457
6384
  if(isLookup){
6458
- let filterFormValues = ${_.isObject(filterFormValues) ? JSON.stringify(filterFormValues) : ('"' + filterFormValues + '"')} || {};
6459
- const isAmisFormula = typeof filterFormValues === "string" && filterFormValues.indexOf("\${") > -1;
6460
- if (isAmisFormula){
6461
- filterFormValues = AmisCore.evaluate(filterFormValues, data) || {};
6462
- }
6463
- if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
6464
- let fields = data.uiSchema && data.uiSchema.fields;
6465
- filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
6466
- setData({ ...filterFormValues });
6467
- }
6468
6385
  // looup字段过滤器不在本地缓存记住过滤条件,所以初始始终隐藏过滤器
6469
6386
  setData({ showFieldsFilter: autoOpenFilter });
6470
6387
  }
@@ -6756,15 +6673,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6756
6673
  "actionType": "custom",
6757
6674
  "script": onSearchableFieldsChangeScript
6758
6675
  },
6759
- // 自动触发搜索事件会造成bug,应该是升级amis到6.4造成的,见:https://github.com/steedos/steedos-platform/issues/7121
6760
- // 变更搜索项后,用户一般会点击搜索按钮,所以这里不自动触发搜索事件
6761
- // {
6762
- // "actionType": "click",
6763
- // "componentId": btnSearchId,
6764
- // "args": {
6765
- // "__from_fields_filter_settings_confirm": true
6766
- // }
6767
- // },
6676
+ {
6677
+ "actionType": "click",
6678
+ "componentId": btnSearchId,
6679
+ "args": {
6680
+ "__from_fields_filter_settings_confirm": true
6681
+ }
6682
+ },
6768
6683
  {
6769
6684
  "componentId": "",
6770
6685
  "args": {},
@@ -6875,6 +6790,10 @@ const getNewListviewButtonSchema = ()=>{
6875
6790
  "blank": false
6876
6791
  },
6877
6792
  "actionType": "url",
6793
+ },
6794
+ {
6795
+ "actionType": "custom",
6796
+ "script": "window.location.reload();"
6878
6797
  }
6879
6798
  ]
6880
6799
  }
@@ -7744,6 +7663,7 @@ function getObjectListHeader(objectSchema, listViewName, ctx) {
7744
7663
  "body": body,
7745
7664
  "className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
7746
7665
  }];
7666
+ // console.log(`getObjectListHeader`, objectSchema, listViewName, ctx)
7747
7667
  return headerSchema;
7748
7668
  }
7749
7669
 
@@ -7765,7 +7685,7 @@ function getBackButtonSchema(){
7765
7685
  },
7766
7686
  "body":[{
7767
7687
  "type": "button",
7768
- "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
7688
+ "visibleOn": "${window:innerWidth > 768 && display !== 'split'}",
7769
7689
  "className":"flex mr-4",
7770
7690
  "onEvent": {
7771
7691
  "click": {
@@ -7836,12 +7756,12 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
7836
7756
  );
7837
7757
 
7838
7758
  let backButtonsSchema = null;
7839
-
7759
+
7840
7760
  if(options.showBackButton != false){
7841
7761
  backButtonsSchema = getBackButtonSchema();
7842
7762
  }
7843
7763
 
7844
- // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
7764
+ console.log(`getObjectRecordDetailHeader==> backButtonsSchema`, backButtonsSchema);
7845
7765
 
7846
7766
  const reg = new RegExp('_', 'g');
7847
7767
  const standardIcon = icon && icon.replace(reg, '-');
@@ -8081,7 +8001,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
8081
8001
  "body": [
8082
8002
  {
8083
8003
  "type": "tpl",
8084
- "tpl": `<a class="text-black text-base font-bold hover:font-bold" href="/app/\${appId}/\${_master.objectName}/\${_master.recordId}/\${objectName}/grid?related_field_name=\${relatedKey}">${relatedLabel}(\${$count})</a>`,
8004
+ "tpl": `<a class="text-black text-base font-bold hover:font-bold" href="/app/\${appId}/\${_master.objectName}/\${_master.record._id}/\${objectName}/grid?related_field_name=\${relatedKey}">${relatedLabel}(\${$count})</a>`,
8085
8005
  "inline": false,
8086
8006
  "wrapperComponent": "",
8087
8007
  "className": "",
@@ -8178,6 +8098,10 @@ const getCopyListviewButtonSchema = ()=>{
8178
8098
  "blank": false
8179
8099
  },
8180
8100
  "actionType": "url",
8101
+ },
8102
+ {
8103
+ "actionType": "custom",
8104
+ "script": "window.location.reload();"
8181
8105
  }
8182
8106
  ]
8183
8107
  }
@@ -8345,6 +8269,10 @@ const getRenameListviewButtonSchema = ()=>{
8345
8269
  },
8346
8270
  "actionType": "url",
8347
8271
  },
8272
+ {
8273
+ "actionType": "custom",
8274
+ "script": "window.location.reload();"
8275
+ }
8348
8276
  ]
8349
8277
  }
8350
8278
  }
@@ -8471,11 +8399,8 @@ const getSetListviewFiltersButtonSchema = ()=>{
8471
8399
  "weight": 0,
8472
8400
  "actions": [
8473
8401
  {
8474
- "args": {
8475
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
8476
- "blank": false
8477
- },
8478
- "actionType": "url",
8402
+ "actionType": "custom",
8403
+ "script": "window.location.reload(); //doAction({'actionType': 'rebuild', 'componentId': `service_listview_${event.data.targetObjectName}`})"
8479
8404
  }
8480
8405
  ]
8481
8406
  }
@@ -8625,11 +8550,8 @@ const getSetListviewColumnsButtonSchema = ()=>{
8625
8550
  "weight": 0,
8626
8551
  "actions": [
8627
8552
  {
8628
- "args": {
8629
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
8630
- "blank": false
8631
- },
8632
- "actionType": "url"
8553
+ "actionType": "custom",
8554
+ "script": "window.location.reload(); //doAction({'actionType': 'rebuild', 'componentId': `service_listview_${event.data.targetObjectName}`})"
8633
8555
  }
8634
8556
  ]
8635
8557
  }
@@ -8778,11 +8700,8 @@ const getSetListviewSortButtonSchema = ()=>{
8778
8700
  "weight": 0,
8779
8701
  "actions": [
8780
8702
  {
8781
- "args": {
8782
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
8783
- "blank": false
8784
- },
8785
- "actionType": "url"
8703
+ "actionType": "custom",
8704
+ "script": "window.location.reload(); //doAction({'actionType': 'rebuild', 'componentId': `service_listview_${event.data.targetObjectName}`})"
8786
8705
  }
8787
8706
  ]
8788
8707
  }
@@ -8903,6 +8822,10 @@ const getDeleteListviewButtonSchema = ()=>{
8903
8822
  "blank": false
8904
8823
  },
8905
8824
  "expression": "data.delete == 1"
8825
+ },
8826
+ {
8827
+ "actionType": "custom",
8828
+ "script": "window.location.reload();"
8906
8829
  }
8907
8830
  ]
8908
8831
  }
@@ -9772,12 +9695,12 @@ async function getObjectCRUD(objectSchema, fields, options){
9772
9695
  payload.status = 2;
9773
9696
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
9774
9697
  }
9775
- var scope = SteedosUI.getRef(context.scopeId);
9776
- var scopeParent = scope && scope.parent;
9777
- var crudScoped = scopeParent.getComponentById('${body.id}');
9778
- setTimeout(()=>{
9779
- crudScoped && crudScoped.control.updateAutoFillHeight();
9780
- }, 500);
9698
+ // var scope = SteedosUI.getRef(context.scopeId);
9699
+ // var scopeParent = scope && scope.parent;
9700
+ // var crudScoped = scopeParent.getComponentById('${body.id}');
9701
+ // setTimeout(()=>{
9702
+ // crudScoped && crudScoped.control.updateAutoFillHeight();
9703
+ // }, 500);
9781
9704
  return payload;
9782
9705
  `;
9783
9706
 
@@ -9984,17 +9907,6 @@ async function getObjectForm(objectSchema, ctx){
9984
9907
  },
9985
9908
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
9986
9909
  },
9987
- // 列表视图、对象表格组件上的lookup字段,点开右侧弹出drawer窗口,修改记录后刷新列表
9988
- {
9989
- "actionType": "broadcast",
9990
- "args": {
9991
- "eventName": "@data.changed.${_tableObjectName}"
9992
- },
9993
- "data": {
9994
- "objectName": "${_tableObjectName}"
9995
- },
9996
- "expression": `\${_tableObjectName != '${objectSchema.name}' && _tableObjectName}`
9997
- },
9998
9910
  ...submitSuccActions,
9999
9911
  // {
10000
9912
  // "actionType": "custom",
@@ -10098,7 +10010,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
10098
10010
  }
10099
10011
 
10100
10012
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
10101
- // console.log('getObjectDetail=====>', amisSchema);
10013
+ // console.log('getObjectDetail=====>', amisSchema, objectSchema, recordId, ctx);
10102
10014
  return amisSchema;
10103
10015
  }
10104
10016
 
@@ -10596,8 +10508,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
10596
10508
  /*
10597
10509
  * @Author: baozhoutao@steedos.com
10598
10510
  * @Date: 2022-07-05 15:55:39
10599
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10600
- * @LastEditTime: 2024-04-26 16:46:44
10511
+ * @LastEditors: baozhoutao@steedos.com
10512
+ * @LastEditTime: 2025-03-07 16:48:27
10601
10513
  * @Description:
10602
10514
  */
10603
10515
 
@@ -10706,7 +10618,7 @@ function formatUISchemaCache(objectName, uiSchema){
10706
10618
  });
10707
10619
  }
10708
10620
 
10709
- async function getUISchema(objectName, force) {
10621
+ async function getUISchema(objectName, force, retry = true) {
10710
10622
  if (!objectName) {
10711
10623
  return;
10712
10624
  }
@@ -10722,7 +10634,13 @@ async function getUISchema(objectName, force) {
10722
10634
  const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
10723
10635
  uiSchema = await fetchAPI(url, { method: "get" });
10724
10636
  }
10725
- if(!uiSchema){
10637
+
10638
+ if(!uiSchema && retry){
10639
+ await new Promise(resolve => setTimeout(resolve, 3000));
10640
+ return getUISchema(objectName, force, false);
10641
+ }
10642
+
10643
+ if(!uiSchema && retry == false){
10726
10644
  return ;
10727
10645
  }
10728
10646
  formatUISchemaCache(objectName, uiSchema);
@@ -10733,7 +10651,16 @@ async function getUISchema(objectName, force) {
10733
10651
  return getUISchemaCache(objectName);
10734
10652
  }
10735
10653
 
10736
- function getUISchemaSync$1(objectName, force) {
10654
+ // 阻塞等待函数,单位毫秒
10655
+ function wait(milliseconds) {
10656
+ const start = new Date().getTime();
10657
+ let now = start;
10658
+ while (now - start < milliseconds) {
10659
+ now = new Date().getTime();
10660
+ }
10661
+ }
10662
+
10663
+ function getUISchemaSync$1(objectName, force, retry = true) {
10737
10664
  if (!objectName) {
10738
10665
  return;
10739
10666
  }
@@ -10749,7 +10676,12 @@ function getUISchemaSync$1(objectName, force) {
10749
10676
  async: false,
10750
10677
  });
10751
10678
 
10752
- if(!uiSchema){
10679
+ if(!uiSchema && retry){
10680
+ wait(2000); // 阻塞等待3秒
10681
+ return getUISchemaSync$1(objectName, force, false)
10682
+ }
10683
+
10684
+ if(!uiSchema && retry == false){
10753
10685
  return ;
10754
10686
  }
10755
10687
  formatUISchemaCache(objectName, uiSchema);
@@ -10794,6 +10726,7 @@ async function getListSchema(
10794
10726
  listViewName,
10795
10727
  ctx = {}
10796
10728
  ) {
10729
+ // console.log('getListSchema', objectName, listView, ctx)
10797
10730
  const uiSchema = await getUISchema(objectName);
10798
10731
  if(!uiSchema){
10799
10732
  return {}
@@ -10824,6 +10757,7 @@ async function getListSchema(
10824
10757
  }
10825
10758
 
10826
10759
  let listViewColumns = getListViewColumns(listView, ctx.formFactor);
10760
+ // console.log('getListSchema listViewColumns', objectName, listView, listViewColumns)
10827
10761
  let sort = getListViewSort(listView);
10828
10762
  let listviewFilter = getListViewFilter(listView);
10829
10763
  let listview_filters = listView && listView._filters;
@@ -11030,7 +10964,7 @@ async function getTableSchema(
11030
10964
  columns,
11031
10965
  ctx = {}
11032
10966
  ) {
11033
- // console.time('getTableSchema', columns);
10967
+ // console.log('getTableSchema', columns);
11034
10968
  const uiSchema = await getUISchema(objectName);
11035
10969
 
11036
10970
  let sort = ctx.sort;
@@ -11064,7 +10998,7 @@ async function getTableSchema(
11064
10998
  };
11065
10999
  crudOptions.amisData = createObject(ctx.amisData || {}, {});
11066
11000
  const amisSchema = await getObjectCRUD(uiSchema, fields, crudOptions);
11067
- // console.timeEnd('getTableSchema');
11001
+ // console.log('getTableSchema', amisSchema, uiSchema);
11068
11002
  return {
11069
11003
  uiSchema,
11070
11004
  amisSchema,
@@ -11101,8 +11035,7 @@ async function getRecordDetailHeaderSchema(objectName,recordId, options){
11101
11035
  }
11102
11036
 
11103
11037
  async function getRecordDetailSchema(objectName, appId, props = {}){
11104
- const uiSchema = await getUISchema(objectName);
11105
-
11038
+ const uiSchema = await getUISchema(objectName);
11106
11039
  const relatedLists = await getObjectRelatedList(objectName);
11107
11040
  const detailed = {
11108
11041
  "title": i18next__default["default"].t('frontend_record_detail_tab_detailed'),
@@ -11141,21 +11074,6 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
11141
11074
  if(relatedLists.length){
11142
11075
  content.tabs.push(related);
11143
11076
  }
11144
- const contents = [content];
11145
- if (uiSchema.enable_chatter && window.BuilderLiveblocks) {
11146
- const chatter = {
11147
- "type": "rooms-provider",
11148
- "baseUrl": "${context.rootUrl}",
11149
- "body": [
11150
- {
11151
- "type": "rooms-comments",
11152
- "className": "flex flex-col gap-3 m-4",
11153
- "roomId": "objects:${objectName}:${recordId}",
11154
- }
11155
- ]
11156
- };
11157
- contents.push(chatter);
11158
- }
11159
11077
  // content.tabs = reverse(content.tabs)
11160
11078
  return {
11161
11079
  uiSchema,
@@ -11171,7 +11089,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
11171
11089
  "showButtons": props.showButtons,
11172
11090
  "showBackButton": props.showBackButton,
11173
11091
  },
11174
- ...contents,
11092
+ content
11175
11093
  ],
11176
11094
  "objectApiName": "${objectName}",
11177
11095
  "recordId": "${recordId}",
@@ -11955,42 +11873,14 @@ function getLookupSapceUserTreeSchema(isMobile){
11955
11873
  {
11956
11874
  "actionType": "custom",
11957
11875
  "script": `
11958
- console.log("lookup-tree-event.data:",event.data);
11959
- console.log("lookup-tree-event.data.value.label:",event.data.value.label);
11960
- console.log("lookup-tree-event.data.value.value:",event.data.value.value);
11961
11876
  const scope = event.context.scoped;
11962
- var treeFilterFormValues={
11877
+ var filterFormValues={
11963
11878
  "__searchable__organizations_parents":event.data.value.value
11964
11879
  }
11965
- // var listView = scope.parent.getComponents().find(function(n){
11966
- // return n.props.type === "crud";
11967
- // });
11968
- // listView.handleFilterSubmit(Object.assign({}, filterFormValues));
11969
- let __lookupField = event.data.__lookupField;
11970
- let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
11971
- var filterForm = scope.getComponents().find(function(n){
11972
- return n.props.type === "form";
11880
+ var listView = scope.parent.getComponents().find(function(n){
11881
+ return n.props.type === "crud";
11973
11882
  });
11974
- let filterFormValues = filterForm.getData();
11975
- filterFormValues = JSON.parse(JSON.stringify(filterFormValues)); //只取当层数据域中数据,去除__super层数据
11976
- const changedFilterFormValues = _.pickBy(filterFormValues, function(n,k){return /^__searchable__/.test(k);});
11977
- Object.assign(changedFilterFormValues, treeFilterFormValues);
11978
- // 同步__changedFilterFormValues中的值
11979
- let __changedFilterFormValuesKey = "__changedFilterFormValues";
11980
- if(__lookupField){
11981
- let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
11982
- if(__lookupField.reference_to_field){
11983
- lookupTag += "__" + __lookupField.reference_to_field;
11984
- }
11985
- __changedFilterFormValuesKey += lookupTag;
11986
- }
11987
- if(crud){
11988
- let crudData = crud.getData();
11989
- crudData[__changedFilterFormValuesKey] = changedFilterFormValues;
11990
- crud.setData(crudData);
11991
- }
11992
- filterForm.setData(treeFilterFormValues);
11993
- filterForm.handleFormSubmit(event);
11883
+ listView.handleFilterSubmit(Object.assign({}, filterFormValues));
11994
11884
  `
11995
11885
  },
11996
11886
  {
@@ -12208,7 +12098,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
12208
12098
  // field.name可能是带点的名称,比如审批王中子表字段'instances.instances_submitter',如果不替换掉点,会造成审批王表单中新建子表行时报错
12209
12099
  let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
12210
12100
 
12211
- const filterFormValues = field.filter_form_data;
12212
12101
  source.requestAdaptor = `
12213
12102
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
12214
12103
  let __lookupField = api.data.$self.__lookupField;
@@ -12251,20 +12140,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12251
12140
  }
12252
12141
  }
12253
12142
 
12254
- let filterFormValues = {};
12255
- if (selfData.op !== 'loadOptions'){
12256
- filterFormValues = ${___namespace.isObject(filterFormValues) ? JSON.stringify(filterFormValues) : ('"' + filterFormValues + '"')} || {};
12257
- const isAmisFormula = typeof filterFormValues === "string" && filterFormValues.indexOf("\${") > -1;
12258
- if (isAmisFormula){
12259
- filterFormValues = AmisCore.evaluate(filterFormValues, context) || {};
12260
- }
12261
- if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
12262
- let fields = api.data.$self.uiSchema && api.data.$self.uiSchema.fields;
12263
- filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
12264
- }
12265
- }
12266
-
12267
- var searchableFilter = SteedosUI.getSearchFilter(Object.assign({}, { ...filterFormValues }, selfData)) || [];
12143
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
12268
12144
 
12269
12145
  if(searchableFilter.length > 0){
12270
12146
  if(filters.length > 0 ){
@@ -12454,7 +12330,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12454
12330
  return payload;
12455
12331
  `;
12456
12332
  }
12457
- let top = 500;
12333
+ let top = 20;
12458
12334
 
12459
12335
  if(refObjectConfig.paging && refObjectConfig.paging.enabled === false){
12460
12336
  top = 1000;
@@ -12504,8 +12380,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12504
12380
  keywordsSearchBoxName,
12505
12381
  searchable_fields: field.searchable_fields,
12506
12382
  auto_open_filter: field.auto_open_filter,
12507
- show_left_filter: field.show_left_filter,
12508
- filter_form_data: field.filter_form_data
12383
+ show_left_filter: field.show_left_filter
12509
12384
  });
12510
12385
  }
12511
12386
  pickerSchema.data = Object.assign({}, pickerSchema.data, {
@@ -12572,7 +12447,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12572
12447
  }
12573
12448
 
12574
12449
  const ctx = ${JSON.stringify(ctx)};
12575
- const componentId = ctx.defaults && ctx.defaults.formSchema && ctx.defaults.formSchema.id;
12450
+ const componentId = ctx.defaults.formSchema.id;
12576
12451
  doAction({
12577
12452
  actionType: 'setValue',
12578
12453
  componentId: componentId,
@@ -12999,10 +12874,6 @@ async function lookupToAmis(field, readonly, ctx){
12999
12874
  }
13000
12875
  let amisSchema;
13001
12876
  // 默认使用下拉框模式显示lookup选项,只能配置了enable_enhanced_lookup才使用弹出增强模式
13002
- if(enableEnhancedLookup == true && field.amis && field.amis.type && field.amis.type !== 'picker'){
13003
- // 如果配置了amis.type且其值不是picker,则不使用弹出增强模式
13004
- enableEnhancedLookup = false;
13005
- }
13006
12877
  if(enableEnhancedLookup == true){
13007
12878
  amisSchema = await lookupToAmisPicker(field, readonly, ctx);
13008
12879
  }else if(refObject.enable_tree) {
@@ -14134,16 +14005,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
14134
14005
  return convertData
14135
14006
  }
14136
14007
  // if(ctx.mode === 'edit'){
14137
- let convertDataResult;
14138
- if(convertData.type == "steedos-field"){
14139
- // 如果是steedos-field,不能把amis属性合并到steedos-field根属性中,要合并也是合并到steedos-field的config.amis中
14140
- // 而steedos-field字段的amis属性本身就在config.amis中了,所以这里不需要再合并field.amis
14141
- // 目前测试到受影响的是,把字段的amis属性配置为{"type": "checkboxes"}时,ObjectForm只读模式下,lookup字段返回的是type为steedos-field的组件,此时field.amis中的type不应该合并到steedos-field根属性中
14142
- convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, {name: baseData.name});
14143
- }
14144
- else {
14145
- convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
14146
- }
14008
+ let convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
14147
14009
  // 只读时file字段的外层control层若存在name,内部each组件存在问题
14148
14010
  if(readonly && field.type == "file") {
14149
14011
  convertDataResult.name = "";