@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.esm.js CHANGED
@@ -505,8 +505,8 @@ function getComparableAmisVersion() {
505
505
  /*
506
506
  * @Author: baozhoutao@steedos.com
507
507
  * @Date: 2022-05-23 09:53:08
508
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
509
- * @LastEditTime: 2025-04-08 10:55:41
508
+ * @LastEditors: baozhoutao@steedos.com
509
+ * @LastEditTime: 2024-11-17 13:10:08
510
510
  * @Description:
511
511
  */
512
512
 
@@ -663,10 +663,9 @@ function getRelatedFieldTpl(field, ctx){
663
663
  const href = Router.getObjectDetailPath({
664
664
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
665
665
  });
666
- if (window.innerWidth >= 768) { //(ctx.isRelated || isObjectListview) && window.innerWidth >= 768
667
- // 相关表字段,包括列表视图、对象表格组件中的lookup/master_detail字段,在PC端显示时,点击字段值,不跳转到详情页而是右侧弹出drawer
666
+ if(ctx.isRelated && window.innerWidth >= 768){
668
667
  labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
669
- } else {
668
+ }else {
670
669
  labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
671
670
  }
672
671
 
@@ -1396,7 +1395,7 @@ const getAmisFileEditSchema = (steedosField)=>{
1396
1395
  receiver: {
1397
1396
  method: "post",
1398
1397
  dataType: "form-data",
1399
- url: `\${context.rootUrl}/s3/${tableName}`,
1398
+ url: `\${context.rootUrl}/api/v6/files/cfs.${tableName}.filerecord`,
1400
1399
  requestAdaptor: `
1401
1400
  const superData = (typeof context != 'undefined') ? context : api.body;
1402
1401
  const { _master, global } = superData;
@@ -1419,14 +1418,14 @@ const getAmisFileEditSchema = (steedosField)=>{
1419
1418
  adaptor: `
1420
1419
  const superData = (typeof context != 'undefined') ? context : api.body;
1421
1420
  const { context:pageContext } = superData;
1422
- var rootUrl = pageContext.rootUrl + "/api/files/${tableName}/";
1421
+ var rootUrl = pageContext.rootUrl + "/api/v6/files/download/cfs.${tableName}.filerecord/";
1423
1422
  payload = {
1424
1423
  status: response.status == 200 ? 0 : response.status,
1425
1424
  msg: response.statusText,
1426
1425
  data: {
1427
1426
  value: payload._id,
1428
1427
  name: payload.original.name,
1429
- url: rootUrl + payload._id,
1428
+ url: rootUrl + payload._id + "/" + payload.original.name,
1430
1429
  }
1431
1430
  }
1432
1431
  return payload;
@@ -1897,12 +1896,7 @@ async function getQuickEditSchema(object, columnField, options){
1897
1896
  if (field.disabled) {
1898
1897
  quickEditSchema = false;
1899
1898
  } else {
1900
- var fieldCtx = Object.assign({}, _$1.omit(options, 'buttons'), {
1901
- defaults: Object.assign({}, options.defaults, {
1902
- formSchema: quickEditSchema
1903
- })
1904
- });
1905
- var fieldSchema = await convertSFieldToAmisField(field, false, fieldCtx);
1899
+ var fieldSchema = await convertSFieldToAmisField(field, false, _$1.omit(options, 'buttons'));
1906
1900
  //存在属性上可编辑,实际不可编辑的字段,convertSFieldToAmisField函数可能会返回undefined,如summary
1907
1901
  if (!!fieldSchema) {
1908
1902
  quickEditSchema.body.push(fieldSchema);
@@ -2335,19 +2329,14 @@ function getFieldWidth(width){
2335
2329
  }
2336
2330
 
2337
2331
  async function getColumnItemOnClick(field, options){
2338
- let objectApiName = options.objectName;
2339
- if(!(field.is_name || field.name === options.labelFieldName)){
2340
- objectApiName = field.reference_to;
2341
- }
2342
- const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: objectApiName, formFactor: options.formFactor });
2332
+ const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
2343
2333
  const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
2344
2334
  "recordId": `\${${options.idFieldName}}`,
2345
2335
  "data": {
2346
2336
  ...recordPage.schema.data,
2347
2337
  "_inDrawer": true, // 用于判断是否在抽屉中
2348
2338
  "recordLoaded": false, // 重置数据加载状态
2349
- "recordId": `\${${options.idFieldName}}`,//审批微页面依赖了作用域中的recordId
2350
- "_tableObjectName": options.objectName
2339
+ "recordId": `\${${options.idFieldName}}`//审批微页面依赖了作用域中的recordId
2351
2340
  }
2352
2341
  }) : {
2353
2342
  "type": "steedos-record-detail",
@@ -2358,16 +2347,12 @@ async function getColumnItemOnClick(field, options){
2358
2347
  "data": {
2359
2348
  "_inDrawer": true, // 用于判断是否在抽屉中
2360
2349
  "recordLoaded": false, // 重置数据加载状态
2361
- "_tableObjectName": options.objectName
2362
2350
  }
2363
2351
  };
2364
2352
 
2365
2353
  if(!(field.is_name || field.name === options.labelFieldName)){
2366
2354
  drawerRecordDetailSchema.objectApiName = field.reference_to;
2367
2355
  drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
2368
- // if (recordPage){
2369
- // drawerRecordDetailSchema.data.recordId = `\${_display.${field.name}.value}`
2370
- // }
2371
2356
  }
2372
2357
  return {
2373
2358
  "click": {
@@ -2517,32 +2502,6 @@ async function getTableColumns(object, fields, options){
2517
2502
  static: true,
2518
2503
  }, fieldAmis, {name: field.name});
2519
2504
  }
2520
- else if(field.type === 'lookup' || field.type === 'master_detail'){
2521
- columnItem = Object.assign({}, {
2522
- type: "static-wrapper",
2523
- name: field.name,
2524
- label: field.label,
2525
- sortable: field.sortable,
2526
- width: getFieldWidth(field.width),
2527
- toggled: field.toggled,
2528
- className,
2529
- size: "none",
2530
- inputClassName: "inline",
2531
- body: {
2532
- type: "steedos-field",
2533
- static: true,
2534
- tableObjectName: options.objectName,
2535
- config: {
2536
- type: "lookup",
2537
- reference_to: field.reference_to,
2538
- name: field.name,
2539
- label: null,
2540
- multiple: field.multiple,
2541
- amis: Object.assign({}, fieldAmis, { label: null })
2542
- }
2543
- }
2544
- }, fieldAmis, {name: field.name});
2545
- }
2546
2505
  else {
2547
2506
  const tpl = await getFieldTpl(field, options);
2548
2507
  let type = 'static-text';
@@ -2591,20 +2550,10 @@ async function getTableColumns(object, fields, options){
2591
2550
  columnItem.defaultColor = null;
2592
2551
  }
2593
2552
 
2594
- let needClickEvent = false;
2595
- // if (options.isRelated){
2596
- // // 子表列表上,Lookup字段和名称字段都需要点击事件
2597
- // needClickEvent = ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && _.isString(field.reference_to) && field.multiple != true));
2598
- // }
2599
- // else {// if (isObjectListview)
2600
- // // 列表视图、对象表格中,Lookup字段需要点击事件
2601
- // needClickEvent = (field.type == 'lookup' || field.type == 'master_detail') && _.isString(field.reference_to) && field.multiple != true;
2602
- // }
2603
- // lookup字段走steedos-field组件了,所以这里只需要判断子表名称字段才额外加点击事件弹出右侧详情
2604
- needClickEvent = options.isRelated && (field.is_name || field.name === options.labelFieldName);
2605
- if(window.innerWidth >= 768 && needClickEvent){
2553
+ if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && _$1.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2606
2554
  columnItem.onEvent = await getColumnItemOnClick(field, options);
2607
2555
  }
2556
+
2608
2557
  }
2609
2558
  }
2610
2559
  if(columnItem){
@@ -2871,7 +2820,9 @@ function getButtonVisibleOn$1(button){
2871
2820
  // return 'false';
2872
2821
  // }
2873
2822
  if(visible.trim().startsWith('function')){
2874
- return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
2823
+ visible = visible.replace('function', 'function __visible');
2824
+ 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)}})()`;
2825
+ return visibleStr;
2875
2826
  }
2876
2827
  return visible;
2877
2828
  }
@@ -3260,7 +3211,7 @@ async function getTableApi(mainObject, fields, options){
3260
3211
  const refField = self.uiSchema.fields[relatedKey];
3261
3212
  const masterRecord = self._master.record;
3262
3213
  const masterObjectName = self._master.objectName;
3263
- let relatedValue = self._master.recordId;
3214
+ let relatedValue = masterRecord._id;
3264
3215
  if(refField && refField.reference_to_field && refField.reference_to_field != '_id'){
3265
3216
  relatedValue = masterRecord[refField.reference_to_field]
3266
3217
  }
@@ -3301,6 +3252,7 @@ async function getTableApi(mainObject, fields, options){
3301
3252
  skip: skip,
3302
3253
  fields: ${JSON.stringify(_$1.map(fields, 'name'))}
3303
3254
  }));
3255
+ // console.log('table requestAdaptor', api);
3304
3256
  return api;
3305
3257
  `;
3306
3258
  api.adaptor = `
@@ -3438,17 +3390,15 @@ async function getTableApi(mainObject, fields, options){
3438
3390
  }
3439
3391
  // 标记加载过,后续优先从本地存储中加载相关参数
3440
3392
  payload.data.loaded= true;
3441
-
3442
3393
  const setDataToComponentId = "${setDataToComponentId}";
3443
3394
  if(setDataToComponentId){
3444
3395
  //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
3445
- var scope = SteedosUI.getRef(api.body.$self.$scopeId);
3396
+ var scope = context._scoped;
3446
3397
  var scopeParent = scope && scope.parent;
3447
3398
  var setDataToComponent = scopeParent && scopeParent.getComponentById(setDataToComponentId);
3448
3399
  if(setDataToComponent){
3449
3400
  setDataToComponent.setData({$count: payload.data.count});
3450
3401
  }
3451
- // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
3452
3402
  };
3453
3403
  let formFactor = "${options.formFactor}";
3454
3404
  if(formFactor !== "SMALL"){
@@ -3561,6 +3511,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3561
3511
  payload.data.data = [emptyDoc];
3562
3512
  }
3563
3513
  else{
3514
+ console.log('无法找到记录', api, payload, context)
3564
3515
  return {
3565
3516
  status: 2,
3566
3517
  msg: "${i18next.t('frontend_no_records_found')}"
@@ -3587,13 +3538,12 @@ function getReadonlyFormAdaptor(object, fields, options){
3587
3538
  console.error(e)
3588
3539
  }
3589
3540
  payload.data = data;
3590
- payload.data.__objectName = "${object.name}";
3591
3541
  payload.data.record = record;
3592
3542
  payload.data.NAME_FIELD_VALUE = ${nameLabel} || record.name;
3593
3543
  payload.data._master = {
3594
3544
  record: record,
3595
- objectName: "${object.name}",
3596
- recordId: record._id
3545
+ objectName: "\${objectName}",
3546
+ recordId: "\${recordId}"
3597
3547
  }
3598
3548
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3599
3549
  }
@@ -4502,6 +4452,11 @@ var __assign = function() {
4502
4452
  return t;
4503
4453
  };
4504
4454
  return __assign.apply(this, arguments);
4455
+ };
4456
+
4457
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
4458
+ var e = new Error(message);
4459
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4505
4460
  };
4506
4461
 
4507
4462
  /**
@@ -5151,8 +5106,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
5151
5106
  /*
5152
5107
  * @Author: 殷亮辉 yinlianghui@hotoa.com
5153
5108
  * @Date: 2023-03-22 09:31:21
5154
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5155
- * @LastEditTime: 2025-04-07 16:02:53
5109
+ * @LastEditors: baozhoutao@steedos.com
5110
+ * @LastEditTime: 2024-02-18 16:06:21
5156
5111
  */
5157
5112
  const getSchema$3 = (uiSchema)=>{
5158
5113
  return {
@@ -5212,17 +5167,6 @@ const getSchema$3 = (uiSchema)=>{
5212
5167
  "_isRelated": "${_isRelated}"
5213
5168
  },
5214
5169
  "expression": `\${_master.objectName != '${uiSchema.name}' && _master.objectName}`
5215
- },
5216
- // 列表视图、对象表格组件上的lookup字段,点开右侧弹出drawer窗口,删除记录后刷新列表
5217
- {
5218
- "actionType": "broadcast",
5219
- "args": {
5220
- "eventName": "@data.changed.${_tableObjectName}"
5221
- },
5222
- "data": {
5223
- "objectName": "${_tableObjectName}"
5224
- },
5225
- "expression": `\${_tableObjectName != '${uiSchema.name}' && _tableObjectName}`
5226
5170
  }
5227
5171
  ]
5228
5172
  }
@@ -5514,9 +5458,7 @@ const StandardButtons = {
5514
5458
  objectName,
5515
5459
  uiSchema
5516
5460
  } = this;
5517
- const scopeId = this.scopeId || `amis-${appId}-${objectName}-listview`;
5518
- const scope = this.scope || SteedosUI?.getRef(scopeId);
5519
- //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
5461
+ const scope = this.scope;
5520
5462
  const listViewRef = scope.parent?.getComponentById(`listview_${uiSchema.name}`);
5521
5463
  if(_.isEmpty(listViewRef.props.store.toJSON().selectedItems)){
5522
5464
  listViewRef.handleAction({}, {
@@ -5579,9 +5521,9 @@ function getButtonVisibleOn(button){
5579
5521
  // return 'false';
5580
5522
  // }
5581
5523
  if(visible.trim().startsWith('function')){
5582
- visible = `${visible}.apply({
5524
+ visible = `(function(){try{const fun = ${visible}; return fun.apply({
5583
5525
  object: uiSchema
5584
- }, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`;
5526
+ }, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])}catch(e){console.error(e)}})()`;
5585
5527
  }
5586
5528
  }
5587
5529
 
@@ -5879,7 +5821,7 @@ const execute = (button, props) => {
5879
5821
  ...props,
5880
5822
  action: button
5881
5823
  };
5882
- return button.todo.apply(todoThis, [todoThis.objectName, todoThis.recordId]);
5824
+ return button.todo.apply(todoThis, [todoThis.objectName, todoThis.recordId, props.record?.record?.recordPermissions, props.record]);
5883
5825
  }
5884
5826
  };
5885
5827
 
@@ -6376,21 +6318,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6376
6318
  let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service", {name: "service_object_table_crud"});
6377
6319
  crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
6378
6320
  `;
