@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.cjs.js CHANGED
@@ -367,22 +367,29 @@ const getSteedosAuth = () => {
367
367
  * @Description:
368
368
  */
369
369
 
370
-
371
370
  const Router = {
372
371
  getTabDisplayAs(tab_id){
372
+ const uiSchema = getUISchemaSync$1(tab_id, false);
373
373
  var urlSearch = new URLSearchParams(document.location.search);
374
374
  if(urlSearch.has('display')){
375
375
  return urlSearch.get('display')
376
376
  }
377
377
  const key = `tab_${tab_id}_display`;
378
378
  // const key = `page_display`;
379
- const value = localStorage.getItem(key);
380
- return value ? value : 'grid'
379
+ const value = sessionStorage.getItem(key);
380
+ let defaultDisplay = "grid";
381
+ if(uiSchema.enable_split){
382
+ defaultDisplay = "split";
383
+ }
384
+ if(window.innerWidth <= 768){
385
+ return "grid";
386
+ }
387
+ return value ? value : defaultDisplay;
381
388
  },
382
389
 
383
390
  setTabDisplayAs(tab_id, displayAs){
384
391
  const key = `tab_${tab_id}_display`;
385
- localStorage.setItem(key, displayAs);
392
+ sessionStorage.setItem(key, displayAs);
386
393
  },
387
394
  getAppPath({formFactor, appId}){
388
395
  return `/app/${appId}`;
@@ -409,8 +416,8 @@ const Router = {
409
416
  /*
410
417
  * @Author: baozhoutao@steedos.com
411
418
  * @Date: 2022-07-20 16:29:22
412
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
413
- * @LastEditTime: 2023-12-28 14:59:08
419
+ * @LastEditors: liaodaxue
420
+ * @LastEditTime: 2024-01-25 14:44:17
414
421
  * @Description:
415
422
  */
416
423
 
@@ -482,11 +489,30 @@ function getComparableAmisVersion() {
482
489
  }
483
490
  }
484
491
 
492
+ /**
493
+ * 判断浏览器类型
494
+ * @returns 按需返回浏览器类型;
495
+ */
496
+ function getBowserType() {
497
+ const userAgent = navigator.userAgent;
498
+ if (userAgent.indexOf("Chrome")!== -1 && userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Edg") === -1) {
499
+ return "Chrome";
500
+ } else if (userAgent.indexOf("Firefox") !== -1) {
501
+ return "Firefox";
502
+ } else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("Edge") === -1) {
503
+ return "Safari";
504
+ } else if (userAgent.indexOf("Edg") !== -1) {
505
+ return "Edge";
506
+ } else {
507
+ return "Unknown browser"; // 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
508
+ }
509
+ }
510
+
485
511
  /*
486
512
  * @Author: baozhoutao@steedos.com
487
513
  * @Date: 2022-05-23 09:53:08
488
514
  * @LastEditors: liaodaxue
489
- * @LastEditTime: 2023-10-11 17:32:17
515
+ * @LastEditTime: 2024-01-17 16:00:27
490
516
  * @Description:
491
517
  */
492
518
 
@@ -558,7 +584,7 @@ function getSelectMap(selectOptions){
558
584
 
559
585
  function getNameTplUrl(field, ctx){
560
586
  if(ctx.objectName === 'cms_files'){
561
- return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
587
+ return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
562
588
  }
563
589
  const href = Router.getObjectDetailPath({
564
590
  ...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
@@ -1304,6 +1330,7 @@ var frontend_notifications$1 = "Notifications";
1304
1330
  var frontend_notifications_allread$1 = "Mark all as read";
1305
1331
  var frontend_notifications_allread_message$1 = "All marked as read";
1306
1332
  var frontend_profile$1 = "Profile";
1333
+ var switch_space$1 = "Switch Space";
1307
1334
  var frontend_about$1 = "About";
1308
1335
  var frontend_log_out$1 = "Log out";
1309
1336
  var frontend_listview_warning_start$1 = "The current ";
@@ -1391,6 +1418,7 @@ var en_us = {
1391
1418
  frontend_notifications_allread: frontend_notifications_allread$1,
1392
1419
  frontend_notifications_allread_message: frontend_notifications_allread_message$1,
1393
1420
  frontend_profile: frontend_profile$1,
1421
+ switch_space: switch_space$1,
1394
1422
  frontend_about: frontend_about$1,
1395
1423
  frontend_log_out: frontend_log_out$1,
1396
1424
  frontend_listview_warning_start: frontend_listview_warning_start$1,
@@ -1430,9 +1458,9 @@ var frontend_display_type_is_split = "分栏视图";
1430
1458
  var frontend_display_as = "显示为";
1431
1459
  var frontend_record_sum = "个项目";
1432
1460
  var frontend_button_reload_tooltip = "刷新";
1433
- var frontend_button_search_tooltip = "筛选";
1461
+ var frontend_button_search_tooltip = "搜索";
1434
1462
  var frontend_fields_filter_button_search = "搜索";
1435
- var frontend_fields_filter_button_settings = "设置搜索项";
1463
+ var frontend_fields_filter_button_settings = "选择搜索项";
1436
1464
  var frontend_button_listview_control_tooltip = "列表视图控制";
1437
1465
  var frontend_button_listview_control_label = "列表视图控制";
1438
1466
  var frontend_listview_control_columns = "显示的列";
@@ -1480,6 +1508,7 @@ var frontend_notifications = "通知";
1480
1508
  var frontend_notifications_allread = "全部标记为已读";
1481
1509
  var frontend_notifications_allread_message = "已全部标记为已读";
1482
1510
  var frontend_profile = "个人资料";
1511
+ var switch_space = "切换工作区";
1483
1512
  var frontend_about = "关于";
1484
1513
  var frontend_log_out = "注销";
1485
1514
  var frontend_listview_warning_start = "当前";
@@ -1568,6 +1597,7 @@ var zh_cn = {
1568
1597
  frontend_notifications_allread: frontend_notifications_allread,
1569
1598
  frontend_notifications_allread_message: frontend_notifications_allread_message,
1570
1599
  frontend_profile: frontend_profile,
1600
+ switch_space: switch_space,
1571
1601
  frontend_about: frontend_about,
1572
1602
  frontend_log_out: frontend_log_out,
1573
1603
  frontend_listview_warning_start: frontend_listview_warning_start,
@@ -1881,7 +1911,8 @@ async function getQuickEditSchema(field, options){
1881
1911
  "failed": "失败了呢。。"
1882
1912
  }
1883
1913
  }
1884
- }
1914
+ },
1915
+ "expression": "${!recordPermissions.modifyAllRecords}"
1885
1916
  },
1886
1917
  {
1887
1918
  "actionType": "setValue",
@@ -1897,7 +1928,7 @@ async function getQuickEditSchema(field, options){
1897
1928
  "componentId": quickEditId,
1898
1929
  "args": {
1899
1930
  "value":{
1900
- "quickedit_record_permissions": "${event.data}"
1931
+ "quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
1901
1932
  }
1902
1933
  }
1903
1934
  }
@@ -1961,7 +1992,7 @@ async function getQuickEditSchema(field, options){
1961
1992
  `
1962
1993
  }
1963
1994
  },
1964
- "expression":"${event.data.value}"
1995
+ "expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
1965
1996
  },
1966
1997
  {
1967
1998
  "actionType": "setValue",
@@ -1992,10 +2023,20 @@ async function getQuickEditSchema(field, options){
1992
2023
  "script": `
1993
2024
  const noPermission = event.data.noPermission;
1994
2025
  const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
1995
- const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
2026
+ let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
1996
2027
  noPermission.forEach(function (item) {
1997
2028
  crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
2029
+ _.remove(selectedItems, (selected) => selected._id === item);
1998
2030
  })
2031
+ doAction({
2032
+ "componentId": "${quickEditId}",
2033
+ "actionType": "setValue",
2034
+ "args": {
2035
+ "value": {
2036
+ selectedItems
2037
+ }
2038
+ }
2039
+ });
1999
2040
  `
2000
2041
  },
2001
2042
  {
@@ -2056,7 +2097,7 @@ async function getQuickEditSchema(field, options){
2056
2097
  }
2057
2098
 
2058
2099
  function getFieldWidth(width){
2059
- const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2100
+ const defaultWidth = null;
2060
2101
  if(typeof width == 'string'){
2061
2102
  if(isNaN(width)){
2062
2103
  return width || defaultWidth;
@@ -2086,18 +2127,35 @@ async function getTableColumns(fields, options){
2086
2127
  //增加quickEdit属性,实现快速编辑
2087
2128
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2088
2129
  let className = "";
2089
- if(field.wrap != true){
2130
+ const bowserType = getBowserType();
2131
+ if(bowserType === "Safari"){
2090
2132
  className += " whitespace-nowrap ";
2091
2133
  }else {
2092
- className += " break-all ";
2134
+ if(field.wrap != true){
2135
+ className += " whitespace-nowrap ";
2136
+ }else {
2137
+ className += " break-words ";
2138
+ }
2093
2139
  }
2140
+
2141
+ if (typeof field.amis?.className == "object") {
2142
+ className = {
2143
+ [className]: "true",
2144
+ ...field.amis.className
2145
+ };
2146
+ } else if (typeof field.amis?.className == "string") {
2147
+ className = `${className} ${field.amis.className} `;
2148
+ }
2149
+ let fieldAmis = ___namespace.clone(field.amis);
2150
+ delete fieldAmis?.className;
2151
+
2094
2152
  let columnItem;
2095
2153
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
2096
2154
  const previewFileScript = `
2097
2155
  var data = event.data;
2098
2156
  var file_name = data.versions ? data.name : "${field.label}";
2099
- var file_id = data._id;
2100
- SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
2157
+ var file_id = data.versions && data.versions[0] && data.versions[0]._id;
2158
+ window.previewFile && window.previewFile({file_name, file_id});
2101
2159
  `;
2102
2160
  columnItem = {
2103
2161
  "type": "button",
@@ -2126,7 +2184,7 @@ async function getTableColumns(fields, options){
2126
2184
  "actionType": "custom",
2127
2185
  "script": previewFileScript,
2128
2186
  // "expression": "!!window?.nw?.require" //PC客户端预览附件
2129
- "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2187
+ "expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2130
2188
  }
2131
2189
  ]
2132
2190
  }
@@ -2141,7 +2199,7 @@ async function getTableColumns(fields, options){
2141
2199
  toggled: field.toggled,
2142
2200
  static: true,
2143
2201
  className,
2144
- }, field.amis, {name: field.name});
2202
+ }, fieldAmis, {name: field.name});
2145
2203
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
2146
2204
  columnItem = Object.assign({}, {
2147
2205
  type: "switch",
@@ -2152,7 +2210,7 @@ async function getTableColumns(fields, options){
2152
2210
  static: true,
2153
2211
  className,
2154
2212
  ...getAmisFileReadonlySchema(field)
2155
- }, field.amis, {name: field.name});
2213
+ }, fieldAmis, {name: field.name});
2156
2214
  }
2157
2215
  else if(field.type === 'select'){
2158
2216
  const map = getSelectMap(field.options);
@@ -2167,7 +2225,7 @@ async function getTableColumns(fields, options){
2167
2225
  className,
2168
2226
  inputClassName: "inline",
2169
2227
  static: true,
2170
- }, field.amis, {name: field.name});
2228
+ }, fieldAmis, {name: field.name});
2171
2229
  }
2172
2230
  else {
2173
2231
  const tpl = await getFieldTpl(field, options);
@@ -2186,23 +2244,14 @@ async function getTableColumns(fields, options){
2186
2244
  if(field.type === 'textarea'){
2187
2245
  className += 'min-w-56';
2188
2246
  }
2189
- if(field.type === 'date'){
2190
- className += 'date-min-w';
2191
- }
2192
- if(field.type === 'datetime'){
2193
- className += 'datetime-min-w';
2194
- }
2247
+ // if(field.type === 'date'){
2248
+ // className += 'date-min-w';
2249
+ // }
2250
+ // if(field.type === 'datetime'){
2251
+ // className += 'datetime-min-w';
2252
+ // }
2195
2253
 
2196
2254
  //field上的amis属性里的clssname需要单独判断类型合并
2197
- if (typeof field.amis?.className == "object") {
2198
- className = {
2199
- [className]: "true",
2200
- ...field.amis.className
2201
- };
2202
- } else if (typeof field.amis?.className == "string") {
2203
- className = `${className} ${field.amis.className} `;
2204
- }
2205
- delete field.amis?.className;
2206
2255
 
2207
2256
  if(!field.hidden && !field.extra){
2208
2257
  columnItem = Object.assign({}, {
@@ -2219,7 +2268,7 @@ async function getTableColumns(fields, options){
2219
2268
  static: true,
2220
2269
  options: field.type === 'html' ? {html: true} : null
2221
2270
  // toggled: true
2222
- }, field.amis, {name: field.name});
2271
+ }, fieldAmis, {name: field.name});
2223
2272
 
2224
2273
  if(field.type === 'color'){
2225
2274
  columnItem.type = 'color';
@@ -2286,7 +2335,7 @@ function getMobileLines(tpls){
2286
2335
  }
2287
2336
  if(isLeft){
2288
2337
  // 左侧半行
2289
- lineChildrenClassName = "steedos-listview-item-left truncate";
2338
+ lineChildrenClassName = "steedos-listview-item-left truncate h-5";
2290
2339
  if(item.field.is_wide){
2291
2340
  // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
2292
2341
  lineChildrenClassName = "steedos-listview-item-wide";
@@ -2298,7 +2347,7 @@ function getMobileLines(tpls){
2298
2347
  }
2299
2348
  else {
2300
2349
  // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
2301
- lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
2350
+ lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
2302
2351
  }
2303
2352
  //支持字段amis属性配置classname,识别classname的类型,与原样式合并
2304
2353
  var className;
@@ -2409,7 +2458,15 @@ async function getMobileTableColumns(fields, options){
2409
2458
  "actions": [
2410
2459
  {
2411
2460
  "script": `
2412
- let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
2461
+ let cms_url = '';
2462
+ let value = event.data.versions[0];
2463
+ if(value){
2464
+ if(value.url){
2465
+ cms_url = value.url;
2466
+ }else{
2467
+ cms_url = "/api/files/files/"+value+"?download=true"
2468
+ }
2469
+ }
2413
2470
  Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
2414
2471
  `,
2415
2472
  "actionType": "custom"
@@ -2525,7 +2582,8 @@ async function getTableOperation(ctx){
2525
2582
  label: "&nbsp;",
2526
2583
  fixed: 'right',
2527
2584
  labelClassName: 'text-center',
2528
- className: 'text-center steedos-listview-operation w-10',
2585
+ //TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
2586
+ className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
2529
2587
  buttons: [
2530
2588
  {
2531
2589
  "type": "steedos-dropdown-button",
@@ -2621,7 +2679,7 @@ async function getTableSchema$1(fields, options){
2621
2679
  }
2622
2680
  return {
2623
2681
  mode: "cards",
2624
- perPageAvailable: [5, 10, 20, 50, 100, 500],
2682
+ perPageAvailable: [20, 50, 100, 500],
2625
2683
  name: "thelist",
2626
2684
  headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
2627
2685
  className: "",
@@ -2654,7 +2712,7 @@ async function getTableSchema$1(fields, options){
2654
2712
 
2655
2713
  return {
2656
2714
  mode: "table",
2657
- perPageAvailable: [5, 10, 20, 50, 100, 500],
2715
+ perPageAvailable: [20, 50, 100, 500],
2658
2716
  name: "thelist",
2659
2717
  headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
2660
2718
  className: "",
@@ -2909,6 +2967,21 @@ async function getTableApi(mainObject, fields, options){
2909
2967
  return api;
2910
2968
  `;
2911
2969
  api.adaptor = `
2970
+ let fields = ${JSON.stringify(___namespace.map(fields, 'name'))};
2971
+ // 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
2972
+ (payload.data.rows || []).forEach((itemRow) => {
2973
+ (fields || []).forEach((itemField) => {
2974
+ if(itemField && itemField.indexOf(".") > -1){
2975
+ return;
2976
+ }
2977
+ if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
2978
+ // 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
2979
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
2980
+ itemRow[itemField] = "";
2981
+ }
2982
+ });
2983
+ });
2984
+
2912
2985
  if(api.body.listName == "recent"){
2913
2986
  payload.data.rows = _.sortBy(payload.data.rows, function(item){
2914
2987
  return _.indexOf(api.body._ids, item._id)
@@ -2933,7 +3006,13 @@ async function getTableApi(mainObject, fields, options){
2933
3006
  value = [value]
2934
3007
  };
2935
3008
  if(field.type === 'file'){
2936
- item[key] = value
3009
+ // item[key] = value
3010
+ // PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
3011
+ let itemKeyValue = item[key];
3012
+ item[key] = value.map(function(item, index){
3013
+ item._id = itemKeyValue[index];
3014
+ return item;
3015
+ });
2937
3016
  }else{
2938
3017
  item[key] = _.map(value, (item)=>{
2939
3018
  if(field.type === 'image'){
@@ -2975,15 +3054,8 @@ async function getTableApi(mainObject, fields, options){
2975
3054
  }
2976
3055
  });
2977
3056
  };
2978
- let isTreeOptionsComputed = false;
2979
- if(records.length === 1 && records[0].children){
2980
- isTreeOptionsComputed = true;
2981
- }
2982
- if(!isTreeOptionsComputed){
2983
- // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2984
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2985
- assignIndexToTreeRecords(payload.data.rows, '');
2986
- }
3057
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
3058
+ assignIndexToTreeRecords(payload.data.rows, '');
2987
3059
  }
2988
3060
 
2989
3061
 
@@ -3040,12 +3112,15 @@ async function getTableApi(mainObject, fields, options){
3040
3112
  }
3041
3113
  // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
3042
3114
  };
3043
- const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3044
- const firstListviewComponent = listviewComponent && listviewComponent[0];
3045
- if(firstListviewComponent){
3046
- setTimeout(()=>{
3047
- firstListviewComponent.scrollIntoView();
3048
- }, 600);
3115
+ let formFactor = "${options.formFactor}";
3116
+ if(formFactor !== "SMALL"){
3117
+ const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3118
+ const firstListviewComponent = listviewComponent && listviewComponent[0];
3119
+ if(firstListviewComponent){
3120
+ setTimeout(()=>{
3121
+ firstListviewComponent.scrollIntoView();
3122
+ }, 600);
3123
+ }
3049
3124
  }
3050
3125
  ${options.adaptor || ''}
3051
3126
  return payload;
@@ -3158,12 +3233,21 @@ function getReadonlyFormAdaptor(object, fields, options){
3158
3233
  }
3159
3234
  payload.data = data;
3160
3235
  payload.data.__objectName = "${object.name}";
3161
- payload.data.__record = record;
3236
+ payload.data.record = record;
3237
+
3238
+ payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
3239
+ payload.data._master = {
3240
+ record: record,
3241
+ objectName: "${object.name}",
3242
+ recordId: record._id
3243
+ }
3162
3244
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3163
3245
  }
3164
3246
  if(payload.errors){
3165
3247
  payload.status = 2;
3166
3248
  payload.msg = payload.errors[0].message;
3249
+ }else{
3250
+ payload.data.recordLoaded = true;
3167
3251
  }
3168
3252
  ${options && options.initApiAdaptor || ''}
3169
3253
  return payload;
@@ -3306,7 +3390,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
3306
3390
  cache: API_CACHE,
3307
3391
  requestAdaptor: `
3308
3392
  // 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
3309
- var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
3393
+ var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
3310
3394
  if(!recordId){
3311
3395
  // 新建则不请求任何数据
3312
3396
  data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
@@ -3384,10 +3468,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
3384
3468
  ...initialValues
3385
3469
  }
3386
3470
  ${options.initApiAdaptor || ''}
3471
+ // console.log('getEditFormInitApi======>', payload);
3387
3472
  return payload;
3388
3473
  `,
3389
3474
  responseData: {
3390
- initialValues: "$$",
3475
+ "&": "$$",
3391
3476
  editFormInited: true
3392
3477
  },
3393
3478
  data: data,
@@ -3426,6 +3511,18 @@ function getBatchDelete(objectName){
3426
3511
  return {
3427
3512
  method: 'post',
3428
3513
  url: getApi$2(),
3514
+ adaptor: `
3515
+ if(payload.errors){
3516
+ payload.data.deleteErrorMessage = [];
3517
+ payload.errors.forEach(function(error){
3518
+ let errorRecord = error.path.map(function (item) {
3519
+ return item.split('delete__')[1].to_float() + 1;
3520
+ }).toString();
3521
+ payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
3522
+ })
3523
+ }
3524
+ return payload;
3525
+ `,
3429
3526
  requestAdaptor: `
3430
3527
  var ids = api.data.ids.split(",");
3431
3528
  var deleteArray = [];
@@ -4220,7 +4317,7 @@ async function getListBody(fields, options){
4220
4317
 
4221
4318
  function getDefaultParams(options){
4222
4319
  return {
4223
- perPage: options.top || options.perPage || 10
4320
+ perPage: options.top || options.perPage || 20
4224
4321
  }
4225
4322
  }
4226
4323
 
@@ -4423,7 +4520,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4423
4520
  "objectApiName": "\${objectName}",
4424
4521
  "recordId": "",
4425
4522
  "mode": "edit",
4426
- "layout": "normal"
4427
4523
  };
4428
4524
 
4429
4525
  if (payload && payload.schema) {
@@ -4855,9 +4951,16 @@ const getSchema$2 = (uiSchema) => {
4855
4951
  "form": {
4856
4952
  debug: false,
4857
4953
  resetAfterSubmit: false,
4954
+ data: {
4955
+ editFormInited: true,
4956
+ },
4858
4957
  initApi: {
4958
+ method: 'GET',
4859
4959
  url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
4860
4960
  sendOn: 'this.recordId',
4961
+ data: null,
4962
+ requestAdaptor: "return api;",
4963
+ adaptor: "return payload;",
4861
4964
  responseData: {
4862
4965
  importState: "${state}"
4863
4966
  }
@@ -5128,7 +5231,7 @@ const StandardButtons = {
5128
5231
  }
5129
5232
  };
5130
5233
 
5131
- const getGlobalData$1 = () => {
5234
+ const getGlobalData = () => {
5132
5235
  return {
5133
5236
  now: new Date(),
5134
5237
  };
@@ -5187,7 +5290,7 @@ const getButtonVisible = (button, ctx) => {
5187
5290
  button._visible,
5188
5291
  props.record,
5189
5292
  "#",
5190
- getGlobalData$1(),
5293
+ getGlobalData(),
5191
5294
  props.userSession
5192
5295
  );
5193
5296
  };
@@ -5729,7 +5832,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
5729
5832
  const formSchema = {
5730
5833
  "type": "service",
5731
5834
  "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
5732
- "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",
5835
+ "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",
5733
5836
  "style":{
5734
5837
  "max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
5735
5838
  },
@@ -6316,7 +6419,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6316
6419
  "className": "slds-filters"
6317
6420
  },
6318
6421
  "size": "xs",
6319
- "className": `border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
6422
+ "className": `border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
6320
6423
  "visibleOn": "this.showFieldsFilter",
6321
6424
  },
6322
6425
  "className": "bg-white"
@@ -6504,7 +6607,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6504
6607
  "icon": "fa fa-refresh",
6505
6608
  "actionType": "reload",
6506
6609
  "target": amisListViewId,
6507
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
6610
+ "className": "bg-white p-2 rounded text-gray-500"
6508
6611
  },
6509
6612
  fieldsFilterButtonSchema,
6510
6613
  // {
@@ -6512,7 +6615,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6512
6615
  // "label": "",
6513
6616
  // "icon": "fa fa-filter",
6514
6617
  // "actionType": "custom",
6515
- // "className": "bg-transparent p-2 rounded border-gray-300 text-gray-500",
6618
+ // "className": "bg-transparent p-2 rounded text-gray-500",
6516
6619
  // "id": "u:c20cb87d96c9",
6517
6620
  // "onEvent": {
6518
6621
  // "click": {
@@ -6560,11 +6663,53 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6560
6663
  let headerSchema = [{
6561
6664
  "type": "wrapper",
6562
6665
  "body": body,
6563
- "className": `bg-gray-100 sm:rounded-tl sm:rounded-tr p-4 -mb-4`
6666
+ "className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
6564
6667
  }];
6565
6668
  return headerSchema;
6566
6669
  }
6567
6670
 
6671
+ function getBackButtonSchema(){
6672
+ return {
6673
+ "type": "service",
6674
+ "onEvent": {
6675
+ "@history_paths.changed": {
6676
+ "actions": [
6677
+ {
6678
+ "actionType": "reload",
6679
+ // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6680
+ "data": {
6681
+ }
6682
+ }
6683
+ ]
6684
+ }
6685
+ },
6686
+ "body":[{
6687
+ "type": "button",
6688
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6689
+ "className":"flex mr-4",
6690
+ "onEvent": {
6691
+ "click": {
6692
+ "actions": [
6693
+ {
6694
+ "actionType": "custom",
6695
+ "script": "window.goBack()"
6696
+ }
6697
+ ]
6698
+ }
6699
+ },
6700
+ "body": [
6701
+ {
6702
+ "type": "steedos-icon",
6703
+ "category": "utility",
6704
+ "name": "back",
6705
+ "colorVariant": "default",
6706
+ "className": "slds-button_icon slds-global-header__icon w-4"
6707
+ }
6708
+ ]
6709
+ }]
6710
+ }
6711
+ }
6712
+
6568
6713
  /**
6569
6714
  * 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
6570
6715
  * @param {*} objectSchema 对象UISchema
@@ -6573,11 +6718,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6573
6718
  * @returns amisSchema
6574
6719
  */
6575
6720
  async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6721
+ // console.log(`getObjectRecordDetailHeader====>`, options)
6576
6722
  const { showRecordTitle = true } = options || {};
6577
6723
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
6578
6724
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
6579
6725
 
6580
- let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6726
+ let amisButtonsSchema = [];
6727
+ if(options.showButtons != false){
6728
+ amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6729
+ }
6730
+
6731
+ let backButtonsSchema = null;
6732
+
6733
+ if(options.showBackButton != false){
6734
+ backButtonsSchema = getBackButtonSchema();
6735
+ }
6581
6736
 
6582
6737
  // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
6583
6738
 
@@ -6592,45 +6747,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6592
6747
  "type": "grid",
6593
6748
  "columns": [
6594
6749
  {
6595
- "body": [{
6596
- "type": "service",
6597
- "onEvent": {
6598
- "@history_paths.changed": {
6599
- "actions": [
6600
- {
6601
- "actionType": "reload",
6602
- // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6603
- "data": {
6604
- }
6605
- }
6606
- ]
6607
- }
6608
- },
6609
- "body":[{
6610
- "type": "button",
6611
- "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6612
- "className":"flex mr-4",
6613
- "onEvent": {
6614
- "click": {
6615
- "actions": [
6616
- {
6617
- "actionType": "custom",
6618
- "script": "window.goBack()"
6619
- }
6620
- ]
6621
- }
6622
- },
6623
- "body": [
6624
- {
6625
- "type": "steedos-icon",
6626
- "category": "utility",
6627
- "name": "back",
6628
- "colorVariant": "default",
6629
- "className": "slds-button_icon slds-global-header__icon w-4"
6630
- }
6631
- ]
6632
- }]
6633
- },{
6750
+ "body": [
6751
+ backButtonsSchema
6752
+ ,{
6634
6753
  "type": "tpl",
6635
6754
  "className": "block",
6636
6755
  // "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'>`
@@ -6651,8 +6770,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6651
6770
  },
6652
6771
  {
6653
6772
  "type": "tpl",
6654
- "tpl": "${name}",
6655
- // "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
6773
+ "tpl": "${NAME_FIELD_VALUE}",
6656
6774
  "inline": false,
6657
6775
  "wrapperComponent": "",
6658
6776
  "className": "record-detail-header-name leading-5 text-xl font-bold"
@@ -6680,7 +6798,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6680
6798
  let body = [
6681
6799
  {
6682
6800
  "type": "wrapper",
6683
- "className": "p-0",
6801
+ "className": "p-4 border-b",
6684
6802
  "body": [
6685
6803
  {
6686
6804
  "type": "grid",
@@ -6695,7 +6813,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6695
6813
  if(showRecordTitle){
6696
6814
  body.push({
6697
6815
  "type": "wrapper",
6698
- "className": "p-0",
6816
+ "className": "p-4",
6699
6817
  "body": [
6700
6818
  {
6701
6819
  "type": "grid",
@@ -6707,11 +6825,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6707
6825
  });
6708
6826
  }
6709
6827
 
6828
+ let max = 10;
6829
+ if(options.formFactor === 'SMALL'){
6830
+ max = 4;
6831
+ }else {
6832
+
6833
+ let divWidth = window.innerWidth;
6834
+
6835
+ if(options.display === 'split'){
6836
+ divWidth = divWidth - 388;
6837
+ }
6838
+
6839
+ if(document.body.classList.contains('sidebar')){
6840
+ divWidth = divWidth - 210;
6841
+ }
6842
+
6843
+ // 根据屏幕宽度计算显示数量, 使高亮字段只占1行
6844
+ max = Math.trunc(divWidth / 200 );
6845
+ if(max > 10){
6846
+ max = 10;
6847
+ }
6848
+ }
6849
+
6850
+ // console.log('=======================max=========================', max)
6851
+
6852
+ if(objectSchema.compactLayouts){
6853
+ const details = [];
6854
+ _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
6855
+ const field = objectSchema.fields[fieldName];
6856
+ if(field){
6857
+ details.push({
6858
+ type: 'steedos-field',
6859
+ static: true,
6860
+ config: field,
6861
+ });
6862
+ }
6863
+ });
6864
+
6865
+ // 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
6866
+ // lg:grid-cols-1
6867
+ // lg:grid-cols-2
6868
+ // lg:grid-cols-3
6869
+ // lg:grid-cols-4
6870
+ // lg:grid-cols-5
6871
+ // lg:grid-cols-6
6872
+ // lg:grid-cols-7
6873
+ // lg:grid-cols-8
6874
+ // lg:grid-cols-9
6875
+ // lg:grid-cols-10
6876
+ // lg:grid-cols-11
6877
+ // lg:grid-cols-12
6878
+
6879
+ body.push({
6880
+ "type": "wrapper",
6881
+ "body": {
6882
+ "type": "form",
6883
+ // "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
6884
+ "className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
6885
+ "wrapWithPanel": false,
6886
+ "actions": [],
6887
+ "body": details,
6888
+ "hiddenOn": "${recordLoaded != true}"
6889
+ },
6890
+ "className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
6891
+ });
6892
+ }
6893
+
6710
6894
  return {
6711
6895
  type: 'service',
6712
6896
  id: `page_readonly_${name}_header`,
6713
6897
  name: `page`,
6714
- data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
6715
6898
  body: body,
6716
6899
  className: ''
6717
6900
  }
@@ -6783,7 +6966,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
6783
6966
  "className": "flex justify-between"
6784
6967
  }
6785
6968
  ],
6786
- "className": "p-3"
6969
+ "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
6787
6970
  };
6788
6971
  return recordRelatedListHeader;
6789
6972
  }
@@ -7741,7 +7924,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
7741
7924
  "icon": "fa fa-cog",
7742
7925
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7743
7926
  // "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
7744
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
7927
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
7745
7928
  "align": "right",
7746
7929
  "visibleOn": "${!isLookup}",
7747
7930
  "buttons": [
@@ -7768,14 +7951,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7768
7951
  {
7769
7952
  "type": "button",
7770
7953
  "label": i18next__default["default"].t('frontend_display_type_is_table'),
7771
- "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');",
7954
+ "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');",
7772
7955
  "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
7773
7956
  "rightIconClassName": "m-l-sm"
7774
7957
  },
7775
7958
  {
7776
7959
  "type": "button",
7777
7960
  "label": i18next__default["default"].t('frontend_display_type_is_split'),
7778
- "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7961
+ "onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7779
7962
  "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
7780
7963
  "rightIconClassName": "m-l-sm"
7781
7964
  }
@@ -7786,7 +7969,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7786
7969
  "icon": "fa fa-table-columns",
7787
7970
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7788
7971
  // "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
7789
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
7972
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
7790
7973
  "align": "right",
7791
7974
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
7792
7975
  "buttons": [
@@ -7918,7 +8101,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
7918
8101
  {
7919
8102
  "type": "search-box",
7920
8103
  "name": keywordsSearchBoxName,
7921
- "placeholder": "搜索此列表",
8104
+ "placeholder": "快捷搜索",
7922
8105
  "value": crudKeywords,
7923
8106
  // "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
7924
8107
  "clearAndSubmit": true,
@@ -7979,7 +8162,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
7979
8162
  // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7980
8163
  // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
7981
8164
  // "tooltipPlacement": "top",
7982
- // "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8165
+ // "className": "bg-white p-2 rounded text-gray-500",
7983
8166
  // "label": "",
7984
8167
  // "icon": "fa fa-sync",
7985
8168
  // "visibleOn": "${!showFieldsFilter}",
@@ -8003,7 +8186,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8003
8186
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8004
8187
  "tooltip":"",
8005
8188
  "tooltipPlacement": "top",
8006
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8189
+ "className": "bg-white p-2 rounded text-gray-500"
8007
8190
  };
8008
8191
  }
8009
8192
  else {
@@ -8014,7 +8197,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8014
8197
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8015
8198
  "tooltip":"",
8016
8199
  "tooltipPlacement": "top",
8017
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8200
+ "className": "bg-white p-2 rounded text-gray-500"
8018
8201
  };
8019
8202
  }
8020
8203
  let toolbarFilter;
@@ -8036,7 +8219,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8036
8219
  "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
8037
8220
  },
8038
8221
  "align": "right",
8039
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8222
+ "className": "bg-white p-2 rounded text-gray-500",
8040
8223
  "onEvent": {
8041
8224
  "click": {
8042
8225
  "actions": [
@@ -8122,7 +8305,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8122
8305
  // ]
8123
8306
  if(options.displayAs === 'split'){
8124
8307
  return [
8125
- "switch-per-page",
8308
+ {
8309
+ "type": "switch-per-page",
8310
+ "visibleOn": "${count >= 20}"
8311
+ },
8126
8312
  {
8127
8313
  "type": "pagination",
8128
8314
  "maxButtons": 5,
@@ -8144,7 +8330,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8144
8330
  else {
8145
8331
  if(options && options.isRelated){
8146
8332
  return [
8147
- "statistics",
8148
8333
  {
8149
8334
  "type": "pagination",
8150
8335
  "maxButtons": 10,
@@ -8157,7 +8342,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8157
8342
  const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
8158
8343
  const is_lookup = options.isLookup;
8159
8344
  const commonConfig = [
8160
- "statistics",
8161
8345
  {
8162
8346
  "type": "pagination",
8163
8347
  "maxButtons": 10,
@@ -8168,7 +8352,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8168
8352
  if (no_pagination && is_lookup) {
8169
8353
  return commonConfig;
8170
8354
  } else {
8171
- return ["switch-per-page", ...commonConfig];
8355
+ return [{
8356
+ "type": "switch-per-page",
8357
+ "visibleOn": "${count >= 20}"
8358
+ }, ...commonConfig];
8172
8359
  }
8173
8360
  }
8174
8361
  }
@@ -8192,7 +8379,6 @@ async function getObjectFilter(objectSchema, fields, options) {
8192
8379
  "timeOut": 1000
8193
8380
  }
8194
8381
  });
8195
- resizeWindow();
8196
8382
  const scope = event.context.scoped;
8197
8383
  // let filterFormValues = event.data;
8198
8384
  let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
@@ -8276,6 +8462,29 @@ function getBulkActions(objectSchema){
8276
8462
  "className": "hidden",
8277
8463
  "id": "batchDelete",
8278
8464
  "api": getBatchDelete(objectSchema.name),
8465
+ "feedback": {
8466
+ "title": "删除警告",
8467
+ "visibleOn": "${deleteErrorMessage}",
8468
+ "body": [
8469
+ {
8470
+ "type": "each",
8471
+ "name": "deleteErrorMessage",
8472
+ "items": {
8473
+ "type": "alert",
8474
+ "body": "${item}",
8475
+ "level": "danger",
8476
+ "className": "mb-3"
8477
+ }
8478
+ }
8479
+ ],
8480
+ "actions": [
8481
+ {
8482
+ "type": "button",
8483
+ "actionType": "close",
8484
+ "label": "关闭"
8485
+ }
8486
+ ]
8487
+ }
8279
8488
  }
8280
8489
  // {
8281
8490
  // "label": "批量修改",
@@ -8336,7 +8545,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8336
8545
  const bodyProps = {
8337
8546
  // toolbar: getToolbar(),
8338
8547
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
8339
- headerToolbarClassName: "px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",
8548
+ headerToolbarClassName: "px-4 py-2 border-b",
8340
8549
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
8341
8550
  ...options,
8342
8551
  disableStatistics: options.queryCount === false
@@ -8472,7 +8681,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8472
8681
  // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8473
8682
  // },
8474
8683
  bodyClassName: {
8475
- "bg-white": "true",
8684
+ "mb-0": true,
8476
8685
  "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8477
8686
  },
8478
8687
  crudClassName: crudClassName,
@@ -8483,16 +8692,11 @@ async function getObjectCRUD(objectSchema, fields, options){
8483
8692
  headers: {
8484
8693
  Authorization: "Bearer ${context.tenantId},${context.authToken}",
8485
8694
  },
8486
- requestAdaptor: quickSaveApiRequestAdaptor,
8487
- adaptor: `
8488
- if(payload.errors){
8489
- payload.status = 2;
8490
- payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8491
- }
8492
- return payload;
8493
- `
8695
+ requestAdaptor: quickSaveApiRequestAdaptor
8494
8696
  },
8495
- rowClassNameExpr: options.rowClassNameExpr
8697
+ // 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
8698
+ // 使用表达式给tr添加初始选中状态
8699
+ 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 %>"
8496
8700
  }, bodyProps);
8497
8701
 
8498
8702
  }
@@ -8505,9 +8709,23 @@ async function getObjectCRUD(objectSchema, fields, options){
8505
8709
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8506
8710
  }
8507
8711
 
8712
+ body.quickSaveApi.adaptor = `
8713
+ if(payload.errors){
8714
+ payload.status = 2;
8715
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8716
+ }
8717
+ var scope = SteedosUI.getRef(context.scopeId);
8718
+ var scopeParent = scope && scope.parent;
8719
+ var crudScoped = scopeParent.getComponentById('${body.id}');
8720
+ setTimeout(()=>{
8721
+ crudScoped && crudScoped.control.updateAutoFillHeight();
8722
+ }, 500);
8723
+ return payload;
8724
+ `;
8725
+
8508
8726
  if(body.columns && options.formFactor != 'SMALL'){
8509
8727
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8510
- body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: objectSchema.name + "_display_${_index}", className: "hidden"});
8728
+ body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
8511
8729
  }
8512
8730
 
8513
8731
  if (defaults) {
@@ -8565,11 +8783,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8565
8783
  }
8566
8784
  }
8567
8785
 
8568
- const getGlobalData = (mode)=>{
8569
- const user = getSteedosAuth();
8570
- return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
8571
- };
8572
-
8573
8786
  const getFormFields$1 = (objectSchema, formProps)=>{
8574
8787
  /**
8575
8788
  * fieldsExtend: 重写字段定义
@@ -8631,7 +8844,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
8631
8844
  }
8632
8845
 
8633
8846
  async function getObjectForm(objectSchema, ctx){
8634
- const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8847
+ const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8635
8848
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8636
8849
  const fields = ___default["default"].values(objectSchema.fields);
8637
8850
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -8647,9 +8860,7 @@ async function getObjectForm(objectSchema, ctx){
8647
8860
  id: `service_${formSchema.id}`,
8648
8861
  className: 'p-0',
8649
8862
  name: `page_edit_${recordId}`,
8650
- api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
8651
8863
  data:{
8652
- editFormInited: false,
8653
8864
  ...amisData
8654
8865
  },
8655
8866
  // data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
@@ -8658,8 +8869,9 @@ async function getObjectForm(objectSchema, ctx){
8658
8869
  body: [defaultsDeep({}, formSchema, {
8659
8870
  type: "form",
8660
8871
  mode: layout,
8872
+ initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
8661
8873
  data: {
8662
- "&": "${initialValues}"
8874
+ editFormInited: false,
8663
8875
  },
8664
8876
  labelAlign,
8665
8877
  persistData: false,
@@ -8673,11 +8885,15 @@ async function getObjectForm(objectSchema, ctx){
8673
8885
  submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
8674
8886
  api: await getSaveApi(objectSchema, recordId, fields, ctx),
8675
8887
  initFetch: recordId != 'new',
8676
- body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
8888
+ body: {
8889
+ type: 'wrapper',
8890
+ className: 'p-0 m-0',
8891
+ body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
8892
+ hiddenOn: "${editFormInited != true}",
8893
+ },
8677
8894
  panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
8678
8895
  bodyClassName: 'p-0',
8679
8896
  className: 'steedos-amis-form',
8680
- hiddenOn: "${editFormInited != true}",
8681
8897
  onEvent: {
8682
8898
  "submitSucc": {
8683
8899
  "weight": 0,
@@ -8722,7 +8938,7 @@ async function getObjectForm(objectSchema, ctx){
8722
8938
  }
8723
8939
 
8724
8940
  async function getObjectDetail(objectSchema, recordId, ctx){
8725
- const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign,
8941
+ const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
8726
8942
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8727
8943
  const fields = ___default["default"].values(objectSchema.fields);
8728
8944
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -8731,8 +8947,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8731
8947
  type: 'service',
8732
8948
  name: `page_readonly_${recordId}`,
8733
8949
  id: serviceId,
8734
- data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
8735
- api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8950
+ // api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8736
8951
  body: [
8737
8952
  {
8738
8953
  "type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
@@ -8758,60 +8973,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8758
8973
  ),
8759
8974
  className: 'steedos-amis-form bg-white',
8760
8975
  actions: [], // 不显示表单默认的提交按钮
8761
- onEvent: {
8762
- [`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
8763
- "actions": [
8764
- {
8765
- "actionType": "reload",
8766
- "componentId": serviceId,
8767
- "expression": "this.__deletedRecord != true"
8768
- },
8769
- {
8770
- // "args": {
8771
- // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
8772
- // "blank": false
8773
- // },
8774
- "actionType": "custom",
8775
- "script": "window.goBack()",
8776
- "expression": "this.__deletedRecord === true"
8777
- }
8778
- ]
8779
- }
8780
- }
8781
8976
  },
8782
8977
  }
8783
8978
  ],
8784
- onEvent: {
8785
- "fetchInited": {
8786
- "weight": 0,
8787
- "actions": [
8788
- {
8789
- actionType: 'broadcast',
8790
- eventName: "recordLoaded",
8791
- args: {
8792
- eventName: "recordLoaded"
8793
- },
8794
- data: {
8795
- objectName: "${event.data.__objectName}",
8796
- record: "${event.data.__record}"
8797
- },
8798
- expression: "${event.data.__response.error != true}"
8799
- },
8800
- {
8801
- "actionType": "setValue",
8802
- "args": {
8803
- value: {
8804
- "recordLoaded": true,
8805
- }
8806
- },
8807
- expression: "${event.data.__response.error != true}"
8808
- }
8809
- ]
8810
- }
8811
- }
8979
+ // onEvent: {
8980
+ // "fetchInited": {
8981
+ // "weight": 0,
8982
+ // "actions": [
8983
+ // {
8984
+ // actionType: 'broadcast',
8985
+ // eventName: "recordLoaded",
8986
+ // args: {
8987
+ // eventName: "recordLoaded"
8988
+ // },
8989
+ // data: {
8990
+ // objectName: "${event.data.__objectName}",
8991
+ // record: "${event.data.__record}"
8992
+ // },
8993
+ // expression: "${event.data.__response.error != true}"
8994
+ // },
8995
+ // {
8996
+ // "actionType": "setValue",
8997
+ // "args": {
8998
+ // value: {
8999
+ // "recordLoaded": true,
9000
+ // }
9001
+ // },
9002
+ // expression: "${event.data.__response.error != true}"
9003
+ // }
9004
+ // ]
9005
+ // }
9006
+ // }
8812
9007
  };
8813
9008
 
8814
9009
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
9010
+ // console.log('getObjectDetail=====>', amisSchema);
8815
9011
  return amisSchema;
8816
9012
  }
8817
9013
 
@@ -8891,8 +9087,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8891
9087
  /*
8892
9088
  * @Author: baozhoutao@steedos.com
8893
9089
  * @Date: 2022-07-05 15:55:39
8894
- * @LastEditors: liaodaxue
8895
- * @LastEditTime: 2023-11-14 15:55:32
9090
+ * @LastEditors: baozhoutao@steedos.com
9091
+ * @LastEditTime: 2024-01-24 10:18:17
8896
9092
  * @Description:
8897
9093
  */
8898
9094
 
@@ -8991,7 +9187,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
8991
9187
  const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
8992
9188
  mainRelated[arr[0]] = foreign_key_value;
8993
9189
  }
8994
- }else {
9190
+ }
9191
+ // 防止related_lists中没有相关子表,但是details中有相关子表的情况
9192
+ if(!mainRelated[relatedObjectName]){
8995
9193
  const details = _$1.union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
8996
9194
  for (const detail of details) {
8997
9195
  const arr = detail.split(".");
@@ -9067,7 +9265,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9067
9265
  setDataToComponentId: componentId,
9068
9266
  // tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
9069
9267
  appId: appId,
9070
- crudClassName: 'border-t border-gray-300 hidden',
9268
+ crudClassName: 'steedos-record-related-crud border-l border-r hidden',
9071
9269
  refField,
9072
9270
  ...ctx
9073
9271
  };
@@ -9080,7 +9278,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9080
9278
  amisSchema: {
9081
9279
  type: "service",
9082
9280
  id: componentId,
9083
- className: `steedos-record-related-list ${componentId} rounded border border-gray-300 bg-gray-100 mb-4 ${className}`,
9281
+ className: `steedos-record-related-list mb-4 last:mb-0 ${componentId} ${className}`,
9084
9282
  data: {
9085
9283
  relatedKey: relatedKey,
9086
9284
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
@@ -9272,11 +9470,44 @@ async function getRelatedListSchema(
9272
9470
  };
9273
9471
  }
9274
9472
 
9473
+ async function getObjectRelatedListsMiniSchema(objectApiName){
9474
+ const relatedLists = await getObjectRelatedList(objectApiName);
9475
+
9476
+ const relatedListsMiniSchema = [];
9477
+
9478
+ for (const relatedList of relatedLists) {
9479
+ relatedListsMiniSchema.push(
9480
+ {
9481
+ type: 'steedos-record-detail-list-mini',
9482
+ objectApiName: objectApiName,
9483
+ // recordId: recordId,
9484
+ formFactor: formFactor,
9485
+ relatedObjectApiName: relatedList.object_name,
9486
+ foreign_key: relatedList.foreign_key,
9487
+ relatedKey: relatedList.foreign_key,
9488
+ columns: relatedList.columns,
9489
+ sort: relatedList.sort,
9490
+ filters: relatedList.filters,
9491
+ visible_on: relatedList.visible_on,
9492
+ perPage: relatedList.page_size || perPage,
9493
+ hiddenEmptyTable: true,
9494
+ relatedLabel: relatedList.label
9495
+ }
9496
+ );
9497
+ }
9498
+
9499
+ return {
9500
+ type: 'wrapper',
9501
+ className: "steedos-record-detail-related-lists-mini",
9502
+ body: relatedListsMiniSchema
9503
+ }
9504
+ }
9505
+
9275
9506
  /*
9276
9507
  * @Author: baozhoutao@steedos.com
9277
9508
  * @Date: 2022-07-05 15:55:39
9278
- * @LastEditors: liaodaxue
9279
- * @LastEditTime: 2023-10-20 11:38:25
9509
+ * @LastEditors: baozhoutao@steedos.com
9510
+ * @LastEditTime: 2024-01-16 11:14:34
9280
9511
  * @Description:
9281
9512
  */
9282
9513
 
@@ -9448,7 +9679,7 @@ async function getField(objectName, fieldName) {
9448
9679
  async function getFormSchema(objectName, ctx) {
9449
9680
  const uiSchema = await getUISchema(objectName);
9450
9681
  const amisSchema = await getObjectForm(uiSchema, ctx);
9451
- console.log(`getFormSchema====>`, amisSchema);
9682
+ // console.log(`getFormSchema====>`, amisSchema)
9452
9683
  return {
9453
9684
  uiSchema,
9454
9685
  amisSchema,
@@ -9774,120 +10005,174 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9774
10005
  "label": "对象表单",
9775
10006
  "objectApiName": "${objectName}",
9776
10007
  "recordId": "${recordId}",
9777
- "id": "u:d4a495811d57",
9778
10008
  appId: appId
9779
10009
  }
9780
10010
  ],
9781
- "id": "u:5d4e7e3f6ecc"
9782
10011
  };
9783
10012
  const related = {
9784
10013
  "title": i18next__default["default"].t('frontend_record_detail_tab_related'),
9785
- "className": "px-0 pt-4",
10014
+ "className": "px-0 py-4",
9786
10015
  "body": [
9787
10016
  {
9788
10017
  "type": "steedos-object-related-lists",
9789
10018
  "label": "相关列表",
9790
10019
  "objectApiName": "${objectName}",
9791
10020
  "recordId": "${recordId}",
9792
- "id": "u:3b85b7b7a7f6",
9793
10021
  appId: appId
9794
10022
  }
9795
10023
  ],
9796
- "id": "u:1a0326aeec2b"
9797
10024
  };
9798
10025
  const content = {
9799
10026
  "type": "tabs",
9800
- "className": "sm:mt-3 bg-white sm:rounded sm:border border-gray-300 p-4",
10027
+ "className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
10028
+ "contentClassName": "bg-none",
9801
10029
  "tabs": [
9802
10030
  detailed
9803
10031
  ],
9804
- "id": "u:a649e4094a12"
9805
10032
  };
9806
10033
  if(relatedLists.length){
9807
10034
  content.tabs.push(related);
9808
10035
  }
10036
+ // content.tabs = reverse(content.tabs)
9809
10037
  return {
9810
10038
  uiSchema,
9811
10039
  amisSchema: {
9812
- "type": "service",
10040
+ "type": "steedos-record-service",
9813
10041
  "body": [
9814
10042
  {
9815
10043
  "type": "steedos-record-detail-header",
9816
10044
  "label": "标题面板",
9817
10045
  "objectApiName": "${objectName}",
9818
10046
  "recordId": "${recordId}",
9819
- "id": "u:48d2c28eb755"
10047
+ "id": "u:48d2c28eb755",
10048
+ "showButtons": props.showButtons,
10049
+ "showBackButton": props.showBackButton,
9820
10050
  },
9821
10051
  content
9822
10052
  ],
9823
- data: {
9824
- "_master.objectName": "${objectName}",
9825
- "_master.recordId": "${recordId}"
9826
- },
9827
- onEvent: {
9828
- "recordLoaded": {
9829
- "actions": [
9830
- {
9831
- "actionType": "reload",
9832
- "data": {
9833
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9834
- "_master.record": `\${record}`,
9835
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9836
- "_master.objectName": "${objectName}",
9837
- "_master.recordId": "${recordId}"
9838
- }
9839
- }
9840
- ]
9841
- },
9842
- ...props.onEvent
9843
- },
10053
+ "objectApiName": "${objectName}",
10054
+ "recordId": "${recordId}",
10055
+ onEvent: props.onEvent,
9844
10056
  }
9845
10057
  }
9846
10058
  }
9847
10059
 
9848
- async function getRecordServiceSchema(objectName, appId, props = {}) {
10060
+ async function getRecordServiceSchema(objectName, appId, props = {}, body) {
9849
10061
  const uiSchema = await getUISchema(objectName);
10062
+ const fields = ___default["default"].values(uiSchema.fields);
10063
+ const serviceId = `u:steedos-record-service-${objectName}`;
9850
10064
  return {
9851
10065
  uiSchema,
9852
10066
  amisSchema: {
9853
- "type": "service",
9854
- "body": [],
9855
- data: {
9856
- "_master.objectName": "${objectName}",
9857
- "_master.recordId": "${recordId}"
9858
- },
9859
- "style": {
9860
- "padding": "var(--Page-body-padding)",
9861
- ...props.style
9862
- },
10067
+ type: 'service',
10068
+ className: "p-0 m-0",
9863
10069
  onEvent: {
9864
- "recordLoaded": {
10070
+ [`@data.changed.${objectName}`]: {
9865
10071
  "actions": [
9866
10072
  {
9867
10073
  "actionType": "reload",
9868
- "data": {
9869
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9870
- "_master.record": `\${record}`,
9871
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9872
- "_master.objectName": "${objectName}",
9873
- "_master.recordId": "${recordId}"
9874
- }
10074
+ "componentId": serviceId,
10075
+ "expression": "this.__deletedRecord != true"
10076
+ },
10077
+ {
10078
+ "actionType": "custom",
10079
+ "script": "window.goBack()",
10080
+ "expression": "this.__deletedRecord === true"
9875
10081
  }
9876
10082
  ]
9877
10083
  },
9878
- ...props.onEvent
10084
+ },
10085
+ body: {
10086
+ "type": "service",
10087
+ id: serviceId,
10088
+ className: 'steedos-record-service p-0',
10089
+ api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
10090
+ body: {
10091
+ "type": "wrapper",
10092
+ "className": "p-0 m-0",
10093
+ "body": body || [],
10094
+ "hiddenOn": "${recordLoaded != true}"
10095
+ },
10096
+ data: {
10097
+ "_master.objectName": "${objectName}",
10098
+ "_master.recordId": "${recordId}",
10099
+ ...(props.data || {})
10100
+ },
10101
+ "style": {
10102
+ // "padding": "var(--Page-body-padding)",
10103
+ ...props.style
10104
+ },
10105
+ onEvent: {
10106
+ // 如果定义了fetchInited,则无法接收到广播事件@data.changed
10107
+ "fetchInited": {
10108
+ "weight": 0,
10109
+ "actions": [
10110
+ {
10111
+ actionType: 'broadcast',
10112
+ eventName: "recordLoaded",
10113
+ data: {
10114
+ objectName: "${event.data.__objectName}",
10115
+ record: "${event.data.record}"
10116
+ },
10117
+ expression: "${event.data.__response.error != true}"
10118
+ },
10119
+ ]
10120
+ },
10121
+ ...props.onEvent
10122
+ }
9879
10123
  }
9880
10124
  }
10125
+
10126
+
9881
10127
  }
9882
10128
  }
9883
10129
 
9884
- // 获取单个相关表
9885
- async function getObjectRelated(
9886
- {appName,
9887
- masterObjectName,
9888
- objectName,
9889
- relatedFieldName,
9890
- recordId,
10130
+ async function getRecordDetailMiniSchema(objectName, appId, props = {}){
10131
+ const uiSchema = await getUISchema(objectName);
10132
+ const fields = ___default["default"].values(uiSchema.fields);
10133
+
10134
+ props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
10135
+
10136
+ // TODO 处理相关表
10137
+ // getObjectRelatedListsMiniSchema
10138
+
10139
+ return {
10140
+ type: "form",
10141
+ wrapWithPanel: false,
10142
+ actions: [],
10143
+ initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
10144
+ body: {
10145
+ "type": "wrapper",
10146
+ "className": "p-0 m-0",
10147
+ "body": [
10148
+ {
10149
+ "type": "steedos-record-detail-header",
10150
+ "showButtons": false,
10151
+ "showBackButton": false,
10152
+ "objectApiName": "${objectName}",
10153
+ "recordId": "${recordId}",
10154
+ },
10155
+ // {
10156
+ // "type": "steedos-object-related-lists",
10157
+ // "label": "相关列表",
10158
+ // "objectApiName": "${objectName}",
10159
+ // "staticRecordId": "${recordId}",
10160
+ // formFactor: "SMALL",
10161
+ // appId: appId
10162
+ // }
10163
+ ],
10164
+ "hiddenOn": "${_finished != true}"
10165
+ }
10166
+ }
10167
+ }
10168
+
10169
+ // 获取单个相关表
10170
+ async function getObjectRelated(
10171
+ {appName,
10172
+ masterObjectName,
10173
+ objectName,
10174
+ relatedFieldName,
10175
+ recordId,
9891
10176
  formFactor}
9892
10177
  ) {
9893
10178
  let filter = null;
@@ -10440,17 +10725,13 @@ function getReferenceToSync(field) {
10440
10725
 
10441
10726
  function getLookupSapceUserTreeSchema(isMobile){
10442
10727
  let apiAdaptor = `
10443
- // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10444
10728
  const records = payload.data.options;
10445
- let isTreeOptionsComputed = false;
10446
- if(records.length === 1 && records[0].children){
10447
- isTreeOptionsComputed = true;
10448
- }
10449
- if(isTreeOptionsComputed){
10450
- return payload;
10451
- }
10452
10729
  const treeRecords = [];
10453
- const getChildren = (records, childrenIds) => {
10730
+ const getChildren = (currentRecord, records, childrenIds) => {
10731
+ if (currentRecord.children && typeof currentRecord.children[0] === "object") {
10732
+ // 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
10733
+ return currentRecord.children;
10734
+ }
10454
10735
  if (!childrenIds) {
10455
10736
  return;
10456
10737
  }
@@ -10459,7 +10740,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10459
10740
  });
10460
10741
  _.each(children, (item) => {
10461
10742
  if (item.children) {
10462
- item.children = getChildren(records, item.children)
10743
+ item.children = getChildren(item, records, item.children)
10463
10744
  }else{
10464
10745
  item.children = [];
10465
10746
  }
@@ -10485,7 +10766,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10485
10766
 
10486
10767
  _.each(records, (record) => {
10487
10768
  if (record.noParent == 1) {
10488
- treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10769
+ treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
10489
10770
  }
10490
10771
  });
10491
10772
  console.log(treeRecords)
@@ -10535,6 +10816,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10535
10816
  }
10536
10817
  },
10537
10818
  "label": "",
10819
+ "mode": "normal",
10538
10820
  "name": "organizations",
10539
10821
  "multiple": false,
10540
10822
  "joinValues": false,
@@ -10677,6 +10959,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
10677
10959
  }
10678
10960
  });
10679
10961
 
10962
+ let listviewFilter = getListViewFilter(listView);
10963
+ let listviewFiltersFunction = listView && listView._filters;
10964
+
10680
10965
  let sort = "";
10681
10966
  if(listView){
10682
10967
  sort = getListViewSort(listView);
@@ -10723,7 +11008,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10723
11008
  Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
10724
11009
  }
10725
11010
  const selfData = JSON.parse(JSON.stringify(api.data.$self));
10726
- var filters = [];
11011
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
10727
11012
  var pageSize = api.data.pageSize || 10;
10728
11013
  var pageNo = api.data.pageNo || 1;
10729
11014
  var skip = (pageNo - 1) * pageSize;
@@ -10785,6 +11070,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
10785
11070
  }
10786
11071
 
10787
11072
  const inFilterForm = ${ctx.inFilterForm};
11073
+
11074
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11075
+
11076
+ if(listviewFiltersFunction && !inFilterForm){
11077
+ const _filters0 = listviewFiltersFunction(filters, api.data.$self.__super);
11078
+ if(_filters0 && _filters0.length){
11079
+ filters.push(_filters0);
11080
+ }
11081
+ }
11082
+
10788
11083
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
10789
11084
 
10790
11085
  if(filtersFunction && !inFilterForm){
@@ -11097,6 +11392,9 @@ async function lookupToAmisSelect(field, readonly, ctx){
11097
11392
  const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
11098
11393
  let listView = getLookupListView(refObjectConfig);
11099
11394
 
11395
+ let listviewFilter = getListViewFilter(listView);
11396
+ let listviewFiltersFunction = listView && listView._filters;
11397
+
11100
11398
  let sort = "";
11101
11399
  if(listView){
11102
11400
  sort = getListViewSort(listView);
@@ -11126,7 +11424,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11126
11424
  apiInfo.data['rfield'] = `\${object_name}`;
11127
11425
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
11128
11426
  apiInfo.requestAdaptor = `
11129
- var filters = [];
11427
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
11130
11428
  var top = 200;
11131
11429
  if(api.data.$term){
11132
11430
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
@@ -11149,6 +11447,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
11149
11447
  }
11150
11448
 
11151
11449
  const inFilterForm = ${ctx.inFilterForm};
11450
+
11451
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11452
+
11453
+ if(listviewFiltersFunction && !inFilterForm){
11454
+ const _filters0 = listviewFiltersFunction(filters, api.data.$);
11455
+ if(_filters0 && _filters0.length){
11456
+ filters.push(_filters0);
11457
+ }
11458
+ }
11459
+
11152
11460
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
11153
11461
 
11154
11462
  if(filtersFunction && !inFilterForm){
@@ -11271,9 +11579,17 @@ async function lookupToAmis(field, readonly, ctx){
11271
11579
  }
11272
11580
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11273
11581
  if(readonly){
11274
- return {
11275
- type: getAmisStaticFieldType('picker', readonly),
11276
- tpl: getRelatedFieldTpl(field, ctx)
11582
+ if(field.reference_to){
11583
+ return {
11584
+ type: 'steedos-field',
11585
+ config: field,
11586
+ static: true
11587
+ }
11588
+ }else {
11589
+ return {
11590
+ type: getAmisStaticFieldType('picker', readonly),
11591
+ tpl: getRelatedFieldTpl(field, ctx)
11592
+ }
11277
11593
  }
11278
11594
  }
11279
11595
  if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
@@ -11925,13 +12241,31 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11925
12241
  };
11926
12242
  break;
11927
12243
  case 'input-datetime-range':
12244
+ // convertData = {
12245
+ // type: "input-datetime-range",
12246
+ // inputFormat: 'YYYY-MM-DD HH:mm',
12247
+ // format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
12248
+ // tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
12249
+ // utc: true,
12250
+ // joinValues: false
12251
+ // }
12252
+ // 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
11928
12253
  convertData = {
11929
- type: "input-datetime-range",
11930
- inputFormat: 'YYYY-MM-DD HH:mm',
12254
+ type: "input-date-range",
12255
+ inputFormat: "YYYY-MM-DD HH:mm",
11931
12256
  format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
11932
12257
  tpl: readonly ? getDateTimeTpl(field) : null,
11933
12258
  utc: true,
11934
- joinValues: false
12259
+ joinValues: false,
12260
+ "shortcuts": [
12261
+ "thismonth",
12262
+ "2monthsago",
12263
+ "3monthslater",
12264
+ "prevquarter",
12265
+ "thisquarter",
12266
+ "thisyear",
12267
+ "lastYear"
12268
+ ]
11935
12269
  };
11936
12270
  break;
11937
12271
  case 'datetime':
@@ -11982,7 +12316,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11982
12316
  convertData = {
11983
12317
  type: getAmisStaticFieldType('datetime', readonly),
11984
12318
  inputFormat: 'YYYY-MM-DD HH:mm',
11985
- format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
12319
+ format: 'YYYY-MM-DDTHH:mm:00.000Z',
11986
12320
  tpl: readonly ? getDateTimeTpl(field) : null,
11987
12321
  utc: true,
11988
12322
  };
@@ -12113,6 +12447,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12113
12447
  convertData = {
12114
12448
  type: 'static-text'
12115
12449
  };
12450
+ }else if(field.autonumber_enable_modify){
12451
+ convertData = {
12452
+ "type": "input-group",
12453
+ "body": [
12454
+ {
12455
+ "type": "input-text",
12456
+ "name": field.name
12457
+ },
12458
+ {
12459
+ "type": "button",
12460
+ "label": "自动获取",
12461
+ "actionType": "ajax",
12462
+ "api": {
12463
+ "url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
12464
+ "method": "post",
12465
+ "headers": {
12466
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
12467
+ },
12468
+ "adaptor": `
12469
+ payload.data["${field.name}"] = payload.data && payload.data.autonumber;
12470
+ delete payload.data.autonumber;
12471
+ return payload;
12472
+ `
12473
+ },
12474
+ "messages": {
12475
+ "success": "获取成功"
12476
+ }
12477
+ }
12478
+ ]
12479
+ };
12116
12480
  }
12117
12481
  break;
12118
12482
  case 'url':
@@ -12267,11 +12631,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12267
12631
  if(field.subFields){
12268
12632
  convertData = {
12269
12633
  type: 'steedos-input-table',
12270
- showIndex: true,
12271
12634
  editable: !readonly,
12272
12635
  addable: !readonly,
12273
12636
  removable: !readonly,
12274
- draggable: !readonly,
12275
12637
  fields: [],
12276
12638
  amis:{
12277
12639
  columnsTogglable: false
@@ -12323,9 +12685,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12323
12685
  if(field.is_wide || convertData.type === 'group'){
12324
12686
  convertData.className = 'col-span-2 m-0';
12325
12687
  }else {
12326
- convertData.className = 'm-1';
12688
+ convertData.className = 'm-0';
12327
12689
  }
12328
- if(readonly){
12690
+ if(readonly && ctx.mode !== 'edit'){
12329
12691
  convertData.className = `${convertData.className} border-b`;
12330
12692
  }
12331
12693
  if(readonly){
@@ -12348,6 +12710,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12348
12710
  }
12349
12711
  }
12350
12712
 
12713
+ if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
12714
+ convertData.className = `${convertData.className || ''} hidden`;
12715
+ }
12716
+
12351
12717
  if(___namespace.isString(baseData.required)){
12352
12718
  if(baseData.required.startsWith("{{")){
12353
12719
  baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
@@ -12416,8 +12782,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
12416
12782
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12417
12783
  }
12418
12784
  if(_field.type === 'datetime'){
12419
- // 特意改为日期范围而不是日期时间范围,因为搜索时一般精确到日期就足够了,需要精确到日期时间范围需要在字段上配置amis属性来实现
12420
- _field.type = 'input-date-range';
12785
+ // 这里如果想把搜索范围展示效果改为日期范围,不可以直接改为input-date-range,因为它们规则不一样,包括时区规则和小时分秒的存值规则都不一样
12786
+ // 所以想改为展示日期范围效果,只能改input-datetime-range类型本身的属性来实现
12787
+ _field.type = 'input-datetime-range';
12421
12788
  _field.is_wide = true;
12422
12789
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12423
12790
  }
@@ -12603,6 +12970,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
12603
12970
  }
12604
12971
  }
12605
12972
 
12973
+ fieldSetBody.forEach((field)=>{
12974
+ //判断label是否存在,不存在时将label的空占位元素隐藏
12975
+ if(!field.label){
12976
+ field.labelClassName = "none";
12977
+ }
12978
+ });
12979
+
12606
12980
  // fieldSet 已支持显隐控制
12607
12981
  const sectionFieldsVisibleOn = ___namespace.map(___namespace.compact(___namespace.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
12608
12982
  let visible = visibleOn;
@@ -12725,19 +13099,200 @@ async function getFormBody(permissionFields, formFields, ctx){
12725
13099
  return await getSections(permissionFields, formFields, ctx);
12726
13100
  }
12727
13101
 
13102
+ /*
13103
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
13104
+ * @Date: 2024-01-18 15:12:41
13105
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13106
+ * @LastEditTime: 2024-01-18 15:12:49
13107
+ */
13108
+ /**
13109
+ * 生成符合标准uuid格式的36位满足唯一性的随机串
13110
+ * @returns uuid
13111
+ */
13112
+ function uuidv4() {
13113
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
13114
+ (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
13115
+ );
13116
+ }
13117
+
12728
13118
  /*
12729
13119
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12730
13120
  * @Date: 2023-11-15 09:50:22
12731
- * @LastEditors: liaodaxue
12732
- * @LastEditTime: 2024-01-09 18:12:28
13121
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13122
+ * @LastEditTime: 2024-01-26 17:47:16
13123
+ */
13124
+
13125
+ /**
13126
+ * 子表组件字段值中每行数据补上字段值为空的的字段值,把值统一设置为空字符串,是为了解决amis amis 3.6/6.0 input-table组件bug:行中字段值为空时会显示为父作用域中的同名变量值,见:https://github.com/baidu/amis/issues/9520
13127
+ * amis #9520修正后此函数及相关代码可以移除
13128
+ * @param {*} value 子表组件字段值,数组
13129
+ * @param {*} fields 子表组件fields属性,数组
13130
+ * @returns 转换后的子表组件字段值
13131
+ */
13132
+ function getTableValueWithEmptyValue(value, fields) {
13133
+ return (value || []).map((itemValue) => {
13134
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里字段值会被改了
13135
+ const newItemValue = _$1.clone(itemValue);
13136
+ (fields || []).forEach((itemField) => {
13137
+ if(itemField.name && (newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13138
+ // 这里newItemValue中不存在 itemField.name 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
13139
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
13140
+ newItemValue[itemField.name] = "";
13141
+ }
13142
+ if (newItemValue.children) {
13143
+ newItemValue.children = getTableValueWithEmptyValue(newItemValue.children, fields);
13144
+ }
13145
+ });
13146
+ return newItemValue;
13147
+ });
13148
+ }
13149
+
13150
+ /**
13151
+ * 把子表组件字段值中每行数据中经过上面getTableValueWithEmptyValue函数空字段值移除
13152
+ * amis #9520修正后此函数及相关代码可以移除
13153
+ * @param {*} value 子表组件字段值,数组
13154
+ * @param {*} fields 子表组件fields属性,数组
13155
+ * @returns 转换后的子表组件字段值
13156
+ */
13157
+ function getTableValueWithoutEmptyValue(value, fields) {
13158
+ return (value || []).map((itemValue) => {
13159
+ const newItemValue = _$1.clone(itemValue);
13160
+ (fields || []).forEach((itemField) => {
13161
+ if(itemField.name && (newItemValue[itemField.name] === "" || newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13162
+ // 这里额外把null和undefined值也删除掉纯粹是没必要输出保存它们
13163
+ delete newItemValue[itemField.name];
13164
+ }
13165
+ if (newItemValue.children) {
13166
+ newItemValue.children = getTableValueWithoutEmptyValue(newItemValue.children, fields);
13167
+ }
13168
+ });
13169
+ return newItemValue;
13170
+ });
13171
+ }
13172
+
13173
+ function getTablePrimaryKey(props) {
13174
+ return props.primaryKey || "_id";
13175
+ }
13176
+
13177
+ /**
13178
+ * 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
13179
+ * @param {*} value 子表组件字段值,数组
13180
+ * @param {*} primaryKey 主键字段名,一般为_id
13181
+ * @returns 转换后的子表组件字段值
13182
+ */
13183
+ function getTableValueWithPrimaryKeyValue(value, primaryKey) {
13184
+ if (!primaryKey) {
13185
+ return value;
13186
+ }
13187
+ return (value || []).map((itemValue) => {
13188
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
13189
+ const newItemValue = _$1.clone(itemValue);
13190
+ if (newItemValue[primaryKey]) {
13191
+ if (newItemValue.children) {
13192
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13193
+ }
13194
+ return newItemValue;
13195
+ }
13196
+ else {
13197
+ newItemValue[primaryKey] = uuidv4();
13198
+ if (newItemValue.children) {
13199
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13200
+ }
13201
+ return newItemValue;
13202
+ }
13203
+ });
13204
+ }
13205
+
13206
+ /**
13207
+ * 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
13208
+ * @param {*} value 子表组件字段值,数组
13209
+ * @param {*} primaryKey 主键字段名,一般为_id
13210
+ * @returns 转换后的子表组件字段值
13211
+ */
13212
+ function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
13213
+ if (!primaryKey) {
13214
+ return value;
13215
+ }
13216
+ return (value || []).map((itemValue) => {
13217
+ //这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
13218
+ const newItemValue = _$1.clone(itemValue);
13219
+ if (newItemValue.children) {
13220
+ newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
13221
+ }
13222
+ delete newItemValue[primaryKey];
13223
+ return newItemValue;
13224
+ });
13225
+ }
13226
+
13227
+ /**
13228
+ * 子表组件字段值中每行数据的键值key移除指定前缀
13229
+ * @param {*} value 子表组件字段值,数组
13230
+ * @param {*} fieldPrefix 字段前缀
13231
+ * @returns 转换后的子表组件字段值
13232
+ */
13233
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
13234
+ let convertedValue = [];
13235
+ (value || []).forEach((itemValue) => {
13236
+ var newItemValue = {};
13237
+ for (let n in itemValue) {
13238
+ if (itemValue.hasOwnProperty(n)) {
13239
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13240
+ }
13241
+ }
13242
+ convertedValue.push(newItemValue);
13243
+ });
13244
+ return convertedValue;
13245
+ }
13246
+
13247
+ /**
13248
+ * 子表组件字段值中每行数据的键值key补上指定前缀
13249
+ * @param {*} value 子表组件字段值,数组
13250
+ * @param {*} fieldPrefix 字段前缀
13251
+ * @param {*} primaryKey 主键字段名,主键不参与被键值key规则,需要排除,审批王amis表单也是这个规则
13252
+ * @returns 转换后的子表组件字段值
12733
13253
  */
13254
+ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
13255
+ let convertedValue = [];
13256
+ (value || []).forEach((itemValue) => {
13257
+ var newItemValue = {};
13258
+ for (let n in itemValue) {
13259
+ if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
13260
+ newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13261
+ }
13262
+ }
13263
+ if (primaryKey && itemValue[primaryKey]) {
13264
+ newItemValue[primaryKey] = itemValue[primaryKey];
13265
+ }
13266
+ convertedValue.push(newItemValue);
13267
+ });
13268
+ return convertedValue;
13269
+ }
13270
+
13271
+ /**
13272
+ * 子表组件字段集合属性中每个字段name移除指定前缀
13273
+ * @param {*} fields 子表组件字段集合,数组
13274
+ * @param {*} fieldPrefix 字段前缀
13275
+ * @returns 转换后的子表组件字段值
13276
+ */
13277
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
13278
+ return (fields || []).map((item) => {
13279
+ const newItem = _$1.clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
13280
+ newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
13281
+ return newItem;
13282
+ });
13283
+ }
12734
13284
 
12735
13285
  /**
12736
13286
  * @param {*} props
12737
13287
  * @param {*} mode edit/new/readonly
12738
13288
  */
12739
13289
  function getFormFields(props, mode = "edit") {
12740
- return (props.fields || []).map(function (item) {
13290
+ let fieldPrefix = props.fieldPrefix;
13291
+ let fields = props.fields || [];
13292
+ if (fieldPrefix) {
13293
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13294
+ }
13295
+ return (fields || []).map(function (item) {
12741
13296
  let formItem = {
12742
13297
  "type": "steedos-field",
12743
13298
  "name": item.name,
@@ -12757,6 +13312,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
12757
13312
  name: field.name,
12758
13313
  quickEdit: {
12759
13314
  "type": "steedos-field",
13315
+ "mode": "inline",
12760
13316
  "config": Object.assign({}, field, {
12761
13317
  label: false
12762
13318
  })
@@ -12809,7 +13365,12 @@ async function getInputTableColumns(props) {
12809
13365
  let inlineEditMode = props.inlineEditMode;
12810
13366
  let showAsInlineEditMode = inlineEditMode && props.editable;
12811
13367
  // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
12812
- let fields = props.fields;
13368
+
13369
+ let fieldPrefix = props.fieldPrefix;
13370
+ let fields = props.fields || [];
13371
+ if (fieldPrefix) {
13372
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13373
+ }
12813
13374
  if (columns && columns.length) {
12814
13375
  return columns.map(function (column) {
12815
13376
  let field, extendColumnProps = {};
@@ -12831,7 +13392,9 @@ async function getInputTableColumns(props) {
12831
13392
  }
12832
13393
  }
12833
13394
  if (field) {
12834
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13395
+ let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
13396
+ extendColumnProps.inlineEditMode : showAsInlineEditMode;
13397
+ let tableCell = getInputTableCell(field, mode);
12835
13398
  return Object.assign({}, tableCell, extendColumnProps);
12836
13399
  }
12837
13400
  else {
@@ -12854,7 +13417,7 @@ async function getInputTableColumns(props) {
12854
13417
  */
12855
13418
  function getFormPagination(props, mode) {
12856
13419
  let showPagination = true;
12857
- if(mode === "new" && !!!props.editable){
13420
+ if (mode === "new" && !!!props.editable) {
12858
13421
  //不允许编辑只允许新建时不应该让用户操作翻页
12859
13422
  showPagination = false;
12860
13423
  }
@@ -12870,23 +13433,41 @@ function getFormPagination(props, mode) {
12870
13433
  let __formId = "${formId}";
12871
13434
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
12872
13435
  let pageChangeDirection = context.props.pageChangeDirection;
13436
+ let mode = "${mode}";
12873
13437
  // event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
12874
13438
  // 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
12875
13439
  // 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
12876
13440
  // let currentPage = currentIndex + 1;
12877
13441
  let currentPage = event.data.__page;
12878
13442
  let currentIndex = event.data.index;
12879
- // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12880
- let currentFormValues = scope.getComponentById(__formId).getValues();
12881
- fieldValue[currentIndex] = currentFormValues;
12882
- // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
12883
- doAction({
12884
- "componentId": "${props.id}",
12885
- "actionType": "setValue",
12886
- "args": {
12887
- "value": fieldValue
13443
+ if(mode !== "readonly"){
13444
+ // 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
13445
+ // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13446
+ let currentFormValues = scope.getComponentById(__formId).getValues();
13447
+ // 这里不clone的话,其值会带上__super属性
13448
+ currentFormValues = _.clone(currentFormValues);
13449
+ var parent = event.data.parent;
13450
+ var __parentIndex = event.data.__parentIndex;
13451
+ if(parent){
13452
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13453
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13454
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13455
+ children: fieldValue[__parentIndex].children,
13456
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13457
+ });
12888
13458
  }
12889
- });
13459
+ else{
13460
+ fieldValue[currentIndex] = currentFormValues;
13461
+ }
13462
+ // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13463
+ doAction({
13464
+ "componentId": "${props.id}",
13465
+ "actionType": "setValue",
13466
+ "args": {
13467
+ "value": fieldValue
13468
+ }
13469
+ });
13470
+ }
12890
13471
 
12891
13472
  // 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
12892
13473
  let targetPage;
@@ -12935,9 +13516,14 @@ function getFormPagination(props, mode) {
12935
13516
  "onEvent": {
12936
13517
  "click": {
12937
13518
  "actions": [
13519
+ {
13520
+ "actionType": "validate",
13521
+ "componentId": formId
13522
+ },
12938
13523
  {
12939
13524
  "actionType": "custom",
12940
- "script": onPageChangeScript
13525
+ "script": onPageChangeScript,
13526
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
12941
13527
  }
12942
13528
  ]
12943
13529
  }
@@ -12945,7 +13531,8 @@ function getFormPagination(props, mode) {
12945
13531
  },
12946
13532
  {
12947
13533
  "type": "tpl",
12948
- "tpl": "${__page}/${__tableItems.length}"
13534
+ // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13535
+ "tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
12949
13536
  },
12950
13537
  {
12951
13538
  "type": "button",
@@ -12953,15 +13540,22 @@ function getFormPagination(props, mode) {
12953
13540
  "icon": `fa fa-angle-right`,
12954
13541
  "level": "link",
12955
13542
  "pageChangeDirection": "next",
12956
- "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13543
+ // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13544
+ // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13545
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
12957
13546
  "size": "sm",
12958
13547
  "id": buttonNextId,
12959
13548
  "onEvent": {
12960
13549
  "click": {
12961
13550
  "actions": [
13551
+ {
13552
+ "actionType": "validate",
13553
+ "componentId": formId
13554
+ },
12962
13555
  {
12963
13556
  "actionType": "custom",
12964
- "script": onPageChangeScript
13557
+ "script": onPageChangeScript,
13558
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
12965
13559
  }
12966
13560
  ]
12967
13561
  }
@@ -12982,18 +13576,19 @@ function getFormPaginationWrapper(props, form, mode) {
12982
13576
  // console.log("==getFormPaginationWrapper===", props, mode);
12983
13577
  let serviceId = getComponentId("form_pagination", props.id);
12984
13578
  let tableServiceId = getComponentId("table_service", props.id);
13579
+ let primaryKey = getTablePrimaryKey(props);
12985
13580
  let innerForm = Object.assign({}, form, {
12986
13581
  "data": {
12987
13582
  // 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
12988
13583
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
12989
- "&": "${__tableItems[__super.index]}"
13584
+ "&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
12990
13585
  }
12991
13586
  });
12992
13587
  let formBody = [
12993
13588
  {
12994
13589
  "type": "wrapper",
12995
13590
  "size": "none",
12996
- "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white -mt-2",
13591
+ "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
12997
13592
  "body": [
12998
13593
  getFormPagination(props, mode)
12999
13594
  ]
@@ -13009,7 +13604,7 @@ function getFormPaginationWrapper(props, form, mode) {
13009
13604
  }
13010
13605
  ];
13011
13606
  let onServiceInitedScript = `
13012
- // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13607
+ // 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13013
13608
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
13014
13609
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
13015
13610
  // 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
@@ -13022,8 +13617,13 @@ function getFormPaginationWrapper(props, form, mode) {
13022
13617
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13023
13618
  // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
13024
13619
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
13620
+ let fieldPrefix = "${props.fieldPrefix || ''}";
13621
+ if(fieldPrefix){
13622
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
13623
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
13624
+ }
13025
13625
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
13026
- let mode = "${mode}";
13626
+ let mode = "${mode || ''}";
13027
13627
  if(mode === "new"){
13028
13628
  // 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
13029
13629
  // 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
@@ -13044,6 +13644,26 @@ function getFormPaginationWrapper(props, form, mode) {
13044
13644
  event.data.__tableItems.forEach(function(n,i){
13045
13645
  event.data.__tableItems[i] = lastestFieldValue[i];
13046
13646
  });
13647
+
13648
+ var parent = event.data.parent;
13649
+ var fieldValue = event.data.__tableItems;
13650
+ if(parent){
13651
+ // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13652
+ var primaryKey = "${primaryKey}";
13653
+ event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13654
+ return item[primaryKey] == parent[primaryKey];
13655
+ });
13656
+ if(event.data.__parentIndex < 0){
13657
+ let tableId = "${props.id}";
13658
+ let table = scope.getComponentById(tableId)
13659
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13660
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13661
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13662
+ event.data.__parentIndex = _.findIndex(table.props.value, function(item){
13663
+ return item[primaryKey] == parent[primaryKey];
13664
+ });
13665
+ }
13666
+ }
13047
13667
  `;
13048
13668
  let schema = {
13049
13669
  "type": "service",
@@ -13064,6 +13684,7 @@ function getFormPaginationWrapper(props, form, mode) {
13064
13684
  // "body": formBody,
13065
13685
  "data": {
13066
13686
  "__page": "${index + 1}",
13687
+ "__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
13067
13688
  // "__total": `\${${props.name}.length}`,
13068
13689
  // "__total": "${__tableItems.length}",
13069
13690
  // "__paginationServiceId": serviceId,
@@ -13090,6 +13711,7 @@ function getFormPaginationWrapper(props, form, mode) {
13090
13711
  async function getForm(props, mode = "edit", formId) {
13091
13712
  let formFields = getFormFields(props, mode);
13092
13713
  let body = await getFormBody(null, formFields);
13714
+ let primaryKey = getTablePrimaryKey(props);
13093
13715
  if (!formId) {
13094
13716
  formId = getComponentId("form", props.id);
13095
13717
  }
@@ -13108,10 +13730,41 @@ async function getForm(props, mode = "edit", formId) {
13108
13730
  // 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
13109
13731
  let onEditItemSubmitScript = `
13110
13732
  // let fieldValue = _.cloneDeep(event.data["${props.name}"]);
13733
+ let removeEmptyItems = function(items){
13734
+ let i = _.findIndex(items, function(item){
13735
+ return item === undefined
13736
+ });
13737
+ if(i > -1){
13738
+ items.splice(i, 1);
13739
+ removeEmptyItems(items);
13740
+ }
13741
+ }
13742
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13743
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13744
+ removeEmptyItems(event.data.__tableItems);
13111
13745
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13112
13746
  //这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
13113
13747
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
13114
- fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
13748
+ // fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
13749
+ var currentIndex = event.data.__super.__super.index;
13750
+ var currentFormValues = JSON.parse(JSON.stringify(event.data));
13751
+ var parent = event.data.__super.__super.parent;
13752
+ var __parentIndex = event.data.__super.__super.__parentIndex;
13753
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
13754
+ var primaryKey = "${primaryKey}";
13755
+ if(parent){
13756
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13757
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13758
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13759
+ children: fieldValue[__parentIndex].children,
13760
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13761
+ });
13762
+ }
13763
+ else{
13764
+ // 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
13765
+ // 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
13766
+ fieldValue[currentIndex] = currentFormValues;
13767
+ }
13115
13768
  doAction({
13116
13769
  "componentId": "${props.id}",
13117
13770
  "actionType": "setValue",
@@ -13207,13 +13860,14 @@ async function getForm(props, mode = "edit", formId) {
13207
13860
  */
13208
13861
  async function getButtonActions(props, mode) {
13209
13862
  let actions = [];
13863
+ let primaryKey = getTablePrimaryKey(props);
13210
13864
  let formId = getComponentId("form", props.id);
13211
13865
  let dialogId = getComponentId("dialog", props.id);
13212
13866
  let buttonNextId = getComponentId("button_next", props.id);
13213
13867
  let formPaginationId = getComponentId("form_pagination", props.id);
13214
13868
  let parentFormData = "${__super.__super.__super.__super || {}}";
13215
13869
  let amisVersion = getComparableAmisVersion();
13216
- if(amisVersion < 3.6){
13870
+ if (amisVersion < 3.6) {
13217
13871
  parentFormData = "${__super.__super || {}}";
13218
13872
  }
13219
13873
  if (mode == "new" || mode == "edit") {
@@ -13249,9 +13903,42 @@ async function getButtonActions(props, mode) {
13249
13903
  // };
13250
13904
  let onSaveAndNewItemScript = `
13251
13905
  let scope = event.context.scoped;
13906
+ let removeEmptyItems = function(items){
13907
+ let i = _.findIndex(items, function(item){
13908
+ return item === undefined
13909
+ });
13910
+ if(i > -1){
13911
+ items.splice(i, 1);
13912
+ removeEmptyItems(items);
13913
+ }
13914
+ }
13915
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13916
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13917
+ removeEmptyItems(event.data.__tableItems);
13252
13918
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13253
13919
  // 新建一条空白行并保存到子表组件
13254
- fieldValue.push({});
13920
+ var parent = event.data.__super.parent;
13921
+ var primaryKey = "${primaryKey}";
13922
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13923
+ return item[primaryKey] == parent[primaryKey];
13924
+ });
13925
+ if(parent && __parentIndex < 0){
13926
+ let tableId = "${props.id}";
13927
+ let table = scope.getComponentById(tableId)
13928
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13929
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13930
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13931
+ __parentIndex = _.findIndex(table.props.value, function(item){
13932
+ return item[primaryKey] == parent[primaryKey];
13933
+ });
13934
+ }
13935
+ if(parent){
13936
+ fieldValue[__parentIndex].children.push({});
13937
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13938
+ }
13939
+ else{
13940
+ fieldValue.push({});
13941
+ }
13255
13942
  doAction({
13256
13943
  "componentId": "${props.id}",
13257
13944
  "actionType": "setValue",
@@ -13263,7 +13950,13 @@ async function getButtonActions(props, mode) {
13263
13950
  let __paginationServiceId = "${formPaginationId}";
13264
13951
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13265
13952
  event.data.index = __paginationData.index;
13266
- event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13953
+ if(parent){
13954
+ event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13955
+ event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
13956
+ }
13957
+ else{
13958
+ event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13959
+ }
13267
13960
  // 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
13268
13961
  scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
13269
13962
  `;
@@ -13272,9 +13965,49 @@ async function getButtonActions(props, mode) {
13272
13965
  let __formId = "${formId}";
13273
13966
  // let newItem = JSON.parse(JSON.stringify(event.data));
13274
13967
  let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
13968
+ newItem = _.clone(newItem);
13969
+ let removeEmptyItems = function(items){
13970
+ let i = _.findIndex(items, function(item){
13971
+ return item === undefined
13972
+ });
13973
+ if(i > -1){
13974
+ items.splice(i, 1);
13975
+ removeEmptyItems(items);
13976
+ }
13977
+ }
13978
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13979
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13980
+ removeEmptyItems(event.data.__tableItems);
13275
13981
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13276
13982
  // 复制当前页数据到新建行并保存到子表组件
13277
- fieldValue.push(newItem);
13983
+ // fieldValue.push(newItem);
13984
+ var parent = event.data.__super.parent;
13985
+ var primaryKey = "${primaryKey}";
13986
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13987
+ return item[primaryKey] == parent[primaryKey];
13988
+ });
13989
+ if(parent && __parentIndex < 0){
13990
+ let tableId = "${props.id}";
13991
+ let table = scope.getComponentById(tableId)
13992
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13993
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13994
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13995
+ __parentIndex = _.findIndex(table.props.value, function(item){
13996
+ return item[primaryKey] == parent[primaryKey];
13997
+ });
13998
+ }
13999
+ if(newItem[primaryKey]){
14000
+ // 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
14001
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
14002
+ newItem[primaryKey] = uuidv4();
14003
+ }
14004
+ if(parent){
14005
+ fieldValue[__parentIndex].children.push(newItem);
14006
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
14007
+ }
14008
+ else{
14009
+ fieldValue.push(newItem);
14010
+ }
13278
14011
  doAction({
13279
14012
  "componentId": "${props.id}",
13280
14013
  "actionType": "setValue",
@@ -13286,19 +14019,25 @@ async function getButtonActions(props, mode) {
13286
14019
  let __paginationServiceId = "${formPaginationId}";
13287
14020
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13288
14021
  event.data.index = __paginationData.index;
13289
- event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
14022
+ if(parent){
14023
+ event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
14024
+ event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
14025
+ }
14026
+ else{
14027
+ event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
14028
+ }
13290
14029
  // 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
13291
14030
  scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
13292
14031
  `;
13293
14032
  let dialogButtons = [
13294
14033
  {
13295
- "type": "button",
13296
- "label": "完成",
13297
- "actionType": "confirm",
13298
- "level": "primary"
14034
+ "type": "button",
14035
+ "label": "完成",
14036
+ "actionType": "confirm",
14037
+ "level": "primary"
13299
14038
  }
13300
14039
  ];
13301
- if(props.addable){
14040
+ if (props.addable) {
13302
14041
  // 有新增行权限时额外添加新增和复制按钮
13303
14042
  dialogButtons = [
13304
14043
  {
@@ -13308,9 +14047,14 @@ async function getButtonActions(props, mode) {
13308
14047
  "onEvent": {
13309
14048
  "click": {
13310
14049
  "actions": [
14050
+ {
14051
+ "actionType": "validate",
14052
+ "componentId": formId
14053
+ },
13311
14054
  {
13312
14055
  "actionType": "custom",
13313
- "script": onSaveAndNewItemScript
14056
+ "script": onSaveAndNewItemScript,
14057
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13314
14058
  }
13315
14059
  ]
13316
14060
  }
@@ -13323,9 +14067,14 @@ async function getButtonActions(props, mode) {
13323
14067
  "onEvent": {
13324
14068
  "click": {
13325
14069
  "actions": [
14070
+ {
14071
+ "actionType": "validate",
14072
+ "componentId": formId
14073
+ },
13326
14074
  {
13327
14075
  "actionType": "custom",
13328
- "script": onSaveAndCopyItemScript
14076
+ "script": onSaveAndCopyItemScript,
14077
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13329
14078
  }
13330
14079
  ]
13331
14080
  }
@@ -13362,12 +14111,15 @@ async function getButtonActions(props, mode) {
13362
14111
  "_master": "${_master}",
13363
14112
  "global": "${global}",
13364
14113
  "uiSchema": "${uiSchema}",
13365
- "index": "${index}",
14114
+ "index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
14115
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13366
14116
  // "__tableItems": `\${${props.name}}`
13367
14117
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13368
14118
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13369
14119
  // "__tableItems": `\${${props.name}|json|toJson}`
13370
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
14120
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14121
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14122
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13371
14123
  },
13372
14124
  "actions": dialogButtons,
13373
14125
  "onEvent": {
@@ -13390,35 +14142,39 @@ async function getButtonActions(props, mode) {
13390
14142
  Object.assign(actionShowEditDialog.dialog, props.dialog);
13391
14143
  }
13392
14144
  if (mode == "new") {
13393
- `
13394
- let newItem = {};
13395
- if(event.data["${props.name}"]){
13396
- // let fieldValue = event.data.__tableItems;
13397
- // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
13398
- // let fieldValue = _.clone(event.data["${props.name}"]);
13399
- let fieldValue = event.data["${props.name}"];
13400
- fieldValue.push(newItem);
13401
- doAction({
13402
- "componentId": "${props.id}",
13403
- "actionType": "setValue",
13404
- "args": {
13405
- "value": fieldValue
13406
- }
13407
- });
13408
- event.data.index = fieldValue.length - 1;
13409
- }
13410
- else{
13411
- // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
13412
- doAction({
13413
- "componentId": "${props.id}",
13414
- "actionType": "setValue",
13415
- "args": {
13416
- "value": [newItem]
13417
- }
13418
- });
13419
- event.data.index = 1;
13420
- }
13421
- `;
14145
+ // let onNewLineScript = `
14146
+ // let newItem = {};
14147
+ // if(event.data["${props.name}"]){
14148
+ // // let fieldValue = event.data.__tableItems;
14149
+ // // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
14150
+ // // let fieldValue = _.clone(event.data["${props.name}"]);
14151
+ // let fieldValue = event.data["${props.name}"];
14152
+ // fieldValue.push(newItem);
14153
+ // doAction({
14154
+ // "componentId": "${props.id}",
14155
+ // "actionType": "setValue",
14156
+ // "args": {
14157
+ // "value": fieldValue
14158
+ // }
14159
+ // });
14160
+ // event.data.index = fieldValue.length - 1;
14161
+ // }
14162
+ // else{
14163
+ // // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
14164
+ // doAction({
14165
+ // "componentId": "${props.id}",
14166
+ // "actionType": "setValue",
14167
+ // "args": {
14168
+ // "value": [newItem]
14169
+ // }
14170
+ // });
14171
+ // event.data.index = 1;
14172
+ // }
14173
+ // `;
14174
+ // let actionNewLine = {
14175
+ // "actionType": "custom",
14176
+ // "script": onNewLineScript
14177
+ // };
13422
14178
  // 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
13423
14179
  // actions = [actionNewLine, actionShowEditDialog];
13424
14180
  actions = [actionShowEditDialog];
@@ -13453,15 +14209,20 @@ async function getButtonActions(props, mode) {
13453
14209
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13454
14210
  // "__parentForm": "${__super.__super || {}}",
13455
14211
  "__parentForm": parentFormData,
14212
+ "_master": "${_master}",
13456
14213
  "global": "${global}",
13457
14214
  "uiSchema": "${uiSchema}",
13458
14215
  "index": "${index}",
14216
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13459
14217
  // "__tableItems": `\${${props.name}}`
13460
14218
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13461
14219
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13462
14220
  // "__tableItems": `\${${props.name}|json|toJson}`
13463
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
13464
- },
14221
+ // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14222
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14223
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14224
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14225
+ },
13465
14226
  }
13466
14227
  }
13467
14228
  ];
@@ -13476,8 +14237,40 @@ async function getButtonActions(props, mode) {
13476
14237
  let wrapperServiceData = wrapperService.getData();
13477
14238
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13478
14239
  // 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
14240
+ // 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
13479
14241
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13480
- lastestFieldValue.splice(event.data.index, 1);
14242
+ var currentIndex = event.data.index;
14243
+ var parent = event.data.__super.parent;
14244
+ var primaryKey = "${primaryKey}";
14245
+ var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
14246
+ return item[primaryKey] == parent[primaryKey];
14247
+ });
14248
+ if(parent && __parentIndex < 0){
14249
+ let tableId = "${props.id}";
14250
+ let table = scope.getComponentById(tableId)
14251
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14252
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14253
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14254
+ __parentIndex = _.findIndex(table.props.value, function(item){
14255
+ return item[primaryKey] == parent[primaryKey];
14256
+ });
14257
+ }
14258
+ if(parent){
14259
+ lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
14260
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
14261
+ lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
14262
+ children: lastestFieldValue[__parentIndex].children,
14263
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
14264
+ });
14265
+ }
14266
+ else{
14267
+ lastestFieldValue.splice(currentIndex, 1);
14268
+ }
14269
+ let fieldPrefix = "${props.fieldPrefix || ''}";
14270
+ if(fieldPrefix){
14271
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
14272
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
14273
+ }
13481
14274
  doAction({
13482
14275
  "componentId": "${props.id}",
13483
14276
  "actionType": "setValue",
@@ -13547,58 +14340,104 @@ async function getButtonView(props) {
13547
14340
 
13548
14341
  async function getButtonDelete(props) {
13549
14342
  return {
13550
- "type": "button",
13551
- "label": "",
13552
- "icon": "fa fa-trash-alt",//不可以用fa-trash-o,因为设计字段布局界面中弹出的设置分组列表中显示不了这个图标
14343
+ "type": "dropdown-button",
13553
14344
  "level": "link",
13554
- "onEvent": {
13555
- "click": {
13556
- "actions": await getButtonActions(props, "delete")
14345
+ "icon": "fa fa-trash-alt",
14346
+ "size": "xs",
14347
+ "hideCaret": true,
14348
+ "closeOnClick": true,
14349
+ "body": [
14350
+ {
14351
+ "type": "wrapper",
14352
+ "size": "md",
14353
+ "className": "w-80",
14354
+ "body": [
14355
+ {
14356
+ "tpl": "确定要删除吗?",
14357
+ "type": "tpl"
14358
+ },
14359
+ {
14360
+ "type": "flex",
14361
+ "justify": "flex-end",
14362
+ "className": "mt-3",
14363
+ "items": [
14364
+ {
14365
+ "type": "button",
14366
+ "label": "取消",
14367
+ "className": "mr-2"
14368
+ },
14369
+ {
14370
+ "type": "button",
14371
+ "label": "删除",
14372
+ "level": "danger",
14373
+ "onEvent": {
14374
+ "click": {
14375
+ "actions": await getButtonActions(props, "delete")
14376
+ }
14377
+ }
14378
+ }
14379
+ ]
14380
+ }
14381
+ ]
13557
14382
  }
13558
- }
13559
- };
14383
+ ]
14384
+ }
13560
14385
  }
13561
14386
 
14387
+
13562
14388
  const getAmisInputTableSchema = async (props) => {
13563
14389
  if (!props.id) {
13564
14390
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13565
14391
  }
14392
+ let primaryKey = getTablePrimaryKey(props);
14393
+ let showOperation = props.showOperation;
14394
+ if (showOperation !== false) {
14395
+ showOperation = true;
14396
+ }
14397
+ let fieldPrefix = props.fieldPrefix;
14398
+ let fields = props.fields || [];
14399
+ if (fieldPrefix) {
14400
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
14401
+ }
13566
14402
  let serviceId = getComponentId("table_service", props.id);
13567
14403
  let buttonsForColumnOperations = [];
13568
14404
  let inlineEditMode = props.inlineEditMode;
13569
14405
  let showAsInlineEditMode = inlineEditMode && props.editable;
13570
- if (props.editable) {
13571
- let showEditButton = true;
13572
- if (showAsInlineEditMode) {
13573
- // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
13574
- showEditButton = true;
13575
- // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
13576
- // if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
13577
- // showEditButton = true;
13578
- // }
13579
- // else {
13580
- // showEditButton = false;
13581
- // }
14406
+ if (showOperation) {
14407
+ if (props.editable) {
14408
+ let showEditButton = true;
14409
+ if (showAsInlineEditMode) {
14410
+ // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
14411
+ showEditButton = true;
14412
+ // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
14413
+ // if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
14414
+ // showEditButton = true;
14415
+ // }
14416
+ // else {
14417
+ // showEditButton = false;
14418
+ // }
14419
+ }
14420
+ // 编辑时显示编辑按钮
14421
+ if (showEditButton) {
14422
+ let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
14423
+ buttonsForColumnOperations.push(buttonEditSchema);
14424
+ }
13582
14425
  }
13583
- // 编辑时显示编辑按钮
13584
- if (showEditButton) {
13585
- let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
13586
- buttonsForColumnOperations.push(buttonEditSchema);
14426
+ else {
14427
+ // 只读时显示查看按钮
14428
+ // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
14429
+ let buttonViewSchema = await getButtonView(props);
14430
+ buttonsForColumnOperations.push(buttonViewSchema);
14431
+ }
14432
+ if (props.removable) {
14433
+ let buttonDeleteSchema = await getButtonDelete(props);
14434
+ buttonsForColumnOperations.push(buttonDeleteSchema);
13587
14435
  }
13588
14436
  }
13589
- else {
13590
- // 只读时显示查看按钮
13591
- // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
13592
- let buttonViewSchema = await getButtonView(props);
13593
- buttonsForColumnOperations.push(buttonViewSchema);
13594
- }
13595
- if (props.removable) {
13596
- let buttonDeleteSchema = await getButtonDelete(props);
13597
- buttonsForColumnOperations.push(buttonDeleteSchema);
13598
- }
14437
+ let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
13599
14438
  let inputTableSchema = {
13600
14439
  "type": "input-table",
13601
- "label": props.label,
14440
+ "mode": "normal",
13602
14441
  "name": props.name,
13603
14442
  //不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
13604
14443
  // "addable": props.addable,
@@ -13613,7 +14452,53 @@ const getAmisInputTableSchema = async (props) => {
13613
14452
  "strictMode": props.strictMode,
13614
14453
  "showTableAddBtn": false,
13615
14454
  "showFooterAddBtn": false,
13616
- "className": props.tableClassName
14455
+ "className": props.tableClassName,
14456
+ "pipeIn": (value, data) => {
14457
+ if (fieldPrefix) {
14458
+ value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
14459
+ }
14460
+ value = getTableValueWithEmptyValue(value, fields);
14461
+ if (primaryKey) {
14462
+ // 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
14463
+ // 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
14464
+ // 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
14465
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14466
+ }
14467
+ if (amis.pipeIn) {
14468
+ if (typeof amis.pipeIn === 'function') {
14469
+ return amis.pipeIn(value, data);
14470
+ }
14471
+ }
14472
+ return value;
14473
+ },
14474
+ "pipeOut": (value, data) => {
14475
+ value = (value || []).map(function (item) {
14476
+ delete item.__fix_rerender_after_children_modified_tag;
14477
+ return item;
14478
+ });
14479
+ if (fieldPrefix) {
14480
+ value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
14481
+ }
14482
+ value = getTableValueWithoutEmptyValue(value, fields);
14483
+ if (props.autoGeneratePrimaryKeyValue === true) {
14484
+ // 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
14485
+ // 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
14486
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14487
+ }
14488
+ else {
14489
+ // 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
14490
+ // 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
14491
+ // 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
14492
+ // 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
14493
+ value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
14494
+ }
14495
+ if (amis.pipeOut) {
14496
+ if (typeof amis.pipeOut === 'function') {
14497
+ return amis.pipeOut(value, data);
14498
+ }
14499
+ }
14500
+ return value;
14501
+ }
13617
14502
  };
13618
14503
  if (buttonsForColumnOperations.length) {
13619
14504
  inputTableSchema.columns.push({
@@ -13623,20 +14508,22 @@ const getAmisInputTableSchema = async (props) => {
13623
14508
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
13624
14509
  });
13625
14510
  }
13626
- if (showAsInlineEditMode) {
13627
- inputTableSchema.needConfirm = false;
13628
- }
13629
- let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
14511
+ // if (showAsInlineEditMode) {
14512
+ // // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
14513
+ // inputTableSchema.needConfirm = false;
14514
+ // }
13630
14515
  if (amis) {
13631
14516
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
13632
14517
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
14518
+ delete amis.pipeIn;//该属性在上面合并过了
14519
+ delete amis.pipeOut;//该属性在上面合并过了
13633
14520
  Object.assign(inputTableSchema, amis);
13634
14521
  }
13635
- const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
14522
+ const isAnyFieldHasDependOn = (fields || []).find(function (item) {
13636
14523
  return item.depend_on;
13637
14524
  });
13638
14525
  if (isAnyFieldHasDependOn) {
13639
- // 有任意一个子字段有depend_on属性时,强制设置禁用静态模式
14526
+ // 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
13640
14527
  Object.assign(inputTableSchema, {
13641
14528
  strictMode: false
13642
14529
  });
@@ -13665,11 +14552,31 @@ const getAmisInputTableSchema = async (props) => {
13665
14552
  "body": headerToolbar
13666
14553
  });
13667
14554
  }
14555
+ let className = "steedos-input-table";
14556
+
14557
+ if (typeof props.className == "object") {
14558
+ className = {
14559
+ [className]: "true",
14560
+ ...props.className
14561
+ };
14562
+ } else if (typeof props.className == "string") {
14563
+ className = `${className} ${props.className} `;
14564
+ }
14565
+
13668
14566
  let schema = {
13669
- "type": "service",
13670
- "body": schemaBody,
13671
- "className": props.className,
13672
- "id": serviceId
14567
+ "type": "control",
14568
+ "body": {
14569
+ "type": "service",
14570
+ "body": schemaBody,
14571
+ "id": serviceId
14572
+ },
14573
+ "label": props.label,
14574
+ "labelClassName": props.label ? props.labelClassName : "none",
14575
+ "labelRemark": props.labelRemark,
14576
+ "labelAlign": props.labelAlign,
14577
+ //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14578
+ "mode": props.mode || null,
14579
+ className
13673
14580
  };
13674
14581
  // console.log("===schema===", schema);
13675
14582
  return schema;
@@ -13741,7 +14648,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
13741
14648
  // 获取
13742
14649
  async function getRecordPageInitSchema(objectApiName){
13743
14650
  const relatedList = await getObjectRelatedList(objectApiName);
13744
- const uiSchema = await getUISchema(objectApiName);
14651
+ await getUISchema(objectApiName);
13745
14652
  let body = [
13746
14653
  // detailHeaderAmisSchema,
13747
14654
  {
@@ -13749,28 +14656,7 @@ async function getRecordPageInitSchema(objectApiName){
13749
14656
  "label": "标题面板",
13750
14657
  "objectApiName": "${objectName}",
13751
14658
  "recordId": "${recordId}",
13752
- "onEvent": {
13753
- "recordLoaded": {
13754
- "actions": [
13755
- {
13756
- "actionType": "setValue",
13757
- "args": {
13758
- "value": {
13759
- "recordLoaded": true,
13760
- }
13761
- }
13762
- },
13763
- {
13764
- "actionType": "reload",
13765
- "data": {
13766
- "name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
13767
- "record": `\${record}`,
13768
- "recordLoaded": true,
13769
- }
13770
- }
13771
- ]
13772
- }
13773
- }
14659
+ "onEvent": {}
13774
14660
  }
13775
14661
  ];
13776
14662
  let contentBody = {
@@ -16405,9 +17291,11 @@ exports.getObjectRelated = getObjectRelated;
16405
17291
  exports.getObjectRelatedList = getObjectRelatedList;
16406
17292
  exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
16407
17293
  exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
17294
+ exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
16408
17295
  exports.getPage = getPage;
16409
17296
  exports.getRecord = getRecord;
16410
17297
  exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
17298
+ exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
16411
17299
  exports.getRecordDetailRelatedListSchema = getRecordDetailRelatedListSchema;
16412
17300
  exports.getRecordDetailSchema = getRecordDetailSchema;
16413
17301
  exports.getRecordPageInitSchema = getRecordPageInitSchema;