@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
  }
@@ -4762,11 +4762,11 @@ async function getQuickEditSchema(field, options){
4762
4762
  if(event.data.isBatchEdit){
4763
4763
  selectedItems.forEach(function(selectedItem){
4764
4764
  selectedItem._display.${field.name} = event.data._display.${field.name};
4765
- doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: "_display_" + selectedItem._index});
4765
+ doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: ${options.objectName} + "_display_" + selectedItem._index});
4766
4766
  doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + selectedItem._index});
4767
4767
  })
4768
4768
  }else{
4769
- doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: "_display_" + event.data._index});
4769
+ doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: ${options.objectName} + "_display_" + event.data._index});
4770
4770
  doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + event.data._index});
4771
4771
  }
4772
4772
  `
@@ -11598,7 +11598,7 @@ async function getObjectCRUD(objectSchema, fields, options){
11598
11598
 
11599
11599
  if(body.columns && options.formFactor != 'SMALL'){
11600
11600
  //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
11601
- body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
11601
+ body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: objectSchema.name + "_display_${_index}", className: "hidden"});
11602
11602
  }
11603
11603
 
11604
11604
  if (defaults) {
@@ -13551,6 +13551,8 @@ function getLookupSapceUserTreeSchema(isMobile){
13551
13551
  _.each(children, (item) => {
13552
13552
  if (item.children) {
13553
13553
  item.children = getChildren(records, item.children)
13554
+ }else{
13555
+ item.children = [];
13554
13556
  }
13555
13557
  })
13556
13558
  return children;
@@ -13905,6 +13907,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
13905
13907
  })
13906
13908
  payload.data.rows = rows;
13907
13909
  */
13910
+ if(enable_tree){
13911
+ const rows = _.map(payload.data.rows, (item)=>{
13912
+ delete item.children;
13913
+ delete item.parent;
13914
+ return item;
13915
+ })
13916
+ payload.data.rows = rows;
13917
+ }
13908
13918
  return payload;
13909
13919
  }
13910
13920
  if(!payload.data.rows){
@@ -13936,6 +13946,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
13936
13946
  _.each(children, (item)=>{
13937
13947
  if(item.children){
13938
13948
  item.children = getChildren(records, item.children)
13949
+ }else{
13950
+ item.children = [];
13939
13951
  }
13940
13952
  })
13941
13953
  return children;
@@ -13990,7 +14002,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
13990
14002
  const isAllowCreate = refObjectConfig.permissions.allowCreate;
13991
14003
  const isCreate = _$1.isBoolean(field.create) ? field.create : true;
13992
14004
  // lookup字段配置过滤条件就强制不显示新建按钮
13993
- let isHasFilters = (field.filters || field._filtersFunction) ? true : false;
14005
+ let isHasFilters = (field.filters || field.filtersFunction || field._filtersFunction) ? true : false;
13994
14006
  if (isAllowCreate && isCreate && !isHasFilters) {
13995
14007
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
13996
14008
  new_button.align = "right";
@@ -14408,11 +14420,13 @@ async function lookupToAmis(field, readonly, ctx){
14408
14420
  }
14409
14421
  let refLookupPage = refObject.pages && refObject.pages.lookup;
14410
14422
  if(refLookupPage){
14411
- if(typeof refLookupPage == 'string'){
14412
- refLookupPage = JSON.parse(refLookupPage);
14423
+ if(refLookupPage.is_enable){
14424
+ let pageAmisSchema = refLookupPage.amis_schema;
14425
+ if(typeof pageAmisSchema == 'string'){
14426
+ pageAmisSchema = JSON.parse(pageAmisSchema);
14427
+ }
14428
+ amisSchema = _$1.defaultsDeep({}, pageAmisSchema, amisSchema);
14413
14429
  }
14414
- // Object.assign(amisSchema, refLookupPage);
14415
- // amisSchema = _.defaultsDeep({}, refLookupPage, amisSchema);
14416
14430
  }
14417
14431
  return amisSchema;
14418
14432
  }
@@ -15163,7 +15177,8 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15163
15177
  },
15164
15178
  pipeOut: (value, oldValue, data) => {
15165
15179
  if(value){
15166
- return value/100;
15180
+ const result = value/100;
15181
+ return Number(result.toFixed(field.scale+2));
15167
15182
  }
15168
15183
  return value;
15169
15184
  },
@@ -15397,7 +15412,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15397
15412
  if(field.is_wide || convertData.type === 'group'){
15398
15413
  convertData.className = 'col-span-2 m-0';
15399
15414
  }else {
15400
- convertData.className = 'm-0';
15415
+ convertData.className = 'm-1';
15401
15416
  }
15402
15417
  if(readonly){
15403
15418
  convertData.className = `${convertData.className} border-b`;
@@ -15802,8 +15817,8 @@ async function getFormBody(permissionFields, formFields, ctx){
15802
15817
  /*
15803
15818
  * @Author: 殷亮辉 yinlianghui@hotoa.com
15804
15819
  * @Date: 2023-11-15 09:50:22
15805
- * @LastEditors: baozhoutao@steedos.com
15806
- * @LastEditTime: 2024-01-02 15:43:50
15820
+ * @LastEditors: liaodaxue
15821
+ * @LastEditTime: 2024-01-09 18:12:28
15807
15822
  */
15808
15823
 
15809
15824
  /**
@@ -15843,6 +15858,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
15843
15858
  "config": Object.assign({}, field, {
15844
15859
  label: false
15845
15860
  }),
15861
+ inInputTable: true,
15846
15862
  "static": true,
15847
15863
  "readonly": true,
15848
15864
  label: field.label,
@@ -19734,6 +19750,7 @@ var AmisObjectButton = function (props) {
19734
19750
  delete renderData.event;
19735
19751
  }
19736
19752
  schema.data = defaultsDeep$1({}, renderData, getDefaultRenderData(), schema.data);
19753
+ delete schema.data.event;
19737
19754
  }
19738
19755
  return (React.createElement(React.Fragment, null, button && amisSchema ? (React.createElement(React.Fragment, null, render('body', schema, {
19739
19756
  // 这里的信息会作为 props 传递给子组件,一般情况下都不需要这个,
@@ -19753,7 +19770,7 @@ var getMenu = function (render, buttons, btnClassName, props) {
19753
19770
  if (btnClassName) {
19754
19771
  button.className = "".concat(button.className, " ").concat(btnClassName);
19755
19772
  }
19756
- if (button.visibleOn) {
19773
+ if (button.visibleOnAlias) {
19757
19774
  button.visibleOn = button.visibleOnAlias;
19758
19775
  }
19759
19776
  delete button.className;
@@ -20121,7 +20138,6 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
20121
20138
  },
20122
20139
  {
20123
20140
  "actionType": "reload",
20124
- "componentId": "listview_" + objectApiName,
20125
20141
  "expression": "${(event.data.recordId || event.data.__deletedRecord === true || event.data.displayAs === 'split') && event.data._isRelated != true}" //不是新建, 或分栏模式下新建主对象记录, 则刷新列表
20126
20142
  }
20127
20143
  ]
@@ -21746,14 +21762,14 @@ function getAmisStaticFieldType(type, data_type, options) {
21746
21762
  return type;
21747
21763
  }
21748
21764
  var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void 0, function () {
21749
- 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;
21765
+ 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;
21750
21766
  var e_1, _e;
21751
- var _f, _g, _h, _j;
21752
- return __generator(this, function (_k) {
21753
- switch (_k.label) {
21767
+ var _f, _g, _h, _j, _k;
21768
+ return __generator(this, function (_l) {
21769
+ switch (_l.label) {
21754
21770
  case 0:
21755
21771
  steedosField = null;
21756
- 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;
21772
+ 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;
21757
21773
  // console.log(`AmisSteedosField`, props)
21758
21774
  // if($schema.config && isString($schema.config)){
21759
21775
  // $schema.config = JSON.parse($schema.config)
@@ -21781,10 +21797,10 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21781
21797
  // 字段配置为只读,强制走fStatic模式,加上_display判断是为了不影响历史代码,比如直接在ObjectForm中调用steedos-field组件
21782
21798
  fStatic = true;
21783
21799
  }
21784
- _k.label = 1;
21800
+ _l.label = 1;
21785
21801
  case 1:
21786
- _k.trys.push([1, 19, , 20]);
21787
- if (!(fStatic && (steedosField.type === 'lookup' || steedosField.type === 'master_detail'))) return [3 /*break*/, 3];
21802
+ _l.trys.push([1, 21, , 22]);
21803
+ if (!(fStatic && (steedosField.type === 'lookup' || steedosField.type === 'master_detail'))) return [3 /*break*/, 5];
21788
21804
  defaultSource = {
21789
21805
  "method": "post",
21790
21806
  "url": "${context.rootUrl}/graphql",
@@ -21806,36 +21822,49 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21806
21822
  }
21807
21823
  }
21808
21824
  source = ((_f = steedosField.amis) === null || _f === void 0 ? void 0 : _f.source) || ((_g = steedosField.amis) === null || _g === void 0 ? void 0 : _g.autoComplete) || defaultSource;
21825
+ fieldBaseProps = {
21826
+ multiple: steedosField.multiple,
21827
+ name: steedosField.name,
21828
+ label: steedosField.label,
21829
+ static: true,
21830
+ className: (_h = steedosField.amis) === null || _h === void 0 ? void 0 : _h.className
21831
+ };
21832
+ if (!inInputTable) return [3 /*break*/, 2];
21833
+ fieldBaseProps = Object.assign({}, fieldBaseProps, { type: 'select', source: source });
21834
+ return [3 /*break*/, 4];
21835
+ case 2:
21809
21836
  tpl_1 = '';
21810
21837
  return [4 /*yield*/, env.fetcher(source, props.data)];
21811
- case 2:
21812
- res = _k.sent();
21813
- valueOptions = ((_h = res === null || res === void 0 ? void 0 : res.data) === null || _h === void 0 ? void 0 : _h.options) || [];
21814
- if (valueOptions && valueOptions.length) {
21838
+ case 3:
21839
+ res = _l.sent();
21840
+ valueOptions = ((_j = res === null || res === void 0 ? void 0 : res.data) === null || _j === void 0 ? void 0 : _j.options) || [];
21841
+ fieldValue_1 = (_k = props.data) === null || _k === void 0 ? void 0 : _k[steedosField.name];
21842
+ if (fieldValue_1 && fieldValue_1.length && valueOptions && valueOptions.length) {
21843
+ reference_to_field_1 = steedosField.reference_to_field;
21815
21844
  forEach(valueOptions, function (item, index) {
21816
21845
  var label = item.label, value = item.value;
21817
- var optionTpl = "<a href=\"/app/-/".concat(steedosField.reference_to, "/view/").concat(value, "\" >").concat(label, "</a>");
21818
- tpl_1 += index ? ',' + optionTpl : optionTpl;
21846
+ if (fieldValue_1.indexOf(value) > -1) {
21847
+ // 因为lookup、master_detail字段配置了reference_to_field != _id的情况下,source中返回的值不能当作链接的后缀值,所以移除字段链接。
21848
+ var optionTpl = "<a href=\"/app/-/".concat(steedosField.reference_to, "/view/").concat(value, "\" >").concat(label, "</a>");
21849
+ if (reference_to_field_1 && reference_to_field_1 != '_id') {
21850
+ optionTpl = "".concat(label);
21851
+ }
21852
+ tpl_1 += tpl_1 ? ',' + optionTpl : optionTpl;
21853
+ }
21819
21854
  });
21820
21855
  }
21821
- schema = Object.assign({}, {
21822
- type: 'static',
21823
- tpl: tpl_1,
21824
- multiple: steedosField.multiple,
21825
- name: steedosField.name,
21826
- label: steedosField.label,
21827
- static: true,
21828
- className: (_j = steedosField.amis) === null || _j === void 0 ? void 0 : _j.className,
21829
- // source: source,
21830
- }, pick(steedosField.amis || {}, ['className', 'inline', 'label', 'labelAlign', 'name', 'labelRemark', 'description', 'placeholder', 'staticClassName', 'staticLabelClassName', 'staticInputClassName', 'staticSchema']));
21856
+ fieldBaseProps = Object.assign({}, fieldBaseProps, { type: 'static', tpl: tpl_1 });
21857
+ _l.label = 4;
21858
+ case 4:
21859
+ schema = Object.assign({}, fieldBaseProps, pick(steedosField.amis || {}, ['className', 'inline', 'label', 'labelAlign', 'name', 'labelRemark', 'description', 'placeholder', 'staticClassName', 'staticLabelClassName', 'staticInputClassName', 'staticSchema']));
21831
21860
  schema.placeholder = "";
21832
21861
  return [2 /*return*/, schema];
21833
- case 3:
21834
- if (!fStatic) return [3 /*break*/, 16];
21835
- if (!props.data.hasOwnProperty("_display")) return [3 /*break*/, 5];
21862
+ case 5:
21863
+ if (!fStatic) return [3 /*break*/, 18];
21864
+ if (!props.data.hasOwnProperty("_display")) return [3 /*break*/, 7];
21836
21865
  return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
21837
- case 4:
21838
- fieldSchema = _k.sent();
21866
+ case 6:
21867
+ fieldSchema = _l.sent();
21839
21868
  if (steedosField.type === 'file' && fieldSchema.disabled) {
21840
21869
  fieldValue = fieldSchema.value;
21841
21870
  if (fieldValue && fieldValue.length) {
@@ -21871,52 +21900,52 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21871
21900
  }
21872
21901
  }
21873
21902
  return [2 /*return*/, fieldSchema];
21874
- case 5:
21903
+ case 7:
21875
21904
  schema = Object.assign({}, steedosField, {
21876
21905
  type: getAmisStaticFieldType(steedosField.type, steedosField.data_type, steedosField),
21877
21906
  static: true,
21878
21907
  label: steedosField.label
21879
21908
  });
21880
- if (!(steedosField.type === "time")) return [3 /*break*/, 6];
21909
+ if (!(steedosField.type === "time")) return [3 /*break*/, 8];
21881
21910
  Object.assign(schema, {
21882
21911
  inputFormat: 'HH:mm',
21883
21912
  timeFormat: 'HH:mm',
21884
21913
  format: '1970-01-01THH:mm:00.000[Z]',
21885
21914
  });
21886
- return [3 /*break*/, 15];
21887
- case 6:
21888
- if (!(steedosField.type === "percent")) return [3 /*break*/, 7];
21915
+ return [3 /*break*/, 17];
21916
+ case 8:
21917
+ if (!(steedosField.type === "percent")) return [3 /*break*/, 9];
21889
21918
  Object.assign(schema, {
21890
21919
  "percent": steedosField.scale ? steedosField.scale : true
21891
21920
  });
21892
- return [3 /*break*/, 15];
21893
- case 7:
21894
- if (!(steedosField.type === "password")) return [3 /*break*/, 8];
21921
+ return [3 /*break*/, 17];
21922
+ case 9:
21923
+ if (!(steedosField.type === "password")) return [3 /*break*/, 10];
21895
21924
  Object.assign(schema, {
21896
21925
  "revealPassword": false //没生效,需要用样式隐藏
21897
21926
  });
21898
- return [3 /*break*/, 15];
21899
- case 8:
21900
- if (!(steedosField.type === "select")) return [3 /*break*/, 9];
21927
+ return [3 /*break*/, 17];
21928
+ case 10:
21929
+ if (!(steedosField.type === "select")) return [3 /*break*/, 11];
21901
21930
  Object.assign(schema, {
21902
21931
  "placeholder": ""
21903
21932
  });
21904
- return [3 /*break*/, 15];
21905
- case 9:
21906
- if (!(steedosField.type === "color")) return [3 /*break*/, 10];
21933
+ return [3 /*break*/, 17];
21934
+ case 11:
21935
+ if (!(steedosField.type === "color")) return [3 /*break*/, 12];
21907
21936
  Object.assign(schema, {
21908
21937
  "defaultColor": null
21909
21938
  });
21910
- return [3 /*break*/, 15];
21911
- case 10:
21912
- if (!(steedosField.type === "number")) return [3 /*break*/, 11];
21939
+ return [3 /*break*/, 17];
21940
+ case 12:
21941
+ if (!(steedosField.type === "number")) return [3 /*break*/, 13];
21913
21942
  // amis input-number和number组件中的precision表示小数位数,并不是魔方平台的精度概念,要转换下,否则小数点后会显示很多的0
21914
21943
  Object.assign(schema, {
21915
21944
  "precision": steedosField.scale || 0
21916
21945
  });
21917
- return [3 /*break*/, 15];
21918
- case 11:
21919
- if (!(steedosField.type === "table")) return [3 /*break*/, 12];
21946
+ return [3 /*break*/, 17];
21947
+ case 13:
21948
+ if (!(steedosField.type === "table")) return [3 /*break*/, 14];
21920
21949
  if (steedosField.subFields) {
21921
21950
  tableFields = [];
21922
21951
  try {
@@ -21949,9 +21978,9 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21949
21978
  }
21950
21979
  });
21951
21980
  }
21952
- return [3 /*break*/, 15];
21953
- case 12:
21954
- if (!(steedosField.type === "image")) return [3 /*break*/, 13];
21981
+ return [3 /*break*/, 17];
21982
+ case 14:
21983
+ if (!(steedosField.type === "image")) return [3 /*break*/, 15];
21955
21984
  Object.assign(schema, {
21956
21985
  enlargeAble: true,
21957
21986
  showToolbar: true,
@@ -21982,18 +22011,18 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
21982
22011
  return value;
21983
22012
  }
21984
22013
  });
21985
- return [3 /*break*/, 15];
21986
- case 13:
21987
- if (!(steedosField.type === "file")) return [3 /*break*/, 15];
22014
+ return [3 /*break*/, 17];
22015
+ case 15:
22016
+ if (!(steedosField.type === "file")) return [3 /*break*/, 17];
21988
22017
  return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
21989
- case 14:
22018
+ case 16:
21990
22019
  // 附件static模式先保持原来的逻辑,依赖_display,审批王中相关功能在creator中
21991
22020
  // convertSFieldToAmisField中会合并steedosField.amis,所以也不需要再次合并steedosField.amis,直接return就好
21992
- return [2 /*return*/, _k.sent()];
21993
- case 15:
22021
+ return [2 /*return*/, _l.sent()];
22022
+ case 17:
21994
22023
  Object.assign(schema, steedosField.amis || {});
21995
22024
  return [2 /*return*/, schema];
21996
- case 16:
22025
+ case 18:
21997
22026
  fieldAmis = steedosField.amis || {};
21998
22027
  if (!props.data.hasOwnProperty("_display")) {
21999
22028
  // 有_display时保持原来的逻辑不变,不走以下新的逻辑,审批王中会特意传入_display以跳过后面新加的代码
@@ -22051,16 +22080,16 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
22051
22080
  }
22052
22081
  }
22053
22082
  return [4 /*yield*/, index.convertSFieldToAmisField(steedosField, readonly, ctx)];
22054
- case 17:
22055
- schema = _k.sent();
22083
+ case 19:
22084
+ schema = _l.sent();
22056
22085
  // console.log(`AmisSteedosField return schema`, schema)
22057
22086
  return [2 /*return*/, schema];
22058
- case 18: return [3 /*break*/, 20];
22059
- case 19:
22060
- error_1 = _k.sent();
22087
+ case 20: return [3 /*break*/, 22];
22088
+ case 21:
22089
+ error_1 = _l.sent();
22061
22090
  console.log("error", error_1);
22062
- return [3 /*break*/, 20];
22063
- case 20: return [2 /*return*/, null];
22091
+ return [3 /*break*/, 22];
22092
+ case 22: return [2 /*return*/, null];
22064
22093
  }
22065
22094
  });
22066
22095
  }); };