@steedos-widgets/amis-lib 3.6.2-beta.3 → 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`,
@@ -8134,7 +8189,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8134
8189
  // ]
8135
8190
  if(options.displayAs === 'split'){
8136
8191
  return [
8137
- "switch-per-page",
8192
+ {
8193
+ "type": "switch-per-page",
8194
+ "visibleOn": "${count >= 20}"
8195
+ },
8138
8196
  {
8139
8197
  "type": "pagination",
8140
8198
  "maxButtons": 5,
@@ -8178,7 +8236,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8178
8236
  if (no_pagination && is_lookup) {
8179
8237
  return commonConfig;
8180
8238
  } else {
8181
- return ["switch-per-page", ...commonConfig];
8239
+ return [{
8240
+ "type": "switch-per-page",
8241
+ "visibleOn": "${count >= 20}"
8242
+ }, ...commonConfig];
8182
8243
  }
8183
8244
  }
8184
8245
  }
@@ -8540,7 +8601,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8540
8601
 
8541
8602
  if(body.columns && options.formFactor != 'SMALL'){
8542
8603
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8543
- 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: "${}"});
8544
8605
  }
8545
8606
 
8546
8607
  if (defaults) {
@@ -8598,11 +8659,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8598
8659
  }
8599
8660
  }
8600
8661
 
8601
- const getGlobalData = (mode)=>{
8602
- const user = getSteedosAuth();
8603
- return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
8604
- };
8605
-
8606
8662
  const getFormFields$1 = (objectSchema, formProps)=>{
8607
8663
  /**
8608
8664
  * fieldsExtend: 重写字段定义
@@ -8764,8 +8820,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8764
8820
  type: 'service',
8765
8821
  name: `page_readonly_${recordId}`,
8766
8822
  id: serviceId,
8767
- data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
8768
- api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8823
+ // api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8769
8824
  body: [
8770
8825
  {
8771
8826
  "type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
@@ -8791,60 +8846,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8791
8846
  ),
8792
8847
  className: 'steedos-amis-form bg-white',
8793
8848
  actions: [], // 不显示表单默认的提交按钮
8794
- onEvent: {
8795
- [`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
8796
- "actions": [
8797
- {
8798
- "actionType": "reload",
8799
- "componentId": serviceId,
8800
- "expression": "this.__deletedRecord != true"
8801
- },
8802
- {
8803
- // "args": {
8804
- // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
8805
- // "blank": false
8806
- // },
8807
- "actionType": "custom",
8808
- "script": "window.goBack()",
8809
- "expression": "this.__deletedRecord === true"
8810
- }
8811
- ]
8812
- }
8813
- }
8814
8849
  },
8815
8850
  }
8816
8851
  ],
8817
- onEvent: {
8818
- "fetchInited": {
8819
- "weight": 0,
8820
- "actions": [
8821
- {
8822
- actionType: 'broadcast',
8823
- eventName: "recordLoaded",
8824
- args: {
8825
- eventName: "recordLoaded"
8826
- },
8827
- data: {
8828
- objectName: "${event.data.__objectName}",
8829
- record: "${event.data.__record}"
8830
- },
8831
- expression: "${event.data.__response.error != true}"
8832
- },
8833
- {
8834
- "actionType": "setValue",
8835
- "args": {
8836
- value: {
8837
- "recordLoaded": true,
8838
- }
8839
- },
8840
- expression: "${event.data.__response.error != true}"
8841
- }
8842
- ]
8843
- }
8844
- }
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
+ // }
8845
8880
  };
8846
8881
 
8847
8882
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
8883
+ // console.log('getObjectDetail=====>', amisSchema);
8848
8884
  return amisSchema;
8849
8885
  }
8850
8886
 
@@ -8924,8 +8960,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8924
8960
  /*
8925
8961
  * @Author: baozhoutao@steedos.com
8926
8962
  * @Date: 2022-07-05 15:55:39
8927
- * @LastEditors: liaodaxue
8928
- * @LastEditTime: 2023-11-14 15:55:32
8963
+ * @LastEditors: baozhoutao@steedos.com
8964
+ * @LastEditTime: 2024-01-15 10:34:46
8929
8965
  * @Description:
8930
8966
  */
