@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.esm.js CHANGED
@@ -3081,6 +3081,17 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3081
3081
  crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
3082
3082
  `;
3083
3083
  const onCancelScript = `
3084
+ doAction(
3085
+ {
3086
+ "componentId": 'service_${ctx.crudId}',
3087
+ "actionType": "setValue",
3088
+ "args": {
3089
+ "value": {
3090
+ "__filterFormValues": null
3091
+ }
3092
+ }
3093
+ }
3094
+ )
3084
3095
  const scope = event.context.scoped;
3085
3096
  var filterForm = scope.parent.parent.getComponents().find(function(n){
3086
3097
  return n.props.type === "form";
@@ -3115,7 +3126,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3115
3126
  removedValues[keywordsSearchBoxName] = filterFormValues[keywordsSearchBoxName];
3116
3127
  }
3117
3128
  filterForm.reset();
3118
- listView.handleFilterSubmit(removedValues);
3129
+ setTimeout(()=>{
3130
+ listView.handleFilterSubmit(removedValues);
3131
+ }, 100);
3119
3132
  const filterService = filterForm.context.getComponents().find(function(n){
3120
3133
  return n.props.type === "service";
3121
3134
  });
@@ -4991,7 +5004,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
4991
5004
  // }
4992
5005
  `;
4993
5006
 
4994
- function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords" } = {}){
5007
+ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords", crudId } = {}){
4995
5008
  const searchableFieldsLabel = [];
4996
5009
  _.each(mainObject.fields, function (field) {
4997
5010
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
@@ -5028,23 +5041,22 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
5028
5041
  "clearAndSubmit": true,
5029
5042
  "searchImediately": false,
5030
5043
  "onEvent": {
5031
- "blur": {
5044
+ "change": {
5032
5045
  "actions": [
5033
5046
  {
5034
5047
  "actionType": "custom",
5035
5048
  "script": `
5036
- try {
5037
- const scope = event.context.scoped;
5038
- const filterCrud = scope.parent.getComponents().find(function(n) {
5039
- return n.props.type === "crud";
5040
- });
5041
- if (filterCrud && typeof filterCrud.reload === 'function') {
5042
- const keyWords = { '${keywordsSearchBoxName}': event.data.value };
5043
- filterCrud.reload(null, keyWords);
5049
+ doAction(
5050
+ {
5051
+ "componentId": 'service_${crudId}',
5052
+ "actionType": "setValue",
5053
+ "args": {
5054
+ "value": {
5055
+ "__serachBoxValues": event.data
5056
+ }
5044
5057
  }
5045
- } catch (error) {
5046
- console.error('An error occurred:', error);
5047
- }
5058
+ }
5059
+ )
5048
5060
  `
5049
5061
  }
5050
5062
  ]
@@ -5056,7 +5068,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
5056
5068
  }
5057
5069
 
5058
5070
  function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5059
- showDisplayAs = false, hiddenCount = false, headerToolbarItems,
5071
+ showDisplayAs = false, hiddenCount = false, headerToolbarItems, crudId,
5060
5072
  filterVisible = true, isLookup = false, keywordsSearchBoxName } = {}){
5061
5073
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5062
5074
  // console.log(`getObjectHeaderToolbar`, mainObject)
@@ -5160,7 +5172,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
5160
5172
  };
5161
5173
  }
5162
5174
  let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name);
5163
- let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName });
5175
+ let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName, crudId });
5164
5176
 
5165
5177
  // toolbars返回的数组元素不可以是空对象{},比如hiddenCount ? {} : {"type": "tpl",...},因为空对象最终还是会生成一个空的.antd-Crud-toolbar-item dom
5166
5178
  // 当出现空的.antd-Crud-toolbar-item dom时会影响toolbar元素的maring-right css样式计算,如果有动态需要应该加到动态数组变量toolbars中
@@ -5326,6 +5338,26 @@ async function getObjectFilter(objectSchema, fields, options) {
5326
5338
  "script": onSubmitSuccScript
5327
5339
  }
5328
5340
  ]
5341
+ },
5342
+ "change": {
5343
+ "actions": [
5344
+ {
5345
+ "actionType": "custom",
5346
+ "script": `
5347
+ doAction(
5348
+ {
5349
+ "componentId": 'service_${options.crudId}',
5350
+ "actionType": "setValue",
5351
+ "args": {
5352
+ "value": {
5353
+ "__filterFormValues": event.data
5354
+ }
5355
+ }
5356
+ }
5357
+ )
5358
+ `
5359
+ }
5360
+ ]
5329
5361
  }
5330
5362
  }
5331
5363
  }
@@ -5529,19 +5561,12 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
5529
5561
 
5530
5562
  const keywordsSearchBoxName = `__keywords_lookup`;
5531
5563
 
5532
- const getReferenceTo = async (field)=>{
5564
+ const getReferenceToFieldSchema = (field, refObjectConfig)=>{
5533
5565
  let referenceTo = field.reference_to;
5534
5566
  if(!referenceTo){
5535
- return ;
5536
- }
5537
-
5538
- if(referenceTo === 'users'){
5539
- referenceTo = 'space_users';
5540
- field.reference_to_field = 'user';
5567
+ return;
5541
5568
  }
5542
5569
 
5543
- const refObjectConfig = await getUISchema(referenceTo);
5544
-
5545
5570
  // 如果lookup 引用的对象未定义
5546
5571
  if (!refObjectConfig)
5547
5572
  return null;
@@ -5564,6 +5589,28 @@ const getReferenceTo = async (field)=>{
5564
5589
  }
5565
5590
  };
5566
5591
 
5592
+ const getReferenceTo = async (field)=>{
5593
+ let referenceTo = field.reference_to;
5594
+ if(referenceTo === 'users'){
5595
+ field.reference_to = 'space_users';
5596
+ field.reference_to_field = 'user';
5597
+ }
5598
+
5599
+ const refObjectConfig = await getUISchema(field.reference_to);
5600
+ return getReferenceToFieldSchema(field, refObjectConfig);
5601
+ };
5602
+
5603
+ function getReferenceToSync(field) {
5604
+ let referenceTo = field.reference_to;
5605
+ if(referenceTo === 'users'){
5606
+ field.reference_to = 'space_users';
5607
+ field.reference_to_field = 'user';
5608
+ }
5609
+
5610
+ const refObjectConfig = getUISchemaSync(field.reference_to);
5611
+ return getReferenceToFieldSchema(field, refObjectConfig);
5612
+ }
5613
+
5567
5614
  function getLookupSapceUserTreeSchema(isMobile){
5568
5615
  const treeSchema = {
5569
5616
  "type": "input-tree",
@@ -6157,7 +6204,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
6157
6204
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
6158
6205
  apiInfo.requestAdaptor = `
6159
6206
  var filters = [];
6160
- var top = 10;
6207
+ var top = 200;
6161
6208
  if(api.data.$term){
6162
6209
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
6163
6210
  }
@@ -6467,6 +6514,12 @@ async function getIdsPickerSchema(field, readonly, ctx){
6467
6514
  return data;
6468
6515
  }
6469
6516
 
6517
+
6518
+ if(typeof window != 'undefined'){
6519
+ window.getReferenceTo = getReferenceTo;
6520
+ window.getReferenceToSync = getReferenceToSync;
6521
+ }
6522
+
6470
6523
  /*
6471
6524
  * @Author: baozhoutao@steedos.com
6472
6525
  * @Date: 2023-01-13 17:27:54
@@ -6644,8 +6697,8 @@ function getAmisStaticFieldType(type, readonly, options){
6644
6697
  /*
6645
6698
  * @Author: baozhoutao@steedos.com
6646
6699
  * @Date: 2022-10-28 14:15:09
6647
- * @LastEditors: 孙浩林 sunhaolin@steedos.com
6648
- * @LastEditTime: 2023-11-24 13:45:24
6700
+ * @LastEditors: liaodaxue
6701
+ * @LastEditTime: 2023-10-30 17:51:54
6649
6702
  * @Description:
6650
6703
  */
6651
6704
 
@@ -6682,7 +6735,7 @@ const getAmisFileReadonlySchema = (steedosField)=>{
6682
6735
  <% let fileData = data._display.${steedosField.name}; if (fileData) { %>
6683
6736
  <% if(!Array.isArray(fileData)){ fileData = [fileData]} %>
6684
6737
  <% fileData.forEach(function(item) { %>
6685
- <a href='<%= item.url+"?download=1" %>' target='_self' class='block'><%= item.name %></a>
6738
+ <a href='<%= item.url %>' target='_self' class='block'><%= item.name %></a>
6686
6739
  <% });} %>`
6687
6740
  }
6688
6741
  }
@@ -6825,6 +6878,8 @@ function getAmisFieldType(sField){
6825
6878
  break;
6826
6879
  case 'grid':
6827
6880
  return 'table';
6881
+ case 'table':
6882
+ return 'steedos-input-table';
6828
6883
  default:
6829
6884
  console.log('convertData default', sField.type);
6830
6885
  // convertData.type = field.type
@@ -6858,6 +6913,19 @@ function getGridFieldSubFields(mainField, fields){
6858
6913
  return newMainField;
6859
6914
  }
6860
6915
 
6916
+ function getTabledFieldSubFields(mainField, fields){
6917
+ const newMainField = Object.assign({subFields: []}, mainField);
6918
+ const subFields = _$1.filter(fields, function(field){
6919
+ let result = field.name.startsWith(`${mainField.name}.`);
6920
+ if(result){
6921
+ field._prefix = `${mainField.name}.`;
6922
+ }
6923
+ return result;
6924
+ });
6925
+ newMainField.subFields = subFields;
6926
+ return newMainField;
6927
+ }
6928
+
6861
6929
  /**
6862
6930
  * TODO 处理权限
6863
6931
  * @param {*} object steedos object
@@ -7361,6 +7429,29 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7361
7429
  }
7362
7430
  }
7363
7431
  break;
7432
+ case 'table':
7433
+ if(field.subFields){
7434
+ convertData = {
7435
+ type: 'steedos-input-table',
7436
+ showIndex: true,
7437
+ editable: !readonly,
7438
+ addable: !readonly,
7439
+ removable: !readonly,
7440
+ draggable: !readonly,
7441
+ fields: [],
7442
+ amis:{
7443
+ columnsTogglable: false
7444
+ }
7445
+ };
7446
+ for (const subField of field.subFields) {
7447
+ const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
7448
+ const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
7449
+ if(gridSub){
7450
+ convertData.fields.push(Object.assign({}, subField, {name: subFieldName}));
7451
+ }
7452
+ }
7453
+ }
7454
+ break;
7364
7455
  case 'object':
7365
7456
  if(field.subFields){
7366
7457
  convertData = {
@@ -7432,7 +7523,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7432
7523
  return convertData
7433
7524
  }
7434
7525
  // if(ctx.mode === 'edit'){
7435
- return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
7526
+ let convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
7527
+ // console.log("convertDataResult:", convertDataResult);
7528
+ return convertDataResult;
7436
7529
  // }else{
7437
7530
  // return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
7438
7531
  // }
@@ -7524,38 +7617,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
7524
7617
 
7525
7618
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
7526
7619
  if(amisField){
7527
- const changeActionsFields = ['select', 'boolean', 'toggle', 'date', 'datetime', 'time', 'number', 'currency', 'lookup', 'master_detail'];
7528
- const isChangeActions = changeActionsFields.indexOf(field.type) > -1;
7529
- let additionalProps = {
7620
+ return Object.assign({}, amisField,{
7530
7621
  submitOnChange: false
7531
- };
7532
- if (isChangeActions) {
7533
- additionalProps.submitOnChange = true;
7534
- } else {
7535
- additionalProps.onEvent = {
7536
- blur: {
7537
- actions: [
7538
- {
7539
- actionType: "custom",
7540
- script: `
7541
- try {
7542
- const scope = event.context.scoped;
7543
- const filterForm = scope.parent.parent.parent.getComponents().find(function(n) {
7544
- return n.props.type === "form";
7545
- });
7546
- if (filterForm && typeof filterForm.handleFormSubmit === 'function') {
7547
- filterForm.handleFormSubmit(event);
7548
- }
7549
- } catch (error) {
7550
- console.error('An error occurred:', error);
7551
- }
7552
- `
7553
- }
7554
- ]
7555
- }
7556
- };
7557
- }
7558
- return Object.assign({}, amisField, additionalProps);
7622
+ });
7559
7623
  }
7560
7624
  }
7561
7625
  }
@@ -7608,6 +7672,7 @@ var index = /*#__PURE__*/Object.freeze({
7608
7672
  getAmisFieldType: getAmisFieldType,
7609
7673
  getObjectFieldSubFields: getObjectFieldSubFields,
7610
7674
  getGridFieldSubFields: getGridFieldSubFields,
7675
+ getTabledFieldSubFields: getTabledFieldSubFields,
7611
7676
  getPermissionFields: getPermissionFields,
7612
7677
  getSelectFieldOptions: getSelectFieldOptions,
7613
7678
  convertSFieldToAmisField: convertSFieldToAmisField,
@@ -8723,7 +8788,7 @@ function deleteVariable(data, key) {
8723
8788
  * @Author: baozhoutao@steedos.com
8724
8789
  * @Date: 2022-05-26 16:02:08
8725
8790
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
8726
- * @LastEditTime: 2023-10-12 18:25:05
8791
+ * @LastEditTime: 2023-11-28 17:00:28
8727
8792
  * @Description:
8728
8793
  */
8729
8794
 
@@ -8774,6 +8839,8 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
8774
8839
  if (perField.type === 'grid') {
8775
8840
  field = await getGridFieldSubFields(perField, formFields);
8776
8841
  // console.log(`perField.type grid ===> field`, field)
8842
+ } else if (perField.type === 'table') {
8843
+ field = await getTabledFieldSubFields(perField, formFields);
8777
8844
  } else if (perField.type === 'object') {
8778
8845
  field = await getObjectFieldSubFields(perField, formFields);
8779
8846
  // console.log(`perField.type object ===> field`, field)
@@ -8781,6 +8848,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
8781
8848
  if (field.name.indexOf(".") < 0) {
8782
8849
  ctx.__formFields = formFields;
8783
8850
  const amisField = await convertSFieldToAmisField(field, field.readonly, ctx);
8851
+ // 如果steedos-field稳定了,可以放开下面的代码直接用组件统一渲染字段
8852
+ // const amisField = {
8853
+ // "type": "steedos-field",
8854
+ // "config": field,
8855
+ // "readonly": field.readonly,
8856
+ // "ctx": ctx
8857
+ // };
8784
8858
  // console.log(`${field.name} amisField`, field, amisField)
8785
8859
  if (amisField) {
8786
8860
  fieldSetBody.push(amisField);
@@ -8989,6 +9063,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8989
9063
  const bulkActions = getBulkActions(objectSchema);
8990
9064
  const defaults = options.defaults;
8991
9065
  const listSchema = (defaults && defaults.listSchema) || {};
9066
+ const id = `listview_${objectSchema.name}`;
8992
9067
 
8993
9068
  const bodyProps = {
8994
9069
  // toolbar: getToolbar(),
@@ -8998,7 +9073,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8998
9073
  ...options,
8999
9074
  disableStatistics: options.queryCount === false
9000
9075
  }),
9001
- filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
9076
+ filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, Object.assign({}, options, {crudId: id})),
9002
9077
  };
9003
9078
  if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
9004
9079
  if(listSchema.mode !== "cards"){
@@ -9027,7 +9102,8 @@ async function getObjectCRUD(objectSchema, fields, options){
9027
9102
  showDisplayAs,
9028
9103
  hiddenCount: options.queryCount === false,
9029
9104
  headerToolbarItems: options.headerToolbarItems,
9030
- filterVisible: options.filterVisible
9105
+ filterVisible: options.filterVisible,
9106
+ crudId: id
9031
9107
  });
9032
9108
 
9033
9109
  options.amisData = createObject(options.amisData, {
@@ -9040,7 +9116,6 @@ async function getObjectCRUD(objectSchema, fields, options){
9040
9116
 
9041
9117
 
9042
9118
  let body = null;
9043
- const id = `listview_${objectSchema.name}`;
9044
9119
  if(options.formFactor === 'SMALL' && false){
9045
9120
  delete bodyProps.bulkActions;
9046
9121
  delete bodyProps.headerToolbar;
@@ -10034,7 +10109,7 @@ async function getUISchema(objectName, force) {
10034
10109
  return getUISchemaCache(objectName);
10035
10110
  }
10036
10111
 
10037
- function getUISchemaSync(objectName, force) {
10112
+ function getUISchemaSync$1(objectName, force) {
10038
10113
  if (!objectName) {
10039
10114
  return;
10040
10115
  }
@@ -10544,7 +10619,7 @@ async function getObjectRelated(
10544
10619
 
10545
10620
  if(typeof window != 'undefined'){
10546
10621
  window.getUISchema = getUISchema;
10547
- window.getUISchemaSync = getUISchemaSync;
10622
+ window.getUISchemaSync = getUISchemaSync$1;
10548
10623
  window.getListSchema = getListSchema;
10549
10624
  }
10550
10625
 
@@ -11863,6 +11938,8 @@ async function getTableApi(mainObject, fields, options){
11863
11938
  api.data.$self = "$$";
11864
11939
  api.data.self = "$$";
11865
11940
  api.data.filter = "$filter";
11941
+ api.data.__filterFormValues = "${__filterFormValues}";
11942
+ api.data.__serachBoxValues = "${__serachBoxValues}";
11866
11943
  api.data.loaded = "${loaded}";
11867
11944
  api.data.listViewId = "${listViewId}";
11868
11945
  api.data.listName = "${listName}";
@@ -11935,9 +12012,12 @@ async function getTableApi(mainObject, fields, options){
11935
12012
  }else if(selfData.op === 'loadOptions' && selfData.value){
11936
12013
  userFilters = [["${valueField.name}", "=", selfData.value]];
11937
12014
  }
11938
-
11939
- var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
11940
12015
 
12016
+ const __filterFormValues = api.data.__filterFormValues;
12017
+ const __serachBoxValues = api.data.__serachBoxValues;
12018
+ // 筛选按钮
12019
+ const filterSelfData = __filterFormValues ? __filterFormValues : selfData;
12020
+ var searchableFilter = SteedosUI.getSearchFilter(filterSelfData) || [];
11941
12021
  if(searchableFilter.length > 0){
11942
12022
  if(userFilters.length > 0 ){
11943
12023
  userFilters = [userFilters, 'and', searchableFilter];
@@ -11946,6 +12026,7 @@ async function getTableApi(mainObject, fields, options){
11946
12026
  }
11947
12027
  }
11948
12028
 
12029
+ // "搜索此列表"搜索框
11949
12030
  if(allowSearchFields){
11950
12031
  allowSearchFields.forEach(function(key){
11951
12032
  const keyValue = selfData[key];
@@ -11957,7 +12038,8 @@ async function getTableApi(mainObject, fields, options){
11957
12038
  })
11958
12039
  }
11959
12040
 
11960
- var keywordsFilters = SteedosUI.getKeywordsSearchFilter(selfData.__keywords, allowSearchFields);
12041
+ const keyWords = __serachBoxValues ? __serachBoxValues.__keywords : selfData.__keywords;
12042
+ var keywordsFilters = SteedosUI.getKeywordsSearchFilter(keyWords, allowSearchFields);
11961
12043
  if(keywordsFilters && keywordsFilters.length > 0){
11962
12044
  userFilters.push(keywordsFilters);
11963
12045
  }
@@ -12167,7 +12249,7 @@ function getRecordPermissionsApi(object, recordId, options){
12167
12249
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12168
12250
  * @Date: 2023-11-15 09:50:22
12169
12251
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12170
- * @LastEditTime: 2023-11-17 20:17:56
12252
+ * @LastEditTime: 2023-11-28 11:34:24
12171
12253
  */
12172
12254
 
12173
12255
  /**
@@ -12176,10 +12258,14 @@ function getRecordPermissionsApi(object, recordId, options){
12176
12258
  */
12177
12259
  function getFormFields(props, mode = "edit") {
12178
12260
  return (props.fields || []).map(function (item) {
12179
- return {
12261
+ let formItem = {
12180
12262
  "type": "steedos-field",
12181
12263
  "config": item
12264
+ };
12265
+ if(mode === "readonly"){
12266
+ formItem.static = true;
12182
12267
  }
12268
+ return formItem;
12183
12269
  }) || [];
12184
12270
  }
12185
12271
 
@@ -12188,32 +12274,59 @@ function getFormFields(props, mode = "edit") {
12188
12274
  * @param {*} mode edit/new/readonly
12189
12275
  */
12190
12276
  async function getInputTableColumns(props) {
12191
- // return props.fields.map(function(item){
12192
- // return {
12193
- // "type": "steedos-field",
12194
- // "config": item,
12195
- // "static": true,
12196
- // "readonly": true
12197
- // }
12198
- // }) || [];
12199
-
12200
- let columns = await getTableColumns(props.fields || [], {
12201
- isInputTable: true,
12202
- permissions: {
12203
- allowEdit: false //快速编辑开关与权限有关
12204
- }
12205
- });
12206
- // columns = columns.map(function(item){
12207
- // if(["text"].indexOf(item.type) > -1){
12208
- // return Object.assign({}, item, {
12209
- // "type": "static"
12210
- // });
12211
- // }
12212
- // else{
12213
- // return item;
12214
- // }
12215
- // }) || [];
12216
- return columns;
12277
+ let columns = props.columns || [];
12278
+ // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
12279
+ let fields = props.fields;
12280
+ if(columns && columns.length){
12281
+ return columns.map(function(column){
12282
+ let field, extendColumnProps = {};
12283
+ if(typeof column === "string"){
12284
+ // 如果字符串,则取出要显示的列配置
12285
+ field = fields.find(function(fieldItem){
12286
+ return fieldItem.name === column;
12287
+ });
12288
+ }
12289
+ else {
12290
+ // 如果是对象,则合并到steedos-field的config.amis属性中,steedos组件会把config.amis属性混合到最终生成的input-table column
12291
+ field = fields.find(function(fieldItem){
12292
+ return fieldItem.name === column.name;
12293
+ });
12294
+ if(field){
12295
+ // field.amis = Object.assign({}, field.amis, column);
12296
+ // 如果把column合并到field.amis,column的label/width等属性不会生效,只能放外层合并
12297
+ extendColumnProps = column;
12298
+ }
12299
+ }
12300
+ if(field){
12301
+ return {
12302
+ "type": "steedos-field",
12303
+ "config": field,
12304
+ "static": true,
12305
+ "readonly": true,
12306
+ label: field.label,
12307
+ name: field.name,
12308
+ hideLabel: true,
12309
+ ...extendColumnProps
12310
+ }
12311
+ }
12312
+ else {
12313
+ return column;
12314
+ }
12315
+ });
12316
+ }
12317
+ else {
12318
+ return fields.map(function(field){
12319
+ return {
12320
+ "type": "steedos-field",
12321
+ "config": field,
12322
+ "static": true,
12323
+ "readonly": true,
12324
+ label: field.label,
12325
+ name: field.name,
12326
+ hideLabel: true
12327
+ }
12328
+ }) || [];
12329
+ }
12217
12330
  }
12218
12331
 
12219
12332
  /**
@@ -12224,6 +12337,7 @@ function getForm(props, mode = "edit") {
12224
12337
  let schema = {
12225
12338
  "type": "form",
12226
12339
  "title": "表单",
12340
+ "debug": false,
12227
12341
  "body": getFormFields(props, mode)
12228
12342
  };
12229
12343
  if (mode === "edit") {
@@ -12297,10 +12411,11 @@ function getButtonNew(props) {
12297
12411
  "actionType": "dialog",
12298
12412
  "dialog": {
12299
12413
  "type": "dialog",
12300
- "title": "弹框标题",
12414
+ "title": "新增行",
12301
12415
  "body": [
12302
12416
  getForm(props, "new")
12303
12417
  ],
12418
+ "size": "md",
12304
12419
  "showCloseButton": true,
12305
12420
  "showErrorMsg": true,
12306
12421
  "showLoading": true,
@@ -12318,7 +12433,9 @@ function getButtonNew(props) {
12318
12433
  function getButtonEdit(props) {
12319
12434
  return {
12320
12435
  "type": "button",
12321
- "label": "编辑",
12436
+ "label": "",
12437
+ "icon": "fa fa-pencil",
12438
+ "level": "link",
12322
12439
  "onEvent": {
12323
12440
  "click": {
12324
12441
  "actions": [
@@ -12326,10 +12443,42 @@ function getButtonEdit(props) {
12326
12443
  "actionType": "dialog",
12327
12444
  "dialog": {
12328
12445
  "type": "dialog",
12329
- "title": "弹框标题",
12446
+ "title": "编辑行",
12330
12447
  "body": [
12331
12448
  getForm(props, "edit")
12332
12449
  ],
12450
+ "size": "md",
12451
+ "showCloseButton": true,
12452
+ "showErrorMsg": true,
12453
+ "showLoading": true,
12454
+ "className": "app-popover",
12455
+ "closeOnEsc": false
12456
+ }
12457
+ }
12458
+ ]
12459
+ }
12460
+ }
12461
+ };
12462
+ }
12463
+
12464
+ function getButtonView(props) {
12465
+ return {
12466
+ "type": "button",
12467
+ "label": "",
12468
+ "icon": "fa fa-external-link",
12469
+ "level": "link",
12470
+ "onEvent": {
12471
+ "click": {
12472
+ "actions": [
12473
+ {
12474
+ "actionType": "dialog",
12475
+ "dialog": {
12476
+ "type": "dialog",
12477
+ "title": "查看行",
12478
+ "body": [
12479
+ getForm(props, "readonly")
12480
+ ],
12481
+ "size": "md",
12333
12482
  "showCloseButton": true,
12334
12483
  "showErrorMsg": true,
12335
12484
  "showLoading": true,
@@ -12346,7 +12495,9 @@ function getButtonEdit(props) {
12346
12495
  function getButtonDelete(props) {
12347
12496
  return {
12348
12497
  "type": "button",
12349
- "label": "删除",
12498
+ "label": "",
12499
+ "icon": "fa fa-minus",
12500
+ "level": "link",
12350
12501
  "onEvent": {
12351
12502
  "click": {
12352
12503
  "actions": [
@@ -12367,14 +12518,21 @@ const getAmisInputTableSchema = async (props, readonly) => {
12367
12518
  if (!props.id) {
12368
12519
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
12369
12520
  }
12370
- let buttonNewSchema = getButtonNew(props);
12371
- let buttonEditSchema = getButtonEdit(props);
12372
- let buttonDeleteSchema = getButtonDelete(props);
12373
12521
  let buttonsForColumnOperations = [];
12374
12522
  if (props.editable) {
12523
+ let buttonEditSchema = getButtonEdit(props);
12375
12524
  buttonsForColumnOperations.push(buttonEditSchema);
12376
12525
  }
12526
+ else {
12527
+ // 只读时显示查看按钮
12528
+ if(props.columns && props.columns.length > 0 && props.columns.length < props.fields.length){
12529
+ // 只在有列被隐藏时才需要显示查看按钮
12530
+ let buttonViewSchema = getButtonView(props);
12531
+ buttonsForColumnOperations.push(buttonViewSchema);
12532
+ }
12533
+ }
12377
12534
  if (props.removable) {
12535
+ let buttonDeleteSchema = getButtonDelete(props);
12378
12536
  buttonsForColumnOperations.push(buttonDeleteSchema);
12379
12537
  }
12380
12538
  let inputTableSchema = {
@@ -12399,7 +12557,8 @@ const getAmisInputTableSchema = async (props, readonly) => {
12399
12557
  inputTableSchema.columns.push({
12400
12558
  "name": "__op__",
12401
12559
  "type": "operation",
12402
- "buttons": buttonsForColumnOperations
12560
+ "buttons": buttonsForColumnOperations,
12561
+ "width": buttonsForColumnOperations.length > 1 ? "46px" : "20px"
12403
12562
  });
12404
12563
  }
12405
12564
  let schema = {
@@ -12410,8 +12569,12 @@ const getAmisInputTableSchema = async (props, readonly) => {
12410
12569
  ]
12411
12570
  };
12412
12571
  if (props.addable) {
12572
+ let buttonNewSchema = getButtonNew(props);
12413
12573
  schema.body.push(buttonNewSchema);
12414
12574
  }
12575
+ if (props.amis) {
12576
+ Object.assign(schema.body[0], props.amis);
12577
+ }
12415
12578
  return schema;
12416
12579
  };
12417
12580
 
@@ -15076,5 +15239,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
15076
15239
  };
15077
15240
  };
15078
15241
 
15079
- 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$1 as 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, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema$1 as getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
15242
+ 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$1 as 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$1 as 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 };
15080
15243
  //# sourceMappingURL=index.esm.js.map