@steedos-widgets/amis-lib 3.6.2-beta.2 → 3.6.2-beta.20

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
@@ -340,22 +340,29 @@ const getSteedosAuth = () => {
340
340
  * @Description:
341
341
  */
342
342
 
343
-
344
343
  const Router = {
345
344
  getTabDisplayAs(tab_id){
345
+ const uiSchema = getUISchemaSync$1(tab_id, false);
346
346
  var urlSearch = new URLSearchParams(document.location.search);
347
347
  if(urlSearch.has('display')){
348
348
  return urlSearch.get('display')
349
349
  }
350
350
  const key = `tab_${tab_id}_display`;
351
351
  // const key = `page_display`;
352
- const value = localStorage.getItem(key);
353
- return value ? value : 'grid'
352
+ const value = sessionStorage.getItem(key);
353
+ let defaultDisplay = "grid";
354
+ if(uiSchema.enable_split){
355
+ defaultDisplay = "split";
356
+ }
357
+ if(window.innerWidth <= 768){
358
+ return "grid";
359
+ }
360
+ return value ? value : defaultDisplay;
354
361
  },
355
362
 
356
363
  setTabDisplayAs(tab_id, displayAs){
357
364
  const key = `tab_${tab_id}_display`;
358
- localStorage.setItem(key, displayAs);
365
+ sessionStorage.setItem(key, displayAs);
359
366
  },
360
367
  getAppPath({formFactor, appId}){
361
368
  return `/app/${appId}`;
@@ -382,8 +389,8 @@ const Router = {
382
389
  /*
383
390
  * @Author: baozhoutao@steedos.com
384
391
  * @Date: 2022-07-20 16:29:22
385
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
386
- * @LastEditTime: 2023-12-28 14:59:08
392
+ * @LastEditors: liaodaxue
393
+ * @LastEditTime: 2024-01-25 14:44:17
387
394
  * @Description:
388
395
  */
389
396
 
@@ -455,11 +462,30 @@ function getComparableAmisVersion() {
455
462
  }
456
463
  }
457
464
 
465
+ /**
466
+ * 判断浏览器类型
467
+ * @returns 按需返回浏览器类型;
468
+ */
469
+ function getBowserType() {
470
+ const userAgent = navigator.userAgent;
471
+ if (userAgent.indexOf("Chrome")!== -1 && userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Edg") === -1) {
472
+ return "Chrome";
473
+ } else if (userAgent.indexOf("Firefox") !== -1) {
474
+ return "Firefox";
475
+ } else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("Edge") === -1) {
476
+ return "Safari";
477
+ } else if (userAgent.indexOf("Edg") !== -1) {
478
+ return "Edge";
479
+ } else {
480
+ return "Unknown browser"; // 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
481
+ }
482
+ }
483
+
458
484
  /*
459
485
  * @Author: baozhoutao@steedos.com
460
486
  * @Date: 2022-05-23 09:53:08
461
487
  * @LastEditors: liaodaxue
462
- * @LastEditTime: 2023-10-11 17:32:17
488
+ * @LastEditTime: 2024-01-17 16:00:27
463
489
  * @Description:
464
490
  */
465
491
 
@@ -531,7 +557,7 @@ function getSelectMap(selectOptions){
531
557
 
532
558
  function getNameTplUrl(field, ctx){
533
559
  if(ctx.objectName === 'cms_files'){
534
- return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
560
+ return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
535
561
  }
536
562
  const href = Router.getObjectDetailPath({
537
563
  ...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
@@ -1277,6 +1303,7 @@ var frontend_notifications$1 = "Notifications";
1277
1303
  var frontend_notifications_allread$1 = "Mark all as read";
1278
1304
  var frontend_notifications_allread_message$1 = "All marked as read";
1279
1305
  var frontend_profile$1 = "Profile";
1306
+ var switch_space$1 = "Switch Space";
1280
1307
  var frontend_about$1 = "About";
1281
1308
  var frontend_log_out$1 = "Log out";
1282
1309
  var frontend_listview_warning_start$1 = "The current ";
@@ -1364,6 +1391,7 @@ var en_us = {
1364
1391
  frontend_notifications_allread: frontend_notifications_allread$1,
1365
1392
  frontend_notifications_allread_message: frontend_notifications_allread_message$1,
1366
1393
  frontend_profile: frontend_profile$1,
1394
+ switch_space: switch_space$1,
1367
1395
  frontend_about: frontend_about$1,
1368
1396
  frontend_log_out: frontend_log_out$1,
1369
1397
  frontend_listview_warning_start: frontend_listview_warning_start$1,
@@ -1403,9 +1431,9 @@ var frontend_display_type_is_split = "分栏视图";
1403
1431
  var frontend_display_as = "显示为";
1404
1432
  var frontend_record_sum = "个项目";
1405
1433
  var frontend_button_reload_tooltip = "刷新";
1406
- var frontend_button_search_tooltip = "筛选";
1434
+ var frontend_button_search_tooltip = "搜索";
1407
1435
  var frontend_fields_filter_button_search = "搜索";
1408
- var frontend_fields_filter_button_settings = "设置搜索项";
1436
+ var frontend_fields_filter_button_settings = "选择搜索项";
1409
1437
  var frontend_button_listview_control_tooltip = "列表视图控制";
1410
1438
  var frontend_button_listview_control_label = "列表视图控制";
1411
1439
  var frontend_listview_control_columns = "显示的列";
@@ -1453,6 +1481,7 @@ var frontend_notifications = "通知";
1453
1481
  var frontend_notifications_allread = "全部标记为已读";
1454
1482
  var frontend_notifications_allread_message = "已全部标记为已读";
1455
1483
  var frontend_profile = "个人资料";
1484
+ var switch_space = "切换工作区";
1456
1485
  var frontend_about = "关于";
1457
1486
  var frontend_log_out = "注销";
1458
1487
  var frontend_listview_warning_start = "当前";
@@ -1541,6 +1570,7 @@ var zh_cn = {
1541
1570
  frontend_notifications_allread: frontend_notifications_allread,
1542
1571
  frontend_notifications_allread_message: frontend_notifications_allread_message,
1543
1572
  frontend_profile: frontend_profile,
1573
+ switch_space: switch_space,
1544
1574
  frontend_about: frontend_about,
1545
1575
  frontend_log_out: frontend_log_out,
1546
1576
  frontend_listview_warning_start: frontend_listview_warning_start,
@@ -1854,7 +1884,8 @@ async function getQuickEditSchema(field, options){
1854
1884
  "failed": "失败了呢。。"
1855
1885
  }
1856
1886
  }
1857
- }
1887
+ },
1888
+ "expression": "${!recordPermissions.modifyAllRecords}"
1858
1889
  },
1859
1890
  {
1860
1891
  "actionType": "setValue",
@@ -1870,7 +1901,7 @@ async function getQuickEditSchema(field, options){
1870
1901
  "componentId": quickEditId,
1871
1902
  "args": {
1872
1903
  "value":{
1873
- "quickedit_record_permissions": "${event.data}"
1904
+ "quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
1874
1905
  }
1875
1906
  }
1876
1907
  }
@@ -1934,7 +1965,7 @@ async function getQuickEditSchema(field, options){
1934
1965
  `
1935
1966
  }
1936
1967
  },
1937
- "expression":"${event.data.value}"
1968
+ "expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
1938
1969
  },
1939
1970
  {
1940
1971
  "actionType": "setValue",
@@ -1965,10 +1996,20 @@ async function getQuickEditSchema(field, options){
1965
1996
  "script": `
1966
1997
  const noPermission = event.data.noPermission;
1967
1998
  const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
1968
- const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
1999
+ let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
1969
2000
  noPermission.forEach(function (item) {
1970
2001
  crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
2002
+ _.remove(selectedItems, (selected) => selected._id === item);
1971
2003
  })
2004
+ doAction({
2005
+ "componentId": "${quickEditId}",
2006
+ "actionType": "setValue",
2007
+ "args": {
2008
+ "value": {
2009
+ selectedItems
2010
+ }
2011
+ }
2012
+ });
1972
2013
  `
1973
2014
  },
1974
2015
  {
@@ -2029,7 +2070,7 @@ async function getQuickEditSchema(field, options){
2029
2070
  }
2030
2071
 
2031
2072
  function getFieldWidth(width){
2032
- const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2073
+ const defaultWidth = null;
2033
2074
  if(typeof width == 'string'){
2034
2075
  if(isNaN(width)){
2035
2076
  return width || defaultWidth;
@@ -2059,18 +2100,35 @@ async function getTableColumns(fields, options){
2059
2100
  //增加quickEdit属性,实现快速编辑
2060
2101
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2061
2102
  let className = "";
2062
- if(field.wrap != true){
2103
+ const bowserType = getBowserType();
2104
+ if(bowserType === "Safari"){
2063
2105
  className += " whitespace-nowrap ";
2064
2106
  }else {
2065
- className += " break-all ";
2107
+ if(field.wrap != true){
2108
+ className += " whitespace-nowrap ";
2109
+ }else {
2110
+ className += " break-words ";
2111
+ }
2066
2112
  }
2113
+
2114
+ if (typeof field.amis?.className == "object") {
2115
+ className = {
2116
+ [className]: "true",
2117
+ ...field.amis.className
2118
+ };
2119
+ } else if (typeof field.amis?.className == "string") {
2120
+ className = `${className} ${field.amis.className} `;
2121
+ }
2122
+ let fieldAmis = _$1.clone(field.amis);
2123
+ delete fieldAmis?.className;
2124
+
2067
2125
  let columnItem;
2068
2126
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
2069
2127
  const previewFileScript = `
2070
2128
  var data = event.data;
2071
2129
  var file_name = data.versions ? data.name : "${field.label}";
2072
- var file_id = data._id;
2073
- SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
2130
+ var file_id = data.versions && data.versions[0] && data.versions[0]._id;
2131
+ window.previewFile && window.previewFile({file_name, file_id});
2074
2132
  `;
2075
2133
  columnItem = {
2076
2134
  "type": "button",
@@ -2099,7 +2157,7 @@ async function getTableColumns(fields, options){
2099
2157
  "actionType": "custom",
2100
2158
  "script": previewFileScript,
2101
2159
  // "expression": "!!window?.nw?.require" //PC客户端预览附件
2102
- "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2160
+ "expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2103
2161
  }
2104
2162
  ]
2105
2163
  }
@@ -2114,7 +2172,7 @@ async function getTableColumns(fields, options){
2114
2172
  toggled: field.toggled,
2115
2173
  static: true,
2116
2174
  className,
2117
- }, field.amis, {name: field.name});
2175
+ }, fieldAmis, {name: field.name});
2118
2176
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
2119
2177
  columnItem = Object.assign({}, {
2120
2178
  type: "switch",
@@ -2125,7 +2183,7 @@ async function getTableColumns(fields, options){
2125
2183
  static: true,
2126
2184
  className,
2127
2185
  ...getAmisFileReadonlySchema(field)
2128
- }, field.amis, {name: field.name});
2186
+ }, fieldAmis, {name: field.name});
2129
2187
  }
2130
2188
  else if(field.type === 'select'){
2131
2189
  const map = getSelectMap(field.options);
@@ -2140,7 +2198,7 @@ async function getTableColumns(fields, options){
2140
2198
  className,
2141
2199
  inputClassName: "inline",
2142
2200
  static: true,
2143
- }, field.amis, {name: field.name});
2201
+ }, fieldAmis, {name: field.name});
2144
2202
  }
2145
2203
  else {
2146
2204
  const tpl = await getFieldTpl(field, options);
@@ -2159,23 +2217,14 @@ async function getTableColumns(fields, options){
2159
2217
  if(field.type === 'textarea'){
2160
2218
  className += 'min-w-56';
2161
2219
  }
2162
- if(field.type === 'date'){
2163
- className += 'date-min-w';
2164
- }
2165
- if(field.type === 'datetime'){
2166
- className += 'datetime-min-w';
2167
- }
2220
+ // if(field.type === 'date'){
2221
+ // className += 'date-min-w';
2222
+ // }
2223
+ // if(field.type === 'datetime'){
2224
+ // className += 'datetime-min-w';
2225
+ // }
2168
2226
 
2169
2227
  //field上的amis属性里的clssname需要单独判断类型合并
2170
- if (typeof field.amis?.className == "object") {
2171
- className = {
2172
- [className]: "true",
2173
- ...field.amis.className
2174
- };
2175
- } else if (typeof field.amis?.className == "string") {
2176
- className = `${className} ${field.amis.className} `;
2177
- }
2178
- delete field.amis?.className;
2179
2228
 
2180
2229
  if(!field.hidden && !field.extra){
2181
2230
  columnItem = Object.assign({}, {
@@ -2192,7 +2241,7 @@ async function getTableColumns(fields, options){
2192
2241
  static: true,
2193
2242
  options: field.type === 'html' ? {html: true} : null
2194
2243
  // toggled: true
2195
- }, field.amis, {name: field.name});
2244
+ }, fieldAmis, {name: field.name});
2196
2245
 
2197
2246
  if(field.type === 'color'){
2198
2247
  columnItem.type = 'color';
@@ -2259,7 +2308,7 @@ function getMobileLines(tpls){
2259
2308
  }
2260
2309
  if(isLeft){
2261
2310
  // 左侧半行
2262
- lineChildrenClassName = "steedos-listview-item-left truncate";
2311
+ lineChildrenClassName = "steedos-listview-item-left truncate h-5";
2263
2312
  if(item.field.is_wide){
2264
2313
  // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
2265
2314
  lineChildrenClassName = "steedos-listview-item-wide";
@@ -2271,7 +2320,7 @@ function getMobileLines(tpls){
2271
2320
  }
2272
2321
  else {
2273
2322
  // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
2274
- lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
2323
+ lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
2275
2324
  }
2276
2325
  //支持字段amis属性配置classname,识别classname的类型,与原样式合并
2277
2326
  var className;
@@ -2382,7 +2431,15 @@ async function getMobileTableColumns(fields, options){
2382
2431
  "actions": [
2383
2432
  {
2384
2433
  "script": `
2385
- let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
2434
+ let cms_url = '';
2435
+ let value = event.data.versions[0];
2436
+ if(value){
2437
+ if(value.url){
2438
+ cms_url = value.url;
2439
+ }else{
2440
+ cms_url = "/api/files/files/"+value+"?download=true"
2441
+ }
2442
+ }
2386
2443
  Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
2387
2444
  `,
2388
2445
  "actionType": "custom"
@@ -2498,7 +2555,8 @@ async function getTableOperation(ctx){
2498
2555
  label: "&nbsp;",
2499
2556
  fixed: 'right',
2500
2557
  labelClassName: 'text-center',
2501
- className: 'text-center steedos-listview-operation w-10',
2558
+ //TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
2559
+ className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
2502
2560
  buttons: [
2503
2561
  {
2504
2562
  "type": "steedos-dropdown-button",
@@ -2594,7 +2652,7 @@ async function getTableSchema$1(fields, options){
2594
2652
  }
2595
2653
  return {
2596
2654
  mode: "cards",
2597
- perPageAvailable: [5, 10, 20, 50, 100, 500],
2655
+ perPageAvailable: [20, 50, 100, 500],
2598
2656
  name: "thelist",
2599
2657
  headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
2600
2658
  className: "",
@@ -2627,7 +2685,7 @@ async function getTableSchema$1(fields, options){
2627
2685
 
2628
2686
  return {
2629
2687
  mode: "table",
2630
- perPageAvailable: [5, 10, 20, 50, 100, 500],
2688
+ perPageAvailable: [20, 50, 100, 500],
2631
2689
  name: "thelist",
2632
2690
  headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
2633
2691
  className: "",
@@ -2882,6 +2940,21 @@ async function getTableApi(mainObject, fields, options){
2882
2940
  return api;
2883
2941
  `;
2884
2942
  api.adaptor = `
2943
+ let fields = ${JSON.stringify(_$1.map(fields, 'name'))};
2944
+ // 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
2945
+ (payload.data.rows || []).forEach((itemRow) => {
2946
+ (fields || []).forEach((itemField) => {
2947
+ if(itemField && itemField.indexOf(".") > -1){
2948
+ return;
2949
+ }
2950
+ if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
2951
+ // 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
2952
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
2953
+ itemRow[itemField] = "";
2954
+ }
2955
+ });
2956
+ });
2957
+
2885
2958
  if(api.body.listName == "recent"){
2886
2959
  payload.data.rows = _.sortBy(payload.data.rows, function(item){
2887
2960
  return _.indexOf(api.body._ids, item._id)
@@ -2906,7 +2979,13 @@ async function getTableApi(mainObject, fields, options){
2906
2979
  value = [value]
2907
2980
  };
2908
2981
  if(field.type === 'file'){
2909
- item[key] = value
2982
+ // item[key] = value
2983
+ // PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
2984
+ let itemKeyValue = item[key];
2985
+ item[key] = value.map(function(item, index){
2986
+ item._id = itemKeyValue[index];
2987
+ return item;
2988
+ });
2910
2989
  }else{
2911
2990
  item[key] = _.map(value, (item)=>{
2912
2991
  if(field.type === 'image'){
@@ -2948,15 +3027,8 @@ async function getTableApi(mainObject, fields, options){
2948
3027
  }
2949
3028
  });
2950
3029
  };
2951
- let isTreeOptionsComputed = false;
2952
- if(records.length === 1 && records[0].children){
2953
- isTreeOptionsComputed = true;
2954
- }
2955
- if(!isTreeOptionsComputed){
2956
- // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2957
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2958
- assignIndexToTreeRecords(payload.data.rows, '');
2959
- }
3030
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
3031
+ assignIndexToTreeRecords(payload.data.rows, '');
2960
3032
  }
2961
3033
 
2962
3034
 
@@ -3013,12 +3085,15 @@ async function getTableApi(mainObject, fields, options){
3013
3085
  }
3014
3086
  // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
3015
3087
  };
3016
- const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3017
- const firstListviewComponent = listviewComponent && listviewComponent[0];
3018
- if(firstListviewComponent){
3019
- setTimeout(()=>{
3020
- firstListviewComponent.scrollIntoView();
3021
- }, 600);
3088
+ let formFactor = "${options.formFactor}";
3089
+ if(formFactor !== "SMALL"){
3090
+ const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3091
+ const firstListviewComponent = listviewComponent && listviewComponent[0];
3092
+ if(firstListviewComponent){
3093
+ setTimeout(()=>{
3094
+ firstListviewComponent.scrollIntoView();
3095
+ }, 600);
3096
+ }
3022
3097
  }
3023
3098
  ${options.adaptor || ''}
3024
3099
  return payload;
@@ -3131,12 +3206,21 @@ function getReadonlyFormAdaptor(object, fields, options){
3131
3206
  }
3132
3207
  payload.data = data;
3133
3208
  payload.data.__objectName = "${object.name}";
3134
- payload.data.__record = record;
3209
+ payload.data.record = record;
3210
+
3211
+ payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
3212
+ payload.data._master = {
3213
+ record: record,
3214
+ objectName: "${object.name}",
3215
+ recordId: record._id
3216
+ }
3135
3217
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3136
3218
  }
3137
3219
  if(payload.errors){
3138
3220
  payload.status = 2;
3139
3221
  payload.msg = payload.errors[0].message;
3222
+ }else{
3223
+ payload.data.recordLoaded = true;
3140
3224
  }
3141
3225
  ${options && options.initApiAdaptor || ''}
3142
3226
  return payload;
@@ -3279,7 +3363,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
3279
3363
  cache: API_CACHE,
3280
3364
  requestAdaptor: `
3281
3365
  // 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
3282
- var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
3366
+ var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
3283
3367
  if(!recordId){
3284
3368
  // 新建则不请求任何数据
3285
3369
  data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
@@ -3357,10 +3441,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
3357
3441
  ...initialValues
3358
3442
  }
3359
3443
  ${options.initApiAdaptor || ''}
3444
+ // console.log('getEditFormInitApi======>', payload);
3360
3445
  return payload;
3361
3446
  `,
3362
3447
  responseData: {
3363
- initialValues: "$$",
3448
+ "&": "$$",
3364
3449
  editFormInited: true
3365
3450
  },
3366
3451
  data: data,
@@ -3399,6 +3484,18 @@ function getBatchDelete(objectName){
3399
3484
  return {
3400
3485
  method: 'post',
3401
3486
  url: getApi$2(),
3487
+ adaptor: `
3488
+ if(payload.errors){
3489
+ payload.data.deleteErrorMessage = [];
3490
+ payload.errors.forEach(function(error){
3491
+ let errorRecord = error.path.map(function (item) {
3492
+ return item.split('delete__')[1].to_float() + 1;
3493
+ }).toString();
3494
+ payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
3495
+ })
3496
+ }
3497
+ return payload;
3498
+ `,
3402
3499
  requestAdaptor: `
3403
3500
  var ids = api.data.ids.split(",");
3404
3501
  var deleteArray = [];
@@ -4193,7 +4290,7 @@ async function getListBody(fields, options){
4193
4290
 
4194
4291
  function getDefaultParams(options){
4195
4292
  return {
4196
- perPage: options.top || options.perPage || 10
4293
+ perPage: options.top || options.perPage || 20
4197
4294
  }
4198
4295
  }
4199
4296
 
@@ -4396,7 +4493,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4396
4493
  "objectApiName": "\${objectName}",
4397
4494
  "recordId": "",
4398
4495
  "mode": "edit",
4399
- "layout": "normal"
4400
4496
  };
4401
4497
 
4402
4498
  if (payload && payload.schema) {
@@ -4828,9 +4924,16 @@ const getSchema$2 = (uiSchema) => {
4828
4924
  "form": {
4829
4925
  debug: false,
4830
4926
  resetAfterSubmit: false,
4927
+ data: {
4928
+ editFormInited: true,
4929
+ },
4831
4930
  initApi: {
4931
+ method: 'GET',
4832
4932
  url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
4833
4933
  sendOn: 'this.recordId',
4934
+ data: null,
4935
+ requestAdaptor: "return api;",
4936
+ adaptor: "return payload;",
4834
4937
  responseData: {
4835
4938
  importState: "${state}"
4836
4939
  }
@@ -5101,7 +5204,7 @@ const StandardButtons = {
5101
5204
  }
5102
5205
  };
5103
5206
 
5104
- const getGlobalData$1 = () => {
5207
+ const getGlobalData = () => {
5105
5208
  return {
5106
5209
  now: new Date(),
5107
5210
  };
@@ -5160,7 +5263,7 @@ const getButtonVisible = (button, ctx) => {
5160
5263
  button._visible,
5161
5264
  props.record,
5162
5265
  "#",
5163
- getGlobalData$1(),
5266
+ getGlobalData(),
5164
5267
  props.userSession
5165
5268
  );
5166
5269
  };
@@ -5702,7 +5805,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
5702
5805
  const formSchema = {
5703
5806
  "type": "service",
5704
5807
  "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
5705
- "className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2 overflow-y-auto overflow-x-hidden" : "slds-filters__body p-0 sm:grid sm:gap-2 sm:grid-cols-4 mb-2",
5808
+ "className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2 overflow-y-auto overflow-x-hidden" : "slds-filters__body p-0 sm:grid sm:gap-4 sm:grid-cols-4 p-2",
5706
5809
  "style":{
5707
5810
  "max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
5708
5811
  },
@@ -6289,7 +6392,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6289
6392
  "className": "slds-filters"
6290
6393
  },
6291
6394
  "size": "xs",
6292
- "className": `border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
6395
+ "className": `border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
6293
6396
  "visibleOn": "this.showFieldsFilter",
6294
6397
  },
6295
6398
  "className": "bg-white"
@@ -6477,7 +6580,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6477
6580
  "icon": "fa fa-refresh",
6478
6581
  "actionType": "reload",
6479
6582
  "target": amisListViewId,
6480
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
6583
+ "className": "bg-white p-2 rounded text-gray-500"
6481
6584
  },
6482
6585
  fieldsFilterButtonSchema,
6483
6586
  // {
@@ -6485,7 +6588,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6485
6588
  // "label": "",
6486
6589
  // "icon": "fa fa-filter",
6487
6590
  // "actionType": "custom",
6488
- // "className": "bg-transparent p-2 rounded border-gray-300 text-gray-500",
6591
+ // "className": "bg-transparent p-2 rounded text-gray-500",
6489
6592
  // "id": "u:c20cb87d96c9",
6490
6593
  // "onEvent": {
6491
6594
  // "click": {
@@ -6533,11 +6636,53 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6533
6636
  let headerSchema = [{
6534
6637
  "type": "wrapper",
6535
6638
  "body": body,
6536
- "className": `bg-gray-100 sm:rounded-tl sm:rounded-tr p-4 -mb-4`
6639
+ "className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
6537
6640
  }];
6538
6641
  return headerSchema;
6539
6642
  }
6540
6643
 
6644
+ function getBackButtonSchema(){
6645
+ return {
6646
+ "type": "service",
6647
+ "onEvent": {
6648
+ "@history_paths.changed": {
6649
+ "actions": [
6650
+ {
6651
+ "actionType": "reload",
6652
+ // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6653
+ "data": {
6654
+ }
6655
+ }
6656
+ ]
6657
+ }
6658
+ },
6659
+ "body":[{
6660
+ "type": "button",
6661
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6662
+ "className":"flex mr-4",
6663
+ "onEvent": {
6664
+ "click": {
6665
+ "actions": [
6666
+ {
6667
+ "actionType": "custom",
6668
+ "script": "window.goBack()"
6669
+ }
6670
+ ]
6671
+ }
6672
+ },
6673
+ "body": [
6674
+ {
6675
+ "type": "steedos-icon",
6676
+ "category": "utility",
6677
+ "name": "back",
6678
+ "colorVariant": "default",
6679
+ "className": "slds-button_icon slds-global-header__icon w-4"
6680
+ }
6681
+ ]
6682
+ }]
6683
+ }
6684
+ }
6685
+
6541
6686
  /**
6542
6687
  * 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
6543
6688
  * @param {*} objectSchema 对象UISchema
@@ -6546,11 +6691,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6546
6691
  * @returns amisSchema
6547
6692
  */
6548
6693
  async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6694
+ // console.log(`getObjectRecordDetailHeader====>`, options)
6549
6695
  const { showRecordTitle = true } = options || {};
6550
6696
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
6551
6697
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
6552
6698
 
6553
- let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6699
+ let amisButtonsSchema = [];
6700
+ if(options.showButtons != false){
6701
+ amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6702
+ }
6703
+
6704
+ let backButtonsSchema = null;
6705
+
6706
+ if(options.showBackButton != false){
6707
+ backButtonsSchema = getBackButtonSchema();
6708
+ }
6554
6709
 
6555
6710
  // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
6556
6711
 
@@ -6565,45 +6720,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6565
6720
  "type": "grid",
6566
6721
  "columns": [
6567
6722
  {
6568
- "body": [{
6569
- "type": "service",
6570
- "onEvent": {
6571
- "@history_paths.changed": {
6572
- "actions": [
6573
- {
6574
- "actionType": "reload",
6575
- // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6576
- "data": {
6577
- }
6578
- }
6579
- ]
6580
- }
6581
- },
6582
- "body":[{
6583
- "type": "button",
6584
- "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6585
- "className":"flex mr-4",
6586
- "onEvent": {
6587
- "click": {
6588
- "actions": [
6589
- {
6590
- "actionType": "custom",
6591
- "script": "window.goBack()"
6592
- }
6593
- ]
6594
- }
6595
- },
6596
- "body": [
6597
- {
6598
- "type": "steedos-icon",
6599
- "category": "utility",
6600
- "name": "back",
6601
- "colorVariant": "default",
6602
- "className": "slds-button_icon slds-global-header__icon w-4"
6603
- }
6604
- ]
6605
- }]
6606
- },{
6723
+ "body": [
6724
+ backButtonsSchema
6725
+ ,{
6607
6726
  "type": "tpl",
6608
6727
  "className": "block",
6609
6728
  // "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
@@ -6624,8 +6743,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6624
6743
  },
6625
6744
  {
6626
6745
  "type": "tpl",
6627
- "tpl": "${name}",
6628
- // "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
6746
+ "tpl": "${NAME_FIELD_VALUE}",
6629
6747
  "inline": false,
6630
6748
  "wrapperComponent": "",
6631
6749
  "className": "record-detail-header-name leading-5 text-xl font-bold"
@@ -6653,7 +6771,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6653
6771
  let body = [
6654
6772
  {
6655
6773
  "type": "wrapper",
6656
- "className": "p-0",
6774
+ "className": "p-4 border-b",
6657
6775
  "body": [
6658
6776
  {
6659
6777
  "type": "grid",
@@ -6668,7 +6786,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6668
6786
  if(showRecordTitle){
6669
6787
  body.push({
6670
6788
  "type": "wrapper",
6671
- "className": "p-0",
6789
+ "className": "p-4",
6672
6790
  "body": [
6673
6791
  {
6674
6792
  "type": "grid",
@@ -6680,11 +6798,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6680
6798
  });
6681
6799
  }
6682
6800
 
6801
+ let max = 10;
6802
+ if(options.formFactor === 'SMALL'){
6803
+ max = 4;
6804
+ }else {
6805
+
6806
+ let divWidth = window.innerWidth;
6807
+
6808
+ if(options.display === 'split'){
6809
+ divWidth = divWidth - 388;
6810
+ }
6811
+
6812
+ if(document.body.classList.contains('sidebar')){
6813
+ divWidth = divWidth - 210;
6814
+ }
6815
+
6816
+ // 根据屏幕宽度计算显示数量, 使高亮字段只占1行
6817
+ max = Math.trunc(divWidth / 200 );
6818
+ if(max > 10){
6819
+ max = 10;
6820
+ }
6821
+ }
6822
+
6823
+ // console.log('=======================max=========================', max)
6824
+
6825
+ if(objectSchema.compactLayouts){
6826
+ const details = [];
6827
+ _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
6828
+ const field = objectSchema.fields[fieldName];
6829
+ if(field){
6830
+ details.push({
6831
+ type: 'steedos-field',
6832
+ static: true,
6833
+ config: field,
6834
+ });
6835
+ }
6836
+ });
6837
+
6838
+ // 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
6839
+ // lg:grid-cols-1
6840
+ // lg:grid-cols-2
6841
+ // lg:grid-cols-3
6842
+ // lg:grid-cols-4
6843
+ // lg:grid-cols-5
6844
+ // lg:grid-cols-6
6845
+ // lg:grid-cols-7
6846
+ // lg:grid-cols-8
6847
+ // lg:grid-cols-9
6848
+ // lg:grid-cols-10
6849
+ // lg:grid-cols-11
6850
+ // lg:grid-cols-12
6851
+
6852
+ body.push({
6853
+ "type": "wrapper",
6854
+ "body": {
6855
+ "type": "form",
6856
+ // "className": "gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-5 3xl:grid-cols-8 4xl:grid-cols-8 5xl:grid-cols-10", //max-h-12 overflow-hidden
6857
+ "className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
6858
+ "wrapWithPanel": false,
6859
+ "actions": [],
6860
+ "body": details,
6861
+ "hiddenOn": "${recordLoaded != true}"
6862
+ },
6863
+ "className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
6864
+ });
6865
+ }
6866
+
6683
6867
  return {
6684
6868
  type: 'service',
6685
6869
  id: `page_readonly_${name}_header`,
6686
6870
  name: `page`,
6687
- data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
6688
6871
  body: body,
6689
6872
  className: ''
6690
6873
  }
@@ -6756,7 +6939,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
6756
6939
  "className": "flex justify-between"
6757
6940
  }
6758
6941
  ],
6759
- "className": "p-3"
6942
+ "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
6760
6943
  };
6761
6944
  return recordRelatedListHeader;
6762
6945
  }
@@ -7714,7 +7897,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
7714
7897
  "icon": "fa fa-cog",
7715
7898
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7716
7899
  // "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
7717
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
7900
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
7718
7901
  "align": "right",
7719
7902
  "visibleOn": "${!isLookup}",
7720
7903
  "buttons": [
@@ -7741,14 +7924,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7741
7924
  {
7742
7925
  "type": "button",
7743
7926
  "label": i18next.t('frontend_display_type_is_table'),
7744
- "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
7927
+ "onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
7745
7928
  "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
7746
7929
  "rightIconClassName": "m-l-sm"
7747
7930
  },
7748
7931
  {
7749
7932
  "type": "button",
7750
7933
  "label": i18next.t('frontend_display_type_is_split'),
7751
- "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7934
+ "onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7752
7935
  "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
7753
7936
  "rightIconClassName": "m-l-sm"
7754
7937
  }
@@ -7759,7 +7942,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7759
7942
  "icon": "fa fa-table-columns",
7760
7943
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7761
7944
  // "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
7762
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
7945
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
7763
7946
  "align": "right",
7764
7947
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
7765
7948
  "buttons": [
@@ -7891,7 +8074,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
7891
8074
  {
7892
8075
  "type": "search-box",
7893
8076
  "name": keywordsSearchBoxName,
7894
- "placeholder": "搜索此列表",
8077
+ "placeholder": "快捷搜索",
7895
8078
  "value": crudKeywords,
7896
8079
  // "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
7897
8080
  "clearAndSubmit": true,
@@ -7952,7 +8135,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
7952
8135
  // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7953
8136
  // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
7954
8137
  // "tooltipPlacement": "top",
7955
- // "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8138
+ // "className": "bg-white p-2 rounded text-gray-500",
7956
8139
  // "label": "",
7957
8140
  // "icon": "fa fa-sync",
7958
8141
  // "visibleOn": "${!showFieldsFilter}",
@@ -7976,7 +8159,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
7976
8159
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
7977
8160
  "tooltip":"",
7978
8161
  "tooltipPlacement": "top",
7979
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8162
+ "className": "bg-white p-2 rounded text-gray-500"
7980
8163
  };
7981
8164
  }
7982
8165
  else {
@@ -7987,7 +8170,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
7987
8170
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
7988
8171
  "tooltip":"",
7989
8172
  "tooltipPlacement": "top",
7990
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8173
+ "className": "bg-white p-2 rounded text-gray-500"
7991
8174
  };
7992
8175
  }
7993
8176
  let toolbarFilter;
@@ -8009,7 +8192,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8009
8192
  "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
8010
8193
  },
8011
8194
  "align": "right",
8012
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8195
+ "className": "bg-white p-2 rounded text-gray-500",
8013
8196
  "onEvent": {
8014
8197
  "click": {
8015
8198
  "actions": [
@@ -8095,7 +8278,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8095
8278
  // ]
8096
8279
  if(options.displayAs === 'split'){
8097
8280
  return [
8098
- "switch-per-page",
8281
+ {
8282
+ "type": "switch-per-page",
8283
+ "visibleOn": "${count >= 20}"
8284
+ },
8099
8285
  {
8100
8286
  "type": "pagination",
8101
8287
  "maxButtons": 5,
@@ -8117,7 +8303,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8117
8303
  else {
8118
8304
  if(options && options.isRelated){
8119
8305
  return [
8120
- "statistics",
8121
8306
  {
8122
8307
  "type": "pagination",
8123
8308
  "maxButtons": 10,
@@ -8130,7 +8315,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8130
8315
  const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
8131
8316
  const is_lookup = options.isLookup;
8132
8317
  const commonConfig = [
8133
- "statistics",
8134
8318
  {
8135
8319
  "type": "pagination",
8136
8320
  "maxButtons": 10,
@@ -8141,7 +8325,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8141
8325
  if (no_pagination && is_lookup) {
8142
8326
  return commonConfig;
8143
8327
  } else {
8144
- return ["switch-per-page", ...commonConfig];
8328
+ return [{
8329
+ "type": "switch-per-page",
8330
+ "visibleOn": "${count >= 20}"
8331
+ }, ...commonConfig];
8145
8332
  }
8146
8333
  }
8147
8334
  }
@@ -8165,7 +8352,6 @@ async function getObjectFilter(objectSchema, fields, options) {
8165
8352
  "timeOut": 1000
8166
8353
  }
8167
8354
  });
8168
- resizeWindow();
8169
8355
  const scope = event.context.scoped;
8170
8356
  // let filterFormValues = event.data;
8171
8357
  let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
@@ -8249,6 +8435,29 @@ function getBulkActions(objectSchema){
8249
8435
  "className": "hidden",
8250
8436
  "id": "batchDelete",
8251
8437
  "api": getBatchDelete(objectSchema.name),
8438
+ "feedback": {
8439
+ "title": "删除警告",
8440
+ "visibleOn": "${deleteErrorMessage}",
8441
+ "body": [
8442
+ {
8443
+ "type": "each",
8444
+ "name": "deleteErrorMessage",
8445
+ "items": {
8446
+ "type": "alert",
8447
+ "body": "${item}",
8448
+ "level": "danger",
8449
+ "className": "mb-3"
8450
+ }
8451
+ }
8452
+ ],
8453
+ "actions": [
8454
+ {
8455
+ "type": "button",
8456
+ "actionType": "close",
8457
+ "label": "关闭"
8458
+ }
8459
+ ]
8460
+ }
8252
8461
  }
8253
8462
  // {
8254
8463
  // "label": "批量修改",
@@ -8309,7 +8518,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8309
8518
  const bodyProps = {
8310
8519
  // toolbar: getToolbar(),
8311
8520
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
8312
- headerToolbarClassName: "px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",
8521
+ headerToolbarClassName: "px-4 py-2 border-b",
8313
8522
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
8314
8523
  ...options,
8315
8524
  disableStatistics: options.queryCount === false
@@ -8445,7 +8654,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8445
8654
  // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8446
8655
  // },
8447
8656
  bodyClassName: {
8448
- "bg-white": "true",
8657
+ "mb-0": true,
8449
8658
  "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8450
8659
  },
8451
8660
  crudClassName: crudClassName,
@@ -8456,16 +8665,11 @@ async function getObjectCRUD(objectSchema, fields, options){
8456
8665
  headers: {
8457
8666
  Authorization: "Bearer ${context.tenantId},${context.authToken}",
8458
8667
  },
8459
- requestAdaptor: quickSaveApiRequestAdaptor,
8460
- adaptor: `
8461
- if(payload.errors){
8462
- payload.status = 2;
8463
- payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8464
- }
8465
- return payload;
8466
- `
8668
+ requestAdaptor: quickSaveApiRequestAdaptor
8467
8669
  },
8468
- rowClassNameExpr: options.rowClassNameExpr
8670
+ // 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
8671
+ // 使用表达式给tr添加初始选中状态
8672
+ rowClassNameExpr: options.rowClassNameExpr || "<%= data._id === data.recordId ? 'steedos-record-tr steedos-record-tr-' + data._id + ' steedos-record-selected' : 'steedos-record-tr steedos-record-tr-' + data._id %>"
8469
8673
  }, bodyProps);
8470
8674
 
8471
8675
  }
@@ -8478,9 +8682,23 @@ async function getObjectCRUD(objectSchema, fields, options){
8478
8682
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8479
8683
  }
8480
8684
 
8685
+ body.quickSaveApi.adaptor = `
8686
+ if(payload.errors){
8687
+ payload.status = 2;
8688
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8689
+ }
8690
+ var scope = SteedosUI.getRef(context.scopeId);
8691
+ var scopeParent = scope && scope.parent;
8692
+ var crudScoped = scopeParent.getComponentById('${body.id}');
8693
+ setTimeout(()=>{
8694
+ crudScoped && crudScoped.control.updateAutoFillHeight();
8695
+ }, 500);
8696
+ return payload;
8697
+ `;
8698
+
8481
8699
  if(body.columns && options.formFactor != 'SMALL'){
8482
8700
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8483
- body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: objectSchema.name + "_display_${_index}", className: "hidden"});
8701
+ body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
8484
8702
  }
8485
8703
 
8486
8704
  if (defaults) {
@@ -8538,11 +8756,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8538
8756
  }
8539
8757
  }
8540
8758
 
8541
- const getGlobalData = (mode)=>{
8542
- const user = getSteedosAuth();
8543
- return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
8544
- };
8545
-
8546
8759
  const getFormFields$1 = (objectSchema, formProps)=>{
8547
8760
  /**
8548
8761
  * fieldsExtend: 重写字段定义
@@ -8604,7 +8817,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
8604
8817
  }
8605
8818
 
8606
8819
  async function getObjectForm(objectSchema, ctx){
8607
- const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8820
+ const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8608
8821
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8609
8822
  const fields = ___default.values(objectSchema.fields);
8610
8823
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -8620,9 +8833,7 @@ async function getObjectForm(objectSchema, ctx){
8620
8833
  id: `service_${formSchema.id}`,
8621
8834
  className: 'p-0',
8622
8835
  name: `page_edit_${recordId}`,
8623
- api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
8624
8836
  data:{
8625
- editFormInited: false,
8626
8837
  ...amisData
8627
8838
  },
8628
8839
  // data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
@@ -8631,8 +8842,9 @@ async function getObjectForm(objectSchema, ctx){
8631
8842
  body: [defaultsDeep({}, formSchema, {
8632
8843
  type: "form",
8633
8844
  mode: layout,
8845
+ initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
8634
8846
  data: {
8635
- "&": "${initialValues}"
8847
+ editFormInited: false,
8636
8848
  },
8637
8849
  labelAlign,
8638
8850
  persistData: false,
@@ -8646,11 +8858,15 @@ async function getObjectForm(objectSchema, ctx){
8646
8858
  submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
8647
8859
  api: await getSaveApi(objectSchema, recordId, fields, ctx),
8648
8860
  initFetch: recordId != 'new',
8649
- body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
8861
+ body: {
8862
+ type: 'wrapper',
8863
+ className: 'p-0 m-0',
8864
+ body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
8865
+ hiddenOn: "${editFormInited != true}",
8866
+ },
8650
8867
  panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
8651
8868
  bodyClassName: 'p-0',
8652
8869
  className: 'steedos-amis-form',
8653
- hiddenOn: "${editFormInited != true}",
8654
8870
  onEvent: {
8655
8871
  "submitSucc": {
8656
8872
  "weight": 0,
@@ -8695,7 +8911,7 @@ async function getObjectForm(objectSchema, ctx){
8695
8911
  }
8696
8912
 
8697
8913
  async function getObjectDetail(objectSchema, recordId, ctx){
8698
- const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign,
8914
+ const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
8699
8915
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8700
8916
  const fields = ___default.values(objectSchema.fields);
8701
8917
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -8704,8 +8920,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8704
8920
  type: 'service',
8705
8921
  name: `page_readonly_${recordId}`,
8706
8922
  id: serviceId,
8707
- data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
8708
- api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8923
+ // api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8709
8924
  body: [
8710
8925
  {
8711
8926
  "type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
@@ -8731,60 +8946,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8731
8946
  ),
8732
8947
  className: 'steedos-amis-form bg-white',
8733
8948
  actions: [], // 不显示表单默认的提交按钮
8734
- onEvent: {
8735
- [`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
8736
- "actions": [
8737
- {
8738
- "actionType": "reload",
8739
- "componentId": serviceId,
8740
- "expression": "this.__deletedRecord != true"
8741
- },
8742
- {
8743
- // "args": {
8744
- // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
8745
- // "blank": false
8746
- // },
8747
- "actionType": "custom",
8748
- "script": "window.goBack()",
8749
- "expression": "this.__deletedRecord === true"
8750
- }
8751
- ]
8752
- }
8753
- }
8754
8949
  },
8755
8950
  }
8756
8951
  ],
8757
- onEvent: {
8758
- "fetchInited": {
8759
- "weight": 0,
8760
- "actions": [
8761
- {
8762
- actionType: 'broadcast',
8763
- eventName: "recordLoaded",
8764
- args: {
8765
- eventName: "recordLoaded"
8766
- },
8767
- data: {
8768
- objectName: "${event.data.__objectName}",
8769
- record: "${event.data.__record}"
8770
- },
8771
- expression: "${event.data.__response.error != true}"
8772
- },
8773
- {
8774
- "actionType": "setValue",
8775
- "args": {
8776
- value: {
8777
- "recordLoaded": true,
8778
- }
8779
- },
8780
- expression: "${event.data.__response.error != true}"
8781
- }
8782
- ]
8783
- }
8784
- }
8952
+ // onEvent: {
8953
+ // "fetchInited": {
8954
+ // "weight": 0,
8955
+ // "actions": [
8956
+ // {
8957
+ // actionType: 'broadcast',
8958
+ // eventName: "recordLoaded",
8959
+ // args: {
8960
+ // eventName: "recordLoaded"
8961
+ // },
8962
+ // data: {
8963
+ // objectName: "${event.data.__objectName}",
8964
+ // record: "${event.data.__record}"
8965
+ // },
8966
+ // expression: "${event.data.__response.error != true}"
8967
+ // },
8968
+ // {
8969
+ // "actionType": "setValue",
8970
+ // "args": {
8971
+ // value: {
8972
+ // "recordLoaded": true,
8973
+ // }
8974
+ // },
8975
+ // expression: "${event.data.__response.error != true}"
8976
+ // }
8977
+ // ]
8978
+ // }
8979
+ // }
8785
8980
  };
8786
8981
 
8787
8982
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
8983
+ // console.log('getObjectDetail=====>', amisSchema);
8788
8984
  return amisSchema;
8789
8985
  }
8790
8986
 
@@ -8864,8 +9060,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8864
9060
  /*
8865
9061
  * @Author: baozhoutao@steedos.com
8866
9062
  * @Date: 2022-07-05 15:55:39
8867
- * @LastEditors: liaodaxue
8868
- * @LastEditTime: 2023-11-14 15:55:32
9063
+ * @LastEditors: baozhoutao@steedos.com
9064
+ * @LastEditTime: 2024-01-24 10:18:17
8869
9065
  * @Description:
8870
9066
  */
8871
9067
 
@@ -8964,7 +9160,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
8964
9160
  const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
8965
9161
  mainRelated[arr[0]] = foreign_key_value;
8966
9162
  }
8967
- }else {
9163
+ }
9164
+ // 防止related_lists中没有相关子表,但是details中有相关子表的情况
9165
+ if(!mainRelated[relatedObjectName]){
8968
9166
  const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
8969
9167
  for (const detail of details) {
8970
9168
  const arr = detail.split(".");
@@ -9040,7 +9238,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9040
9238
  setDataToComponentId: componentId,
9041
9239
  // tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
9042
9240
  appId: appId,
9043
- crudClassName: 'border-t border-gray-300 hidden',
9241
+ crudClassName: 'steedos-record-related-crud border-l border-r hidden',
9044
9242
  refField,
9045
9243
  ...ctx
9046
9244
  };
@@ -9053,7 +9251,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9053
9251
  amisSchema: {
9054
9252
  type: "service",
9055
9253
  id: componentId,
9056
- className: `steedos-record-related-list ${componentId} rounded border border-gray-300 bg-gray-100 mb-4 ${className}`,
9254
+ className: `steedos-record-related-list mb-4 last:mb-0 ${componentId} ${className}`,
9057
9255
  data: {
9058
9256
  relatedKey: relatedKey,
9059
9257
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
@@ -9245,11 +9443,44 @@ async function getRelatedListSchema(
9245
9443
  };
9246
9444
  }
9247
9445
 
9446
+ async function getObjectRelatedListsMiniSchema(objectApiName){
9447
+ const relatedLists = await getObjectRelatedList(objectApiName);
9448
+
9449
+ const relatedListsMiniSchema = [];
9450
+
9451
+ for (const relatedList of relatedLists) {
9452
+ relatedListsMiniSchema.push(
9453
+ {
9454
+ type: 'steedos-record-detail-list-mini',
9455
+ objectApiName: objectApiName,
9456
+ // recordId: recordId,
9457
+ formFactor: formFactor,
9458
+ relatedObjectApiName: relatedList.object_name,
9459
+ foreign_key: relatedList.foreign_key,
9460
+ relatedKey: relatedList.foreign_key,
9461
+ columns: relatedList.columns,
9462
+ sort: relatedList.sort,
9463
+ filters: relatedList.filters,
9464
+ visible_on: relatedList.visible_on,
9465
+ perPage: relatedList.page_size || perPage,
9466
+ hiddenEmptyTable: true,
9467
+ relatedLabel: relatedList.label
9468
+ }
9469
+ );
9470
+ }
9471
+
9472
+ return {
9473
+ type: 'wrapper',
9474
+ className: "steedos-record-detail-related-lists-mini",
9475
+ body: relatedListsMiniSchema
9476
+ }
9477
+ }
9478
+
9248
9479
  /*
9249
9480
  * @Author: baozhoutao@steedos.com
9250
9481
  * @Date: 2022-07-05 15:55:39
9251
- * @LastEditors: liaodaxue
9252
- * @LastEditTime: 2023-10-20 11:38:25
9482
+ * @LastEditors: baozhoutao@steedos.com
9483
+ * @LastEditTime: 2024-01-16 11:14:34
9253
9484
  * @Description:
9254
9485
  */
9255
9486
 
@@ -9421,7 +9652,7 @@ async function getField(objectName, fieldName) {
9421
9652
  async function getFormSchema(objectName, ctx) {
9422
9653
  const uiSchema = await getUISchema(objectName);
9423
9654
  const amisSchema = await getObjectForm(uiSchema, ctx);
9424
- console.log(`getFormSchema====>`, amisSchema);
9655
+ // console.log(`getFormSchema====>`, amisSchema)
9425
9656
  return {
9426
9657
  uiSchema,
9427
9658
  amisSchema,
@@ -9747,120 +9978,174 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9747
9978
  "label": "对象表单",
9748
9979
  "objectApiName": "${objectName}",
9749
9980
  "recordId": "${recordId}",
9750
- "id": "u:d4a495811d57",
9751
9981
  appId: appId
9752
9982
  }
9753
9983
  ],
9754
- "id": "u:5d4e7e3f6ecc"
9755
9984
  };
9756
9985
  const related = {
9757
9986
  "title": i18next.t('frontend_record_detail_tab_related'),
9758
- "className": "px-0 pt-4",
9987
+ "className": "px-0 py-4",
9759
9988
  "body": [
9760
9989
  {
9761
9990
  "type": "steedos-object-related-lists",
9762
9991
  "label": "相关列表",
9763
9992
  "objectApiName": "${objectName}",
9764
9993
  "recordId": "${recordId}",
9765
- "id": "u:3b85b7b7a7f6",
9766
9994
  appId: appId
9767
9995
  }
9768
9996
  ],
9769
- "id": "u:1a0326aeec2b"
9770
9997
  };
9771
9998
  const content = {
9772
9999
  "type": "tabs",
9773
- "className": "sm:mt-3 bg-white sm:rounded sm:border border-gray-300 p-4",
10000
+ "className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
10001
+ "contentClassName": "bg-none",
9774
10002
  "tabs": [
9775
10003
  detailed
9776
10004
  ],
9777
- "id": "u:a649e4094a12"
9778
10005
  };
9779
10006
  if(relatedLists.length){
9780
10007
  content.tabs.push(related);
9781
10008
  }
10009
+ // content.tabs = reverse(content.tabs)
9782
10010
  return {
9783
10011
  uiSchema,
9784
10012
  amisSchema: {
9785
- "type": "service",
10013
+ "type": "steedos-record-service",
9786
10014
  "body": [
9787
10015
  {
9788
10016
  "type": "steedos-record-detail-header",
9789
10017
  "label": "标题面板",
9790
10018
  "objectApiName": "${objectName}",
9791
10019
  "recordId": "${recordId}",
9792
- "id": "u:48d2c28eb755"
10020
+ "id": "u:48d2c28eb755",
10021
+ "showButtons": props.showButtons,
10022
+ "showBackButton": props.showBackButton,
9793
10023
  },
9794
10024
  content
9795
10025
  ],
9796
- data: {
9797
- "_master.objectName": "${objectName}",
9798
- "_master.recordId": "${recordId}"
9799
- },
9800
- onEvent: {
9801
- "recordLoaded": {
9802
- "actions": [
9803
- {
9804
- "actionType": "reload",
9805
- "data": {
9806
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9807
- "_master.record": `\${record}`,
9808
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9809
- "_master.objectName": "${objectName}",
9810
- "_master.recordId": "${recordId}"
9811
- }
9812
- }
9813
- ]
9814
- },
9815
- ...props.onEvent
9816
- },
10026
+ "objectApiName": "${objectName}",
10027
+ "recordId": "${recordId}",
10028
+ onEvent: props.onEvent,
9817
10029
  }
9818
10030
  }
9819
10031
  }
9820
10032
 
9821
- async function getRecordServiceSchema(objectName, appId, props = {}) {
10033
+ async function getRecordServiceSchema(objectName, appId, props = {}, body) {
9822
10034
  const uiSchema = await getUISchema(objectName);
10035
+ const fields = ___default.values(uiSchema.fields);
10036
+ const serviceId = `u:steedos-record-service-${objectName}`;
9823
10037
  return {
9824
10038
  uiSchema,
9825
10039
  amisSchema: {
9826
- "type": "service",
9827
- "body": [],
9828
- data: {
9829
- "_master.objectName": "${objectName}",
9830
- "_master.recordId": "${recordId}"
9831
- },
9832
- "style": {
9833
- "padding": "var(--Page-body-padding)",
9834
- ...props.style
9835
- },
10040
+ type: 'service',
10041
+ className: "p-0 m-0",
9836
10042
  onEvent: {
9837
- "recordLoaded": {
10043
+ [`@data.changed.${objectName}`]: {
9838
10044
  "actions": [
9839
10045
  {
9840
10046
  "actionType": "reload",
9841
- "data": {
9842
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9843
- "_master.record": `\${record}`,
9844
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9845
- "_master.objectName": "${objectName}",
9846
- "_master.recordId": "${recordId}"
9847
- }
10047
+ "componentId": serviceId,
10048
+ "expression": "this.__deletedRecord != true"
10049
+ },
10050
+ {
10051
+ "actionType": "custom",
10052
+ "script": "window.goBack()",
10053
+ "expression": "this.__deletedRecord === true"
9848
10054
  }
9849
10055
  ]
9850
10056
  },
9851
- ...props.onEvent
10057
+ },
10058
+ body: {
10059
+ "type": "service",
10060
+ id: serviceId,
10061
+ className: 'steedos-record-service p-0',
10062
+ api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
10063
+ body: {
10064
+ "type": "wrapper",
10065
+ "className": "p-0 m-0",
10066
+ "body": body || [],
10067
+ "hiddenOn": "${recordLoaded != true}"
10068
+ },
10069
+ data: {
10070
+ "_master.objectName": "${objectName}",
10071
+ "_master.recordId": "${recordId}",
10072
+ ...(props.data || {})
10073
+ },
10074
+ "style": {
10075
+ // "padding": "var(--Page-body-padding)",
10076
+ ...props.style
10077
+ },
10078
+ onEvent: {
10079
+ // 如果定义了fetchInited,则无法接收到广播事件@data.changed
10080
+ "fetchInited": {
10081
+ "weight": 0,
10082
+ "actions": [
10083
+ {
10084
+ actionType: 'broadcast',
10085
+ eventName: "recordLoaded",
10086
+ data: {
10087
+ objectName: "${event.data.__objectName}",
10088
+ record: "${event.data.record}"
10089
+ },
10090
+ expression: "${event.data.__response.error != true}"
10091
+ },
10092
+ ]
10093
+ },
10094
+ ...props.onEvent
10095
+ }
9852
10096
  }
9853
10097
  }
10098
+
10099
+
9854
10100
  }
9855
10101
  }
9856
10102
 
9857
- // 获取单个相关表
9858
- async function getObjectRelated(
9859
- {appName,
9860
- masterObjectName,
9861
- objectName,
9862
- relatedFieldName,
9863
- recordId,
10103
+ async function getRecordDetailMiniSchema(objectName, appId, props = {}){
10104
+ const uiSchema = await getUISchema(objectName);
10105
+ const fields = ___default.values(uiSchema.fields);
10106
+
10107
+ props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
10108
+
10109
+ // TODO 处理相关表
10110
+ // getObjectRelatedListsMiniSchema
10111
+
10112
+ return {
10113
+ type: "form",
10114
+ wrapWithPanel: false,
10115
+ actions: [],
10116
+ initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
10117
+ body: {
10118
+ "type": "wrapper",
10119
+ "className": "p-0 m-0",
10120
+ "body": [
10121
+ {
10122
+ "type": "steedos-record-detail-header",
10123
+ "showButtons": false,
10124
+ "showBackButton": false,
10125
+ "objectApiName": "${objectName}",
10126
+ "recordId": "${recordId}",
10127
+ },
10128
+ // {
10129
+ // "type": "steedos-object-related-lists",
10130
+ // "label": "相关列表",
10131
+ // "objectApiName": "${objectName}",
10132
+ // "staticRecordId": "${recordId}",
10133
+ // formFactor: "SMALL",
10134
+ // appId: appId
10135
+ // }
10136
+ ],
10137
+ "hiddenOn": "${_finished != true}"
10138
+ }
10139
+ }
10140
+ }
10141
+
10142
+ // 获取单个相关表
10143
+ async function getObjectRelated(
10144
+ {appName,
10145
+ masterObjectName,
10146
+ objectName,
10147
+ relatedFieldName,
10148
+ recordId,
9864
10149
  formFactor}
9865
10150
  ) {
9866
10151
  let filter = null;
@@ -10413,17 +10698,13 @@ function getReferenceToSync(field) {
10413
10698
 
10414
10699
  function getLookupSapceUserTreeSchema(isMobile){
10415
10700
  let apiAdaptor = `
10416
- // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10417
10701
  const records = payload.data.options;
10418
- let isTreeOptionsComputed = false;
10419
- if(records.length === 1 && records[0].children){
10420
- isTreeOptionsComputed = true;
10421
- }
10422
- if(isTreeOptionsComputed){
10423
- return payload;
10424
- }
10425
10702
  const treeRecords = [];
10426
- const getChildren = (records, childrenIds) => {
10703
+ const getChildren = (currentRecord, records, childrenIds) => {
10704
+ if (currentRecord.children && typeof currentRecord.children[0] === "object") {
10705
+ // 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
10706
+ return currentRecord.children;
10707
+ }
10427
10708
  if (!childrenIds) {
10428
10709
  return;
10429
10710
  }
@@ -10432,7 +10713,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10432
10713
  });
10433
10714
  _.each(children, (item) => {
10434
10715
  if (item.children) {
10435
- item.children = getChildren(records, item.children)
10716
+ item.children = getChildren(item, records, item.children)
10436
10717
  }else{
10437
10718
  item.children = [];
10438
10719
  }
@@ -10458,7 +10739,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10458
10739
 
10459
10740
  _.each(records, (record) => {
10460
10741
  if (record.noParent == 1) {
10461
- treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10742
+ treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
10462
10743
  }
10463
10744
  });
10464
10745
  console.log(treeRecords)
@@ -10508,6 +10789,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10508
10789
  }
10509
10790
  },
10510
10791
  "label": "",
10792
+ "mode": "normal",
10511
10793
  "name": "organizations",
10512
10794
  "multiple": false,
10513
10795
  "joinValues": false,
@@ -10650,6 +10932,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
10650
10932
  }
10651
10933
  });
10652
10934
 
10935
+ let listviewFilter = getListViewFilter(listView);
10936
+ let listviewFiltersFunction = listView && listView._filters;
10937
+
10653
10938
  let sort = "";
10654
10939
  if(listView){
10655
10940
  sort = getListViewSort(listView);
@@ -10696,7 +10981,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10696
10981
  Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
10697
10982
  }
10698
10983
  const selfData = JSON.parse(JSON.stringify(api.data.$self));
10699
- var filters = [];
10984
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
10700
10985
  var pageSize = api.data.pageSize || 10;
10701
10986
  var pageNo = api.data.pageNo || 1;
10702
10987
  var skip = (pageNo - 1) * pageSize;
@@ -10758,6 +11043,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
10758
11043
  }
10759
11044
 
10760
11045
  const inFilterForm = ${ctx.inFilterForm};
11046
+
11047
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11048
+
11049
+ if(listviewFiltersFunction && !inFilterForm){
11050
+ const _filters0 = listviewFiltersFunction(filters, api.data.$self.__super);
11051
+ if(_filters0 && _filters0.length){
11052
+ filters.push(_filters0);
11053
+ }
11054
+ }
11055
+
10761
11056
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
10762
11057
 
10763
11058
  if(filtersFunction && !inFilterForm){
@@ -11070,6 +11365,9 @@ async function lookupToAmisSelect(field, readonly, ctx){
11070
11365
  const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
11071
11366
  let listView = getLookupListView(refObjectConfig);
11072
11367
 
11368
+ let listviewFilter = getListViewFilter(listView);
11369
+ let listviewFiltersFunction = listView && listView._filters;
11370
+
11073
11371
  let sort = "";
11074
11372
  if(listView){
11075
11373
  sort = getListViewSort(listView);
@@ -11099,7 +11397,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11099
11397
  apiInfo.data['rfield'] = `\${object_name}`;
11100
11398
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
11101
11399
  apiInfo.requestAdaptor = `
11102
- var filters = [];
11400
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
11103
11401
  var top = 200;
11104
11402
  if(api.data.$term){
11105
11403
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
@@ -11122,6 +11420,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
11122
11420
  }
11123
11421
 
11124
11422
  const inFilterForm = ${ctx.inFilterForm};
11423
+
11424
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11425
+
11426
+ if(listviewFiltersFunction && !inFilterForm){
11427
+ const _filters0 = listviewFiltersFunction(filters, api.data.$);
11428
+ if(_filters0 && _filters0.length){
11429
+ filters.push(_filters0);
11430
+ }
11431
+ }
11432
+
11125
11433
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
11126
11434
 
11127
11435
  if(filtersFunction && !inFilterForm){
@@ -11244,9 +11552,17 @@ async function lookupToAmis(field, readonly, ctx){
11244
11552
  }
11245
11553
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11246
11554
  if(readonly){
11247
- return {
11248
- type: getAmisStaticFieldType('picker', readonly),
11249
- tpl: getRelatedFieldTpl(field, ctx)
11555
+ if(field.reference_to){
11556
+ return {
11557
+ type: 'steedos-field',
11558
+ config: field,
11559
+ static: true
11560
+ }
11561
+ }else {
11562
+ return {
11563
+ type: getAmisStaticFieldType('picker', readonly),
11564
+ tpl: getRelatedFieldTpl(field, ctx)
11565
+ }
11250
11566
  }
11251
11567
  }
11252
11568
  if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
@@ -11898,13 +12214,31 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11898
12214
  };
11899
12215
  break;
11900
12216
  case 'input-datetime-range':
12217
+ // convertData = {
12218
+ // type: "input-datetime-range",
12219
+ // inputFormat: 'YYYY-MM-DD HH:mm',
12220
+ // format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
12221
+ // tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
12222
+ // utc: true,
12223
+ // joinValues: false
12224
+ // }
12225
+ // 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
11901
12226
  convertData = {
11902
- type: "input-datetime-range",
11903
- inputFormat: 'YYYY-MM-DD HH:mm',
12227
+ type: "input-date-range",
12228
+ inputFormat: "YYYY-MM-DD HH:mm",
11904
12229
  format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
11905
12230
  tpl: readonly ? getDateTimeTpl(field) : null,
11906
12231
  utc: true,
11907
- joinValues: false
12232
+ joinValues: false,
12233
+ "shortcuts": [
12234
+ "thismonth",
12235
+ "2monthsago",
12236
+ "3monthslater",
12237
+ "prevquarter",
12238
+ "thisquarter",
12239
+ "thisyear",
12240
+ "lastYear"
12241
+ ]
11908
12242
  };
11909
12243
  break;
11910
12244
  case 'datetime':
@@ -11955,7 +12289,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11955
12289
  convertData = {
11956
12290
  type: getAmisStaticFieldType('datetime', readonly),
11957
12291
  inputFormat: 'YYYY-MM-DD HH:mm',
11958
- format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
12292
+ format: 'YYYY-MM-DDTHH:mm:00.000Z',
11959
12293
  tpl: readonly ? getDateTimeTpl(field) : null,
11960
12294
  utc: true,
11961
12295
  };
@@ -12086,6 +12420,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12086
12420
  convertData = {
12087
12421
  type: 'static-text'
12088
12422
  };
12423
+ }else if(field.autonumber_enable_modify){
12424
+ convertData = {
12425
+ "type": "input-group",
12426
+ "body": [
12427
+ {
12428
+ "type": "input-text",
12429
+ "name": field.name
12430
+ },
12431
+ {
12432
+ "type": "button",
12433
+ "label": "自动获取",
12434
+ "actionType": "ajax",
12435
+ "api": {
12436
+ "url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
12437
+ "method": "post",
12438
+ "headers": {
12439
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
12440
+ },
12441
+ "adaptor": `
12442
+ payload.data["${field.name}"] = payload.data && payload.data.autonumber;
12443
+ delete payload.data.autonumber;
12444
+ return payload;
12445
+ `
12446
+ },
12447
+ "messages": {
12448
+ "success": "获取成功"
12449
+ }
12450
+ }
12451
+ ]
12452
+ };
12089
12453
  }
12090
12454
  break;
12091
12455
  case 'url':
@@ -12240,11 +12604,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12240
12604
  if(field.subFields){
12241
12605
  convertData = {
12242
12606
  type: 'steedos-input-table',
12243
- showIndex: true,
12244
12607
  editable: !readonly,
12245
12608
  addable: !readonly,
12246
12609
  removable: !readonly,
12247
- draggable: !readonly,
12248
12610
  fields: [],
12249
12611
  amis:{
12250
12612
  columnsTogglable: false
@@ -12296,9 +12658,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12296
12658
  if(field.is_wide || convertData.type === 'group'){
12297
12659
  convertData.className = 'col-span-2 m-0';
12298
12660
  }else {
12299
- convertData.className = 'm-1';
12661
+ convertData.className = 'm-0';
12300
12662
  }
12301
- if(readonly){
12663
+ if(readonly && ctx.mode !== 'edit'){
12302
12664
  convertData.className = `${convertData.className} border-b`;
12303
12665
  }
12304
12666
  if(readonly){
@@ -12321,6 +12683,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12321
12683
  }
12322
12684
  }
12323
12685
 
12686
+ if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
12687
+ convertData.className = `${convertData.className || ''} hidden`;
12688
+ }
12689
+
12324
12690
  if(_$1.isString(baseData.required)){
12325
12691
  if(baseData.required.startsWith("{{")){
12326
12692
  baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
@@ -12389,8 +12755,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
12389
12755
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12390
12756
  }
12391
12757
  if(_field.type === 'datetime'){
12392
- // 特意改为日期范围而不是日期时间范围,因为搜索时一般精确到日期就足够了,需要精确到日期时间范围需要在字段上配置amis属性来实现
12393
- _field.type = 'input-date-range';
12758
+ // 这里如果想把搜索范围展示效果改为日期范围,不可以直接改为input-date-range,因为它们规则不一样,包括时区规则和小时分秒的存值规则都不一样
12759
+ // 所以想改为展示日期范围效果,只能改input-datetime-range类型本身的属性来实现
12760
+ _field.type = 'input-datetime-range';
12394
12761
  _field.is_wide = true;
12395
12762
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12396
12763
  }
@@ -12576,6 +12943,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
12576
12943
  }
12577
12944
  }
12578
12945
 
12946
+ fieldSetBody.forEach((field)=>{
12947
+ //判断label是否存在,不存在时将label的空占位元素隐藏
12948
+ if(!field.label){
12949
+ field.labelClassName = "none";
12950
+ }
12951
+ });
12952
+
12579
12953
  // fieldSet 已支持显隐控制
12580
12954
  const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
12581
12955
  let visible = visibleOn;
@@ -12698,19 +13072,200 @@ async function getFormBody(permissionFields, formFields, ctx){
12698
13072
  return await getSections(permissionFields, formFields, ctx);
12699
13073
  }
12700
13074
 
13075
+ /*
13076
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
13077
+ * @Date: 2024-01-18 15:12:41
13078
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13079
+ * @LastEditTime: 2024-01-18 15:12:49
13080
+ */
13081
+ /**
13082
+ * 生成符合标准uuid格式的36位满足唯一性的随机串
13083
+ * @returns uuid
13084
+ */
13085
+ function uuidv4() {
13086
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
13087
+ (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
13088
+ );
13089
+ }
13090
+
12701
13091
  /*
12702
13092
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12703
13093
  * @Date: 2023-11-15 09:50:22
12704
- * @LastEditors: liaodaxue
12705
- * @LastEditTime: 2024-01-09 18:12:28
13094
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13095
+ * @LastEditTime: 2024-01-26 17:47:16
13096
+ */
13097
+
13098
+ /**
13099
+ * 子表组件字段值中每行数据补上字段值为空的的字段值,把值统一设置为空字符串,是为了解决amis amis 3.6/6.0 input-table组件bug:行中字段值为空时会显示为父作用域中的同名变量值,见:https://github.com/baidu/amis/issues/9520
13100
+ * amis #9520修正后此函数及相关代码可以移除
13101
+ * @param {*} value 子表组件字段值,数组
13102
+ * @param {*} fields 子表组件fields属性,数组
13103
+ * @returns 转换后的子表组件字段值
13104
+ */
13105
+ function getTableValueWithEmptyValue(value, fields) {
13106
+ return (value || []).map((itemValue) => {
13107
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里字段值会被改了
13108
+ const newItemValue = clone(itemValue);
13109
+ (fields || []).forEach((itemField) => {
13110
+ if(itemField.name && (newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13111
+ // 这里newItemValue中不存在 itemField.name 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
13112
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
13113
+ newItemValue[itemField.name] = "";
13114
+ }
13115
+ if (newItemValue.children) {
13116
+ newItemValue.children = getTableValueWithEmptyValue(newItemValue.children, fields);
13117
+ }
13118
+ });
13119
+ return newItemValue;
13120
+ });
13121
+ }
13122
+
13123
+ /**
13124
+ * 把子表组件字段值中每行数据中经过上面getTableValueWithEmptyValue函数空字段值移除
13125
+ * amis #9520修正后此函数及相关代码可以移除
13126
+ * @param {*} value 子表组件字段值,数组
13127
+ * @param {*} fields 子表组件fields属性,数组
13128
+ * @returns 转换后的子表组件字段值
13129
+ */
13130
+ function getTableValueWithoutEmptyValue(value, fields) {
13131
+ return (value || []).map((itemValue) => {
13132
+ const newItemValue = clone(itemValue);
13133
+ (fields || []).forEach((itemField) => {
13134
+ if(itemField.name && (newItemValue[itemField.name] === "" || newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13135
+ // 这里额外把null和undefined值也删除掉纯粹是没必要输出保存它们
13136
+ delete newItemValue[itemField.name];
13137
+ }
13138
+ if (newItemValue.children) {
13139
+ newItemValue.children = getTableValueWithoutEmptyValue(newItemValue.children, fields);
13140
+ }
13141
+ });
13142
+ return newItemValue;
13143
+ });
13144
+ }
13145
+
13146
+ function getTablePrimaryKey(props) {
13147
+ return props.primaryKey || "_id";
13148
+ }
13149
+
13150
+ /**
13151
+ * 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
13152
+ * @param {*} value 子表组件字段值,数组
13153
+ * @param {*} primaryKey 主键字段名,一般为_id
13154
+ * @returns 转换后的子表组件字段值
13155
+ */
13156
+ function getTableValueWithPrimaryKeyValue(value, primaryKey) {
13157
+ if (!primaryKey) {
13158
+ return value;
13159
+ }
13160
+ return (value || []).map((itemValue) => {
13161
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
13162
+ const newItemValue = clone(itemValue);
13163
+ if (newItemValue[primaryKey]) {
13164
+ if (newItemValue.children) {
13165
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13166
+ }
13167
+ return newItemValue;
13168
+ }
13169
+ else {
13170
+ newItemValue[primaryKey] = uuidv4();
13171
+ if (newItemValue.children) {
13172
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13173
+ }
13174
+ return newItemValue;
13175
+ }
13176
+ });
13177
+ }
13178
+
13179
+ /**
13180
+ * 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
13181
+ * @param {*} value 子表组件字段值,数组
13182
+ * @param {*} primaryKey 主键字段名,一般为_id
13183
+ * @returns 转换后的子表组件字段值
13184
+ */
13185
+ function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
13186
+ if (!primaryKey) {
13187
+ return value;
13188
+ }
13189
+ return (value || []).map((itemValue) => {
13190
+ //这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
13191
+ const newItemValue = clone(itemValue);
13192
+ if (newItemValue.children) {
13193
+ newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
13194
+ }
13195
+ delete newItemValue[primaryKey];
13196
+ return newItemValue;
13197
+ });
13198
+ }
13199
+
13200
+ /**
13201
+ * 子表组件字段值中每行数据的键值key移除指定前缀
13202
+ * @param {*} value 子表组件字段值,数组
13203
+ * @param {*} fieldPrefix 字段前缀
13204
+ * @returns 转换后的子表组件字段值
13205
+ */
13206
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
13207
+ let convertedValue = [];
13208
+ (value || []).forEach((itemValue) => {
13209
+ var newItemValue = {};
13210
+ for (let n in itemValue) {
13211
+ if (itemValue.hasOwnProperty(n)) {
13212
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13213
+ }
13214
+ }
13215
+ convertedValue.push(newItemValue);
13216
+ });
13217
+ return convertedValue;
13218
+ }
13219
+
13220
+ /**
13221
+ * 子表组件字段值中每行数据的键值key补上指定前缀
13222
+ * @param {*} value 子表组件字段值,数组
13223
+ * @param {*} fieldPrefix 字段前缀
13224
+ * @param {*} primaryKey 主键字段名,主键不参与被键值key规则,需要排除,审批王amis表单也是这个规则
13225
+ * @returns 转换后的子表组件字段值
12706
13226
  */
13227
+ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
13228
+ let convertedValue = [];
13229
+ (value || []).forEach((itemValue) => {
13230
+ var newItemValue = {};
13231
+ for (let n in itemValue) {
13232
+ if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
13233
+ newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13234
+ }
13235
+ }
13236
+ if (primaryKey && itemValue[primaryKey]) {
13237
+ newItemValue[primaryKey] = itemValue[primaryKey];
13238
+ }
13239
+ convertedValue.push(newItemValue);
13240
+ });
13241
+ return convertedValue;
13242
+ }
13243
+
13244
+ /**
13245
+ * 子表组件字段集合属性中每个字段name移除指定前缀
13246
+ * @param {*} fields 子表组件字段集合,数组
13247
+ * @param {*} fieldPrefix 字段前缀
13248
+ * @returns 转换后的子表组件字段值
13249
+ */
13250
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
13251
+ return (fields || []).map((item) => {
13252
+ const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
13253
+ newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
13254
+ return newItem;
13255
+ });
13256
+ }
12707
13257
 
12708
13258
  /**
12709
13259
  * @param {*} props
12710
13260
  * @param {*} mode edit/new/readonly
12711
13261
  */
12712
13262
  function getFormFields(props, mode = "edit") {
12713
- return (props.fields || []).map(function (item) {
13263
+ let fieldPrefix = props.fieldPrefix;
13264
+ let fields = props.fields || [];
13265
+ if (fieldPrefix) {
13266
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13267
+ }
13268
+ return (fields || []).map(function (item) {
12714
13269
  let formItem = {
12715
13270
  "type": "steedos-field",
12716
13271
  "name": item.name,
@@ -12730,6 +13285,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
12730
13285
  name: field.name,
12731
13286
  quickEdit: {
12732
13287
  "type": "steedos-field",
13288
+ "mode": "inline",
12733
13289
  "config": Object.assign({}, field, {
12734
13290
  label: false
12735
13291
  })
@@ -12782,7 +13338,12 @@ async function getInputTableColumns(props) {
12782
13338
  let inlineEditMode = props.inlineEditMode;
12783
13339
  let showAsInlineEditMode = inlineEditMode && props.editable;
12784
13340
  // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
12785
- let fields = props.fields;
13341
+
13342
+ let fieldPrefix = props.fieldPrefix;
13343
+ let fields = props.fields || [];
13344
+ if (fieldPrefix) {
13345
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13346
+ }
12786
13347
  if (columns && columns.length) {
12787
13348
  return columns.map(function (column) {
12788
13349
  let field, extendColumnProps = {};
@@ -12804,7 +13365,9 @@ async function getInputTableColumns(props) {
12804
13365
  }
12805
13366
  }
12806
13367
  if (field) {
12807
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13368
+ let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
13369
+ extendColumnProps.inlineEditMode : showAsInlineEditMode;
13370
+ let tableCell = getInputTableCell(field, mode);
12808
13371
  return Object.assign({}, tableCell, extendColumnProps);
12809
13372
  }
12810
13373
  else {
@@ -12827,7 +13390,7 @@ async function getInputTableColumns(props) {
12827
13390
  */
12828
13391
  function getFormPagination(props, mode) {
12829
13392
  let showPagination = true;
12830
- if(mode === "new" && !!!props.editable){
13393
+ if (mode === "new" && !!!props.editable) {
12831
13394
  //不允许编辑只允许新建时不应该让用户操作翻页
12832
13395
  showPagination = false;
12833
13396
  }
@@ -12843,23 +13406,41 @@ function getFormPagination(props, mode) {
12843
13406
  let __formId = "${formId}";
12844
13407
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
12845
13408
  let pageChangeDirection = context.props.pageChangeDirection;
13409
+ let mode = "${mode}";
12846
13410
  // event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
12847
13411
  // 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
12848
13412
  // 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
12849
13413
  // let currentPage = currentIndex + 1;
12850
13414
  let currentPage = event.data.__page;
12851
13415
  let currentIndex = event.data.index;
12852
- // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12853
- let currentFormValues = scope.getComponentById(__formId).getValues();
12854
- fieldValue[currentIndex] = currentFormValues;
12855
- // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
12856
- doAction({
12857
- "componentId": "${props.id}",
12858
- "actionType": "setValue",
12859
- "args": {
12860
- "value": fieldValue
13416
+ if(mode !== "readonly"){
13417
+ // 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
13418
+ // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13419
+ let currentFormValues = scope.getComponentById(__formId).getValues();
13420
+ // 这里不clone的话,其值会带上__super属性
13421
+ currentFormValues = _.clone(currentFormValues);
13422
+ var parent = event.data.parent;
13423
+ var __parentIndex = event.data.__parentIndex;
13424
+ if(parent){
13425
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13426
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13427
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13428
+ children: fieldValue[__parentIndex].children,
13429
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13430
+ });
12861
13431
  }
12862
- });
13432
+ else{
13433
+ fieldValue[currentIndex] = currentFormValues;
13434
+ }
13435
+ // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13436
+ doAction({
13437
+ "componentId": "${props.id}",
13438
+ "actionType": "setValue",
13439
+ "args": {
13440
+ "value": fieldValue
13441
+ }
13442
+ });
13443
+ }
12863
13444
 
12864
13445
  // 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
12865
13446
  let targetPage;
@@ -12908,9 +13489,14 @@ function getFormPagination(props, mode) {
12908
13489
  "onEvent": {
12909
13490
  "click": {
12910
13491
  "actions": [
13492
+ {
13493
+ "actionType": "validate",
13494
+ "componentId": formId
13495
+ },
12911
13496
  {
12912
13497
  "actionType": "custom",
12913
- "script": onPageChangeScript
13498
+ "script": onPageChangeScript,
13499
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
12914
13500
  }
12915
13501
  ]
12916
13502
  }
@@ -12918,7 +13504,8 @@ function getFormPagination(props, mode) {
12918
13504
  },
12919
13505
  {
12920
13506
  "type": "tpl",
12921
- "tpl": "${__page}/${__tableItems.length}"
13507
+ // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13508
+ "tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
12922
13509
  },
12923
13510
  {
12924
13511
  "type": "button",
@@ -12926,15 +13513,22 @@ function getFormPagination(props, mode) {
12926
13513
  "icon": `fa fa-angle-right`,
12927
13514
  "level": "link",
12928
13515
  "pageChangeDirection": "next",
12929
- "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13516
+ // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13517
+ // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13518
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
12930
13519
  "size": "sm",
12931
13520
  "id": buttonNextId,
12932
13521
  "onEvent": {
12933
13522
  "click": {
12934
13523
  "actions": [
13524
+ {
13525
+ "actionType": "validate",
13526
+ "componentId": formId
13527
+ },
12935
13528
  {
12936
13529
  "actionType": "custom",
12937
- "script": onPageChangeScript
13530
+ "script": onPageChangeScript,
13531
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
12938
13532
  }
12939
13533
  ]
12940
13534
  }
@@ -12955,18 +13549,19 @@ function getFormPaginationWrapper(props, form, mode) {
12955
13549
  // console.log("==getFormPaginationWrapper===", props, mode);
12956
13550
  let serviceId = getComponentId("form_pagination", props.id);
12957
13551
  let tableServiceId = getComponentId("table_service", props.id);
13552
+ let primaryKey = getTablePrimaryKey(props);
12958
13553
  let innerForm = Object.assign({}, form, {
12959
13554
  "data": {
12960
13555
  // 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
12961
13556
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
12962
- "&": "${__tableItems[__super.index]}"
13557
+ "&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
12963
13558
  }
12964
13559
  });
12965
13560
  let formBody = [
12966
13561
  {
12967
13562
  "type": "wrapper",
12968
13563
  "size": "none",
12969
- "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white -mt-2",
13564
+ "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
12970
13565
  "body": [
12971
13566
  getFormPagination(props, mode)
12972
13567
  ]
@@ -12982,7 +13577,7 @@ function getFormPaginationWrapper(props, form, mode) {
12982
13577
  }
12983
13578
  ];
12984
13579
  let onServiceInitedScript = `
12985
- // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13580
+ // 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
12986
13581
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
12987
13582
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
12988
13583
  // 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
@@ -12995,8 +13590,13 @@ function getFormPaginationWrapper(props, form, mode) {
12995
13590
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
12996
13591
  // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
12997
13592
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
13593
+ let fieldPrefix = "${props.fieldPrefix || ''}";
13594
+ if(fieldPrefix){
13595
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
13596
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
13597
+ }
12998
13598
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
12999
- let mode = "${mode}";
13599
+ let mode = "${mode || ''}";
13000
13600
  if(mode === "new"){
13001
13601
  // 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
13002
13602
  // 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
@@ -13017,6 +13617,26 @@ function getFormPaginationWrapper(props, form, mode) {
13017
13617
  event.data.__tableItems.forEach(function(n,i){
13018
13618
  event.data.__tableItems[i] = lastestFieldValue[i];
13019
13619
  });
13620
+
13621
+ var parent = event.data.parent;
13622
+ var fieldValue = event.data.__tableItems;
13623
+ if(parent){
13624
+ // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13625
+ var primaryKey = "${primaryKey}";
13626
+ event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13627
+ return item[primaryKey] == parent[primaryKey];
13628
+ });
13629
+ if(event.data.__parentIndex < 0){
13630
+ let tableId = "${props.id}";
13631
+ let table = scope.getComponentById(tableId)
13632
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13633
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13634
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13635
+ event.data.__parentIndex = _.findIndex(table.props.value, function(item){
13636
+ return item[primaryKey] == parent[primaryKey];
13637
+ });
13638
+ }
13639
+ }
13020
13640
  `;
13021
13641
  let schema = {
13022
13642
  "type": "service",
@@ -13037,6 +13657,7 @@ function getFormPaginationWrapper(props, form, mode) {
13037
13657
  // "body": formBody,
13038
13658
  "data": {
13039
13659
  "__page": "${index + 1}",
13660
+ "__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
13040
13661
  // "__total": `\${${props.name}.length}`,
13041
13662
  // "__total": "${__tableItems.length}",
13042
13663
  // "__paginationServiceId": serviceId,
@@ -13063,6 +13684,7 @@ function getFormPaginationWrapper(props, form, mode) {
13063
13684
  async function getForm(props, mode = "edit", formId) {
13064
13685
  let formFields = getFormFields(props, mode);
13065
13686
  let body = await getFormBody(null, formFields);
13687
+ let primaryKey = getTablePrimaryKey(props);
13066
13688
  if (!formId) {
13067
13689
  formId = getComponentId("form", props.id);
13068
13690
  }
@@ -13081,10 +13703,41 @@ async function getForm(props, mode = "edit", formId) {
13081
13703
  // 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
13082
13704
  let onEditItemSubmitScript = `
13083
13705
  // let fieldValue = _.cloneDeep(event.data["${props.name}"]);
13706
+ let removeEmptyItems = function(items){
13707
+ let i = _.findIndex(items, function(item){
13708
+ return item === undefined
13709
+ });
13710
+ if(i > -1){
13711
+ items.splice(i, 1);
13712
+ removeEmptyItems(items);
13713
+ }
13714
+ }
13715
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13716
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13717
+ removeEmptyItems(event.data.__tableItems);
13084
13718
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13085
13719
  //这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
13086
13720
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
13087
- fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
13721
+ // fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
13722
+ var currentIndex = event.data.__super.__super.index;
13723
+ var currentFormValues = JSON.parse(JSON.stringify(event.data));
13724
+ var parent = event.data.__super.__super.parent;
13725
+ var __parentIndex = event.data.__super.__super.__parentIndex;
13726
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
13727
+ var primaryKey = "${primaryKey}";
13728
+ if(parent){
13729
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13730
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13731
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13732
+ children: fieldValue[__parentIndex].children,
13733
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13734
+ });
13735
+ }
13736
+ else{
13737
+ // 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
13738
+ // 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
13739
+ fieldValue[currentIndex] = currentFormValues;
13740
+ }
13088
13741
  doAction({
13089
13742
  "componentId": "${props.id}",
13090
13743
  "actionType": "setValue",
@@ -13180,13 +13833,14 @@ async function getForm(props, mode = "edit", formId) {
13180
13833
  */
13181
13834
  async function getButtonActions(props, mode) {
13182
13835
  let actions = [];
13836
+ let primaryKey = getTablePrimaryKey(props);
13183
13837
  let formId = getComponentId("form", props.id);
13184
13838
  let dialogId = getComponentId("dialog", props.id);
13185
13839
  let buttonNextId = getComponentId("button_next", props.id);
13186
13840
  let formPaginationId = getComponentId("form_pagination", props.id);
13187
13841
  let parentFormData = "${__super.__super.__super.__super || {}}";
13188
13842
  let amisVersion = getComparableAmisVersion();
13189
- if(amisVersion < 3.6){
13843
+ if (amisVersion < 3.6) {
13190
13844
  parentFormData = "${__super.__super || {}}";
13191
13845
  }
13192
13846
  if (mode == "new" || mode == "edit") {
@@ -13222,9 +13876,42 @@ async function getButtonActions(props, mode) {
13222
13876
  // };
13223
13877
  let onSaveAndNewItemScript = `
13224
13878
  let scope = event.context.scoped;
13879
+ let removeEmptyItems = function(items){
13880
+ let i = _.findIndex(items, function(item){
13881
+ return item === undefined
13882
+ });
13883
+ if(i > -1){
13884
+ items.splice(i, 1);
13885
+ removeEmptyItems(items);
13886
+ }
13887
+ }
13888
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13889
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13890
+ removeEmptyItems(event.data.__tableItems);
13225
13891
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13226
13892
  // 新建一条空白行并保存到子表组件
13227
- fieldValue.push({});
13893
+ var parent = event.data.__super.parent;
13894
+ var primaryKey = "${primaryKey}";
13895
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13896
+ return item[primaryKey] == parent[primaryKey];
13897
+ });
13898
+ if(parent && __parentIndex < 0){
13899
+ let tableId = "${props.id}";
13900
+ let table = scope.getComponentById(tableId)
13901
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13902
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13903
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13904
+ __parentIndex = _.findIndex(table.props.value, function(item){
13905
+ return item[primaryKey] == parent[primaryKey];
13906
+ });
13907
+ }
13908
+ if(parent){
13909
+ fieldValue[__parentIndex].children.push({});
13910
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13911
+ }
13912
+ else{
13913
+ fieldValue.push({});
13914
+ }
13228
13915
  doAction({
13229
13916
  "componentId": "${props.id}",
13230
13917
  "actionType": "setValue",
@@ -13236,7 +13923,13 @@ async function getButtonActions(props, mode) {
13236
13923
  let __paginationServiceId = "${formPaginationId}";
13237
13924
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13238
13925
  event.data.index = __paginationData.index;
13239
- event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13926
+ if(parent){
13927
+ event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13928
+ event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
13929
+ }
13930
+ else{
13931
+ event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13932
+ }
13240
13933
  // 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
13241
13934
  scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
13242
13935
  `;
@@ -13245,9 +13938,49 @@ async function getButtonActions(props, mode) {
13245
13938
  let __formId = "${formId}";
13246
13939
  // let newItem = JSON.parse(JSON.stringify(event.data));
13247
13940
  let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
13941
+ newItem = _.clone(newItem);
13942
+ let removeEmptyItems = function(items){
13943
+ let i = _.findIndex(items, function(item){
13944
+ return item === undefined
13945
+ });
13946
+ if(i > -1){
13947
+ items.splice(i, 1);
13948
+ removeEmptyItems(items);
13949
+ }
13950
+ }
13951
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13952
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13953
+ removeEmptyItems(event.data.__tableItems);
13248
13954
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13249
13955
  // 复制当前页数据到新建行并保存到子表组件
13250
- fieldValue.push(newItem);
13956
+ // fieldValue.push(newItem);
13957
+ var parent = event.data.__super.parent;
13958
+ var primaryKey = "${primaryKey}";
13959
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13960
+ return item[primaryKey] == parent[primaryKey];
13961
+ });
13962
+ if(parent && __parentIndex < 0){
13963
+ let tableId = "${props.id}";
13964
+ let table = scope.getComponentById(tableId)
13965
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13966
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13967
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13968
+ __parentIndex = _.findIndex(table.props.value, function(item){
13969
+ return item[primaryKey] == parent[primaryKey];
13970
+ });
13971
+ }
13972
+ if(newItem[primaryKey]){
13973
+ // 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
13974
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
13975
+ newItem[primaryKey] = uuidv4();
13976
+ }
13977
+ if(parent){
13978
+ fieldValue[__parentIndex].children.push(newItem);
13979
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13980
+ }
13981
+ else{
13982
+ fieldValue.push(newItem);
13983
+ }
13251
13984
  doAction({
13252
13985
  "componentId": "${props.id}",
13253
13986
  "actionType": "setValue",
@@ -13259,19 +13992,25 @@ async function getButtonActions(props, mode) {
13259
13992
  let __paginationServiceId = "${formPaginationId}";
13260
13993
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13261
13994
  event.data.index = __paginationData.index;
13262
- event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13995
+ if(parent){
13996
+ event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13997
+ event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
13998
+ }
13999
+ else{
14000
+ event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
14001
+ }
13263
14002
  // 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
13264
14003
  scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
13265
14004
  `;
13266
14005
  let dialogButtons = [
13267
14006
  {
13268
- "type": "button",
13269
- "label": "完成",
13270
- "actionType": "confirm",
13271
- "level": "primary"
14007
+ "type": "button",
14008
+ "label": "完成",
14009
+ "actionType": "confirm",
14010
+ "level": "primary"
13272
14011
  }
13273
14012
  ];
13274
- if(props.addable){
14013
+ if (props.addable) {
13275
14014
  // 有新增行权限时额外添加新增和复制按钮
13276
14015
  dialogButtons = [
13277
14016
  {
@@ -13281,9 +14020,14 @@ async function getButtonActions(props, mode) {
13281
14020
  "onEvent": {
13282
14021
  "click": {
13283
14022
  "actions": [
14023
+ {
14024
+ "actionType": "validate",
14025
+ "componentId": formId
14026
+ },
13284
14027
  {
13285
14028
  "actionType": "custom",
13286
- "script": onSaveAndNewItemScript
14029
+ "script": onSaveAndNewItemScript,
14030
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13287
14031
  }
13288
14032
  ]
13289
14033
  }
@@ -13296,9 +14040,14 @@ async function getButtonActions(props, mode) {
13296
14040
  "onEvent": {
13297
14041
  "click": {
13298
14042
  "actions": [
14043
+ {
14044
+ "actionType": "validate",
14045
+ "componentId": formId
14046
+ },
13299
14047
  {
13300
14048
  "actionType": "custom",
13301
- "script": onSaveAndCopyItemScript
14049
+ "script": onSaveAndCopyItemScript,
14050
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13302
14051
  }
13303
14052
  ]
13304
14053
  }
@@ -13335,12 +14084,15 @@ async function getButtonActions(props, mode) {
13335
14084
  "_master": "${_master}",
13336
14085
  "global": "${global}",
13337
14086
  "uiSchema": "${uiSchema}",
13338
- "index": "${index}",
14087
+ "index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
14088
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13339
14089
  // "__tableItems": `\${${props.name}}`
13340
14090
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13341
14091
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13342
14092
  // "__tableItems": `\${${props.name}|json|toJson}`
13343
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
14093
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14094
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14095
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13344
14096
  },
13345
14097
  "actions": dialogButtons,
13346
14098
  "onEvent": {
@@ -13363,35 +14115,39 @@ async function getButtonActions(props, mode) {
13363
14115
  Object.assign(actionShowEditDialog.dialog, props.dialog);
13364
14116
  }
13365
14117
  if (mode == "new") {
13366
- `
13367
- let newItem = {};
13368
- if(event.data["${props.name}"]){
13369
- // let fieldValue = event.data.__tableItems;
13370
- // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
13371
- // let fieldValue = _.clone(event.data["${props.name}"]);
13372
- let fieldValue = event.data["${props.name}"];
13373
- fieldValue.push(newItem);
13374
- doAction({
13375
- "componentId": "${props.id}",
13376
- "actionType": "setValue",
13377
- "args": {
13378
- "value": fieldValue
13379
- }
13380
- });
13381
- event.data.index = fieldValue.length - 1;
13382
- }
13383
- else{
13384
- // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
13385
- doAction({
13386
- "componentId": "${props.id}",
13387
- "actionType": "setValue",
13388
- "args": {
13389
- "value": [newItem]
13390
- }
13391
- });
13392
- event.data.index = 1;
13393
- }
13394
- `;
14118
+ // let onNewLineScript = `
14119
+ // let newItem = {};
14120
+ // if(event.data["${props.name}"]){
14121
+ // // let fieldValue = event.data.__tableItems;
14122
+ // // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
14123
+ // // let fieldValue = _.clone(event.data["${props.name}"]);
14124
+ // let fieldValue = event.data["${props.name}"];
14125
+ // fieldValue.push(newItem);
14126
+ // doAction({
14127
+ // "componentId": "${props.id}",
14128
+ // "actionType": "setValue",
14129
+ // "args": {
14130
+ // "value": fieldValue
14131
+ // }
14132
+ // });
14133
+ // event.data.index = fieldValue.length - 1;
14134
+ // }
14135
+ // else{
14136
+ // // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
14137
+ // doAction({
14138
+ // "componentId": "${props.id}",
14139
+ // "actionType": "setValue",
14140
+ // "args": {
14141
+ // "value": [newItem]
14142
+ // }
14143
+ // });
14144
+ // event.data.index = 1;
14145
+ // }
14146
+ // `;
14147
+ // let actionNewLine = {
14148
+ // "actionType": "custom",
14149
+ // "script": onNewLineScript
14150
+ // };
13395
14151
  // 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
13396
14152
  // actions = [actionNewLine, actionShowEditDialog];
13397
14153
  actions = [actionShowEditDialog];
@@ -13426,15 +14182,20 @@ async function getButtonActions(props, mode) {
13426
14182
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13427
14183
  // "__parentForm": "${__super.__super || {}}",
13428
14184
  "__parentForm": parentFormData,
14185
+ "_master": "${_master}",
13429
14186
  "global": "${global}",
13430
14187
  "uiSchema": "${uiSchema}",
13431
14188
  "index": "${index}",
14189
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13432
14190
  // "__tableItems": `\${${props.name}}`
13433
14191
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13434
14192
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13435
14193
  // "__tableItems": `\${${props.name}|json|toJson}`
13436
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
13437
- },
14194
+ // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14195
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14196
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14197
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14198
+ },
13438
14199
  }
13439
14200
  }
13440
14201
  ];
@@ -13449,8 +14210,40 @@ async function getButtonActions(props, mode) {
13449
14210
  let wrapperServiceData = wrapperService.getData();
13450
14211
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13451
14212
  // 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
14213
+ // 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
13452
14214
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13453
- lastestFieldValue.splice(event.data.index, 1);
14215
+ var currentIndex = event.data.index;
14216
+ var parent = event.data.__super.parent;
14217
+ var primaryKey = "${primaryKey}";
14218
+ var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
14219
+ return item[primaryKey] == parent[primaryKey];
14220
+ });
14221
+ if(parent && __parentIndex < 0){
14222
+ let tableId = "${props.id}";
14223
+ let table = scope.getComponentById(tableId)
14224
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14225
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14226
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14227
+ __parentIndex = _.findIndex(table.props.value, function(item){
14228
+ return item[primaryKey] == parent[primaryKey];
14229
+ });
14230
+ }
14231
+ if(parent){
14232
+ lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
14233
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
14234
+ lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
14235
+ children: lastestFieldValue[__parentIndex].children,
14236
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
14237
+ });
14238
+ }
14239
+ else{
14240
+ lastestFieldValue.splice(currentIndex, 1);
14241
+ }
14242
+ let fieldPrefix = "${props.fieldPrefix || ''}";
14243
+ if(fieldPrefix){
14244
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
14245
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
14246
+ }
13454
14247
  doAction({
13455
14248
  "componentId": "${props.id}",
13456
14249
  "actionType": "setValue",
@@ -13520,58 +14313,104 @@ async function getButtonView(props) {
13520
14313
 
13521
14314
  async function getButtonDelete(props) {
13522
14315
  return {
13523
- "type": "button",
13524
- "label": "",
13525
- "icon": "fa fa-trash-alt",//不可以用fa-trash-o,因为设计字段布局界面中弹出的设置分组列表中显示不了这个图标
14316
+ "type": "dropdown-button",
13526
14317
  "level": "link",
13527
- "onEvent": {
13528
- "click": {
13529
- "actions": await getButtonActions(props, "delete")
14318
+ "icon": "fa fa-trash-alt",
14319
+ "size": "xs",
14320
+ "hideCaret": true,
14321
+ "closeOnClick": true,
14322
+ "body": [
14323
+ {
14324
+ "type": "wrapper",
14325
+ "size": "md",
14326
+ "className": "w-80",
14327
+ "body": [
14328
+ {
14329
+ "tpl": "确定要删除吗?",
14330
+ "type": "tpl"
14331
+ },
14332
+ {
14333
+ "type": "flex",
14334
+ "justify": "flex-end",
14335
+ "className": "mt-3",
14336
+ "items": [
14337
+ {
14338
+ "type": "button",
14339
+ "label": "取消",
14340
+ "className": "mr-2"
14341
+ },
14342
+ {
14343
+ "type": "button",
14344
+ "label": "删除",
14345
+ "level": "danger",
14346
+ "onEvent": {
14347
+ "click": {
14348
+ "actions": await getButtonActions(props, "delete")
14349
+ }
14350
+ }
14351
+ }
14352
+ ]
14353
+ }
14354
+ ]
13530
14355
  }
13531
- }
13532
- };
14356
+ ]
14357
+ }
13533
14358
  }
13534
14359
 
14360
+
13535
14361
  const getAmisInputTableSchema = async (props) => {
13536
14362
  if (!props.id) {
13537
14363
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13538
14364
  }
14365
+ let primaryKey = getTablePrimaryKey(props);
14366
+ let showOperation = props.showOperation;
14367
+ if (showOperation !== false) {
14368
+ showOperation = true;
14369
+ }
14370
+ let fieldPrefix = props.fieldPrefix;
14371
+ let fields = props.fields || [];
14372
+ if (fieldPrefix) {
14373
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
14374
+ }
13539
14375
  let serviceId = getComponentId("table_service", props.id);
13540
14376
  let buttonsForColumnOperations = [];
13541
14377
  let inlineEditMode = props.inlineEditMode;
13542
14378
  let showAsInlineEditMode = inlineEditMode && props.editable;
13543
- if (props.editable) {
13544
- let showEditButton = true;
13545
- if (showAsInlineEditMode) {
13546
- // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
13547
- showEditButton = true;
13548
- // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
13549
- // if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
13550
- // showEditButton = true;
13551
- // }
13552
- // else {
13553
- // showEditButton = false;
13554
- // }
14379
+ if (showOperation) {
14380
+ if (props.editable) {
14381
+ let showEditButton = true;
14382
+ if (showAsInlineEditMode) {
14383
+ // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
14384
+ showEditButton = true;
14385
+ // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
14386
+ // if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
14387
+ // showEditButton = true;
14388
+ // }
14389
+ // else {
14390
+ // showEditButton = false;
14391
+ // }
14392
+ }
14393
+ // 编辑时显示编辑按钮
14394
+ if (showEditButton) {
14395
+ let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
14396
+ buttonsForColumnOperations.push(buttonEditSchema);
14397
+ }
13555
14398
  }
13556
- // 编辑时显示编辑按钮
13557
- if (showEditButton) {
13558
- let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
13559
- buttonsForColumnOperations.push(buttonEditSchema);
14399
+ else {
14400
+ // 只读时显示查看按钮
14401
+ // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
14402
+ let buttonViewSchema = await getButtonView(props);
14403
+ buttonsForColumnOperations.push(buttonViewSchema);
14404
+ }
14405
+ if (props.removable) {
14406
+ let buttonDeleteSchema = await getButtonDelete(props);
14407
+ buttonsForColumnOperations.push(buttonDeleteSchema);
13560
14408
  }
13561
14409
  }
13562
- else {
13563
- // 只读时显示查看按钮
13564
- // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
13565
- let buttonViewSchema = await getButtonView(props);
13566
- buttonsForColumnOperations.push(buttonViewSchema);
13567
- }
13568
- if (props.removable) {
13569
- let buttonDeleteSchema = await getButtonDelete(props);
13570
- buttonsForColumnOperations.push(buttonDeleteSchema);
13571
- }
14410
+ let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
13572
14411
  let inputTableSchema = {
13573
14412
  "type": "input-table",
13574
- "label": props.label,
14413
+ "mode": "normal",
13575
14414
  "name": props.name,
13576
14415
  //不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
13577
14416
  // "addable": props.addable,
@@ -13586,7 +14425,53 @@ const getAmisInputTableSchema = async (props) => {
13586
14425
  "strictMode": props.strictMode,
13587
14426
  "showTableAddBtn": false,
13588
14427
  "showFooterAddBtn": false,
13589
- "className": props.tableClassName
14428
+ "className": props.tableClassName,
14429
+ "pipeIn": (value, data) => {
14430
+ if (fieldPrefix) {
14431
+ value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
14432
+ }
14433
+ value = getTableValueWithEmptyValue(value, fields);
14434
+ if (primaryKey) {
14435
+ // 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
14436
+ // 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
14437
+ // 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
14438
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14439
+ }
14440
+ if (amis.pipeIn) {
14441
+ if (typeof amis.pipeIn === 'function') {
14442
+ return amis.pipeIn(value, data);
14443
+ }
14444
+ }
14445
+ return value;
14446
+ },
14447
+ "pipeOut": (value, data) => {
14448
+ value = (value || []).map(function (item) {
14449
+ delete item.__fix_rerender_after_children_modified_tag;
14450
+ return item;
14451
+ });
14452
+ if (fieldPrefix) {
14453
+ value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
14454
+ }
14455
+ value = getTableValueWithoutEmptyValue(value, fields);
14456
+ if (props.autoGeneratePrimaryKeyValue === true) {
14457
+ // 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
14458
+ // 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
14459
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14460
+ }
14461
+ else {
14462
+ // 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
14463
+ // 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
14464
+ // 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
14465
+ // 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
14466
+ value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
14467
+ }
14468
+ if (amis.pipeOut) {
14469
+ if (typeof amis.pipeOut === 'function') {
14470
+ return amis.pipeOut(value, data);
14471
+ }
14472
+ }
14473
+ return value;
14474
+ }
13590
14475
  };
13591
14476
  if (buttonsForColumnOperations.length) {
13592
14477
  inputTableSchema.columns.push({
@@ -13596,20 +14481,22 @@ const getAmisInputTableSchema = async (props) => {
13596
14481
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
13597
14482
  });
13598
14483
  }
13599
- if (showAsInlineEditMode) {
13600
- inputTableSchema.needConfirm = false;
13601
- }
13602
- let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
14484
+ // if (showAsInlineEditMode) {
14485
+ // // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
14486
+ // inputTableSchema.needConfirm = false;
14487
+ // }
13603
14488
  if (amis) {
13604
14489
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
13605
14490
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
14491
+ delete amis.pipeIn;//该属性在上面合并过了
14492
+ delete amis.pipeOut;//该属性在上面合并过了
13606
14493
  Object.assign(inputTableSchema, amis);
13607
14494
  }
13608
- const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
14495
+ const isAnyFieldHasDependOn = (fields || []).find(function (item) {
13609
14496
  return item.depend_on;
13610
14497
  });
13611
14498
  if (isAnyFieldHasDependOn) {
13612
- // 有任意一个子字段有depend_on属性时,强制设置禁用静态模式
14499
+ // 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
13613
14500
  Object.assign(inputTableSchema, {
13614
14501
  strictMode: false
13615
14502
  });
@@ -13638,11 +14525,31 @@ const getAmisInputTableSchema = async (props) => {
13638
14525
  "body": headerToolbar
13639
14526
  });
13640
14527
  }
14528
+ let className = "steedos-input-table";
14529
+
14530
+ if (typeof props.className == "object") {
14531
+ className = {
14532
+ [className]: "true",
14533
+ ...props.className
14534
+ };
14535
+ } else if (typeof props.className == "string") {
14536
+ className = `${className} ${props.className} `;
14537
+ }
14538
+
13641
14539
  let schema = {
13642
- "type": "service",
13643
- "body": schemaBody,
13644
- "className": props.className,
13645
- "id": serviceId
14540
+ "type": "control",
14541
+ "body": {
14542
+ "type": "service",
14543
+ "body": schemaBody,
14544
+ "id": serviceId
14545
+ },
14546
+ "label": props.label,
14547
+ "labelClassName": props.label ? props.labelClassName : "none",
14548
+ "labelRemark": props.labelRemark,
14549
+ "labelAlign": props.labelAlign,
14550
+ //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14551
+ "mode": props.mode || null,
14552
+ className
13646
14553
  };
13647
14554
  // console.log("===schema===", schema);
13648
14555
  return schema;
@@ -13714,7 +14621,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
13714
14621
  // 获取
13715
14622
  async function getRecordPageInitSchema(objectApiName){
13716
14623
  const relatedList = await getObjectRelatedList(objectApiName);
13717
- const uiSchema = await getUISchema(objectApiName);
14624
+ await getUISchema(objectApiName);
13718
14625
  let body = [
13719
14626
  // detailHeaderAmisSchema,
13720
14627
  {
@@ -13722,28 +14629,7 @@ async function getRecordPageInitSchema(objectApiName){
13722
14629
  "label": "标题面板",
13723
14630
  "objectApiName": "${objectName}",
13724
14631
  "recordId": "${recordId}",
13725
- "onEvent": {
13726
- "recordLoaded": {
13727
- "actions": [
13728
- {
13729
- "actionType": "setValue",
13730
- "args": {
13731
- "value": {
13732
- "recordLoaded": true,
13733
- }
13734
- }
13735
- },
13736
- {
13737
- "actionType": "reload",
13738
- "data": {
13739
- "name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
13740
- "record": `\${record}`,
13741
- "recordLoaded": true,
13742
- }
13743
- }
13744
- ]
13745
- }
13746
- }
14632
+ "onEvent": {}
13747
14633
  }
13748
14634
  ];
13749
14635
  let contentBody = {
@@ -16308,5 +17194,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
16308
17194
  };
16309
17195
  };
16310
17196
 
16311
- export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
17197
+ export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getObjectRelatedListsMiniSchema, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailMiniSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
16312
17198
  //# sourceMappingURL=index.esm.js.map