@steedos-widgets/amis-lib 3.6.2-beta.4 → 3.6.2-beta.5

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, 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, reverse, 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';
@@ -2059,11 +2059,12 @@ async function getTableColumns(fields, options){
2059
2059
  //增加quickEdit属性,实现快速编辑
2060
2060
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2061
2061
  let className = "";
2062
- if(field.wrap != true){
2063
- className += " whitespace-nowrap ";
2064
- }else {
2065
- className += " break-all ";
2066
- }
2062
+ //crud内默认换行
2063
+ // if(field.wrap != true){
2064
+ // className += " whitespace-nowrap "
2065
+ // }else{
2066
+ // className += " break-words "
2067
+ // }
2067
2068
  let columnItem;
2068
2069
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
2069
2070
  const previewFileScript = `
@@ -2498,7 +2499,8 @@ async function getTableOperation(ctx){
2498
2499
  label: " ",
2499
2500
  fixed: 'right',
2500
2501
  labelClassName: 'text-center',
2501
- className: 'text-center steedos-listview-operation w-10',
2502
+ //TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
2503
+ className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
2502
2504
  buttons: [
2503
2505
  {
2504
2506
  "type": "steedos-dropdown-button",
@@ -3131,12 +3133,21 @@ function getReadonlyFormAdaptor(object, fields, options){
3131
3133
  }
3132
3134
  payload.data = data;
3133
3135
  payload.data.__objectName = "${object.name}";
3134
- payload.data.__record = record;
3136
+ payload.data.record = record;
3137
+
3138
+ payload.data.name = record.${object.NAME_FIELD_KEY || 'name'};
3139
+ payload.data._master = {
3140
+ record: record,
3141
+ objectName: "${object.name}",
3142
+ recordId: record._id
3143
+ }
3135
3144
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3136
3145
  }
3137
3146
  if(payload.errors){
3138
3147
  payload.status = 2;
3139
3148
  payload.msg = payload.errors[0].message;
3149
+ }else{
3150
+ payload.data.recordLoaded = true;
3140
3151
  }
3141
3152
  ${options && options.initApiAdaptor || ''}
3142
3153
  return payload;
@@ -5113,7 +5124,7 @@ const StandardButtons = {
5113
5124
  }
5114
5125
  };
5115
5126
 
5116
- const getGlobalData$1 = () => {
5127
+ const getGlobalData = () => {
5117
5128
  return {
5118
5129
  now: new Date(),
5119
5130
  };
@@ -5172,7 +5183,7 @@ const getButtonVisible = (button, ctx) => {
5172
5183
  button._visible,
5173
5184
  props.record,
5174
5185
  "#",
5175
- getGlobalData$1(),
5186
+ getGlobalData(),
5176
5187
  props.userSession
5177
5188
  );
5178
5189
  };
@@ -6550,6 +6561,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6550
6561
  return headerSchema;
6551
6562
  }
6552
6563
 
6564
+ function getBackButtonSchema(){
6565
+ return {
6566
+ "type": "service",
6567
+ "onEvent": {
6568
+ "@history_paths.changed": {
6569
+ "actions": [
6570
+ {
6571
+ "actionType": "reload",
6572
+ // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6573
+ "data": {
6574
+ }
6575
+ }
6576
+ ]
6577
+ }
6578
+ },
6579
+ "body":[{
6580
+ "type": "button",
6581
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6582
+ "className":"flex mr-4",
6583
+ "onEvent": {
6584
+ "click": {
6585
+ "actions": [
6586
+ {
6587
+ "actionType": "custom",
6588
+ "script": "window.goBack()"
6589
+ }
6590
+ ]
6591
+ }
6592
+ },
6593
+ "body": [
6594
+ {
6595
+ "type": "steedos-icon",
6596
+ "category": "utility",
6597
+ "name": "back",
6598
+ "colorVariant": "default",
6599
+ "className": "slds-button_icon slds-global-header__icon w-4"
6600
+ }
6601
+ ]
6602
+ }]
6603
+ }
6604
+ }
6605
+
6553
6606
  /**
6554
6607
  * 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
6555
6608
  * @param {*} objectSchema 对象UISchema
@@ -6558,11 +6611,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6558
6611
  * @returns amisSchema
6559
6612
  */
6560
6613
  async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6614
+ // console.log(`getObjectRecordDetailHeader====>`, options)
6561
6615
  const { showRecordTitle = true } = options || {};
6562
6616
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
6563
6617
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
6564
6618
 
6565
- let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6619
+ let amisButtonsSchema = [];
6620
+ if(options.showButtons != false){
6621
+ amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6622
+ }
6623
+
6624
+ let backButtonsSchema = null;
6625
+
6626
+ if(options.showBackButton != false){
6627
+ backButtonsSchema = getBackButtonSchema();
6628
+ }
6566
6629
 
6567
6630
  // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
6568
6631
 
@@ -6577,45 +6640,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6577
6640
  "type": "grid",
6578
6641
  "columns": [
6579
6642
  {
6580
- "body": [{
6581
- "type": "service",
6582
- "onEvent": {
6583
- "@history_paths.changed": {
6584
- "actions": [
6585
- {
6586
- "actionType": "reload",
6587
- // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6588
- "data": {
6589
- }
6590
- }
6591
- ]
6592
- }
6593
- },
6594
- "body":[{
6595
- "type": "button",
6596
- "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6597
- "className":"flex mr-4",
6598
- "onEvent": {
6599
- "click": {
6600
- "actions": [
6601
- {
6602
- "actionType": "custom",
6603
- "script": "window.goBack()"
6604
- }
6605
- ]
6606
- }
6607
- },
6608
- "body": [
6609
- {
6610
- "type": "steedos-icon",
6611
- "category": "utility",
6612
- "name": "back",
6613
- "colorVariant": "default",
6614
- "className": "slds-button_icon slds-global-header__icon w-4"
6615
- }
6616
- ]
6617
- }]
6618
- },{
6643
+ "body": [
6644
+ backButtonsSchema
6645
+ ,{
6619
6646
  "type": "tpl",
6620
6647
  "className": "block",
6621
6648
  // "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
@@ -6665,7 +6692,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6665
6692
  let body = [
6666
6693
  {
6667
6694
  "type": "wrapper",
6668
- "className": "p-0",
6695
+ "className": "p-4",
6669
6696
  "body": [
6670
6697
  {
6671
6698
  "type": "grid",
@@ -6680,7 +6707,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6680
6707
  if(showRecordTitle){
6681
6708
  body.push({
6682
6709
  "type": "wrapper",
6683
- "className": "p-0",
6710
+ "className": "p-4",
6684
6711
  "body": [
6685
6712
  {
6686
6713
  "type": "grid",
@@ -6692,6 +6719,34 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6692
6719
  });
6693
6720
  }
6694
6721
 
6722
+ let max = 10;
6723
+ if(options.formFactor === 'SMALL'){
6724
+ max = 4;
6725
+ }
6726
+
6727
+ if(objectSchema.compactLayouts){
6728
+ const details = [];
6729
+ _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
6730
+ const field = objectSchema.fields[fieldName];
6731
+ if(field){
6732
+ details.push({
6733
+ type: 'steedos-field',
6734
+ static: true,
6735
+ config: field,
6736
+ });
6737
+ }
6738
+ });
6739
+
6740
+ body.push({
6741
+ "type": "form",
6742
+ "className": "p-4 pb-0 bg-white compact-layouts",
6743
+ "wrapWithPanel": false,
6744
+ "actions": [],
6745
+ "body": details,
6746
+ "hiddenOn": "${recordLoaded != true}"
6747
+ });
6748
+ }
6749
+
6695
6750
  return {
6696
6751
  type: 'service',
6697
6752
  id: `page_readonly_${name}_header`,
@@ -8519,7 +8574,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8519
8574
 
8520
8575
  if(body.columns && options.formFactor != 'SMALL'){
8521
8576
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8522
- body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: objectSchema.name + "_display_${_index}", className: "hidden"});
8577
+ body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${}"});
8523
8578
  }
8524
8579
 
8525
8580
  if (defaults) {
@@ -8577,11 +8632,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8577
8632
  }
8578
8633
  }
8579
8634
 
8580
- const getGlobalData = (mode)=>{
8581
- const user = getSteedosAuth();
8582
- return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
8583
- };
8584
-
8585
8635
  const getFormFields$1 = (objectSchema, formProps)=>{
8586
8636
  /**
8587
8637
  * fieldsExtend: 重写字段定义
@@ -8743,8 +8793,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8743
8793
  type: 'service',
8744
8794
  name: `page_readonly_${recordId}`,
8745
8795
  id: serviceId,
8746
- data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
8747
- api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8796
+ // api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8748
8797
  body: [
8749
8798
  {
8750
8799
  "type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
@@ -8770,60 +8819,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8770
8819
  ),
8771
8820
  className: 'steedos-amis-form bg-white',
8772
8821
  actions: [], // 不显示表单默认的提交按钮
8773
- onEvent: {
8774
- [`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
8775
- "actions": [
8776
- {
8777
- "actionType": "reload",
8778
- "componentId": serviceId,
8779
- "expression": "this.__deletedRecord != true"
8780
- },
8781
- {
8782
- // "args": {
8783
- // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
8784
- // "blank": false
8785
- // },
8786
- "actionType": "custom",
8787
- "script": "window.goBack()",
8788
- "expression": "this.__deletedRecord === true"
8789
- }
8790
- ]
8791
- }
8792
- }
8793
8822
  },