6379
- /**
6380
- 给lookup字段配置filter_form_data时可以配置为amis变量,也可以配置为事态key-value键值对象值:
6381
- ```
6382
- "filter_form_data": "${selectedPublicGroupFilterFormData|toJson}"
6383
- ```
6384
- or
6385
- ```
6386
- "filter_form_data": {
6387
- "public_group_ids": [
6388
- "67addbef39f9a4503789b38d"
6389
- ]
6390
- }
6391
- ```
6392
- */
6393
- const filterFormValues = ctx.filter_form_data;
6394
6321
  const dataProviderInited = `
6395
6322
  const searchableFields = ${JSON.stringify(searchableFields)};
6396
6323
  const autoOpenFilter = ${autoOpenFilter};
@@ -6428,16 +6355,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6428
6355
  }
6429
6356
  setData({ filterFormSearchableFields: defaultSearchableFields });
6430
6357
  if(isLookup){
6431
- let filterFormValues = ${_.isObject(filterFormValues) ? JSON.stringify(filterFormValues) : ('"' + filterFormValues + '"')} || {};
6432
- const isAmisFormula = typeof filterFormValues === "string" && filterFormValues.indexOf("\${") > -1;
6433
- if (isAmisFormula){
6434
- filterFormValues = AmisCore.evaluate(filterFormValues, data) || {};
6435
- }
6436
- if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
6437
- let fields = data.uiSchema && data.uiSchema.fields;
6438
- filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
6439
- setData({ ...filterFormValues });
6440
- }
6441
6358
  // looup字段过滤器不在本地缓存记住过滤条件,所以初始始终隐藏过滤器
6442
6359
  setData({ showFieldsFilter: autoOpenFilter });
6443
6360
  }
@@ -6729,15 +6646,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6729
6646
  "actionType": "custom",
6730
6647
  "script": onSearchableFieldsChangeScript
6731
6648
  },
6732
- // 自动触发搜索事件会造成bug,应该是升级amis到6.4造成的,见:https://github.com/steedos/steedos-platform/issues/7121
6733
- // 变更搜索项后,用户一般会点击搜索按钮,所以这里不自动触发搜索事件
6734
- // {
6735
- // "actionType": "click",
6736
- // "componentId": btnSearchId,
6737
- // "args": {
6738
- // "__from_fields_filter_settings_confirm": true
6739
- // }
6740
- // },
6649
+ {
6650
+ "actionType": "click",
6651
+ "componentId": btnSearchId,
6652
+ "args": {
6653
+ "__from_fields_filter_settings_confirm": true
6654
+ }
6655
+ },
6741
6656
  {
6742
6657
  "componentId": "",
6743
6658
  "args": {},
@@ -6848,6 +6763,10 @@ const getNewListviewButtonSchema = ()=>{
6848
6763
  "blank": false
6849
6764
  },
6850
6765
  "actionType": "url",
6766
+ },
6767
+ {
6768
+ "actionType": "custom",
6769
+ "script": "window.location.reload();"
6851
6770
  }
6852
6771
  ]
6853
6772
  }
@@ -7717,6 +7636,7 @@ function getObjectListHeader(objectSchema, listViewName, ctx) {
7717
7636
  "body": body,
7718
7637
  "className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
7719
7638
  }];
7639
+ // console.log(`getObjectListHeader`, objectSchema, listViewName, ctx)
7720
7640
  return headerSchema;
7721
7641
  }
7722
7642
 
@@ -7738,7 +7658,7 @@ function getBackButtonSchema(){
7738
7658
  },
7739
7659
  "body":[{
7740
7660
  "type": "button",
7741
- "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
7661
+ "visibleOn": "${window:innerWidth > 768 && display !== 'split'}",
7742
7662
  "className":"flex mr-4",
7743
7663
  "onEvent": {
7744
7664
  "click": {
@@ -7809,12 +7729,12 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
7809
7729
  );
7810
7730
 
7811
7731
  let backButtonsSchema = null;
7812
-
7732
+
7813
7733
  if(options.showBackButton != false){
7814
7734
  backButtonsSchema = getBackButtonSchema();
7815
7735
  }
7816
7736
 
7817
- // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
7737
+ console.log(`getObjectRecordDetailHeader==> backButtonsSchema`, backButtonsSchema);
7818
7738
 
7819
7739
  const reg = new RegExp('_', 'g');
7820
7740
  const standardIcon = icon && icon.replace(reg, '-');
@@ -8054,7 +7974,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
8054
7974
  "body": [
8055
7975
  {
8056
7976
  "type": "tpl",
8057
- "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>`,
7977
+ "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>`,
8058
7978
  "inline": false,
8059
7979
  "wrapperComponent": "",
8060
7980
  "className": "",
@@ -8151,6 +8071,10 @@ const getCopyListviewButtonSchema = ()=>{
8151
8071
  "blank": false
8152
8072
  },
8153
8073
  "actionType": "url",
8074
+ },
8075
+ {
8076
+ "actionType": "custom",
8077
+ "script": "window.location.reload();"
8154
8078
  }
8155
8079
  ]
8156
8080
  }
@@ -8318,6 +8242,10 @@ const getRenameListviewButtonSchema = ()=>{
8318
8242
  },
8319
8243
  "actionType": "url",
8320
8244
  },
8245
+ {
8246
+ "actionType": "custom",
8247
+ "script": "window.location.reload();"
8248
+ }
8321
8249
  ]
8322
8250
  }
8323
8251
  }
@@ -8444,11 +8372,8 @@ const getSetListviewFiltersButtonSchema = ()=>{
8444
8372
  "weight": 0,
8445
8373
  "actions": [
8446
8374
  {
8447
- "args": {
8448
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
8449
- "blank": false
8450
- },
8451
- "actionType": "url",
8375
+ "actionType": "custom",
8376
+ "script": "window.location.reload(); //doAction({'actionType': 'rebuild', 'componentId': `service_listview_${event.data.targetObjectName}`})"
8452
8377
  }
8453
8378
  ]
8454
8379
  }
