@steedos-widgets/amis-object 3.6.0-beta.9 → 3.6.1

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.
@@ -479,6 +479,9 @@ fieldset.antd-Collapse > legend{
479
479
  .m-0 {
480
480
  margin: 0px
481
481
  }
482
+ .m-1 {
483
+ margin: 0.25rem
484
+ }
482
485
  .m-2 {
483
486
  margin: 0.5rem
484
487
  }
@@ -4790,11 +4790,11 @@ async function getQuickEditSchema(field, options){
4790
4790
  if(event.data.isBatchEdit){
4791
4791
  selectedItems.forEach(function(selectedItem){
4792
4792
  selectedItem._display.${field.name} = event.data._display.${field.name};
4793
- doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: "_display_" + selectedItem._index});
4793
+ doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: ${options.objectName} + "_display_" + selectedItem._index});
4794
4794
  doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + selectedItem._index});
4795
4795
  })
4796
4796
  }else{
4797
- doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: "_display_" + event.data._index});
4797
+ doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: ${options.objectName} + "_display_" + event.data._index});
4798
4798
  doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + event.data._index});
4799
4799
  }
4800
4800
  `
@@ -11626,7 +11626,7 @@ async function getObjectCRUD(objectSchema, fields, options){
11626
11626
 
11627
11627
  if(body.columns && options.formFactor != 'SMALL'){
11628
11628
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
11629
- body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
11629
+ body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: objectSchema.name + "_display_${_index}", className: "hidden"});
11630
11630
  }
11631
11631
 
11632
11632
  if (defaults) {
@@ -13579,6 +13579,8 @@ function getLookupSapceUserTreeSchema(isMobile){
13579
13579
  _.each(children, (item) => {
13580
13580
  if (item.children) {
13581
13581
  item.children = getChildren(records, item.children)
13582
+ }else{
13583
+ item.children = [];
13582
13584
  }
13583
13585
  })
13584
13586
  return children;
@@ -13933,6 +13935,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
13933
13935
  })
13934
13936
  payload.data.rows = rows;
13935
13937
  */
13938
+ if(enable_tree){
13939
+ const rows = _.map(payload.data.rows, (item)=>{
13940
+ delete item.children;
13941
+ delete item.parent;
13942
+ return item;
13943
+ })
13944
+ payload.data.rows = rows;
13945
+ }
13936
13946
  return payload;
13937
13947
  }
13938
13948
  if(!payload.data.rows){
@@ -13964,6 +13974,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
13964
13974
  _.each(children, (item)=>{
13965
13975
  if(item.children){
13966
13976
  item.children = getChildren(records, item.children)
13977
+ }else{
13978
+ item.children = [];
13967
13979
  }
13968
13980
  })
13969
13981
  return children;
@@ -14018,7 +14030,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
14018
14030
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
14019
14031
  const isCreate = _$1__namespace.isBoolean(field.create) ? field.create : true;
14020
14032
  // lookup字段配置过滤条件就强制不显示新建按钮
14021
- let isHasFilters = (field.filters || field._filtersFunction) ? true : false;
14033
+ let isHasFilters = (field.filters || field.filtersFunction || field._filtersFunction) ? true : false;
14022
14034
  if (isAllowCreate && isCreate && !isHasFilters) {
14023
14035
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
14024
14036
  new_button.align = "right";
@@ -14436,11 +14448,13 @@ async function lookupToAmis(field, readonly, ctx){
14436
14448
  }
14437
14449
  let refLookupPage = refObject.pages && refObject.pages.lookup;
14438
14450
  if(refLookupPage){
14439
- if(typeof refLookupPage == 'string'){
14440
- refLookupPage = JSON.parse(refLookupPage);
14451
+ if(refLookupPage.is_enable){
14452
+ let pageAmisSchema = refLookupPage.amis_schema;
14453
+ if(typeof pageAmisSchema == 'string'){
14454
+ pageAmisSchema = JSON.parse(pageAmisSchema);
14455
+ }
14456
+ amisSchema = _$1__namespace.defaultsDeep({}, pageAmisSchema, amisSchema);
14441
14457
  }
14442
- // Object.assign(amisSchema, refLookupPage);
14443
- // amisSchema = _.defaultsDeep({}, refLookupPage, amisSchema);
14444
14458
  }
14445
14459
  return amisSchema;
14446
14460
  }
@@ -15191,7 +15205,8 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15191
15205
  },
15192
15206
  pipeOut: (value, oldValue, data) => {
15193
15207
  if(value){
15194
- return value/100;
15208
+ const result = value/100;
15209
+ return Number(result.toFixed(field.scale+2));
15195
15210
  }
15196
15211
  return value;
15197
15212
  },
@@ -15425,7 +15440,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15425
15440
  if(field.is_wide || convertData.type === 'group'){
15426
15441
  convertData.className = 'col-span-2 m-0';
15427
15442
  }else {
15428
- convertData.className = 'm-0';
15443
+ convertData.className = 'm-1';
15429
15444
  }
15430
15445
  if(readonly){
15431
15446
  convertData.className = `${convertData.className} border-b`;
@@ -15830,8 +15845,8 @@ async function getFormBody(permissionFields, formFields, ctx){
15830
15845
  /*
15831
15846
  * @Author: 殷亮辉 yinlianghui@hotoa.com
15832
15847
  * @Date: 2023-11-15 09:50:22
15833
- * @LastEditors: baozhoutao@steedos.com
15834
- * @LastEditTime: 2024-01-02 15:43:50
15848
+ * @LastEditors: liaodaxue
15849
+ * @LastEditTime: 2024-01-09 18:12:28
15835
15850
  */
15836
15851
 
15837
15852
  /**
@@ -15871,6 +15886,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
15871
15886
  "config": Object.assign({}, field, {
15872
15887
  label: false
15873
15888
  }),
15889
+ inInputTable: true,
15874
15890
  "static": true,
15875
15891
  "readonly": true,
15876
15892
  label: field.label,
@@ -19762,6 +19778,7 @@ var AmisObjectButton = function (props) {
19762
19778
  delete renderData.event;
19763
19779
  }
19764
19780
  schema.data = _$1.defaultsDeep({}, renderData, getDefaultRenderData(), schema.data);
19781
+ delete schema.data.event;
19765
19782
  }
19766
19783
  return (React__default["default"].createElement(React__default["default"].Fragment, null, button && amisSchema ? (React__default["default"].createElement(React__default["default"].Fragment, null, render('body', schema, {
19767
19784
  // 这里的信息会作为 props 传递给子组件,一般情况下都不需要这个,
@@ -19781,7 +19798,7 @@ var getMenu = function (render, buttons, btnClassName, props) {
19781
19798
  if (btnClassName) {
19782
19799
  button.className = "".concat(button.className, " ").concat(btnClassName);
19783
19800
  }
19784
- if (button.visibleOn) {
19801
+ if (button.visibleOnAlias) {
19785
19802
  button.visibleOn = button.visibleOnAlias;
19786
19803
  }
19787
19804
  delete button.className;
@@ -20149,7 +20166,6 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
20149
20166
  },
20150
20167
  {
20151
20168
  "actionType": "reload",
20152
- "componentId": "listview_" + objectApiName,
20153
20169
  "expression": "${(event.data.recordId || event.data.__deletedRecord === true || event.data.displayAs === 'split') && event.data._isRelated != true}" //不是新建, 或分栏模式下新建主对象记录, 则刷新列表
20154
20170
  }
20155
20171
  ]
@@ -21774,14 +21790,14 @@ function getAmisStaticFieldType(type, data_type, options) {
21774
21790
  return type;
21775
21791
  }
21776
21792
  var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void 0, function () {
21777
- var steedosField, field, _a, readonly, _b, ctx, config, fStatic, env, defaultSource, source, tpl_1, res, valueOptions, schema, fieldSchema, fieldValue, hasImageOrFile_1, fieldHtml_1, schema, tableFields, _c, _d, subField, subFieldName, fieldAmis, schema, error_1;
21793
+ var steedosField, field, _a, readonly, _b, ctx, config, fStatic, env, inInputTable, defaultSource, source, fieldBaseProps, tpl_1, res, valueOptions, fieldValue_1, reference_to_field_1, schema, fieldSchema, fieldValue, hasImageOrFile_1, fieldHtml_1, schema, tableFields, _c, _d, subField, subFieldName, fieldAmis, schema, error_1;
21778
21794
  var e_1, _e;
21779
- var _f, _g, _h, _j;
21780
- return __generator(this, function (_k) {
21781
- switch (_k.label) {
21795
+ var _f, _g, _h, _j, _k;
21796
+ return __generator(this, function (_l) {
21797
+ switch (_l.label) {
21782
21798
  case 0:
21783
21799
  steedosField = null;
21784
- 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, env = props.env;
21800
+ 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, env = props.env, inInputTable = props.inInputTable;
21785
21801
  // console.log(`AmisSteedosField`, props)
21786
21802
  // if($schema.config && isString($schema.config)){
21787
21803
  // $schema.config = JSON.parse($schema.config)
@@ -21809,10 +21825,10 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21809
21825
  // 字段配置为只读,强制走fStatic模式,加上_display判断是为了不影响历史代码,比如直接在ObjectForm中调用steedos-field组件
21810
21826
  fStatic = true;
21811
21827
  }
21812
- _k.label = 1;
21828
+ _l.label = 1;
21813
21829
  case 1:
21814
- _k.trys.push([1, 19, , 20]);
21815
- if (!(fStatic && (steedosField.type === 'lookup' || steedosField.type === 'master_detail'))) return [3 /*break*/, 3];
21830
+ _l.trys.push([1, 21, , 22]);
21831
+ if (!(fStatic && (steedosField.type === 'lookup' || steedosField.type === 'master_detail'))) return [3 /*break*/, 5];
21816
21832
  defaultSource = {
21817
21833
  "method": "post",
21818
21834
  "url": "${context.rootUrl}/graphql",
@@ -21834,36 +21850,49 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21834
21850
  }
21835
21851
  }
21836
21852
  source = ((_f = steedosField.amis) === null || _f === void 0 ? void 0 : _f.source) || ((_g = steedosField.amis) === null || _g === void 0 ? void 0 : _g.autoComplete) || defaultSource;
21853
+ fieldBaseProps = {
21854
+ multiple: steedosField.multiple,
21855
+ name: steedosField.name,
21856
+ label: steedosField.label,
21857
+ static: true,
21858
+ className: (_h = steedosField.amis) === null || _h === void 0 ? void 0 : _h.className
21859
+ };
21860
+ if (!inInputTable) return [3 /*break*/, 2];
21861
+ fieldBaseProps = Object.assign({}, fieldBaseProps, { type: 'select', source: source });
21862
+ return [3 /*break*/, 4];
21863
+ case 2:
21837
21864
  tpl_1 = '';
21838
21865
  return [4 /*yield*/, env.fetcher(source, props.data)];
21839
- case 2:
21840
- res = _k.sent();
21841
- valueOptions = ((_h = res === null || res === void 0 ? void 0 : res.data) === null || _h === void 0 ? void 0 : _h.options) || [];
21842
- if (valueOptions && valueOptions.length) {
21866
+ case 3:
21867
+ res = _l.sent();
21868
+ valueOptions = ((_j = res === null || res === void 0 ? void 0 : res.data) === null || _j === void 0 ? void 0 : _j.options) || [];
21869
+ fieldValue_1 = (_k = props.data) === null || _k === void 0 ? void 0 : _k[steedosField.name];
21870
+ if (fieldValue_1 && fieldValue_1.length && valueOptions && valueOptions.length) {
21871
+ reference_to_field_1 = steedosField.reference_to_field;
21843
21872
  _$1.forEach(valueOptions, function (item, index) {
21844
21873
  var label = item.label, value = item.value;
21845
- var optionTpl = "<a href=\"/app/-/".concat(steedosField.reference_to, "/view/").concat(value, "\" >").concat(label, "</a>");
21846
- tpl_1 += index ? ',' + optionTpl : optionTpl;
21874
+ if (fieldValue_1.indexOf(value) > -1) {
21875
+ // 因为lookup、master_detail字段配置了reference_to_field != _id的情况下,source中返回的值不能当作链接的后缀值,所以移除字段链接。
21876
+ var optionTpl = "<a href=\"/app/-/".concat(steedosField.reference_to, "/view/").concat(value, "\" >").concat(label, "</a>");
21877
+ if (reference_to_field_1 && reference_to_field_1 != '_id') {
21878
+ optionTpl = "".concat(label);
21879
+ }
21880
+ tpl_1 += tpl_1 ? ',' + optionTpl : optionTpl;
21881
+ }
21847
21882
  });
21848
21883
  }
21849
- schema = Object.assign({}, {
21850
- type: 'static',
21851
- tpl: tpl_1,
21852
- multiple: steedosField.multiple,
21853
- name: steedosField.name,
21854
- label: steedosField.label,
21855
- static: true,
21856
- className: (_j = steedosField.amis) === null || _j === void 0 ? void 0 : _j.className,
21857
- // source: source,
21858
- }, _$1.pick(steedosField.amis || {}, ['className', 'inline', 'label', 'labelAlign', 'name', 'labelRemark', 'description', 'placeholder', 'staticClassName', 'staticLabelClassName', 'staticInputClassName', 'staticSchema']));
21884
+ fieldBaseProps = Object.assign({}, fieldBaseProps, { type: 'static', tpl: tpl_1 });
21885
+ _l.label = 4;
21886
+ case 4:
21887
+ schema = Object.assign({}, fieldBaseProps, _$1.pick(steedosField.amis || {}, ['className', 'inline', 'label', 'labelAlign', 'name', 'labelRemark', 'description', 'placeholder', 'staticClassName', 'staticLabelClassName', 'staticInputClassName', 'staticSchema']));
21859
21888
  schema.placeholder = "";
21860
21889
  return [2 /*return*/, schema];
21861
- case 3:
21862
- if (!fStatic) return [3 /*break*/, 16];
21863
- if (!props.data.hasOwnProperty("_display")) return [3 /*break*/, 5];
21890
+ case 5:
21891
+ if (!fStatic) return [3 /*break*/, 18];
21892
+ if (!props.data.hasOwnProperty("_display")) return [3 /*break*/, 7];
21864
21893
  return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
21865
- case 4:
21866
- fieldSchema = _k.sent();
21894
+ case 6:
21895
+ fieldSchema = _l.sent();
21867
21896
  if (steedosField.type === 'file' && fieldSchema.disabled) {
21868
21897
  fieldValue = fieldSchema.value;
21869
21898
  if (fieldValue && fieldValue.length) {
@@ -21899,52 +21928,52 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21899
21928
  }
21900
21929
  }
21901
21930
  return [2 /*return*/, fieldSchema];
21902
- case 5:
21931
+ case 7:
21903
21932
  schema = Object.assign({}, steedosField, {
21904
21933
  type: getAmisStaticFieldType(steedosField.type, steedosField.data_type, steedosField),
21905
21934
  static: true,
21906
21935
  label: steedosField.label
21907
21936
  });
21908
- if (!(steedosField.type === "time")) return [3 /*break*/, 6];
21937
+ if (!(steedosField.type === "time")) return [3 /*break*/, 8];
21909
21938
  Object.assign(schema, {
21910
21939
  inputFormat: 'HH:mm',
21911
21940
  timeFormat: 'HH:mm',
21912
21941
  format: '1970-01-01THH:mm:00.000[Z]',
21913
21942
  });
21914
- return [3 /*break*/, 15];
21915
- case 6:
21916
- if (!(steedosField.type === "percent")) return [3 /*break*/, 7];
21943
+ return [3 /*break*/, 17];
21944
+ case 8:
21945
+ if (!(steedosField.type === "percent")) return [3 /*break*/, 9];
21917
21946
  Object.assign(schema, {
21918
21947
  "percent": steedosField.scale ? steedosField.scale : true
21919
21948
  });
21920
- return [3 /*break*/, 15];
21921
- case 7:
21922
- if (!(steedosField.type === "password")) return [3 /*break*/, 8];
21949
+ return [3 /*break*/, 17];
21950
+ case 9:
21951
+ if (!(steedosField.type === "password")) return [3 /*break*/, 10];
21923
21952
  Object.assign(schema, {
21924
21953
  "revealPassword": false //没生效,需要用样式隐藏
21925
21954
  });
21926
- return [3 /*break*/, 15];
21927
- case 8:
21928
- if (!(steedosField.type === "select")) return [3 /*break*/, 9];
21955
+ return [3 /*break*/, 17];
21956
+ case 10:
21957
+ if (!(steedosField.type === "select")) return [3 /*break*/, 11];
21929
21958
  Object.assign(schema, {
21930
21959
  "placeholder": ""
21931
21960
  });
21932
- return [3 /*break*/, 15];
21933
- case 9:
21934
- if (!(steedosField.type === "color")) return [3 /*break*/, 10];
21961
+ return [3 /*break*/, 17];
21962
+ case 11:
21963
+ if (!(steedosField.type === "color")) return [3 /*break*/, 12];
21935
21964
  Object.assign(schema, {
21936
21965
  "defaultColor": null
21937
21966
  });
21938
- return [3 /*break*/, 15];
21939
- case 10:
21940
- if (!(steedosField.type === "number")) return [3 /*break*/, 11];
21967
+ return [3 /*break*/, 17];
21968
+ case 12:
21969
+ if (!(steedosField.type === "number")) return [3 /*break*/, 13];
21941
21970
  // amis input-number和number组件中的precision表示小数位数,并不是魔方平台的精度概念,要转换下,否则小数点后会显示很多的0
21942
21971
  Object.assign(schema, {
21943
21972
  "precision": steedosField.scale || 0
21944
21973
  });
21945
- return [3 /*break*/, 15];
21946
- case 11:
21947
- if (!(steedosField.type === "table")) return [3 /*break*/, 12];
21974
+ return [3 /*break*/, 17];
21975
+ case 13:
21976
+ if (!(steedosField.type === "table")) return [3 /*break*/, 14];
21948
21977
  if (steedosField.subFields) {
21949
21978
  tableFields = [];
21950
21979
  try {
@@ -21977,9 +22006,9 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21977
22006
  }
21978
22007
  });
21979
22008
  }
21980
- return [3 /*break*/, 15];
21981
- case 12:
21982
- if (!(steedosField.type === "image")) return [3 /*break*/, 13];
22009
+ return [3 /*break*/, 17];
22010
+ case 14:
22011
+ if (!(steedosField.type === "image")) return [3 /*break*/, 15];
21983
22012
  Object.assign(schema, {
21984
22013
  enlargeAble: true,
21985
22014
  showToolbar: true,
@@ -22010,18 +22039,18 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
22010
22039
  return value;
22011
22040
  }
22012
22041
  });
22013
- return [3 /*break*/, 15];
22014
- case 13:
22015
- if (!(steedosField.type === "file")) return [3 /*break*/, 15];
22042
+ return [3 /*break*/, 17];
22043
+ case 15:
22044
+ if (!(steedosField.type === "file")) return [3 /*break*/, 17];
22016
22045
  return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
22017
- case 14:
22046
+ case 16:
22018
22047
  // 附件static模式先保持原来的逻辑,依赖_display,审批王中相关功能在creator中
22019
22048
  // convertSFieldToAmisField中会合并steedosField.amis,所以也不需要再次合并steedosField.amis,直接return就好
22020
- return [2 /*return*/, _k.sent()];
22021
- case 15:
22049
+ return [2 /*return*/, _l.sent()];
22050
+ case 17:
22022
22051
  Object.assign(schema, steedosField.amis || {});
22023
22052
  return [2 /*return*/, schema];
22024
- case 16:
22053
+ case 18:
22025
22054
  fieldAmis = steedosField.amis || {};
22026
22055
  if (!props.data.hasOwnProperty("_display")) {
22027
22056
  // 有_display时保持原来的逻辑不变,不走以下新的逻辑,审批王中会特意传入_display以跳过后面新加的代码
@@ -22079,16 +22108,16 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
22079
22108
  }
22080
22109
  }
22081
22110
  return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
22082
- case 17:
22083
- schema = _k.sent();
22111
+ case 19:
22112
+ schema = _l.sent();
22084
22113
  // console.log(`AmisSteedosField return schema`, schema)
22085
22114
  return [2 /*return*/, schema];
22086
- case 18: return [3 /*break*/, 20];
22087
- case 19:
22088
- error_1 = _k.sent();
22115
+ case 20: return [3 /*break*/, 22];
22116
+ case 21:
22117
+ error_1 = _l.sent();
22089
22118
  console.log("error", error_1);
22090
- return [3 /*break*/, 20];
22091
- case 20: return [2 /*return*/, null];
22119
+ return [3 /*break*/, 22];
22120
+ case 22: return [2 /*return*/, null];
22092
22121
  }
22093
22122
  });
22094
22123
  }); };