8794
8823
  }
8795
8824
  ],
8796
- onEvent: {
8797
- "fetchInited": {
8798
- "weight": 0,
8799
- "actions": [
8800
- {
8801
- actionType: 'broadcast',
8802
- eventName: "recordLoaded",
8803
- args: {
8804
- eventName: "recordLoaded"
8805
- },
8806
- data: {
8807
- objectName: "${event.data.__objectName}",
8808
- record: "${event.data.__record}"
8809
- },
8810
- expression: "${event.data.__response.error != true}"
8811
- },
8812
- {
8813
- "actionType": "setValue",
8814
- "args": {
8815
- value: {
8816
- "recordLoaded": true,
8817
- }
8818
- },
8819
- expression: "${event.data.__response.error != true}"
8820
- }
8821
- ]
8822
- }
8823
- }
8825
+ // onEvent: {
8826
+ // "fetchInited": {
8827
+ // "weight": 0,
8828
+ // "actions": [
8829
+ // {
8830
+ // actionType: 'broadcast',
8831
+ // eventName: "recordLoaded",
8832
+ // args: {
8833
+ // eventName: "recordLoaded"
8834
+ // },
8835
+ // data: {
8836
+ // objectName: "${event.data.__objectName}",
8837
+ // record: "${event.data.__record}"
8838
+ // },
8839
+ // expression: "${event.data.__response.error != true}"
8840
+ // },
8841
+ // {
8842
+ // "actionType": "setValue",
8843
+ // "args": {
8844
+ // value: {
8845
+ // "recordLoaded": true,
8846
+ // }
8847
+ // },
8848
+ // expression: "${event.data.__response.error != true}"
8849
+ // }
8850
+ // ]
8851
+ // }
8852
+ // }
8824
8853
  };
