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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -486,7 +486,7 @@ function getComparableAmisVersion() {
486
486
  * @Author: baozhoutao@steedos.com
487
487
  * @Date: 2022-05-23 09:53:08
488
488
  * @LastEditors: liaodaxue
489
- * @LastEditTime: 2023-10-11 17:32:17
489
+ * @LastEditTime: 2024-01-17 16:00:27
490
490
  * @Description:
491
491
  */
492
492
 
@@ -558,7 +558,7 @@ function getSelectMap(selectOptions){
558
558
 
559
559
  function getNameTplUrl(field, ctx){
560
560
  if(ctx.objectName === 'cms_files'){
561
- return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
561
+ return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
562
562
  }
563
563
  const href = Router.getObjectDetailPath({
564
564
  ...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
@@ -2286,7 +2286,7 @@ function getMobileLines(tpls){
2286
2286
  }
2287
2287
  if(isLeft){
2288
2288
  // 左侧半行
2289
- lineChildrenClassName = "steedos-listview-item-left truncate";
2289
+ lineChildrenClassName = "steedos-listview-item-left truncate h-5";
2290
2290
  if(item.field.is_wide){
2291
2291
  // 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
2292
2292
  lineChildrenClassName = "steedos-listview-item-wide";
@@ -2298,7 +2298,7 @@ function getMobileLines(tpls){
2298
2298
  }
2299
2299
  else {
2300
2300
  // 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
2301
- lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
2301
+ lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
2302
2302
  }
2303
2303
  //支持字段amis属性配置classname,识别classname的类型,与原样式合并
2304
2304
  var className;
@@ -2409,7 +2409,15 @@ async function getMobileTableColumns(fields, options){
2409
2409
  "actions": [
2410
2410
  {
2411
2411
  "script": `
2412
- let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
2412
+ let cms_url = '';
2413
+ let value = event.data.versions[0];
2414
+ if(value){
2415
+ if(value.url){
2416
+ cms_url = value.url;
2417
+ }else{
2418
+ cms_url = "/api/files/files/"+value+"?download=true"
2419
+ }
2420
+ }
2413
2421
  Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
2414
2422
  `,
2415
2423
  "actionType": "custom"
@@ -3041,12 +3049,15 @@ async function getTableApi(mainObject, fields, options){
3041
3049
  }
3042
3050
  // SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
3043
3051
  };
3044
- const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3045
- const firstListviewComponent = listviewComponent && listviewComponent[0];
3046
- if(firstListviewComponent){
3047
- setTimeout(()=>{
3048
- firstListviewComponent.scrollIntoView();
3049
- }, 600);
3052
+ let formFactor = "${options.formFactor}";
3053
+ if(formFactor !== "SMALL"){
3054
+ const listviewComponent = $(".steedos-object-listview .antd-Table-table");
3055
+ const firstListviewComponent = listviewComponent && listviewComponent[0];
3056
+ if(firstListviewComponent){
3057
+ setTimeout(()=>{
3058
+ firstListviewComponent.scrollIntoView();
3059
+ }, 600);
3060
+ }
3050
3061
  }
3051
3062
  ${options.adaptor || ''}
3052
3063
  return payload;
@@ -3391,17 +3402,16 @@ async function getEditFormInitApi(object, recordId, fields, options){
3391
3402
  }
3392
3403
  // data下的变量需要在保存接口(getSaveApi)中被删除。
3393
3404
  payload.data = {
3394
- ...initialValues,
3395
- editFormInited: true
3405
+ ...initialValues
3396
3406
  }
3397
3407
  ${options.initApiAdaptor || ''}
3398
3408
  // console.log('getEditFormInitApi======>', payload);
3399
3409
  return payload;
3400
3410
  `,
3401
- // responseData: {
3402
- // initialValues: "$$",
3403
- // editFormInited: true
3404
- // },
3411
+ responseData: {
3412
+ "&": "$$",
3413
+ editFormInited: true
3414
+ },
3405
3415
  data: data,
3406
3416
  headers: {
3407
3417
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -4244,7 +4254,7 @@ async function getListBody(fields, options){
4244
4254
 
4245
4255
  function getDefaultParams(options){
4246
4256
  return {
4247
- perPage: options.top || options.perPage || 10
4257
+ perPage: options.top || options.perPage || 20
4248
4258
  }
4249
4259
  }
4250
4260
 
@@ -4447,7 +4457,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4447
4457
  "objectApiName": "\${objectName}",
4448
4458
  "recordId": "",
4449
4459
  "mode": "edit",
4450
- "layout": "normal"
4451
4460
  };
4452
4461
 
4453
4462
  if (payload && payload.schema) {
@@ -6719,7 +6728,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6719
6728
  let body = [
6720
6729
  {
6721
6730
  "type": "wrapper",
6722
- "className": "p-4 bg-gray-100 border-b sm:sticky top-0 z-10",
6731
+ "className": "p-4 bg-gray-100 border-b",
6723
6732
  "body": [
6724
6733
  {
6725
6734
  "type": "grid",
@@ -6765,12 +6774,16 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6765
6774
  });
6766
6775
 
6767
6776
  body.push({
6768
- "type": "form",
6769
- "className": "p-4 bg-white compact-layouts",
6770
- "wrapWithPanel": false,
6771
- "actions": [],
6772
- "body": details,
6773
- "hiddenOn": "${recordLoaded != true}"
6777
+ "type": "wrapper",
6778
+ "body": {
6779
+ "type": "form",
6780
+ "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
6781
+ "wrapWithPanel": false,
6782
+ "actions": [],
6783
+ "body": details,
6784
+ "hiddenOn": "${recordLoaded != true}"
6785
+ },
6786
+ "className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
6774
6787
  });
6775
6788
  }
6776
6789
 
@@ -6849,7 +6862,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
6849
6862
  "className": "flex justify-between"
6850
6863
  }
6851
6864
  ],
6852
- "className": "pt-0 pb-2 px-0"
6865
+ "className": "steedos-record-related-header py-2 px-0"
6853
6866
  };
6854
6867
  return recordRelatedListHeader;
6855
6868
  }
@@ -8565,7 +8578,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8565
8578
  // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8566
8579
  // },
8567
8580
  bodyClassName: {
8568
- "bg-white": "true",
8581
+ "mb-0": true,
8569
8582
  "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8570
8583
  },
8571
8584
  crudClassName: crudClassName,
@@ -8721,7 +8734,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
8721
8734
  }
8722
8735
 
8723
8736
  async function getObjectForm(objectSchema, ctx){
8724
- const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8737
+ const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
8725
8738
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8726
8739
  const fields = ___default["default"].values(objectSchema.fields);
8727
8740
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -8815,7 +8828,7 @@ async function getObjectForm(objectSchema, ctx){
8815
8828
  }
8816
8829
 
8817
8830
  async function getObjectDetail(objectSchema, recordId, ctx){
8818
- const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign,
8831
+ const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
8819
8832
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
8820
8833
  const fields = ___default["default"].values(objectSchema.fields);
8821
8834
  const formFields = getFormFields$1(objectSchema, ctx);
@@ -9140,7 +9153,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9140
9153
  setDataToComponentId: componentId,
9141
9154
  // tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
9142
9155
  appId: appId,
9143
- crudClassName: 'border-t border-gray-300 hidden',
9156
+ crudClassName: 'steedos-record-related-crud hidden',
9144
9157
  refField,
9145
9158
  ...ctx
9146
9159
  };
@@ -9153,7 +9166,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9153
9166
  amisSchema: {
9154
9167
  type: "service",
9155
9168
  id: componentId,
9156
- className: `steedos-record-related-list pt-4 pb-2 border-b first:pt-0 last:border-0 ${componentId} ${className}`,
9169
+ className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
9157
9170
  data: {
9158
9171
  relatedKey: relatedKey,
9159
9172
  listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
@@ -9899,7 +9912,8 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9899
9912
  };
9900
9913
  const content = {
9901
9914
  "type": "tabs",
9902
- "className": "steedos-record-tabs p-4 m-0",
9915
+ "className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
9916
+ "contentClassName": "bg-none",
9903
9917
  "tabs": [
9904
9918
  detailed
9905
9919
  ],
@@ -9907,7 +9921,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9907
9921
  if(relatedLists.length){
9908
9922
  content.tabs.push(related);
9909
9923
  }
9910
- content.tabs = _$1.reverse(content.tabs);
9924
+ // content.tabs = reverse(content.tabs)
9911
9925
  return {
9912
9926
  uiSchema,
9913
9927
  amisSchema: {
@@ -11187,8 +11201,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
11187
11201
  labelField: referenceTo.labelField.name,
11188
11202
  valueField: referenceTo.valueField.name,
11189
11203
  // disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
11190
- disabledOn: `${readonly}`,
11191
- hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11204
+ disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11192
11205
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
11193
11206
  source: source,
11194
11207
  size: "lg",
@@ -11431,16 +11444,18 @@ async function lookupToAmis(field, readonly, ctx){
11431
11444
  }
11432
11445
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11433
11446
  if(readonly){
11434
- return {
11435
- type: 'steedos-field',
11436
- config: field,
11437
- static: true
11447
+ if(field.reference_to){
11448
+ return {
11449
+ type: 'steedos-field',
11450
+ config: field,
11451
+ static: true
11452
+ }
11453
+ }else {
11454
+ return {
11455
+ type: getAmisStaticFieldType('picker', readonly),
11456
+ tpl: getRelatedFieldTpl(field, ctx)
11457
+ }
11438
11458
  }
11439
-
11440
- // return {
11441
- // type: Field.getAmisStaticFieldType('picker', readonly),
11442
- // tpl: Tpl.getRelatedFieldTpl(field, ctx)
11443
- // }
11444
11459
  }
11445
11460
  if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
11446
11461
  return {
@@ -12487,7 +12502,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12487
12502
  if(field.is_wide || convertData.type === 'group'){
12488
12503
  convertData.className = 'col-span-2 m-0';
12489
12504
  }else {
12490
- convertData.className = 'm-1';
12505
+ convertData.className = 'm-0';
12491
12506
  }
12492
12507
  if(readonly){
12493
12508
  convertData.className = `${convertData.className} border-b`;
@@ -12512,6 +12527,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12512
12527
  }
12513
12528
  }
12514
12529
 
12530
+ if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
12531
+ convertData.className = `${convertData.className || ''} hidden`;
12532
+ }
12533
+
12515
12534
  if(___namespace.isString(baseData.required)){
12516
12535
  if(baseData.required.startsWith("{{")){
12517
12536
  baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
@@ -12893,9 +12912,41 @@ async function getFormBody(permissionFields, formFields, ctx){
12893
12912
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12894
12913
  * @Date: 2023-11-15 09:50:22
12895
12914
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12896
- * @LastEditTime: 2024-01-16 14:58:51
12915
+ * @LastEditTime: 2024-01-17 17:15:57
12897
12916
  */
12898
12917
 
12918
+ /**
12919
+ * 子表组件字段值中每行数据的键值key移除指定前缀
12920
+ * @param {*} value 子表组件字段值,数组
12921
+ * @param {*} fieldPrefix 字段前缀
12922
+ * @returns 转换后的子表组件字段值
12923
+ */
12924
+ function getTableValueWithoutFieldPrefix(value, fieldPrefix){
12925
+ let convertedValue = [];
12926
+ (value || []).forEach((itemValue)=>{
12927
+ var newItemValue = {};
12928
+ for(let n in itemValue){
12929
+ newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
12930
+ }
12931
+ convertedValue.push(newItemValue);
12932
+ });
12933
+ return convertedValue;
12934
+ }
12935
+
12936
+ /**
12937
+ * 子表组件字段集合属性中每个字段name移除指定前缀
12938
+ * @param {*} fields 子表组件字段集合,数组
12939
+ * @param {*} fieldPrefix 字段前缀
12940
+ * @returns 转换后的子表组件字段值
12941
+ */
12942
+ function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
12943
+ return (fields || []).map((item) => {
12944
+ const newItem = _$1.clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
12945
+ newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
12946
+ return newItem;
12947
+ });
12948
+ }
12949
+
12899
12950
  /**
12900
12951
  * @param {*} props
12901
12952
  * @param {*} mode edit/new/readonly
@@ -13172,7 +13223,7 @@ function getFormPaginationWrapper(props, form, mode) {
13172
13223
  {
13173
13224
  "type": "wrapper",
13174
13225
  "size": "none",
13175
- "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white -mt-2",
13226
+ "className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
13176
13227
  "body": [
13177
13228
  getFormPagination(props, mode)
13178
13229
  ]
@@ -13188,16 +13239,8 @@ function getFormPaginationWrapper(props, form, mode) {
13188
13239
  }
13189
13240
  ];
13190
13241
  let onServiceInitedScript = `
13191
- var parent = event.data.parent;
13192
- var fieldValue = event.data.__tableItems;
13193
- if(parent){
13194
- // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13195
- var primaryKey = "${props.primaryKey}";
13196
- event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13197
- return item[primaryKey] == parent[primaryKey];
13198
- });
13199
- }
13200
- // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13242
+
13243
+ // 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13201
13244
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
13202
13245
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
13203
13246
  // 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
@@ -13210,6 +13253,11 @@ function getFormPaginationWrapper(props, form, mode) {
13210
13253
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13211
13254
  // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
13212
13255
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
13256
+ let fieldPrefix = "${props.fieldPrefix}";
13257
+ if(fieldPrefix){
13258
+ let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
13259
+ lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
13260
+ }
13213
13261
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
13214
13262
  let mode = "${mode}";
13215
13263
  if(mode === "new"){
@@ -13232,6 +13280,16 @@ function getFormPaginationWrapper(props, form, mode) {
13232
13280
  event.data.__tableItems.forEach(function(n,i){
13233
13281
  event.data.__tableItems[i] = lastestFieldValue[i];
13234
13282
  });
13283
+
13284
+ var parent = event.data.parent;
13285
+ var fieldValue = event.data.__tableItems;
13286
+ if(parent){
13287
+ // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13288
+ var primaryKey = "${props.primaryKey}";
13289
+ event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13290
+ return item[primaryKey] == parent[primaryKey];
13291
+ });
13292
+ }
13235
13293
  `;
13236
13294
  let schema = {
13237
13295
  "type": "service",
@@ -13834,6 +13892,11 @@ const getAmisInputTableSchema = async (props) => {
13834
13892
  if(showOperation !== false){
13835
13893
  showOperation = true;
13836
13894
  }
13895
+ // props.fieldPrefix = "project_milestone_";
13896
+ if (props.fieldPrefix) {
13897
+ props.fields = getTableFieldsWithoutFieldPrefix(props.fields, props.fieldPrefix);
13898
+ }
13899
+ console.log("=getAmisInputTableSchema==props.fields, props.fieldPrefix===", props.fields, props.fieldPrefix);
13837
13900
  let serviceId = getComponentId("table_service", props.id);
13838
13901
  let buttonsForColumnOperations = [];
13839
13902
  let inlineEditMode = props.inlineEditMode;
@@ -13894,6 +13957,11 @@ const getAmisInputTableSchema = async (props) => {
13894
13957
  });
13895
13958
  }
13896
13959
  };
13960
+ if(props.fieldPrefix){
13961
+ inputTableSchema.pipeIn = (value, data) => {
13962
+ return getTableValueWithoutFieldPrefix(value, props.fieldPrefix);
13963
+ };
13964
+ }
13897
13965
  if (buttonsForColumnOperations.length) {
13898
13966
  inputTableSchema.columns.push({
13899
13967
  "name": "__op__",