8931
8967
 
@@ -9305,11 +9341,44 @@ async function getRelatedListSchema(
9305
9341
  };
9306
9342
  }
9307
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
+
9308
9377
  /*
9309
9378
  * @Author: baozhoutao@steedos.com
9310
9379
  * @Date: 2022-07-05 15:55:39
9311
- * @LastEditors: liaodaxue
9312
- * @LastEditTime: 2023-10-20 11:38:25
9380
+ * @LastEditors: baozhoutao@steedos.com
9381
+ * @LastEditTime: 2024-01-15 15:50:40
9313
9382
  * @Description:
9314
9383
  */
9315
9384
 
@@ -9481,7 +9550,7 @@ async function getField(objectName, fieldName) {
9481
9550
  async function getFormSchema(objectName, ctx) {
9482
9551
  const uiSchema = await getUISchema(objectName);
9483
9552
  const amisSchema = await getObjectForm(uiSchema, ctx);
9484
- console.log(`getFormSchema====>`, amisSchema);
9553
+ // console.log(`getFormSchema====>`, amisSchema)
9485
9554
  return {
9486
9555
  uiSchema,
9487
9556
  amisSchema,
@@ -9839,61 +9908,95 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9839
9908
  if(relatedLists.length){
9840
9909
  content.tabs.push(related);
9841
9910
  }
9911
+ content.tabs = _$1.reverse(content.tabs);
9842
9912
  return {
9843
9913
  uiSchema,
9844
9914
  amisSchema: {
9845
- "type": "service",
9915
+ "type": "steedos-record-service",
9846
9916
  "body": [
9847
9917
  {
9848
9918
  "type": "steedos-record-detail-header",
9849
9919
  "label": "标题面板",
9850
9920
  "objectApiName": "${objectName}",
9851
9921
  "recordId": "${recordId}",
9852
- "id": "u:48d2c28eb755"
9922
+ "id": "u:48d2c28eb755",
9923
+ "showButtons": props.showButtons,
9924
+ "showBackButton": props.showBackButton,
9853
9925
  },
9854
9926
  content
9855
9927
  ],
9856
- data: {
9857
- "_master.objectName": "${objectName}",
9858
- "_master.recordId": "${recordId}"
9859
- },
9860
- onEvent: {
9861
- "recordLoaded": {
9862
- "actions": [
9863
- {
9864
- "actionType": "reload",
9865
- "data": {
9866
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9867
- "_master.record": `\${record}`,
9868
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9869
- "_master.objectName": "${objectName}",
9870
- "_master.recordId": "${recordId}"
9871
- }
9872
- }
9873
- ]
9874
- },
9875
- ...props.onEvent
9876
- },
9928
+ "objectApiName": "${objectName}",
9929
+ "recordId": "${recordId}",
9930
+ onEvent: props.onEvent,
9877
9931
  }
9878
9932
  }
9879
9933
  }
9880
9934
 
9881
9935
  async function getRecordServiceSchema(objectName, appId, props = {}) {
9882
9936
  const uiSchema = await getUISchema(objectName);
9937
+ const fields = ___default["default"].values(uiSchema.fields);
9883
9938
  return {
9884
9939
  uiSchema,
9885
9940
  amisSchema: {
9886
9941
  "type": "service",
9887
- "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
+ },
9888
9950
  data: {
9889
9951
  "_master.objectName": "${objectName}",
9890
- "_master.recordId": "${recordId}"
9952
+ "_master.recordId": "${recordId}",
9953
+ ...(props.data || {})
9891
9954
  },
9892
9955
  "style": {
9893
- "padding": "var(--Page-body-padding)",
9956
+ // "padding": "var(--Page-body-padding)",
9894
9957
  ...props.style
9895
9958
  },
9896
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
+ // },
9897
10000
  "recordLoaded": {
9898
10001
  "actions": [
9899
10002
  {
@@ -9914,6 +10017,45 @@ async function getRecordServiceSchema(objectName, appId, props = {}) {
9914
10017
  }
9915
10018
  }
9916
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
+
9917
10059
  // 获取单个相关表
9918
10060
  async function getObjectRelated(
9919
10061
  {appName,
@@ -11061,7 +11203,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
11061
11203
  labelField: referenceTo.labelField.name,
11062
11204
  valueField: referenceTo.valueField.name,
11063
11205
  // disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
11064
- 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)) )`,
11065
11208
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
11066
11209
  source: source,
11067
11210
  size: "lg",
@@ -11305,9 +11448,15 @@ async function lookupToAmis(field, readonly, ctx){
11305
11448
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11306
11449
  if(readonly){
11307
11450
  return {
11308
- type: getAmisStaticFieldType('picker', readonly),
11309
- tpl: getRelatedFieldTpl(field, ctx)
11451
+ type: 'steedos-field',
11452
+ config: field,
11453
+ static: true
11310
11454
  }
11455
+
11456
+ // return {
11457
+ // type: Field.getAmisStaticFieldType('picker', readonly),
11458
+ // tpl: Tpl.getRelatedFieldTpl(field, ctx)
11459
+ // }
11311
11460
  }
11312
11461
  if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
11313
11462
  return {
@@ -12300,11 +12449,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12300
12449
  if(field.subFields){
12301
12450
  convertData = {
12302
12451
  type: 'steedos-input-table',
12303
- showIndex: true,
12304
12452
  editable: !readonly,
12305
12453
  addable: !readonly,
12306
12454
  removable: !readonly,
12307
- draggable: !readonly,
12308
12455
  fields: [],
12309
12456
  amis:{
12310
12457
  columnsTogglable: false
@@ -12762,7 +12909,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12762
12909
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12763
12910
  * @Date: 2023-11-15 09:50:22
12764
12911
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12765
- * @LastEditTime: 2024-01-12 14:51:00
12912
+ * @LastEditTime: 2024-01-15 17:50:02
12766
12913
  */
12767
12914
 
12768
12915
  /**
@@ -12911,8 +13058,15 @@ function getFormPagination(props, mode) {
12911
13058
  let currentIndex = event.data.index;
12912
13059
  // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12913
13060
  let currentFormValues = scope.getComponentById(__formId).getValues();
12914
- if(event.data.parent){
12915
- 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
+ });
12916
13070
  }
12917
13071
  else{
12918
13072
  fieldValue[currentIndex] = currentFormValues;
@@ -13050,9 +13204,14 @@ function getFormPaginationWrapper(props, form, mode) {
13050
13204
  }
13051
13205
  ];
13052
13206
  let onServiceInitedScript = `
13053
- if(event.data.parent){
13207
+ var parent = event.data.parent;
13208
+ var fieldValue = event.data.__tableItems;
13209
+ if(parent){
13054
13210
  // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13055
- 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
+ });
13056
13215
  }
13057
13216
  // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13058
13217
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
@@ -13164,6 +13323,11 @@ async function getForm(props, mode = "edit", formId) {
13164
13323
  var __parentIndex = event.data.__super.__super.__parentIndex;
13165
13324
  if(parent){
13166
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
+ });
13167
13331
  }
13168
13332
  else{
13169
13333
  fieldValue[currentIndex] = currentFormValues;
@@ -13308,9 +13472,13 @@ async function getButtonActions(props, mode) {
13308
13472
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13309
13473
  // 新建一条空白行并保存到子表组件
13310
13474
  var parent = event.data.__super.parent;
13311
- 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
+ });
13312
13479
  if(parent){
13313
13480
  fieldValue[__parentIndex].children.push({});
13481
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13314
13482
  }
13315
13483
  else{
13316
13484
  fieldValue.push({});
@@ -13345,9 +13513,13 @@ async function getButtonActions(props, mode) {
13345
13513
  // 复制当前页数据到新建行并保存到子表组件
13346
13514
  // fieldValue.push(newItem);
13347
13515
  var parent = event.data.__super.parent;
13348
- 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
+ });
13349
13520
  if(parent){
13350
13521
  fieldValue[__parentIndex].children.push(newItem);
13522
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13351
13523
  }
13352
13524
  else{
13353
13525
  fieldValue.push(newItem);
@@ -13363,7 +13535,6 @@ async function getButtonActions(props, mode) {
13363
13535
  let __paginationServiceId = "${formPaginationId}";
13364
13536
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13365
13537
  event.data.index = __paginationData.index;
13366
- // event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13367
13538
  if(parent){
13368
13539
  event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13369
13540
  event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
@@ -13447,13 +13618,15 @@ async function getButtonActions(props, mode) {
13447
13618
  "global": "${global}",
13448
13619
  "uiSchema": "${uiSchema}",
13449
13620
  "index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
13450
- "parent": "${parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13621
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13451
13622
  // "__tableItems": `\${${props.name}}`
13452
13623
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13453
13624
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13454
13625
  // "__tableItems": `\${${props.name}|json|toJson}`
13455
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
13456
- },
13626
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13627
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13628
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13629
+ },
13457
13630
  "actions": dialogButtons,
13458
13631
  "onEvent": {
13459
13632
  "confirm": {
@@ -13542,15 +13715,17 @@ async function getButtonActions(props, mode) {
13542
13715
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13543
13716
  // "__parentForm": "${__super.__super || {}}",
13544
13717
  "__parentForm": parentFormData,
13718
+ "_master": "${_master}",
13545
13719
  "global": "${global}",
13546
13720
  "uiSchema": "${uiSchema}",
13547
13721
  "index": "${index}",
13722
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13548
13723
  // "__tableItems": `\${${props.name}}`
13549
13724
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13550
13725
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13551
13726
  // "__tableItems": `\${${props.name}|json|toJson}`
13552
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
13553
- },
13727
+ "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13728
+ },
13554
13729
  }
13555
13730
  }
13556
13731
  ];
@@ -13568,9 +13743,17 @@ async function getButtonActions(props, mode) {
13568
13743
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13569
13744
  var currentIndex = event.data.index;
13570
13745
  var parent = event.data.__super.parent;
13571
- 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
+ });
13572
13750
  if(parent){
13573
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
+ });
13574
13757
  }