8825
8854
 
8826
8855
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
8856
+ // console.log('getObjectDetail=====>', amisSchema);
8827
8857
  return amisSchema;
8828
8858
  }
8829
8859
 
@@ -8903,8 +8933,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8903
8933
  /*
8904
8934
  * @Author: baozhoutao@steedos.com
8905
8935
  * @Date: 2022-07-05 15:55:39
8906
- * @LastEditors: liaodaxue
8907
- * @LastEditTime: 2023-11-14 15:55:32
8936
+ * @LastEditors: baozhoutao@steedos.com
8937
+ * @LastEditTime: 2024-01-15 10:34:46
8908
8938
  * @Description:
8909
8939
  */
8910
8940
 
@@ -9284,11 +9314,44 @@ async function getRelatedListSchema(
9284
9314
  };
9285
9315
  }
9286
9316
 
9317
+ async function getObjectRelatedListsMiniSchema(objectApiName){
9318
+ const relatedLists = await getObjectRelatedList(objectApiName);
9319
+
9320
+ const relatedListsMiniSchema = [];
9321
+
9322
+ for (const relatedList of relatedLists) {
9323
+ relatedListsMiniSchema.push(
9324
+ {
9325
+ type: 'steedos-record-detail-list-mini',
9326
+ objectApiName: objectApiName,
9327
+ // recordId: recordId,
9328
+ formFactor: formFactor,
9329
+ relatedObjectApiName: relatedList.object_name,
9330
+ foreign_key: relatedList.foreign_key,
9331
+ relatedKey: relatedList.foreign_key,
9332
+ columns: relatedList.columns,
9333
+ sort: relatedList.sort,
9334
+ filters: relatedList.filters,
9335
+ visible_on: relatedList.visible_on,
9336
+ perPage: relatedList.page_size || perPage,
9337
+ hiddenEmptyTable: true,
9338
+ relatedLabel: relatedList.label
9339
+ }
9340
+ );
9341
+ }
9342
+
9343
+ return {
9344
+ type: 'wrapper',
9345
+ className: "steedos-record-detail-related-lists-mini",
9346
+ body: relatedListsMiniSchema
9347
+ }
9348
+ }
9349
+
9287
9350
  /*
9288
9351
  * @Author: baozhoutao@steedos.com
9289
9352
  * @Date: 2022-07-05 15:55:39
9290
- * @LastEditors: liaodaxue
9291
- * @LastEditTime: 2023-10-20 11:38:25
9353
+ * @LastEditors: baozhoutao@steedos.com
9354
+ * @LastEditTime: 2024-01-15 15:50:40
9292
9355
  * @Description:
9293
9356
  */
