@steedos-widgets/amis-lib 1.3.22-beta.4 → 3.6.0-beta.10

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
@@ -382,8 +382,8 @@ const Router = {
382
382
  /*
383
383
  * @Author: baozhoutao@steedos.com
384
384
  * @Date: 2022-07-20 16:29:22
385
- * @LastEditors: liaodaxue
386
- * @LastEditTime: 2023-09-11 17:19:53
385
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
386
+ * @LastEditTime: 2023-12-28 14:59:08
387
387
  * @Description:
388
388
  */
389
389
 
@@ -440,6 +440,21 @@ function getLookupListView(refObjectConfig) {
440
440
  return listView;
441
441
  }
442
442
 
443
+
444
+ /**
445
+ * 获取可比较的amis版本号
446
+ * @returns 只返回前两位版本,第三位忽略,比如3.6.3返回3.6
447
+ */
448
+ function getComparableAmisVersion() {
449
+ let amis = (window.amisRequire && window.amisRequire('amis')) || window.Amis;
450
+ let amisVersion = amis && amis.version;
451
+ if(amisVersion){
452
+ let comparableVersions = amisVersion.split(".");
453
+ let comparableVersion = parseFloat(comparableVersions[0].toString() + "." + comparableVersions[1].toString());
454
+ return comparableVersion;
455
+ }
456
+ }
457
+
443
458
  /*
444
459
  * @Author: baozhoutao@steedos.com
445
460
  * @Date: 2022-05-23 09:53:08
@@ -530,7 +545,7 @@ function getNameTpl(field, ctx){
530
545
  if(ctx && ctx.isLookup){
531
546
  linkTarget = "target='_blank'";
532
547
  }
533
- return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
548
+ return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
534
549
  }
535
550
 
536
551
  function getRelatedFieldTpl(field, ctx){
@@ -1087,7 +1102,7 @@ function getAmisStaticFieldType(type, readonly, options){
1087
1102
  * @Author: baozhoutao@steedos.com
1088
1103
  * @Date: 2022-10-28 14:15:09
1089
1104
  * @LastEditors: liaodaxue
1090
- * @LastEditTime: 2023-10-30 17:51:54
1105
+ * @LastEditTime: 2023-12-29 10:46:50
1091
1106
  * @Description:
1092
1107
  */
1093
1108
 
@@ -1141,7 +1156,8 @@ const getAmisFileEditSchema = (steedosField)=>{
1141
1156
  dataType: "form-data",
1142
1157
  url: `\${context.rootUrl}/s3/${tableName}`,
1143
1158
  requestAdaptor: `
1144
- const { _master, global,context } = api.body;
1159
+ const superData = (typeof context != 'undefined') ? context : api.body;
1160
+ const { _master, global } = superData;
1145
1161
  // const { recordId, objectName } = _master;
1146
1162
  const { spaceId, userId, user } = global;
1147
1163
  /*
@@ -1159,8 +1175,9 @@ const getAmisFileEditSchema = (steedosField)=>{
1159
1175
  return api;
1160
1176
  `,
1161
1177
  adaptor: `
1162
- const { context } = api.body;
1163
- var rootUrl = context.rootUrl + "/api/files/${tableName}/";
1178
+ const superData = (typeof context != 'undefined') ? context : api.body;
1179
+ const { context:pageContext } = superData;
1180
+ var rootUrl = pageContext.rootUrl + "/api/files/${tableName}/";
1164
1181
  payload = {
1165
1182
  status: response.status == 200 ? 0 : response.status,
1166
1183
  msg: response.statusText,
@@ -1626,7 +1643,6 @@ async function getQuickEditSchema(field, options){
1626
1643
  {
1627
1644
  "actionType": "custom",
1628
1645
  "script": `
1629
-
1630
1646
  var _display = _.cloneDeep(event.data._display);
1631
1647
  ${displayField}
1632
1648
  doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
@@ -1764,8 +1780,9 @@ async function getQuickEditSchema(field, options){
1764
1780
  case "avatar":
1765
1781
  case "image":
1766
1782
  quickEditSchema.body[0].receiver.adaptor = `
1767
- const { context } = api.body;
1768
- var rootUrl = context.rootUrl + "/api/files/${field.type}s/";
1783
+ const superData = (typeof context != 'undefined') ? context : api.body;
1784
+ const { context:pageContext } = superData;
1785
+ var rootUrl = pageContext.rootUrl + "/api/files/${field.type}s/";
1769
1786
  payload = {
1770
1787
  status: response.status == 200 ? 0 : response.status,
1771
1788
  msg: response.statusText,
@@ -1796,9 +1813,26 @@ async function getQuickEditSchema(field, options){
1796
1813
  "onEvent":{
1797
1814
  "init":{
1798
1815
  "actions":[
1816
+ //amis3.6无法从数据域中直接拿到正确的selectitems,需要通过crud组件的getSelected()函数获取
1817
+ {
1818
+ "actionType": "custom",
1819
+ "script": `
1820
+ crudScoped = event.context.scoped.getComponentById('${options.crudId}');
1821
+ const selectedItems = crudScoped && crudScoped.control.getSelected();
1822
+ doAction({
1823
+ "componentId": "${quickEditId}",
1824
+ "actionType": "setValue",
1825
+ "args": {
1826
+ "value": {
1827
+ selectedItems
1828
+ }
1829
+ }
1830
+ });
1831
+ `
1832
+ },
1799
1833
  {
1800
1834
  "actionType": "setValue",
1801
- "componentId": `service_listview_${options.objectName}`,
1835
+ "componentId": quickEditId,
1802
1836
  "args": {
1803
1837
  "value":{
1804
1838
  "quickedit_record_permissions_loading": true
@@ -1823,7 +1857,7 @@ async function getQuickEditSchema(field, options){
1823
1857
  },
1824
1858
  {
1825
1859
  "actionType": "setValue",
1826
- "componentId": `service_listview_${options.objectName}`,
1860
+ "componentId": quickEditId,
1827
1861
  "args": {
1828
1862
  "value":{
1829
1863
  "quickedit_record_permissions_loading": false
@@ -1832,7 +1866,7 @@ async function getQuickEditSchema(field, options){
1832
1866
  },
1833
1867
  {
1834
1868
  "actionType": "setValue",
1835
- "componentId": `service_listview_${options.objectName}`,
1869
+ "componentId": quickEditId,
1836
1870
  "args": {
1837
1871
  "value":{
1838
1872
  "quickedit_record_permissions": "${event.data}"
@@ -2011,8 +2045,6 @@ function getFieldWidth(width){
2011
2045
  async function getTableColumns(fields, options){
2012
2046
  const columns = [];
2013
2047
  if(!options.isLookup && !options.isInputTable){
2014
- //将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
2015
- columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
2016
2048
  if(!options.enable_tree){
2017
2049
  columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
2018
2050
  }
@@ -2170,8 +2202,8 @@ async function getTableColumns(fields, options){
2170
2202
  const href = Router.getObjectDetailPath({
2171
2203
  ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
2172
2204
  });
2173
- columns[1].type = "tpl";
2174
- columns[1].tpl = `<a href="${href}">\${${columns[1].name}}</a>`;
2205
+ columns[0].type = "tpl";
2206
+ columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
2175
2207
  }
2176
2208
  return columns;
2177
2209
  }
@@ -2430,7 +2462,7 @@ async function getTableOperation(ctx){
2430
2462
  type: 'steedos-object-button',
2431
2463
  name: button.name,
2432
2464
  objectName: button.objectName,
2433
- visibleOn: getButtonVisibleOn$1(button),
2465
+ visibleOnAlias: getButtonVisibleOn$1(button),
2434
2466
  className: 'antd-Button--default'
2435
2467
  });
2436
2468
  });
@@ -2555,8 +2587,18 @@ async function getTableSchema$1(fields, options){
2555
2587
  }
2556
2588
 
2557
2589
  if(!isLookup && !hiddenColumnOperation){
2558
- columns.push(await getTableOperation(options));
2590
+ const toolbarOperation = await getTableOperation(options);
2591
+ columns.push(toolbarOperation);
2559
2592
  }
2593
+
2594
+ }
2595
+
2596
+ const treeConfig = {};
2597
+
2598
+ if(options.enable_tree){
2599
+ treeConfig.expandConfig = {
2600
+ expand: 'first'
2601
+ };
2560
2602
  }
2561
2603
 
2562
2604
  return {
@@ -2574,6 +2616,7 @@ async function getTableSchema$1(fields, options){
2574
2616
  labelTpl: `\${${options.labelFieldName}}`,
2575
2617
  autoFillHeight: false, // 自动高度效果不理想,先关闭
2576
2618
  columnsTogglable: false,
2619
+ ...treeConfig
2577
2620
  }
2578
2621
  }
2579
2622
 
@@ -2890,17 +2933,6 @@ async function getTableApi(mainObject, fields, options){
2890
2933
  payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2891
2934
  assignIndexToTreeRecords(payload.data.rows, '');
2892
2935
  }
2893
- try{
2894
- setTimeout(() => {
2895
- let expandBtn = $('.steedos-object-listview-content .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn');
2896
- if(expandBtn && expandBtn.length > 0 && !expandBtn.hasClass("is-active")){
2897
- expandBtn[0].click();
2898
- }
2899
- }, 600);
2900
- }
2901
- catch(ex){
2902
- console.error("tree数据格式展开异常:", ex);
2903
- }
2904
2936
  }
2905
2937
 
2906
2938
 
@@ -3665,6 +3697,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
3665
3697
  "dialog": {
3666
3698
  "type": "dialog",
3667
3699
  "title": title,
3700
+ data,
3668
3701
  "body": [
3669
3702
  {
3670
3703
  "type": "steedos-object-form",
@@ -5727,12 +5760,16 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5727
5760
  // }
5728
5761
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
5729
5762
  // 点击搜索的时候自动收起搜索栏
5730
- let resizeWindow = function(){
5731
- //触发amis crud 高度重算
5732
- setTimeout(()=>{
5733
- window.dispatchEvent(new Event("resize"))
5734
- }, 500);
5735
- }
5763
+ //触发amis crud 高度重算
5764
+ doAction({
5765
+ "actionType": "broadcast",
5766
+ "args": {
5767
+ "eventName": "@height.changed.${objectSchema.name}"
5768
+ },
5769
+ "data": {
5770
+ "timeOut": 500
5771
+ }
5772
+ });
5736
5773
  const filterService = filterForm.context.getComponents().find(function(n){
5737
5774
  return n.props.type === "service";
5738
5775
  });
@@ -5817,7 +5854,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5817
5854
  // crud && crud.setData({__changedFilterFormValues: {}});
5818
5855
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
5819
5856
  if(isLookup && __lookupField){
5820
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
5857
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
5821
5858
  if(__lookupField.reference_to_field){
5822
5859
  lookupTag += "__" + __lookupField.reference_to_field;
5823
5860
  }
@@ -5834,9 +5871,16 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5834
5871
  let filterFormService = SteedosUI.getClosestAmisComponentByType(filterForm.context, "service");
5835
5872
  filterFormService.setData({showFieldsFilter: !!!filterFormService.props.data.showFieldsFilter});
5836
5873
  //触发amis crud 高度重算
5837
- setTimeout(()=>{
5838
- window.dispatchEvent(new Event("resize"))
5839
- }, 100);
5874
+ doAction({
5875
+ "actionType": "broadcast",
5876
+ "args": {
5877
+ "eventName": "@height.changed.${objectSchema.name}"
5878
+ },
5879
+ "data": {
5880
+ "timeOut": 100
5881
+ }
5882
+ });
5883
+
5840
5884
  // 移除搜索按钮上的红点
5841
5885
  // let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
5842
5886
  let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -5993,9 +6037,15 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5993
6037
  sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
5994
6038
  }
5995
6039
  //触发amis crud 高度重算
5996
- setTimeout(()=>{
5997
- window.dispatchEvent(new Event("resize"))
5998
- }, 100)
6040
+ doAction({
6041
+ "actionType": "broadcast",
6042
+ "args": {
6043
+ "eventName": "@height.changed.${objectSchema.name}"
6044
+ },
6045
+ "data": {
6046
+ "timeOut": 100
6047
+ }
6048
+ });
5999
6049
  // ===END===
6000
6050
  `;
6001
6051
  return {
@@ -6490,7 +6540,10 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6490
6540
  "@history_paths.changed": {
6491
6541
  "actions": [
6492
6542
  {
6493
- "actionType": "reload"
6543
+ "actionType": "reload",
6544
+ // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6545
+ "data": {
6546
+ }
6494
6547
  }
6495
6548
  ]
6496
6549
  }
@@ -7698,13 +7751,16 @@ const filterService = filterForm.context.getComponents().find(function(n){
7698
7751
  });
7699
7752
  let toShowFieldsFilter = !!!filterService.props.data.showFieldsFilter;
7700
7753
  filterService.setData({showFieldsFilter: toShowFieldsFilter});
7701
- let resizeWindow = function(){
7702
- //触发amis crud 高度重算
7703
- setTimeout(()=>{
7704
- window.dispatchEvent(new Event("resize"))
7705
- }, 1000);
7706
- }
7707
- resizeWindow();
7754
+ //触发amis crud 高度重算
7755
+ doAction({
7756
+ "actionType": "broadcast",
7757
+ "args": {
7758
+ "eventName": "@height.changed." + event.data.objectName
7759
+ },
7760
+ "data": {
7761
+ "timeOut": 1000
7762
+ }
7763
+ });
7708
7764
  // 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
7709
7765
  let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
7710
7766
  crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
@@ -7777,7 +7833,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
7777
7833
  let __lookupField = event.data.__lookupField;
7778
7834
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
7779
7835
  if(isLookup && __lookupField){
7780
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
7836
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
7781
7837
  if(__lookupField.reference_to_field){
7782
7838
  lookupTag += "__" + __lookupField.reference_to_field;
7783
7839
  }
@@ -8068,12 +8124,16 @@ async function getObjectFilter(objectSchema, fields, options) {
8068
8124
  return;
8069
8125
  }
8070
8126
  // 列表搜索栏字段值变更后立刻触发提交表单执行crud搜索,所以这里需要额外重算crud高度及筛选按钮红色星号图标显示隐藏
8071
- let resizeWindow = function(){
8072
- //触发amis crud 高度重算
8073
- setTimeout(()=>{
8074
- window.dispatchEvent(new Event("resize"))
8075
- }, 1000);
8076
- }
8127
+ //触发amis crud 高度重算
8128
+ doAction({
8129
+ "actionType": "broadcast",
8130
+ "args": {
8131
+ "eventName": "@height.changed.${objectSchema.name}"
8132
+ },
8133
+ "data": {
8134
+ "timeOut": 1000
8135
+ }
8136
+ });
8077
8137
  resizeWindow();
8078
8138
  const scope = event.context.scoped;
8079
8139
  // let filterFormValues = event.data;
@@ -8089,13 +8149,13 @@ async function getObjectFilter(objectSchema, fields, options) {
8089
8149
  let onChangeScript = `
8090
8150
  let isLookup = event.data.isLookup;
8091
8151
  let __lookupField = event.data.__lookupField;
8092
- console.log("==onChangeScript=isLookup===", isLookup);
8093
8152
  const scope = event.context.scoped;
8094
8153
  // let filterFormValues = event.data;
8095
8154
  let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
8096
8155
  let filterFormService = SteedosUI.getClosestAmisComponentByType(filterForm.context, "service");
8097
8156
  // 使用event.data的话,并不能拿到本地存储中的过滤条件,所以需要从filterFormService中取。
8098
8157
  let filterFormValues = filterFormService.getData();
8158
+ filterFormValues = JSON.parse(JSON.stringify(filterFormValues)); //只取当层数据域中数据,去除__super层数据
8099
8159
  let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
8100
8160
  const changedFilterFormValues = _.pickBy(filterFormValues, function(n,k){return /^__searchable__/.test(k);});;
8101
8161
  // let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -8104,7 +8164,7 @@ async function getObjectFilter(objectSchema, fields, options) {
8104
8164
  // crud && crud.setData({__changedFilterFormValues: changedFilterFormValues});
8105
8165
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
8106
8166
  if(isLookup && __lookupField){
8107
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
8167
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
8108
8168
  if(__lookupField.reference_to_field){
8109
8169
  lookupTag += "__" + __lookupField.reference_to_field;
8110
8170
  }
@@ -8383,6 +8443,11 @@ async function getObjectCRUD(objectSchema, fields, options){
8383
8443
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8384
8444
  }
8385
8445
 
8446
+ if(body.columns && options.formFactor != 'SMALL'){
8447
+ //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8448
+ body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
8449
+ }
8450
+
8386
8451
  if (defaults) {
8387
8452
  const headerSchema = defaults.headerSchema;
8388
8453
  const footerSchema = defaults.footerSchema;
@@ -8407,6 +8472,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8407
8472
  body = wrappedBody;
8408
8473
  }
8409
8474
  }
8475
+
8410
8476
  // console.timeEnd('getObjectCRUD');
8411
8477
  // TODO: data应该只留loaded,其他属性都改为从上层传递下来
8412
8478
  return {
@@ -8416,7 +8482,24 @@ async function getObjectCRUD(objectSchema, fields, options){
8416
8482
  id: `service_${id}`,
8417
8483
  name: `page`,
8418
8484
  data: options.amisData,
8419
- body: body
8485
+ body: body,
8486
+ //监听广播事件,重算crud高度
8487
+ onEvent: {
8488
+ [`@height.changed.${objectSchema.name}`]: {
8489
+ "actions": [
8490
+ {
8491
+ "actionType": "custom",
8492
+ "script": `
8493
+ var crudScoped = event.context.scoped.getComponentById('${body.id}');
8494
+ var timeOut = event.data.timeOut || 500;
8495
+ setTimeout(()=>{
8496
+ crudScoped && crudScoped.control.updateAutoFillHeight();
8497
+ }, timeOut);
8498
+ `
8499
+ }
8500
+ ]
8501
+ }
8502
+ }
8420
8503
  }
8421
8504
  }
8422
8505
 
@@ -10294,6 +10377,60 @@ function getReferenceToSync(field) {
10294
10377
  }
10295
10378
 
10296
10379
  function getLookupSapceUserTreeSchema(isMobile){
10380
+ let apiAdaptor = `
10381
+ // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10382
+ const records = payload.data.options;
10383
+ let isTreeOptionsComputed = false;
10384
+ if(records.length === 1 && records[0].children){
10385
+ isTreeOptionsComputed = true;
10386
+ }
10387
+ if(isTreeOptionsComputed){
10388
+ return payload;
10389
+ }
10390
+ const treeRecords = [];
10391
+ const getChildren = (records, childrenIds) => {
10392
+ if (!childrenIds) {
10393
+ return;
10394
+ }
10395
+ const children = _.filter(records, (record) => {
10396
+ return _.includes(childrenIds, record.value)
10397
+ });
10398
+ _.each(children, (item) => {
10399
+ if (item.children) {
10400
+ item.children = getChildren(records, item.children)
10401
+ }else{
10402
+ item.children = [];
10403
+ }
10404
+ })
10405
+ return children;
10406
+ }
10407
+
10408
+ const getRoot = (records) => {
10409
+ for (var i = 0; i < records.length; i++) {
10410
+ records[i].noParent = 0;
10411
+ if (!!records[i].parent) {
10412
+ biaozhi = 1
10413
+ for (var j = 0; j < records.length; j++) {
10414
+ if (records[i].parent == records[j].value)
10415
+ biaozhi = 0;
10416
+ }
10417
+ if (biaozhi == 1) records[i].noParent = 1;
10418
+ } else records[i].noParent = 1;
10419
+ }
10420
+ }
10421
+ getRoot(records);
10422
+ console.log(records)
10423
+
10424
+ _.each(records, (record) => {
10425
+ if (record.noParent == 1) {
10426
+ treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10427
+ }
10428
+ });
10429
+ console.log(treeRecords)
10430
+
10431
+ payload.data.options = treeRecords;
10432
+ return payload;
10433
+ `;
10297
10434
  const treeSchema = {
10298
10435
  "type": "input-tree",
10299
10436
  "className":"steedos-select-user-tree",
@@ -10304,8 +10441,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10304
10441
  "headers": {
10305
10442
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
10306
10443
  },
10307
- "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 ",
10308
- "requestAdaptor": "\n ",
10444
+ "adaptor": apiAdaptor,
10309
10445
  "data": {
10310
10446
  "query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
10311
10447
  },
@@ -10509,7 +10645,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10509
10645
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
10510
10646
  let __lookupField = api.data.$self.__lookupField;
10511
10647
  if(__lookupField){
10512
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
10648
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
10513
10649
  if(__lookupField.reference_to_field){
10514
10650
  lookupTag += "__" + __lookupField.reference_to_field;
10515
10651
  }
@@ -10618,8 +10754,19 @@ async function lookupToAmisPicker(field, readonly, ctx){
10618
10754
  })
10619
10755
  payload.data.rows = rows;
10620
10756
  */
10757
+ if(enable_tree){
10758
+ const rows = _.map(payload.data.rows, (item)=>{
10759
+ delete item.children;
10760
+ delete item.parent;
10761
+ return item;
10762
+ })
10763
+ payload.data.rows = rows;
10764
+ }
10621
10765
  return payload;
10622
10766
  }
10767
+ if(!payload.data.rows){
10768
+ payload.data.rows = [];
10769
+ }
10623
10770
  if(enable_tree){
10624
10771
  const records = payload.data.rows;
10625
10772
  const treeRecords = [];
@@ -10646,6 +10793,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
10646
10793
  _.each(children, (item)=>{
10647
10794
  if(item.children){
10648
10795
  item.children = getChildren(records, item.children)
10796
+ }else{
10797
+ item.children = [];
10649
10798
  }
10650
10799
  })
10651
10800
  return children;
@@ -10658,14 +10807,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
10658
10807
  }
10659
10808
  });
10660
10809
  payload.data.rows = treeRecords;
10661
- try{
10662
- setTimeout(() => {
10663
- $('.amis-dialog-widget.antd-Modal .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn')[0]?.click();
10664
- }, 600);
10665
- }
10666
- catch(ex){
10667
- console.error("tree数据格式展开异常:", ex);
10668
- }
10669
10810
  }
10670
10811
  return payload;
10671
10812
  `;
@@ -10692,6 +10833,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10692
10833
  labelFieldName,
10693
10834
  top: top,
10694
10835
  isLookup: true,
10836
+ enable_tree: refObjectConfig.enable_tree,
10695
10837
  ...ctx
10696
10838
  });
10697
10839
 
@@ -10707,7 +10849,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10707
10849
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
10708
10850
  const isCreate = _$1.isBoolean(field.create) ? field.create : true;
10709
10851
  // lookup字段配置过滤条件就强制不显示新建按钮
10710
- let isHasFilters = (field.filters || field._filtersFunction) ? true : false;
10852
+ let isHasFilters = (field.filters || field.filtersFunction || field._filtersFunction) ? true : false;
10711
10853
  if (isAllowCreate && isCreate && !isHasFilters) {
10712
10854
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
10713
10855
  new_button.align = "right";
@@ -10905,7 +11047,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
10905
11047
  sendOn.push(`this.${fName}`);
10906
11048
  });
10907
11049
  if(depend_on.length > 0){
10908
- apiInfo.url = `${apiInfo.url}?${depend_on.join('&')}`;
11050
+ apiInfo.url = `${apiInfo.url}&${depend_on.join('&')}`;
10909
11051
  apiInfo.sendOn = `${sendOn.join(' && ')}`;
10910
11052
  }
10911
11053
  }
@@ -11013,6 +11155,13 @@ async function lookupToAmisSelect(field, readonly, ctx){
11013
11155
  autoComplete: apiInfo,
11014
11156
  searchable: true,
11015
11157
  };
11158
+ let amisVersion = getComparableAmisVersion();
11159
+ if(amisVersion >= 3.6){
11160
+ // amis 3.6中不加source会造成子表组件中弹出行编辑窗口的lookup字段有时不请求接口(概率现象,同一个地方反复操作有时请求有时不请求)
11161
+ // 但是同时配置autoComplete和source会多请求一次接口
11162
+ // TODO:应该想办法把是否字段在子表组件内,即ctx.isInputTable,如果不在子表组件内不需要加source
11163
+ data.source = apiInfo;
11164
+ }
11016
11165
  //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
11017
11166
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
11018
11167
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
@@ -11094,18 +11243,37 @@ async function lookupToAmis(field, readonly, ctx){
11094
11243
 
11095
11244
  // 优先取字段中配置的enable_enhanced_lookup,字段上没配置时,才从对象上取enable_enhanced_lookup属性
11096
11245
  let enableEnhancedLookup = _$1.isBoolean(field.enable_enhanced_lookup) ? field.enable_enhanced_lookup : refObject.enable_enhanced_lookup;
11246
+ let amisVersion = getComparableAmisVersion();
11247
+ if(amisVersion >= 3.6){
11248
+ // amis 3.6.3单选和多选的树picker都有bug(https://github.com/baidu/amis/issues/9279,https://github.com/baidu/amis/issues/9295),我们改amis源码修正了
11249
+ // amis 3.6.3多选的下拉树组件有bug,多选树字段的选中值在编辑模式展开树时不会自动勾选树里面的节点,而是始终勾选显示在最外面的选中值选项(即defaultValueOptions),amis 3.2没有这个问题
11250
+ // 这里强制禁用多选下拉树,统一改为弹出树,如果以后需要下拉树功能,可以把下拉树组件改为一次性加载所有树节点数据模式来跳过这个问题
11251
+ if(!enableEnhancedLookup && refObject.enable_tree && field.multiple){
11252
+ enableEnhancedLookup = true;
11253
+ }
11254
+ }
11255
+ let amisSchema;
11097
11256
  // 默认使用下拉框模式显示lookup选项,只能配置了enable_enhanced_lookup才使用弹出增强模式
11098
11257
  if(enableEnhancedLookup == true){
11099
- return await lookupToAmisPicker(field, readonly, ctx);
11258
+ amisSchema = await lookupToAmisPicker(field, readonly, ctx);
11100
11259
  }else if(refObject.enable_tree) {
11101
- return await lookupToAmisTreeSelect(field, readonly, Object.assign({}, ctx, {
11260
+ amisSchema = await lookupToAmisTreeSelect(field, readonly, Object.assign({}, ctx, {
11102
11261
  labelField: referenceTo.labelField?.name || 'name',
11103
11262
  valueField: referenceTo.valueField?.name || '_id',
11104
11263
  objectName: referenceTo.objectName
11105
11264
  }));
11106
11265
  }else {
11107
- return await lookupToAmisSelect(field, readonly, ctx);
11266
+ amisSchema = await lookupToAmisSelect(field, readonly, ctx);
11108
11267
  }
11268
+ let refLookupPage = refObject.pages && refObject.pages.lookup;
11269
+ if(refLookupPage){
11270
+ if(typeof refLookupPage == 'string'){
11271
+ refLookupPage = JSON.parse(refLookupPage);
11272
+ }
11273
+ // Object.assign(amisSchema, refLookupPage);
11274
+ // amisSchema = _.defaultsDeep({}, refLookupPage, amisSchema);
11275
+ }
11276
+ return amisSchema;
11109
11277
  }
11110
11278
 
11111
11279
  async function lookupToAmisSelectUser(field, readonly, ctx){
@@ -11372,9 +11540,9 @@ const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
11372
11540
  // const Lookup = require('./lookup');
11373
11541
 
11374
11542
  function getBaseFields(readonly){
11375
- let calssName = 'm-1';
11543
+ let className = 'm-0';
11376
11544
  if(readonly){
11377
- calssName = `${calssName}`;
11545
+ className = `${className}`;
11378
11546
  }
11379
11547
  return [
11380
11548
  {
@@ -11382,7 +11550,7 @@ function getBaseFields(readonly){
11382
11550
  label: "创建人",
11383
11551
  type: "static",
11384
11552
  labelClassName: 'text-left',
11385
- className: calssName,
11553
+ className: className,
11386
11554
  tpl: getCreatedInfoTpl()
11387
11555
  },
11388
11556
  {
@@ -11390,7 +11558,7 @@ function getBaseFields(readonly){
11390
11558
  label: "修改人",
11391
11559
  type: "static",
11392
11560
  labelClassName: 'text-left',
11393
- className: calssName,
11561
+ className: className,
11394
11562
  tpl: getModifiedInfoTpl()
11395
11563
  }
11396
11564
  ]
@@ -11854,7 +12022,8 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11854
12022
  },
11855
12023
  pipeOut: (value, oldValue, data) => {
11856
12024
  if(value){
11857
- return value/100;
12025
+ const result = value/100;
12026
+ return Number(result.toFixed(field.scale+2));
11858
12027
  }
11859
12028
  return value;
11860
12029
  },
@@ -12086,7 +12255,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12086
12255
  }
12087
12256
  if(!_$1.isEmpty(convertData)){
12088
12257
  if(field.is_wide || convertData.type === 'group'){
12089
- convertData.className = 'col-span-2 m-1';
12258
+ convertData.className = 'col-span-2 m-0';
12090
12259
  }else {
12091
12260
  convertData.className = 'm-1';
12092
12261
  }
@@ -12493,8 +12662,8 @@ async function getFormBody(permissionFields, formFields, ctx){
12493
12662
  /*
12494
12663
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12495
12664
  * @Date: 2023-11-15 09:50:22
12496
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12497
- * @LastEditTime: 2023-12-26 11:15:04
12665
+ * @LastEditors: baozhoutao@steedos.com
12666
+ * @LastEditTime: 2024-01-02 15:43:50
12498
12667
  */
12499
12668
 
12500
12669
  /**
@@ -12975,6 +13144,11 @@ async function getButtonActions(props, mode) {
12975
13144
  let dialogId = getComponentId("dialog", props.id);
12976
13145
  let buttonNextId = getComponentId("button_next", props.id);
12977
13146
  let formPaginationId = getComponentId("form_pagination", props.id);
13147
+ let parentFormData = "${__super.__super.__super.__super || {}}";
13148
+ let amisVersion = getComparableAmisVersion();
13149
+ if(amisVersion < 3.6){
13150
+ parentFormData = "${__super.__super || {}}";
13151
+ }
12978
13152
  if (mode == "new" || mode == "edit") {
12979
13153
  // let actionShowNewDialog = {
12980
13154
  // "actionType": "dialog",
@@ -13116,7 +13290,9 @@ async function getButtonActions(props, mode) {
13116
13290
  // 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
13117
13291
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13118
13292
  // "__parentForm": "${__super.__super || {}}",
13119
- "__parentForm": mode == "new" ? "$$" : "${__super.__super || {}}",
13293
+ // "__parentForm": mode == "new" ? "$$" : "${__super.__super || {}}",
13294
+ "__parentForm": mode == "new" ? "$$" : parentFormData,
13295
+ "_master": "${_master}",
13120
13296
  "global": "${global}",
13121
13297
  "uiSchema": "${uiSchema}",
13122
13298
  "index": "${index}",
@@ -13209,7 +13385,7 @@ async function getButtonActions(props, mode) {
13209
13385
  // 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
13210
13386
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13211
13387
  // "__parentForm": "${__super.__super || {}}",
13212
- "__parentForm": "${__super.__super || {}}",
13388
+ "__parentForm": parentFormData,
13213
13389
  "global": "${global}",
13214
13390
  "uiSchema": "${uiSchema}",
13215
13391
  "index": "${index}",
@@ -13377,7 +13553,7 @@ const getAmisInputTableSchema = async (props) => {
13377
13553
  "name": "__op__",
13378
13554
  "type": "operation",
13379
13555
  "buttons": buttonsForColumnOperations,
13380
- "width": buttonsForColumnOperations.length > 1 ? "46px" : "20px"
13556
+ "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
13381
13557
  });
13382
13558
  }
13383
13559
  if (showAsInlineEditMode) {
@@ -14826,8 +15002,8 @@ const getInstanceApprovalHistory = async ()=>{
14826
15002
  /*
14827
15003
  * @Author: baozhoutao@steedos.com
14828
15004
  * @Date: 2022-09-07 16:20:45
14829
- * @LastEditors: baozhoutao@steedos.com
14830
- * @LastEditTime: 2023-03-23 16:49:44
15005
+ * @LastEditors: liaodaxue
15006
+ * @LastEditTime: 2023-12-29 16:06:35
14831
15007
  * @Description:
14832
15008
  */
14833
15009
 
@@ -15653,7 +15829,6 @@ const getFlowFormSchema = async (instance, box) => {
15653
15829
  "messages": {
15654
15830
  },
15655
15831
  "requestAdaptor": `
15656
- const { context } = api.data;
15657
15832
  api.data = {
15658
15833
  query: \`
15659
15834
  {
@@ -15676,7 +15851,7 @@ const getFlowFormSchema = async (instance, box) => {
15676
15851
  `,
15677
15852
  "data": {
15678
15853
  // "&": "$$",
15679
- "context": "${context}",
15854
+ // "context": "${context}",
15680
15855
  "judge": "${new_judge}",
15681
15856
  }
15682
15857
  },