@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.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`,
@@ -8107,7 +8162,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8107
8162
  // ]
8108
8163
  if(options.displayAs === 'split'){
8109
8164
  return [
8110
- "switch-per-page",
8165
+ {
8166
+ "type": "switch-per-page",
8167
+ "visibleOn": "${count >= 20}"
8168
+ },
8111
8169
  {
8112
8170
  "type": "pagination",
8113
8171
  "maxButtons": 5,
@@ -8151,7 +8209,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8151
8209
  if (no_pagination && is_lookup) {
8152
8210
  return commonConfig;
8153
8211
  } else {
8154
- return ["switch-per-page", ...commonConfig];
8212
+ return [{
8213
+ "type": "switch-per-page",
8214
+ "visibleOn": "${count >= 20}"
8215
+ }, ...commonConfig];
8155
8216
  }
8156
8217
  }
8157
8218
  }
@@ -8513,7 +8574,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8513
8574
 
8514
8575
  if(body.columns && options.formFactor != 'SMALL'){
8515
8576
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8516
- 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: "${}"});
8517
8578
  }
8518
8579
 
8519
8580
  if (defaults) {
@@ -8571,11 +8632,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8571
8632
  }
8572
8633
  }
8573
8634
 
8574
- const getGlobalData = (mode)=>{
8575
- const user = getSteedosAuth();
8576
- return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
8577
- };
8578
-
8579
8635
  const getFormFields$1 = (objectSchema, formProps)=>{
8580
8636
  /**
8581
8637
  * fieldsExtend: 重写字段定义
@@ -8737,8 +8793,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8737
8793
  type: 'service',
8738
8794
  name: `page_readonly_${recordId}`,
8739
8795
  id: serviceId,
8740
- data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
8741
- api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8796
+ // api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
8742
8797
  body: [
8743
8798
  {
8744
8799
  "type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
@@ -8764,60 +8819,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
8764
8819
  ),
8765
8820
  className: 'steedos-amis-form bg-white',
8766
8821
  actions: [], // 不显示表单默认的提交按钮
8767
- onEvent: {
8768
- [`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
8769
- "actions": [
8770
- {
8771
- "actionType": "reload",
8772
- "componentId": serviceId,
8773
- "expression": "this.__deletedRecord != true"
8774
- },
8775
- {
8776
- // "args": {
8777
- // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
8778
- // "blank": false
8779
- // },
8780
- "actionType": "custom",
8781
- "script": "window.goBack()",
8782
- "expression": "this.__deletedRecord === true"
8783
- }
8784
- ]
8785
- }
8786
- }
8787
8822
  },
8788
8823
  }
8789
8824
  ],
8790
- onEvent: {
8791
- "fetchInited": {
8792
- "weight": 0,
8793
- "actions": [
8794
- {
8795
- actionType: 'broadcast',
8796
- eventName: "recordLoaded",
8797
- args: {
8798
- eventName: "recordLoaded"
8799
- },
8800
- data: {
8801
- objectName: "${event.data.__objectName}",
8802
- record: "${event.data.__record}"
8803
- },
8804
- expression: "${event.data.__response.error != true}"
8805
- },
8806
- {
8807
- "actionType": "setValue",
8808
- "args": {
8809
- value: {
8810
- "recordLoaded": true,
8811
- }
8812
- },
8813
- expression: "${event.data.__response.error != true}"
8814
- }
8815
- ]
8816
- }
8817
- }
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
+ // }
8818
8853
  };
8819
8854
 
8820
8855
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
8856
+ // console.log('getObjectDetail=====>', amisSchema);
8821
8857
  return amisSchema;
8822
8858
  }
8823
8859
 
@@ -8897,8 +8933,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
8897
8933
  /*
8898
8934
  * @Author: baozhoutao@steedos.com
8899
8935
  * @Date: 2022-07-05 15:55:39
8900
- * @LastEditors: liaodaxue
8901
- * @LastEditTime: 2023-11-14 15:55:32
8936
+ * @LastEditors: baozhoutao@steedos.com
8937
+ * @LastEditTime: 2024-01-15 10:34:46
8902
8938
  * @Description:
8903
8939
  */