@@ -8598,11 +8523,8 @@ const getSetListviewColumnsButtonSchema = ()=>{
8598
8523
  "weight": 0,
8599
8524
  "actions": [
8600
8525
  {
8601
- "args": {
8602
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
8603
- "blank": false
8604
- },
8605
- "actionType": "url"
8526
+ "actionType": "custom",
8527
+ "script": "window.location.reload(); //doAction({'actionType': 'rebuild', 'componentId': `service_listview_${event.data.targetObjectName}`})"
8606
8528
  }
8607
8529
  ]
8608
8530
  }
@@ -8751,11 +8673,8 @@ const getSetListviewSortButtonSchema = ()=>{
8751
8673
  "weight": 0,
8752
8674
  "actions": [
8753
8675
  {
8754
- "args": {
8755
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
8756
- "blank": false
8757
- },
8758
- "actionType": "url"
8676
+ "actionType": "custom",
8677
+ "script": "window.location.reload(); //doAction({'actionType': 'rebuild', 'componentId': `service_listview_${event.data.targetObjectName}`})"
8759
8678
  }
8760
8679
  ]
8761
8680
  }
@@ -8876,6 +8795,10 @@ const getDeleteListviewButtonSchema = ()=>{
8876
8795
  "blank": false
8877
8796
  },