9294
9357
 
@@ -9460,7 +9523,7 @@ async function getField(objectName, fieldName) {
9460
9523
  async function getFormSchema(objectName, ctx) {
9461
9524
  const uiSchema = await getUISchema(objectName);
9462
9525
  const amisSchema = await getObjectForm(uiSchema, ctx);
9463
- console.log(`getFormSchema====>`, amisSchema);
9526
+ // console.log(`getFormSchema====>`, amisSchema)
9464
9527
  return {
9465
9528
  uiSchema,
9466
9529
  amisSchema,
@@ -9818,61 +9881,95 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9818
9881
  if(relatedLists.length){
9819
9882
  content.tabs.push(related);
9820
9883
  }
9884
+ content.tabs = reverse(content.tabs);
9821
9885
  return {
9822
9886
  uiSchema,
9823
9887
  amisSchema: {
9824
- "type": "service",
9888
+ "type": "steedos-record-service",
9825
9889
  "body": [
9826
9890
  {
9827
9891
  "type": "steedos-record-detail-header",
9828
9892
  "label": "标题面板",
9829
9893
  "objectApiName": "${objectName}",
9830
9894
  "recordId": "${recordId}",
9831
- "id": "u:48d2c28eb755"
9895
+ "id": "u:48d2c28eb755",
9896
+ "showButtons": props.showButtons,
9897
+ "showBackButton": props.showBackButton,
9832
9898
  },
9833
9899
  content
9834
9900
  ],
9835
- data: {
9836
- "_master.objectName": "${objectName}",
9837
- "_master.recordId": "${recordId}"
9838
- },
9839
- onEvent: {
9840
- "recordLoaded": {
9841
- "actions": [
9842
- {
9843
- "actionType": "reload",
9844
- "data": {
9845
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9846
- "_master.record": `\${record}`,
9847
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9848
- "_master.objectName": "${objectName}",
9849
- "_master.recordId": "${recordId}"
9850
- }
9851
- }
9852
- ]
9853
- },
9854
- ...props.onEvent
9855
- },
9901
+ "objectApiName": "${objectName}",
9902
+ "recordId": "${recordId}",
9903
+ onEvent: props.onEvent,
9856
9904
  }
9857
9905
  }
9858
9906
  }
9859
9907
 
9860
9908
  async function getRecordServiceSchema(objectName, appId, props = {}) {
9861
9909
  const uiSchema = await getUISchema(objectName);
9910
+ const fields = ___default.values(uiSchema.fields);
9862
9911
  return {
9863
9912
  uiSchema,
9864
9913
  amisSchema: {
9865
9914
  "type": "service",
9866
- "body": [],
9915
+ className: 'steedos-record-service p-0 md:p-2',
9916
+ api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
9917
+ "body": {
9918
+ "type": "wrapper",
9919
+ "className": "p-0 m-0",
9920
+ "body": [],
9921
+ "hiddenOn": "${recordLoaded != true}"
9922
+ },
9867
9923
  data: {
9868
9924
  "_master.objectName": "${objectName}",
9869
- "_master.recordId": "${recordId}"
9925
+ "_master.recordId": "${recordId}",
9926
+ ...(props.data || {})
9870
9927
  },
9871
9928
  "style": {
9872
- "padding": "var(--Page-body-padding)",
9929
+ // "padding": "var(--Page-body-padding)",
9873
9930
  ...props.style
9874
9931
  },
9875
9932
  onEvent: {
9933
+ [`@data.changed.${objectName}`]: {
9934
+ "actions": [
9935
+ {
9936
+ "actionType": "reload",
9937
+ "expression": "this.__deletedRecord != true"
9938
+ },
9939
+ {
9940
+ "actionType": "custom",
9941
+ "script": "window.goBack()",
9942
+ "expression": "this.__deletedRecord === true"
9943
+ }
9944
+ ]
9945
+ },
9946
+ // 如果定义了fetchInited,则无法接收到广播事件@data.changed
9947
+ // "fetchInited": {
9948
+ // "weight": 0,
9949
+ // "actions": [
9950
+ // // {
9951
+ // // actionType: 'broadcast',
9952
+ // // eventName: "recordLoaded",
9953
+ // // args: {
9954
+ // // eventName: "recordLoaded"
9955
+ // // },
9956
+ // // data: {
9957
+ // // objectName: "${event.data.__objectName}",
9958
+ // // record: "${event.data.__record}"
9959
+ // // },
9960
+ // // expression: "${event.data.__response.error != true}"
9961
+ // // },
9962
+ // {
9963
+ // "actionType": "setValue",
9964
+ // "args": {
9965
+ // value: {
9966
+ // "recordLoaded": true,
9967
+ // }
9968
+ // },
9969
+ // expression: "${event.data.__response.error != true}"
9970
+ // }
9971
+ // ]
9972
+ // },
9876
9973
  "recordLoaded": {
9877
9974
  "actions": [
9878
9975
  {
@@ -9893,6 +9990,45 @@ async function getRecordServiceSchema(objectName, appId, props = {}) {
9893
9990
  }
9894
9991
  }
9895
9992
 
9993
+ async function getRecordDetailMiniSchema(objectName, appId, props = {}){
9994
+ const uiSchema = await getUISchema(objectName);
9995
+ const fields = ___default.values(uiSchema.fields);
9996
+
9997
+ props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
9998
+
9999
+ // TODO 处理相关表
10000
+ // getObjectRelatedListsMiniSchema
10001
+
10002
+ return {
10003
+ type: "form",
10004
+ wrapWithPanel: false,
10005
+ actions: [],
10006
+ initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
10007
+ body: {
10008
+ "type": "wrapper",
10009
+ "className": "p-0 m-0",
10010
+ "body": [
10011
+ {
10012
+ "type": "steedos-record-detail-header",
10013
+ "showButtons": false,
10014
+ "showBackButton": false,
10015
+ "objectApiName": "${objectName}",
10016
+ "recordId": "${recordId}",
10017
+ },
10018
+ // {
10019
+ // "type": "steedos-object-related-lists",
10020
+ // "label": "相关列表",
10021
+ // "objectApiName": "${objectName}",
10022
+ // "staticRecordId": "${recordId}",
10023
+ // formFactor: "SMALL",
10024
+ // appId: appId
10025
+ // }
10026
+ ],
10027
+ "hiddenOn": "${_finished != true}"
10028
+ }
10029
+ }
10030
+ }
10031
+
9896
10032
  // 获取单个相关表
9897
10033
  async function getObjectRelated(
9898
10034
  {appName,
@@ -11040,7 +11176,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
11040
11176
  labelField: referenceTo.labelField.name,
11041
11177
  valueField: referenceTo.valueField.name,
11042
11178
  // disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
11043
- disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11179
+ disabledOn: `${readonly}`,
11180
+ hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11044
11181
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
11045
11182
  source: source,
11046
11183
  size: "lg",
@@ -11284,9 +11421,15 @@ async function lookupToAmis(field, readonly, ctx){
11284
11421
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11285
11422
  if(readonly){
11286
11423
  return {
11287
- type: getAmisStaticFieldType('picker', readonly),
11288
- tpl: getRelatedFieldTpl(field, ctx)
11424
+ type: 'steedos-field',
11425
+ config: field,
11426
+ static: true
11289
11427
  }
11428
+
11429
+ // return {
11430
+ // type: Field.getAmisStaticFieldType('picker', readonly),
11431
+ // tpl: Tpl.getRelatedFieldTpl(field, ctx)
11432
+ // }
11290
11433
  }
11291
11434
  if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
11292
11435
  return {
@@ -12279,11 +12422,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12279
12422
  if(field.subFields){
12280
12423
  convertData = {
12281
12424
  type: 'steedos-input-table',
12282
- showIndex: true,
12283
12425
  editable: !readonly,
12284
12426
  addable: !readonly,
12285
12427
  removable: !readonly,
12286
- draggable: !readonly,
12287
12428
  fields: [],
12288
12429
  amis:{
12289
12430
  columnsTogglable: false
@@ -12741,7 +12882,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12741
12882
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12742
12883
  * @Date: 2023-11-15 09:50:22
12743
12884
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12744
- * @LastEditTime: 2024-01-14 21:08:32
12885
+ * @LastEditTime: 2024-01-15 17:50:02
12745
12886
  */
12746
12887
 
12747
12888
  /**
@@ -12890,8 +13031,15 @@ function getFormPagination(props, mode) {
12890
13031
  let currentIndex = event.data.index;
12891
13032
  // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12892
13033
  let currentFormValues = scope.getComponentById(__formId).getValues();
12893
- if(event.data.parent){
12894
- fieldValue[event.data.__parentIndex].children[currentIndex] = currentFormValues;
13034
+ var parent = event.data.parent;
13035
+ var __parentIndex = event.data.__parentIndex;
13036
+ if(parent){
13037
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13038
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13039
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13040
+ children: fieldValue[__parentIndex].children,
13041
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13042
+ });
12895
13043
  }
12896
13044
  else{
12897
13045
  fieldValue[currentIndex] = currentFormValues;
@@ -13029,9 +13177,14 @@ function getFormPaginationWrapper(props, form, mode) {
13029
13177
  }
13030
13178
  ];
13031
13179
  let onServiceInitedScript = `
13032
- if(event.data.parent){
13180
+ var parent = event.data.parent;
13181
+ var fieldValue = event.data.__tableItems;
13182
+ if(parent){
13033
13183
  // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13034
- event.data.__parentIndex = _.findIndex(event.data.__tableItems, {_id: event.data.parent._id});
13184
+ var primaryKey = "${props.primaryKey}";
13185
+ event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13186
+ return item[primaryKey] == parent[primaryKey];
13187
+ });
13035
13188
  }
13036
13189
  // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13037
13190
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
@@ -13143,6 +13296,11 @@ async function getForm(props, mode = "edit", formId) {
13143
13296
  var __parentIndex = event.data.__super.__super.__parentIndex;
13144
13297
  if(parent){
13145
13298
  fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13299
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13300
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13301
+ children: fieldValue[__parentIndex].children,
13302
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13303
+ });
13146
13304
  }
13147
13305
  else{
13148
13306
  fieldValue[currentIndex] = currentFormValues;
@@ -13287,9 +13445,13 @@ async function getButtonActions(props, mode) {
13287
13445
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13288
13446
  // 新建一条空白行并保存到子表组件
13289
13447
  var parent = event.data.__super.parent;
13290
- var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
13448
+ var primaryKey = "${props.primaryKey}";
13449
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13450
+ return item[primaryKey] == parent[primaryKey];
13451
+ });
13291
13452
  if(parent){
13292
13453
  fieldValue[__parentIndex].children.push({});
13454
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13293
13455
  }
13294
13456
  else{
13295
13457
  fieldValue.push({});
@@ -13324,9 +13486,13 @@ async function getButtonActions(props, mode) {
13324
13486
  // 复制当前页数据到新建行并保存到子表组件
13325
13487
  // fieldValue.push(newItem);
13326
13488
  var parent = event.data.__super.parent;
13327
- var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
13489
+ var primaryKey = "${props.primaryKey}";
13490
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13491
+ return item[primaryKey] == parent[primaryKey];
13492
+ });
13328
13493
  if(parent){
13329
13494
  fieldValue[__parentIndex].children.push(newItem);
13495
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13330
13496
  }
13331
13497
  else{
13332
13498
  fieldValue.push(newItem);
@@ -13342,7 +13508,6 @@ async function getButtonActions(props, mode) {
13342
13508
  let __paginationServiceId = "${formPaginationId}";
13343
13509
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13344
13510
  event.data.index = __paginationData.index;
13345
- // event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13346
13511
  if(parent){
13347
13512
  event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13348
13513
  event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
@@ -13431,8 +13596,9 @@ async function getButtonActions(props, mode) {
13431
13596
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13432
13597
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13433
13598
  // "__tableItems": `\${${props.name}|json|toJson}`
13434
- // 这里加__super.__super是因为要让映射到准确的作用域层,如果不加,在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组
13435
- "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13599
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13600
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13601
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13436
13602
  },
13437
13603
  "actions": dialogButtons,
13438
13604
  "onEvent": {
@@ -13550,9 +13716,17 @@ async function getButtonActions(props, mode) {
13550
13716
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13551
13717
  var currentIndex = event.data.index;
13552
13718
  var parent = event.data.__super.parent;
13553
- var __parentIndex = parent && _.findIndex(lastestFieldValue, {_id: parent._id});
13719
+ var primaryKey = "${props.primaryKey}";
13720
+ var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
13721
+ return item[primaryKey] == parent[primaryKey];
13722
+ });
13554
13723
  if(parent){
13555
13724
  lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
13725
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13726
+ lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
13727
+ children: lastestFieldValue[__parentIndex].children,
13728
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13729
+ });
13556
13730
  }
13557
13731
  else{
13558
13732
  lastestFieldValue.splice(currentIndex, 1);
@@ -13642,6 +13816,9 @@ const getAmisInputTableSchema = async (props) => {
13642
13816
  if (!props.id) {
13643
13817
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13644
13818
  }
13819
+ if (!props.primaryKey) {
13820
+ props.primaryKey = "_id";
13821
+ }
13645
13822
  let serviceId = getComponentId("table_service", props.id);
13646
13823
  let buttonsForColumnOperations = [];
13647
13824
  let inlineEditMode = props.inlineEditMode;
@@ -13692,7 +13869,13 @@ const getAmisInputTableSchema = async (props) => {
13692
13869
  "strictMode": props.strictMode,
13693
13870
  "showTableAddBtn": false,
13694
13871
  "showFooterAddBtn": false,
13695
- "className": props.tableClassName
13872
+ "className": props.tableClassName,
13873
+ "pipeOut": (value, data) => {
13874
+ return (value || []).map(function(item){
13875
+ delete item.__fix_rerender_after_children_modified_tag;
13876
+ return item;
13877
+ });
13878
+ }
13696
13879
  };
13697
13880
  if (buttonsForColumnOperations.length) {
13698
13881
  inputTableSchema.columns.push({
@@ -16414,5 +16597,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
16414
16597
  };
16415
16598
  };
16416
16599
 
16417
- export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
16600
+ export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getObjectRelatedListsMiniSchema, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailMiniSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
16418
16601
  //# sourceMappingURL=index.esm.js.map