@steedos-widgets/amis-lib 1.3.14 → 1.3.16

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
@@ -3108,6 +3108,17 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3108
3108
  crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
3109
3109
  `;
3110
3110
  const onCancelScript = `
3111
+ doAction(
3112
+ {
3113
+ "componentId": 'service_${ctx.crudId}',
3114
+ "actionType": "setValue",
3115
+ "args": {
3116
+ "value": {
3117
+ "__filterFormValues": null
3118
+ }
3119
+ }
3120
+ }
3121
+ )
3111
3122
  const scope = event.context.scoped;
3112
3123
  var filterForm = scope.parent.parent.getComponents().find(function(n){
3113
3124
  return n.props.type === "form";
@@ -3142,7 +3153,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3142
3153
  removedValues[keywordsSearchBoxName] = filterFormValues[keywordsSearchBoxName];
3143
3154
  }
3144
3155
  filterForm.reset();
3145
- listView.handleFilterSubmit(removedValues);
3156
+ setTimeout(()=>{
3157
+ listView.handleFilterSubmit(removedValues);
3158
+ }, 100);
3146
3159
  const filterService = filterForm.context.getComponents().find(function(n){
3147
3160
  return n.props.type === "service";
3148
3161
  });
@@ -5018,7 +5031,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5018
5031
  // }
5019
5032
  `;
5020
5033
 
5021
- function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords" } = {}){
5034
+ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords", crudId } = {}){
5022
5035
  const searchableFieldsLabel = [];
5023
5036
  _.each(mainObject.fields, function (field) {
5024
5037
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
@@ -5055,23 +5068,22 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
5055
5068
  "clearAndSubmit": true,
5056
5069
  "searchImediately": false,
5057
5070
  "onEvent": {
5058
- "blur": {
5071
+ "change": {
5059
5072
  "actions": [
5060
5073
  {
5061
5074
  "actionType": "custom",
5062
5075
  "script": `
5063
- try {
5064
- const scope = event.context.scoped;
5065
- const filterCrud = scope.parent.getComponents().find(function(n) {
5066
- return n.props.type === "crud";
5067
- });
5068
- if (filterCrud && typeof filterCrud.reload === 'function') {
5069
- const keyWords = { '${keywordsSearchBoxName}': event.data.value };
5070
- filterCrud.reload(null, keyWords);
5076
+ doAction(
5077
+ {
5078
+ "componentId": 'service_${crudId}',
5079
+ "actionType": "setValue",
5080
+ "args": {
5081
+ "value": {
5082
+ "__serachBoxValues": event.data
5083
+ }
5071
5084
  }
5072
- } catch (error) {
5073
- console.error('An error occurred:', error);
5074
- }
5085
+ }
5086
+ )
5075
5087
  `
5076
5088
  }
5077
5089
  ]
@@ -5083,7 +5095,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
5083
5095
  }
5084
5096
 
5085
5097
  function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5086
- showDisplayAs = false, hiddenCount = false, headerToolbarItems,
5098
+ showDisplayAs = false, hiddenCount = false, headerToolbarItems, crudId,
5087
5099
  filterVisible = true, isLookup = false, keywordsSearchBoxName } = {}){
5088
5100
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5089
5101
  // console.log(`getObjectHeaderToolbar`, mainObject)
@@ -5187,7 +5199,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5187
5199
  };
5188
5200
  }
5189
5201
  let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name);
5190
- let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName });
5202
+ let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName, crudId });
5191
5203
 
5192
5204
  // toolbars返回的数组元素不可以是空对象{},比如hiddenCount ? {} : {"type": "tpl",...},因为空对象最终还是会生成一个空的.antd-Crud-toolbar-item dom
5193
5205
  // 当出现空的.antd-Crud-toolbar-item dom时会影响toolbar元素的maring-right css样式计算,如果有动态需要应该加到动态数组变量toolbars中
@@ -5353,6 +5365,26 @@ async function getObjectFilter(objectSchema, fields, options) {
5353
5365
  "script": onSubmitSuccScript
5354
5366
  }
5355
5367
  ]
5368
+ },
5369
+ "change": {
5370
+ "actions": [
5371
+ {
5372
+ "actionType": "custom",
5373
+ "script": `
5374
+ doAction(
5375
+ {
5376
+ "componentId": 'service_${options.crudId}',
5377
+ "actionType": "setValue",
5378
+ "args": {
5379
+ "value": {
5380
+ "__filterFormValues": event.data
5381
+ }
5382
+ }
5383
+ }
5384
+ )
5385
+ `
5386
+ }
5387
+ ]
5356
5388
  }
5357
5389
  }
5358
5390
  }
@@ -5556,19 +5588,12 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
5556
5588
 
5557
5589
  const keywordsSearchBoxName = `__keywords_lookup`;
5558
5590
 
5559
- const getReferenceTo = async (field)=>{
5591
+ const getReferenceToFieldSchema = (field, refObjectConfig)=>{
5560
5592
  let referenceTo = field.reference_to;
5561
5593
  if(!referenceTo){
5562
- return ;
5563
- }
5564
-
5565
- if(referenceTo === 'users'){
5566
- referenceTo = 'space_users';
5567
- field.reference_to_field = 'user';
5594
+ return;
5568
5595
  }
5569
5596
 
5570
- const refObjectConfig = await getUISchema(referenceTo);
5571
-
5572
5597
  // 如果lookup 引用的对象未定义
5573
5598
  if (!refObjectConfig)
5574
5599
  return null;
@@ -5591,6 +5616,28 @@ const getReferenceTo = async (field)=>{
5591
5616
  }
5592
5617
  };
5593
5618
 
5619
+ const getReferenceTo = async (field)=>{
5620
+ let referenceTo = field.reference_to;
5621
+ if(referenceTo === 'users'){
5622
+ field.reference_to = 'space_users';
5623
+ field.reference_to_field = 'user';
5624
+ }
5625
+
5626
+ const refObjectConfig = await getUISchema(field.reference_to);
5627
+ return getReferenceToFieldSchema(field, refObjectConfig);
5628
+ };
5629
+
5630
+ function getReferenceToSync(field) {
5631
+ let referenceTo = field.reference_to;
5632
+ if(referenceTo === 'users'){
5633
+ field.reference_to = 'space_users';
5634
+ field.reference_to_field = 'user';
5635
+ }
5636
+
5637
+ const refObjectConfig = getUISchemaSync(field.reference_to);
5638
+ return getReferenceToFieldSchema(field, refObjectConfig);
5639
+ }
5640
+
5594
5641
  function getLookupSapceUserTreeSchema(isMobile){
5595
5642
  const treeSchema = {
5596
5643
  "type": "input-tree",
@@ -6184,7 +6231,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
6184
6231
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
6185
6232
  apiInfo.requestAdaptor = `
6186
6233
  var filters = [];
6187
- var top = 10;
6234
+ var top = 200;
6188
6235
  if(api.data.$term){
6189
6236
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
6190
6237
  }
@@ -6494,6 +6541,12 @@ async function getIdsPickerSchema(field, readonly, ctx){
6494
6541
  return data;
6495
6542
  }
6496
6543
 
6544
+
6545
+ if(typeof window != 'undefined'){
6546
+ window.getReferenceTo = getReferenceTo;
6547
+ window.getReferenceToSync = getReferenceToSync;
6548
+ }
6549
+
6497
6550
  /*
6498
6551
  * @Author: baozhoutao@steedos.com
6499
6552
  * @Date: 2023-01-13 17:27:54
@@ -6671,8 +6724,8 @@ function getAmisStaticFieldType(type, readonly, options){
6671
6724
  /*
6672
6725
  * @Author: baozhoutao@steedos.com
6673
6726
  * @Date: 2022-10-28 14:15:09
6674
- * @LastEditors: 孙浩林 sunhaolin@steedos.com
6675
- * @LastEditTime: 2023-11-24 13:45:24
6727
+ * @LastEditors: liaodaxue
6728
+ * @LastEditTime: 2023-10-30 17:51:54
6676
6729
  * @Description:
6677
6730
  */
6678
6731
 
@@ -6709,7 +6762,7 @@ const getAmisFileReadonlySchema = (steedosField)=>{
6709
6762
  <% let fileData = data._display.${steedosField.name}; if (fileData) { %>
6710
6763
  <% if(!Array.isArray(fileData)){ fileData = [fileData]} %>
6711
6764
  <% fileData.forEach(function(item) { %>
6712
- <a href='<%= item.url+"?download=1" %>' target='_self' class='block'><%= item.name %></a>
6765
+ <a href='<%= item.url %>' target='_self' class='block'><%= item.name %></a>
6713
6766
  <% });} %>`
6714
6767
  }
6715
6768
  }
@@ -6852,6 +6905,8 @@ function getAmisFieldType(sField){
6852
6905
  break;
6853
6906
  case 'grid':
6854
6907
  return 'table';
6908
+ case 'table':
6909
+ return 'steedos-input-table';
6855
6910
  default:
6856
6911
  console.log('convertData default', sField.type);
6857
6912
  // convertData.type = field.type
@@ -6885,6 +6940,19 @@ function getGridFieldSubFields(mainField, fields){
6885
6940
  return newMainField;
6886
6941
  }
6887
6942
 
6943
+ function getTabledFieldSubFields(mainField, fields){
6944
+ const newMainField = Object.assign({subFields: []}, mainField);
6945
+ const subFields = ___namespace.filter(fields, function(field){
6946
+ let result = field.name.startsWith(`${mainField.name}.`);
6947
+ if(result){
6948
+ field._prefix = `${mainField.name}.`;
6949
+ }
6950
+ return result;
6951
+ });
6952
+ newMainField.subFields = subFields;
6953
+ return newMainField;
6954
+ }
6955
+
6888
6956
  /**
6889
6957
  * TODO 处理权限
6890
6958
  * @param {*} object steedos object
@@ -7388,6 +7456,29 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7388
7456
  }
7389
7457
  }
7390
7458
  break;
7459
+ case 'table':
7460
+ if(field.subFields){
7461
+ convertData = {
7462
+ type: 'steedos-input-table',
7463
+ showIndex: true,
7464
+ editable: !readonly,
7465
+ addable: !readonly,
7466
+ removable: !readonly,
7467
+ draggable: !readonly,
7468
+ fields: [],
7469
+ amis:{
7470
+ columnsTogglable: false
7471
+ }
7472
+ };
7473
+ for (const subField of field.subFields) {
7474
+ const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
7475
+ const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
7476
+ if(gridSub){
7477
+ convertData.fields.push(Object.assign({}, subField, {name: subFieldName}));
7478
+ }
7479
+ }
7480
+ }
7481
+ break;
7391
7482
  case 'object':
7392
7483
  if(field.subFields){
7393
7484
  convertData = {
@@ -7459,7 +7550,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7459
7550
  return convertData
7460
7551
  }
7461
7552
  // if(ctx.mode === 'edit'){
7462
- return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
7553
+ let convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
7554
+ // console.log("convertDataResult:", convertDataResult);
7555
+ return convertDataResult;
7463
7556
  // }else{
7464
7557
  // return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
7465
7558
  // }
@@ -7551,38 +7644,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
7551
7644
 
7552
7645
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
7553
7646
  if(amisField){
7554
- const changeActionsFields = ['select', 'boolean', 'toggle', 'date', 'datetime', 'time', 'number', 'currency', 'lookup', 'master_detail'];
7555
- const isChangeActions = changeActionsFields.indexOf(field.type) > -1;
7556
- let additionalProps = {
7647
+ return Object.assign({}, amisField,{
7557
7648
  submitOnChange: false
7558
- };
7559
- if (isChangeActions) {
7560
- additionalProps.submitOnChange = true;
7561
- } else {
7562
- additionalProps.onEvent = {
7563
- blur: {
7564
- actions: [
7565
- {
7566
- actionType: "custom",
7567
- script: `
7568
- try {
7569
- const scope = event.context.scoped;
7570
- const filterForm = scope.parent.parent.parent.getComponents().find(function(n) {
7571
- return n.props.type === "form";
7572
- });
7573
- if (filterForm && typeof filterForm.handleFormSubmit === 'function') {
7574
- filterForm.handleFormSubmit(event);
7575
- }
7576
- } catch (error) {
7577
- console.error('An error occurred:', error);
7578
- }
7579
- `
7580
- }
7581
- ]
7582
- }
7583
- };
7584
- }
7585
- return Object.assign({}, amisField, additionalProps);
7649
+ });
7586
7650
  }
7587
7651
  }
7588
7652
  }
@@ -7635,6 +7699,7 @@ var index = /*#__PURE__*/Object.freeze({
7635
7699
  getAmisFieldType: getAmisFieldType,
7636
7700
  getObjectFieldSubFields: getObjectFieldSubFields,
7637
7701
  getGridFieldSubFields: getGridFieldSubFields,
7702
+ getTabledFieldSubFields: getTabledFieldSubFields,
7638
7703
  getPermissionFields: getPermissionFields,
7639
7704
  getSelectFieldOptions: getSelectFieldOptions,
7640
7705
  convertSFieldToAmisField: convertSFieldToAmisField,
@@ -8750,7 +8815,7 @@ function deleteVariable(data, key) {
8750
8815
  * @Author: baozhoutao@steedos.com
8751
8816
  * @Date: 2022-05-26 16:02:08
8752
8817
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
8753
- * @LastEditTime: 2023-10-12 18:25:05
8818
+ * @LastEditTime: 2023-11-28 17:00:28
8754
8819
  * @Description:
8755
8820
  */
8756
8821
 
@@ -8801,6 +8866,8 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
8801
8866
  if (perField.type === 'grid') {
8802
8867
  field = await getGridFieldSubFields(perField, formFields);
8803
8868
  // console.log(`perField.type grid ===> field`, field)
8869
+ } else if (perField.type === 'table') {
8870
+ field = await getTabledFieldSubFields(perField, formFields);
8804
8871
  } else if (perField.type === 'object') {
8805
8872
  field = await getObjectFieldSubFields(perField, formFields);
8806
8873
  // console.log(`perField.type object ===> field`, field)
@@ -8808,6 +8875,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
8808
8875
  if (field.name.indexOf(".") < 0) {
8809
8876
  ctx.__formFields = formFields;
8810
8877
  const amisField = await convertSFieldToAmisField(field, field.readonly, ctx);
8878
+ // 如果steedos-field稳定了,可以放开下面的代码直接用组件统一渲染字段
8879
+ // const amisField = {
8880
+ // "type": "steedos-field",
8881
+ // "config": field,
8882
+ // "readonly": field.readonly,
8883
+ // "ctx": ctx
8884
+ // };
8811
8885
  // console.log(`${field.name} amisField`, field, amisField)
8812
8886
  if (amisField) {
8813
8887
  fieldSetBody.push(amisField);
@@ -9016,6 +9090,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9016
9090
  const bulkActions = getBulkActions(objectSchema);
9017
9091
  const defaults = options.defaults;
9018
9092
  const listSchema = (defaults && defaults.listSchema) || {};
9093
+ const id = `listview_${objectSchema.name}`;
9019
9094
 
9020
9095
  const bodyProps = {
9021
9096
  // toolbar: getToolbar(),
@@ -9025,7 +9100,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9025
9100
  ...options,
9026
9101
  disableStatistics: options.queryCount === false
9027
9102
  }),
9028
- filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
9103
+ filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, Object.assign({}, options, {crudId: id})),
9029
9104
  };
9030
9105
  if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
9031
9106
  if(listSchema.mode !== "cards"){
@@ -9054,7 +9129,8 @@ async function getObjectCRUD(objectSchema, fields, options){
9054
9129
  showDisplayAs,
9055
9130
  hiddenCount: options.queryCount === false,
9056
9131
  headerToolbarItems: options.headerToolbarItems,
9057
- filterVisible: options.filterVisible
9132
+ filterVisible: options.filterVisible,
9133
+ crudId: id
9058
9134
  });
9059
9135
 
9060
9136
  options.amisData = createObject(options.amisData, {
@@ -9067,7 +9143,6 @@ async function getObjectCRUD(objectSchema, fields, options){
9067
9143
 
9068
9144
 
9069
9145
  let body = null;
9070
- const id = `listview_${objectSchema.name}`;
9071
9146
  if(options.formFactor === 'SMALL' && false){
9072
9147
  delete bodyProps.bulkActions;
9073
9148
  delete bodyProps.headerToolbar;
@@ -10061,7 +10136,7 @@ async function getUISchema(objectName, force) {
10061
10136
  return getUISchemaCache(objectName);
10062
10137
  }
10063
10138
 
10064
- function getUISchemaSync(objectName, force) {
10139
+ function getUISchemaSync$1(objectName, force) {
10065
10140
  if (!objectName) {
10066
10141
  return;
10067
10142
  }
@@ -10571,7 +10646,7 @@ async function getObjectRelated(
10571
10646
 
10572
10647
  if(typeof window != 'undefined'){
10573
10648
  window.getUISchema = getUISchema;
10574
- window.getUISchemaSync = getUISchemaSync;
10649
+ window.getUISchemaSync = getUISchemaSync$1;
10575
10650
  window.getListSchema = getListSchema;
10576
10651
  }
10577
10652
 
@@ -11890,6 +11965,8 @@ async function getTableApi(mainObject, fields, options){
11890
11965
  api.data.$self = "$$";
11891
11966
  api.data.self = "$$";
11892
11967
  api.data.filter = "$filter";
11968
+ api.data.__filterFormValues = "${__filterFormValues}";
11969
+ api.data.__serachBoxValues = "${__serachBoxValues}";
11893
11970
  api.data.loaded = "${loaded}";
11894
11971
  api.data.listViewId = "${listViewId}";
11895
11972
  api.data.listName = "${listName}";
@@ -11962,9 +12039,12 @@ async function getTableApi(mainObject, fields, options){
11962
12039
  }else if(selfData.op === 'loadOptions' && selfData.value){
11963
12040
  userFilters = [["${valueField.name}", "=", selfData.value]];
11964
12041
  }
11965
-
11966
- var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
11967
12042
 
12043
+ const __filterFormValues = api.data.__filterFormValues;
12044
+ const __serachBoxValues = api.data.__serachBoxValues;
12045
+ // 筛选按钮
12046
+ const filterSelfData = __filterFormValues ? __filterFormValues : selfData;
12047
+ var searchableFilter = SteedosUI.getSearchFilter(filterSelfData) || [];
11968
12048
  if(searchableFilter.length > 0){
11969
12049
  if(userFilters.length > 0 ){
11970
12050
  userFilters = [userFilters, 'and', searchableFilter];
@@ -11973,6 +12053,7 @@ async function getTableApi(mainObject, fields, options){
11973
12053
  }
11974
12054
  }
11975
12055
 
12056
+ // "搜索此列表"搜索框
11976
12057
  if(allowSearchFields){
11977
12058
  allowSearchFields.forEach(function(key){
11978
12059
  const keyValue = selfData[key];
@@ -11984,7 +12065,8 @@ async function getTableApi(mainObject, fields, options){
11984
12065
  })
11985
12066
  }
11986
12067
 
11987
- var keywordsFilters = SteedosUI.getKeywordsSearchFilter(selfData.__keywords, allowSearchFields);
12068
+ const keyWords = __serachBoxValues ? __serachBoxValues.__keywords : selfData.__keywords;
12069
+ var keywordsFilters = SteedosUI.getKeywordsSearchFilter(keyWords, allowSearchFields);
11988
12070
  if(keywordsFilters && keywordsFilters.length > 0){
11989
12071
  userFilters.push(keywordsFilters);
11990
12072
  }
@@ -12194,7 +12276,7 @@ function getRecordPermissionsApi(object, recordId, options){
12194
12276
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12195
12277
  * @Date: 2023-11-15 09:50:22
12196
12278
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12197
- * @LastEditTime: 2023-11-17 20:17:56
12279
+ * @LastEditTime: 2023-11-28 11:34:24
12198
12280
  */
12199
12281
 
12200
12282
  /**
@@ -12203,10 +12285,14 @@ function getRecordPermissionsApi(object, recordId, options){
12203
12285
  */
12204
12286
  function getFormFields(props, mode = "edit") {
12205
12287
  return (props.fields || []).map(function (item) {
12206
- return {
12288
+ let formItem = {
12207
12289
  "type": "steedos-field",
12208
12290
  "config": item
12291
+ };
12292
+ if(mode === "readonly"){
12293
+ formItem.static = true;
12209
12294
  }
12295
+ return formItem;
12210
12296
  }) || [];
12211
12297
  }
12212
12298
 
@@ -12215,32 +12301,59 @@ function getFormFields(props, mode = "edit") {
12215
12301
  * @param {*} mode edit/new/readonly
12216
12302
  */
12217
12303
  async function getInputTableColumns(props) {
12218
- // return props.fields.map(function(item){
12219
- // return {
12220
- // "type": "steedos-field",
12221
- // "config": item,
12222
- // "static": true,
12223
- // "readonly": true
12224
- // }
12225
- // }) || [];
12226
-
12227
- let columns = await getTableColumns(props.fields || [], {
12228
- isInputTable: true,
12229
- permissions: {
12230
- allowEdit: false //快速编辑开关与权限有关
12231
- }
12232
- });
12233
- // columns = columns.map(function(item){
12234
- // if(["text"].indexOf(item.type) > -1){
12235
- // return Object.assign({}, item, {
12236
- // "type": "static"
12237
- // });
12238
- // }
12239
- // else{
12240
- // return item;
12241
- // }
12242
- // }) || [];
12243
- return columns;
12304
+ let columns = props.columns || [];
12305
+ // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
12306
+ let fields = props.fields;
12307
+ if(columns && columns.length){
12308
+ return columns.map(function(column){
12309
+ let field, extendColumnProps = {};
12310
+ if(typeof column === "string"){
12311
+ // 如果字符串,则取出要显示的列配置
12312
+ field = fields.find(function(fieldItem){
12313
+ return fieldItem.name === column;
12314
+ });
12315
+ }
12316
+ else {
12317
+ // 如果是对象,则合并到steedos-field的config.amis属性中,steedos组件会把config.amis属性混合到最终生成的input-table column
12318
+ field = fields.find(function(fieldItem){
12319
+ return fieldItem.name === column.name;
12320
+ });
12321
+ if(field){
12322
+ // field.amis = Object.assign({}, field.amis, column);
12323
+ // 如果把column合并到field.amis,column的label/width等属性不会生效,只能放外层合并
12324
+ extendColumnProps = column;
12325
+ }
12326
+ }
12327
+ if(field){
12328
+ return {
12329
+ "type": "steedos-field",
12330
+ "config": field,
12331
+ "static": true,
12332
+ "readonly": true,
12333
+ label: field.label,
12334
+ name: field.name,
12335
+ hideLabel: true,
12336
+ ...extendColumnProps
12337
+ }
12338
+ }
12339
+ else {
12340
+ return column;
12341
+ }
12342
+ });
12343
+ }
12344
+ else {
12345
+ return fields.map(function(field){
12346
+ return {
12347
+ "type": "steedos-field",
12348
+ "config": field,
12349
+ "static": true,
12350
+ "readonly": true,
12351
+ label: field.label,
12352
+ name: field.name,
12353
+ hideLabel: true
12354
+ }
12355
+ }) || [];
12356
+ }
12244
12357
  }
12245
12358
 
12246
12359
  /**
@@ -12251,6 +12364,7 @@ function getForm(props, mode = "edit") {
12251
12364
  let schema = {
12252
12365
  "type": "form",
12253
12366
  "title": "表单",
12367
+ "debug": false,
12254
12368
  "body": getFormFields(props, mode)
12255
12369
  };
12256
12370
  if (mode === "edit") {
@@ -12324,10 +12438,11 @@ function getButtonNew(props) {
12324
12438
  "actionType": "dialog",
12325
12439
  "dialog": {
12326
12440
  "type": "dialog",
12327
- "title": "弹框标题",
12441
+ "title": "新增行",
12328
12442
  "body": [
12329
12443
  getForm(props, "new")
12330
12444
  ],
12445
+ "size": "md",
12331
12446
  "showCloseButton": true,
12332
12447
  "showErrorMsg": true,
12333
12448
  "showLoading": true,
@@ -12345,7 +12460,9 @@ function getButtonNew(props) {
12345
12460
  function getButtonEdit(props) {
12346
12461
  return {
12347
12462
  "type": "button",
12348
- "label": "编辑",
12463
+ "label": "",
12464
+ "icon": "fa fa-pencil",
12465
+ "level": "link",
12349
12466
  "onEvent": {
12350
12467
  "click": {
12351
12468
  "actions": [
@@ -12353,10 +12470,42 @@ function getButtonEdit(props) {
12353
12470
  "actionType": "dialog",
12354
12471
  "dialog": {
12355
12472
  "type": "dialog",
12356
- "title": "弹框标题",
12473
+ "title": "编辑行",
12357
12474
  "body": [
12358
12475
  getForm(props, "edit")
12359
12476
  ],
12477
+ "size": "md",
12478
+ "showCloseButton": true,
12479
+ "showErrorMsg": true,
12480
+ "showLoading": true,
12481
+ "className": "app-popover",
12482
+ "closeOnEsc": false
12483
+ }
12484
+ }
12485
+ ]
12486
+ }
12487
+ }
12488
+ };
12489
+ }
12490
+
12491
+ function getButtonView(props) {
12492
+ return {
12493
+ "type": "button",
12494
+ "label": "",
12495
+ "icon": "fa fa-external-link",
12496
+ "level": "link",
12497
+ "onEvent": {
12498
+ "click": {
12499
+ "actions": [
12500
+ {
12501
+ "actionType": "dialog",
12502
+ "dialog": {
12503
+ "type": "dialog",
12504
+ "title": "查看行",
12505
+ "body": [
12506
+ getForm(props, "readonly")
12507
+ ],
12508
+ "size": "md",
12360
12509
  "showCloseButton": true,
12361
12510
  "showErrorMsg": true,
12362
12511
  "showLoading": true,
@@ -12373,7 +12522,9 @@ function getButtonEdit(props) {
12373
12522
  function getButtonDelete(props) {
12374
12523
  return {
12375
12524
  "type": "button",
12376
- "label": "删除",
12525
+ "label": "",
12526
+ "icon": "fa fa-minus",
12527
+ "level": "link",
12377
12528
  "onEvent": {
12378
12529
  "click": {
12379
12530
  "actions": [
@@ -12394,14 +12545,21 @@ const getAmisInputTableSchema = async (props, readonly) => {
12394
12545
  if (!props.id) {
12395
12546
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
12396
12547
  }
12397
- let buttonNewSchema = getButtonNew(props);
12398
- let buttonEditSchema = getButtonEdit(props);
12399
- let buttonDeleteSchema = getButtonDelete(props);
12400
12548
  let buttonsForColumnOperations = [];
12401
12549
  if (props.editable) {
12550
+ let buttonEditSchema = getButtonEdit(props);
12402
12551
  buttonsForColumnOperations.push(buttonEditSchema);
12403
12552
  }
12553
+ else {
12554
+ // 只读时显示查看按钮
12555
+ if(props.columns && props.columns.length > 0 && props.columns.length < props.fields.length){
12556
+ // 只在有列被隐藏时才需要显示查看按钮
12557
+ let buttonViewSchema = getButtonView(props);
12558
+ buttonsForColumnOperations.push(buttonViewSchema);
12559
+ }
12560
+ }
12404
12561
  if (props.removable) {
12562
+ let buttonDeleteSchema = getButtonDelete(props);
12405
12563
  buttonsForColumnOperations.push(buttonDeleteSchema);
12406
12564
  }
12407
12565
  let inputTableSchema = {
@@ -12426,7 +12584,8 @@ const getAmisInputTableSchema = async (props, readonly) => {
12426
12584
  inputTableSchema.columns.push({
12427
12585
  "name": "__op__",
12428
12586
  "type": "operation",
12429
- "buttons": buttonsForColumnOperations
12587
+ "buttons": buttonsForColumnOperations,
12588
+ "width": buttonsForColumnOperations.length > 1 ? "46px" : "20px"
12430
12589
  });
12431
12590
  }
12432
12591
  let schema = {
@@ -12437,8 +12596,12 @@ const getAmisInputTableSchema = async (props, readonly) => {
12437
12596
  ]
12438
12597
  };
12439
12598
  if (props.addable) {
12599
+ let buttonNewSchema = getButtonNew(props);
12440
12600
  schema.body.push(buttonNewSchema);
12441
12601
  }
12602
+ if (props.amis) {
12603
+ Object.assign(schema.body[0], props.amis);
12604
+ }
12442
12605
  return schema;
12443
12606
  };
12444
12607
 
@@ -15182,6 +15345,8 @@ exports.getRecordPageInitSchema = getRecordPageInitSchema;
15182
15345
  exports.getRecordPermissions = getRecordPermissions;
15183
15346
  exports.getRecordServiceSchema = getRecordServiceSchema;
15184
15347
  exports.getReferenceTo = getReferenceTo;
15348
+ exports.getReferenceToFieldSchema = getReferenceToFieldSchema;
15349
+ exports.getReferenceToSync = getReferenceToSync;
15185
15350
  exports.getRelatedFieldValue = getRelatedFieldValue;
15186
15351
  exports.getRelatedListSchema = getRelatedListSchema;
15187
15352
  exports.getRelatedsCount = getRelatedsCount;
@@ -15193,7 +15358,7 @@ exports.getSteedosAuth = getSteedosAuth;
15193
15358
  exports.getTableSchema = getTableSchema$1;
15194
15359
  exports.getTenantId = getTenantId;
15195
15360
  exports.getUISchema = getUISchema;
15196
- exports.getUISchemaSync = getUISchemaSync;
15361
+ exports.getUISchemaSync = getUISchemaSync$1;
15197
15362
  exports.getUserId = getUserId;
15198
15363
  exports.getViewSchema = getViewSchema;
15199
15364
  exports.isExpression = isExpression;