8878
8797
  "expression": "data.delete == 1"
8798
+ },
8799
+ {
8800
+ "actionType": "custom",
8801
+ "script": "window.location.reload();"
8879
8802
  }
8880
8803
  ]
8881
8804
  }
@@ -9745,12 +9668,12 @@ async function getObjectCRUD(objectSchema, fields, options){
9745
9668
  payload.status = 2;
9746
9669
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
9747
9670
  }
9748
- var scope = SteedosUI.getRef(context.scopeId);
9749
- var scopeParent = scope && scope.parent;
9750
- var crudScoped = scopeParent.getComponentById('${body.id}');
9751
- setTimeout(()=>{
9752
- crudScoped && crudScoped.control.updateAutoFillHeight();
9753
- }, 500);
9671
+ // var scope = SteedosUI.getRef(context.scopeId);
9672
+ // var scopeParent = scope && scope.parent;
9673
+ // var crudScoped = scopeParent.getComponentById('${body.id}');
9674
+ // setTimeout(()=>{
9675
+ // crudScoped && crudScoped.control.updateAutoFillHeight();
9676
+ // }, 500);
9754
9677
  return payload;
9755
9678
  `;
9756
9679
 
@@ -9957,17 +9880,6 @@ async function getObjectForm(objectSchema, ctx){
9957
9880
  },
9958
9881
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
9959
9882
  },
9960
- // 列表视图、对象表格组件上的lookup字段,点开右侧弹出drawer窗口,修改记录后刷新列表
9961
- {
9962
- "actionType": "broadcast",
9963
- "args": {
9964
- "eventName": "@data.changed.${_tableObjectName}"
9965
- },
9966
- "data": {
9967
- "objectName": "${_tableObjectName}"
9968
- },
9969
- "expression": `\${_tableObjectName != '${objectSchema.name}' && _tableObjectName}`
9970
- },
9971
9883
  ...submitSuccActions,
9972
9884
  // {
9973
9885
  // "actionType": "custom",
@@ -10071,7 +9983,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
10071
9983
  }
10072
9984
 
10073
9985
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
10074
- // console.log('getObjectDetail=====>', amisSchema);
9986
+ // console.log('getObjectDetail=====>', amisSchema, objectSchema, recordId, ctx);
10075
9987
  return amisSchema;
10076
9988
  }
10077
9989
 
@@ -10569,8 +10481,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
10569
10481
  /*
10570
10482
  * @Author: baozhoutao@steedos.com
10571
10483
  * @Date: 2022-07-05 15:55:39
10572
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10573
- * @LastEditTime: 2024-04-26 16:46:44
10484
+ * @LastEditors: baozhoutao@steedos.com
10485
+ * @LastEditTime: 2025-03-07 16:48:27
10574
10486
  * @Description:
10575
10487
  */
10576
10488
 
@@ -10679,7 +10591,7 @@ function formatUISchemaCache(objectName, uiSchema){
10679
10591
  });
10680
10592
  }
10681
10593
 
10682
- async function getUISchema(objectName, force) {
10594
+ async function getUISchema(objectName, force, retry = true) {
10683
10595
  if (!objectName) {
10684
10596
  return;
10685
10597
  }
@@ -10695,7 +10607,13 @@ async function getUISchema(objectName, force) {
10695
10607
  const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
10696
10608
  uiSchema = await fetchAPI(url, { method: "get" });
10697
10609
  }
10698
- if(!uiSchema){
10610
+
10611
+ if(!uiSchema && retry){
10612
+ await new Promise(resolve => setTimeout(resolve, 3000));
10613
+ return getUISchema(objectName, force, false);
10614
+ }
10615
+
10616
+ if(!uiSchema && retry == false){
10699
10617
  return ;
10700
10618
  }
10701
10619
  formatUISchemaCache(objectName, uiSchema);
@@ -10706,7 +10624,16 @@ async function getUISchema(objectName, force) {
10706
10624
  return getUISchemaCache(objectName);
10707
10625
  }
10708
10626
 
10709
- function getUISchemaSync$1(objectName, force) {
10627
+ // 阻塞等待函数,单位毫秒
10628
+ function wait(milliseconds) {
10629
+ const start = new Date().getTime();
10630
+ let now = start;
10631
+ while (now - start < milliseconds) {
10632
+ now = new Date().getTime();
10633
+ }
10634
+ }
10635
+
10636
+ function getUISchemaSync$1(objectName, force, retry = true) {
10710
10637
  if (!objectName) {
10711
10638
  return;
10712
10639
  }
@@ -10722,7 +10649,12 @@ function getUISchemaSync$1(objectName, force) {
10722
10649
  async: false,
10723
10650
  });
10724
10651
 
10725
- if(!uiSchema){
10652
+ if(!uiSchema && retry){
10653
+ wait(2000); // 阻塞等待3秒
10654
+ return getUISchemaSync$1(objectName, force, false)
10655
+ }
10656
+
10657
+ if(!uiSchema && retry == false){
10726
10658
  return ;
10727
10659
  }
10728
10660
  formatUISchemaCache(objectName, uiSchema);
@@ -10767,6 +10699,7 @@ async function getListSchema(
10767
10699
  listViewName,
10768
10700
  ctx = {}
10769
10701
  ) {
10702
+ // console.log('getListSchema', objectName, listView, ctx)
10770
10703
  const uiSchema = await getUISchema(objectName);
10771
10704
  if(!uiSchema){
10772
10705
  return {}
@@ -10797,6 +10730,7 @@ async function getListSchema(
10797
10730
  }
10798
10731
 
10799
10732
  let listViewColumns = getListViewColumns(listView, ctx.formFactor);
10733
+ // console.log('getListSchema listViewColumns', objectName, listView, listViewColumns)
10800
10734
  let sort = getListViewSort(listView);
10801
10735
  let listviewFilter = getListViewFilter(listView);
10802
10736
  let listview_filters = listView && listView._filters;
@@ -11003,7 +10937,7 @@ async function getTableSchema(
11003
10937
  columns,
11004
10938
  ctx = {}
11005
10939
  ) {
11006
- // console.time('getTableSchema', columns);
10940
+ // console.log('getTableSchema', columns);
11007
10941
  const uiSchema = await getUISchema(objectName);
11008
10942
 
11009
10943
  let sort = ctx.sort;
@@ -11037,7 +10971,7 @@ async function getTableSchema(
11037
10971
  };
11038
10972
  crudOptions.amisData = createObject(ctx.amisData || {}, {});
11039
10973
  const amisSchema = await getObjectCRUD(uiSchema, fields, crudOptions);
11040
- // console.timeEnd('getTableSchema');
10974
+ // console.log('getTableSchema', amisSchema, uiSchema);
11041
10975
  return {
11042
10976
  uiSchema,
11043
10977
  amisSchema,
@@ -11074,8 +11008,7 @@ async function getRecordDetailHeaderSchema(objectName,recordId, options){
11074
11008
  }
11075
11009
 
11076
11010
  async function getRecordDetailSchema(objectName, appId, props = {}){
11077
- const uiSchema = await getUISchema(objectName);
11078
-
11011
+ const uiSchema = await getUISchema(objectName);
11079
11012
  const relatedLists = await getObjectRelatedList(objectName);
11080
11013
  const detailed = {
11081
11014
  "title": i18next.t('frontend_record_detail_tab_detailed'),
@@ -11114,21 +11047,6 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
11114
11047
  if(relatedLists.length){
11115
11048
  content.tabs.push(related);
11116
11049
  }
11117
- const contents = [content];
11118
- if (uiSchema.enable_chatter && window.BuilderLiveblocks) {
11119
- const chatter = {
11120
- "type": "rooms-provider",
11121
- "baseUrl": "${context.rootUrl}",
11122
- "body": [
11123
- {
11124
- "type": "rooms-comments",
11125
- "className": "flex flex-col gap-3 m-4",
11126
- "roomId": "objects:${objectName}:${recordId}",
11127
- }
11128
- ]
11129
- };
11130
- contents.push(chatter);
11131
- }
11132
11050
  // content.tabs = reverse(content.tabs)
11133
11051
  return {
11134
11052
  uiSchema,
@@ -11144,7 +11062,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
11144
11062
  "showButtons": props.showButtons,
11145
11063
  "showBackButton": props.showBackButton,
11146
11064
  },
11147
- ...contents,
11065
+ content
11148
11066
  ],
11149
11067
  "objectApiName": "${objectName}",
11150
11068
  "recordId": "${recordId}",
@@ -11928,42 +11846,14 @@ function getLookupSapceUserTreeSchema(isMobile){
11928
11846
  {
11929
11847
  "actionType": "custom",
11930
11848
  "script": `
