@steedos-widgets/amis-lib 3.6.2-beta.8 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -335,27 +335,33 @@ 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
-
344
343
  const Router = {
345
- getTabDisplayAs(tab_id){
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')
349
348
  }
350
349
  const key = `tab_${tab_id}_display`;
351
350
  // const key = `page_display`;
352
- const value = localStorage.getItem(key);
353
- return value ? value : 'grid'
351
+ const value = sessionStorage.getItem(key);
352
+ let defaultDisplay = "grid";
353
+ if(defaultEnableSplit === true){
354
+ defaultDisplay = "split";
355
+ }
356
+ if(window.innerWidth <= 768){
357
+ return "grid";
358
+ }
359
+ return value ? value : defaultDisplay;
354
360
  },
355
361
 
356
362
  setTabDisplayAs(tab_id, displayAs){
357
363
  const key = `tab_${tab_id}_display`;
358
- localStorage.setItem(key, displayAs);
364
+ sessionStorage.setItem(key, displayAs);
359
365
  },
360
366
  getAppPath({formFactor, appId}){
361
367
  return `/app/${appId}`;
@@ -382,8 +388,8 @@ const Router = {
382
388
  /*
383
389
  * @Author: baozhoutao@steedos.com
384
390
  * @Date: 2022-07-20 16:29:22
385
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
386
- * @LastEditTime: 2023-12-28 14:59:08
391
+ * @LastEditors: liaodaxue
392
+ * @LastEditTime: 2024-01-25 14:44:17
387
393
  * @Description:
388
394
  */
389
395
 
@@ -455,6 +461,25 @@ function getComparableAmisVersion() {
455
461
  }
456
462
  }
457
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
+
458
483
  /*
459
484
  * @Author: baozhoutao@steedos.com
460
485
  * @Date: 2022-05-23 09:53:08
@@ -517,7 +542,7 @@ function getSelectMap(selectOptions){
517
542
  forEach(selectOptions,(option)=>{
518
543
  const optionValue = option.value + '';
519
544
  const optionColor = option.color + '';
520
- if(optionColor){
545
+ if(optionColor && optionColor != "undefined"){
521
546
  const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
522
547
  const color = getContrastColor(background);
523
548
  const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
@@ -1133,7 +1158,31 @@ const getAmisFileReadonlySchema = (steedosField)=>{
1133
1158
  }
1134
1159
  }
1135
1160
  if(type === 'file'){
1136
- 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
+ } : {
1137
1186
  type: amisFieldType,
1138
1187
  tpl: `
1139
1188
  <% let fileData = data._display.${steedosField.name}; if (fileData) { %>
@@ -1277,6 +1326,7 @@ var frontend_notifications$1 = "Notifications";
1277
1326
  var frontend_notifications_allread$1 = "Mark all as read";
1278
1327
  var frontend_notifications_allread_message$1 = "All marked as read";
1279
1328
  var frontend_profile$1 = "Profile";
1329
+ var switch_space$1 = "Switch Space";
1280
1330
  var frontend_about$1 = "About";
1281
1331
  var frontend_log_out$1 = "Log out";
1282
1332
  var frontend_listview_warning_start$1 = "The current ";
@@ -1364,6 +1414,7 @@ var en_us = {
1364
1414
  frontend_notifications_allread: frontend_notifications_allread$1,
1365
1415
  frontend_notifications_allread_message: frontend_notifications_allread_message$1,
1366
1416
  frontend_profile: frontend_profile$1,
1417
+ switch_space: switch_space$1,
1367
1418
  frontend_about: frontend_about$1,
1368
1419
  frontend_log_out: frontend_log_out$1,
1369
1420
  frontend_listview_warning_start: frontend_listview_warning_start$1,
@@ -1419,7 +1470,7 @@ var frontend_listview_control_delete_label = "删除";
1419
1470
  var frontend_listview_control_delete_confirm_text = "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?";
1420
1471
  var frontend_listview_control_delete_message_success = "删除成功";
1421
1472
  var frontend_listview_control_filters = "过滤设置";
1422
- var frontend_listview_control_filters_fields_extend = "条件组件1";
1473
+ var frontend_listview_control_filters_fields_extend = "条件组件";
1423
1474
  var frontend_listview_control_new_label = "新建";
1424
1475
  var frontend_listview_control_new_title = "新建 列表视图";
1425
1476
  var frontend_listview_control_new_message_success = "成功";
@@ -1453,6 +1504,7 @@ var frontend_notifications = "通知";
1453
1504
  var frontend_notifications_allread = "全部标记为已读";
1454
1505
  var frontend_notifications_allread_message = "已全部标记为已读";
1455
1506
  var frontend_profile = "个人资料";
1507
+ var switch_space = "切换工作区";
1456
1508
  var frontend_about = "关于";
1457
1509
  var frontend_log_out = "注销";
1458
1510
  var frontend_listview_warning_start = "当前";
@@ -1541,6 +1593,7 @@ var zh_cn = {
1541
1593
  frontend_notifications_allread: frontend_notifications_allread,
1542
1594
  frontend_notifications_allread_message: frontend_notifications_allread_message,
1543
1595
  frontend_profile: frontend_profile,
1596
+ switch_space: switch_space,
1544
1597
  frontend_about: frontend_about,
1545
1598
  frontend_log_out: frontend_log_out,
1546
1599
  frontend_listview_warning_start: frontend_listview_warning_start,
@@ -1595,7 +1648,7 @@ async function getQuickEditSchema(field, options){
1595
1648
  isAmisVersionforBatchEdit = window.Amis.version[0] >= 3 && window.Amis.version[2] >= 2;
1596
1649
  }
1597
1650
  const quickEditId = options.objectName + "_" + field.name + "_quickEdit";//定义快速编辑的表单id,用于setvalue传值
1598
- var quickEditSchema = { body: [], id: quickEditId };
1651
+ var quickEditSchema = { body: [], id: quickEditId, className: "steedos-table-quickEdit" };
1599
1652
  //select,avatar,image,file等组件无法行记录字段赋值,暂不支持批量编辑;
1600
1653
  if(field.type != 'avatar' && field.type != 'image' && field.type != 'file' && isAmisVersionforBatchEdit){
1601
1654
  const submitEvent = {
@@ -1854,7 +1907,8 @@ async function getQuickEditSchema(field, options){
1854
1907
  "failed": "失败了呢。。"
1855
1908
  }
1856
1909
  }
1857
- }
1910
+ },
1911
+ "expression": "${!recordPermissions.modifyAllRecords}"
1858
1912
  },
1859
1913
  {
1860
1914
  "actionType": "setValue",
@@ -1870,7 +1924,7 @@ async function getQuickEditSchema(field, options){
1870
1924
  "componentId": quickEditId,
1871
1925
  "args": {
1872
1926
  "value":{
1873
- "quickedit_record_permissions": "${event.data}"
1927
+ "quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
1874
1928
  }
1875
1929
  }
1876
1930
  }
@@ -1934,7 +1988,7 @@ async function getQuickEditSchema(field, options){
1934
1988
  `
1935
1989
  }
1936
1990
  },
1937
- "expression":"${event.data.value}"
1991
+ "expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
1938
1992
  },
1939
1993
  {
1940
1994
  "actionType": "setValue",
@@ -1965,10 +2019,20 @@ async function getQuickEditSchema(field, options){
1965
2019
  "script": `
1966
2020
  const noPermission = event.data.noPermission;
1967
2021
  const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
1968
- const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
2022
+ let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
1969
2023
  noPermission.forEach(function (item) {
1970
2024
  crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
2025
+ _.remove(selectedItems, (selected) => selected._id === item);
1971
2026
  })
2027
+ doAction({
2028
+ "componentId": "${quickEditId}",
2029
+ "actionType": "setValue",
2030
+ "args": {
2031
+ "value": {
2032
+ selectedItems
2033
+ }
2034
+ }
2035
+ });
1972
2036
  `
1973
2037
  },
1974
2038
  {
@@ -2029,7 +2093,7 @@ async function getQuickEditSchema(field, options){
2029
2093
  }
2030
2094
 
2031
2095
  function getFieldWidth(width){
2032
- const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2096
+ const defaultWidth = null;
2033
2097
  if(typeof width == 'string'){
2034
2098
  if(isNaN(width)){
2035
2099
  return width || defaultWidth;
@@ -2059,18 +2123,35 @@ async function getTableColumns(fields, options){
2059
2123
  //增加quickEdit属性,实现快速编辑
2060
2124
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2061
2125
  let className = "";
2062
- if(field.wrap != true){
2126
+ const bowserType = getBowserType();
2127
+ if(bowserType === "Safari"){
2063
2128
  className += " whitespace-nowrap ";
2064
2129
  }else {
2065
- className += " break-words ";
2130
+ if(field.wrap != true){
2131
+ className += " whitespace-nowrap ";
2132
+ }else {
2133
+ className += " break-words ";
2134
+ }
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} `;
2066
2144
  }
2145
+ let fieldAmis = _$1.clone(field.amis);
2146
+ delete fieldAmis?.className;
2147
+
2067
2148
  let columnItem;
2068
2149
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
2069
2150
  const previewFileScript = `
2070
2151
  var data = event.data;
2071
2152
  var file_name = data.versions ? data.name : "${field.label}";
2072
- var file_id = data._id;
2073
- 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});
2074
2155
  `;
2075
2156
  columnItem = {
2076
2157
  "type": "button",
@@ -2095,11 +2176,11 @@ async function getTableColumns(fields, options){
2095
2176
  "expression": "!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
2096
2177
  },
2097
2178
  {
2098
- "args": {},
2099
- "actionType": "custom",
2100
- "script": previewFileScript,
2101
- // "expression": "!!window?.nw?.require" //PC客户端预览附件
2102
- "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客户端预览附件
2103
2184
  }
2104
2185
  ]
2105
2186
  }
@@ -2114,7 +2195,7 @@ async function getTableColumns(fields, options){
2114
2195
  toggled: field.toggled,
2115
2196
  static: true,
2116
2197
  className,
2117
- }, field.amis, {name: field.name});
2198
+ }, fieldAmis, {name: field.name});
2118
2199
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
2119
2200
  columnItem = Object.assign({}, {
2120
2201
  type: "switch",
@@ -2125,7 +2206,7 @@ async function getTableColumns(fields, options){
2125
2206
  static: true,
2126
2207
  className,
2127
2208
  ...getAmisFileReadonlySchema(field)
2128
- }, field.amis, {name: field.name});
2209
+ }, fieldAmis, {name: field.name});
2129
2210
  }
2130
2211
  else if(field.type === 'select'){
2131
2212
  const map = getSelectMap(field.options);
@@ -2140,7 +2221,7 @@ async function getTableColumns(fields, options){
2140
2221
  className,
2141
2222
  inputClassName: "inline",
2142
2223
  static: true,
2143
- }, field.amis, {name: field.name});
2224
+ }, fieldAmis, {name: field.name});
2144
2225
  }
2145
2226
  else {
2146
2227
  const tpl = await getFieldTpl(field, options);
@@ -2159,23 +2240,14 @@ async function getTableColumns(fields, options){
2159
2240
  if(field.type === 'textarea'){
2160
2241
  className += 'min-w-56';
2161
2242
  }
2162
- if(field.type === 'date'){
2163
- className += 'date-min-w';
2164
- }
2165
- if(field.type === 'datetime'){
2166
- className += 'datetime-min-w';
2167
- }
2243
+ // if(field.type === 'date'){
2244
+ // className += 'date-min-w';
2245
+ // }
2246
+ // if(field.type === 'datetime'){
2247
+ // className += 'datetime-min-w';
2248
+ // }
2168
2249
 
2169
2250
  //field上的amis属性里的clssname需要单独判断类型合并
2170
- if (typeof field.amis?.className == "object") {
2171
- className = {
2172
- [className]: "true",
2173
- ...field.amis.className
2174
- };
2175
- } else if (typeof field.amis?.className == "string") {
2176
- className = `${className} ${field.amis.className} `;
2177
- }
2178
- delete field.amis?.className;
2179
2251
 
2180
2252
  if(!field.hidden && !field.extra){
2181
2253
  columnItem = Object.assign({}, {
@@ -2192,7 +2264,7 @@ async function getTableColumns(fields, options){
2192
2264
  static: true,
2193
2265
  options: field.type === 'html' ? {html: true} : null
2194
2266
  // toggled: true
2195
- }, field.amis, {name: field.name});
2267
+ }, fieldAmis, {name: field.name});
2196
2268
 
2197
2269
  if(field.type === 'color'){
2198
2270
  columnItem.type = 'color';
@@ -2388,10 +2460,10 @@ async function getMobileTableColumns(fields, options){
2388
2460
  if(value.url){
2389
2461
  cms_url = value.url;
2390
2462
  }else{
2391
- cms_url = "/api/files/files/"+value+"?download=true"
2463
+ cms_url = Steedos.absoluteUrl("/api/files/files/"+value+"?download=true");
2392
2464
  }
2393
2465
  }
2394
- Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
2466
+ Steedos.cordovaDownload(encodeURI(cms_url), event.data.name);
2395
2467
  `,
2396
2468
  "actionType": "custom"
2397
2469
  }
@@ -2891,6 +2963,21 @@ async function getTableApi(mainObject, fields, options){
2891
2963
  return api;
2892
2964
  `;
2893
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
+
2894
2981
  if(api.body.listName == "recent"){
2895
2982
  payload.data.rows = _.sortBy(payload.data.rows, function(item){
2896
2983
  return _.indexOf(api.body._ids, item._id)
@@ -2915,7 +3002,13 @@ async function getTableApi(mainObject, fields, options){
2915
3002
  value = [value]
2916
3003
  };
2917
3004
  if(field.type === 'file'){
2918
- 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
+ });
2919
3012
  }else{
2920
3013
  item[key] = _.map(value, (item)=>{
2921
3014
  if(field.type === 'image'){
@@ -2957,15 +3050,8 @@ async function getTableApi(mainObject, fields, options){
2957
3050
  }
2958
3051
  });
2959
3052
  };
2960
- let isTreeOptionsComputed = false;
2961
- if(records.length === 1 && records[0].children){
2962
- isTreeOptionsComputed = true;
2963
- }
2964
- if(!isTreeOptionsComputed){
2965
- // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2966
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2967
- assignIndexToTreeRecords(payload.data.rows, '');
2968
- }
3053
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
3054
+ assignIndexToTreeRecords(payload.data.rows, '');
2969
3055
  }
2970
3056
 
2971
3057
 
@@ -3024,11 +3110,10 @@ async function getTableApi(mainObject, fields, options){
3024
3110
  };
3025
3111
  let formFactor = "${options.formFactor}";
3026
3112
  if(formFactor !== "SMALL"){
3027
- const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3028
- const firstListviewComponent = listviewComponent && listviewComponent[0];
3029
- if(firstListviewComponent){
3113
+ const lisviewDom = document.querySelector(".steedos-object-listview .antd-Table-table");
3114
+ if(lisviewDom){
3030
3115
  setTimeout(()=>{
3031
- firstListviewComponent.scrollIntoView();
3116
+ lisviewDom.scrollIntoView();
3032
3117
  }, 600);
3033
3118
  }
3034
3119
  }
@@ -4861,9 +4946,16 @@ const getSchema$2 = (uiSchema) => {
4861
4946
  "form": {
4862
4947
  debug: false,
4863
4948
  resetAfterSubmit: false,
4949
+ data: {
4950
+ editFormInited: true,
4951
+ },
4864
4952
  initApi: {
4953
+ method: 'GET',
4865
4954
  url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
4866
4955
  sendOn: 'this.recordId',
4956
+ data: null,
4957
+ requestAdaptor: "return api;",
4958
+ adaptor: "return payload;",
4867
4959
  responseData: {
4868
4960
  importState: "${state}"
4869
4961
  }
@@ -5735,7 +5827,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
5735
5827
  const formSchema = {
5736
5828
  "type": "service",
5737
5829
  "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
5738
- "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",
5739
5831
  "style":{
5740
5832
  "max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
5741
5833
  },
@@ -6322,7 +6414,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6322
6414
  "className": "slds-filters"
6323
6415
  },
6324
6416
  "size": "xs",
6325
- "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"}`,
6326
6418
  "visibleOn": "this.showFieldsFilter",
6327
6419
  },
6328
6420
  "className": "bg-white"
@@ -6510,7 +6602,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6510
6602
  "icon": "fa fa-refresh",
6511
6603
  "actionType": "reload",
6512
6604
  "target": amisListViewId,
6513
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
6605
+ "className": "bg-white p-2 rounded text-gray-500"
6514
6606
  },
6515
6607
  fieldsFilterButtonSchema,
6516
6608
  // {
@@ -6518,7 +6610,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
6518
6610
  // "label": "",
6519
6611
  // "icon": "fa fa-filter",
6520
6612
  // "actionType": "custom",
6521
- // "className": "bg-transparent p-2 rounded border-gray-300 text-gray-500",
6613
+ // "className": "bg-transparent p-2 rounded text-gray-500",
6522
6614
  // "id": "u:c20cb87d96c9",
6523
6615
  // "onEvent": {
6524
6616
  // "click": {
@@ -6566,7 +6658,7 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6566
6658
  let headerSchema = [{
6567
6659
  "type": "wrapper",
6568
6660
  "body": body,
6569
- "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`
6570
6662
  }];
6571
6663
  return headerSchema;
6572
6664
  }
@@ -6701,7 +6793,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6701
6793
  let body = [
6702
6794
  {
6703
6795
  "type": "wrapper",
6704
- "className": "p-4 bg-gray-100 border-b",
6796
+ "className": "p-4 border-b",
6705
6797
  "body": [
6706
6798
  {
6707
6799
  "type": "grid",
@@ -6731,8 +6823,27 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6731
6823
  let max = 10;
6732
6824
  if(options.formFactor === 'SMALL'){
6733
6825
  max = 4;
6826
+ }else {
6827
+
6828
+ let divWidth = window.innerWidth;
6829
+
6830
+ if(options.display === 'split'){
6831
+ divWidth = divWidth - 388;
6832
+ }
6833
+
6834
+ if(document.body.classList.contains('sidebar')){
6835
+ divWidth = divWidth - 210;
6836
+ }
6837
+
6838
+ // 根据屏幕宽度计算显示数量, 使高亮字段只占1行
6839
+ max = Math.trunc(divWidth / 200 );
6840
+ if(max > 10){
6841
+ max = 10;
6842
+ }
6734
6843
  }
6735
6844
 
6845
+ // console.log('=======================max=========================', max)
6846
+
6736
6847
  if(objectSchema.compactLayouts){
6737
6848
  const details = [];
6738
6849
  _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
@@ -6746,11 +6857,26 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6746
6857
  }
6747
6858
  });
6748
6859
 
6860
+ // 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
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
6873
+
6749
6874
  body.push({
6750
6875
  "type": "wrapper",
6751
6876
  "body": {
6752
6877
  "type": "form",
6753
- "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
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
6879
+ "className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
6754
6880
  "wrapWithPanel": false,
6755
6881
  "actions": [],
6756
6882
  "body": details,
@@ -6835,7 +6961,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
6835
6961
  "className": "flex justify-between"
6836
6962
  }
6837
6963
  ],
6838
- "className": "steedos-record-related-header py-2 px-0"
6964
+ "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
6839
6965
  };
6840
6966
  return recordRelatedListHeader;
6841
6967
  }
@@ -6878,6 +7004,7 @@ const getNewListviewButtonSchema = ()=>{
6878
7004
  "objectApiName": "object_listviews",
6879
7005
  "recordId": "",
6880
7006
  "mode": "edit",
7007
+ "layout": "normal",
6881
7008
  "defaultData": {
6882
7009
  "&": "${list_view}",
6883
7010
  "name":"",
@@ -6885,8 +7012,16 @@ const getNewListviewButtonSchema = ()=>{
6885
7012
  "filters":"",
6886
7013
  "shared":false,
6887
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
6888
7023
  },
6889
- "fieldsExtend": fieldsExtend$4(),
7024
+ "fieldsExtend": fieldsExtend$5(),
6890
7025
  "fields": fields$1(),
6891
7026
  "onEvent": {
6892
7027
  "submitSucc": {
@@ -6937,14 +7072,17 @@ function fields$1(){
6937
7072
  "mobile_columns",
6938
7073
  "searchable_fields",
6939
7074
  "is_system",
6940
- "shared"
7075
+ "shared",
7076
+ "shared_to",
7077
+ "shared_to_organizations"
6941
7078
  ]
6942
7079
  }
6943
7080
 
6944
- function fieldsExtend$4(){
7081
+ function fieldsExtend$5(){
6945
7082
  return {
6946
7083
  "group": "",
6947
7084
  "label": {
7085
+ "group": "",
6948
7086
  "is_wide": true
6949
7087
  },
6950
7088
  "name": {
@@ -7026,9 +7164,19 @@ function fieldsExtend$4(){
7026
7164
  "shared": {
7027
7165
  "group": "",
7028
7166
  "amis": {
7029
- "visibleOn": "${global.user.is_space_admin}"
7167
+ "visibleOn": "${false}"
7168
+ }
7169
+ },
7170
+ "shared_to": {
7171
+ "group": "",
7172
+ "amis":{
7173
+ "type": "radios",
7174
+ "inline": false
7030
7175
  }
7031
7176
  },
7177
+ "shared_to_organizations": {
7178
+ "group": ""
7179
+ },
7032
7180
  "filters": {
7033
7181
  "group": "",
7034
7182
  "amis": {
@@ -7066,14 +7214,23 @@ const getCopyListviewButtonSchema = ()=>{
7066
7214
  "objectApiName": "object_listviews",
7067
7215
  "recordId": "",
7068
7216
  "mode": "edit",
7217
+ "layout": "normal",
7069
7218
  "defaultData": {
7070
7219
  "&": "${list_view}",
7071
7220
  "name":"",
7072
7221
  "label": i18next.t('frontend_listview_control_clone_defaultData_label_start') + " ${list_view.label} " + i18next.t('frontend_listview_control_clone_defaultData_label_end'),
7073
7222
  "shared":false,
7074
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
7075
7232
  },
7076
- "fieldsExtend": fieldsExtend$3(),
7233
+ "fieldsExtend": fieldsExtend$4(),
7077
7234
  "fields": fields(),
7078
7235
  "onEvent": {
7079
7236
  "submitSucc": {
@@ -7121,13 +7278,16 @@ function fields(){
7121
7278
  "mobile_columns.$.field",
7122
7279
  "searchable_fields.$.field",
7123
7280
  "is_system",
7124
- "shared"
7281
+ "shared",
7282
+ "shared_to",
7283
+ "shared_to_organizations"
7125
7284
  ]
7126
7285
  }
7127
7286
 
7128
- function fieldsExtend$3(){
7287
+ function fieldsExtend$4(){
7129
7288
  return {
7130
7289
  "label": {
7290
+ "group": "",
7131
7291
  "is_wide": true
7132
7292
  },
7133
7293
  "name": {
@@ -7177,10 +7337,21 @@ function fieldsExtend$3(){
7177
7337
  }
7178
7338
  },
7179
7339
  "shared": {
7340
+ "group": "",
7180
7341
  "amis": {
7181
- "visibleOn": "${global.user.is_space_admin}"
7342
+ "visibleOn": "${false}"
7343
+ }
7344
+ },
7345
+ "shared_to": {
7346
+ "group": "",
7347
+ "amis":{
7348
+ "type": "radios",
7349
+ "inline": false
7182
7350
  }
7183
7351
  },
7352
+ "shared_to_organizations": {
7353
+ "group": ""
7354
+ },
7184
7355
  "filters": {
7185
7356
  "group": "",
7186
7357
  "amis": {
@@ -7190,6 +7361,12 @@ function fieldsExtend$3(){
7190
7361
  }
7191
7362
  }
7192
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
+ */
7193
7370
  const getRenameListviewButtonSchema = ()=>{
7194
7371
  return {
7195
7372
  "type": "button",
@@ -7215,6 +7392,7 @@ const getRenameListviewButtonSchema = ()=>{
7215
7392
  "label": "对象表单",
7216
7393
  "objectApiName": "object_listviews",
7217
7394
  "recordId": "${recordId}",
7395
+ "layout": "normal",
7218
7396
  "mode": "edit",
7219
7397
  "fields": [
7220
7398
  "label"
@@ -7249,6 +7427,12 @@ const getRenameListviewButtonSchema = ()=>{
7249
7427
  }
7250
7428
  };
7251
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
+ */
7252
7436
  const getSetListviewShareButtonSchema = ()=>{
7253
7437
  return {
7254
7438
  "type": "button",
@@ -7264,6 +7448,8 @@ const getSetListviewShareButtonSchema = ()=>{
7264
7448
  "title": i18next.t('frontend_listview_control_share'),
7265
7449
  "data": {
7266
7450
  "recordId": "${uiSchema.list_views[listName]._id}",
7451
+ "appId": "${appId}",
7452
+ "global": "${global}",
7267
7453
  "context": "${context}"
7268
7454
  },
7269
7455
  "body": [
@@ -7273,9 +7459,12 @@ const getSetListviewShareButtonSchema = ()=>{
7273
7459
  "objectApiName": "object_listviews",
7274
7460
  "recordId": "${recordId}",
7275
7461
  "mode": "edit",
7462
+ "layout": "normal",
7276
7463
  "fields": [
7277
- "shared"
7278
- ]
7464
+ "shared_to",
7465
+ "shared_to_organizations"
7466
+ ],
7467
+ "fieldsExtend": fieldsExtend$3(),
7279
7468
  }
7280
7469
  ],
7281
7470
  "showCloseButton": true,
@@ -7293,6 +7482,21 @@ const getSetListviewShareButtonSchema = ()=>{
7293
7482
  }
7294
7483
  };
7295
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
+
7296
7500
  const getSetListviewFiltersButtonSchema = ()=>{
7297
7501
  return {
7298
7502
  "type": "button",
@@ -7424,10 +7628,12 @@ function apiRequestAdaptor$2(){
7424
7628
  function fieldsExtend$2(){
7425
7629
  return {
7426
7630
  "filters": {
7631
+ "label": "",
7632
+ "group": "",
7427
7633
  "visible_on": "true",
7428
7634
  "amis": {
7429
7635
  "type": "condition-builder",
7430
- "label": i18next.t('frontend_listview_control_filters_fields_extend'),
7636
+ // "label": i18next.t('frontend_listview_control_filters_fields_extend'),
7431
7637
  "source": {
7432
7638
  "method": "get",
7433
7639
  "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
@@ -7470,6 +7676,7 @@ const getSetListviewColumnsButtonSchema = ()=>{
7470
7676
  "objectApiName": "object_listviews",
7471
7677
  "recordId": "${recordId}",
7472
7678
  "mode": "edit",
7679
+ "layout": "normal",
7473
7680
  "fieldsExtend": fieldsExtend$1(),
7474
7681
  "initApiAdaptor": initApiAdaptor$1(),
7475
7682
  "apiRequestAdaptor": apiRequestAdaptor$1(),
@@ -7666,6 +7873,8 @@ const getSetListviewSortButtonSchema = ()=>{
7666
7873
  function fieldsExtend(){
7667
7874
  return {
7668
7875
  "sort": {
7876
+ "label": "",
7877
+ "group": "",
7669
7878
  "amis": {
7670
7879
  "type": "tabs-transfer",
7671
7880
  "sortable": true,
@@ -7793,7 +8002,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
7793
8002
  "icon": "fa fa-cog",
7794
8003
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7795
8004
  // "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
7796
- "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",
7797
8006
  "align": "right",
7798
8007
  "visibleOn": "${!isLookup}",
7799
8008
  "buttons": [
@@ -7814,20 +8023,20 @@ const getSettingListviewToolbarButtonSchema = ()=>{
7814
8023
  }
7815
8024
  };
7816
8025
 
7817
- const getDisplayAsButton = function(objectName, showDisplayAs){
7818
- let displayAs = Router$1.getTabDisplayAs(objectName);
8026
+ const getDisplayAsButton = function(objectName, defaultEnableSplit){
8027
+ let displayAs = Router$1.getTabDisplayAs(objectName, defaultEnableSplit);
7819
8028
  let buttons = [
7820
8029
  {
7821
8030
  "type": "button",
7822
8031
  "label": i18next.t('frontend_display_type_is_table'),
7823
- "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
8032
+ "onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
7824
8033
  "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
7825
8034
  "rightIconClassName": "m-l-sm"
7826
8035
  },
7827
8036
  {
7828
8037
  "type": "button",
7829
8038
  "label": i18next.t('frontend_display_type_is_split'),
7830
- "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
8039
+ "onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7831
8040
  "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
7832
8041
  "rightIconClassName": "m-l-sm"
7833
8042
  }
@@ -7838,7 +8047,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7838
8047
  "icon": "fa fa-table-columns",
7839
8048
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
7840
8049
  // "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
7841
- "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",
7842
8051
  "align": "right",
7843
8052
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
7844
8053
  "buttons": [
@@ -8031,7 +8240,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8031
8240
  // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8032
8241
  // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8033
8242
  // "tooltipPlacement": "top",
8034
- // "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8243
+ // "className": "bg-white p-2 rounded text-gray-500",
8035
8244
  // "label": "",
8036
8245
  // "icon": "fa fa-sync",
8037
8246
  // "visibleOn": "${!showFieldsFilter}",
@@ -8055,7 +8264,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8055
8264
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8056
8265
  "tooltip":"",
8057
8266
  "tooltipPlacement": "top",
8058
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8267
+ "className": "bg-white p-2 rounded text-gray-500"
8059
8268
  };
8060
8269
  }
8061
8270
  else {
@@ -8066,7 +8275,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8066
8275
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8067
8276
  "tooltip":"",
8068
8277
  "tooltipPlacement": "top",
8069
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8278
+ "className": "bg-white p-2 rounded text-gray-500"
8070
8279
  };
8071
8280
  }
8072
8281
  let toolbarFilter;
@@ -8088,7 +8297,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8088
8297
  "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
8089
8298
  },
8090
8299
  "align": "right",
8091
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
8300
+ "className": "bg-white p-2 rounded text-gray-500",
8092
8301
  "onEvent": {
8093
8302
  "click": {
8094
8303
  "actions": [
@@ -8102,7 +8311,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8102
8311
  "id": "steedos_crud_toolbar_filter"
8103
8312
  };
8104
8313
  }
8105
- let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name);
8314
+ let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name, mainObject?.enable_split);
8106
8315
  let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName });
8107
8316
 
8108
8317
  // toolbars返回的数组元素不可以是空对象{},比如hiddenCount ? {} : {"type": "tpl",...},因为空对象最终还是会生成一个空的.antd-Crud-toolbar-item dom
@@ -8248,7 +8457,6 @@ async function getObjectFilter(objectSchema, fields, options) {
8248
8457
  "timeOut": 1000
8249
8458
  }
8250
8459
  });
8251
- resizeWindow();
8252
8460
  const scope = event.context.scoped;
8253
8461
  // let filterFormValues = event.data;
8254
8462
  let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
@@ -8415,7 +8623,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8415
8623
  const bodyProps = {
8416
8624
  // toolbar: getToolbar(),
8417
8625
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
8418
- headerToolbarClassName: "px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",
8626
+ headerToolbarClassName: "px-4 py-2 border-b",
8419
8627
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
8420
8628
  ...options,
8421
8629
  disableStatistics: options.queryCount === false
@@ -8562,14 +8770,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8562
8770
  headers: {
8563
8771
  Authorization: "Bearer ${context.tenantId},${context.authToken}",
8564
8772
  },
8565
- requestAdaptor: quickSaveApiRequestAdaptor,
8566
- adaptor: `
8567
- if(payload.errors){
8568
- payload.status = 2;
8569
- payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8570
- }
8571
- return payload;
8572
- `
8773
+ requestAdaptor: quickSaveApiRequestAdaptor
8573
8774
  },
8574
8775
  // 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
8575
8776
  // 使用表达式给tr添加初始选中状态
@@ -8586,6 +8787,20 @@ async function getObjectCRUD(objectSchema, fields, options){
8586
8787
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8587
8788
  }
8588
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
+
8589
8804
  if(body.columns && options.formFactor != 'SMALL'){
8590
8805
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8591
8806
  body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
@@ -8951,7 +9166,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8951
9166
  * @Author: baozhoutao@steedos.com
8952
9167
  * @Date: 2022-07-05 15:55:39
8953
9168
  * @LastEditors: baozhoutao@steedos.com
8954
- * @LastEditTime: 2024-01-15 10:34:46
9169
+ * @LastEditTime: 2024-01-24 10:18:17
8955
9170
  * @Description:
8956
9171
  */
8957
9172
 
@@ -9050,7 +9265,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9050
9265
  const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
9051
9266
  mainRelated[arr[0]] = foreign_key_value;
9052
9267
  }
9053
- }else {
9268
+ }
9269
+ // 防止related_lists中没有相关子表,但是details中有相关子表的情况
9270
+ if(!mainRelated[relatedObjectName]){
9054
9271
  const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
9055
9272
  for (const detail of details) {
9056
9273
  const arr = detail.split(".");
@@ -9139,7 +9356,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9139
9356
  amisSchema: {
9140
9357
  type: "service",
9141
9358
  id: componentId,
9142
- className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
9359
+ className: `steedos-record-related-list mb-4 last:mb-0 ${componentId} ${className}`,
9143
9360
  data: {
9144
9361
  relatedKey: relatedKey,
9145
9362
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
@@ -9367,8 +9584,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9367
9584
  /*
9368
9585
  * @Author: baozhoutao@steedos.com
9369
9586
  * @Date: 2022-07-05 15:55:39
9370
- * @LastEditors: baozhoutao@steedos.com
9371
- * @LastEditTime: 2024-01-16 11:14:34
9587
+ * @LastEditors: liaodaxue
9588
+ * @LastEditTime: 2024-02-05 17:56:27
9372
9589
  * @Description:
9373
9590
  */
9374
9591
 
@@ -9724,6 +9941,8 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
9724
9941
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
9725
9942
  const rfFieldInfo = rfUiSchema.fields[displayName];
9726
9943
  fields.push(Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx));
9944
+ }else if(filedInfo && filedInfo.type === 'object'){
9945
+ fields.push(uiSchema.fields[column]);
9727
9946
  }
9728
9947
  } else {
9729
9948
  if (uiSchema.fields[column]) {
@@ -9885,7 +10104,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9885
10104
  };
9886
10105
  const content = {
9887
10106
  "type": "tabs",
9888
- "className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
10107
+ "className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
9889
10108
  "contentClassName": "bg-none",
9890
10109
  "tabs": [
9891
10110
  detailed
@@ -10586,17 +10805,13 @@ function getReferenceToSync(field) {
10586
10805
 
10587
10806
  function getLookupSapceUserTreeSchema(isMobile){
10588
10807
  let apiAdaptor = `
10589
- // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10590
10808
  const records = payload.data.options;
10591
- let isTreeOptionsComputed = false;
10592
- if(records.length === 1 && records[0].children){
10593
- isTreeOptionsComputed = true;
10594
- }
10595
- if(isTreeOptionsComputed){
10596
- return payload;
10597
- }
10598
10809
  const treeRecords = [];
10599
- const getChildren = (records, childrenIds) => {
10810
+ const getChildren = (currentRecord, records, childrenIds) => {
10811
+ if (currentRecord.children && typeof currentRecord.children[0] === "object") {
10812
+ // 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
10813
+ return currentRecord.children;
10814
+ }
10600
10815
  if (!childrenIds) {
10601
10816
  return;
10602
10817
  }
@@ -10605,7 +10820,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10605
10820
  });
10606
10821
  _.each(children, (item) => {
10607
10822
  if (item.children) {
10608
- item.children = getChildren(records, item.children)
10823
+ item.children = getChildren(item, records, item.children)
10609
10824
  }else{
10610
10825
  item.children = [];
10611
10826
  }
@@ -10631,7 +10846,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10631
10846
 
10632
10847
  _.each(records, (record) => {
10633
10848
  if (record.noParent == 1) {
10634
- treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10849
+ treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
10635
10850
  }
10636
10851
  });
10637
10852
  console.log(treeRecords)
@@ -10681,6 +10896,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10681
10896
  }
10682
10897
  },
10683
10898
  "label": "",
10899
+ "mode": "normal",
10684
10900
  "name": "organizations",
10685
10901
  "multiple": false,
10686
10902
  "joinValues": false,
@@ -10823,6 +11039,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
10823
11039
  }
10824
11040
  });
10825
11041
 
11042
+ let listviewFilter = getListViewFilter(listView);
11043
+ let listviewFiltersFunction = listView && listView._filters;
11044
+
10826
11045
  let sort = "";
10827
11046
  if(listView){
10828
11047
  sort = getListViewSort(listView);
@@ -10869,7 +11088,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10869
11088
  Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
10870
11089
  }
10871
11090
  const selfData = JSON.parse(JSON.stringify(api.data.$self));
10872
- var filters = [];
11091
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
10873
11092
  var pageSize = api.data.pageSize || 10;
10874
11093
  var pageNo = api.data.pageNo || 1;
10875
11094
  var skip = (pageNo - 1) * pageSize;
@@ -10931,6 +11150,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
10931
11150
  }
10932
11151
 
10933
11152
  const inFilterForm = ${ctx.inFilterForm};
11153
+
11154
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11155
+
11156
+ if(listviewFiltersFunction && !inFilterForm){
11157
+ const _filters0 = listviewFiltersFunction(filters, api.data.$self.__super);
11158
+ if(_filters0 && _filters0.length){
11159
+ filters.push(_filters0);
11160
+ }
11161
+ }
11162
+
10934
11163
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
10935
11164
 
10936
11165
  if(filtersFunction && !inFilterForm){
@@ -11018,6 +11247,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
11018
11247
  });
11019
11248
  payload.data.rows = treeRecords;
11020
11249
  }
11250
+ const result = payload.data.rows;
11251
+ if(result && result.length){
11252
+ const updatedResult = _.map(result, (element) => {
11253
+ const data = { ...element };
11254
+ // image字段值添加URL前缀
11255
+ ${getScriptForAddUrlPrefixForImgFields(_$1.values(refObjectConfig.fields))}
11256
+ return data;
11257
+ });
11258
+ payload.data.rows = updatedResult;
11259
+ }
11021
11260
  return payload;
11022
11261
  `;
11023
11262
  if(field.optionsFunction || field._optionsFunction){
@@ -11049,13 +11288,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
11049
11288
 
11050
11289
  pickerSchema.affixHeader = false;
11051
11290
 
11052
- var headerToolbarItems = [];
11291
+
11292
+
11293
+ pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { isLookup: true, keywordsSearchBoxName });
11294
+
11053
11295
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
11054
- headerToolbarItems = getLookupSapceUserTreeSchema(isMobile);
11296
+ pickerSchema.headerToolbar.push(getLookupSapceUserTreeSchema(isMobile));
11055
11297
  pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
11056
11298
  }
11057
-
11058
- pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { headerToolbarItems, isLookup: true, keywordsSearchBoxName });
11299
+
11059
11300
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
11060
11301
  const isCreate = _$1.isBoolean(field.create) ? field.create : true;
11061
11302
  // lookup字段配置过滤条件就强制不显示新建按钮
@@ -11168,8 +11409,19 @@ async function lookupToAmisPicker(field, readonly, ctx){
11168
11409
  pickerSchema.footerToolbar = ["pagination"];
11169
11410
  }
11170
11411
 
11412
+ if(field.inlineHelpText){
11413
+ pickerSchema.toolbarClassName = "hasHelpText";
11414
+ pickerSchema.headerToolbar = [{
11415
+ "type": "tpl",
11416
+ "tpl": field.inlineHelpText,
11417
+ "className": "text-secondary"
11418
+ }, ...pickerSchema.headerToolbar];
11419
+ }
11420
+ pickerSchema.className = (pickerSchema.className || "") + " steedos-lookup-crud";
11421
+
11171
11422
  const data = {
11172
11423
  type: getAmisStaticFieldType('picker', readonly),
11424
+ className: ctx.className || '',
11173
11425
  modalTitle: i18next.t('frontend_form_please_select') + " " + refObjectConfig.label,
11174
11426
  labelField: referenceTo.labelField.name,
11175
11427
  valueField: referenceTo.valueField.name,
@@ -11243,6 +11495,9 @@ async function lookupToAmisSelect(field, readonly, ctx){
11243
11495
  const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
11244
11496
  let listView = getLookupListView(refObjectConfig);
11245
11497
 
11498
+ let listviewFilter = getListViewFilter(listView);
11499
+ let listviewFiltersFunction = listView && listView._filters;
11500
+
11246
11501
  let sort = "";
11247
11502
  if(listView){
11248
11503
  sort = getListViewSort(listView);
@@ -11272,7 +11527,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11272
11527
  apiInfo.data['rfield'] = `\${object_name}`;
11273
11528
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
11274
11529
  apiInfo.requestAdaptor = `
11275
- var filters = [];
11530
+ ${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
11276
11531
  var top = 200;
11277
11532
  if(api.data.$term){
11278
11533
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
@@ -11295,6 +11550,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
11295
11550
  }
11296
11551
 
11297
11552
  const inFilterForm = ${ctx.inFilterForm};
11553
+
11554
+ const listviewFiltersFunction = ${listviewFiltersFunction};
11555
+
11556
+ if(listviewFiltersFunction && !inFilterForm){
11557
+ const _filters0 = listviewFiltersFunction(filters, api.data.$);
11558
+ if(_filters0 && _filters0.length){
11559
+ filters.push(_filters0);
11560
+ }
11561
+ }
11562
+
11298
11563
  const filtersFunction = ${field.filtersFunction || field._filtersFunction};
11299
11564
 
11300
11565
  if(filtersFunction && !inFilterForm){
@@ -11371,6 +11636,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11371
11636
  // 但是同时配置autoComplete和source会多请求一次接口
11372
11637
  // TODO:应该想办法把是否字段在子表组件内,即ctx.isInputTable,如果不在子表组件内不需要加source
11373
11638
  data.source = apiInfo;
11639
+ delete data.autoComplete;
11374
11640
  }
11375
11641
  //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
11376
11642
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
@@ -11417,7 +11683,8 @@ async function lookupToAmis(field, readonly, ctx){
11417
11683
  }
11418
11684
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11419
11685
  if(readonly){
11420
- if(field.reference_to){
11686
+ if(field.reference_to && !field.isTableField){
11687
+ //isTableField只在grid字段内存在
11421
11688
  return {
11422
11689
  type: 'steedos-field',
11423
11690
  config: field,
@@ -11632,8 +11899,8 @@ if(typeof window != 'undefined'){
11632
11899
  /*
11633
11900
  * @Author: baozhoutao@steedos.com
11634
11901
  * @Date: 2023-01-13 17:27:54
11635
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
11636
- * @LastEditTime: 2023-08-28 17:45:38
11902
+ * @LastEditors: liaodaxue
11903
+ * @LastEditTime: 2024-02-04 17:29:54
11637
11904
  * @Description:
11638
11905
  */
11639
11906
 
@@ -11734,7 +12001,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
11734
12001
  "title": "Insert",
11735
12002
  "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
11736
12003
  }
11737
- }
12004
+ },
12005
+ "statusbar": false
11738
12006
  },
11739
12007
  "name": field.name
11740
12008
  }
@@ -12079,13 +12347,31 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12079
12347
  };
12080
12348
  break;
12081
12349
  case 'input-datetime-range':
12350
+ // convertData = {
12351
+ // type: "input-datetime-range",
12352
+ // inputFormat: 'YYYY-MM-DD HH:mm',
12353
+ // format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
12354
+ // tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
12355
+ // utc: true,
12356
+ // joinValues: false
12357
+ // }
12358
+ // 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
12082
12359
  convertData = {
12083
- type: "input-datetime-range",
12084
- inputFormat: 'YYYY-MM-DD HH:mm',
12360
+ type: "input-date-range",
12361
+ inputFormat: "YYYY-MM-DD HH:mm",
12085
12362
  format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
12086
12363
  tpl: readonly ? getDateTimeTpl(field) : null,
12087
12364
  utc: true,
12088
- joinValues: false
12365
+ joinValues: false,
12366
+ "shortcuts": [
12367
+ "thismonth",
12368
+ "2monthsago",
12369
+ "3monthslater",
12370
+ "prevquarter",
12371
+ "thisquarter",
12372
+ "thisyear",
12373
+ "lastYear"
12374
+ ]
12089
12375
  };
12090
12376
  break;
12091
12377
  case 'datetime':
@@ -12136,7 +12422,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12136
12422
  convertData = {
12137
12423
  type: getAmisStaticFieldType('datetime', readonly),
12138
12424
  inputFormat: 'YYYY-MM-DD HH:mm',
12139
- format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
12425
+ format: 'YYYY-MM-DDTHH:mm:00.000Z',
12140
12426
  tpl: readonly ? getDateTimeTpl(field) : null,
12141
12427
  utc: true,
12142
12428
  };
@@ -12267,6 +12553,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12267
12553
  convertData = {
12268
12554
  type: 'static-text'
12269
12555
  };
12556
+ }else if(field.autonumber_enable_modify){
12557
+ convertData = {
12558
+ "type": "input-group",
12559
+ "body": [
12560
+ {
12561
+ "type": "input-text",
12562
+ "name": field.name
12563
+ },
12564
+ {
12565
+ "type": "button",
12566
+ "label": "自动获取",
12567
+ "actionType": "ajax",
12568
+ "api": {
12569
+ "url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
12570
+ "method": "post",
12571
+ "headers": {
12572
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
12573
+ },
12574
+ "adaptor": `
12575
+ payload.data["${field.name}"] = payload.data && payload.data.autonumber;
12576
+ delete payload.data.autonumber;
12577
+ return payload;
12578
+ `
12579
+ },
12580
+ "messages": {
12581
+ "success": "获取成功"
12582
+ }
12583
+ }
12584
+ ]
12585
+ };
12270
12586
  }
12271
12587
  break;
12272
12588
  case 'url':
@@ -12472,12 +12788,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12472
12788
  break;
12473
12789
  }
12474
12790
  if(!_$1.isEmpty(convertData)){
12791
+ const className = convertData.className;
12475
12792
  if(field.is_wide || convertData.type === 'group'){
12476
- convertData.className = 'col-span-2 m-0';
12793
+ convertData.className = className ? 'col-span-2 m-0 ' + className : 'col-span-2 m-0';
12477
12794
  }else {
12478
- convertData.className = 'm-0';
12795
+ convertData.className = className ? 'm-0 ' + className : 'm-0';
12479
12796
  }
12480
- if(readonly){
12797
+ if(readonly && ctx.mode !== 'edit'){
12481
12798
  convertData.className = `${convertData.className} border-b`;
12482
12799
  }
12483
12800
  if(readonly){
@@ -12485,11 +12802,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12485
12802
  }
12486
12803
 
12487
12804
  let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
12488
- if (convertData.className) {
12489
- convertData.className = convertData.className + fieldTypeClassName;
12490
- } else {
12491
- convertData.className = fieldTypeClassName;
12492
- }
12805
+ convertData.className = convertData.className + fieldTypeClassName;
12493
12806
 
12494
12807
  if(field.visible_on && !ctx.inFilterForm){
12495
12808
  // convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
@@ -12572,8 +12885,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
12572
12885
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12573
12886
  }
12574
12887
  if(_field.type === 'datetime'){
12575
- // 特意改为日期范围而不是日期时间范围,因为搜索时一般精确到日期就足够了,需要精确到日期时间范围需要在字段上配置amis属性来实现
12576
- _field.type = 'input-date-range';
12888
+ // 这里如果想把搜索范围展示效果改为日期范围,不可以直接改为input-date-range,因为它们规则不一样,包括时区规则和小时分秒的存值规则都不一样
12889
+ // 所以想改为展示日期范围效果,只能改input-datetime-range类型本身的属性来实现
12890
+ _field.type = 'input-datetime-range';
12577
12891
  _field.is_wide = true;
12578
12892
  fieldNamePrefix = `${fieldNamePrefix}between__`;
12579
12893
  }
@@ -12759,6 +13073,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
12759
13073
  }
12760
13074
  }
12761
13075
 
13076
+ fieldSetBody.forEach((field)=>{
13077
+ //判断label是否存在,不存在时将label的空占位元素隐藏
13078
+ if(!field.label){
13079
+ field.labelClassName = "none";
13080
+ }
13081
+ });
13082
+
12762
13083
  // fieldSet 已支持显隐控制
12763
13084
  const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
12764
13085
  let visible = visibleOn;
@@ -12881,12 +13202,130 @@ async function getFormBody(permissionFields, formFields, ctx){
12881
13202
  return await getSections(permissionFields, formFields, ctx);
12882
13203
  }
12883
13204
 
13205
+ /*
13206
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
13207
+ * @Date: 2024-01-18 15:12:41
13208
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13209
+ * @LastEditTime: 2024-01-18 15:12:49
13210
+ */
13211
+ /**
13212
+ * 生成符合标准uuid格式的36位满足唯一性的随机串
13213
+ * @returns uuid
13214
+ */
13215
+ function uuidv4() {
13216
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
13217
+ (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
13218
+ );
13219
+ }
13220
+
12884
13221
  /*
12885
13222
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12886
13223
  * @Date: 2023-11-15 09:50:22
12887
13224
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12888
- * @LastEditTime: 2024-01-17 17:15:57
13225
+ * @LastEditTime: 2024-01-26 17:47:16
13226
+ */
13227
+
13228
+ /**
13229
+ * 子表组件字段值中每行数据补上字段值为空的的字段值,把值统一设置为空字符串,是为了解决amis amis 3.6/6.0 input-table组件bug:行中字段值为空时会显示为父作用域中的同名变量值,见:https://github.com/baidu/amis/issues/9520
13230
+ * amis #9520修正后此函数及相关代码可以移除
13231
+ * @param {*} value 子表组件字段值,数组
13232
+ * @param {*} fields 子表组件fields属性,数组
13233
+ * @returns 转换后的子表组件字段值
13234
+ */
13235
+ function getTableValueWithEmptyValue(value, fields) {
13236
+ return (value || []).map((itemValue) => {
13237
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里字段值会被改了
13238
+ const newItemValue = clone(itemValue);
13239
+ (fields || []).forEach((itemField) => {
13240
+ if(itemField.name && (newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13241
+ // 这里newItemValue中不存在 itemField.name 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
13242
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
13243
+ newItemValue[itemField.name] = "";
13244
+ }
13245
+ if (newItemValue.children) {
13246
+ newItemValue.children = getTableValueWithEmptyValue(newItemValue.children, fields);
13247
+ }
13248
+ });
13249
+ return newItemValue;
13250
+ });
13251
+ }
13252
+
13253
+ /**
13254
+ * 把子表组件字段值中每行数据中经过上面getTableValueWithEmptyValue函数空字段值移除
13255
+ * amis #9520修正后此函数及相关代码可以移除
13256
+ * @param {*} value 子表组件字段值,数组
13257
+ * @param {*} fields 子表组件fields属性,数组
13258
+ * @returns 转换后的子表组件字段值
13259
+ */
13260
+ function getTableValueWithoutEmptyValue(value, fields) {
13261
+ return (value || []).map((itemValue) => {
13262
+ const newItemValue = clone(itemValue);
13263
+ (fields || []).forEach((itemField) => {
13264
+ if(itemField.name && (newItemValue[itemField.name] === "" || newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
13265
+ // 这里额外把null和undefined值也删除掉纯粹是没必要输出保存它们
13266
+ delete newItemValue[itemField.name];
13267
+ }
13268
+ if (newItemValue.children) {
13269
+ newItemValue.children = getTableValueWithoutEmptyValue(newItemValue.children, fields);
13270
+ }
13271
+ });
13272
+ return newItemValue;
13273
+ });
13274
+ }
13275
+
13276
+ function getTablePrimaryKey(props) {
13277
+ return props.primaryKey || "_id";
13278
+ }
13279
+
13280
+ /**
13281
+ * 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
13282
+ * @param {*} value 子表组件字段值,数组
13283
+ * @param {*} primaryKey 主键字段名,一般为_id
13284
+ * @returns 转换后的子表组件字段值
13285
+ */
13286
+ function getTableValueWithPrimaryKeyValue(value, primaryKey) {
13287
+ if (!primaryKey) {
13288
+ return value;
13289
+ }
13290
+ return (value || []).map((itemValue) => {
13291
+ //这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
13292
+ const newItemValue = clone(itemValue);
13293
+ if (newItemValue[primaryKey]) {
13294
+ if (newItemValue.children) {
13295
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13296
+ }
13297
+ return newItemValue;
13298
+ }
13299
+ else {
13300
+ newItemValue[primaryKey] = uuidv4();
13301
+ if (newItemValue.children) {
13302
+ newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
13303
+ }
13304
+ return newItemValue;
13305
+ }
13306
+ });
13307
+ }
13308
+
13309
+ /**
13310
+ * 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
13311
+ * @param {*} value 子表组件字段值,数组
13312
+ * @param {*} primaryKey 主键字段名,一般为_id
13313
+ * @returns 转换后的子表组件字段值
12889
13314
  */
13315
+ function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
13316
+ if (!primaryKey) {
13317
+ return value;
13318
+ }
13319
+ return (value || []).map((itemValue) => {
13320
+ //这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
13321
+ const newItemValue = clone(itemValue);
13322
+ if (newItemValue.children) {
13323
+ newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
13324
+ }
13325
+ delete newItemValue[primaryKey];
13326
+ return newItemValue;
13327
+ });
13328
+ }
12890
13329
 
12891
13330
  /**
12892
13331
  * 子表组件字段值中每行数据的键值key移除指定前缀
@@ -12894,12 +13333,38 @@ async function getFormBody(permissionFields, formFields, ctx){
12894
13333
  * @param {*} fieldPrefix 字段前缀
12895
13334
  * @returns 转换后的子表组件字段值
12896
13335
  */
12897
- function getTableValueWithoutFieldPrefix(value, fieldPrefix){
13336
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
13337
+ let convertedValue = [];
13338
+ (value || []).forEach((itemValue) => {
13339
+ var newItemValue = {};
13340
+ for (let n in itemValue) {
13341
+ if (itemValue.hasOwnProperty(n)) {
13342
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13343
+ }
13344
+ }
13345
+ convertedValue.push(newItemValue);
13346
+ });
13347
+ return convertedValue;
13348
+ }
13349
+
13350
+ /**
13351
+ * 子表组件字段值中每行数据的键值key补上指定前缀
13352
+ * @param {*} value 子表组件字段值,数组
13353
+ * @param {*} fieldPrefix 字段前缀
13354
+ * @param {*} primaryKey 主键字段名,主键不参与被键值key规则,需要排除,审批王amis表单也是这个规则
13355
+ * @returns 转换后的子表组件字段值
13356
+ */
13357
+ function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
12898
13358
  let convertedValue = [];
12899
- (value || []).forEach((itemValue)=>{
13359
+ (value || []).forEach((itemValue) => {
12900
13360
  var newItemValue = {};
12901
- for(let n in itemValue){
12902
- newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
13361
+ for (let n in itemValue) {
13362
+ if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
13363
+ newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
13364
+ }
13365
+ }
13366
+ if (primaryKey && itemValue[primaryKey]) {
13367
+ newItemValue[primaryKey] = itemValue[primaryKey];
12903
13368
  }
12904
13369
  convertedValue.push(newItemValue);
12905
13370
  });
@@ -12912,7 +13377,7 @@ function getTableValueWithoutFieldPrefix(value, fieldPrefix){
12912
13377
  * @param {*} fieldPrefix 字段前缀
12913
13378
  * @returns 转换后的子表组件字段值
12914
13379
  */
12915
- function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
13380
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
12916
13381
  return (fields || []).map((item) => {
12917
13382
  const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
12918
13383
  newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
@@ -12925,7 +13390,12 @@ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
12925
13390
  * @param {*} mode edit/new/readonly
12926
13391
  */
12927
13392
  function getFormFields(props, mode = "edit") {
12928
- return (props.fields || []).map(function (item) {
13393
+ let fieldPrefix = props.fieldPrefix;
13394
+ let fields = props.fields || [];
13395
+ if (fieldPrefix) {
13396
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13397
+ }
13398
+ return (fields || []).map(function (item) {
12929
13399
  let formItem = {
12930
13400
  "type": "steedos-field",
12931
13401
  "name": item.name,
@@ -12945,6 +13415,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
12945
13415
  name: field.name,
12946
13416
  quickEdit: {
12947
13417
  "type": "steedos-field",
13418
+ "mode": "inline",
12948
13419
  "config": Object.assign({}, field, {
12949
13420
  label: false
12950
13421
  })
@@ -12997,7 +13468,12 @@ async function getInputTableColumns(props) {
12997
13468
  let inlineEditMode = props.inlineEditMode;
12998
13469
  let showAsInlineEditMode = inlineEditMode && props.editable;
12999
13470
  // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
13000
- let fields = props.fields;
13471
+
13472
+ let fieldPrefix = props.fieldPrefix;
13473
+ let fields = props.fields || [];
13474
+ if (fieldPrefix) {
13475
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13476
+ }
13001
13477
  if (columns && columns.length) {
13002
13478
  return columns.map(function (column) {
13003
13479
  let field, extendColumnProps = {};
@@ -13019,8 +13495,26 @@ async function getInputTableColumns(props) {
13019
13495
  }
13020
13496
  }
13021
13497
  if (field) {
13022
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13023
- return Object.assign({}, tableCell, extendColumnProps);
13498
+ let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
13499
+ extendColumnProps.inlineEditMode : showAsInlineEditMode;
13500
+ let tableCell = getInputTableCell(field, mode);
13501
+ let className = "";
13502
+ //判断是否换行,目前规则默认换行
13503
+ if(extendColumnProps.wrap != true){
13504
+ className += " whitespace-nowrap ";
13505
+ }else {
13506
+ className += " break-words ";
13507
+ }
13508
+ //合并classname
13509
+ if (typeof extendColumnProps.className == "object") {
13510
+ className = {
13511
+ [className]: "true",
13512
+ ...extendColumnProps.className
13513
+ };
13514
+ } else if (typeof extendColumnProps.className == "string") {
13515
+ className = `${className} ${extendColumnProps.className} `;
13516
+ }
13517
+ return Object.assign({}, tableCell, extendColumnProps, {className});
13024
13518
  }
13025
13519
  else {
13026
13520
  return column;
@@ -13030,6 +13524,7 @@ async function getInputTableColumns(props) {
13030
13524
  else {
13031
13525
  return fields.map(function (field) {
13032
13526
  let tableCell = getInputTableCell(field, showAsInlineEditMode);
13527
+ tableCell.className = " whitespace-nowrap ";
13033
13528
  return tableCell;
13034
13529
  }) || [];
13035
13530
  }
@@ -13042,7 +13537,7 @@ async function getInputTableColumns(props) {
13042
13537
  */
13043
13538
  function getFormPagination(props, mode) {
13044
13539
  let showPagination = true;
13045
- if(mode === "new" && !!!props.editable){
13540
+ if (mode === "new" && !!!props.editable) {
13046
13541
  //不允许编辑只允许新建时不应该让用户操作翻页
13047
13542
  showPagination = false;
13048
13543
  }
@@ -13058,35 +13553,41 @@ function getFormPagination(props, mode) {
13058
13553
  let __formId = "${formId}";
13059
13554
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13060
13555
  let pageChangeDirection = context.props.pageChangeDirection;
13556
+ let mode = "${mode}";
13061
13557
  // event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
13062
13558
  // 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
13063
13559
  // 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
13064
13560
  // let currentPage = currentIndex + 1;
13065
13561
  let currentPage = event.data.__page;
13066
13562
  let currentIndex = event.data.index;
13067
- // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13068
- let currentFormValues = scope.getComponentById(__formId).getValues();
13069
- var parent = event.data.parent;
13070
- var __parentIndex = event.data.__parentIndex;
13071
- if(parent){
13072
- fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13073
- // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13074
- fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13075
- children: fieldValue[__parentIndex].children,
13076
- __fix_rerender_after_children_modified_tag: new Date().getTime()
13563
+ if(mode !== "readonly"){
13564
+ // 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
13565
+ // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13566
+ let currentFormValues = scope.getComponentById(__formId).getValues();
13567
+ // 这里不clone的话,其值会带上__super属性
13568
+ currentFormValues = _.clone(currentFormValues);
13569
+ var parent = event.data.parent;
13570
+ var __parentIndex = event.data.__parentIndex;
13571
+ if(parent){
13572
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13573
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13574
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13575
+ children: fieldValue[__parentIndex].children,
13576
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13577
+ });
13578
+ }
13579
+ else{
13580
+ fieldValue[currentIndex] = currentFormValues;
13581
+ }
13582
+ // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13583
+ doAction({
13584
+ "componentId": "${props.id}",
13585
+ "actionType": "setValue",
13586
+ "args": {
13587
+ "value": fieldValue
13588
+ }
13077
13589
  });
13078
13590
  }
13079
- else{
13080
- fieldValue[currentIndex] = currentFormValues;
13081
- }
13082
- // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13083
- doAction({
13084
- "componentId": "${props.id}",
13085
- "actionType": "setValue",
13086
- "args": {
13087
- "value": fieldValue
13088
- }
13089
- });
13090
13591
 
13091
13592
  // 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
13092
13593
  let targetPage;
@@ -13135,9 +13636,14 @@ function getFormPagination(props, mode) {
13135
13636
  "onEvent": {
13136
13637
  "click": {
13137
13638
  "actions": [
13639
+ {
13640
+ "actionType": "validate",
13641
+ "componentId": formId
13642
+ },
13138
13643
  {
13139
13644
  "actionType": "custom",
13140
- "script": onPageChangeScript
13645
+ "script": onPageChangeScript,
13646
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13141
13647
  }
13142
13648
  ]
13143
13649
  }
@@ -13146,7 +13652,7 @@ function getFormPagination(props, mode) {
13146
13652
  {
13147
13653
  "type": "tpl",
13148
13654
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13149
- "tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
13655
+ "tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
13150
13656
  },
13151
13657
  {
13152
13658
  "type": "button",
@@ -13156,15 +13662,20 @@ function getFormPagination(props, mode) {
13156
13662
  "pageChangeDirection": "next",
13157
13663
  // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13158
13664
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13159
- "disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
13665
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
13160
13666
  "size": "sm",
13161
13667
  "id": buttonNextId,
13162
13668
  "onEvent": {
13163
13669
  "click": {
13164
13670
  "actions": [
13671
+ {
13672
+ "actionType": "validate",
13673
+ "componentId": formId
13674
+ },
13165
13675
  {
13166
13676
  "actionType": "custom",
13167
- "script": onPageChangeScript
13677
+ "script": onPageChangeScript,
13678
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13168
13679
  }
13169
13680
  ]
13170
13681
  }
@@ -13185,6 +13696,7 @@ function getFormPaginationWrapper(props, form, mode) {
13185
13696
  // console.log("==getFormPaginationWrapper===", props, mode);
13186
13697
  let serviceId = getComponentId("form_pagination", props.id);
13187
13698
  let tableServiceId = getComponentId("table_service", props.id);
13699
+ let primaryKey = getTablePrimaryKey(props);
13188
13700
  let innerForm = Object.assign({}, form, {
13189
13701
  "data": {
13190
13702
  // 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
@@ -13212,7 +13724,6 @@ function getFormPaginationWrapper(props, form, mode) {
13212
13724
  }
13213
13725
  ];
13214
13726
  let onServiceInitedScript = `
13215
-
13216
13727
  // 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13217
13728
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
13218
13729
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
@@ -13226,13 +13737,13 @@ function getFormPaginationWrapper(props, form, mode) {
13226
13737
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13227
13738
  // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
13228
13739
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
13229
- let fieldPrefix = "${props.fieldPrefix}";
13740
+ let fieldPrefix = "${props.fieldPrefix || ''}";
13230
13741
  if(fieldPrefix){
13231
13742
  let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
13232
13743
  lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
13233
13744
  }
13234
13745
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
13235
- let mode = "${mode}";
13746
+ let mode = "${mode || ''}";
13236
13747
  if(mode === "new"){
13237
13748
  // 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
13238
13749
  // 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
@@ -13258,10 +13769,20 @@ function getFormPaginationWrapper(props, form, mode) {
13258
13769
  var fieldValue = event.data.__tableItems;
13259
13770
  if(parent){
13260
13771
  // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13261
- var primaryKey = "${props.primaryKey}";
13772
+ var primaryKey = "${primaryKey}";
13262
13773
  event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13263
13774
  return item[primaryKey] == parent[primaryKey];
13264
13775
  });
13776
+ if(event.data.__parentIndex < 0){
13777
+ let tableId = "${props.id}";
13778
+ let table = scope.getComponentById(tableId)
13779
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
13780
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
13781
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
13782
+ event.data.__parentIndex = _.findIndex(table.props.value, function(item){
13783
+ return item[primaryKey] == parent[primaryKey];
13784
+ });
13785
+ }
13265
13786
  }
13266
13787
  `;
13267
13788
  let schema = {
@@ -13310,6 +13831,7 @@ function getFormPaginationWrapper(props, form, mode) {
13310
13831
  async function getForm(props, mode = "edit", formId) {
13311
13832
  let formFields = getFormFields(props, mode);
13312
13833
  let body = await getFormBody(null, formFields);
13834
+ let primaryKey = getTablePrimaryKey(props);
13313
13835
  if (!formId) {
13314
13836
  formId = getComponentId("form", props.id);
13315
13837
  }
@@ -13328,6 +13850,18 @@ async function getForm(props, mode = "edit", formId) {
13328
13850
  // 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
13329
13851
  let onEditItemSubmitScript = `
13330
13852
  // let fieldValue = _.cloneDeep(event.data["${props.name}"]);
13853
+ let removeEmptyItems = function(items){
13854
+ let i = _.findIndex(items, function(item){
13855
+ return item === undefined
13856
+ });
13857
+ if(i > -1){
13858
+ items.splice(i, 1);
13859
+ removeEmptyItems(items);
13860
+ }
13861
+ }
13862
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
13863
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
13864
+ removeEmptyItems(event.data.__tableItems);
13331
13865
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13332
13866
  //这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
13333
13867
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
@@ -13336,6 +13870,8 @@ async function getForm(props, mode = "edit", formId) {
13336
13870
  var currentFormValues = JSON.parse(JSON.stringify(event.data));
13337
13871
  var parent = event.data.__super.__super.parent;
13338
13872
  var __parentIndex = event.data.__super.__super.__parentIndex;
13873
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
13874
+ var primaryKey = "${primaryKey}";
13339
13875
  if(parent){
13340
13876
  fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13341
13877
  // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
@@ -13345,6 +13881,8 @@ async function getForm(props, mode = "edit", formId) {
13345
13881
  });
13346
13882
  }
13347
13883
  else{
13884
+ // 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
13885
+ // 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
13348
13886
  fieldValue[currentIndex] = currentFormValues;
13349
13887
  }
13350
13888
  doAction({
@@ -13442,13 +13980,14 @@ async function getForm(props, mode = "edit", formId) {
13442
13980
  */
13443
13981
  async function getButtonActions(props, mode) {
13444
13982
  let actions = [];
13983
+ let primaryKey = getTablePrimaryKey(props);
13445
13984
  let formId = getComponentId("form", props.id);
13446
13985
  let dialogId = getComponentId("dialog", props.id);
13447
13986
  let buttonNextId = getComponentId("button_next", props.id);
13448
13987
  let formPaginationId = getComponentId("form_pagination", props.id);
13449
13988
  let parentFormData = "${__super.__super.__super.__super || {}}";
13450
13989
  let amisVersion = getComparableAmisVersion();
13451
- if(amisVersion < 3.6){
13990
+ if (amisVersion < 3.6) {
13452
13991
  parentFormData = "${__super.__super || {}}";
13453
13992
  }
13454
13993
  if (mode == "new" || mode == "edit") {
@@ -13484,13 +14023,35 @@ async function getButtonActions(props, mode) {
13484
14023
  // };
13485
14024
  let onSaveAndNewItemScript = `
13486
14025
  let scope = event.context.scoped;
14026
+ let removeEmptyItems = function(items){
14027
+ let i = _.findIndex(items, function(item){
14028
+ return item === undefined
14029
+ });
14030
+ if(i > -1){
14031
+ items.splice(i, 1);
14032
+ removeEmptyItems(items);
14033
+ }
14034
+ }
14035
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
14036
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
14037
+ removeEmptyItems(event.data.__tableItems);
13487
14038
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13488
14039
  // 新建一条空白行并保存到子表组件
13489
14040
  var parent = event.data.__super.parent;
13490
- var primaryKey = "${props.primaryKey}";
14041
+ var primaryKey = "${primaryKey}";
13491
14042
  var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13492
14043
  return item[primaryKey] == parent[primaryKey];
13493
14044
  });
14045
+ if(parent && __parentIndex < 0){
14046
+ let tableId = "${props.id}";
14047
+ let table = scope.getComponentById(tableId)
14048
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14049
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14050
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14051
+ __parentIndex = _.findIndex(table.props.value, function(item){
14052
+ return item[primaryKey] == parent[primaryKey];
14053
+ });
14054
+ }
13494
14055
  if(parent){
13495
14056
  fieldValue[__parentIndex].children.push({});
13496
14057
  // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
@@ -13524,14 +14085,42 @@ async function getButtonActions(props, mode) {
13524
14085
  let __formId = "${formId}";
13525
14086
  // let newItem = JSON.parse(JSON.stringify(event.data));
13526
14087
  let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
14088
+ newItem = _.clone(newItem);
14089
+ let removeEmptyItems = function(items){
14090
+ let i = _.findIndex(items, function(item){
14091
+ return item === undefined
14092
+ });
14093
+ if(i > -1){
14094
+ items.splice(i, 1);
14095
+ removeEmptyItems(items);
14096
+ }
14097
+ }
14098
+ // 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
14099
+ // 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
14100
+ removeEmptyItems(event.data.__tableItems);
13527
14101
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13528
14102
  // 复制当前页数据到新建行并保存到子表组件
13529
14103
  // fieldValue.push(newItem);
13530
14104
  var parent = event.data.__super.parent;
13531
- var primaryKey = "${props.primaryKey}";
14105
+ var primaryKey = "${primaryKey}";
13532
14106
  var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13533
14107
  return item[primaryKey] == parent[primaryKey];
13534
14108
  });
14109
+ if(parent && __parentIndex < 0){
14110
+ let tableId = "${props.id}";
14111
+ let table = scope.getComponentById(tableId)
14112
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14113
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14114
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14115
+ __parentIndex = _.findIndex(table.props.value, function(item){
14116
+ return item[primaryKey] == parent[primaryKey];
14117
+ });
14118
+ }
14119
+ if(newItem[primaryKey]){
14120
+ // 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
14121
+ let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
14122
+ newItem[primaryKey] = uuidv4();
14123
+ }
13535
14124
  if(parent){
13536
14125
  fieldValue[__parentIndex].children.push(newItem);
13537
14126
  // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
@@ -13562,13 +14151,13 @@ async function getButtonActions(props, mode) {
13562
14151
  `;
13563
14152
  let dialogButtons = [
13564
14153
  {
13565
- "type": "button",
13566
- "label": "完成",
13567
- "actionType": "confirm",
13568
- "level": "primary"
14154
+ "type": "button",
14155
+ "label": "完成",
14156
+ "actionType": "confirm",
14157
+ "level": "primary"
13569
14158
  }
13570
14159
  ];
13571
- if(props.addable){
14160
+ if (props.addable) {
13572
14161
  // 有新增行权限时额外添加新增和复制按钮
13573
14162
  dialogButtons = [
13574
14163
  {
@@ -13578,9 +14167,14 @@ async function getButtonActions(props, mode) {
13578
14167
  "onEvent": {
13579
14168
  "click": {
13580
14169
  "actions": [
14170
+ {
14171
+ "actionType": "validate",
14172
+ "componentId": formId
14173
+ },
13581
14174
  {
13582
14175
  "actionType": "custom",
13583
- "script": onSaveAndNewItemScript
14176
+ "script": onSaveAndNewItemScript,
14177
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13584
14178
  }
13585
14179
  ]
13586
14180
  }
@@ -13593,9 +14187,14 @@ async function getButtonActions(props, mode) {
13593
14187
  "onEvent": {
13594
14188
  "click": {
13595
14189
  "actions": [
14190
+ {
14191
+ "actionType": "validate",
14192
+ "componentId": formId
14193
+ },
13596
14194
  {
13597
14195
  "actionType": "custom",
13598
- "script": onSaveAndCopyItemScript
14196
+ "script": onSaveAndCopyItemScript,
14197
+ "expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
13599
14198
  }
13600
14199
  ]
13601
14200
  }
@@ -13641,7 +14240,7 @@ async function getButtonActions(props, mode) {
13641
14240
  // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13642
14241
  // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13643
14242
  "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13644
- },
14243
+ },
13645
14244
  "actions": dialogButtons,
13646
14245
  "onEvent": {
13647
14246
  "confirm": {
@@ -13739,7 +14338,10 @@ async function getButtonActions(props, mode) {
13739
14338
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13740
14339
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13741
14340
  // "__tableItems": `\${${props.name}|json|toJson}`
13742
- "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14341
+ // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14342
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14343
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14344
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13743
14345
  },
13744
14346
  }
13745
14347
  }
@@ -13755,13 +14357,24 @@ async function getButtonActions(props, mode) {
13755
14357
  let wrapperServiceData = wrapperService.getData();
13756
14358
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13757
14359
  // 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
14360
+ // 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
13758
14361
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13759
14362
  var currentIndex = event.data.index;
13760
14363
  var parent = event.data.__super.parent;
13761
- var primaryKey = "${props.primaryKey}";
14364
+ var primaryKey = "${primaryKey}";
13762
14365
  var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
13763
14366
  return item[primaryKey] == parent[primaryKey];
13764
14367
  });
14368
+ if(parent && __parentIndex < 0){
14369
+ let tableId = "${props.id}";
14370
+ let table = scope.getComponentById(tableId)
14371
+ // autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
14372
+ // 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
14373
+ // 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
14374
+ __parentIndex = _.findIndex(table.props.value, function(item){
14375
+ return item[primaryKey] == parent[primaryKey];
14376
+ });
14377
+ }
13765
14378
  if(parent){
13766
14379
  lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
13767
14380
  // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
@@ -13773,6 +14386,11 @@ async function getButtonActions(props, mode) {
13773
14386
  else{
13774
14387
  lastestFieldValue.splice(currentIndex, 1);
13775
14388
  }
14389
+ let fieldPrefix = "${props.fieldPrefix || ''}";
14390
+ if(fieldPrefix){
14391
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
14392
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
14393
+ }
13776
14394
  doAction({
13777
14395
  "componentId": "${props.id}",
13778
14396
  "actionType": "setValue",
@@ -13842,46 +14460,77 @@ async function getButtonView(props) {
13842
14460
 
13843
14461
  async function getButtonDelete(props) {
13844
14462
  return {
13845
- "type": "button",
13846
- "label": "",
13847
- "icon": "fa fa-trash-alt",//不可以用fa-trash-o,因为设计字段布局界面中弹出的设置分组列表中显示不了这个图标
14463
+ "type": "dropdown-button",
13848
14464
  "level": "link",
13849
- "onEvent": {
13850
- "click": {
13851
- "actions": await getButtonActions(props, "delete")
14465
+ "icon": "fa fa-trash-alt",
14466
+ "size": "xs",
14467
+ "hideCaret": true,
14468
+ "closeOnClick": true,
14469
+ "body": [
14470
+ {
14471
+ "type": "wrapper",
14472
+ "size": "md",
14473
+ "className": "w-80",
14474
+ "body": [
14475
+ {
14476
+ "tpl": "确定要删除吗?",
14477
+ "type": "tpl"
14478
+ },
14479
+ {
14480
+ "type": "flex",
14481
+ "justify": "flex-end",
14482
+ "className": "mt-3",
14483
+ "items": [
14484
+ {
14485
+ "type": "button",
14486
+ "label": "取消",
14487
+ "className": "mr-2"
14488
+ },
14489
+ {
14490
+ "type": "button",
14491
+ "label": "删除",
14492
+ "level": "danger",
14493
+ "onEvent": {
14494
+ "click": {
14495
+ "actions": await getButtonActions(props, "delete")
14496
+ }
14497
+ }
14498
+ }
14499
+ ]
14500
+ }
14501
+ ]
13852
14502
  }
13853
- }
13854
- };
14503
+ ]
14504
+ }
13855
14505
  }
13856
14506
 
14507
+
13857
14508
  const getAmisInputTableSchema = async (props) => {
13858
14509
  if (!props.id) {
13859
14510
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13860
14511
  }
13861
- if (!props.primaryKey) {
13862
- props.primaryKey = "_id";
13863
- }
14512
+ let primaryKey = getTablePrimaryKey(props);
13864
14513
  let showOperation = props.showOperation;
13865
- if(showOperation !== false){
14514
+ if (showOperation !== false) {
13866
14515
  showOperation = true;
13867
14516
  }
13868
- // props.fieldPrefix = "project_milestone_";
13869
- if (props.fieldPrefix) {
13870
- props.fields = getTableFieldsWithoutFieldPrefix(props.fields, props.fieldPrefix);
14517
+ let fieldPrefix = props.fieldPrefix;
14518
+ let fields = props.fields || [];
14519
+ if (fieldPrefix) {
14520
+ fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13871
14521
  }
13872
- console.log("=getAmisInputTableSchema==props.fields, props.fieldPrefix===", props.fields, props.fieldPrefix);
13873
14522
  let serviceId = getComponentId("table_service", props.id);
13874
14523
  let buttonsForColumnOperations = [];
13875
14524
  let inlineEditMode = props.inlineEditMode;
13876
14525
  let showAsInlineEditMode = inlineEditMode && props.editable;
13877
- if(showOperation){
14526
+ if (showOperation) {
13878
14527
  if (props.editable) {
13879
14528
  let showEditButton = true;
13880
14529
  if (showAsInlineEditMode) {
13881
14530
  // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
13882
14531
  showEditButton = true;
13883
14532
  // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
13884
- // if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
14533
+ // if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
13885
14534
  // showEditButton = true;
13886
14535
  // }
13887
14536
  // else {
@@ -13896,7 +14545,7 @@ const getAmisInputTableSchema = async (props) => {
13896
14545
  }
13897
14546
  else {
13898
14547
  // 只读时显示查看按钮
13899
- // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
14548
+ // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
13900
14549
  let buttonViewSchema = await getButtonView(props);
13901
14550
  buttonsForColumnOperations.push(buttonViewSchema);
13902
14551
  }
@@ -13905,9 +14554,10 @@ const getAmisInputTableSchema = async (props) => {
13905
14554
  buttonsForColumnOperations.push(buttonDeleteSchema);
13906
14555
  }
13907
14556
  }
14557
+ let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
13908
14558
  let inputTableSchema = {
13909
14559
  "type": "input-table",
13910
- "label": props.label,
14560
+ "mode": "normal",
13911
14561
  "name": props.name,
13912
14562
  //不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
13913
14563
  // "addable": props.addable,
@@ -13923,18 +14573,53 @@ const getAmisInputTableSchema = async (props) => {
13923
14573
  "showTableAddBtn": false,
13924
14574
  "showFooterAddBtn": false,
13925
14575
  "className": props.tableClassName,
14576
+ "pipeIn": (value, data) => {
14577
+ if (fieldPrefix) {
14578
+ value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
14579
+ }
14580
+ value = getTableValueWithEmptyValue(value, fields);
14581
+ if (primaryKey) {
14582
+ // 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
14583
+ // 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
14584
+ // 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
14585
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14586
+ }
14587
+ if (amis.pipeIn) {
14588
+ if (typeof amis.pipeIn === 'function') {
14589
+ return amis.pipeIn(value, data);
14590
+ }
14591
+ }
14592
+ return value;
14593
+ },
13926
14594
  "pipeOut": (value, data) => {
13927
- return (value || []).map(function(item){
14595
+ value = (value || []).map(function (item) {
13928
14596
  delete item.__fix_rerender_after_children_modified_tag;
13929
14597
  return item;
13930
14598
  });
14599
+ if (fieldPrefix) {
14600
+ value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
14601
+ }
14602
+ value = getTableValueWithoutEmptyValue(value, fields);
14603
+ if (props.autoGeneratePrimaryKeyValue === true) {
14604
+ // 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
14605
+ // 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
14606
+ value = getTableValueWithPrimaryKeyValue(value, primaryKey);
14607
+ }
14608
+ else {
14609
+ // 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
14610
+ // 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
14611
+ // 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
14612
+ // 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
14613
+ value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
14614
+ }
14615
+ if (amis.pipeOut) {
14616
+ if (typeof amis.pipeOut === 'function') {
14617
+ return amis.pipeOut(value, data);
14618
+ }
14619
+ }
14620
+ return value;
13931
14621
  }
13932
14622
  };
13933
- if(props.fieldPrefix){
13934
- inputTableSchema.pipeIn = (value, data) => {
13935
- return getTableValueWithoutFieldPrefix(value, props.fieldPrefix);
13936
- };
13937
- }
13938
14623
  if (buttonsForColumnOperations.length) {
13939
14624
  inputTableSchema.columns.push({
13940
14625
  "name": "__op__",
@@ -13943,16 +14628,18 @@ const getAmisInputTableSchema = async (props) => {
13943
14628
  "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
13944
14629
  });
13945
14630
  }
13946
- if (showAsInlineEditMode) {
13947
- inputTableSchema.needConfirm = false;
13948
- }
13949
- let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
14631
+ // if (showAsInlineEditMode) {
14632
+ // // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
14633
+ // inputTableSchema.needConfirm = false;
14634
+ // }
13950
14635
  if (amis) {
13951
14636
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
13952
14637
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
14638
+ delete amis.pipeIn;//该属性在上面合并过了
14639
+ delete amis.pipeOut;//该属性在上面合并过了
13953
14640
  Object.assign(inputTableSchema, amis);
13954
14641
  }
13955
- const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
14642
+ const isAnyFieldHasDependOn = (fields || []).find(function (item) {
13956
14643
  return item.depend_on;
13957
14644
  });
13958
14645
  if (isAnyFieldHasDependOn) {
@@ -13985,11 +14672,31 @@ const getAmisInputTableSchema = async (props) => {
13985
14672
  "body": headerToolbar
13986
14673
  });
13987
14674
  }
14675
+ let className = "steedos-input-table";
14676
+
14677
+ if (typeof props.className == "object") {
14678
+ className = {
14679
+ [className]: "true",
14680
+ ...props.className
14681
+ };
14682
+ } else if (typeof props.className == "string") {
14683
+ className = `${className} ${props.className} `;
14684
+ }
14685
+
13988
14686
  let schema = {
13989
- "type": "service",
13990
- "body": schemaBody,
13991
- "className": props.className,
13992
- "id": serviceId
14687
+ "type": "control",
14688
+ "body": {
14689
+ "type": "service",
14690
+ "body": schemaBody,
14691
+ "id": serviceId
14692
+ },
14693
+ "label": props.label,
14694
+ "labelClassName": props.label ? props.labelClassName : "none",
14695
+ "labelRemark": props.labelRemark,
14696
+ "labelAlign": props.labelAlign,
14697
+ //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14698
+ "mode": props.mode || null,
14699
+ className
13993
14700
  };
13994
14701
  // console.log("===schema===", schema);
13995
14702
  return schema;