@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.cjs.js CHANGED
@@ -409,8 +409,8 @@ const Router = {
409
409
  /*
410
410
  * @Author: baozhoutao@steedos.com
411
411
  * @Date: 2022-07-20 16:29:22
412
- * @LastEditors: liaodaxue
413
- * @LastEditTime: 2023-09-11 17:19:53
412
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
413
+ * @LastEditTime: 2023-12-28 14:59:08
414
414
  * @Description:
415
415
  */
416
416
 
@@ -467,6 +467,21 @@ function getLookupListView(refObjectConfig) {
467
467
  return listView;
468
468
  }
469
469
 
470
+
471
+ /**
472
+ * 获取可比较的amis版本号
473
+ * @returns 只返回前两位版本,第三位忽略,比如3.6.3返回3.6
474
+ */
475
+ function getComparableAmisVersion() {
476
+ let amis = (window.amisRequire && window.amisRequire('amis')) || window.Amis;
477
+ let amisVersion = amis && amis.version;
478
+ if(amisVersion){
479
+ let comparableVersions = amisVersion.split(".");
480
+ let comparableVersion = parseFloat(comparableVersions[0].toString() + "." + comparableVersions[1].toString());
481
+ return comparableVersion;
482
+ }
483
+ }
484
+
470
485
  /*
471
486
  * @Author: baozhoutao@steedos.com
472
487
  * @Date: 2022-05-23 09:53:08
@@ -557,7 +572,7 @@ function getNameTpl(field, ctx){
557
572
  if(ctx && ctx.isLookup){
558
573
  linkTarget = "target='_blank'";
559
574
  }
560
- return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
575
+ return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
561
576
  }
562
577
 
563
578
  function getRelatedFieldTpl(field, ctx){
@@ -1114,7 +1129,7 @@ function getAmisStaticFieldType(type, readonly, options){
1114
1129
  * @Author: baozhoutao@steedos.com
1115
1130
  * @Date: 2022-10-28 14:15:09
1116
1131
  * @LastEditors: liaodaxue
1117
- * @LastEditTime: 2023-10-30 17:51:54
1132
+ * @LastEditTime: 2023-12-29 10:46:50
1118
1133
  * @Description:
1119
1134
  */
1120
1135
 
@@ -1168,7 +1183,8 @@ const getAmisFileEditSchema = (steedosField)=>{
1168
1183
  dataType: "form-data",
1169
1184
  url: `\${context.rootUrl}/s3/${tableName}`,
1170
1185
  requestAdaptor: `
1171
- const { _master, global,context } = api.body;
1186
+ const superData = (typeof context != 'undefined') ? context : api.body;
1187
+ const { _master, global } = superData;
1172
1188
  // const { recordId, objectName } = _master;
1173
1189
  const { spaceId, userId, user } = global;
1174
1190
  /*
@@ -1186,8 +1202,9 @@ const getAmisFileEditSchema = (steedosField)=>{
1186
1202
  return api;
1187
1203
  `,
1188
1204
  adaptor: `
1189
- const { context } = api.body;
1190
- var rootUrl = context.rootUrl + "/api/files/${tableName}/";
1205
+ const superData = (typeof context != 'undefined') ? context : api.body;
1206
+ const { context:pageContext } = superData;
1207
+ var rootUrl = pageContext.rootUrl + "/api/files/${tableName}/";
1191
1208
  payload = {
1192
1209
  status: response.status == 200 ? 0 : response.status,
1193
1210
  msg: response.statusText,
@@ -1653,7 +1670,6 @@ async function getQuickEditSchema(field, options){
1653
1670
  {
1654
1671
  "actionType": "custom",
1655
1672
  "script": `
1656
-
1657
1673
  var _display = _.cloneDeep(event.data._display);
1658
1674
  ${displayField}
1659
1675
  doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
@@ -1791,8 +1807,9 @@ async function getQuickEditSchema(field, options){
1791
1807
  case "avatar":
1792
1808
  case "image":
1793
1809
  quickEditSchema.body[0].receiver.adaptor = `
1794
- const { context } = api.body;
1795
- var rootUrl = context.rootUrl + "/api/files/${field.type}s/";
1810
+ const superData = (typeof context != 'undefined') ? context : api.body;
1811
+ const { context:pageContext } = superData;
1812
+ var rootUrl = pageContext.rootUrl + "/api/files/${field.type}s/";
1796
1813
  payload = {
1797
1814
  status: response.status == 200 ? 0 : response.status,
1798
1815
  msg: response.statusText,
@@ -1823,9 +1840,26 @@ async function getQuickEditSchema(field, options){
1823
1840
  "onEvent":{
1824
1841
  "init":{
1825
1842
  "actions":[
1843
+ //amis3.6无法从数据域中直接拿到正确的selectitems,需要通过crud组件的getSelected()函数获取
1844
+ {
1845
+ "actionType": "custom",
1846
+ "script": `
1847
+ crudScoped = event.context.scoped.getComponentById('${options.crudId}');
1848
+ const selectedItems = crudScoped && crudScoped.control.getSelected();
1849
+ doAction({
1850
+ "componentId": "${quickEditId}",
1851
+ "actionType": "setValue",
1852
+ "args": {
1853
+ "value": {
1854
+ selectedItems
1855
+ }
1856
+ }
1857
+ });
1858
+ `
1859
+ },
1826
1860
  {
1827
1861
  "actionType": "setValue",
1828
- "componentId": `service_listview_${options.objectName}`,
1862
+ "componentId": quickEditId,
1829
1863
  "args": {
1830
1864
  "value":{
1831
1865
  "quickedit_record_permissions_loading": true
@@ -1850,7 +1884,7 @@ async function getQuickEditSchema(field, options){
1850
1884
  },
1851
1885
  {
1852
1886
  "actionType": "setValue",
1853
- "componentId": `service_listview_${options.objectName}`,
1887
+ "componentId": quickEditId,
1854
1888
  "args": {
1855
1889
  "value":{
1856
1890
  "quickedit_record_permissions_loading": false
@@ -1859,7 +1893,7 @@ async function getQuickEditSchema(field, options){
1859
1893
  },
1860
1894
  {
1861
1895
  "actionType": "setValue",
1862
- "componentId": `service_listview_${options.objectName}`,
1896
+ "componentId": quickEditId,
1863
1897
  "args": {
1864
1898
  "value":{
1865
1899
  "quickedit_record_permissions": "${event.data}"
@@ -2038,8 +2072,6 @@ function getFieldWidth(width){
2038
2072
  async function getTableColumns(fields, options){
2039
2073
  const columns = [];
2040
2074
  if(!options.isLookup && !options.isInputTable){
2041
- //将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
2042
- columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
2043
2075
  if(!options.enable_tree){
2044
2076
  columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
2045
2077
  }
@@ -2197,8 +2229,8 @@ async function getTableColumns(fields, options){
2197
2229
  const href = Router.getObjectDetailPath({
2198
2230
  ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
2199
2231
  });
2200
- columns[1].type = "tpl";
2201
- columns[1].tpl = `<a href="${href}">\${${columns[1].name}}</a>`;
2232
+ columns[0].type = "tpl";
2233
+ columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
2202
2234
  }
2203
2235
  return columns;
2204
2236
  }
@@ -2457,7 +2489,7 @@ async function getTableOperation(ctx){
2457
2489
  type: 'steedos-object-button',
2458
2490
  name: button.name,
2459
2491
  objectName: button.objectName,
2460
- visibleOn: getButtonVisibleOn$1(button),
2492
+ visibleOnAlias: getButtonVisibleOn$1(button),
2461
2493
  className: 'antd-Button--default'
2462
2494
  });
2463
2495
  });
@@ -2582,8 +2614,18 @@ async function getTableSchema$1(fields, options){
2582
2614
  }
2583
2615
 
2584
2616
  if(!isLookup && !hiddenColumnOperation){
2585
- columns.push(await getTableOperation(options));
2617
+ const toolbarOperation = await getTableOperation(options);
2618
+ columns.push(toolbarOperation);
2586
2619
  }
2620
+
2621
+ }
2622
+
2623
+ const treeConfig = {};
2624
+
2625
+ if(options.enable_tree){
2626
+ treeConfig.expandConfig = {
2627
+ expand: 'first'
2628
+ };
2587
2629
  }
2588
2630
 
2589
2631
  return {
@@ -2601,6 +2643,7 @@ async function getTableSchema$1(fields, options){
2601
2643
  labelTpl: `\${${options.labelFieldName}}`,
2602
2644
  autoFillHeight: false, // 自动高度效果不理想,先关闭
2603
2645
  columnsTogglable: false,
2646
+ ...treeConfig
2604
2647
  }
2605
2648
  }
2606
2649
 
@@ -2917,17 +2960,6 @@ async function getTableApi(mainObject, fields, options){
2917
2960
  payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2918
2961
  assignIndexToTreeRecords(payload.data.rows, '');
2919
2962
  }
2920
- try{
2921
- setTimeout(() => {
2922
- let expandBtn = $('.steedos-object-listview-content .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn');
2923
- if(expandBtn && expandBtn.length > 0 && !expandBtn.hasClass("is-active")){
2924
- expandBtn[0].click();
2925
- }
2926
- }, 600);
2927
- }
2928
- catch(ex){
2929
- console.error("tree数据格式展开异常:", ex);
2930
- }
2931
2963
  }
2932
2964
 
2933
2965
 
@@ -3692,6 +3724,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
3692
3724
  "dialog": {
3693
3725
  "type": "dialog",
3694
3726
  "title": title,
3727
+ data,
3695
3728
  "body": [
3696
3729
  {
3697
3730
  "type": "steedos-object-form",
@@ -5754,12 +5787,16 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5754
5787
  // }
5755
5788
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
5756
5789
  // 点击搜索的时候自动收起搜索栏
5757
- let resizeWindow = function(){
5758
- //触发amis crud 高度重算
5759
- setTimeout(()=>{
5760
- window.dispatchEvent(new Event("resize"))
5761
- }, 500);
5762
- }
5790
+ //触发amis crud 高度重算
5791
+ doAction({
5792
+ "actionType": "broadcast",
5793
+ "args": {
5794
+ "eventName": "@height.changed.${objectSchema.name}"
5795
+ },
5796
+ "data": {
5797
+ "timeOut": 500
5798
+ }
5799
+ });
5763
5800
  const filterService = filterForm.context.getComponents().find(function(n){
5764
5801
  return n.props.type === "service";
5765
5802
  });
@@ -5844,7 +5881,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5844
5881
  // crud && crud.setData({__changedFilterFormValues: {}});
5845
5882
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
5846
5883
  if(isLookup && __lookupField){
5847
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
5884
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
5848
5885
  if(__lookupField.reference_to_field){
5849
5886
  lookupTag += "__" + __lookupField.reference_to_field;
5850
5887
  }
@@ -5861,9 +5898,16 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
5861
5898
  let filterFormService = SteedosUI.getClosestAmisComponentByType(filterForm.context, "service");
5862
5899
  filterFormService.setData({showFieldsFilter: !!!filterFormService.props.data.showFieldsFilter});
5863
5900
  //触发amis crud 高度重算
5864
- setTimeout(()=>{
5865
- window.dispatchEvent(new Event("resize"))
5866
- }, 100);
5901
+ doAction({
5902
+ "actionType": "broadcast",
5903
+ "args": {
5904
+ "eventName": "@height.changed.${objectSchema.name}"
5905
+ },
5906
+ "data": {
5907
+ "timeOut": 100
5908
+ }
5909
+ });
5910
+
5867
5911
  // 移除搜索按钮上的红点
5868
5912
  // let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
5869
5913
  let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -6020,9 +6064,15 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6020
6064
  sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
6021
6065
  }
6022
6066
  //触发amis crud 高度重算
6023
- setTimeout(()=>{
6024
- window.dispatchEvent(new Event("resize"))
6025
- }, 100)
6067
+ doAction({
6068
+ "actionType": "broadcast",
6069
+ "args": {
6070
+ "eventName": "@height.changed.${objectSchema.name}"
6071
+ },
6072
+ "data": {
6073
+ "timeOut": 100
6074
+ }
6075
+ });
6026
6076
  // ===END===
6027
6077
  `;
6028
6078
  return {
@@ -6517,7 +6567,10 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6517
6567
  "@history_paths.changed": {
6518
6568
  "actions": [
6519
6569
  {
6520
- "actionType": "reload"
6570
+ "actionType": "reload",
6571
+ // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6572
+ "data": {
6573
+ }
6521
6574
  }
6522
6575
  ]
6523
6576
  }
@@ -7725,13 +7778,16 @@ const filterService = filterForm.context.getComponents().find(function(n){
7725
7778
  });
7726
7779
  let toShowFieldsFilter = !!!filterService.props.data.showFieldsFilter;
7727
7780
  filterService.setData({showFieldsFilter: toShowFieldsFilter});
7728
- let resizeWindow = function(){
7729
- //触发amis crud 高度重算
7730
- setTimeout(()=>{
7731
- window.dispatchEvent(new Event("resize"))
7732
- }, 1000);
7733
- }
7734
- resizeWindow();
7781
+ //触发amis crud 高度重算
7782
+ doAction({
7783
+ "actionType": "broadcast",
7784
+ "args": {
7785
+ "eventName": "@height.changed." + event.data.objectName
7786
+ },
7787
+ "data": {
7788
+ "timeOut": 1000
7789
+ }
7790
+ });
7735
7791
  // 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
7736
7792
  let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
7737
7793
  crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
@@ -7804,7 +7860,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
7804
7860
  let __lookupField = event.data.__lookupField;
7805
7861
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
7806
7862
  if(isLookup && __lookupField){
7807
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
7863
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
7808
7864
  if(__lookupField.reference_to_field){
7809
7865
  lookupTag += "__" + __lookupField.reference_to_field;
7810
7866
  }
@@ -8095,12 +8151,16 @@ async function getObjectFilter(objectSchema, fields, options) {
8095
8151
  return;
8096
8152
  }
8097
8153
  // 列表搜索栏字段值变更后立刻触发提交表单执行crud搜索,所以这里需要额外重算crud高度及筛选按钮红色星号图标显示隐藏
8098
- let resizeWindow = function(){
8099
- //触发amis crud 高度重算
8100
- setTimeout(()=>{
8101
- window.dispatchEvent(new Event("resize"))
8102
- }, 1000);
8103
- }
8154
+ //触发amis crud 高度重算
8155
+ doAction({
8156
+ "actionType": "broadcast",
8157
+ "args": {
8158
+ "eventName": "@height.changed.${objectSchema.name}"
8159
+ },
8160
+ "data": {
8161
+ "timeOut": 1000
8162
+ }
8163
+ });
8104
8164
  resizeWindow();
8105
8165
  const scope = event.context.scoped;
8106
8166
  // let filterFormValues = event.data;
@@ -8116,13 +8176,13 @@ async function getObjectFilter(objectSchema, fields, options) {
8116
8176
  let onChangeScript = `
8117
8177
  let isLookup = event.data.isLookup;
8118
8178
  let __lookupField = event.data.__lookupField;
8119
- console.log("==onChangeScript=isLookup===", isLookup);
8120
8179
  const scope = event.context.scoped;
8121
8180
  // let filterFormValues = event.data;
8122
8181
  let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
8123
8182
  let filterFormService = SteedosUI.getClosestAmisComponentByType(filterForm.context, "service");
8124
8183
  // 使用event.data的话,并不能拿到本地存储中的过滤条件,所以需要从filterFormService中取。
8125
8184
  let filterFormValues = filterFormService.getData();
8185
+ filterFormValues = JSON.parse(JSON.stringify(filterFormValues)); //只取当层数据域中数据,去除__super层数据
8126
8186
  let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
8127
8187
  const changedFilterFormValues = _.pickBy(filterFormValues, function(n,k){return /^__searchable__/.test(k);});;
8128
8188
  // let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -8131,7 +8191,7 @@ async function getObjectFilter(objectSchema, fields, options) {
8131
8191
  // crud && crud.setData({__changedFilterFormValues: changedFilterFormValues});
8132
8192
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
8133
8193
  if(isLookup && __lookupField){
8134
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
8194
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
8135
8195
  if(__lookupField.reference_to_field){
8136
8196
  lookupTag += "__" + __lookupField.reference_to_field;
8137
8197
  }
@@ -8410,6 +8470,11 @@ async function getObjectCRUD(objectSchema, fields, options){
8410
8470
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8411
8471
  }
8412
8472
 
8473
+ if(body.columns && options.formFactor != 'SMALL'){
8474
+ //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8475
+ body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
8476
+ }
8477
+
8413
8478
  if (defaults) {
8414
8479
  const headerSchema = defaults.headerSchema;
8415
8480
  const footerSchema = defaults.footerSchema;
@@ -8434,6 +8499,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8434
8499
  body = wrappedBody;
8435
8500
  }
8436
8501
  }
8502
+
8437
8503
  // console.timeEnd('getObjectCRUD');
8438
8504
  // TODO: data应该只留loaded,其他属性都改为从上层传递下来
8439
8505
  return {
@@ -8443,7 +8509,24 @@ async function getObjectCRUD(objectSchema, fields, options){
8443
8509
  id: `service_${id}`,
8444
8510
  name: `page`,
8445
8511
  data: options.amisData,
8446
- body: body
8512
+ body: body,
8513
+ //监听广播事件,重算crud高度
8514
+ onEvent: {
8515
+ [`@height.changed.${objectSchema.name}`]: {
8516
+ "actions": [
8517
+ {
8518
+ "actionType": "custom",
8519
+ "script": `
8520
+ var crudScoped = event.context.scoped.getComponentById('${body.id}');
8521
+ var timeOut = event.data.timeOut || 500;
8522
+ setTimeout(()=>{
8523
+ crudScoped && crudScoped.control.updateAutoFillHeight();
8524
+ }, timeOut);
8525
+ `
8526
+ }
8527
+ ]
8528
+ }
8529
+ }
8447
8530
  }
8448
8531
  }
8449
8532
 
@@ -10321,6 +10404,60 @@ function getReferenceToSync(field) {
10321
10404
  }
10322
10405
 
10323
10406
  function getLookupSapceUserTreeSchema(isMobile){
10407
+ let apiAdaptor = `
10408
+ // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10409
+ const records = payload.data.options;
10410
+ let isTreeOptionsComputed = false;
10411
+ if(records.length === 1 && records[0].children){
10412
+ isTreeOptionsComputed = true;
10413
+ }
10414
+ if(isTreeOptionsComputed){
10415
+ return payload;
10416
+ }
10417
+ const treeRecords = [];
10418
+ const getChildren = (records, childrenIds) => {
10419
+ if (!childrenIds) {
10420
+ return;
10421
+ }
10422
+ const children = _.filter(records, (record) => {
10423
+ return _.includes(childrenIds, record.value)
10424
+ });
10425
+ _.each(children, (item) => {
10426
+ if (item.children) {
10427
+ item.children = getChildren(records, item.children)
10428
+ }else{
10429
+ item.children = [];
10430
+ }
10431
+ })
10432
+ return children;
10433
+ }
10434
+
10435
+ const getRoot = (records) => {
10436
+ for (var i = 0; i < records.length; i++) {
10437
+ records[i].noParent = 0;
10438
+ if (!!records[i].parent) {
10439
+ biaozhi = 1
10440
+ for (var j = 0; j < records.length; j++) {
10441
+ if (records[i].parent == records[j].value)
10442
+ biaozhi = 0;
10443
+ }
10444
+ if (biaozhi == 1) records[i].noParent = 1;
10445
+ } else records[i].noParent = 1;
10446
+ }
10447
+ }
10448
+ getRoot(records);
10449
+ console.log(records)
10450
+
10451
+ _.each(records, (record) => {
10452
+ if (record.noParent == 1) {
10453
+ treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10454
+ }
10455
+ });
10456
+ console.log(treeRecords)
10457
+
10458
+ payload.data.options = treeRecords;
10459
+ return payload;
10460
+ `;
10324
10461
  const treeSchema = {
10325
10462
  "type": "input-tree",
10326
10463
  "className":"steedos-select-user-tree",
@@ -10331,8 +10468,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10331
10468
  "headers": {
10332
10469
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
10333
10470
  },
10334
- "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 ",
10335
- "requestAdaptor": "\n ",
10471
+ "adaptor": apiAdaptor,
10336
10472
  "data": {
10337
10473
  "query": "{options:organizations(filters:[\"hidden\", \"!=\", true],sort:\"sort_no desc\"){value:_id label:name,parent,children}}"
10338
10474
  },
@@ -10536,7 +10672,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10536
10672
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
10537
10673
  let __lookupField = api.data.$self.__lookupField;
10538
10674
  if(__lookupField){
10539
- let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
10675
+ let lookupTag = "__lookup__" + __lookupField.name + "__" + __lookupField.reference_to;
10540
10676
  if(__lookupField.reference_to_field){
10541
10677
  lookupTag += "__" + __lookupField.reference_to_field;
10542
10678
  }
@@ -10645,8 +10781,19 @@ async function lookupToAmisPicker(field, readonly, ctx){
10645
10781
  })
10646
10782
  payload.data.rows = rows;
10647
10783
  */
10784
+ if(enable_tree){
10785
+ const rows = _.map(payload.data.rows, (item)=>{
10786
+ delete item.children;
10787
+ delete item.parent;
10788
+ return item;
10789
+ })
10790
+ payload.data.rows = rows;
10791
+ }
10648
10792
  return payload;
10649
10793
  }
10794
+ if(!payload.data.rows){
10795
+ payload.data.rows = [];
10796
+ }
10650
10797
  if(enable_tree){
10651
10798
  const records = payload.data.rows;
10652
10799
  const treeRecords = [];
@@ -10673,6 +10820,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
10673
10820
  _.each(children, (item)=>{
10674
10821
  if(item.children){
10675
10822
  item.children = getChildren(records, item.children)
10823
+ }else{
10824
+ item.children = [];
10676
10825
  }
10677
10826
  })
10678
10827
  return children;
@@ -10685,14 +10834,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
10685
10834
  }
10686
10835
  });
10687
10836
  payload.data.rows = treeRecords;
10688
- try{
10689
- setTimeout(() => {
10690
- $('.amis-dialog-widget.antd-Modal .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn')[0]?.click();
10691
- }, 600);
10692
- }
10693
- catch(ex){
10694
- console.error("tree数据格式展开异常:", ex);
10695
- }
10696
10837
  }
10697
10838
  return payload;
10698
10839
  `;
@@ -10719,6 +10860,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10719
10860
  labelFieldName,
10720
10861
  top: top,
10721
10862
  isLookup: true,
10863
+ enable_tree: refObjectConfig.enable_tree,
10722
10864
  ...ctx
10723
10865
  });
10724
10866
 
@@ -10734,7 +10876,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10734
10876
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
10735
10877
  const isCreate = ___namespace.isBoolean(field.create) ? field.create : true;
10736
10878
  // lookup字段配置过滤条件就强制不显示新建按钮
10737
- let isHasFilters = (field.filters || field._filtersFunction) ? true : false;
10879
+ let isHasFilters = (field.filters || field.filtersFunction || field._filtersFunction) ? true : false;
10738
10880
  if (isAllowCreate && isCreate && !isHasFilters) {
10739
10881
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
10740
10882
  new_button.align = "right";
@@ -10932,7 +11074,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
10932
11074
  sendOn.push(`this.${fName}`);
10933
11075
  });
10934
11076
  if(depend_on.length > 0){
10935
- apiInfo.url = `${apiInfo.url}?${depend_on.join('&')}`;
11077
+ apiInfo.url = `${apiInfo.url}&${depend_on.join('&')}`;
10936
11078
  apiInfo.sendOn = `${sendOn.join(' && ')}`;
10937
11079
  }
10938
11080
  }
@@ -11040,6 +11182,13 @@ async function lookupToAmisSelect(field, readonly, ctx){
11040
11182
  autoComplete: apiInfo,
11041
11183
  searchable: true,
11042
11184
  };
11185
+ let amisVersion = getComparableAmisVersion();
11186
+ if(amisVersion >= 3.6){
11187
+ // amis 3.6中不加source会造成子表组件中弹出行编辑窗口的lookup字段有时不请求接口(概率现象,同一个地方反复操作有时请求有时不请求)
11188
+ // 但是同时配置autoComplete和source会多请求一次接口
11189
+ // TODO:应该想办法把是否字段在子表组件内,即ctx.isInputTable,如果不在子表组件内不需要加source
11190
+ data.source = apiInfo;
11191
+ }
11043
11192
  //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
11044
11193
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
11045
11194
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
@@ -11121,18 +11270,37 @@ async function lookupToAmis(field, readonly, ctx){
11121
11270
 
11122
11271
  // 优先取字段中配置的enable_enhanced_lookup,字段上没配置时,才从对象上取enable_enhanced_lookup属性
11123
11272
  let enableEnhancedLookup = ___namespace.isBoolean(field.enable_enhanced_lookup) ? field.enable_enhanced_lookup : refObject.enable_enhanced_lookup;
11273
+ let amisVersion = getComparableAmisVersion();
11274
+ if(amisVersion >= 3.6){
11275
+ // amis 3.6.3单选和多选的树picker都有bug(https://github.com/baidu/amis/issues/9279,https://github.com/baidu/amis/issues/9295),我们改amis源码修正了
11276
+ // amis 3.6.3多选的下拉树组件有bug,多选树字段的选中值在编辑模式展开树时不会自动勾选树里面的节点,而是始终勾选显示在最外面的选中值选项(即defaultValueOptions),amis 3.2没有这个问题
11277
+ // 这里强制禁用多选下拉树,统一改为弹出树,如果以后需要下拉树功能,可以把下拉树组件改为一次性加载所有树节点数据模式来跳过这个问题
11278
+ if(!enableEnhancedLookup && refObject.enable_tree && field.multiple){
11279
+ enableEnhancedLookup = true;
11280
+ }
11281
+ }
11282
+ let amisSchema;
11124
11283
  // 默认使用下拉框模式显示lookup选项,只能配置了enable_enhanced_lookup才使用弹出增强模式
11125
11284
  if(enableEnhancedLookup == true){
11126
- return await lookupToAmisPicker(field, readonly, ctx);
11285
+ amisSchema = await lookupToAmisPicker(field, readonly, ctx);
11127
11286
  }else if(refObject.enable_tree) {
11128
- return await lookupToAmisTreeSelect(field, readonly, Object.assign({}, ctx, {
11287
+ amisSchema = await lookupToAmisTreeSelect(field, readonly, Object.assign({}, ctx, {
11129
11288
  labelField: referenceTo.labelField?.name || 'name',
11130
11289
  valueField: referenceTo.valueField?.name || '_id',
11131
11290
  objectName: referenceTo.objectName
11132
11291
  }));
11133
11292
  }else {
11134
- return await lookupToAmisSelect(field, readonly, ctx);
11293
+ amisSchema = await lookupToAmisSelect(field, readonly, ctx);
11135
11294
  }
11295
+ let refLookupPage = refObject.pages && refObject.pages.lookup;
11296
+ if(refLookupPage){
11297
+ if(typeof refLookupPage == 'string'){
11298
+ refLookupPage = JSON.parse(refLookupPage);
11299
+ }
11300
+ // Object.assign(amisSchema, refLookupPage);
11301
+ // amisSchema = _.defaultsDeep({}, refLookupPage, amisSchema);
11302
+ }
11303
+ return amisSchema;
11136
11304
  }
11137
11305
 
11138
11306
  async function lookupToAmisSelectUser(field, readonly, ctx){
@@ -11399,9 +11567,9 @@ const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
11399
11567
  // const Lookup = require('./lookup');
11400
11568
 
11401
11569
  function getBaseFields(readonly){
11402
- let calssName = 'm-1';
11570
+ let className = 'm-0';
11403
11571
  if(readonly){
11404
- calssName = `${calssName}`;
11572
+ className = `${className}`;
11405
11573
  }
11406
11574
  return [
11407
11575
  {
@@ -11409,7 +11577,7 @@ function getBaseFields(readonly){
11409
11577
  label: "创建人",
11410
11578
  type: "static",
11411
11579
  labelClassName: 'text-left',
11412
- className: calssName,
11580
+ className: className,
11413
11581
  tpl: getCreatedInfoTpl()
11414
11582
  },
11415
11583
  {
@@ -11417,7 +11585,7 @@ function getBaseFields(readonly){
11417
11585
  label: "修改人",
11418
11586
  type: "static",
11419
11587
  labelClassName: 'text-left',
11420
- className: calssName,
11588
+ className: className,
11421
11589
  tpl: getModifiedInfoTpl()
11422
11590
  }
11423
11591
  ]
@@ -11881,7 +12049,8 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11881
12049
  },
11882
12050
  pipeOut: (value, oldValue, data) => {
11883
12051
  if(value){
11884
- return value/100;
12052
+ const result = value/100;
12053
+ return Number(result.toFixed(field.scale+2));
11885
12054
  }
11886
12055
  return value;
11887
12056
  },
@@ -12113,7 +12282,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12113
12282
  }
12114
12283
  if(!___namespace.isEmpty(convertData)){
12115
12284
  if(field.is_wide || convertData.type === 'group'){
12116
- convertData.className = 'col-span-2 m-1';
12285
+ convertData.className = 'col-span-2 m-0';
12117
12286
  }else {
12118
12287
  convertData.className = 'm-1';
12119
12288
  }
@@ -12520,8 +12689,8 @@ async function getFormBody(permissionFields, formFields, ctx){
12520
12689
  /*
12521
12690
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12522
12691
  * @Date: 2023-11-15 09:50:22
12523
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12524
- * @LastEditTime: 2023-12-26 11:15:04
12692
+ * @LastEditors: baozhoutao@steedos.com
12693
+ * @LastEditTime: 2024-01-02 15:43:50
12525
12694
  */
12526
12695
 
12527
12696
  /**
@@ -13002,6 +13171,11 @@ async function getButtonActions(props, mode) {
13002
13171
  let dialogId = getComponentId("dialog", props.id);
13003
13172
  let buttonNextId = getComponentId("button_next", props.id);
13004
13173
  let formPaginationId = getComponentId("form_pagination", props.id);
13174
+ let parentFormData = "${__super.__super.__super.__super || {}}";
13175
+ let amisVersion = getComparableAmisVersion();
13176
+ if(amisVersion < 3.6){
13177
+ parentFormData = "${__super.__super || {}}";
13178
+ }
13005
13179
  if (mode == "new" || mode == "edit") {
13006
13180
  // let actionShowNewDialog = {
13007
13181
  // "actionType": "dialog",
@@ -13143,7 +13317,9 @@ async function getButtonActions(props, mode) {
13143
13317
  // 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
13144
13318
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13145
13319
  // "__parentForm": "${__super.__super || {}}",
13146
- "__parentForm": mode == "new" ? "$$" : "${__super.__super || {}}",
13320
+ // "__parentForm": mode == "new" ? "$$" : "${__super.__super || {}}",
13321
+ "__parentForm": mode == "new" ? "$$" : parentFormData,
13322
+ "_master": "${_master}",
13147
13323
  "global": "${global}",
13148
13324
  "uiSchema": "${uiSchema}",
13149
13325
  "index": "${index}",
@@ -13236,7 +13412,7 @@ async function getButtonActions(props, mode) {
13236
13412
  // 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
13237
13413
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13238
13414
  // "__parentForm": "${__super.__super || {}}",
13239
- "__parentForm": "${__super.__super || {}}",
13415
+ "__parentForm": parentFormData,
13240
13416
  "global": "${global}",
13241
13417
  "uiSchema": "${uiSchema}",
13242
13418
  "index": "${index}",
@@ -13404,7 +13580,7 @@ const getAmisInputTableSchema = async (props) => {
13404
13580
  "name": "__op__",
13405
13581
  "type": "operation",
13406
13582
  "buttons": buttonsForColumnOperations,
13407
- "width": buttonsForColumnOperations.length > 1 ? "46px" : "20px"
13583
+ "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
13408
13584
  });
13409
13585
  }
13410
13586
  if (showAsInlineEditMode) {
@@ -14853,8 +15029,8 @@ const getInstanceApprovalHistory = async ()=>{
14853
15029
  /*
14854
15030
  * @Author: baozhoutao@steedos.com
14855
15031
  * @Date: 2022-09-07 16:20:45
14856
- * @LastEditors: baozhoutao@steedos.com
14857
- * @LastEditTime: 2023-03-23 16:49:44
15032
+ * @LastEditors: liaodaxue
15033
+ * @LastEditTime: 2023-12-29 16:06:35
14858
15034
  * @Description:
14859
15035
  */
14860
15036
 
@@ -15680,7 +15856,6 @@ const getFlowFormSchema = async (instance, box) => {
15680
15856
  "messages": {
15681
15857
  },
15682
15858
  "requestAdaptor": `
15683
- const { context } = api.data;
15684
15859
  api.data = {
15685
15860
  query: \`
15686
15861
  {
@@ -15703,7 +15878,7 @@ const getFlowFormSchema = async (instance, box) => {
15703
15878
  `,
15704
15879
  "data": {
15705
15880
  // "&": "$$",
15706
- "context": "${context}",
15881
+ // "context": "${context}",
15707
15882
  "judge": "${new_judge}",
15708
15883
  }
15709
15884
  },