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

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
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, reverse, isObject as isObject$1, clone, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, startsWith } from 'lodash';
3
3
  import i18next from 'i18next';
4
4
  export { default as i18next } from 'i18next';
5
5
  import { initReactI18next } from 'react-i18next';
@@ -340,22 +340,26 @@ const getSteedosAuth = () => {
340
340
  * @Description:
341
341
  */
342
342
 
343
-
344
343
  const Router = {
345
344
  getTabDisplayAs(tab_id){
345
+ const uiSchema = getUISchemaSync$1(tab_id, false);
346
346
  var urlSearch = new URLSearchParams(document.location.search);
347
347
  if(urlSearch.has('display')){
348
348
  return urlSearch.get('display')
349
349
  }
350
350
  const key = `tab_${tab_id}_display`;
351
351
  // const key = `page_display`;
352
- const value = localStorage.getItem(key);
353
- return value ? value : 'grid'
352
+ const value = sessionStorage.getItem(key);
353
+ let defaultDisplay = "grid";
354
+ if(uiSchema.enable_split){
355
+ defaultDisplay = "split";
356
+ }
357
+ return value ? value : defaultDisplay;
354
358
  },
355
359
 
356
360
  setTabDisplayAs(tab_id, displayAs){
357
361
  const key = `tab_${tab_id}_display`;
358
- localStorage.setItem(key, displayAs);
362
+ sessionStorage.setItem(key, displayAs);
359
363
  },
360
364
  getAppPath({formFactor, appId}){
361
365
  return `/app/${appId}`;
@@ -459,7 +463,7 @@ function getComparableAmisVersion() {
459
463
  * @Author: baozhoutao@steedos.com
460
464
  * @Date: 2022-05-23 09:53:08
461
465
  * @LastEditors: liaodaxue
462
- * @LastEditTime: 2023-10-11 17:32:17
466
+ * @LastEditTime: 2024-01-17 16:00:27
463
467
  * @Description:
464
468
  */
465
469
 
@@ -531,7 +535,7 @@ function getSelectMap(selectOptions){
531
535
 
532
536
  function getNameTplUrl(field, ctx){
533
537
  if(ctx.objectName === 'cms_files'){
534
- return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
538
+ return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
535
539
  }
536
540
  const href = Router.getObjectDetailPath({
537
541
  ...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
@@ -2060,7 +2064,11 @@ async function getTableColumns(fields, options){
2060
2064
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2061
2065
  let className = "";
2062
2066
  if(field.wrap != true){
2063
- className += " whitespace-nowrap ";
2067
+ if(field.wrap != false && field.is_wide){
2068
+ className += " break-words ";
2069
+ }else {
2070
+ className += " whitespace-nowrap ";
2071
+ }
2064
2072
  }else {
2065
2073
  className += " break-words ";
2066
2074
  }
@@ -2159,12 +2167,12 @@ async function getTableColumns(fields, options){
2159
2167
  if(field.type === 'textarea'){
2160
2168
  className += 'min-w-56';
2161
2169
  }
2162
- if(field.type === 'date'){
2163
- className += 'date-min-w';
2164
- }
2165
- if(field.type === 'datetime'){
2166
- className += 'datetime-min-w';
2167
- }
2170
+ // if(field.type === 'date'){
2171
+ // className += 'date-min-w';
2172
+ // }
2173
+ // if(field.type === 'datetime'){
2174
+ // className += 'datetime-min-w';
2175
+ // }
2168
2176
 
2169
2177
  //field上的amis属性里的clssname需要单独判断类型合并
2170
2178
  if (typeof field.amis?.className == "object") {
@@ -2259,7 +2267,7 @@ function getMobileLines(tpls){
2259
2267
  }
2260
2268
  if(isLeft){
2261
2269
  // 左侧半行
2262
- lineChildrenClassName = "steedos-listview-item-left truncate";
2270
+ lineChildrenClassName = "steedos-listview-item-left truncate h-5";
2263
2271
  if(item.field.is_wide){
2264
2272
  // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
2265
2273
  lineChildrenClassName = "steedos-listview-item-wide";
@@ -2271,7 +2279,7 @@ function getMobileLines(tpls){
2271
2279
  }
2272
2280
  else {
2273
2281
  // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
2274
- lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
2282
+ lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
2275
2283
  }
2276
2284
  //支持字段amis属性配置classname,识别classname的类型,与原样式合并
2277
2285
  var className;
@@ -2382,7 +2390,15 @@ async function getMobileTableColumns(fields, options){
2382
2390
  "actions": [
2383
2391
  {
2384
2392
  "script": `
2385
- let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
2393
+ let cms_url = '';
2394
+ let value = event.data.versions[0];
2395
+ if(value){
2396
+ if(value.url){
2397
+ cms_url = value.url;
2398
+ }else{
2399
+ cms_url = "/api/files/files/"+value+"?download=true"
2400
+ }
2401
+ }
2386
2402
  Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
2387
2403
  `,
2388
2404
  "actionType": "custom"
@@ -3014,12 +3030,15 @@ async function getTableApi(mainObject, fields, options){
3014
3030
  }
3015
3031
  // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
3016
3032
  };
3017
- const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3018
- const firstListviewComponent = listviewComponent && listviewComponent[0];
3019
- if(firstListviewComponent){
3020
- setTimeout(()=>{
3021
- firstListviewComponent.scrollIntoView();
3022
- }, 600);
3033
+ let formFactor = "${options.formFactor}";
3034
+ if(formFactor !== "SMALL"){
3035
+ const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3036
+ const firstListviewComponent = listviewComponent && listviewComponent[0];
3037
+ if(firstListviewComponent){
3038
+ setTimeout(()=>{
3039
+ firstListviewComponent.scrollIntoView();
3040
+ }, 600);
3041
+ }
3023
3042
  }
3024
3043
  ${options.adaptor || ''}
3025
3044
  return payload;
@@ -3364,17 +3383,16 @@ async function getEditFormInitApi(object, recordId, fields, options){
3364
3383
  }
3365
3384
  // data下的变量需要在保存接口(getSaveApi)中被删除。
3366
3385
  payload.data = {
3367
- ...initialValues,
3368
- editFormInited: true
3386
+ ...initialValues
3369
3387
  }
3370
3388
  ${options.initApiAdaptor || ''}
3371
3389
  // console.log('getEditFormInitApi======>', payload);
3372
3390
  return payload;
3373
3391
  `,
3374
- // responseData: {
3375
- // initialValues: "$$",
3376
- // editFormInited: true
3377
- // },
3392
+ responseData: {
3393
+ "&": "$$",
3394
+ editFormInited: true
3395
+ },
3378
3396
  data: data,
3379
3397
  headers: {
3380
3398
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -4217,7 +4235,7 @@ async function getListBody(fields, options){
4217
4235
 
4218
4236
  function getDefaultParams(options){
4219
4237
  return {
4220
- perPage: options.top || options.perPage || 10
4238
+ perPage: options.top || options.perPage || 20
4221
4239
  }
4222
4240
  }
4223
4241
 
@@ -4420,7 +4438,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4420
4438
  "objectApiName": "\${objectName}",
4421
4439
  "recordId": "",
4422
4440
  "mode": "edit",
4423
- "layout": "normal"
4424
4441
  };
4425
4442
 
4426
4443
  if (payload && payload.schema) {
@@ -6692,7 +6709,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6692
6709
  let body = [
6693
6710
  {
6694
6711
  "type": "wrapper",
6695
- "className": "p-4 bg-gray-100 border-b sm:sticky top-0 z-10",
6712
+ "className": "p-4 bg-gray-100 border-b",
6696
6713
  "body": [
6697
6714
  {
6698
6715
  "type": "grid",
@@ -6722,8 +6739,27 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6722
6739
  let max = 10;
6723
6740
  if(options.formFactor === 'SMALL'){
6724
6741
  max = 4;
6742
+ }else {
6743
+
6744
+ let divWidth = window.innerWidth;
6745
+
6746
+ if(options.display === 'split'){
6747
+ divWidth = divWidth - 388;
6748
+ }
6749
+
6750
+ if(document.body.classList.contains('sidebar')){
6751
+ divWidth = divWidth - 210;
6752
+ }
6753
+
6754
+ // 根据屏幕宽度计算显示数量, 使高亮字段只占1行
6755
+ max = Math.trunc(divWidth / 200 );
6756
+ if(max > 10){
6757
+ max = 10;
6758
+ }
6725
6759
  }
6726
6760
 
6761
+ // console.log('=======================max=========================', max)
6762
+
6727
6763
  if(objectSchema.compactLayouts){
6728
6764
  const details = [];
6729
6765
  _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
@@ -6737,13 +6773,32 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6737
6773
  }
6738
6774
  });
6739
6775
 
6776
+ // 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
6777
+ // xl:grid-cols-1
6778
+ // xl:grid-cols-2
6779
+ // xl:grid-cols-3
6780
+ // xl:grid-cols-4
6781
+ // xl:grid-cols-5
6782
+ // xl:grid-cols-6
6783
+ // xl:grid-cols-7
6784
+ // xl:grid-cols-8
6785
+ // xl:grid-cols-9
6786
+ // xl:grid-cols-10
6787
+ // xl:grid-cols-11
6788
+ // xl:grid-cols-12
6789
+
6740
6790
  body.push({
6741
- "type": "form",
6742
- "className": "p-4 bg-white compact-layouts",
6743
- "wrapWithPanel": false,
6744
- "actions": [],
6745
- "body": details,
6746
- "hiddenOn": "${recordLoaded != true}"
6791
+ "type": "wrapper",
6792
+ "body": {
6793
+ "type": "form",
6794
+ // "className": "gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-5 3xl:grid-cols-8 4xl:grid-cols-8 5xl:grid-cols-10", //max-h-12 overflow-hidden
6795
+ "className": `gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-${max}`,
6796
+ "wrapWithPanel": false,
6797
+ "actions": [],
6798
+ "body": details,
6799
+ "hiddenOn": "${recordLoaded != true}"
6800
+ },
6801
+ "className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
6747
6802
  });
6748
6803
  }
6749
6804
 
@@ -6822,7 +6877,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
6822
6877
  "className": "flex justify-between"
6823
6878
  }
6824
6879
  ],
6825
- "className": "pt-0 pb-2 px-0"
6880
+ "className": "steedos-record-related-header py-2 px-0"
6826
6881
  };
6827
6882
  return recordRelatedListHeader;
6828
6883
  }
@@ -7807,14 +7862,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
7807
7862
  {
7808
7863
  "type": "button",
7809
7864
  "label": i18next.t('frontend_display_type_is_table'),
7810
- "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');",
7865
+ "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');",
7811
7866
  "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
7812
7867
  "rightIconClassName": "m-l-sm"
7813
7868
  },
7814
7869
  {
7815
7870
  "type": "button",
7816
7871
  "label": i18next.t('frontend_display_type_is_split'),
7817
- "onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7872
+ "onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
7818
7873
  "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
7819
7874
  "rightIconClassName": "m-l-sm"
7820
7875
  }
@@ -8538,7 +8593,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8538
8593
  // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8539
8594
  // },
8540
8595
  bodyClassName: {
8541
- "bg-white": "true",
8596
+ "mb-0": true,
8542
8597
  "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8543
8598
  },
8544
8599
  crudClassName: crudClassName,
@@ -8694,7 +8749,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
8694
8749
  }
8695
8750
 
8696
8751
  async function getObjectForm(objectSchema, ctx){
8697
- const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8752
+ const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8698
8753
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8699
8754
  const fields = ___default.values(objectSchema.fields);
8700
8755
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -8788,7 +8843,7 @@ async function getObjectForm(objectSchema, ctx){
8788
8843
  }
8789
8844
 
8790
8845
  async function getObjectDetail(objectSchema, recordId, ctx){
8791
- const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign,
8846
+ const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
8792
8847
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8793
8848
  const fields = ___default.values(objectSchema.fields);
8794
8849
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -9113,7 +9168,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9113
9168
  setDataToComponentId: componentId,
9114
9169
  // tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
9115
9170
  appId: appId,
9116
- crudClassName: 'border-t border-gray-300 hidden',
9171
+ crudClassName: 'steedos-record-related-crud hidden',
9117
9172
  refField,
9118
9173
  ...ctx
9119
9174
  };
@@ -9126,7 +9181,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9126
9181
  amisSchema: {
9127
9182
  type: "service",
9128
9183
  id: componentId,
9129
- className: `steedos-record-related-list pt-4 pb-2 border-b first:pt-0 last:border-0 ${componentId} ${className}`,
9184
+ className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
9130
9185
  data: {
9131
9186
  relatedKey: relatedKey,
9132
9187
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
@@ -9872,7 +9927,8 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9872
9927
  };
9873
9928
  const content = {
9874
9929
  "type": "tabs",
9875
- "className": "steedos-record-tabs p-4 m-0",
9930
+ "className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
9931
+ "contentClassName": "bg-none",
9876
9932
  "tabs": [
9877
9933
  detailed
9878
9934
  ],
@@ -9880,7 +9936,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9880
9936
  if(relatedLists.length){
9881
9937
  content.tabs.push(related);
9882
9938
  }
9883
- content.tabs = reverse(content.tabs);
9939
+ // content.tabs = reverse(content.tabs)
9884
9940
  return {
9885
9941
  uiSchema,
9886
9942
  amisSchema: {
@@ -11160,8 +11216,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
11160
11216
  labelField: referenceTo.labelField.name,
11161
11217
  valueField: referenceTo.valueField.name,
11162
11218
  // disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
11163
- disabledOn: `${readonly}`,
11164
- hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11219
+ disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11165
11220
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
11166
11221
  source: source,
11167
11222
  size: "lg",
@@ -11404,16 +11459,18 @@ async function lookupToAmis(field, readonly, ctx){
11404
11459
  }
11405
11460
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11406
11461
  if(readonly){
11407
- return {
11408
- type: 'steedos-field',
11409
- config: field,
11410
- static: true
11462
+ if(field.reference_to){
11463
+ return {
11464
+ type: 'steedos-field',
11465
+ config: field,
11466
+ static: true
11467
+ }
11468
+ }else {
11469
+ return {
11470
+ type: getAmisStaticFieldType('picker', readonly),
11471
+ tpl: getRelatedFieldTpl(field, ctx)
11472
+ }
11411
11473
  }
11412
-
11413
- // return {
11414
- // type: Field.getAmisStaticFieldType('picker', readonly),
11415
- // tpl: Tpl.getRelatedFieldTpl(field, ctx)
11416
- // }
11417
11474
  }
11418
11475
  if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
11419
11476
  return {
@@ -12460,7 +12517,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12460
12517
  if(field.is_wide || convertData.type === 'group'){
12461
12518
  convertData.className = 'col-span-2 m-0';
12462
12519
  }else {
12463
- convertData.className = 'm-1';
12520
+ convertData.className = 'm-0';
12464
12521
  }
12465
12522
  if(readonly){
12466
12523
  convertData.className = `${convertData.className} border-b`;
@@ -12485,6 +12542,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12485
12542
  }
12486
12543
  }
12487
12544
 
12545
+ if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
12546
+ convertData.className = `${convertData.className || ''} hidden`;
12547
+ }
12548
+
12488
12549
  if(_$1.isString(baseData.required)){
12489
12550
  if(baseData.required.startsWith("{{")){
12490
12551
  baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
@@ -12866,9 +12927,61 @@ async function getFormBody(permissionFields, formFields, ctx){
12866
12927
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12867
12928
  * @Date: 2023-11-15 09:50:22
12868
12929
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12869
- * @LastEditTime: 2024-01-16 14:58:51
12930
+ * @LastEditTime: 2024-01-18 10:29:57
12870
12931
  */
12871
12932
 
12933
+ /**
12934
+ * 子表组件字段值中每行数据的键值key移除指定前缀
12935
+ * @param {*} value 子表组件字段值,数组
12936
+ * @param {*} fieldPrefix 字段前缀
12937
+ * @returns 转换后的子表组件字段值
12938
+ */
12939
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix){
12940
+ let convertedValue = [];
12941
+ (value || []).forEach((itemValue)=>{
12942
+ var newItemValue = {};
12943
+ for(let n in itemValue){
12944
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
12945
+ }
12946
+ convertedValue.push(newItemValue);
12947
+ });
12948
+ return convertedValue;
12949
+ }
12950
+
12951
+ /**
12952
+ * 子表组件字段值中每行数据的键值key补上指定前缀
12953
+ * @param {*} value 子表组件字段值,数组
12954
+ * @param {*} fieldPrefix 字段前缀
12955
+ * @returns 转换后的子表组件字段值
12956
+ */
12957
+ function getTableValuePrependFieldPrefix(value, fieldPrefix){
12958
+ let convertedValue = [];
12959
+ (value || []).forEach((itemValue)=>{
12960
+ var newItemValue = {};
12961
+ for(let n in itemValue){
12962
+ if(typeof itemValue[n] !== undefined){
12963
+ newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
12964
+ }
12965
+ }
12966
+ convertedValue.push(newItemValue);
12967
+ });
12968
+ return convertedValue;
12969
+ }
12970
+
12971
+ /**
12972
+ * 子表组件字段集合属性中每个字段name移除指定前缀
12973
+ * @param {*} fields 子表组件字段集合,数组
12974
+ * @param {*} fieldPrefix 字段前缀
12975
+ * @returns 转换后的子表组件字段值
12976
+ */
12977
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
12978
+ return (fields || []).map((item) => {
12979
+ const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
12980
+ newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
12981
+ return newItem;
12982
+ });
12983
+ }
12984
+
12872
12985
  /**
12873
12986
  * @param {*} props
12874
12987
  * @param {*} mode edit/new/readonly
@@ -13145,7 +13258,7 @@ function getFormPaginationWrapper(props, form, mode) {
13145
13258
  {
13146
13259
  "type": "wrapper",
13147
13260
  "size": "none",
13148
- "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white -mt-2",
13261
+ "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
13149
13262
  "body": [
13150
13263
  getFormPagination(props, mode)
13151
13264
  ]
@@ -13161,16 +13274,8 @@ function getFormPaginationWrapper(props, form, mode) {
13161
13274
  }
13162
13275
  ];
13163
13276
  let onServiceInitedScript = `
13164
- var parent = event.data.parent;
13165
- var fieldValue = event.data.__tableItems;
13166
- if(parent){
13167
- // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13168
- var primaryKey = "${props.primaryKey}";
13169
- event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13170
- return item[primaryKey] == parent[primaryKey];
13171
- });
13172
- }
13173
- // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13277
+
13278
+ // 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13174
13279
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
13175
13280
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
13176
13281
  // 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
@@ -13183,6 +13288,11 @@ function getFormPaginationWrapper(props, form, mode) {
13183
13288
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13184
13289
  // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
13185
13290
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
13291
+ let fieldPrefix = "${props.fieldPrefix}";
13292
+ if(fieldPrefix){
13293
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
13294
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
13295
+ }
13186
13296
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
13187
13297
  let mode = "${mode}";
13188
13298
  if(mode === "new"){
@@ -13205,6 +13315,16 @@ function getFormPaginationWrapper(props, form, mode) {
13205
13315
  event.data.__tableItems.forEach(function(n,i){
13206
13316
  event.data.__tableItems[i] = lastestFieldValue[i];
13207
13317
  });
13318
+
13319
+ var parent = event.data.parent;
13320
+ var fieldValue = event.data.__tableItems;
13321
+ if(parent){
13322
+ // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13323
+ var primaryKey = "${props.primaryKey}";
13324
+ event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13325
+ return item[primaryKey] == parent[primaryKey];
13326
+ });
13327
+ }
13208
13328
  `;
13209
13329
  let schema = {
13210
13330
  "type": "service",
@@ -13807,6 +13927,10 @@ const getAmisInputTableSchema = async (props) => {
13807
13927
  if(showOperation !== false){
13808
13928
  showOperation = true;
13809
13929
  }
13930
+ // props.fieldPrefix = "project_milestone_";
13931
+ if (props.fieldPrefix) {
13932
+ props.fields = getTableFieldsWithoutFieldPrefix(props.fields, props.fieldPrefix);
13933
+ }
13810
13934
  let serviceId = getComponentId("table_service", props.id);
13811
13935
  let buttonsForColumnOperations = [];
13812
13936
  let inlineEditMode = props.inlineEditMode;
@@ -13842,6 +13966,7 @@ const getAmisInputTableSchema = async (props) => {
13842
13966
  buttonsForColumnOperations.push(buttonDeleteSchema);
13843
13967
  }
13844
13968
  }
13969
+ let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
13845
13970
  let inputTableSchema = {
13846
13971
  "type": "input-table",
13847
13972
  "label": props.label,
@@ -13861,12 +13986,35 @@ const getAmisInputTableSchema = async (props) => {
13861
13986
  "showFooterAddBtn": false,
13862
13987
  "className": props.tableClassName,
13863
13988
  "pipeOut": (value, data) => {
13864
- return (value || []).map(function(item){
13989
+ value = (value || []).map(function(item){
13865
13990
  delete item.__fix_rerender_after_children_modified_tag;
13866
13991
  return item;
13867
13992
  });
13993
+ if(props.fieldPrefix){
13994
+ value = getTableValuePrependFieldPrefix(value, props.fieldPrefix);
13995
+ }
13996
+ if(amis.pipeOut){
13997
+ if(typeof amis.pipeOut === 'function'){
13998
+ return amis.pipeOut(value, data);
13999
+ }
14000
+ }
14001
+ return value;
13868
14002
  }
13869
14003
  };
14004
+ if(amis.pipeIn){
14005
+ inputTableSchema.pipeIn = amis.pipeIn;
14006
+ }
14007
+ if(props.fieldPrefix){
14008
+ inputTableSchema.pipeIn = (value, data) => {
14009
+ value = getTableValueWithoutFieldPrefix(value, props.fieldPrefix);
14010
+ if(amis.pipeIn){
14011
+ if(typeof amis.pipeIn === 'function'){
14012
+ return amis.pipeIn(value, data);
14013
+ }
14014
+ }
14015
+ return value;
14016
+ };
14017
+ }
13870
14018
  if (buttonsForColumnOperations.length) {
13871
14019
  inputTableSchema.columns.push({
13872
14020
  "name": "__op__",
@@ -13878,10 +14026,11 @@ const getAmisInputTableSchema = async (props) => {
13878
14026
  if (showAsInlineEditMode) {
13879
14027
  inputTableSchema.needConfirm = false;
13880
14028
  }
13881
- let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
13882
14029
  if (amis) {
13883
14030
  // 支持配置amis属性重写或添加最终生成的input-table中任何属性。
13884
14031
  delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
14032
+ delete amis.pipeIn;//该属性在上面合并过了
14033
+ delete amis.pipeOut;//该属性在上面合并过了
13885
14034
  Object.assign(inputTableSchema, amis);
13886
14035
  }
13887
14036
  const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {