@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.cjs.js CHANGED
@@ -2086,11 +2086,12 @@ async function getTableColumns(fields, options){
2086
2086
  //增加quickEdit属性,实现快速编辑
2087
2087
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2088
2088
  let className = "";
2089
- if(field.wrap != true){
2090
- className += " whitespace-nowrap ";
2091
- }else {
2092
- className += " break-all ";
2093
- }
2089
+ //crud内默认换行
2090
+ // if(field.wrap != true){
2091
+ // className += " whitespace-nowrap "
2092
+ // }else{
2093
+ // className += " break-words "
2094
+ // }
2094
2095
  let columnItem;
2095
2096
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
2096
2097
  const previewFileScript = `
@@ -2525,7 +2526,8 @@ async function getTableOperation(ctx){
2525
2526
  label: " ",
2526
2527
  fixed: 'right',
2527
2528
  labelClassName: 'text-center',
2528
- className: 'text-center steedos-listview-operation w-10',
2529
+ //TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
2530
+ className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
2529
2531
  buttons: [
2530
2532
  {
2531
2533
  "type": "steedos-dropdown-button",
@@ -3158,12 +3160,21 @@ function getReadonlyFormAdaptor(object, fields, options){
3158
3160
  }
3159
3161
  payload.data = data;
3160
3162
  payload.data.__objectName = "${object.name}";
3161
- payload.data.__record = record;
3163
+ payload.data.record = record;
3164
+
3165
+ payload.data.name = record.${object.NAME_FIELD_KEY || 'name'};
3166
+ payload.data._master = {
3167
+ record: record,
3168
+ objectName: "${object.name}",
3169
+ recordId: record._id
3170
+ }
3162
3171
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3163
3172
  }
3164
3173
  if(payload.errors){
3165
3174
  payload.status = 2;
3166
3175
  payload.msg = payload.errors[0].message;
3176
+ }else{
3177
+ payload.data.recordLoaded = true;
3167
3178
  }
3168
3179
  ${options && options.initApiAdaptor || ''}
3169
3180
  return payload;
@@ -5140,7 +5151,7 @@ const StandardButtons = {
5140
5151
  }
5141
5152
  };
5142
5153
 
5143
- const getGlobalData$1 = () => {
5154
+ const getGlobalData = () => {
5144
5155
  return {
5145
5156
  now: new Date(),
5146
5157
  };
@@ -5199,7 +5210,7 @@ const getButtonVisible = (button, ctx) => {
5199
5210
  button._visible,
5200
5211
  props.record,
5201
5212
  "#",
5202
- getGlobalData$1(),
5213
+ getGlobalData(),
5203
5214
  props.userSession
5204
5215
  );
5205
5216
  };
@@ -6577,6 +6588,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6577
6588
  return headerSchema;
6578
6589
  }
6579
6590
 
6591
+ function getBackButtonSchema(){
6592
+ return {
6593
+ "type": "service",
6594
+ "onEvent": {
6595
+ "@history_paths.changed": {
6596
+ "actions": [
6597
+ {
6598
+ "actionType": "reload",
6599
+ // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6600
+ "data": {
6601
+ }
6602
+ }
6603
+ ]
6604
+ }
6605
+ },
6606
+ "body":[{
6607
+ "type": "button",
6608
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6609
+ "className":"flex mr-4",
6610
+ "onEvent": {
6611
+ "click": {
6612
+ "actions": [
6613
+ {
6614
+ "actionType": "custom",
6615
+ "script": "window.goBack()"
6616
+ }
6617
+ ]
6618
+ }
6619
+ },
6620
+ "body": [
6621
+ {
6622
+ "type": "steedos-icon",
6623
+ "category": "utility",
6624
+ "name": "back",
6625
+ "colorVariant": "default",
6626
+ "className": "slds-button_icon slds-global-header__icon w-4"
6627
+ }
6628
+ ]
6629
+ }]
6630
+ }
6631
+ }
6632
+
6580
6633
  /**
6581
6634
  * 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
6582
6635
  * @param {*} objectSchema 对象UISchema
@@ -6585,11 +6638,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
6585
6638
  * @returns amisSchema
6586
6639
  */
6587
6640
  async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6641
+ // console.log(`getObjectRecordDetailHeader====>`, options)
6588
6642
  const { showRecordTitle = true } = options || {};
6589
6643
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
6590
6644
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
6591
6645
 
6592
- let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6646
+ let amisButtonsSchema = [];
6647
+ if(options.showButtons != false){
6648
+ amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6649
+ }
6650
+
6651
+ let backButtonsSchema = null;
6652
+
6653
+ if(options.showBackButton != false){
6654
+ backButtonsSchema = getBackButtonSchema();
6655
+ }
6593
6656
 
6594
6657
  // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
6595
6658
 
@@ -6604,45 +6667,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6604
6667
  "type": "grid",
6605
6668
  "columns": [
6606
6669
  {
6607
- "body": [{
6608
- "type": "service",
6609
- "onEvent": {
6610
- "@history_paths.changed": {
6611
- "actions": [
6612
- {
6613
- "actionType": "reload",
6614
- // amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
6615
- "data": {
6616
- }
6617
- }
6618
- ]
6619
- }
6620
- },
6621
- "body":[{
6622
- "type": "button",
6623
- "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
6624
- "className":"flex mr-4",
6625
- "onEvent": {
6626
- "click": {
6627
- "actions": [
6628
- {
6629
- "actionType": "custom",
6630
- "script": "window.goBack()"
6631
- }
6632
- ]
6633
- }
6634
- },
6635
- "body": [
6636
- {
6637
- "type": "steedos-icon",
6638
- "category": "utility",
6639
- "name": "back",
6640
- "colorVariant": "default",
6641
- "className": "slds-button_icon slds-global-header__icon w-4"
6642
- }
6643
- ]
6644
- }]
6645
- },{
6670
+ "body": [
6671
+ backButtonsSchema
6672
+ ,{
6646
6673
  "type": "tpl",
6647
6674
  "className": "block",
6648
6675
  // "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'>`
@@ -6692,7 +6719,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6692
6719
  let body = [
6693
6720
  {
6694
6721
  "type": "wrapper",
6695
- "className": "p-0",
6722
+ "className": "p-4",
6696
6723
  "body": [
6697
6724
  {
6698
6725
  "type": "grid",
@@ -6707,7 +6734,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6707
6734
  if(showRecordTitle){
6708
6735
  body.push({
6709
6736
  "type": "wrapper",
6710
- "className": "p-0",
6737
+ "className": "p-4",
6711
6738
  "body": [
6712
6739
  {
6713
6740
  "type": "grid",
@@ -6719,6 +6746,34 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6719
6746
  });
6720
6747
  }
6721
6748
 
6749
+ let max = 10;
6750
+ if(options.formFactor === 'SMALL'){
6751
+ max = 4;
6752
+ }
6753
+
6754
+ if(objectSchema.compactLayouts){
6755
+ const details = [];
6756
+ _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
6757
+ const field = objectSchema.fields[fieldName];
6758
+ if(field){
6759
+ details.push({
6760
+ type: 'steedos-field',
6761
+ static: true,
6762
+ config: field,
6763
+ });
6764
+ }
6765
+ });
6766
+
6767
+ body.push({
6768
+ "type": "form",
6769
+ "className": "p-4 pb-0 bg-white compact-layouts",
6770
+ "wrapWithPanel": false,
6771
+ "actions": [],
6772
+ "body": details,
6773
+ "hiddenOn": "${recordLoaded != true}"
6774
+ });
6775
+ }
6776
+
6722
6777
  return {
6723
6778
  type: 'service',
6724
6779
  id: `page_readonly_${name}_header`,
@@ -8546,7 +8601,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8546
8601
 
8547
8602
  if(body.columns && options.formFactor != 'SMALL'){
8548
8603
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8549
- body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: objectSchema.name + "_display_${_index}", className: "hidden"});
8604
+ body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${}"});
8550
8605
  }
8551
8606
 
8552
8607
  if (defaults) {
@@ -8604,11 +8659,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8604
8659
  }
8605
8660
  }
8606
8661
 
8607
- const getGlobalData = (mode)=>{
8608
- const user = getSteedosAuth();
8609
- return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
8610
- };
8611
-
8612
8662
  const getFormFields$1 = (objectSchema, formProps)=>{
8613
8663
  /**
8614
8664
  * fieldsExtend: 重写字段定义
@@ -8770,8 +8820,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8770
8820
  type: 'service',
8771
8821
  name: `page_readonly_${recordId}`,
8772
8822
  id: serviceId,
8773
- data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
8774
- api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8823
+ // api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8775
8824
  body: [
8776
8825
  {
8777
8826
  "type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
@@ -8797,60 +8846,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8797
8846
  ),
8798
8847
  className: 'steedos-amis-form bg-white',
8799
8848
  actions: [], // 不显示表单默认的提交按钮
8800
- onEvent: {
8801
- [`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
8802
- "actions": [
8803
- {
8804
- "actionType": "reload",
8805
- "componentId": serviceId,
8806
- "expression": "this.__deletedRecord != true"
8807
- },
8808
- {
8809
- // "args": {
8810
- // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
8811
- // "blank": false
8812
- // },
8813
- "actionType": "custom",
8814
- "script": "window.goBack()",
8815
- "expression": "this.__deletedRecord === true"
8816
- }
8817
- ]
8818
- }
8819
- }
8820
8849
  },
8821
8850
  }
8822
8851
  ],
8823
- onEvent: {
8824
- "fetchInited": {
8825
- "weight": 0,
8826
- "actions": [
8827
- {
8828
- actionType: 'broadcast',
8829
- eventName: "recordLoaded",
8830
- args: {
8831
- eventName: "recordLoaded"
8832
- },
8833
- data: {
8834
- objectName: "${event.data.__objectName}",
8835
- record: "${event.data.__record}"
8836
- },
8837
- expression: "${event.data.__response.error != true}"
8838
- },
8839
- {
8840
- "actionType": "setValue",
8841
- "args": {
8842
- value: {
8843
- "recordLoaded": true,
8844
- }
8845
- },
8846
- expression: "${event.data.__response.error != true}"
8847
- }
8848
- ]
8849
- }
8850
- }
8852
+ // onEvent: {
8853
+ // "fetchInited": {
8854
+ // "weight": 0,
8855
+ // "actions": [
8856
+ // {
8857
+ // actionType: 'broadcast',
8858
+ // eventName: "recordLoaded",
8859
+ // args: {
8860
+ // eventName: "recordLoaded"
8861
+ // },
8862
+ // data: {
8863
+ // objectName: "${event.data.__objectName}",
8864
+ // record: "${event.data.__record}"
8865
+ // },
8866
+ // expression: "${event.data.__response.error != true}"
8867
+ // },
8868
+ // {
8869
+ // "actionType": "setValue",
8870
+ // "args": {
8871
+ // value: {
8872
+ // "recordLoaded": true,
8873
+ // }
8874
+ // },
8875
+ // expression: "${event.data.__response.error != true}"
8876
+ // }
8877
+ // ]
8878
+ // }
8879
+ // }
8851
8880
  };
8852
8881
 
8853
8882
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
8883
+ // console.log('getObjectDetail=====>', amisSchema);
8854
8884
  return amisSchema;
8855
8885
  }
8856
8886
 
@@ -8930,8 +8960,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8930
8960
  /*
8931
8961
  * @Author: baozhoutao@steedos.com
8932
8962
  * @Date: 2022-07-05 15:55:39
8933
- * @LastEditors: liaodaxue
8934
- * @LastEditTime: 2023-11-14 15:55:32
8963
+ * @LastEditors: baozhoutao@steedos.com
8964
+ * @LastEditTime: 2024-01-15 10:34:46
8935
8965
  * @Description:
8936
8966
  */
8937
8967
 
@@ -9311,11 +9341,44 @@ async function getRelatedListSchema(
9311
9341
  };
9312
9342
  }
9313
9343
 
9344
+ async function getObjectRelatedListsMiniSchema(objectApiName){
9345
+ const relatedLists = await getObjectRelatedList(objectApiName);
9346
+
9347
+ const relatedListsMiniSchema = [];
9348
+
9349
+ for (const relatedList of relatedLists) {
9350
+ relatedListsMiniSchema.push(
9351
+ {
9352
+ type: 'steedos-record-detail-list-mini',
9353
+ objectApiName: objectApiName,
9354
+ // recordId: recordId,
9355
+ formFactor: formFactor,
9356
+ relatedObjectApiName: relatedList.object_name,
9357
+ foreign_key: relatedList.foreign_key,
9358
+ relatedKey: relatedList.foreign_key,
9359
+ columns: relatedList.columns,
9360
+ sort: relatedList.sort,
9361
+ filters: relatedList.filters,
9362
+ visible_on: relatedList.visible_on,
9363
+ perPage: relatedList.page_size || perPage,
9364
+ hiddenEmptyTable: true,
9365
+ relatedLabel: relatedList.label
9366
+ }
9367
+ );
9368
+ }
9369
+
9370
+ return {
9371
+ type: 'wrapper',
9372
+ className: "steedos-record-detail-related-lists-mini",
9373
+ body: relatedListsMiniSchema
9374
+ }
9375
+ }
9376
+
9314
9377
  /*
9315
9378
  * @Author: baozhoutao@steedos.com
9316
9379
  * @Date: 2022-07-05 15:55:39
9317
- * @LastEditors: liaodaxue
9318
- * @LastEditTime: 2023-10-20 11:38:25
9380
+ * @LastEditors: baozhoutao@steedos.com
9381
+ * @LastEditTime: 2024-01-15 15:50:40
9319
9382
  * @Description:
9320
9383
  */
9321
9384
 
@@ -9487,7 +9550,7 @@ async function getField(objectName, fieldName) {
9487
9550
  async function getFormSchema(objectName, ctx) {
9488
9551
  const uiSchema = await getUISchema(objectName);
9489
9552
  const amisSchema = await getObjectForm(uiSchema, ctx);
9490
- console.log(`getFormSchema====>`, amisSchema);
9553
+ // console.log(`getFormSchema====>`, amisSchema)
9491
9554
  return {
9492
9555
  uiSchema,
9493
9556
  amisSchema,
@@ -9845,61 +9908,95 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9845
9908
  if(relatedLists.length){
9846
9909
  content.tabs.push(related);
9847
9910
  }
9911
+ content.tabs = _$1.reverse(content.tabs);
9848
9912
  return {
9849
9913
  uiSchema,
9850
9914
  amisSchema: {
9851
- "type": "service",
9915
+ "type": "steedos-record-service",
9852
9916
  "body": [
9853
9917
  {
9854
9918
  "type": "steedos-record-detail-header",
9855
9919
  "label": "标题面板",
9856
9920
  "objectApiName": "${objectName}",
9857
9921
  "recordId": "${recordId}",
9858
- "id": "u:48d2c28eb755"
9922
+ "id": "u:48d2c28eb755",
9923
+ "showButtons": props.showButtons,
9924
+ "showBackButton": props.showBackButton,
9859
9925
  },
9860
9926
  content
9861
9927
  ],
9862
- data: {
9863
- "_master.objectName": "${objectName}",
9864
- "_master.recordId": "${recordId}"
9865
- },
9866
- onEvent: {
9867
- "recordLoaded": {
9868
- "actions": [
9869
- {
9870
- "actionType": "reload",
9871
- "data": {
9872
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9873
- "_master.record": `\${record}`,
9874
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9875
- "_master.objectName": "${objectName}",
9876
- "_master.recordId": "${recordId}"
9877
- }
9878
- }
9879
- ]
9880
- },
9881
- ...props.onEvent
9882
- },
9928
+ "objectApiName": "${objectName}",
9929
+ "recordId": "${recordId}",
9930
+ onEvent: props.onEvent,
9883
9931
  }
9884
9932
  }
9885
9933
  }
9886
9934
 
9887
9935
  async function getRecordServiceSchema(objectName, appId, props = {}) {
9888
9936
  const uiSchema = await getUISchema(objectName);
9937
+ const fields = ___default["default"].values(uiSchema.fields);
9889
9938
  return {
9890
9939
  uiSchema,
9891
9940
  amisSchema: {
9892
9941
  "type": "service",
9893
- "body": [],
9942
+ className: 'steedos-record-service p-0 md:p-2',
9943
+ api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
9944
+ "body": {
9945
+ "type": "wrapper",
9946
+ "className": "p-0 m-0",
9947
+ "body": [],
9948
+ "hiddenOn": "${recordLoaded != true}"
9949
+ },
9894
9950
  data: {
9895
9951
  "_master.objectName": "${objectName}",
9896
- "_master.recordId": "${recordId}"
9952
+ "_master.recordId": "${recordId}",
9953
+ ...(props.data || {})
9897
9954
  },
9898
9955
  "style": {
9899
- "padding": "var(--Page-body-padding)",
9956
+ // "padding": "var(--Page-body-padding)",
9900
9957
  ...props.style
9901
9958
  },
9902
9959
  onEvent: {
9960
+ [`@data.changed.${objectName}`]: {
9961
+ "actions": [
9962
+ {
9963
+ "actionType": "reload",
9964
+ "expression": "this.__deletedRecord != true"
9965
+ },
9966
+ {
9967
+ "actionType": "custom",
9968
+ "script": "window.goBack()",
9969
+ "expression": "this.__deletedRecord === true"
9970
+ }
9971
+ ]
9972
+ },
9973
+ // 如果定义了fetchInited,则无法接收到广播事件@data.changed
9974
+ // "fetchInited": {
9975
+ // "weight": 0,
9976
+ // "actions": [
9977
+ // // {
9978
+ // // actionType: 'broadcast',
9979
+ // // eventName: "recordLoaded",
9980
+ // // args: {
9981
+ // // eventName: "recordLoaded"
9982
+ // // },
9983
+ // // data: {
9984
+ // // objectName: "${event.data.__objectName}",
9985
+ // // record: "${event.data.__record}"
9986
+ // // },
9987
+ // // expression: "${event.data.__response.error != true}"
9988
+ // // },
9989
+ // {
9990
+ // "actionType": "setValue",
9991
+ // "args": {
9992
+ // value: {
9993
+ // "recordLoaded": true,
9994
+ // }
9995
+ // },
9996
+ // expression: "${event.data.__response.error != true}"
9997
+ // }
9998
+ // ]
9999
+ // },
9903
10000
  "recordLoaded": {
9904
10001
  "actions": [
9905
10002
  {
@@ -9920,6 +10017,45 @@ async function getRecordServiceSchema(objectName, appId, props = {}) {
9920
10017
  }
9921
10018
  }
9922
10019
 
10020
+ async function getRecordDetailMiniSchema(objectName, appId, props = {}){
10021
+ const uiSchema = await getUISchema(objectName);
10022
+ const fields = ___default["default"].values(uiSchema.fields);
10023
+
10024
+ props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
10025
+
10026
+ // TODO 处理相关表
10027
+ // getObjectRelatedListsMiniSchema
10028
+
10029
+ return {
10030
+ type: "form",
10031
+ wrapWithPanel: false,
10032
+ actions: [],
10033
+ initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
10034
+ body: {
10035
+ "type": "wrapper",
10036
+ "className": "p-0 m-0",
10037
+ "body": [
10038
+ {
10039
+ "type": "steedos-record-detail-header",
10040
+ "showButtons": false,
10041
+ "showBackButton": false,
10042
+ "objectApiName": "${objectName}",
10043
+ "recordId": "${recordId}",
10044
+ },
10045
+ // {
10046
+ // "type": "steedos-object-related-lists",
10047
+ // "label": "相关列表",
10048
+ // "objectApiName": "${objectName}",
10049
+ // "staticRecordId": "${recordId}",
10050
+ // formFactor: "SMALL",
10051
+ // appId: appId
10052
+ // }
10053
+ ],
10054
+ "hiddenOn": "${_finished != true}"
10055
+ }
10056
+ }
10057
+ }
10058
+
9923
10059
  // 获取单个相关表
9924
10060
  async function getObjectRelated(
9925
10061
  {appName,
@@ -11067,7 +11203,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
11067
11203
  labelField: referenceTo.labelField.name,
11068
11204
  valueField: referenceTo.valueField.name,
11069
11205
  // disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
11070
- disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11206
+ disabledOn: `${readonly}`,
11207
+ hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
11071
11208
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
11072
11209
  source: source,
11073
11210
  size: "lg",
@@ -11311,9 +11448,15 @@ async function lookupToAmis(field, readonly, ctx){
11311
11448
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11312
11449
  if(readonly){
11313
11450
  return {
11314
- type: getAmisStaticFieldType('picker', readonly),
11315
- tpl: getRelatedFieldTpl(field, ctx)
11451
+ type: 'steedos-field',
11452
+ config: field,
11453
+ static: true
11316
11454
  }
11455
+
11456
+ // return {
11457
+ // type: Field.getAmisStaticFieldType('picker', readonly),
11458
+ // tpl: Tpl.getRelatedFieldTpl(field, ctx)
11459
+ // }
11317
11460
  }
11318
11461
  if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
11319
11462
  return {
@@ -12306,11 +12449,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12306
12449
  if(field.subFields){
12307
12450
  convertData = {
12308
12451
  type: 'steedos-input-table',
12309
- showIndex: true,
12310
12452
  editable: !readonly,
12311
12453
  addable: !readonly,
12312
12454
  removable: !readonly,
12313
- draggable: !readonly,
12314
12455
  fields: [],
12315
12456
  amis:{
12316
12457
  columnsTogglable: false
@@ -12768,7 +12909,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12768
12909
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12769
12910
  * @Date: 2023-11-15 09:50:22
12770
12911
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12771
- * @LastEditTime: 2024-01-14 21:08:32
12912
+ * @LastEditTime: 2024-01-15 17:50:02
12772
12913
  */
12773
12914
 
12774
12915
  /**
@@ -12917,8 +13058,15 @@ function getFormPagination(props, mode) {
12917
13058
  let currentIndex = event.data.index;
12918
13059
  // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12919
13060
  let currentFormValues = scope.getComponentById(__formId).getValues();
12920
- if(event.data.parent){
12921
- fieldValue[event.data.__parentIndex].children[currentIndex] = currentFormValues;
13061
+ var parent = event.data.parent;
13062
+ var __parentIndex = event.data.__parentIndex;
13063
+ if(parent){
13064
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13065
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13066
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13067
+ children: fieldValue[__parentIndex].children,
13068
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13069
+ });
12922
13070
  }
12923
13071
  else{
12924
13072
  fieldValue[currentIndex] = currentFormValues;
@@ -13056,9 +13204,14 @@ function getFormPaginationWrapper(props, form, mode) {
13056
13204
  }
13057
13205
  ];
13058
13206
  let onServiceInitedScript = `
13059
- if(event.data.parent){
13207
+ var parent = event.data.parent;
13208
+ var fieldValue = event.data.__tableItems;
13209
+ if(parent){
13060
13210
  // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13061
- event.data.__parentIndex = _.findIndex(event.data.__tableItems, {_id: event.data.parent._id});
13211
+ var primaryKey = "${props.primaryKey}";
13212
+ event.data.__parentIndex = _.findIndex(fieldValue, function(item){
13213
+ return item[primaryKey] == parent[primaryKey];
13214
+ });
13062
13215
  }
13063
13216
  // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13064
13217
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
@@ -13170,6 +13323,11 @@ async function getForm(props, mode = "edit", formId) {
13170
13323
  var __parentIndex = event.data.__super.__super.__parentIndex;
13171
13324
  if(parent){
13172
13325
  fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13326
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13327
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13328
+ children: fieldValue[__parentIndex].children,
13329
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13330
+ });
13173
13331
  }
13174
13332
  else{
13175
13333
  fieldValue[currentIndex] = currentFormValues;
@@ -13314,9 +13472,13 @@ async function getButtonActions(props, mode) {
13314
13472
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13315
13473
  // 新建一条空白行并保存到子表组件
13316
13474
  var parent = event.data.__super.parent;
13317
- var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
13475
+ var primaryKey = "${props.primaryKey}";
13476
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13477
+ return item[primaryKey] == parent[primaryKey];
13478
+ });
13318
13479
  if(parent){
13319
13480
  fieldValue[__parentIndex].children.push({});
13481
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13320
13482
  }
13321
13483
  else{
13322
13484
  fieldValue.push({});
@@ -13351,9 +13513,13 @@ async function getButtonActions(props, mode) {
13351
13513
  // 复制当前页数据到新建行并保存到子表组件
13352
13514
  // fieldValue.push(newItem);
13353
13515
  var parent = event.data.__super.parent;
13354
- var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
13516
+ var primaryKey = "${props.primaryKey}";
13517
+ var __parentIndex = parent && _.findIndex(fieldValue, function(item){
13518
+ return item[primaryKey] == parent[primaryKey];
13519
+ });
13355
13520
  if(parent){
13356
13521
  fieldValue[__parentIndex].children.push(newItem);
13522
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13357
13523
  }
13358
13524
  else{
13359
13525
  fieldValue.push(newItem);
@@ -13369,7 +13535,6 @@ async function getButtonActions(props, mode) {
13369
13535
  let __paginationServiceId = "${formPaginationId}";
13370
13536
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13371
13537
  event.data.index = __paginationData.index;
13372
- // event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13373
13538
  if(parent){
13374
13539
  event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13375
13540
  event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
@@ -13458,8 +13623,9 @@ async function getButtonActions(props, mode) {
13458
13623
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13459
13624
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13460
13625
  // "__tableItems": `\${${props.name}|json|toJson}`
13461
- // 这里加__super.__super是因为要让映射到准确的作用域层,如果不加,在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组
13462
- "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13626
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13627
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13628
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13463
13629
  },
13464
13630
  "actions": dialogButtons,
13465
13631
  "onEvent": {
@@ -13577,9 +13743,17 @@ async function getButtonActions(props, mode) {
13577
13743
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13578
13744
  var currentIndex = event.data.index;
13579
13745
  var parent = event.data.__super.parent;
13580
- var __parentIndex = parent && _.findIndex(lastestFieldValue, {_id: parent._id});
13746
+ var primaryKey = "${props.primaryKey}";
13747
+ var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
13748
+ return item[primaryKey] == parent[primaryKey];
13749
+ });
13581
13750
  if(parent){
13582
13751
  lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
13752
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13753
+ lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
13754
+ children: lastestFieldValue[__parentIndex].children,
13755
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13756
+ });
13583
13757
  }
13584
13758
  else{
13585
13759
  lastestFieldValue.splice(currentIndex, 1);
@@ -13669,6 +13843,9 @@ const getAmisInputTableSchema = async (props) => {
13669
13843
  if (!props.id) {
13670
13844
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13671
13845
  }
13846
+ if (!props.primaryKey) {
13847
+ props.primaryKey = "_id";
13848
+ }
13672
13849
  let serviceId = getComponentId("table_service", props.id);
13673
13850
  let buttonsForColumnOperations = [];
13674
13851
  let inlineEditMode = props.inlineEditMode;
@@ -13719,7 +13896,13 @@ const getAmisInputTableSchema = async (props) => {
13719
13896
  "strictMode": props.strictMode,
13720
13897
  "showTableAddBtn": false,
13721
13898
  "showFooterAddBtn": false,
13722
- "className": props.tableClassName
13899
+ "className": props.tableClassName,
13900
+ "pipeOut": (value, data) => {
13901
+ return (value || []).map(function(item){
13902
+ delete item.__fix_rerender_after_children_modified_tag;
13903
+ return item;
13904
+ });
13905
+ }
13723
13906
  };
13724
13907
  if (buttonsForColumnOperations.length) {
13725
13908
  inputTableSchema.columns.push({
@@ -16511,9 +16694,11 @@ exports.getObjectRelated = getObjectRelated;
16511
16694
  exports.getObjectRelatedList = getObjectRelatedList;
16512
16695
  exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
16513
16696
  exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
16697
+ exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
16514
16698
  exports.getPage = getPage;
16515
16699
  exports.getRecord = getRecord;
16516
16700
  exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
16701
+ exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
16517
16702
  exports.getRecordDetailRelatedListSchema = getRecordDetailRelatedListSchema;
16518
16703
  exports.getRecordDetailSchema = getRecordDetailSchema;
16519
16704
  exports.getRecordPageInitSchema = getRecordPageInitSchema;