11931
- console.log("lookup-tree-event.data:",event.data);
11932
- console.log("lookup-tree-event.data.value.label:",event.data.value.label);
11933
- console.log("lookup-tree-event.data.value.value:",event.data.value.value);
11934
11849
  const scope = event.context.scoped;
11935
- var treeFilterFormValues={
11850
+ var filterFormValues={
11936
11851
  "__searchable__organizations_parents":event.data.value.value
11937
11852
  }
11938
- // var listView = scope.parent.getComponents().find(function(n){
11939
- // return n.props.type === "crud";
11940
- // });
11941
- // listView.handleFilterSubmit(Object.assign({}, filterFormValues));
11942
- let __lookupField = event.data.__lookupField;
11943
- let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
11944
- var filterForm = scope.getComponents().find(function(n){
11945
- return n.props.type === "form";
11853
+ var listView = scope.parent.getComponents().find(function(n){
11854
+ return n.props.type === "crud";
11946
11855
  });
11947
- let filterFormValues = filterForm.getData();
11948
- filterFormValues = JSON.parse(JSON.stringify(filterFormValues)); //只取当层数据域中数据,去除__super层数据
11949
- const changedFilterFormValues = _.pickBy(filterFormValues, function(n,k){return /^__searchable__/.test(k);});
11950
- Object.assign(changedFilterFormValues, treeFilterFormValues);
11951
- // 同步__changedFilterFormValues中的值
11952
- let __changedFilterFormValuesKey = "__changedFilterFormValues";
11953
- if(__lookupField){
11954
- let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
11955
- if(__lookupField.reference_to_field){
11956
- lookupTag += "__" + __lookupField.reference_to_field;
11957
- }
11958
- __changedFilterFormValuesKey += lookupTag;
11959
- }
11960
- if(crud){
11961
- let crudData = crud.getData();
11962
- crudData[__changedFilterFormValuesKey] = changedFilterFormValues;
11963
- crud.setData(crudData);
11964
- }
11965
- filterForm.setData(treeFilterFormValues);
11966
- filterForm.handleFormSubmit(event);
11856
+ listView.handleFilterSubmit(Object.assign({}, filterFormValues));
11967
11857
  `
11968
11858
  },
11969
11859
  {
@@ -12181,7 +12071,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
12181
12071
  // field.name可能是带点的名称,比如审批王中子表字段'instances.instances_submitter',如果不替换掉点,会造成审批王表单中新建子表行时报错
12182
12072
  let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
12183
12073
 
12184
- const filterFormValues = field.filter_form_data;
12185
12074
  source.requestAdaptor = `
12186
12075
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
12187
12076
  let __lookupField = api.data.$self.__lookupField;
@@ -12224,20 +12113,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12224
12113
  }
12225
12114
  }
12226
12115
 
12227
- let filterFormValues = {};
12228
- if (selfData.op !== 'loadOptions'){
12229
- filterFormValues = ${_$1.isObject(filterFormValues) ? JSON.stringify(filterFormValues) : ('"' + filterFormValues + '"')} || {};
12230
- const isAmisFormula = typeof filterFormValues === "string" && filterFormValues.indexOf("\${") > -1;
12231
- if (isAmisFormula){
12232
- filterFormValues = AmisCore.evaluate(filterFormValues, context) || {};
12233
- }
12234
- if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
12235
- let fields = api.data.$self.uiSchema && api.data.$self.uiSchema.fields;
12236
- filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
12237
- }
12238
- }
12239
-
12240
- var searchableFilter = SteedosUI.getSearchFilter(Object.assign({}, { ...filterFormValues }, selfData)) || [];
12116
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
12241
12117
 