8904
8940
 
@@ -9278,11 +9314,44 @@ async function getRelatedListSchema(
9278
9314
  };
9279
9315
  }
9280
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
+
9281
9350
  /*
9282
9351
  * @Author: baozhoutao@steedos.com
9283
9352
  * @Date: 2022-07-05 15:55:39
9284
- * @LastEditors: liaodaxue
9285
- * @LastEditTime: 2023-10-20 11:38:25
9353
+ * @LastEditors: baozhoutao@steedos.com
9354
+ * @LastEditTime: 2024-01-15 15:50:40
9286
9355
  * @Description:
9287
9356
  */
9288
9357
 
@@ -9454,7 +9523,7 @@ async function getField(objectName, fieldName) {
9454
9523
  async function getFormSchema(objectName, ctx) {
9455
9524
  const uiSchema = await getUISchema(objectName);
9456
9525
  const amisSchema = await getObjectForm(uiSchema, ctx);
9457
- console.log(`getFormSchema====>`, amisSchema);
9526
+ // console.log(`getFormSchema====>`, amisSchema)
9458
9527
  return {
9459
9528
  uiSchema,
9460
9529
  amisSchema,
@@ -9812,61 +9881,95 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
9812
9881
  if(relatedLists.length){
9813
9882
  content.tabs.push(related);
9814
9883
  }
9884
+ content.tabs = reverse(content.tabs);
9815
9885
  return {
9816
9886
  uiSchema,
9817
9887
  amisSchema: {
9818
- "type": "service",
9888
+ "type": "steedos-record-service",
9819
9889
  "body": [
9820
9890
  {
9821
9891
  "type": "steedos-record-detail-header",
9822
9892
  "label": "标题面板",
9823
9893
  "objectApiName": "${objectName}",
9824
9894
  "recordId": "${recordId}",
9825
- "id": "u:48d2c28eb755"
9895
+ "id": "u:48d2c28eb755",
9896
+ "showButtons": props.showButtons,
9897
+ "showBackButton": props.showBackButton,
9826
9898
  },
9827
9899
  content
9828
9900
  ],
9829
- data: {
9830
- "_master.objectName": "${objectName}",
9831
- "_master.recordId": "${recordId}"
9832
- },
9833
- onEvent: {
9834
- "recordLoaded": {
9835
- "actions": [
9836
- {
9837
- "actionType": "reload",
9838
- "data": {
9839
- "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
9840
- "_master.record": `\${record}`,
9841
- // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
9842
- "_master.objectName": "${objectName}",
9843
- "_master.recordId": "${recordId}"
9844
- }
9845
- }
9846
- ]
9847
- },
9848
- ...props.onEvent
9849
- },
9901
+ "objectApiName": "${objectName}",
9902
+ "recordId": "${recordId}",
9903
+ onEvent: props.onEvent,
9850
9904
  }
9851
9905
  }
9852
9906
  }
9853
9907
 
9854
9908
  async function getRecordServiceSchema(objectName, appId, props = {}) {
9855
9909
  const uiSchema = await getUISchema(objectName);
9910
+ const fields = ___default.values(uiSchema.fields);
9856
9911
  return {
9857
9912
  uiSchema,
9858
9913
  amisSchema: {
9859
9914
  "type": "service",
9860
- "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
+ },
9861
9923
  data: {
9862
9924
  "_master.objectName": "${objectName}",
9863
- "_master.recordId": "${recordId}"
9925
+ "_master.recordId": "${recordId}",
9926
+ ...(props.data || {})
9864
9927
  },
9865
9928
  "style": {
9866
- "padding": "var(--Page-body-padding)",
9929
+ // "padding": "var(--Page-body-padding)",
9867
9930
  ...props.style
9868
9931
  },
9869
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
+ // },
9870
9973
  "recordLoaded": {
9871
9974
  "actions": [
9872
9975
  {
@@ -9887,6 +9990,45 @@ async function getRecordServiceSchema(objectName, appId, props = {}) {
9887
9990
  }
9888
9991
  }
9889
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
+
9890
10032
  // 获取单个相关表
9891
10033
  async function getObjectRelated(
9892
10034
  {appName,
@@ -11034,7 +11176,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
11034
11176
  labelField: referenceTo.labelField.name,
11035
11177
  valueField: referenceTo.valueField.name,
11036
11178
  // disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
11037
- 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)) )`,
11038
11181
  modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
11039
11182
  source: source,
11040
11183
  size: "lg",
@@ -11278,9 +11421,15 @@ async function lookupToAmis(field, readonly, ctx){
11278
11421
  // console.log(`lookupToAmis====`, field, readonly, ctx)
11279
11422
  if(readonly){
11280
11423
  return {
11281
- type: getAmisStaticFieldType('picker', readonly),
11282
- tpl: getRelatedFieldTpl(field, ctx)
11424
+ type: 'steedos-field',
11425
+ config: field,
11426
+ static: true
11283
11427
  }
11428
+
11429
+ // return {
11430
+ // type: Field.getAmisStaticFieldType('picker', readonly),
11431
+ // tpl: Tpl.getRelatedFieldTpl(field, ctx)
11432
+ // }
11284
11433
  }
11285
11434
  if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
11286
11435
  return {
@@ -12273,11 +12422,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12273
12422
  if(field.subFields){
12274
12423
  convertData = {
12275
12424
  type: 'steedos-input-table',
12276
- showIndex: true,
12277
12425
  editable: !readonly,
12278
12426
  addable: !readonly,
12279
12427
  removable: !readonly,
12280
- draggable: !readonly,
12281
12428
  fields: [],
12282
12429
  amis:{
12283
12430
  columnsTogglable: false
@@ -12735,7 +12882,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12735
12882
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12736
12883
  * @Date: 2023-11-15 09:50:22
12737
12884
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12738
- * @LastEditTime: 2024-01-12 14:51:00
12885
+ * @LastEditTime: 2024-01-15 17:50:02
12739
12886
  */
12740
12887
 
12741
12888
  /**
@@ -12884,8 +13031,15 @@ function getFormPagination(props, mode) {
12884
13031
  let currentIndex = event.data.index;
12885
13032
  // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12886
13033
  let currentFormValues = scope.getComponentById(__formId).getValues();
12887
- if(event.data.parent){
12888
- 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
+ });
12889
13043
  }
12890
13044
  else{
12891
13045
  fieldValue[currentIndex] = currentFormValues;
@@ -13023,9 +13177,14 @@ function getFormPaginationWrapper(props, form, mode) {
13023
13177
  }
13024
13178
  ];
13025
13179
  let onServiceInitedScript = `
13026
- if(event.data.parent){
13180
+ var parent = event.data.parent;
13181
+ var fieldValue = event.data.__tableItems;
13182
+ if(parent){
13027
13183
  // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13028
- 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
+ });
13029
13188
  }
13030
13189
  // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
13031
13190
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
@@ -13137,6 +13296,11 @@ async function getForm(props, mode = "edit", formId) {
13137
13296
  var __parentIndex = event.data.__super.__super.__parentIndex;
13138
13297
  if(parent){
13139
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
+ });
13140
13304
  }
13141
13305
  else{
13142
13306
  fieldValue[currentIndex] = currentFormValues;
@@ -13281,9 +13445,13 @@ async function getButtonActions(props, mode) {
13281
13445
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13282
13446
  // 新建一条空白行并保存到子表组件
13283
13447
  var parent = event.data.__super.parent;
13284
- 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
+ });
13285
13452
  if(parent){
13286
13453
  fieldValue[__parentIndex].children.push({});
13454
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13287
13455
  }
13288
13456
  else{
13289
13457
  fieldValue.push({});
@@ -13318,9 +13486,13 @@ async function getButtonActions(props, mode) {
13318
13486
  // 复制当前页数据到新建行并保存到子表组件
13319
13487
  // fieldValue.push(newItem);
13320
13488
  var parent = event.data.__super.parent;
13321
- 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
+ });
13322
13493
  if(parent){
13323
13494
  fieldValue[__parentIndex].children.push(newItem);
13495
+ // 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
13324
13496
  }
13325
13497
  else{
13326
13498
  fieldValue.push(newItem);
@@ -13336,7 +13508,6 @@ async function getButtonActions(props, mode) {
13336
13508
  let __paginationServiceId = "${formPaginationId}";
13337
13509
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13338
13510
  event.data.index = __paginationData.index;
13339
- // event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13340
13511
  if(parent){
13341
13512
  event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13342
13513
  event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
@@ -13420,13 +13591,15 @@ async function getButtonActions(props, mode) {
13420
13591
  "global": "${global}",
13421
13592
  "uiSchema": "${uiSchema}",
13422
13593
  "index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
13423
- "parent": "${parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13594
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13424
13595
  // "__tableItems": `\${${props.name}}`
13425
13596
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13426
13597
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13427
13598
  // "__tableItems": `\${${props.name}|json|toJson}`
13428
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
13429
- },
13599
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13600
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13601
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13602
+ },
13430
13603
  "actions": dialogButtons,
13431
13604
  "onEvent": {
13432
13605
  "confirm": {
@@ -13515,15 +13688,17 @@ async function getButtonActions(props, mode) {
13515
13688
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13516
13689
  // "__parentForm": "${__super.__super || {}}",
13517
13690
  "__parentForm": parentFormData,
13691
+ "_master": "${_master}",
13518
13692
  "global": "${global}",
13519
13693
  "uiSchema": "${uiSchema}",
13520
13694
  "index": "${index}",
13695
+ "parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13521
13696
  // "__tableItems": `\${${props.name}}`
13522
13697
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13523
13698
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13524
13699
  // "__tableItems": `\${${props.name}|json|toJson}`
13525
- "__tableItems": `\${(${props.name} || [])|json|toJson}`
13526
- },
13700
+ "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13701
+ },
13527
13702
  }
13528
13703
  }
13529
13704
  ];
@@ -13541,9 +13716,17 @@ async function getButtonActions(props, mode) {
13541
13716
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13542
13717
  var currentIndex = event.data.index;
13543
13718
  var parent = event.data.__super.parent;
13544
- 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
+ });
13545
13723
  if(parent){
13546
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
+ });
13547
13730
  }
13548
13731
  else{
13549
13732
  lastestFieldValue.splice(currentIndex, 1);
@@ -13633,6 +13816,9 @@ const getAmisInputTableSchema = async (props) => {
13633
13816
  if (!props.id) {
13634
13817
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
13635
13818
  }
13819
+ if (!props.primaryKey) {
13820
+ props.primaryKey = "_id";
13821
+ }
13636
13822
  let serviceId = getComponentId("table_service", props.id);
13637
13823
  let buttonsForColumnOperations = [];
13638
13824
  let inlineEditMode = props.inlineEditMode;
@@ -13683,7 +13869,13 @@ const getAmisInputTableSchema = async (props) => {
13683
13869
  "strictMode": props.strictMode,
13684
13870
  "showTableAddBtn": false,
13685
13871
  "showFooterAddBtn": false,
13686
- "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
+ }
13687
13879
  };
13688
13880
  if (buttonsForColumnOperations.length) {
13689
13881
  inputTableSchema.columns.push({
@@ -16405,5 +16597,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
16405
16597
  };
16406
16598
  };
16407
16599
 
16408
- 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 };
16409
16601
  //# sourceMappingURL=index.esm.js.map