@steedos-widgets/amis-lib 3.6.2-beta.9 → 3.6.3-beta.1

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.
Files changed (26) hide show
  1. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  2. package/dist/index.cjs.js +884 -268
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +884 -268
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.umd.js +212 -127
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/types/lib/converter/amis/api.d.ts +1 -0
  9. package/dist/types/lib/converter/amis/fields/editor.d.ts +1 -1
  10. package/dist/types/lib/converter/amis/fields/file.d.ts +52 -0
  11. package/dist/types/lib/converter/amis/fields/lookup.d.ts +3 -0
  12. package/dist/types/lib/converter/amis/toolbars/setting_listview/columns.d.ts +1 -0
  13. package/dist/types/lib/converter/amis/toolbars/setting_listview/copy.d.ts +21 -0
  14. package/dist/types/lib/converter/amis/toolbars/setting_listview/filters.d.ts +2 -1
  15. package/dist/types/lib/converter/amis/toolbars/setting_listview/new.d.ts +20 -0
  16. package/dist/types/lib/converter/amis/toolbars/setting_listview/rename.d.ts +1 -0
  17. package/dist/types/lib/converter/amis/toolbars/setting_listview/share.d.ts +15 -0
  18. package/dist/types/lib/converter/amis/toolbars/setting_listview/sort.d.ts +2 -0
  19. package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +130 -0
  20. package/dist/types/lib/converter/amis/util.d.ts +5 -0
  21. package/dist/types/lib/input_table.d.ts +24 -15
  22. package/dist/types/lib/objectsRelated.d.ts +8 -17
  23. package/dist/types/lib/router.d.ts +2 -2
  24. package/dist/types/schema/standard_import_data.amis.d.ts +7 -0
  25. package/dist/types/standard/button.d.ts +7 -0
  26. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -335,14 +335,13 @@ const getSteedosAuth = () => {
335
335
  /*
336
336
  * @Author: baozhoutao@steedos.com
337
337
  * @Date: 2022-08-16 17:02:08
338
- * @LastEditors: baozhoutao@steedos.com
339
- * @LastEditTime: 2023-06-20 13:50:15
338
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
339
+ * @LastEditTime: 2024-02-02 10:15:00
340
340
  * @Description:
341
341
  */
342
342
 
343
343
  const Router = {
344
- getTabDisplayAs(tab_id){
345
- const uiSchema = getUISchemaSync$1(tab_id, false);
344
+ getTabDisplayAs(tab_id, defaultEnableSplit){
346
345
  var urlSearch = new URLSearchParams(document.location.search);
347
346
  if(urlSearch.has('display')){
348
347
  return urlSearch.get('display')
@@ -351,9 +350,12 @@ const Router = {
351
350
  // const key = `page_display`;
352
351
  const value = sessionStorage.getItem(key);
353
352
  let defaultDisplay = "grid";
354
- if(uiSchema.enable_split){
353
+ if(defaultEnableSplit === true){
355
354
  defaultDisplay = "split";
356
355
  }
356
+ if(window.innerWidth <= 768){
357
+ return "grid";
358
+ }
357
359
  return value ? value : defaultDisplay;
358
360
  },
359
361
 
@@ -386,8 +388,8 @@ const Router = {
386
388
  /*
387
389
  * @Author: baozhoutao@steedos.com
388
390
  * @Date: 2022-07-20 16:29:22
389
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
390
- * @LastEditTime: 2023-12-28 14:59:08
391
+ * @LastEditors: liaodaxue
392
+ * @LastEditTime: 2024-01-25 14:44:17
391
393
  * @Description:
392
394
  */
393
395
 
@@ -459,6 +461,25 @@ function getComparableAmisVersion() {
459
461
  }
460
462
  }
461
463
 
464
+ /**
465
+ * 判断浏览器类型
466
+ * @returns 按需返回浏览器类型;
467
+ */
468
+ function getBowserType() {
469
+ const userAgent = navigator.userAgent;
470
+ if (userAgent.indexOf("Chrome")!== -1 && userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Edg") === -1) {
471
+ return "Chrome";
472
+ } else if (userAgent.indexOf("Firefox") !== -1) {
473
+ return "Firefox";
474
+ } else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("Edge") === -1) {
475
+ return "Safari";
476
+ } else if (userAgent.indexOf("Edg") !== -1) {
477
+ return "Edge";
478
+ } else {
479
+ return "Unknown browser"; // 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
480
+ }
481
+ }
482
+
462
483
  /*
463
484
  * @Author: baozhoutao@steedos.com
464
485
  * @Date: 2022-05-23 09:53:08
@@ -521,7 +542,7 @@ function getSelectMap(selectOptions){
521
542
  forEach(selectOptions,(option)=>{
522
543
  const optionValue = option.value + '';
523
544
  const optionColor = option.color + '';
524
- if(optionColor){
545
+ if(optionColor && optionColor != "undefined"){
525
546
  const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
526
547
  const color = getContrastColor(background);
527
548
  const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
@@ -1137,7 +1158,31 @@ const getAmisFileReadonlySchema = (steedosField)=>{
1137
1158
  }
1138
1159
  }
1139
1160
  if(type === 'file'){
1140
- return {
1161
+ return window.Meteor?.isCordova ? {
1162
+ "type": "control",
1163
+ "body": {
1164
+ "type": "each",
1165
+ "name": "_display." + steedosField.name,
1166
+ "items": {
1167
+ "type": "tpl",
1168
+ "tpl": "${name}",
1169
+ "className": "antd-Button--link inline-block",
1170
+ "onEvent": {
1171
+ "click": {
1172
+ "actions": [
1173
+ {
1174
+ "script": `
1175
+ Steedos.cordovaDownload(encodeURI(event.data.url), event.data.name);
1176
+ `,
1177
+ "actionType": "custom"
1178
+ }
1179
+ ],
1180
+ "weight": 0
1181
+ }
1182
+ }
1183
+ }
1184
+ }
1185
+ } : {
1141
1186
  type: amisFieldType,
1142
1187
  tpl: `
1143
1188
  <% let fileData = data._display.${steedosField.name}; if (fileData) { %>
@@ -1281,6 +1326,7 @@ var frontend_notifications$1 = "Notifications";
1281
1326
  var frontend_notifications_allread$1 = "Mark all as read";
1282
1327
  var frontend_notifications_allread_message$1 = "All marked as read";
1283
1328
  var frontend_profile$1 = "Profile";
1329
+ var switch_space$1 = "Switch Space";
1284
1330
  var frontend_about$1 = "About";
1285
1331
  var frontend_log_out$1 = "Log out";
1286
1332
  var frontend_listview_warning_start$1 = "The current ";
@@ -1368,6 +1414,7 @@ var en_us = {
1368
1414
  frontend_notifications_allread: frontend_notifications_allread$1,
1369
1415
  frontend_notifications_allread_message: frontend_notifications_allread_message$1,
1370
1416
  frontend_profile: frontend_profile$1,
1417
+ switch_space: switch_space$1,
1371
1418
  frontend_about: frontend_about$1,
1372
1419
  frontend_log_out: frontend_log_out$1,
1373
1420
  frontend_listview_warning_start: frontend_listview_warning_start$1,
@@ -1423,7 +1470,7 @@ var frontend_listview_control_delete_label = "删除";
1423
1470
  var frontend_listview_control_delete_confirm_text = "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?";
1424
1471
  var frontend_listview_control_delete_message_success = "删除成功";
1425
1472
  var frontend_listview_control_filters = "过滤设置";
1426
- var frontend_listview_control_filters_fields_extend = "条件组件1";
1473
+ var frontend_listview_control_filters_fields_extend = "条件组件";
1427
1474
  var frontend_listview_control_new_label = "新建";
1428
1475
  var frontend_listview_control_new_title = "新建 列表视图";
1429
1476
  var frontend_listview_control_new_message_success = "成功";
@@ -1457,6 +1504,7 @@ var frontend_notifications = "通知";
1457
1504
  var frontend_notifications_allread = "全部标记为已读";
1458
1505
  var frontend_notifications_allread_message = "已全部标记为已读";
1459
1506
  var frontend_profile = "个人资料";
1507
+ var switch_space = "切换工作区";
1460
1508
  var frontend_about = "关于";
1461
1509
  var frontend_log_out = "注销";
1462
1510
  var frontend_listview_warning_start = "当前";
@@ -1545,6 +1593,7 @@ var zh_cn = {
1545
1593
  frontend_notifications_allread: frontend_notifications_allread,
1546
1594
  frontend_notifications_allread_message: frontend_notifications_allread_message,
1547
1595
  frontend_profile: frontend_profile,
1596
+ switch_space: switch_space,
1548
1597
  frontend_about: frontend_about,
1549
1598
  frontend_log_out: frontend_log_out,
1550
1599
  frontend_listview_warning_start: frontend_listview_warning_start,
@@ -1599,7 +1648,7 @@ async function getQuickEditSchema(field, options){
1599
1648
  isAmisVersionforBatchEdit = window.Amis.version[0] >= 3 && window.Amis.version[2] >= 2;
1600
1649
  }
1601
1650
  const quickEditId = options.objectName + "_" + field.name + "_quickEdit";//定义快速编辑的表单id,用于setvalue传值
1602
- var quickEditSchema = { body: [], id: quickEditId };
1651
+ var quickEditSchema = { body: [], id: quickEditId, className: "steedos-table-quickEdit" };
1603
1652
  //select,avatar,image,file等组件无法行记录字段赋值,暂不支持批量编辑;
1604
1653
  if(field.type != 'avatar' && field.type != 'image' && field.type != 'file' && isAmisVersionforBatchEdit){
1605
1654
  const submitEvent = {
@@ -1858,7 +1907,8 @@ async function getQuickEditSchema(field, options){
1858
1907
  "failed": "失败了呢。。"
1859
1908
  }
1860
1909
  }
1861
- }
1910
+ },
1911
+ "expression": "${!recordPermissions.modifyAllRecords}"
1862
1912
  },
1863
1913
  {
1864
1914
  "actionType": "setValue",
@@ -1874,7 +1924,7 @@ async function getQuickEditSchema(field, options){
1874
1924
  "componentId": quickEditId,
1875
1925
  "args": {
1876
1926
  "value":{
1877
- "quickedit_record_permissions": "${event.data}"
1927
+ "quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
1878
1928
  }
1879
1929
  }
1880
1930
  }
@@ -1938,7 +1988,7 @@ async function getQuickEditSchema(field, options){
1938
1988
  `
1939
1989
  }
1940
1990
  },
1941
- "expression":"${event.data.value}"
1991
+ "expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
1942
1992
  },
1943
1993
  {
1944
1994
  "actionType": "setValue",
@@ -1969,10 +2019,20 @@ async function getQuickEditSchema(field, options){
1969
2019
  "script": `
1970
2020
  const noPermission = event.data.noPermission;
1971
2021
  const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
1972
- const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
2022
+ let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
1973
2023
  noPermission.forEach(function (item) {
1974
2024
  crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
2025
+ _.remove(selectedItems, (selected) => selected._id === item);
1975
2026
  })
2027
+ doAction({
2028
+ "componentId": "${quickEditId}",
2029
+ "actionType": "setValue",
2030
+ "args": {
2031
+ "value": {
2032
+ selectedItems
2033
+ }
2034
+ }
2035
+ });
1976
2036
  `
1977
2037
  },
1978
2038
  {
@@ -2033,7 +2093,7 @@ async function getQuickEditSchema(field, options){
2033
2093
  }
2034
2094
 
2035
2095
  function getFieldWidth(width){
2036
- const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2096
+ const defaultWidth = null;
2037
2097
  if(typeof width == 'string'){
2038
2098
  if(isNaN(width)){
2039
2099
  return width || defaultWidth;
@@ -2063,22 +2123,35 @@ async function getTableColumns(fields, options){
2063
2123
  //增加quickEdit属性,实现快速编辑
2064
2124
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2065
2125
  let className = "";
2066
- if(field.wrap != true){
2067
- if(field.wrap != false && field.is_wide){
2068
- className += " break-words ";
2069
- }else {
2126
+ const bowserType = getBowserType();
2127
+ if(bowserType === "Safari"){
2128
+ className += " whitespace-nowrap ";
2129
+ }else {
2130
+ if(field.wrap != true){
2070
2131
  className += " whitespace-nowrap ";
2132
+ }else {
2133
+ className += " break-words ";
2071
2134
  }
2072
- }else {
2073
- className += " break-words ";
2074
2135
  }
2136
+
2137
+ if (typeof field.amis?.className == "object") {
2138
+ className = {
2139
+ [className]: "true",
2140
+ ...field.amis.className
2141
+ };
2142
+ } else if (typeof field.amis?.className == "string") {
2143
+ className = `${className} ${field.amis.className} `;
2144
+ }
2145
+ let fieldAmis = _$1.clone(field.amis);
2146
+ delete fieldAmis?.className;
2147
+
2075
2148
  let columnItem;
2076
2149
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
2077
2150
  const previewFileScript = `
2078
2151
  var data = event.data;
2079
2152
  var file_name = data.versions ? data.name : "${field.label}";
2080
- var file_id = data._id;
2081
- SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
2153
+ var file_id = data.versions && data.versions[0] && data.versions[0]._id;
2154
+ window.previewFile && window.previewFile({file_name, file_id});
2082
2155
  `;
2083
2156
  columnItem = {
2084
2157
  "type": "button",
@@ -2103,11 +2176,11 @@ async function getTableColumns(fields, options){
2103
2176
  "expression": "!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
2104
2177
  },
2105
2178
  {
2106
- "args": {},
2107
- "actionType": "custom",
2108
- "script": previewFileScript,
2109
- // "expression": "!!window?.nw?.require" //PC客户端预览附件
2110
- "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2179
+ "args": {},
2180
+ "actionType": "custom",
2181
+ "script": previewFileScript,
2182
+ // "expression": "!!window?.nw?.require" //PC客户端预览附件
2183
+ "expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2111
2184
  }
2112
2185
  ]
2113
2186
  }
@@ -2122,7 +2195,7 @@ async function getTableColumns(fields, options){
2122
2195
  toggled: field.toggled,
2123
2196
  static: true,
2124
2197
  className,
2125
- }, field.amis, {name: field.name});
2198
+ }, fieldAmis, {name: field.name});
2126
2199
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
2127
2200
  columnItem = Object.assign({}, {
2128
2201
  type: "switch",
@@ -2133,7 +2206,7 @@ async function getTableColumns(fields, options){
2133
2206
  static: true,
2134
2207
  className,
2135
2208
  ...getAmisFileReadonlySchema(field)
2136
- }, field.amis, {name: field.name});
2209
+ }, fieldAmis, {name: field.name});
2137
2210
  }
2138
2211
  else if(field.type === 'select'){
2139
2212
  const map = getSelectMap(field.options);
@@ -2148,7 +2221,7 @@ async function getTableColumns(fields, options){
2148
2221
  className,
2149
2222
  inputClassName: "inline",
2150
2223
  static: true,
2151
- }, field.amis, {name: field.name});
2224
+ }, fieldAmis, {name: field.name});
2152
2225
  }
2153
2226
  else {
2154
2227
  const tpl = await getFieldTpl(field, options);
@@ -2175,15 +2248,6 @@ async function getTableColumns(fields, options){
2175
2248
  // }
2176
2249
 
2177
2250
  //field上的amis属性里的clssname需要单独判断类型合并
2178
- if (typeof field.amis?.className == "object") {
2179
- className = {
2180
- [className]: "true",
2181
- ...field.amis.className
2182
- };
2183
- } else if (typeof field.amis?.className == "string") {
2184
- className = `${className} ${field.amis.className} `;
2185
- }
2186
- delete field.amis?.className;
2187
2251
 
2188
2252
  if(!field.hidden && !field.extra){
2189
2253
  columnItem = Object.assign({}, {
@@ -2200,7 +2264,7 @@ async function getTableColumns(fields, options){
2200
2264
  static: true,
2201
2265
  options: field.type === 'html' ? {html: true} : null
2202
2266
  // toggled: true
2203
- }, field.amis, {name: field.name});
2267
+ }, fieldAmis, {name: field.name});
2204
2268
 
2205
2269
  if(field.type === 'color'){
2206
2270
  columnItem.type = 'color';
@@ -2396,10 +2460,10 @@ async function getMobileTableColumns(fields, options){
2396
2460
  if(value.url){
2397
2461
  cms_url = value.url;
2398
2462
  }else{
2399
- cms_url = "/api/files/files/"+value+"?download=true"
2463
+ cms_url = Steedos.absoluteUrl("/api/files/files/"+value+"?download=true");
2400
2464
  }
2401
2465
  }
2402
- Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
2466
+ Steedos.cordovaDownload(encodeURI(cms_url), event.data.name);
2403
2467
  `,
2404
2468
  "actionType": "custom"
2405
2469
  }
@@ -2899,6 +2963,21 @@ async function getTableApi(mainObject, fields, options){
2899
2963
  return api;
2900
2964
  `;
2901
2965
  api.adaptor = `
2966
+ let fields = ${JSON.stringify(_$1.map(fields, 'name'))};
2967
+ // 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
2968
+ (payload.data.rows || []).forEach((itemRow) => {
2969
+ (fields || []).forEach((itemField) => {
2970
+ if(itemField && itemField.indexOf(".") > -1){
2971
+ return;
2972
+ }
2973
+ if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
2974
+ // 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
2975
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
2976
+ itemRow[itemField] = "";
2977
+ }
2978
+ });
2979
+ });
2980
+
2902
2981
  if(api.body.listName == "recent"){
2903
2982
  payload.data.rows = _.sortBy(payload.data.rows, function(item){
2904
2983
  return _.indexOf(api.body._ids, item._id)
@@ -2923,7 +3002,13 @@ async function getTableApi(mainObject, fields, options){
2923
3002
  value = [value]
2924
3003
  };
2925
3004
  if(field.type === 'file'){
2926
- item[key] = value
3005
+ // item[key] = value
3006
+ // PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
3007
+ let itemKeyValue = item[key];
3008
+ item[key] = value.map(function(item, index){
3009
+ item._id = itemKeyValue[index];
3010
+ return item;
3011
+ });
2927
3012
  }else{
2928
3013
  item[key] = _.map(value, (item)=>{
2929
3014
  if(field.type === 'image'){
@@ -2965,15 +3050,8 @@ async function getTableApi(mainObject, fields, options){
2965
3050
  }
2966
3051
  });
2967
3052
  };
2968
- let isTreeOptionsComputed = false;
2969
- if(records.length === 1 && records[0].children){
2970
- isTreeOptionsComputed = true;
2971
- }
2972
- if(!isTreeOptionsComputed){
2973
- // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2974
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2975
- assignIndexToTreeRecords(payload.data.rows, '');
2976
- }
3053
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
3054
+ assignIndexToTreeRecords(payload.data.rows, '');
2977
3055
  }
2978
3056
 
2979
3057
 
@@ -3032,11 +3110,10 @@ async function getTableApi(mainObject, fields, options){
3032
3110
  };
3033
3111
  let formFactor = "${options.formFactor}";
3034
3112
  if(formFactor !== "SMALL"){
3035
- const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3036
- const firstListviewComponent = listviewComponent && listviewComponent[0];
3037
- if(firstListviewComponent){
3113
+ const lisviewDom = document.querySelector(".steedos-object-listview .antd-Table-table");
3114
+ if(lisviewDom){
3038
3115
  setTimeout(()=>{
3039
- firstListviewComponent.scrollIntoView();
3116
+ lisviewDom.scrollIntoView();
3040
3117
  }, 600);
3041
3118
  }
3042
3119
  }
@@ -4869,9 +4946,16 @@ const getSchema$2 = (uiSchema) => {
4869
4946
  "form": {
4870
4947
  debug: false,
4871
4948
  resetAfterSubmit: false,
4949
+ data: {
4950
+ editFormInited: true,
4951
+ },
4872
4952
  initApi: {
4953
+ method: 'GET',
4873
4954
  url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
4874
4955
  sendOn: 'this.recordId',
4956
+ data: null,
4957
+ requestAdaptor: "return api;",
4958
+ adaptor: "return payload;",
4875
4959
  responseData: {
4876
4960
  importState: "${state}"
4877
4961
  }
@@ -5743,7 +5827,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
5743
5827
  const formSchema = {
5744
5828
  "type": "service",
5745
5829
  "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
5746
- "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",
5830
+ "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",
5747
5831
  "style":{
5748
5832
  "max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
5749
5833
  },
@@ -6330,7 +6414,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6330
6414
  "className": "slds-filters"
6331
6415
  },
6332
6416
  "size": "xs",
6333
- "className": `border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
6417
+ "className": `border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
6334
6418
  "visibleOn": "this.showFieldsFilter",
6335
6419
  },
6336
6420
  "className": "bg-white"
@@ -6518,7 +6602,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6518
6602
  "icon": "fa fa-refresh",
6519
6603
  "actionType": "reload",
6520
6604
  "target": amisListViewId,
6521
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
6605
+ "className": "bg-white p-2 rounded text-gray-500"
6522
6606
  },
6523
6607
  fieldsFilterButtonSchema,
6524
6608
  // {
@@ -6526,7 +6610,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6526
6610
  // "label": "",
6527
6611
  // "icon": "fa fa-filter",
6528
6612
  // "actionType": "custom",
6529
- // "className": "bg-transparent p-2 rounded border-gray-300 text-gray-500",
6613
+ // "className": "bg-transparent p-2 rounded text-gray-500",
6530
6614
  // "id": "u:c20cb87d96c9",
6531
6615
  // "onEvent": {
6532
6616
  // "click": {
@@ -6574,7 +6658,7 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6574
6658
  let headerSchema = [{
6575
6659
  "type": "wrapper",
6576
6660
  "body": body,
6577
- "className": `bg-gray-100 sm:rounded-tl sm:rounded-tr p-4 -mb-4`
6661
+ "className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
6578
6662
  }];
6579
6663
  return headerSchema;
6580
6664
  }
@@ -6709,7 +6793,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6709
6793
  let body = [
6710
6794
  {
6711
6795
  "type": "wrapper",
6712
- "className": "p-4 bg-gray-100 border-b",
6796
+ "className": "p-4 border-b",
6713
6797
  "body": [
6714
6798
  {
6715
6799
  "type": "grid",
@@ -6774,25 +6858,25 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6774
6858
  });
6775
6859
 
6776
6860
  // 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
6777
- // xl:grid-cols-1
6778
- // xl:grid-cols-2
6779
- // xl:grid-cols-3
6780
- // xl:grid-cols-4
6781
- // xl:grid-cols-5
6782
- // xl:grid-cols-6
6783
- // xl:grid-cols-7
6784
- // xl:grid-cols-8
6785
- // xl:grid-cols-9
6786
- // xl:grid-cols-10
6787
- // xl:grid-cols-11
6788
- // xl:grid-cols-12
6861
+ // lg:grid-cols-1
6862
+ // lg:grid-cols-2
6863
+ // lg:grid-cols-3
6864
+ // lg:grid-cols-4
6865
+ // lg:grid-cols-5
6866
+ // lg:grid-cols-6
6867
+ // lg:grid-cols-7
6868
+ // lg:grid-cols-8
6869
+ // lg:grid-cols-9
6870
+ // lg:grid-cols-10
6871
+ // lg:grid-cols-11
6872
+ // lg:grid-cols-12
6789
6873
 
6790
6874
  body.push({
6791
6875
  "type": "wrapper",
6792
6876
  "body": {
6793
6877
  "type": "form",
6794
6878
  // "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
6795
- "className": `gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-${max}`,
6879
+ "className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
6796
6880
  "wrapWithPanel": false,
6797
6881
  "actions": [],
6798
6882
  "body": details,
@@ -6877,7 +6961,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
6877
6961
  "className": "flex justify-between"
6878
6962
  }
6879
6963
  ],
6880
- "className": "steedos-record-related-header py-2 px-0"
6964
+ "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
6881
6965
  };
6882
6966
  return recordRelatedListHeader;
6883
6967
  }
@@ -6920,6 +7004,7 @@ const getNewListviewButtonSchema = ()=>{
6920
7004
  "objectApiName": "object_listviews",
6921
7005
  "recordId": "",
6922
7006
  "mode": "edit",
7007
+ "layout": "normal",
6923
7008
  "defaultData": {
6924
7009
  "&": "${list_view}",
6925
7010
  "name":"",
@@ -6927,8 +7012,16 @@ const getNewListviewButtonSchema = ()=>{
6927
7012
  "filters":"",
6928
7013
  "shared":false,
6929
7014
  "object_name": "${targetObjectName}",
7015
+ "_id":"",
7016
+ "shared_to": null,
7017
+ "shared_to_organizations": null,
7018
+ "locked": false,
7019
+ "owner": null,
7020
+ "company_id": null,
7021
+ "company_ids": null,
7022
+ "is_system": false
6930
7023
  },
6931
- "fieldsExtend": fieldsExtend$4(),
7024
+ "fieldsExtend": fieldsExtend$5(),
6932
7025
  "fields": fields$1(),
6933
7026
  "onEvent": {
6934
7027
  "submitSucc": {
@@ -6979,14 +7072,17 @@ function fields$1(){
6979
7072
  "mobile_columns",
6980
7073
  "searchable_fields",
6981
7074
  "is_system",
6982
- "shared"
7075
+ "shared",
7076
+ "shared_to",
7077
+ "shared_to_organizations"
6983
7078
  ]
6984
7079
  }
6985
7080
 
6986
- function fieldsExtend$4(){
7081
+ function fieldsExtend$5(){
6987
7082
  return {
6988
7083
  "group": "",
6989
7084
  "label": {
7085
+ "group": "",
6990
7086
  "is_wide": true
6991
7087
  },
6992
7088
  "name": {
@@ -7068,9 +7164,19 @@ function fieldsExtend$4(){
7068
7164
  "shared": {
7069
7165
  "group": "",
7070
7166
  "amis": {
7071
- "visibleOn": "${global.user.is_space_admin}"
7167
+ "visibleOn": "${false}"
7168
+ }
7169
+ },
7170
+ "shared_to": {
7171
+ "group": "",
7172
+ "amis":{
7173
+ "type": "radios",
7174
+ "inline": false
7072
7175
  }
7073
7176
  },
7177
+ "shared_to_organizations": {
7178
+ "group": ""
7179
+ },
7074
7180
  "filters": {
7075
7181
  "group": "",
7076
7182
  "amis": {
@@ -7108,14 +7214,23 @@ const getCopyListviewButtonSchema = ()=>{
7108
7214
  "objectApiName": "object_listviews",
7109
7215
  "recordId": "",
7110
7216
  "mode": "edit",
7217
+ "layout": "normal",
7111
7218
  "defaultData": {
7112
7219
  "&": "${list_view}",
7113
7220
  "name":"",
7114
7221
  "label": i18next.t('frontend_listview_control_clone_defaultData_label_start') + " ${list_view.label} " + i18next.t('frontend_listview_control_clone_defaultData_label_end'),
7115
7222
  "shared":false,
7116
7223
  "object_name": "${targetObjectName}",
7224
+ "_id":"",
7225
+ "shared_to": null,
7226
+ "shared_to_organizations": null,
7227
+ "locked": false,
7228
+ "owner": null,
7229
+ "company_id": null,
7230
+ "company_ids": null,
7231
+ "is_system": false
7117
7232
  },
7118
- "fieldsExtend": fieldsExtend$3(),
7233
+ "fieldsExtend": fieldsExtend$4(),
7119
7234
  "fields": fields(),
7120
7235
  "onEvent": {
7121
7236
  "submitSucc": {
@@ -7163,13 +7278,16 @@ function fields(){
7163
7278
  "mobile_columns.$.field",
7164
7279
  "searchable_fields.$.field",
7165
7280
  "is_system",
7166
- "shared"
7281
+ "shared",
7282
+ "shared_to",
7283
+ "shared_to_organizations"
7167
7284
  ]
7168
7285
  }
7169
7286
 
7170
- function fieldsExtend$3(){
7287
+ function fieldsExtend$4(){
7171
7288
  return {
7172
7289
  "label": {
7290
+ "group": "",
7173
7291
  "is_wide": true
7174
7292
  },
7175
7293
  "name": {
@@ -7219,10 +7337,21 @@ function fieldsExtend$3(){
7219
7337
  }
7220
7338
  },
7221
7339
  "shared": {
7340
+ "group": "",
7222
7341
  "amis": {
7223
- "visibleOn": "${global.user.is_space_admin}"
7342
+ "visibleOn": "${false}"
7224
7343
  }
7225
7344
  },
7345
+ "shared_to": {
7346
+ "group": "",
7347
+ "amis":{
7348
+ "type": "radios",
7349
+ "inline": false
7350
+ }
7351
+ },
7352
+ "shared_to_organizations": {
7353
+ "group": ""
7354
+ },
7226
7355
  "filters": {
7227
7356
  "group": "",
7228
7357
  "amis": {
@@ -7232,6 +7361,12 @@ function fieldsExtend$3(){
7232
7361
  }
7233
7362
  }
7234
7363
 
7364
+ /*
7365
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
7366
+ * @Date: 2023-06-13 13:51:19
7367
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7368
+ * @LastEditTime: 2024-02-05 11:25:09
7369
+ */
7235
7370
  const getRenameListviewButtonSchema = ()=>{
7236
7371
  return {
7237
7372
  "type": "button",
@@ -7257,6 +7392,7 @@ const getRenameListviewButtonSchema = ()=>{
7257
7392
  "label": "对象表单",
7258
7393
  "objectApiName": "object_listviews",
7259
7394
  "recordId": "${recordId}",
7395
+ "layout": "normal",
7260
7396
  "mode": "edit",
7261
7397
  "fields": [
7262
7398
  "label"
@@ -7291,6 +7427,12 @@ const getRenameListviewButtonSchema = ()=>{
7291
7427
  }
7292
7428
  };
7293
7429
 
7430
+ /*
7431
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
7432
+ * @Date: 2023-06-13 13:51:19
7433
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7434
+ * @LastEditTime: 2024-02-06 15:38:49
7435
+ */
7294
7436
  const getSetListviewShareButtonSchema = ()=>{
7295
7437
  return {
7296
7438
  "type": "button",
@@ -7306,6 +7448,8 @@ const getSetListviewShareButtonSchema = ()=>{
7306
7448
  "title": i18next.t('frontend_listview_control_share'),
7307
7449
  "data": {
7308
7450
  "recordId": "${uiSchema.list_views[listName]._id}",
7451
+ "appId": "${appId}",
7452
+ "global": "${global}",
7309
7453
  "context": "${context}"
7310
7454
  },
7311
7455
  "body": [
@@ -7315,9 +7459,12 @@ const getSetListviewShareButtonSchema = ()=>{
7315
7459
  "objectApiName": "object_listviews",
7316
7460
  "recordId": "${recordId}",
7317
7461
  "mode": "edit",
7462
+ "layout": "normal",
7318
7463
  "fields": [
7319
- "shared"
7320
- ]
7464
+ "shared_to",
7465
+ "shared_to_organizations"
7466
+ ],
7467
+ "fieldsExtend": fieldsExtend$3(),
7321
7468
  }
7322
7469
  ],
7323
7470
  "showCloseButton": true,
@@ -7335,6 +7482,21 @@ const getSetListviewShareButtonSchema = ()=>{
7335
7482
  }
7336
7483
  };
7337
7484
 
7485
+ function fieldsExtend$3(){
7486
+ return {
7487
+ "shared_to": {
7488
+ "group": "",
7489
+ "amis":{
7490
+ "type": "radios",
7491
+ "inline": false
7492
+ }
7493
+ },
7494
+ "shared_to_organizations": {
7495
+ "group": ""
7496
+ }
7497
+ }
7498
+ }
7499
+
7338
7500
  const getSetListviewFiltersButtonSchema = ()=>{
7339
7501
  return {
7340
7502
  "type": "button",
@@ -7466,10 +7628,12 @@ function apiRequestAdaptor$2(){
7466
7628
  function fieldsExtend$2(){
7467
7629
  return {
7468
7630
  "filters": {
7631
+ "label": "",
7632
+ "group": "",
7469
7633
  "visible_on": "true",
7470
7634
  "amis": {
7471
7635
  "type": "condition-builder",
7472
- "label": i18next.t('frontend_listview_control_filters_fields_extend'),
7636
+ // "label": i18next.t('frontend_listview_control_filters_fields_extend'),
7473
7637
  "source": {
7474
7638
  "method": "get",
7475
7639
  "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
@@ -7512,6 +7676,7 @@ const getSetListviewColumnsButtonSchema = ()=>{
7512
7676
  "objectApiName": "object_listviews",
7513
7677
  "recordId": "${recordId}",
7514
7678
  "mode": "edit",
7679
+ "layout": "normal",
7515
7680
  "fieldsExtend": fieldsExtend$1(),
7516
7681
  "initApiAdaptor": initApiAdaptor$1(),
7517
7682
  "apiRequestAdaptor": apiRequestAdaptor$1(),
@@ -7708,6 +7873,8 @@ const getSetListviewSortButtonSchema = ()=>{
7708
7873
  function fieldsExtend(){
7709
7874
  return {
7710
7875
  "sort": {
7876
+ "label": "",
7877
+ "group": "",
7711
7878
  "amis": {
7712
7879
  "type": "tabs-transfer",
7713
7880
  "sortable": true,
@@ -7835,7 +8002,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
7835
8002
  "icon": "fa fa-cog",
7836
8003
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7837
8004
  // "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
7838
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
8005
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
7839
8006
  "align": "right",
7840
8007
  "visibleOn": "${!isLookup}",
7841
8008
  "buttons": [
@@ -7856,8 +8023,8 @@ const getSettingListviewToolbarButtonSchema = ()=>{
7856
8023
  }
7857
8024
  };
7858
8025
 
7859
- const getDisplayAsButton = function(objectName, showDisplayAs){
7860
- let displayAs = Router$1.getTabDisplayAs(objectName);
8026
+ const getDisplayAsButton = function(objectName, defaultEnableSplit){
8027
+ let displayAs = Router$1.getTabDisplayAs(objectName, defaultEnableSplit);
7861
8028
  let buttons = [
7862
8029
  {
7863
8030
  "type": "button",
@@ -7880,7 +8047,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7880
8047
  "icon": "fa fa-table-columns",
7881
8048
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7882
8049
  // "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
7883
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500",
8050
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
7884
8051
  "align": "right",
7885
8052
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
7886
8053
  "buttons": [
@@ -8073,7 +8240,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8073
8240
  // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8074
8241
  // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8075
8242
  // "tooltipPlacement": "top",
8076
- // "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8243
+ // "className": "bg-white p-2 rounded text-gray-500",
8077
8244
  // "label": "",
8078
8245
  // "icon": "fa fa-sync",
8079
8246
  // "visibleOn": "${!showFieldsFilter}",
@@ -8097,7 +8264,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8097
8264
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8098
8265
  "tooltip":"",
8099
8266
  "tooltipPlacement": "top",
8100
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8267
+ "className": "bg-white p-2 rounded text-gray-500"
8101
8268
  };
8102
8269
  }
8103
8270
  else {
@@ -8108,7 +8275,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8108
8275
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8109
8276
  "tooltip":"",
8110
8277
  "tooltipPlacement": "top",
8111
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8278
+ "className": "bg-white p-2 rounded text-gray-500"
8112
8279
  };
8113
8280
  }
8114
8281
  let toolbarFilter;
@@ -8130,7 +8297,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8130
8297
  "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
8131
8298
  },
8132
8299
  "align": "right",
8133
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8300
+ "className": "bg-white p-2 rounded text-gray-500",
8134
8301
  "onEvent": {
8135
8302
  "click": {
8136
8303
  "actions": [
@@ -8144,7 +8311,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8144
8311
  "id": "steedos_crud_toolbar_filter"
8145
8312
  };
8146
8313
  }
8147
- let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name);
8314
+ let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name, mainObject?.enable_split);
8148
8315
  let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName });
8149
8316
 
8150
8317
  // toolbars返回的数组元素不可以是空对象{},比如hiddenCount ? {} : {"type": "tpl",...},因为空对象最终还是会生成一个空的.antd-Crud-toolbar-item dom
@@ -8290,7 +8457,6 @@ async function getObjectFilter(objectSchema, fields, options) {
8290
8457
  "timeOut": 1000
8291
8458
  }
8292
8459
  });
8293
- resizeWindow();
8294
8460
  const scope = event.context.scoped;
8295
8461
  // let filterFormValues = event.data;
8296
8462
  let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
@@ -8457,7 +8623,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8457
8623
  const bodyProps = {
8458
8624
  // toolbar: getToolbar(),
8459
8625
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
8460
- headerToolbarClassName: "px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",
8626
+ headerToolbarClassName: "px-4 py-2 border-b",
8461
8627
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
8462
8628
  ...options,
8463
8629
  disableStatistics: options.queryCount === false
@@ -8604,14 +8770,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8604
8770
  headers: {
8605
8771
  Authorization: "Bearer ${context.tenantId},${context.authToken}",
8606
8772
  },
8607
- requestAdaptor: quickSaveApiRequestAdaptor,
8608
- adaptor: `
8609
- if(payload.errors){
8610
- payload.status = 2;
8611
- payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8612
- }
8613
- return payload;
8614
- `
8773
+ requestAdaptor: quickSaveApiRequestAdaptor
8615
8774
  },
8616
8775
  // 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
8617
8776
  // 使用表达式给tr添加初始选中状态
@@ -8628,6 +8787,20 @@ async function getObjectCRUD(objectSchema, fields, options){
8628
8787
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8629
8788
  }
8630
8789
 
8790
+ body.quickSaveApi.adaptor = `
8791
+ if(payload.errors){
8792
+ payload.status = 2;
8793
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8794
+ }
8795
+ var scope = SteedosUI.getRef(context.scopeId);
8796
+ var scopeParent = scope && scope.parent;
8797
+ var crudScoped = scopeParent.getComponentById('${body.id}');
8798
+ setTimeout(()=>{
8799
+ crudScoped && crudScoped.control.updateAutoFillHeight();
8800
+ }, 500);
8801
+ return payload;
8802
+ `;
8803
+
8631
8804
  if(body.columns && options.formFactor != 'SMALL'){
8632
8805
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8633
8806
  body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
@@ -8992,8 +9165,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8992
9165
  /*
8993
9166
  * @Author: baozhoutao@steedos.com
8994
9167
  * @Date: 2022-07-05 15:55:39
8995
- * @LastEditors: baozhoutao@steedos.com
8996
- * @LastEditTime: 2024-01-15 10:34:46
9168
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9169
+ * @LastEditTime: 2024-02-08 16:10:52
8997
9170
  * @Description:
8998
9171
  */
8999
9172
 
@@ -9092,7 +9265,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9092
9265
  const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9093
9266
  mainRelated[arr[0]] = foreign_key_value;
9094
9267
  }
9095
- }else {
9268
+ }
9269
+ // 防止related_lists中没有相关子表,但是details中有相关子表的情况
9270
+ if(!mainRelated[relatedObjectName]){
9096
9271
  const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
9097
9272
  for (const detail of details) {
9098
9273
  const arr = detail.split(".");
@@ -9108,19 +9283,6 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9108
9283
  let globalFilter = null;
9109
9284
  // TODO: refField变量去掉,写到amis运行时脚本中,uiSchema.fields[relatedKey];可以取到
9110
9285
  const refField = await getField(relatedObjectName, relatedKey);
9111
-
9112
- if(!refField){
9113
- return {
9114
- uiSchema: relatedObjectUiSchema,
9115
- amisSchema: {
9116
- "type": "alert",
9117
- "body": `${i18next.t('frontend_objects_related_alert_start')} ${relatedObjectName} ${i18next.t('frontend_objects_related_alert_end')}`,
9118
- "level": "warning",
9119
- "showIcon": true,
9120
- "className": "mb-3"
9121
- }
9122
- }
9123
- }
9124
9286
  // if(refField.reference_to_field && refField.reference_to_field != '_id'){
9125
9287
  // const masterRecord = await getRecord(objectName, recordId, [refField.reference_to_field]);
9126
9288
  // relatedValue = masterRecord[refField.reference_to_field]
@@ -9181,7 +9343,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9181
9343
  amisSchema: {
9182
9344
  type: "service",
9183
9345
  id: componentId,
9184
- className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
9346
+ className: `steedos-record-related-list mb-4 last:mb-0 ${componentId} ${className}`,
9185
9347
  data: {
9186
9348
  relatedKey: relatedKey,
9187
9349
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
@@ -9364,7 +9526,10 @@ async function getRelatedListSchema(
9364
9526
  "filterVisible": false,
9365
9527
  "requestAdaptor": ctx.requestAdaptor,
9366
9528
  "adaptor": adaptor + ctx.adaptor || '',
9367
- "ctx": ctx
9529
+ "ctx": ctx,
9530
+ "crud": ctx.crud,
9531
+ "crudDataFilter": ctx.crudDataFilter,
9532
+ "onCrudDataFilter": ctx.onCrudDataFilter
9368
9533
  };
9369
9534
  // console.log(`getRelatedListSchema amisSchema`, amisSchema);
9370
9535
  return {
@@ -9409,8 +9574,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9409
9574
  /*
9410
9575
  * @Author: baozhoutao@steedos.com
9411
9576
  * @Date: 2022-07-05 15:55:39
9412
- * @LastEditors: baozhoutao@steedos.com
9413
- * @LastEditTime: 2024-01-16 11:14:34
9577
+ * @LastEditors: liaodaxue
9578
+ * @LastEditTime: 2024-02-05 17:56:27
9414
9579
  * @Description:
9415
9580
  */
9416
9581
 
@@ -9766,6 +9931,8 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
9766
9931
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
9767
9932
  const rfFieldInfo = rfUiSchema.fields[displayName];
9768
9933
  fields.push(Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx));
9934
+ }else if(filedInfo && filedInfo.type === 'object'){
9935
+ fields.push(uiSchema.fields[column]);
9769
9936
  }
9770
9937
  } else {
9771
9938
  if (uiSchema.fields[column]) {
@@ -9927,7 +10094,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9927
10094
  };
9928
10095
  const content = {
9929
10096
  "type": "tabs",
9930
- "className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
10097
+ "className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
9931
10098
  "contentClassName": "bg-none",
9932
10099
  "tabs": [
9933
10100
  detailed
@@ -10628,17 +10795,13 @@ function getReferenceToSync(field) {
10628
10795
 
10629
10796
  function getLookupSapceUserTreeSchema(isMobile){
10630
10797
  let apiAdaptor = `
10631
- // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10632
10798
  const records = payload.data.options;
10633
- let isTreeOptionsComputed = false;
10634
- if(records.length === 1 && records[0].children){
10635
- isTreeOptionsComputed = true;
10636
- }
10637
- if(isTreeOptionsComputed){
10638
- return payload;
10639
- }
10640
10799
  const treeRecords = [];
10641
- const getChildren = (records, childrenIds) => {
10800
+ const getChildren = (currentRecord, records, childrenIds) => {
10801
+ if (currentRecord.children && typeof currentRecord.children[0] === "object") {
10802
+ // 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
10803
+ return currentRecord.children;
10804
+ }
10642
10805
  if (!childrenIds) {
10643
10806
  return;
10644
10807
  }
@@ -10647,7 +10810,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10647
10810
  });
10648
10811
  _.each(children, (item) => {
10649
10812
  if (item.children) {
10650
- item.children = getChildren(records, item.children)
10813
+ item.children = getChildren(item, records, item.children)
10651
10814
  }else{
10652
10815
  item.children = [];
10653
10816
  }
@@ -10673,7 +10836,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10673
10836
 
10674
10837
  _.each(records, (record) => {
10675
10838
  if (record.noParent == 1) {
10676
- treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10839
+ treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
10677
10840
  }
10678
10841
  });
10679
10842
  console.log(treeRecords)
@@ -10723,6 +10886,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10723
10886
  }
10724
10887
  },
10725
10888
  "label": "",
10889
+ "mode": "normal",
10726
10890
  "name": "organizations",
10727
10891
  "multiple": false,
10728
10892
  "joinValues": false,
@@ -10865,6 +11029,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
10865
11029
  }
10866
11030
  });
10867
11031
 
11032
+ let listviewFilter = getListViewFilter(listView);
11033
+ let listviewFiltersFunction = listView && listView._filters;
11034
+
10868
11035
  let sort = "";
10869
11036
  if(listView){
10870
11037
  sort = getListViewSort(listView);
@@ -10911,7 +11078,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10911
11078
  Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
10912
11079
  }
10913
11080
  const selfData = JSON.parse(JSON.stringify(api.data.$self));
10914
- var filters = [];
11081
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
10915
11082
  var pageSize = api.data.pageSize || 10;
10916
11083
  var pageNo = api.data.pageNo || 1;
10917
11084
  var skip = (pageNo - 1) * pageSize;
@@ -10973,6 +11140,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
10973
11140
  }
10974
11141
 
10975
11142
  const inFilterForm = ${ctx.inFilterForm};
11143
+
11144
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11145
+
11146
+ if(listviewFiltersFunction && !inFilterForm){
11147
+ const _filters0 = listviewFiltersFunction(filters, api.data.$self.__super);
11148
+ if(_filters0 && _filters0.length){
11149
+ filters.push(_filters0);
11150
+ }
11151
+ }
11152
+
10976
11153
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
10977
11154
 
10978
11155
  if(filtersFunction && !inFilterForm){
@@ -11060,6 +11237,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
11060
11237
  });
11061
11238
  payload.data.rows = treeRecords;
11062
11239
  }
11240
+ const result = payload.data.rows;
11241
+ if(result && result.length){
11242
+ const updatedResult = _.map(result, (element) => {
11243
+ const data = { ...element };
11244
+ // image字段值添加URL前缀
11245
+ ${getScriptForAddUrlPrefixForImgFields(_$1.values(refObjectConfig.fields))}
11246
+ return data;
11247
+ });
11248
+ payload.data.rows = updatedResult;
11249
+ }
11063
11250
  return payload;
11064
11251
  `;
11065
11252
  if(field.optionsFunction || field._optionsFunction){
@@ -11091,13 +11278,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
11091
11278
 
11092
11279
  pickerSchema.affixHeader = false;
11093
11280
 
11094
- var headerToolbarItems = [];
11281
+
11282
+
11283
+ pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { isLookup: true, keywordsSearchBoxName });
11284
+
11095
11285
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
11096
- headerToolbarItems = getLookupSapceUserTreeSchema(isMobile);
11286
+ pickerSchema.headerToolbar.push(getLookupSapceUserTreeSchema(isMobile));
11097
11287
  pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
11098
11288
  }
11099
-
11100
- pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { headerToolbarItems, isLookup: true, keywordsSearchBoxName });
11289
+
11101
11290
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
11102
11291
  const isCreate = _$1.isBoolean(field.create) ? field.create : true;
11103
11292
  // lookup字段配置过滤条件就强制不显示新建按钮
@@ -11210,8 +11399,19 @@ async function lookupToAmisPicker(field, readonly, ctx){
11210
11399
  pickerSchema.footerToolbar = ["pagination"];
11211
11400
  }
11212
11401
 
11402
+ if(field.inlineHelpText){
11403
+ pickerSchema.toolbarClassName = "hasHelpText";
11404
+ pickerSchema.headerToolbar = [{
11405
+ "type": "tpl",
11406
+ "tpl": field.inlineHelpText,
11407
+ "className": "text-secondary"
11408
+ }, ...pickerSchema.headerToolbar];
11409
+ }
11410
+ pickerSchema.className = (pickerSchema.className || "") + " steedos-lookup-crud";
11411
+
11213
11412
  const data = {
11214
11413
  type: getAmisStaticFieldType('picker', readonly),
11414
+ className: ctx.className || '',
11215
11415
  modalTitle: i18next.t('frontend_form_please_select') + " " + refObjectConfig.label,
11216
11416
  labelField: referenceTo.labelField.name,
11217
11417
  valueField: referenceTo.valueField.name,
@@ -11285,6 +11485,9 @@ async function lookupToAmisSelect(field, readonly, ctx){
11285
11485
  const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
11286
11486
  let listView = getLookupListView(refObjectConfig);
11287
11487
 
11488
+ let listviewFilter = getListViewFilter(listView);
11489
+ let listviewFiltersFunction = listView && listView._filters;
11490
+
11288
11491
  let sort = "";
11289
11492
  if(listView){
11290
11493
  sort = getListViewSort(listView);
@@ -11314,7 +11517,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11314
11517
  apiInfo.data['rfield'] = `\${object_name}`;
11315
11518
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
11316
11519
  apiInfo.requestAdaptor = `
11317
- var filters = [];
11520
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
11318
11521
  var top = 200;
11319
11522
  if(api.data.$term){
11320
11523
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
@@ -11337,6 +11540,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
11337
11540
  }
11338
11541
 
11339
11542
  const inFilterForm = ${ctx.inFilterForm};
11543
+
11544
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11545
+
11546
+ if(listviewFiltersFunction && !inFilterForm){
11547
+ const _filters0 = listviewFiltersFunction(filters, api.data.$);
11548
+ if(_filters0 && _filters0.length){
11549
+ filters.push(_filters0);
11550
+ }
11551
+ }
11552
+
11340
11553
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
11341
11554
 
11342
11555
  if(filtersFunction && !inFilterForm){
@@ -11413,6 +11626,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11413
11626
  // 但是同时配置autoComplete和source会多请求一次接口
11414
11627
  // TODO:应该想办法把是否字段在子表组件内,即ctx.isInputTable,如果不在子表组件内不需要加source
11415
11628
  data.source = apiInfo;
11629
+ delete data.autoComplete;
11416
11630
  }
11417
11631
  //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
11418
11632
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
@@ -11459,7 +11673,8 @@ async function lookupToAmis(field, readonly, ctx){
11459
11673
  }
11460
11674
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11461
11675
  if(readonly){
11462
- if(field.reference_to){
11676
+ if(field.reference_to && !field.isTableField){
11677
+ //isTableField只在grid字段内存在
11463
11678
  return {
11464
11679
  type: 'steedos-field',
11465
11680
  config: field,
@@ -11674,8 +11889,8 @@ if(typeof window != 'undefined'){
11674
11889
  /*
11675
11890
  * @Author: baozhoutao@steedos.com
11676
11891
  * @Date: 2023-01-13 17:27:54
11677
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
11678
- * @LastEditTime: 2023-08-28 17:45:38
11892
+ * @LastEditors: liaodaxue
11893
+ * @LastEditTime: 2024-02-04 17:29:54
11679
11894
  * @Description:
11680
11895
  */
11681
11896
 
@@ -11776,7 +11991,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
11776
11991
  "title": "Insert",
11777
11992
  "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
11778
11993
  }
11779
- }
11994
+ },
11995
+ "statusbar": false
11780
11996
  },
11781
11997
  "name": field.name
11782
11998
  }
@@ -12121,13 +12337,31 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12121
12337
  };
12122
12338
  break;
12123
12339
  case 'input-datetime-range':
12340
+ // convertData = {
12341
+ // type: "input-datetime-range",
12342
+ // inputFormat: 'YYYY-MM-DD HH:mm',
12343
+ // format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
12344
+ // tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
12345
+ // utc: true,
12346
+ // joinValues: false
12347
+ // }
12348
+ // 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
12124
12349
  convertData = {
12125
- type: "input-datetime-range",
12126
- inputFormat: 'YYYY-MM-DD HH:mm',
12350
+ type: "input-date-range",
12351
+ inputFormat: "YYYY-MM-DD HH:mm",
12127
12352
  format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
12128
12353
  tpl: readonly ? getDateTimeTpl(field) : null,
12129
12354
  utc: true,
12130
- joinValues: false
12355
+ joinValues: false,
12356
+ "shortcuts": [
12357
+ "thismonth",
12358
+ "2monthsago",
12359
+ "3monthslater",
12360
+ "prevquarter",
12361
+ "thisquarter",
12362
+ "thisyear",
12363
+ "lastYear"
12364
+ ]
12131
12365
  };
12132
12366
  break;
12133
12367
  case 'datetime':
@@ -12178,7 +12412,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12178
12412
  convertData = {
12179
12413
  type: getAmisStaticFieldType('datetime', readonly),
12180
12414
  inputFormat: 'YYYY-MM-DD HH:mm',
12181
- format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
12415
+ format: 'YYYY-MM-DDTHH:mm:00.000Z',
12182
12416
  tpl: readonly ? getDateTimeTpl(field) : null,
12183
12417
  utc: true,
12184
12418
  };
@@ -12309,6 +12543,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12309
12543
  convertData = {
12310
12544
  type: 'static-text'
12311
12545
  };
12546
+ }else if(field.autonumber_enable_modify){
12547
+ convertData = {
12548
+ "type": "input-group",
12549
+ "body": [
12550
+ {
12551
+ "type": "input-text",
12552
+ "name": field.name
12553
+ },
12554
+ {
12555
+ "type": "button",
12556
+ "label": "自动获取",
12557
+ "actionType": "ajax",
12558
+ "api": {
12559
+ "url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
12560
+ "method": "post",
12561
+ "headers": {
12562
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
12563
+ },
12564
+ "adaptor": `
12565
+ payload.data["${field.name}"] = payload.data && payload.data.autonumber;
12566
+ delete payload.data.autonumber;
12567
+ return payload;
12568
+ `
12569
+ },
12570
+ "messages": {
12571
+ "success": "获取成功"
12572
+ }
12573
+ }
12574
+ ]
12575
+ };
12312
12576
  }
12313
12577
  break;
12314
12578
  case 'url':
@@ -12514,12 +12778,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12514
12778
  break;
12515
12779
  }
12516
12780
  if(!_$1.isEmpty(convertData)){
12781
+ const className = convertData.className;
12517
12782
  if(field.is_wide || convertData.type === 'group'){
12518
- convertData.className = 'col-span-2 m-0';
12783
+ convertData.className = className ? 'col-span-2 m-0 ' + className : 'col-span-2 m-0';
12519
12784
  }else {
12520
- convertData.className = 'm-0';
12785
+ convertData.className = className ? 'm-0 ' + className : 'm-0';
12521
12786
  }
12522
- if(readonly){
12787
+ if(readonly && ctx.mode !== 'edit'){
12523
12788
  convertData.className = `${convertData.className} border-b`;
12524
12789
  }
12525
12790
  if(readonly){
@@ -12527,11 +12792,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12527
12792
  }
12528
12793
 
12529
12794
  let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
12530
- if (convertData.className) {
12531
- convertData.className = convertData.className + fieldTypeClassName;
12532
- } else {
12533
- convertData.className = fieldTypeClassName;
12534
- }
12795
+ convertData.className = convertData.className + fieldTypeClassName;
12535
12796
 
12536
12797
  if(field.visible_on && !ctx.inFilterForm){
12537
12798
  // convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
@@ -12614,8 +12875,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
12614
12875
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12615
12876
  }
12616
12877
  if(_field.type === 'datetime'){
12617
- // 特意改为日期范围而不是日期时间范围,因为搜索时一般精确到日期就足够了,需要精确到日期时间范围需要在字段上配置amis属性来实现
12618
- _field.type = 'input-date-range';
12878
+ // 这里如果想把搜索范围展示效果改为日期范围,不可以直接改为input-date-range,因为它们规则不一样,包括时区规则和小时分秒的存值规则都不一样
12879
+ // 所以想改为展示日期范围效果,只能改input-datetime-range类型本身的属性来实现
12880
+ _field.type = 'input-datetime-range';
12619
12881
  _field.is_wide = true;
12620
12882
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12621
12883
  }
@@ -12801,6 +13063,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
12801
13063
  }
12802
13064
  }
12803
13065
 
13066
+ fieldSetBody.forEach((field)=>{
13067
+ //判断label是否存在,不存在时将label的空占位元素隐藏
13068
+ if(!field.label){
13069
+ field.labelClassName = "none";
13070
+ }
13071
+ });
13072
+
12804
13073
  // fieldSet 已支持显隐控制
12805
13074
  const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
12806
13075
  let visible = visibleOn;
@@ -12923,12 +13192,130 @@ async function getFormBody(permissionFields, formFields, ctx){
12923
13192
  return await getSections(permissionFields, formFields, ctx);
12924
13193
  }
12925
13194
 
13195
+ /*
13196
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
13197
+ * @Date: 2024-01-18 15:12:41
13198
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13199
+ * @LastEditTime: 2024-01-18 15:12:49
13200
+ */
13201
+ /**
13202
+ * 生成符合标准uuid格式的36位满足唯一性的随机串
13203
+ * @returns uuid
13204
+ */
13205
+ function uuidv4() {
13206
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
13207
+ (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
13208
+ );
13209
+ }
13210
+
12926
13211
  /*
12927
13212
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12928
13213
  * @Date: 2023-11-15 09:50:22
12929
13214
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12930
- * @LastEditTime: 2024-01-18 10:29:57
13215
+ * @LastEditTime: 2024-01-26 17:47:16
13216
+ */
13217
+
13218
+ /**
13219
+ * 子表组件字段值中每行数据补上字段值为空的的字段值,把值统一设置为空字符串,是为了解决amis amis 3.6/6.0 input-table组件bug:行中字段值为空时会显示为父作用域中的同名变量值,见:https://github.com/baidu/amis/issues/9520
13220
+ * amis #9520修正后此函数及相关代码可以移除
13221
+ * @param {*} value 子表组件字段值,数组
13222
+ * @param {*} fields 子表组件fields属性,数组
13223
+ * @returns 转换后的子表组件字段值
13224
+ */
13225
+ function getTableValueWithEmptyValue(value, fields) {
13226
+ return (value || []).map((itemValue) => {
13227
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里字段值会被改了
13228
+ const newItemValue = clone(itemValue);
13229
+ (fields || []).forEach((itemField) => {
13230
+ if(itemField.name && (newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13231
+ // 这里newItemValue中不存在 itemField.name 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
13232
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
13233
+ newItemValue[itemField.name] = "";
13234
+ }
13235
+ if (newItemValue.children) {
13236
+ newItemValue.children = getTableValueWithEmptyValue(newItemValue.children, fields);
13237
+ }
13238
+ });
13239
+ return newItemValue;
13240
+ });
13241
+ }
13242
+
13243
+ /**
13244
+ * 把子表组件字段值中每行数据中经过上面getTableValueWithEmptyValue函数空字段值移除
13245
+ * amis #9520修正后此函数及相关代码可以移除
13246
+ * @param {*} value 子表组件字段值,数组
13247
+ * @param {*} fields 子表组件fields属性,数组
13248
+ * @returns 转换后的子表组件字段值
13249
+ */
13250
+ function getTableValueWithoutEmptyValue(value, fields) {
13251
+ return (value || []).map((itemValue) => {
13252
+ const newItemValue = clone(itemValue);
13253
+ (fields || []).forEach((itemField) => {
13254
+ if(itemField.name && (newItemValue[itemField.name] === "" || newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13255
+ // 这里额外把null和undefined值也删除掉纯粹是没必要输出保存它们
13256
+ delete newItemValue[itemField.name];
13257
+ }
13258
+ if (newItemValue.children) {
13259
+ newItemValue.children = getTableValueWithoutEmptyValue(newItemValue.children, fields);
13260
+ }
13261
+ });
13262
+ return newItemValue;
13263
+ });
13264
+ }
13265
+
13266
+ function getTablePrimaryKey(props) {
13267
+ return props.primaryKey || "_id";
13268
+ }
13269
+
13270
+ /**
13271
+ * 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
13272
+ * @param {*} value 子表组件字段值,数组
13273
+ * @param {*} primaryKey 主键字段名,一般为_id
13274
+ * @returns 转换后的子表组件字段值
13275
+ */
13276
+ function getTableValueWithPrimaryKeyValue(value, primaryKey) {
13277
+ if (!primaryKey) {
13278
+ return value;
13279
+ }
13280
+ return (value || []).map((itemValue) => {
13281
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
13282
+ const newItemValue = clone(itemValue);
13283
+ if (newItemValue[primaryKey]) {
13284
+ if (newItemValue.children) {
13285
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13286
+ }
13287
+ return newItemValue;
13288
+ }
13289
+ else {
13290
+ newItemValue[primaryKey] = uuidv4();
13291
+ if (newItemValue.children) {
13292
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13293
+ }
13294
+ return newItemValue;
13295
+ }
13296
+ });
13297
+ }
13298
+
13299
+ /**
13300
+ * 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
13301
+ * @param {*} value 子表组件字段值,数组
13302
+ * @param {*} primaryKey 主键字段名,一般为_id
13303
+ * @returns 转换后的子表组件字段值
12931
13304
  */
13305
+ function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
13306
+ if (!primaryKey) {
13307
+ return value;
13308
+ }
13309
+ return (value || []).map((itemValue) => {
13310
+ //这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
13311
+ const newItemValue = clone(itemValue);
13312
+ if (newItemValue.children) {
13313
+ newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
13314
+ }
13315
+ delete newItemValue[primaryKey];
13316
+ return newItemValue;
13317
+ });
13318
+ }
12932
13319
 
12933
13320
  /**
12934
13321
  * 子表组件字段值中每行数据的键值key移除指定前缀
@@ -12936,12 +13323,14 @@ async function getFormBody(permissionFields, formFields, ctx){
12936
13323
  * @param {*} fieldPrefix 字段前缀
12937
13324
  * @returns 转换后的子表组件字段值
12938
13325
  */
12939
- function getTableValueWithoutFieldPrefix(value, fieldPrefix){
13326
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
12940
13327
  let convertedValue = [];
12941
- (value || []).forEach((itemValue)=>{
13328
+ (value || []).forEach((itemValue) => {
12942
13329
  var newItemValue = {};
12943
- for(let n in itemValue){
12944
- newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13330
+ for (let n in itemValue) {
13331
+ if (itemValue.hasOwnProperty(n)) {
13332
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13333
+ }
12945
13334
  }
12946
13335
  convertedValue.push(newItemValue);
12947
13336
  });
@@ -12952,17 +13341,21 @@ function getTableValueWithoutFieldPrefix(value, fieldPrefix){
12952
13341
  * 子表组件字段值中每行数据的键值key补上指定前缀
12953
13342
  * @param {*} value 子表组件字段值,数组
12954
13343
  * @param {*} fieldPrefix 字段前缀
13344
+ * @param {*} primaryKey 主键字段名,主键不参与被键值key规则,需要排除,审批王amis表单也是这个规则
12955
13345
  * @returns 转换后的子表组件字段值
12956
13346
  */
12957
- function getTableValuePrependFieldPrefix(value, fieldPrefix){
13347
+ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
12958
13348
  let convertedValue = [];
12959
- (value || []).forEach((itemValue)=>{
13349
+ (value || []).forEach((itemValue) => {
12960
13350
  var newItemValue = {};
12961
- for(let n in itemValue){
12962
- if(typeof itemValue[n] !== undefined){
13351
+ for (let n in itemValue) {
13352
+ if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
12963
13353
  newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
12964
13354
  }
12965
13355
  }
13356
+ if (primaryKey && itemValue[primaryKey]) {
13357
+ newItemValue[primaryKey] = itemValue[primaryKey];
13358
+ }
12966
13359
  convertedValue.push(newItemValue);
12967
13360
  });
12968
13361
  return convertedValue;
@@ -12974,7 +13367,7 @@ function getTableValuePrependFieldPrefix(value, fieldPrefix){
12974
13367
  * @param {*} fieldPrefix 字段前缀
12975
13368
  * @returns 转换后的子表组件字段值
12976
13369
  */
12977
- function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
13370
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
12978
13371
  return (fields || []).map((item) => {
12979
13372
  const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
12980
13373
  newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
@@ -12987,7 +13380,12 @@ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
12987
13380
  * @param {*} mode edit/new/readonly
12988
13381
  */
12989
13382
  function getFormFields(props, mode = "edit") {
12990
- return (props.fields || []).map(function (item) {
13383
+ let fieldPrefix = props.fieldPrefix;
13384
+ let fields = props.fields || [];
13385
+ if (fieldPrefix) {
13386
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13387
+ }
13388
+ return (fields || []).map(function (item) {
12991
13389
  let formItem = {
12992
13390
  "type": "steedos-field",
12993
13391
  "name": item.name,
@@ -13007,6 +13405,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
13007
13405
  name: field.name,
13008
13406
  quickEdit: {
13009
13407
  "type": "steedos-field",
13408
+ "mode": "inline",
13010
13409
  "config": Object.assign({}, field, {
13011
13410
  label: false
13012
13411
  })
@@ -13059,7 +13458,12 @@ async function getInputTableColumns(props) {
13059
13458
  let inlineEditMode = props.inlineEditMode;
13060
13459
  let showAsInlineEditMode = inlineEditMode && props.editable;
13061
13460
  // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
13062
- let fields = props.fields;
13461
+
13462
+ let fieldPrefix = props.fieldPrefix;
13463
+ let fields = props.fields || [];
13464
+ if (fieldPrefix) {
13465
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13466
+ }
13063
13467
  if (columns && columns.length) {
13064
13468
  return columns.map(function (column) {
13065
13469
  let field, extendColumnProps = {};
@@ -13081,8 +13485,26 @@ async function getInputTableColumns(props) {
13081
13485
  }
13082
13486
  }
13083
13487
  if (field) {
13084
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13085
- return Object.assign({}, tableCell, extendColumnProps);
13488
+ let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
13489
+ extendColumnProps.inlineEditMode : showAsInlineEditMode;
13490
+ let tableCell = getInputTableCell(field, mode);
13491
+ let className = "";
13492
+ //判断是否换行,目前规则默认换行
13493
+ if(extendColumnProps.wrap != true){
13494
+ className += " whitespace-nowrap ";
13495
+ }else {
13496
+ className += " break-words ";
13497
+ }
13498
+ //合并classname
13499
+ if (typeof extendColumnProps.className == "object") {
13500
+ className = {
13501
+ [className]: "true",
13502
+ ...extendColumnProps.className
13503
+ };
13504
+ } else if (typeof extendColumnProps.className == "string") {
13505
+ className = `${className} ${extendColumnProps.className} `;
13506
+ }
13507
+ return Object.assign({}, tableCell, extendColumnProps, {className});
13086
13508
  }
13087
13509
  else {
13088
13510
  return column;
@@ -13092,6 +13514,7 @@ async function getInputTableColumns(props) {
13092
13514
  else {
13093
13515
  return fields.map(function (field) {
13094
13516
  let tableCell = getInputTableCell(field, showAsInlineEditMode);
13517
+ tableCell.className = " whitespace-nowrap ";
13095
13518
  return tableCell;
13096
13519
  }) || [];
13097
13520
  }
@@ -13104,7 +13527,7 @@ async function getInputTableColumns(props) {
13104
13527
  */
13105
13528
  function getFormPagination(props, mode) {
13106
13529
  let showPagination = true;
13107
- if(mode === "new" && !!!props.editable){
13530
+ if (mode === "new" && !!!props.editable) {
13108
13531
  //不允许编辑只允许新建时不应该让用户操作翻页
13109
13532
  showPagination = false;
13110
13533
  }
@@ -13120,35 +13543,41 @@ function getFormPagination(props, mode) {
13120
13543
  let __formId = "${formId}";
13121
13544
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13122
13545
  let pageChangeDirection = context.props.pageChangeDirection;
13546
+ let mode = "${mode}";
13123
13547
  // event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
13124
13548
  // 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
13125
13549
  // 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
13126
13550
  // let currentPage = currentIndex + 1;
13127
13551
  let currentPage = event.data.__page;
13128
13552
  let currentIndex = event.data.index;
13129
- // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13130
- let currentFormValues = scope.getComponentById(__formId).getValues();
13131
- var parent = event.data.parent;
13132
- var __parentIndex = event.data.__parentIndex;
13133
- if(parent){
13134
- fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13135
- // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13136
- fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13137
- children: fieldValue[__parentIndex].children,
13138
- __fix_rerender_after_children_modified_tag: new Date().getTime()
13553
+ if(mode !== "readonly"){
13554
+ // 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
13555
+ // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13556
+ let currentFormValues = scope.getComponentById(__formId).getValues();
13557
+ // 这里不clone的话,其值会带上__super属性
13558
+ currentFormValues = _.clone(currentFormValues);
13559
+ var parent = event.data.parent;
13560
+ var __parentIndex = event.data.__parentIndex;
13561
+ if(parent){
13562
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13563
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13564
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13565
+ children: fieldValue[__parentIndex].children,
13566
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13567
+ });
13568
+ }
13569
+ else{
13570
+ fieldValue[currentIndex] = currentFormValues;
13571
+ }
13572
+ // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13573
+ doAction({
13574
+ "componentId": "${props.id}",
13575
+ "actionType": "setValue",
13576
+ "args": {
13577
+ "value": fieldValue
13578
+ }
13139
13579
  });
13140
13580
  }
13141
- else{
13142
- fieldValue[currentIndex] = currentFormValues;
13143
- }
13144
- // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13145
- doAction({
13146
- "componentId": "${props.id}",
13147
- "actionType": "setValue",
13148
- "args": {
13149
- "value": fieldValue
13150
- }
13151
- });
13152
13581
 
13153
13582
  // 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
13154
13583
  let targetPage;
@@ -13197,9 +13626,14 @@ function getFormPagination(props, mode) {
13197
13626
  "onEvent": {
13198
13627
  "click": {
13199
13628
  "actions": [
13629
+ {
13630
+ "actionType": "validate",
13631
+ "componentId": formId
13632
+ },
13200
13633
  {
13201
13634
  "actionType": "custom",
13202
- "script": onPageChangeScript
13635
+ "script": onPageChangeScript,
13636
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13203
13637
  }
13204
13638
  ]
13205
13639
  }
@@ -13208,7 +13642,7 @@ function getFormPagination(props, mode) {
13208
13642
  {
13209
13643
  "type": "tpl",
13210
13644
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13211
- "tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
13645
+ "tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
13212
13646
  },
13213
13647
  {
13214
13648
  "type": "button",
@@ -13218,15 +13652,20 @@ function getFormPagination(props, mode) {
13218
13652
  "pageChangeDirection": "next",
13219
13653
  // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13220
13654
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13221
- "disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
13655
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
13222
13656
  "size": "sm",
13223
13657
  "id": buttonNextId,
13224
13658
  "onEvent": {
13225
13659
  "click": {
13226
13660
  "actions": [
13661
+ {
13662
+ "actionType": "validate",
13663
+ "componentId": formId
13664
+ },
13227
13665
  {
13228
13666
  "actionType": "custom",
13229
- "script": onPageChangeScript
13667
+ "script": onPageChangeScript,
13668
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13230
13669
  }
13231
13670
  ]
13232
13671
  }
@@ -13247,6 +13686,7 @@ function getFormPaginationWrapper(props, form, mode) {
13247
13686
  // console.log("==getFormPaginationWrapper===", props, mode);
13248
13687
  let serviceId = getComponentId("form_pagination", props.id);
13249
13688
  let tableServiceId = getComponentId("table_service", props.id);
13689
+ let primaryKey = getTablePrimaryKey(props);
13250
13690
  let innerForm = Object.assign({}, form, {
13251
13691
  "data": {
13252
13692
  // 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
@@ -13274,7 +13714,6 @@ function getFormPaginationWrapper(props, form, mode) {
13274
13714
  }
13275
13715
  ];
13276
13716
  let onServiceInitedScript = `
13277
-
13278
13717
  // 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13279
13718
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
13280
13719
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
@@ -13288,13 +13727,13 @@ function getFormPaginationWrapper(props, form, mode) {
13288
13727
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13289
13728
  // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
13290
13729
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
13291
- let fieldPrefix = "${props.fieldPrefix}";
13730
+ let fieldPrefix = "${props.fieldPrefix || ''}";
13292
13731
  if(fieldPrefix){
13293
13732
  let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
13294
13733
  lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
13295
13734
  }
13296
13735
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
13297
- let mode = "${mode}";
13736
+ let mode = "${mode || ''}";
13298
13737
  if(mode === "new"){
13299
13738
  // 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
13300
13739
  // 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
@@ -13320,10 +13759,20 @@ function getFormPaginationWrapper(props, form, mode) {
13320
13759
  var fieldValue = event.data.__tableItems;
13321
13760
  if(parent){
13322
13761
  // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13323
- var primaryKey = "${props.primaryKey}";
13762
+ var primaryKey = "${primaryKey}";
13324
13763
  event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13325
13764
  return item[primaryKey] == parent[primaryKey];
13326
13765
  });
13766
+ if(event.data.__parentIndex < 0){
13767
+ let tableId = "${props.id}";
13768
+ let table = scope.getComponentById(tableId)
13769
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13770
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13771
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13772
+ event.data.__parentIndex = _.findIndex(table.props.value, function(item){
13773
+ return item[primaryKey] == parent[primaryKey];
13774
+ });
13775
+ }
13327
13776
  }
13328
13777
  `;
13329
13778
  let schema = {
@@ -13372,6 +13821,7 @@ function getFormPaginationWrapper(props, form, mode) {
13372
13821
  async function getForm(props, mode = "edit", formId) {
13373
13822
  let formFields = getFormFields(props, mode);
13374
13823
  let body = await getFormBody(null, formFields);
13824
+ let primaryKey = getTablePrimaryKey(props);
13375
13825
  if (!formId) {
13376
13826
  formId = getComponentId("form", props.id);
13377
13827
  }
@@ -13390,6 +13840,18 @@ async function getForm(props, mode = "edit", formId) {
13390
13840
  // 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
13391
13841
  let onEditItemSubmitScript = `
13392
13842
  // let fieldValue = _.cloneDeep(event.data["${props.name}"]);
13843
+ let removeEmptyItems = function(items){
13844
+ let i = _.findIndex(items, function(item){
13845
+ return item === undefined
13846
+ });
13847
+ if(i > -1){
13848
+ items.splice(i, 1);
13849
+ removeEmptyItems(items);
13850
+ }
13851
+ }
13852
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13853
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13854
+ removeEmptyItems(event.data.__tableItems);
13393
13855
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13394
13856
  //这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
13395
13857
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
@@ -13398,6 +13860,8 @@ async function getForm(props, mode = "edit", formId) {
13398
13860
  var currentFormValues = JSON.parse(JSON.stringify(event.data));
13399
13861
  var parent = event.data.__super.__super.parent;
13400
13862
  var __parentIndex = event.data.__super.__super.__parentIndex;
13863
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
13864
+ var primaryKey = "${primaryKey}";
13401
13865
  if(parent){
13402
13866
  fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13403
13867
  // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
@@ -13407,6 +13871,8 @@ async function getForm(props, mode = "edit", formId) {
13407
13871
  });
13408
13872
  }
13409
13873
  else{
13874
+ // 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
13875
+ // 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
13410
13876
  fieldValue[currentIndex] = currentFormValues;
13411
13877
  }
13412
13878
  doAction({
@@ -13504,13 +13970,14 @@ async function getForm(props, mode = "edit", formId) {
13504
13970
  */
13505
13971
  async function getButtonActions(props, mode) {
13506
13972
  let actions = [];
13973
+ let primaryKey = getTablePrimaryKey(props);
13507
13974
  let formId = getComponentId("form", props.id);
13508
13975
  let dialogId = getComponentId("dialog", props.id);
13509
13976
  let buttonNextId = getComponentId("button_next", props.id);
13510
13977
  let formPaginationId = getComponentId("form_pagination", props.id);
13511
13978
  let parentFormData = "${__super.__super.__super.__super || {}}";
13512
13979
  let amisVersion = getComparableAmisVersion();
13513
- if(amisVersion < 3.6){
13980
+ if (amisVersion < 3.6) {
13514
13981
  parentFormData = "${__super.__super || {}}";
13515
13982
  }
13516
13983
  if (mode == "new" || mode == "edit") {
@@ -13546,13 +14013,35 @@ async function getButtonActions(props, mode) {
13546
14013
  // };
13547
14014
  let onSaveAndNewItemScript = `
13548
14015
  let scope = event.context.scoped;
14016
+ let removeEmptyItems = function(items){
14017
+ let i = _.findIndex(items, function(item){
14018
+ return item === undefined
14019
+ });
14020
+ if(i > -1){
14021
+ items.splice(i, 1);
14022
+ removeEmptyItems(items);
14023
+ }
14024
+ }
14025
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
14026
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
14027
+ removeEmptyItems(event.data.__tableItems);
13549
14028
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13550
14029
  // 新建一条空白行并保存到子表组件
13551
14030
  var parent = event.data.__super.parent;
13552
- var primaryKey = "${props.primaryKey}";
14031
+ var primaryKey = "${primaryKey}";
13553
14032
  var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13554
14033
  return item[primaryKey] == parent[primaryKey];
13555
14034
  });
14035
+ if(parent && __parentIndex < 0){
14036
+ let tableId = "${props.id}";
14037
+ let table = scope.getComponentById(tableId)
14038
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14039
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14040
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14041
+ __parentIndex = _.findIndex(table.props.value, function(item){
14042
+ return item[primaryKey] == parent[primaryKey];
14043
+ });
14044
+ }
13556
14045
  if(parent){
13557
14046
  fieldValue[__parentIndex].children.push({});
13558
14047
  // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
@@ -13586,14 +14075,42 @@ async function getButtonActions(props, mode) {
13586
14075
  let __formId = "${formId}";
13587
14076
  // let newItem = JSON.parse(JSON.stringify(event.data));
13588
14077
  let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
14078
+ newItem = _.clone(newItem);
14079
+ let removeEmptyItems = function(items){
14080
+ let i = _.findIndex(items, function(item){
14081
+ return item === undefined
14082
+ });
14083
+ if(i > -1){
14084
+ items.splice(i, 1);
14085
+ removeEmptyItems(items);
14086
+ }
14087
+ }
14088
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
14089
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
14090
+ removeEmptyItems(event.data.__tableItems);
13589
14091
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13590
14092
  // 复制当前页数据到新建行并保存到子表组件
13591
14093
  // fieldValue.push(newItem);
13592
14094
  var parent = event.data.__super.parent;
13593
- var primaryKey = "${props.primaryKey}";
14095
+ var primaryKey = "${primaryKey}";
13594
14096
  var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13595
14097
  return item[primaryKey] == parent[primaryKey];
13596
14098
  });
14099
+ if(parent && __parentIndex < 0){
14100
+ let tableId = "${props.id}";
14101
+ let table = scope.getComponentById(tableId)
14102
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14103
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14104
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14105
+ __parentIndex = _.findIndex(table.props.value, function(item){
14106
+ return item[primaryKey] == parent[primaryKey];
14107
+ });
14108
+ }
14109
+ if(newItem[primaryKey]){
14110
+ // 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
14111
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
14112
+ newItem[primaryKey] = uuidv4();
14113
+ }
13597
14114
  if(parent){
13598
14115
  fieldValue[__parentIndex].children.push(newItem);
13599
14116
  // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
@@ -13624,13 +14141,13 @@ async function getButtonActions(props, mode) {
13624
14141
  `;
13625
14142
  let dialogButtons = [
13626
14143
  {
13627
- "type": "button",
13628
- "label": "完成",
13629
- "actionType": "confirm",
13630
- "level": "primary"
14144
+ "type": "button",
14145
+ "label": "完成",
14146
+ "actionType": "confirm",
14147
+ "level": "primary"
13631
14148
  }
13632
14149
  ];
13633
- if(props.addable){
14150
+ if (props.addable) {
13634
14151
  // 有新增行权限时额外添加新增和复制按钮
13635
14152
  dialogButtons = [
13636
14153
  {
@@ -13640,9 +14157,14 @@ async function getButtonActions(props, mode) {
13640
14157
  "onEvent": {
13641
14158
  "click": {
13642
14159
  "actions": [
14160
+ {
14161
+ "actionType": "validate",
14162
+ "componentId": formId
14163
+ },
13643
14164
  {
13644
14165
  "actionType": "custom",
13645
- "script": onSaveAndNewItemScript
14166
+ "script": onSaveAndNewItemScript,
14167
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13646
14168
  }
13647
14169
  ]
13648
14170
  }
@@ -13655,9 +14177,14 @@ async function getButtonActions(props, mode) {
13655
14177
  "onEvent": {
13656
14178
  "click": {
13657
14179
  "actions": [
14180
+ {
14181
+ "actionType": "validate",
14182
+ "componentId": formId
14183
+ },
13658
14184
  {
13659
14185
  "actionType": "custom",
13660
- "script": onSaveAndCopyItemScript
14186
+ "script": onSaveAndCopyItemScript,
14187
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13661
14188
  }
13662
14189
  ]
13663
14190
  }
@@ -13703,7 +14230,7 @@ async function getButtonActions(props, mode) {
13703
14230
  // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13704
14231
  // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13705
14232
  "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13706
- },
14233
+ },
13707
14234
  "actions": dialogButtons,
13708
14235
  "onEvent": {
13709
14236
  "confirm": {
@@ -13801,7 +14328,10 @@ async function getButtonActions(props, mode) {
13801
14328
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13802
14329
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13803
14330
  // "__tableItems": `\${${props.name}|json|toJson}`
13804
- "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14331
+ // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14332
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14333
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14334
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13805
14335
  },
13806
14336
  }
13807
14337
  }
@@ -13817,13 +14347,24 @@ async function getButtonActions(props, mode) {
13817
14347
  let wrapperServiceData = wrapperService.getData();
13818
14348
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13819
14349
  // 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
14350
+ // 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
13820
14351
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13821
14352
  var currentIndex = event.data.index;
13822
14353
  var parent = event.data.__super.parent;
13823
- var primaryKey = "${props.primaryKey}";
14354
+ var primaryKey = "${primaryKey}";
13824
14355
  var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
13825
14356
  return item[primaryKey] == parent[primaryKey];
13826
14357
  });
14358
+ if(parent && __parentIndex < 0){
14359
+ let tableId = "${props.id}";
14360
+ let table = scope.getComponentById(tableId)
14361
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14362
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14363
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14364
+ __parentIndex = _.findIndex(table.props.value, function(item){
14365
+ return item[primaryKey] == parent[primaryKey];
14366
+ });
14367
+ }
13827
14368
  if(parent){
13828
14369
  lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
13829
14370
  // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
@@ -13835,6 +14376,11 @@ async function getButtonActions(props, mode) {
13835
14376
  else{
13836
14377
  lastestFieldValue.splice(currentIndex, 1);
13837
14378
  }
14379
+ let fieldPrefix = "${props.fieldPrefix || ''}";
14380
+ if(fieldPrefix){
14381
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
14382
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
14383
+ }
13838
14384
  doAction({
13839
14385
  "componentId": "${props.id}",
13840
14386
  "actionType": "setValue",
@@ -13904,45 +14450,77 @@ async function getButtonView(props) {
13904
14450
 
13905
14451
  async function getButtonDelete(props) {
13906
14452
  return {
13907
- "type": "button",
13908
- "label": "",
13909
- "icon": "fa fa-trash-alt",//不可以用fa-trash-o,因为设计字段布局界面中弹出的设置分组列表中显示不了这个图标
14453
+ "type": "dropdown-button",
13910
14454
  "level": "link",
13911
- "onEvent": {
13912
- "click": {
13913
- "actions": await getButtonActions(props, "delete")
14455
+ "icon": "fa fa-trash-alt",
14456
+ "size": "xs",
14457
+ "hideCaret": true,
14458
+ "closeOnClick": true,
14459
+ "body": [
14460
+ {
14461
+ "type": "wrapper",
14462
+ "size": "md",
14463
+ "className": "w-80",
14464
+ "body": [
14465
+ {
14466
+ "tpl": "确定要删除吗?",
14467
+ "type": "tpl"
14468
+ },
14469
+ {
14470
+ "type": "flex",
14471
+ "justify": "flex-end",
14472
+ "className": "mt-3",
14473
+ "items": [
14474
+ {
14475
+ "type": "button",
14476
+ "label": "取消",
14477
+ "className": "mr-2"
14478
+ },
14479
+ {
14480
+ "type": "button",
14481
+ "label": "删除",
14482
+ "level": "danger",
14483
+ "onEvent": {
14484
+ "click": {
14485
+ "actions": await getButtonActions(props, "delete")
14486
+ }
14487
+ }
14488
+ }
14489
+ ]
14490
+ }
14491
+ ]
13914
14492
  }
13915
- }
13916
- };
14493
+ ]
14494
+ }
13917
14495
  }
13918
14496
 
14497
+
13919
14498
  const getAmisInputTableSchema = async (props) => {
13920
14499
  if (!props.id) {
13921
14500
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13922
14501
  }
13923
- if (!props.primaryKey) {
13924
- props.primaryKey = "_id";
13925
- }
14502
+ let primaryKey = getTablePrimaryKey(props);
13926
14503
  let showOperation = props.showOperation;
13927
- if(showOperation !== false){
14504
+ if (showOperation !== false) {
13928
14505
  showOperation = true;
13929
14506
  }
13930
- // props.fieldPrefix = "project_milestone_";
13931
- if (props.fieldPrefix) {
13932
- props.fields = getTableFieldsWithoutFieldPrefix(props.fields, props.fieldPrefix);
14507
+ let fieldPrefix = props.fieldPrefix;
14508
+ let fields = props.fields || [];
14509
+ if (fieldPrefix) {
14510
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13933
14511
  }
13934
14512
  let serviceId = getComponentId("table_service", props.id);
13935
14513
  let buttonsForColumnOperations = [];
13936
14514
  let inlineEditMode = props.inlineEditMode;
13937
14515
  let showAsInlineEditMode = inlineEditMode && props.editable;
13938
- if(showOperation){
14516
+ if (showOperation) {
13939
14517
  if (props.editable) {
13940
14518
  let showEditButton = true;
13941
14519
  if (showAsInlineEditMode) {
13942
14520
  // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
13943
14521
  showEditButton = true;
13944
14522
  // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
13945
- // if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
14523
+ // if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
13946
14524
  // showEditButton = true;
13947
14525
  // }
13948
14526
  // else {
@@ -13957,7 +14535,7 @@ const getAmisInputTableSchema = async (props) => {
13957
14535
  }
13958
14536
  else {
13959
14537
  // 只读时显示查看按钮
13960
- // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
14538
+ // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
13961
14539
  let buttonViewSchema = await getButtonView(props);
13962
14540
  buttonsForColumnOperations.push(buttonViewSchema);
13963
14541
  }
@@ -13966,10 +14544,10 @@ const getAmisInputTableSchema = async (props) => {
13966
14544
  buttonsForColumnOperations.push(buttonDeleteSchema);
13967
14545
  }
13968
14546
  }
13969
- let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
14547
+ let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
13970
14548
  let inputTableSchema = {
13971
14549
  "type": "input-table",
13972
- "label": props.label,
14550
+ "mode": "normal",
13973
14551
  "name": props.name,
13974
14552
  //不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
13975
14553
  // "addable": props.addable,
@@ -13985,36 +14563,53 @@ const getAmisInputTableSchema = async (props) => {
13985
14563
  "showTableAddBtn": false,
13986
14564
  "showFooterAddBtn": false,
13987
14565
  "className": props.tableClassName,
14566
+ "pipeIn": (value, data) => {
14567
+ if (fieldPrefix) {
14568
+ value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
14569
+ }
14570
+ value = getTableValueWithEmptyValue(value, fields);
14571
+ if (primaryKey) {
14572
+ // 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
14573
+ // 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
14574
+ // 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
14575
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14576
+ }
14577
+ if (amis.pipeIn) {
14578
+ if (typeof amis.pipeIn === 'function') {
14579
+ return amis.pipeIn(value, data);
14580
+ }
14581
+ }
14582
+ return value;
14583
+ },
13988
14584
  "pipeOut": (value, data) => {
13989
- value = (value || []).map(function(item){
14585
+ value = (value || []).map(function (item) {
13990
14586
  delete item.__fix_rerender_after_children_modified_tag;
13991
14587
  return item;
13992
14588
  });
13993
- if(props.fieldPrefix){
13994
- value = getTableValuePrependFieldPrefix(value, props.fieldPrefix);
14589
+ if (fieldPrefix) {
14590
+ value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
14591
+ }
14592
+ value = getTableValueWithoutEmptyValue(value, fields);
14593
+ if (props.autoGeneratePrimaryKeyValue === true) {
14594
+ // 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
14595
+ // 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
14596
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14597
+ }
14598
+ else {
14599
+ // 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
14600
+ // 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
14601
+ // 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
14602
+ // 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
14603
+ value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
13995
14604
  }
13996
- if(amis.pipeOut){
13997
- if(typeof amis.pipeOut === 'function'){
14605
+ if (amis.pipeOut) {
14606
+ if (typeof amis.pipeOut === 'function') {
13998
14607
  return amis.pipeOut(value, data);
13999
14608
  }
14000
14609
  }
14001
14610
  return value;
14002
14611
  }
14003
14612
  };
14004
- if(amis.pipeIn){
14005
- inputTableSchema.pipeIn = amis.pipeIn;
14006
- }
14007
- if(props.fieldPrefix){
14008
- inputTableSchema.pipeIn = (value, data) => {
14009
- value = getTableValueWithoutFieldPrefix(value, props.fieldPrefix);
14010
- if(amis.pipeIn){
14011
- if(typeof amis.pipeIn === 'function'){
14012
- return amis.pipeIn(value, data);
14013
- }
14014
- }
14015
- return value;
14016
- };
14017
- }
14018
14613
  if (buttonsForColumnOperations.length) {
14019
14614
  inputTableSchema.columns.push({
14020
14615
  "name": "__op__",
@@ -14023,9 +14618,10 @@ const getAmisInputTableSchema = async (props) => {
14023
14618
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
14024
14619
  });
14025
14620
  }
14026
- if (showAsInlineEditMode) {
14027
- inputTableSchema.needConfirm = false;
14028
- }
14621
+ // if (showAsInlineEditMode) {
14622
+ // // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
14623
+ // inputTableSchema.needConfirm = false;
14624
+ // }
14029
14625
  if (amis) {
14030
14626
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
14031
14627
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
@@ -14033,7 +14629,7 @@ const getAmisInputTableSchema = async (props) => {
14033
14629
  delete amis.pipeOut;//该属性在上面合并过了
14034
14630
  Object.assign(inputTableSchema, amis);
14035
14631
  }
14036
- const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
14632
+ const isAnyFieldHasDependOn = (fields || []).find(function (item) {
14037
14633
  return item.depend_on;
14038
14634
  });
14039
14635
  if (isAnyFieldHasDependOn) {
@@ -14066,11 +14662,31 @@ const getAmisInputTableSchema = async (props) => {
14066
14662
  "body": headerToolbar
14067
14663
  });
14068
14664
  }
14665
+ let className = "steedos-input-table";
14666
+
14667
+ if (typeof props.className == "object") {
14668
+ className = {
14669
+ [className]: "true",
14670
+ ...props.className
14671
+ };
14672
+ } else if (typeof props.className == "string") {
14673
+ className = `${className} ${props.className} `;
14674
+ }
14675
+
14069
14676
  let schema = {
14070
- "type": "service",
14071
- "body": schemaBody,
14072
- "className": props.className,
14073
- "id": serviceId
14677
+ "type": "control",
14678
+ "body": {
14679
+ "type": "service",
14680
+ "body": schemaBody,
14681
+ "id": serviceId
14682
+ },
14683
+ "label": props.label,
14684
+ "labelClassName": props.label ? props.labelClassName : "none",
14685
+ "labelRemark": props.labelRemark,
14686
+ "labelAlign": props.labelAlign,
14687
+ //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14688
+ "mode": props.mode || null,
14689
+ className
14074
14690
  };
14075
14691
  // console.log("===schema===", schema);
14076
14692
  return schema;