13575
13758
  else{
13576
13759
  lastestFieldValue.splice(currentIndex, 1);
@@ -13660,6 +13843,9 @@ const getAmisInputTableSchema = async (props) => {
13660
13843
  if (!props.id) {
13661
13844
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13662
13845
  }
13846
+ if (!props.primaryKey) {
13847
+ props.primaryKey = "_id";
13848
+ }
13663
13849
  let serviceId = getComponentId("table_service", props.id);
13664
13850
  let buttonsForColumnOperations = [];
13665
13851
  let inlineEditMode = props.inlineEditMode;
@@ -13710,7 +13896,13 @@ const getAmisInputTableSchema = async (props) => {
13710
13896
  "strictMode": props.strictMode,
13711
13897
  "showTableAddBtn": false,
13712
13898
  "showFooterAddBtn": false,
13713
- "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
+ }
13714
13906
  };
13715
13907
  if (buttonsForColumnOperations.length) {
13716
13908
  inputTableSchema.columns.push({
@@ -16502,9 +16694,11 @@ exports.getObjectRelated = getObjectRelated;
16502
16694
  exports.getObjectRelatedList = getObjectRelatedList;
16503
16695
  exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
16504
16696
  exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
16697
+ exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
16505
16698
  exports.getPage = getPage;
16506
16699
  exports.getRecord = getRecord;
16507
16700
  exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
16701
+ exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
16508
16702
  exports.getRecordDetailRelatedListSchema = getRecordDetailRelatedListSchema;
16509
16703
  exports.getRecordDetailSchema = getRecordDetailSchema;
16510
16704
  exports.getRecordPageInitSchema = getRecordPageInitSchema;