@steedos-widgets/amis-object 1.3.15 → 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.
@@ -4652,7 +4652,7 @@ async function getSelectUserSchema(field, readonly, ctx) {
4652
4652
  ctx = {};
4653
4653
  }
4654
4654
  const amisSchema = {
4655
- "type": getAmisStaticFieldType('select', readonly)
4655
+ "type": getAmisStaticFieldType$1('select', readonly)
4656
4656
  };
4657
4657
 
4658
4658
  if (readonly) {
@@ -6250,6 +6250,17 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6250
6250
  crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
6251
6251
  `;
6252
6252
  const onCancelScript = `
6253
+ doAction(
6254
+ {
6255
+ "componentId": 'service_${ctx.crudId}',
6256
+ "actionType": "setValue",
6257
+ "args": {
6258
+ "value": {
6259
+ "__filterFormValues": null
6260
+ }
6261
+ }
6262
+ }
6263
+ )
6253
6264
  const scope = event.context.scoped;
6254
6265
  var filterForm = scope.parent.parent.getComponents().find(function(n){
6255
6266
  return n.props.type === "form";
@@ -6284,7 +6295,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6284
6295
  removedValues[keywordsSearchBoxName] = filterFormValues[keywordsSearchBoxName];
6285
6296
  }
6286
6297
  filterForm.reset();
6287
- listView.handleFilterSubmit(removedValues);
6298
+ setTimeout(()=>{
6299
+ listView.handleFilterSubmit(removedValues);
6300
+ }, 100);
6288
6301
  const filterService = filterForm.context.getComponents().find(function(n){
6289
6302
  return n.props.type === "service";
6290
6303
  });
@@ -8160,7 +8173,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8160
8173
  // }
8161
8174
  `;
8162
8175
 
8163
- function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords" } = {}){
8176
+ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords", crudId } = {}){
8164
8177
  const searchableFieldsLabel = [];
8165
8178
  _.each(mainObject.fields, function (field) {
8166
8179
  if (isFieldQuickSearchable(field, mainObject.NAME_FIELD_KEY)) {
@@ -8197,23 +8210,22 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8197
8210
  "clearAndSubmit": true,
8198
8211
  "searchImediately": false,
8199
8212
  "onEvent": {
8200
- "blur": {
8213
+ "change": {
8201
8214
  "actions": [
8202
8215
  {
8203
8216
  "actionType": "custom",
8204
8217
  "script": `
8205
- try {
8206
- const scope = event.context.scoped;
8207
- const filterCrud = scope.parent.getComponents().find(function(n) {
8208
- return n.props.type === "crud";
8209
- });
8210
- if (filterCrud && typeof filterCrud.reload === 'function') {
8211
- const keyWords = { '${keywordsSearchBoxName}': event.data.value };
8212
- filterCrud.reload(null, keyWords);
8218
+ doAction(
8219
+ {
8220
+ "componentId": 'service_${crudId}',
8221
+ "actionType": "setValue",
8222
+ "args": {
8223
+ "value": {
8224
+ "__serachBoxValues": event.data
8225
+ }
8213
8226
  }
8214
- } catch (error) {
8215
- console.error('An error occurred:', error);
8216
- }
8227
+ }
8228
+ )
8217
8229
  `
8218
8230
  }
8219
8231
  ]
@@ -8225,7 +8237,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8225
8237
  }
8226
8238
 
8227
8239
  function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8228
- showDisplayAs = false, hiddenCount = false, headerToolbarItems,
8240
+ showDisplayAs = false, hiddenCount = false, headerToolbarItems, crudId,
8229
8241
  filterVisible = true, isLookup = false, keywordsSearchBoxName } = {}){
8230
8242
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
8231
8243
  // console.log(`getObjectHeaderToolbar`, mainObject)
@@ -8329,7 +8341,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8329
8341
  };
8330
8342
  }
8331
8343
  let toolbarDisplayAsButton = getDisplayAsButton(mainObject?.name);
8332
- let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName });
8344
+ let toolbarDQuickSearchBox = getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup, keywordsSearchBoxName, crudId });
8333
8345
 
8334
8346
  // toolbars返回的数组元素不可以是空对象{},比如hiddenCount ? {} : {"type": "tpl",...},因为空对象最终还是会生成一个空的.antd-Crud-toolbar-item dom
8335
8347
  // 当出现空的.antd-Crud-toolbar-item dom时会影响toolbar元素的maring-right css样式计算,如果有动态需要应该加到动态数组变量toolbars中
@@ -8495,6 +8507,26 @@ async function getObjectFilter(objectSchema, fields, options) {
8495
8507
  "script": onSubmitSuccScript
8496
8508
  }
8497
8509
  ]
8510
+ },
8511
+ "change": {
8512
+ "actions": [
8513
+ {
8514
+ "actionType": "custom",
8515
+ "script": `
8516
+ doAction(
8517
+ {
8518
+ "componentId": 'service_${options.crudId}',
8519
+ "actionType": "setValue",
8520
+ "args": {
8521
+ "value": {
8522
+ "__filterFormValues": event.data
8523
+ }
8524
+ }
8525
+ }
8526
+ )
8527
+ `
8528
+ }
8529
+ ]
8498
8530
  }
8499
8531
  }
8500
8532
  }
@@ -8658,7 +8690,7 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
8658
8690
  ctx = {};
8659
8691
  }
8660
8692
  const amisSchema = {
8661
- "type": getAmisStaticFieldType('tree-select', readonly)
8693
+ "type": getAmisStaticFieldType$1('tree-select', readonly)
8662
8694
  };
8663
8695
 
8664
8696
  if (readonly) {
@@ -8698,19 +8730,12 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
8698
8730
 
8699
8731
  const keywordsSearchBoxName = `__keywords_lookup`;
8700
8732
 
8701
- const getReferenceTo = async (field)=>{
8733
+ const getReferenceToFieldSchema = (field, refObjectConfig)=>{
8702
8734
  let referenceTo = field.reference_to;
8703
8735
  if(!referenceTo){
8704
- return ;
8705
- }
8706
-
8707
- if(referenceTo === 'users'){
8708
- referenceTo = 'space_users';
8709
- field.reference_to_field = 'user';
8736
+ return;
8710
8737
  }
8711
8738
 
8712
- const refObjectConfig = await getUISchema(referenceTo);
8713
-
8714
8739
  // 如果lookup 引用的对象未定义
8715
8740
  if (!refObjectConfig)
8716
8741
  return null;
@@ -8733,6 +8758,28 @@ const getReferenceTo = async (field)=>{
8733
8758
  }
8734
8759
  };
8735
8760
 
8761
+ const getReferenceTo = async (field)=>{
8762
+ let referenceTo = field.reference_to;
8763
+ if(referenceTo === 'users'){
8764
+ field.reference_to = 'space_users';
8765
+ field.reference_to_field = 'user';
8766
+ }
8767
+
8768
+ const refObjectConfig = await getUISchema(field.reference_to);
8769
+ return getReferenceToFieldSchema(field, refObjectConfig);
8770
+ };
8771
+
8772
+ function getReferenceToSync(field) {
8773
+ let referenceTo = field.reference_to;
8774
+ if(referenceTo === 'users'){
8775
+ field.reference_to = 'space_users';
8776
+ field.reference_to_field = 'user';
8777
+ }
8778
+
8779
+ const refObjectConfig = getUISchemaSync(field.reference_to);
8780
+ return getReferenceToFieldSchema(field, refObjectConfig);
8781
+ }
8782
+
8736
8783
  function getLookupSapceUserTreeSchema(isMobile){
8737
8784
  const treeSchema = {
8738
8785
  "type": "input-tree",
@@ -9223,7 +9270,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
9223
9270
  }
9224
9271
 
9225
9272
  const data = {
9226
- type: getAmisStaticFieldType('picker', readonly),
9273
+ type: getAmisStaticFieldType$1('picker', readonly),
9227
9274
  modalTitle: instance.t('frontend_form_please_select') + " " + refObjectConfig.label,
9228
9275
  labelField: referenceTo.labelField.name,
9229
9276
  valueField: referenceTo.valueField.name,
@@ -9326,7 +9373,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
9326
9373
  // [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
9327
9374
  apiInfo.requestAdaptor = `
9328
9375
  var filters = [];
9329
- var top = 10;
9376
+ var top = 200;
9330
9377
  if(api.data.$term){
9331
9378
  filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
9332
9379
  }
@@ -9406,7 +9453,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
9406
9453
  }
9407
9454
 
9408
9455
  const data = {
9409
- type: getAmisStaticFieldType('select', readonly),
9456
+ type: getAmisStaticFieldType$1('select', readonly),
9410
9457
  joinValues: false,
9411
9458
  extractValue: true,
9412
9459
  clearable: true,
@@ -9460,7 +9507,7 @@ async function lookupToAmis(field, readonly, ctx){
9460
9507
  // console.log(`lookupToAmis====`, field, readonly, ctx)
9461
9508
  if(readonly){
9462
9509
  return {
9463
- type: getAmisStaticFieldType('picker', readonly),
9510
+ type: getAmisStaticFieldType$1('picker', readonly),
9464
9511
  tpl: getRelatedFieldTpl(field, ctx)
9465
9512
  }
9466
9513
  }
@@ -9605,7 +9652,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
9605
9652
  }
9606
9653
 
9607
9654
  const data = {
9608
- type: getAmisStaticFieldType('picker', readonly),
9655
+ type: getAmisStaticFieldType$1('picker', readonly),
9609
9656
  labelField: referenceTo.labelField.name,
9610
9657
  valueField: referenceTo.valueField.name,
9611
9658
  modalMode: 'dialog',
@@ -9636,6 +9683,12 @@ async function getIdsPickerSchema(field, readonly, ctx){
9636
9683
  return data;
9637
9684
  }
9638
9685
 
9686
+
9687
+ if(typeof window != 'undefined'){
9688
+ window.getReferenceTo = getReferenceTo;
9689
+ window.getReferenceToSync = getReferenceToSync;
9690
+ }
9691
+
9639
9692
  /*
9640
9693
  * @Author: baozhoutao@steedos.com
9641
9694
  * @Date: 2023-01-13 17:27:54
@@ -9770,7 +9823,7 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
9770
9823
  * @Description:
9771
9824
  */
9772
9825
 
9773
- const AmisFormInputs = [
9826
+ const AmisFormInputs$1 = [
9774
9827
  'text',
9775
9828
  'date',
9776
9829
  'file',
@@ -9786,9 +9839,9 @@ const AmisFormInputs = [
9786
9839
  'email'
9787
9840
  ];
9788
9841
 
9789
- function getAmisStaticFieldType(type, readonly, options){
9842
+ function getAmisStaticFieldType$1(type, readonly, options){
9790
9843
  if(!readonly){
9791
- if(_$1__namespace.includes(AmisFormInputs, type)){
9844
+ if(_$1__namespace.includes(AmisFormInputs$1, type)){
9792
9845
  return `input-${type}`;
9793
9846
  }else if(type === 'location'){
9794
9847
  return "location-picker"
@@ -9830,7 +9883,7 @@ const getFileTableName = (steedosField)=>{
9830
9883
  };
9831
9884
 
9832
9885
  const getAmisFieldType$1 = (steedosField, readonly)=>{
9833
- return getAmisStaticFieldType(steedosField.type === 'avatar' ? 'image' : steedosField.type, readonly, {multiple: steedosField.multiple});
9886
+ return getAmisStaticFieldType$1(steedosField.type === 'avatar' ? 'image' : steedosField.type, readonly, {multiple: steedosField.multiple});
9834
9887
  };
9835
9888
 
9836
9889
  const getAmisFileReadonlySchema = (steedosField)=>{
@@ -9994,6 +10047,8 @@ function getAmisFieldType(sField){
9994
10047
  break;
9995
10048
  case 'grid':
9996
10049
  return 'table';
10050
+ case 'table':
10051
+ return 'steedos-input-table';
9997
10052
  default:
9998
10053
  console.log('convertData default', sField.type);
9999
10054
  // convertData.type = field.type
@@ -10027,6 +10082,19 @@ function getGridFieldSubFields(mainField, fields){
10027
10082
  return newMainField;
10028
10083
  }
10029
10084
 
10085
+ function getTabledFieldSubFields(mainField, fields){
10086
+ const newMainField = Object.assign({subFields: []}, mainField);
10087
+ const subFields = _$1__namespace.filter(fields, function(field){
10088
+ let result = field.name.startsWith(`${mainField.name}.`);
10089
+ if(result){
10090
+ field._prefix = `${mainField.name}.`;
10091
+ }
10092
+ return result;
10093
+ });
10094
+ newMainField.subFields = subFields;
10095
+ return newMainField;
10096
+ }
10097
+
10030
10098
  /**
10031
10099
  * TODO 处理权限
10032
10100
  * @param {*} object steedos object
@@ -10082,10 +10150,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10082
10150
  // }
10083
10151
  switch (field.type) {
10084
10152
  case 'text':
10085
- convertData.type = getAmisStaticFieldType('text', readonly, field);
10153
+ convertData.type = getAmisStaticFieldType$1('text', readonly, field);
10086
10154
  break;
10087
10155
  case 'textarea':
10088
- convertData.type = getAmisStaticFieldType('textarea', readonly);
10156
+ convertData.type = getAmisStaticFieldType$1('textarea', readonly);
10089
10157
  // convertData.tpl = `<b><%=data.${field.name}%></b>`;
10090
10158
  convertData.tpl = `<%=(data.${field.name} || "").split("\\n").join('<br>')%>`;
10091
10159
  break;
@@ -10114,7 +10182,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10114
10182
  };
10115
10183
  }else {
10116
10184
  convertData = {
10117
- type: getAmisStaticFieldType('select', readonly),
10185
+ type: getAmisStaticFieldType$1('select', readonly),
10118
10186
  joinValues: false,
10119
10187
  options: getSelectFieldOptions(field),
10120
10188
  extractValue: true,
@@ -10142,7 +10210,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10142
10210
  break;
10143
10211
  case 'boolean':
10144
10212
  convertData = {
10145
- type: getAmisStaticFieldType('checkbox', readonly),
10213
+ type: getAmisStaticFieldType$1('checkbox', readonly),
10146
10214
  // option: field.inlineHelpText,
10147
10215
  tpl: readonly ? getSwitchTpl(field) : null
10148
10216
  };
@@ -10185,7 +10253,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10185
10253
  // // utc: true
10186
10254
  // }
10187
10255
  convertData = {
10188
- type: getAmisStaticFieldType('date', readonly),
10256
+ type: getAmisStaticFieldType$1('date', readonly),
10189
10257
  inputFormat: "YYYY-MM-DD",
10190
10258
  format:'YYYY-MM-DDT00:00:00.000[Z]',
10191
10259
  tpl: readonly ? getDateTpl(field) : null,
@@ -10248,7 +10316,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10248
10316
  // }
10249
10317
 
10250
10318
  convertData = {
10251
- type: getAmisStaticFieldType('datetime', readonly),
10319
+ type: getAmisStaticFieldType$1('datetime', readonly),
10252
10320
  inputFormat: 'YYYY-MM-DD HH:mm',
10253
10321
  format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
10254
10322
  tpl: readonly ? getDateTimeTpl(field) : null,
@@ -10295,7 +10363,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10295
10363
  // // utc: true
10296
10364
  // }
10297
10365
  convertData = {
10298
- type: getAmisStaticFieldType('time', readonly),
10366
+ type: getAmisStaticFieldType$1('time', readonly),
10299
10367
  inputFormat: 'HH:mm',
10300
10368
  timeFormat:'HH:mm',
10301
10369
  format:'1970-01-01THH:mm:00.000[Z]',
@@ -10312,7 +10380,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10312
10380
  };
10313
10381
  }else {
10314
10382
  convertData = {
10315
- type: getAmisStaticFieldType('number', readonly),
10383
+ type: getAmisStaticFieldType$1('number', readonly),
10316
10384
  min: field.min,
10317
10385
  max: field.max,
10318
10386
  precision: field.scale
@@ -10341,7 +10409,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10341
10409
  };
10342
10410
  }else {
10343
10411
  convertData = {
10344
- type: getAmisStaticFieldType('number', readonly),
10412
+ type: getAmisStaticFieldType$1('number', readonly),
10345
10413
  min: field.min,
10346
10414
  max: field.max,
10347
10415
  precision: field.scale,
@@ -10365,7 +10433,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10365
10433
  break;
10366
10434
  case 'password':
10367
10435
  convertData = {
10368
- type: getAmisStaticFieldType('password', readonly),
10436
+ type: getAmisStaticFieldType$1('password', readonly),
10369
10437
  tpl: readonly ? getPasswordTpl(field) : null
10370
10438
  };
10371
10439
  break;
@@ -10384,7 +10452,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10384
10452
  break;
10385
10453
  case 'url':
10386
10454
  convertData = {
10387
- type: getAmisStaticFieldType('url', readonly, field),
10455
+ type: getAmisStaticFieldType$1('url', readonly, field),
10388
10456
  static: readonly ? true : false
10389
10457
  };
10390
10458
  if(readonly && field.show_as_qr){
@@ -10401,7 +10469,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10401
10469
  break;
10402
10470
  case 'email':
10403
10471
  convertData = {
10404
- type: getAmisStaticFieldType('email', readonly)
10472
+ type: getAmisStaticFieldType$1('email', readonly)
10405
10473
  };
10406
10474
  break;
10407
10475
  case 'location':
@@ -10422,7 +10490,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10422
10490
 
10423
10491
  const coordinatesType = field.coordinatesType || "bd09";
10424
10492
  convertData = {
10425
- type: getAmisStaticFieldType('location', readonly),
10493
+ type: getAmisStaticFieldType$1('location', readonly),
10426
10494
  tpl: readonly ? getLocationTpl(field) : null,
10427
10495
  ak,
10428
10496
  vendor,
@@ -10530,6 +10598,29 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10530
10598
  }
10531
10599
  }
10532
10600
  break;
10601
+ case 'table':
10602
+ if(field.subFields){
10603
+ convertData = {
10604
+ type: 'steedos-input-table',
10605
+ showIndex: true,
10606
+ editable: !readonly,
10607
+ addable: !readonly,
10608
+ removable: !readonly,
10609
+ draggable: !readonly,
10610
+ fields: [],
10611
+ amis:{
10612
+ columnsTogglable: false
10613
+ }
10614
+ };
10615
+ for (const subField of field.subFields) {
10616
+ const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
10617
+ const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
10618
+ if(gridSub){
10619
+ convertData.fields.push(Object.assign({}, subField, {name: subFieldName}));
10620
+ }
10621
+ }
10622
+ }
10623
+ break;
10533
10624
  case 'object':
10534
10625
  if(field.subFields){
10535
10626
  convertData = {
@@ -10601,7 +10692,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10601
10692
  return convertData
10602
10693
  }
10603
10694
  // if(ctx.mode === 'edit'){
10604
- return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
10695
+ let convertDataResult = Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
10696
+ // console.log("convertDataResult:", convertDataResult);
10697
+ return convertDataResult;
10605
10698
  // }else{
10606
10699
  // return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
10607
10700
  // }
@@ -10693,38 +10786,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
10693
10786
 
10694
10787
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
10695
10788
  if(amisField){
10696
- const changeActionsFields = ['select', 'boolean', 'toggle', 'date', 'datetime', 'time', 'number', 'currency', 'lookup', 'master_detail'];
10697
- const isChangeActions = changeActionsFields.indexOf(field.type) > -1;
10698
- let additionalProps = {
10789
+ return Object.assign({}, amisField,{
10699
10790
  submitOnChange: false
10700
- };
10701
- if (isChangeActions) {
10702
- additionalProps.submitOnChange = true;
10703
- } else {
10704
- additionalProps.onEvent = {
10705
- blur: {
10706
- actions: [
10707
- {
10708
- actionType: "custom",
10709
- script: `
10710
- try {
10711
- const scope = event.context.scoped;
10712
- const filterForm = scope.parent.parent.parent.getComponents().find(function(n) {
10713
- return n.props.type === "form";
10714
- });
10715
- if (filterForm && typeof filterForm.handleFormSubmit === 'function') {
10716
- filterForm.handleFormSubmit(event);
10717
- }
10718
- } catch (error) {
10719
- console.error('An error occurred:', error);
10720
- }
10721
- `
10722
- }
10723
- ]
10724
- }
10725
- };
10726
- }
10727
- return Object.assign({}, amisField, additionalProps);
10791
+ });
10728
10792
  }
10729
10793
  }
10730
10794
  }
@@ -10777,13 +10841,14 @@ var index = /*#__PURE__*/Object.freeze({
10777
10841
  getAmisFieldType: getAmisFieldType,
10778
10842
  getObjectFieldSubFields: getObjectFieldSubFields,
10779
10843
  getGridFieldSubFields: getGridFieldSubFields,
10844
+ getTabledFieldSubFields: getTabledFieldSubFields,
10780
10845
  getPermissionFields: getPermissionFields,
10781
10846
  getSelectFieldOptions: getSelectFieldOptions,
10782
10847
  convertSFieldToAmisField: convertSFieldToAmisField,
10783
10848
  getFieldSearchable: getFieldSearchable,
10784
10849
  isFieldTypeSearchable: isFieldTypeSearchable,
10785
10850
  isFieldQuickSearchable: isFieldQuickSearchable,
10786
- getAmisStaticFieldType: getAmisStaticFieldType
10851
+ getAmisStaticFieldType: getAmisStaticFieldType$1
10787
10852
  });
10788
10853
 
10789
10854
  const API_CACHE = 100;
@@ -11892,7 +11957,7 @@ function deleteVariable(data, key) {
11892
11957
  * @Author: baozhoutao@steedos.com
11893
11958
  * @Date: 2022-05-26 16:02:08
11894
11959
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
11895
- * @LastEditTime: 2023-10-12 18:25:05
11960
+ * @LastEditTime: 2023-11-28 17:00:28
11896
11961
  * @Description:
11897
11962
  */
11898
11963
 
@@ -11943,6 +12008,8 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
11943
12008
  if (perField.type === 'grid') {
11944
12009
  field = await getGridFieldSubFields(perField, formFields);
11945
12010
  // console.log(`perField.type grid ===> field`, field)
12011
+ } else if (perField.type === 'table') {
12012
+ field = await getTabledFieldSubFields(perField, formFields);
11946
12013
  } else if (perField.type === 'object') {
11947
12014
  field = await getObjectFieldSubFields(perField, formFields);
11948
12015
  // console.log(`perField.type object ===> field`, field)
@@ -11950,6 +12017,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
11950
12017
  if (field.name.indexOf(".") < 0) {
11951
12018
  ctx.__formFields = formFields;
11952
12019
  const amisField = await convertSFieldToAmisField(field, field.readonly, ctx);
12020
+ // 如果steedos-field稳定了,可以放开下面的代码直接用组件统一渲染字段
12021
+ // const amisField = {
12022
+ // "type": "steedos-field",
12023
+ // "config": field,
12024
+ // "readonly": field.readonly,
12025
+ // "ctx": ctx
12026
+ // };
11953
12027
  // console.log(`${field.name} amisField`, field, amisField)
11954
12028
  if (amisField) {
11955
12029
  fieldSetBody.push(amisField);
@@ -12158,6 +12232,7 @@ async function getObjectCRUD(objectSchema, fields, options){
12158
12232
  const bulkActions = getBulkActions(objectSchema);
12159
12233
  const defaults = options.defaults;
12160
12234
  const listSchema = (defaults && defaults.listSchema) || {};
12235
+ const id = `listview_${objectSchema.name}`;
12161
12236
 
12162
12237
  const bodyProps = {
12163
12238
  // toolbar: getToolbar(),
@@ -12167,7 +12242,7 @@ async function getObjectCRUD(objectSchema, fields, options){
12167
12242
  ...options,
12168
12243
  disableStatistics: options.queryCount === false
12169
12244
  }),
12170
- filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
12245
+ filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, Object.assign({}, options, {crudId: id})),
12171
12246
  };
12172
12247
  if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
12173
12248
  if(listSchema.mode !== "cards"){
@@ -12196,7 +12271,8 @@ async function getObjectCRUD(objectSchema, fields, options){
12196
12271
  showDisplayAs,
12197
12272
  hiddenCount: options.queryCount === false,
12198
12273
  headerToolbarItems: options.headerToolbarItems,
12199
- filterVisible: options.filterVisible
12274
+ filterVisible: options.filterVisible,
12275
+ crudId: id
12200
12276
  });
12201
12277
 
12202
12278
  options.amisData = createObject(options.amisData, {
@@ -12209,7 +12285,6 @@ async function getObjectCRUD(objectSchema, fields, options){
12209
12285
 
12210
12286
 
12211
12287
  let body = null;
12212
- const id = `listview_${objectSchema.name}`;
12213
12288
  if(options.formFactor === 'SMALL' && false){
12214
12289
  delete bodyProps.bulkActions;
12215
12290
  delete bodyProps.headerToolbar;
@@ -13203,7 +13278,7 @@ async function getUISchema(objectName, force) {
13203
13278
  return getUISchemaCache(objectName);
13204
13279
  }
13205
13280
 
13206
- function getUISchemaSync(objectName, force) {
13281
+ function getUISchemaSync$1(objectName, force) {
13207
13282
  if (!objectName) {
13208
13283
  return;
13209
13284
  }
@@ -13713,7 +13788,7 @@ async function getObjectRelated(
13713
13788
 
13714
13789
  if(typeof window != 'undefined'){
13715
13790
  window.getUISchema = getUISchema;
13716
- window.getUISchemaSync = getUISchemaSync;
13791
+ window.getUISchemaSync = getUISchemaSync$1;
13717
13792
  window.getListSchema = getListSchema;
13718
13793
  }
13719
13794
 
@@ -15032,6 +15107,8 @@ async function getTableApi(mainObject, fields, options){
15032
15107
  api.data.$self = "$$";
15033
15108
  api.data.self = "$$";
15034
15109
  api.data.filter = "$filter";
15110
+ api.data.__filterFormValues = "${__filterFormValues}";
15111
+ api.data.__serachBoxValues = "${__serachBoxValues}";
15035
15112
  api.data.loaded = "${loaded}";
15036
15113
  api.data.listViewId = "${listViewId}";
15037
15114
  api.data.listName = "${listName}";
@@ -15104,9 +15181,12 @@ async function getTableApi(mainObject, fields, options){
15104
15181
  }else if(selfData.op === 'loadOptions' && selfData.value){
15105
15182
  userFilters = [["${valueField.name}", "=", selfData.value]];
15106
15183
  }
15107
-
15108
- var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
15109
15184
 
15185
+ const __filterFormValues = api.data.__filterFormValues;
15186
+ const __serachBoxValues = api.data.__serachBoxValues;
15187
+ // 筛选按钮
15188
+ const filterSelfData = __filterFormValues ? __filterFormValues : selfData;
15189
+ var searchableFilter = SteedosUI.getSearchFilter(filterSelfData) || [];
15110
15190
  if(searchableFilter.length > 0){
15111
15191
  if(userFilters.length > 0 ){
15112
15192
  userFilters = [userFilters, 'and', searchableFilter];
@@ -15115,6 +15195,7 @@ async function getTableApi(mainObject, fields, options){
15115
15195
  }
15116
15196
  }
15117
15197
 
15198
+ // "搜索此列表"搜索框
15118
15199
  if(allowSearchFields){
15119
15200
  allowSearchFields.forEach(function(key){
15120
15201
  const keyValue = selfData[key];
@@ -15126,7 +15207,8 @@ async function getTableApi(mainObject, fields, options){
15126
15207
  })
15127
15208
  }
15128
15209
 
15129
- var keywordsFilters = SteedosUI.getKeywordsSearchFilter(selfData.__keywords, allowSearchFields);
15210
+ const keyWords = __serachBoxValues ? __serachBoxValues.__keywords : selfData.__keywords;
15211
+ var keywordsFilters = SteedosUI.getKeywordsSearchFilter(keyWords, allowSearchFields);
15130
15212
  if(keywordsFilters && keywordsFilters.length > 0){
15131
15213
  userFilters.push(keywordsFilters);
15132
15214
  }
@@ -15336,7 +15418,7 @@ function getRecordPermissionsApi(object, recordId, options){
15336
15418
  * @Author: 殷亮辉 yinlianghui@hotoa.com
15337
15419
  * @Date: 2023-11-15 09:50:22
15338
15420
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
15339
- * @LastEditTime: 2023-11-17 20:17:56
15421
+ * @LastEditTime: 2023-11-28 11:34:24
15340
15422
  */
15341
15423
 
15342
15424
  /**
@@ -15345,10 +15427,14 @@ function getRecordPermissionsApi(object, recordId, options){
15345
15427
  */
15346
15428
  function getFormFields(props, mode = "edit") {
15347
15429
  return (props.fields || []).map(function (item) {
15348
- return {
15430
+ let formItem = {
15349
15431
  "type": "steedos-field",
15350
15432
  "config": item
15433
+ };
15434
+ if(mode === "readonly"){
15435
+ formItem.static = true;
15351
15436
  }
15437
+ return formItem;
15352
15438
  }) || [];
15353
15439
  }
15354
15440
 
@@ -15357,32 +15443,59 @@ function getFormFields(props, mode = "edit") {
15357
15443
  * @param {*} mode edit/new/readonly
15358
15444
  */
15359
15445
  async function getInputTableColumns(props) {
15360
- // return props.fields.map(function(item){
15361
- // return {
15362
- // "type": "steedos-field",
15363
- // "config": item,
15364
- // "static": true,
15365
- // "readonly": true
15366
- // }
15367
- // }) || [];
15368
-
15369
- let columns = await getTableColumns$1(props.fields || [], {
15370
- isInputTable: true,
15371
- permissions: {
15372
- allowEdit: false //快速编辑开关与权限有关
15373
- }
15374
- });
15375
- // columns = columns.map(function(item){
15376
- // if(["text"].indexOf(item.type) > -1){
15377
- // return Object.assign({}, item, {
15378
- // "type": "static"
15379
- // });
15380
- // }
15381
- // else{
15382
- // return item;
15383
- // }
15384
- // }) || [];
15385
- return columns;
15446
+ let columns = props.columns || [];
15447
+ // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
15448
+ let fields = props.fields;
15449
+ if(columns && columns.length){
15450
+ return columns.map(function(column){
15451
+ let field, extendColumnProps = {};
15452
+ if(typeof column === "string"){
15453
+ // 如果字符串,则取出要显示的列配置
15454
+ field = fields.find(function(fieldItem){
15455
+ return fieldItem.name === column;
15456
+ });
15457
+ }
15458
+ else {
15459
+ // 如果是对象,则合并到steedos-field的config.amis属性中,steedos组件会把config.amis属性混合到最终生成的input-table column
15460
+ field = fields.find(function(fieldItem){
15461
+ return fieldItem.name === column.name;
15462
+ });
15463
+ if(field){
15464
+ // field.amis = Object.assign({}, field.amis, column);
15465
+ // 如果把column合并到field.amis,column的label/width等属性不会生效,只能放外层合并
15466
+ extendColumnProps = column;
15467
+ }
15468
+ }
15469
+ if(field){
15470
+ return {
15471
+ "type": "steedos-field",
15472
+ "config": field,
15473
+ "static": true,
15474
+ "readonly": true,
15475
+ label: field.label,
15476
+ name: field.name,
15477
+ hideLabel: true,
15478
+ ...extendColumnProps
15479
+ }
15480
+ }
15481
+ else {
15482
+ return column;
15483
+ }
15484
+ });
15485
+ }
15486
+ else {
15487
+ return fields.map(function(field){
15488
+ return {
15489
+ "type": "steedos-field",
15490
+ "config": field,
15491
+ "static": true,
15492
+ "readonly": true,
15493
+ label: field.label,
15494
+ name: field.name,
15495
+ hideLabel: true
15496
+ }
15497
+ }) || [];
15498
+ }
15386
15499
  }
15387
15500
 
15388
15501
  /**
@@ -15393,6 +15506,7 @@ function getForm(props, mode = "edit") {
15393
15506
  let schema = {
15394
15507
  "type": "form",
15395
15508
  "title": "表单",
15509
+ "debug": false,
15396
15510
  "body": getFormFields(props, mode)
15397
15511
  };
15398
15512
  if (mode === "edit") {
@@ -15466,10 +15580,11 @@ function getButtonNew(props) {
15466
15580
  "actionType": "dialog",
15467
15581
  "dialog": {
15468
15582
  "type": "dialog",
15469
- "title": "弹框标题",
15583
+ "title": "新增行",
15470
15584
  "body": [
15471
15585
  getForm(props, "new")
15472
15586
  ],
15587
+ "size": "md",
15473
15588
  "showCloseButton": true,
15474
15589
  "showErrorMsg": true,
15475
15590
  "showLoading": true,
@@ -15487,7 +15602,9 @@ function getButtonNew(props) {
15487
15602
  function getButtonEdit(props) {
15488
15603
  return {
15489
15604
  "type": "button",
15490
- "label": "编辑",
15605
+ "label": "",
15606
+ "icon": "fa fa-pencil",
15607
+ "level": "link",
15491
15608
  "onEvent": {
15492
15609
  "click": {
15493
15610
  "actions": [
@@ -15495,10 +15612,42 @@ function getButtonEdit(props) {
15495
15612
  "actionType": "dialog",
15496
15613
  "dialog": {
15497
15614
  "type": "dialog",
15498
- "title": "弹框标题",
15615
+ "title": "编辑行",
15499
15616
  "body": [
15500
15617
  getForm(props, "edit")
15501
15618
  ],
15619
+ "size": "md",
15620
+ "showCloseButton": true,
15621
+ "showErrorMsg": true,
15622
+ "showLoading": true,
15623
+ "className": "app-popover",
15624
+ "closeOnEsc": false
15625
+ }
15626
+ }
15627
+ ]
15628
+ }
15629
+ }
15630
+ };
15631
+ }
15632
+
15633
+ function getButtonView(props) {
15634
+ return {
15635
+ "type": "button",
15636
+ "label": "",
15637
+ "icon": "fa fa-external-link",
15638
+ "level": "link",
15639
+ "onEvent": {
15640
+ "click": {
15641
+ "actions": [
15642
+ {
15643
+ "actionType": "dialog",
15644
+ "dialog": {
15645
+ "type": "dialog",
15646
+ "title": "查看行",
15647
+ "body": [
15648
+ getForm(props, "readonly")
15649
+ ],
15650
+ "size": "md",
15502
15651
  "showCloseButton": true,
15503
15652
  "showErrorMsg": true,
15504
15653
  "showLoading": true,
@@ -15515,7 +15664,9 @@ function getButtonEdit(props) {
15515
15664
  function getButtonDelete(props) {
15516
15665
  return {
15517
15666
  "type": "button",
15518
- "label": "删除",
15667
+ "label": "",
15668
+ "icon": "fa fa-minus",
15669
+ "level": "link",
15519
15670
  "onEvent": {
15520
15671
  "click": {
15521
15672
  "actions": [
@@ -15536,14 +15687,21 @@ const getAmisInputTableSchema = async (props, readonly) => {
15536
15687
  if (!props.id) {
15537
15688
  props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
15538
15689
  }
15539
- let buttonNewSchema = getButtonNew(props);
15540
- let buttonEditSchema = getButtonEdit(props);
15541
- let buttonDeleteSchema = getButtonDelete(props);
15542
15690
  let buttonsForColumnOperations = [];
15543
15691
  if (props.editable) {
15692
+ let buttonEditSchema = getButtonEdit(props);
15544
15693
  buttonsForColumnOperations.push(buttonEditSchema);
15545
15694
  }
15695
+ else {
15696
+ // 只读时显示查看按钮
15697
+ if(props.columns && props.columns.length > 0 && props.columns.length < props.fields.length){
15698
+ // 只在有列被隐藏时才需要显示查看按钮
15699
+ let buttonViewSchema = getButtonView(props);
15700
+ buttonsForColumnOperations.push(buttonViewSchema);
15701
+ }
15702
+ }
15546
15703
  if (props.removable) {
15704
+ let buttonDeleteSchema = getButtonDelete(props);
15547
15705
  buttonsForColumnOperations.push(buttonDeleteSchema);
15548
15706
  }
15549
15707
  let inputTableSchema = {
@@ -15568,7 +15726,8 @@ const getAmisInputTableSchema = async (props, readonly) => {
15568
15726
  inputTableSchema.columns.push({
15569
15727
  "name": "__op__",
15570
15728
  "type": "operation",
15571
- "buttons": buttonsForColumnOperations
15729
+ "buttons": buttonsForColumnOperations,
15730
+ "width": buttonsForColumnOperations.length > 1 ? "46px" : "20px"
15572
15731
  });
15573
15732
  }
15574
15733
  let schema = {
@@ -15579,8 +15738,12 @@ const getAmisInputTableSchema = async (props, readonly) => {
15579
15738
  ]
15580
15739
  };
15581
15740
  if (props.addable) {
15741
+ let buttonNewSchema = getButtonNew(props);
15582
15742
  schema.body.push(buttonNewSchema);
15583
15743
  }
15744
+ if (props.amis) {
15745
+ Object.assign(schema.body[0], props.amis);
15746
+ }
15584
15747
  return schema;
15585
15748
  };
15586
15749
 
@@ -18322,6 +18485,8 @@ var index_esm$1 = /*#__PURE__*/Object.freeze({
18322
18485
  getRecordPermissions: getRecordPermissions,
18323
18486
  getRecordServiceSchema: getRecordServiceSchema,
18324
18487
  getReferenceTo: getReferenceTo,
18488
+ getReferenceToFieldSchema: getReferenceToFieldSchema,
18489
+ getReferenceToSync: getReferenceToSync,
18325
18490
  getRelatedFieldValue: getRelatedFieldValue,
18326
18491
  getRelatedListSchema: getRelatedListSchema,
18327
18492
  getRelatedsCount: getRelatedsCount,
@@ -18333,7 +18498,7 @@ var index_esm$1 = /*#__PURE__*/Object.freeze({
18333
18498
  getTableSchema: getTableSchema$1,
18334
18499
  getTenantId: getTenantId,
18335
18500
  getUISchema: getUISchema,
18336
- getUISchemaSync: getUISchemaSync,
18501
+ getUISchemaSync: getUISchemaSync$1,
18337
18502
  getUserId: getUserId,
18338
18503
  getViewSchema: getViewSchema,
18339
18504
  isExpression: isExpression$1,
@@ -20503,15 +20668,62 @@ var AmisGlobalHeader = function (props) { return __awaiter(void 0, void 0, void
20503
20668
  });
20504
20669
  }); };
20505
20670
 
20671
+ var defaultImageValue = "data:image/svg+xml,%3C%3Fxml version='1.0' standalone='no'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg t='1631083237695' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2420' xmlns:xlink='http://www.w3.org/1999/xlink' width='1024' height='1024'%3E%3Cdefs%3E%3Cstyle type='text/css'%3E%3C/style%3E%3C/defs%3E%3Cpath d='M959.872 128c0.032 0.032 0.096 0.064 0.128 0.128v767.776c-0.032 0.032-0.064 0.096-0.128 0.128H64.096c-0.032-0.032-0.096-0.064-0.128-0.128V128.128c0.032-0.032 0.064-0.096 0.128-0.128h895.776zM960 64H64C28.8 64 0 92.8 0 128v768c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64V128c0-35.2-28.8-64-64-64z' p-id='2421' fill='%23bfbfbf'%3E%3C/path%3E%3Cpath d='M832 288c0 53.024-42.976 96-96 96s-96-42.976-96-96 42.976-96 96-96 96 42.976 96 96zM896 832H128V704l224-384 256 320h64l224-192z' p-id='2422' fill='%23bfbfbf'%3E%3C/path%3E%3C/svg%3E";
20672
+ var AmisFormInputs = [
20673
+ 'text',
20674
+ 'date',
20675
+ // 'file',
20676
+ // "avatar",
20677
+ // 'image',
20678
+ 'datetime',
20679
+ 'time',
20680
+ 'number',
20681
+ 'password',
20682
+ 'url',
20683
+ 'email'
20684
+ ];
20685
+ function getAmisStaticFieldType(type, data_type, options) {
20686
+ if (_$1.includes(AmisFormInputs, type)) {
20687
+ return "input-".concat(type);
20688
+ }
20689
+ else if (type === 'boolean') {
20690
+ return "checkbox";
20691
+ }
20692
+ else if (type === 'toggle') {
20693
+ return "switch";
20694
+ }
20695
+ else if (type === 'currency') {
20696
+ return "number";
20697
+ }
20698
+ else if (type === 'autonumber') {
20699
+ return "text";
20700
+ }
20701
+ else if (type === 'percent') {
20702
+ return "number";
20703
+ }
20704
+ else if (type === 'formula' || type === 'summary') {
20705
+ return getAmisStaticFieldType(data_type, null, options);
20706
+ }
20707
+ else if (type === 'location') {
20708
+ return "location-picker";
20709
+ }
20710
+ else if (type === 'image') {
20711
+ if (options && options.multiple) {
20712
+ return "static-images";
20713
+ }
20714
+ return "static-image";
20715
+ }
20716
+ return type;
20717
+ }
20506
20718
  var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void 0, function () {
20507
- var steedosField, field, _a, readonly, _b, ctx, config, fStatic, objectName, filters, valueFieldKey, labelFieldKey, referenceTo, referenceToField, value, _steedosField, referenceTo, referenceToField, schema, schema, error_1;
20508
- var _c, _d, _e, _f, _g;
20509
- return __generator(this, function (_h) {
20510
- switch (_h.label) {
20719
+ var steedosField, field, _a, readonly, _b, ctx, config, fStatic, hideLabel, schema, schema, fieldAmis, schema, error_1;
20720
+ var _c;
20721
+ return __generator(this, function (_d) {
20722
+ switch (_d.label) {
20511
20723
  case 0:
20512
20724
  steedosField = null;
20513
- field = props.field, _a = props.readonly, readonly = _a === void 0 ? false : _a, _b = props.ctx, ctx = _b === void 0 ? {} : _b, config = props.config, props.$schema, fStatic = props.static;
20514
- // console.log(`AmisSteedosField`, props)
20725
+ field = props.field, _a = props.readonly, readonly = _a === void 0 ? false : _a, _b = props.ctx, ctx = _b === void 0 ? {} : _b, config = props.config, props.$schema, fStatic = props.static, hideLabel = props.hideLabel;
20726
+ console.log("AmisSteedosField", props);
20515
20727
  // if($schema.config && isString($schema.config)){
20516
20728
  // $schema.config = JSON.parse($schema.config)
20517
20729
  // props.config = $schema.config
@@ -20531,66 +20743,182 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
20531
20743
  steedosField = JSON.parse(field);
20532
20744
  }
20533
20745
  }
20534
- _h.label = 1;
20746
+ _d.label = 1;
20535
20747
  case 1:
20536
- _h.trys.push([1, 9, , 10]);
20537
- if (!(fStatic && (steedosField.type === 'lookup' || steedosField.type === 'master_detail'))) return [3 /*break*/, 6];
20538
- objectName = void 0, filters = void 0, valueFieldKey = void 0, labelFieldKey = void 0;
20539
- if (!props.data[steedosField.name]) {
20540
- return [2 /*return*/, {}];
20541
- }
20542
- if (!_$1.isString(steedosField.reference_to)) return [3 /*break*/, 3];
20543
- return [4 /*yield*/, getReferenceTo(steedosField)];
20544
- case 2:
20545
- referenceTo = _h.sent();
20546
- referenceToField = steedosField.reference_to_field || '_id';
20547
- objectName = referenceTo.objectName;
20548
- valueFieldKey = referenceTo && ((_c = referenceTo.valueField) === null || _c === void 0 ? void 0 : _c.name) || '_id';
20549
- labelFieldKey = referenceTo && ((_d = referenceTo.labelField) === null || _d === void 0 ? void 0 : _d.name) || 'name';
20550
- value = props.data[steedosField.name];
20551
- if (_$1.isString(value)) {
20552
- value = [value];
20553
- }
20554
- filters = [referenceToField, "in", value];
20555
- return [3 /*break*/, 5];
20556
- case 3:
20557
- _steedosField = __assign$2(__assign$2({}, steedosField), { reference_to: props.data[steedosField.name].o });
20558
- return [4 /*yield*/, getReferenceTo(_steedosField)];
20559
- case 4:
20560
- referenceTo = _h.sent();
20561
- referenceToField = _steedosField.reference_to_field || '_id';
20562
- objectName = referenceTo.objectName;
20563
- valueFieldKey = referenceTo && ((_e = referenceTo.valueField) === null || _e === void 0 ? void 0 : _e.name) || '_id';
20564
- labelFieldKey = referenceTo && ((_f = referenceTo.labelField) === null || _f === void 0 ? void 0 : _f.name) || 'name';
20565
- filters = [referenceToField, "in", props.data[_steedosField.name].ids];
20566
- _h.label = 5;
20567
- case 5:
20748
+ _d.trys.push([1, 15, , 16]);
20749
+ if (!(fStatic && (steedosField.type === 'lookup' || steedosField.type === 'master_detail'))) return [3 /*break*/, 2];
20568
20750
  schema = Object.assign({}, {
20569
20751
  type: 'select',
20570
20752
  multiple: steedosField.multiple,
20571
20753
  name: steedosField.name,
20572
20754
  label: steedosField.label,
20573
20755
  static: true,
20574
- className: (_g = steedosField.amis) === null || _g === void 0 ? void 0 : _g.className,
20756
+ className: (_c = steedosField.amis) === null || _c === void 0 ? void 0 : _c.className,
20575
20757
  source: {
20576
20758
  "method": "post",
20577
20759
  "url": "${context.rootUrl}/graphql",
20578
- "requestAdaptor": "\n api.data = {\n query: '{options:".concat(objectName, "(filters: ").concat(JSON.stringify(filters), "){label: ").concat(labelFieldKey, ",value: ").concat(valueFieldKey, "}}'\n }\n return api;\n ")
20579
- }
20760
+ "requestAdaptor": "\n var steedosField = ".concat(JSON.stringify(steedosField), ";\n var objectName, filters, valueFieldKey, labelFieldKey;\n if(_.isString(steedosField.reference_to)){\n const referenceTo = getReferenceToSync(steedosField);\n const referenceToField = steedosField.reference_to_field || '_id';\n\n objectName = referenceTo.objectName\n valueFieldKey = referenceTo && referenceTo.valueField?.name || '_id' ;\n labelFieldKey = referenceTo && referenceTo.labelField?.name || 'name';\n let value = api.data[steedosField.name];\n if(_.isString(value)){\n value = [value]\n }\n filters = [referenceToField, \"in\", value || []];\n }else{\n const _steedosField = {\n ...steedosField,\n reference_to: api.data[steedosField.name].o\n }\n const referenceTo = getReferenceToSync(_steedosField);\n const referenceToField = _steedosField.reference_to_field || '_id';\n\n objectName = referenceTo.objectName\n valueFieldKey = referenceTo && referenceTo.valueField?.name || '_id' ;\n labelFieldKey = referenceTo && referenceTo.labelField?.name || 'name';\n let value = api.data[_steedosField.name] && api.data[_steedosField.name].ids;\n filters = [referenceToField, \"in\", value || []];\n }\n api.data = {\n query: '{options:' + objectName + '(filters: ' + JSON.stringify(filters) + '){label: ' + labelFieldKey + ',value: ' + valueFieldKey + '}}'\n }\n return api;\n "),
20761
+ "trackExpression": "${" + steedosField.name + "}",
20762
+ "cache": 3000
20763
+ },
20580
20764
  }, _$1.pick(steedosField.amis || {}, ['className', 'inline', 'label', 'labelAlign', 'name', 'labelRemark', 'description', 'placeholder', 'staticClassName', 'staticLabelClassName', 'staticInputClassName', 'staticSchema']));
20581
- // console.log(`AmisSteedosField return schema`, schema)
20765
+ schema.placeholder = "";
20766
+ if (hideLabel) {
20767
+ delete schema.label;
20768
+ }
20582
20769
  return [2 /*return*/, schema];
20583
- case 6: return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
20770
+ case 2:
20771
+ if (!fStatic) return [3 /*break*/, 12];
20772
+ if (!props.data.hasOwnProperty("_display")) return [3 /*break*/, 4];
20773
+ return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
20774
+ case 3:
20775
+ // 有_display时保持原来的逻辑不变,不走以下新的逻辑,审批王中会特意传入_display以跳过后面新加的代码
20776
+ return [2 /*return*/, _d.sent()];
20777
+ case 4:
20778
+ schema = Object.assign({}, steedosField, {
20779
+ type: getAmisStaticFieldType(steedosField.type, steedosField.data_type, steedosField),
20780
+ static: true,
20781
+ label: steedosField.label
20782
+ });
20783
+ if (!(steedosField.type === "time")) return [3 /*break*/, 5];
20784
+ Object.assign(schema, {
20785
+ inputFormat: 'HH:mm',
20786
+ timeFormat: 'HH:mm',
20787
+ format: '1970-01-01THH:mm:00.000[Z]',
20788
+ });
20789
+ return [3 /*break*/, 11];
20790
+ case 5:
20791
+ if (!(steedosField.type === "percent")) return [3 /*break*/, 6];
20792
+ Object.assign(schema, {
20793
+ "percent": steedosField.scale ? steedosField.scale : true
20794
+ });
20795
+ return [3 /*break*/, 11];
20796
+ case 6:
20797
+ if (!(steedosField.type === "password")) return [3 /*break*/, 7];
20798
+ Object.assign(schema, {
20799
+ "revealPassword": false //没生效,需要用样式隐藏
20800
+ });
20801
+ return [3 /*break*/, 11];
20584
20802
  case 7:
20585
- schema = _h.sent();
20803
+ if (!(steedosField.type === "select")) return [3 /*break*/, 8];
20804
+ Object.assign(schema, {
20805
+ "placeholder": ""
20806
+ });
20807
+ return [3 /*break*/, 11];
20808
+ case 8:
20809
+ if (!(steedosField.type === "image")) return [3 /*break*/, 9];
20810
+ Object.assign(schema, {
20811
+ enlargeAble: true,
20812
+ showToolbar: true,
20813
+ pipeIn: function (value, data) {
20814
+ if (steedosField.multiple) {
20815
+ if (!value) {
20816
+ value = [defaultImageValue];
20817
+ }
20818
+ value = value.map(function (item) {
20819
+ if (item && item.split("/").length === 1) {
20820
+ // 不是url格式时转为url格式显示
20821
+ return window.getImageFieldUrl(window.Meteor.absoluteUrl("/api/files/images/".concat(item)));
20822
+ }
20823
+ else {
20824
+ return item;
20825
+ }
20826
+ });
20827
+ }
20828
+ else {
20829
+ if (_$1.isArray(value)) {
20830
+ value = value[0];
20831
+ }
20832
+ if (value && value.split("/").length === 1) {
20833
+ // 不是url格式时转为url格式显示
20834
+ return window.getImageFieldUrl(window.Meteor.absoluteUrl("/api/files/images/".concat(value)));
20835
+ }
20836
+ }
20837
+ return value;
20838
+ }
20839
+ });
20840
+ return [3 /*break*/, 11];
20841
+ case 9:
20842
+ if (!(steedosField.type === "file")) return [3 /*break*/, 11];
20843
+ return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
20844
+ case 10:
20845
+ // 附件static模式先保持原来的逻辑,依赖_display,审批王中相关功能在creator中
20846
+ // convertSFieldToAmisField中会合并steedosField.amis,所以也不需要再次合并steedosField.amis,直接return就好
20847
+ return [2 /*return*/, _d.sent()];
20848
+ case 11:
20849
+ Object.assign(schema, steedosField.amis || {});
20850
+ if (hideLabel) {
20851
+ delete schema.label;
20852
+ }
20853
+ return [2 /*return*/, schema];
20854
+ case 12:
20855
+ fieldAmis = steedosField.amis || {};
20856
+ if (!props.data.hasOwnProperty("_display")) {
20857
+ // 有_display时保持原来的逻辑不变,不走以下新的逻辑,审批王中会特意传入_display以跳过后面新加的代码
20858
+ // 重写amis中相关属性,但是允许用户通过配置组件的config.amis覆盖下面重写的逻辑
20859
+ if (steedosField.type === "image") {
20860
+ fieldAmis = Object.assign({}, {
20861
+ pipeIn: function (value, data) {
20862
+ if (steedosField.multiple) {
20863
+ value = value && value.map(function (item) {
20864
+ if (item && item.split("/").length === 1) {
20865
+ // 不是url格式时转为url格式显示
20866
+ return window.getImageFieldUrl(window.Meteor.absoluteUrl("/api/files/images/".concat(item)));
20867
+ }
20868
+ else {
20869
+ return item;
20870
+ }
20871
+ });
20872
+ }
20873
+ else {
20874
+ if (_$1.isArray(value)) {
20875
+ value = value[0];
20876
+ }
20877
+ if (value && value.split("/").length === 1) {
20878
+ // 不是url格式时转为url格式显示
20879
+ return window.getImageFieldUrl(window.Meteor.absoluteUrl("/api/files/images/".concat(value)));
20880
+ }
20881
+ }
20882
+ return value;
20883
+ },
20884
+ pipeOut: function (value, data) {
20885
+ if (steedosField.multiple) {
20886
+ value = value && value.map(function (item) {
20887
+ if (item && item.split("/").length > 1) {
20888
+ // 是url格式时转_id值输出用于保存
20889
+ return item.split("/").pop();
20890
+ }
20891
+ else {
20892
+ return item;
20893
+ }
20894
+ });
20895
+ }
20896
+ else {
20897
+ if (_$1.isArray(value)) {
20898
+ value = value[0];
20899
+ }
20900
+ if (value && value.split("/").length > 1) {
20901
+ // 是url格式时转_id值输出用于保存
20902
+ return value.split("/").pop();
20903
+ }
20904
+ }
20905
+ return value;
20906
+ }
20907
+ }, fieldAmis);
20908
+ steedosField.amis = fieldAmis;
20909
+ }
20910
+ }
20911
+ return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
20912
+ case 13:
20913
+ schema = _d.sent();
20586
20914
  // console.log(`AmisSteedosField return schema`, schema)
20587
20915
  return [2 /*return*/, schema];
20588
- case 8: return [3 /*break*/, 10];
20589
- case 9:
20590
- error_1 = _h.sent();
20916
+ case 14: return [3 /*break*/, 16];
20917
+ case 15:
20918
+ error_1 = _d.sent();
20591
20919
  console.log("error", error_1);
20592
- return [3 /*break*/, 10];
20593
- case 10: return [2 /*return*/, null];
20920
+ return [3 /*break*/, 16];
20921
+ case 16: return [2 /*return*/, null];
20594
20922
  }
20595
20923
  });
20596
20924
  }); };
@@ -20833,10 +21161,11 @@ var AmisInputTable = function (props) { return __awaiter(void 0, void 0, void 0,
20833
21161
  return __generator(this, function (_a) {
20834
21162
  switch (_a.label) {
20835
21163
  case 0:
20836
- props.$schema, props.fields, props.name, props.id, props.data;
21164
+ props.$schema, props.fields, props.name, props.id, props.data, props.columns, props.amis;
20837
21165
  return [4 /*yield*/, getAmisInputTableSchema(props)];
20838
21166
  case 1:
20839
21167
  amisSchema = _a.sent();
21168
+ // console.log("=AmisInputTable==amisSchema====", amisSchema);
20840
21169
  return [2 /*return*/, amisSchema];
20841
21170
  }
20842
21171
  });