12242
12118
  if(searchableFilter.length > 0){
12243
12119
  if(filters.length > 0 ){
@@ -12427,7 +12303,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12427
12303
  return payload;
12428
12304
  `;
12429
12305
  }
12430
- let top = 500;
12306
+ let top = 20;
12431
12307
 
12432
12308
  if(refObjectConfig.paging && refObjectConfig.paging.enabled === false){
12433
12309
  top = 1000;
@@ -12477,8 +12353,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12477
12353
  keywordsSearchBoxName,
12478
12354
  searchable_fields: field.searchable_fields,
12479
12355
  auto_open_filter: field.auto_open_filter,
12480
- show_left_filter: field.show_left_filter,
12481
- filter_form_data: field.filter_form_data
12356
+ show_left_filter: field.show_left_filter
12482
12357
  });
12483
12358
  }
12484
12359
  pickerSchema.data = Object.assign({}, pickerSchema.data, {
@@ -12545,7 +12420,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
12545
12420
  }
12546
12421
 
12547
12422
  const ctx = ${JSON.stringify(ctx)};
12548
- const componentId = ctx.defaults && ctx.defaults.formSchema && ctx.defaults.formSchema.id;
12423
+ const componentId = ctx.defaults.formSchema.id;
12549
12424
  doAction({
12550
12425
  actionType: 'setValue',
12551
12426
  componentId: componentId,
@@ -12972,10 +12847,6 @@ async function lookupToAmis(field, readonly, ctx){
12972
12847
  }
12973
12848
  let amisSchema;
12974
12849
  // 默认使用下拉框模式显示lookup选项,只能配置了enable_enhanced_lookup才使用弹出增强模式
12975
- if(enableEnhancedLookup == true && field.amis && field.amis.type && field.amis.type !== 'picker'){
12976
- // 如果配置了amis.type且其值不是picker,则不使用弹出增强模式
12977
- enableEnhancedLookup = false;
12978
- }
12979
12850
  if(enableEnhancedLookup == true){
12980
12851
  amisSchema = await lookupToAmisPicker(field, readonly, ctx);
12981
12852
  }else if(refObject.enable_tree) {
@@ -14107,16 +13978,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
14107
13978
  return convertData
14108
13979
  }
14109
13980
  // if(ctx.mode === 'edit'){
14110
- let convertDataResult;
14111
- if(convertData.type == "steedos-field"){
14112
- // 如果是steedos-field,不能把amis属性合并到steedos-field根属性中,要合并也是合并到steedos-field的config.amis中
14113
- // 而steedos-field字段的amis属性本身就在config.amis中了,所以这里不需要再合并field.amis
14114
- // 目前测试到受影响的是,把字段的amis属性配置为{"type": "checkboxes"}时,ObjectForm只读模式下,lookup字段返回的是type为steedos-field的组件,此时field.amis中的type不应该合并到steedos-field根属性中
14115
- convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, {name: baseData.name});
14116
- }
14117
- else {
14118
- convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
14119
- }
13981
+ let convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
14120
13982
  // 只读时file字段的外层control层若存在name,内部each组件存在问题
14121
13983
  if(readonly && field.type == "file") {
14122
13984
  convertDataResult.name = "";