@steedos-widgets/amis-lib 6.10.11 → 6.10.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -15566,6 +15566,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15566
15566
  labelField: 'label',
15567
15567
  valueField: 'value'
15568
15568
  };
15569
+ if(field.isAmis){
15570
+ delete field.mode;
15571
+ convertData = {
15572
+ ...convertData,
15573
+ ...field
15574
+ };
15575
+ }
15569
15576
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
15570
15577
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
15571
15578
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
@@ -16803,7 +16810,7 @@ function getFormFields(props, mode = "edit") {
16803
16810
  fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
16804
16811
  }
16805
16812
  return (fields || []).map(function (item) {
16806
- let formItem = {
16813
+ let formItem = item.isAmis ? item : {
16807
16814
  "type": "steedos-field",
16808
16815
  "name": item.name,
16809
16816
  "config": item
@@ -16818,6 +16825,9 @@ function getFormFields(props, mode = "edit") {
16818
16825
  function getInputTableCell(field, showAsInlineEditMode) {
16819
16826
  if (showAsInlineEditMode) {
16820
16827
  // 这里不可以用quickEdit,因为amis存在bug:input-table内的字段在行编辑模式时会受到外层相同name的字段的影响 https://github.com/baidu/amis/issues/9653
16828
+ if(field.isAmis){
16829
+ return field;
16830
+ }
16821
16831
  return {
16822
16832
  "type": "steedos-field",
16823
16833
  "config": Object.assign({}, field, {
@@ -16836,6 +16846,16 @@ function getInputTableCell(field, showAsInlineEditMode) {
16836
16846
  }
16837
16847
  }
16838
16848
  else {
16849
+ if(field.isAmis){
16850
+ return {
16851
+ ...field,
16852
+ inInputTable: true,
16853
+ "static": true,
16854
+ "readonly": true,
16855
+ label: field.label,
16856
+ name: field.name
16857
+ };
16858
+ }
16839
16859
  return {
16840
16860
  "type": "steedos-field",
16841
16861
  "config": Object.assign({}, field, {
@@ -17238,6 +17258,7 @@ function getFormPaginationWrapper(props, form, mode) {
17238
17258
  "method": "get",
17239
17259
  "adaptor": `
17240
17260
  const formBody = ${JSON.stringify(formBody)};
17261
+ console.log('formBody===>', formBody);
17241
17262
  return {
17242
17263
  "body": formBody
17243
17264
  }
@@ -19617,21 +19638,21 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19617
19638
  placeholder: amisLib.i18next.t('frontend_workflow_suggestion_placeholder'),//"请填写意见",
19618
19639
  requiredOn: "${judge === 'rejected'}",
19619
19640
  value: userApprove?.description,
19620
- "onEvent": {
19621
- "change": {
19622
- "actions": [
19623
- {
19624
- "componentId": "u:instancePage",
19625
- "actionType": "setValue",
19626
- "args": {
19627
- "value": {
19628
- "instance_my_approve_description": "${value}"
19629
- }
19630
- }
19631
- }
19632
- ]
19633
- }
19634
- }
19641
+ // "onEvent": {
19642
+ // "blur": {
19643
+ // "actions": [
19644
+ // {
19645
+ // "componentId": "u:instancePage",
19646
+ // "actionType": "setValue",
19647
+ // "args": {
19648
+ // "value": {
19649
+ // "instance_my_approve_description": "${value}"
19650
+ // }
19651
+ // }
19652
+ // }
19653
+ // ]
19654
+ // }
19655
+ // }
19635
19656
  },
19636
19657
  await getNextStepInput(instance),
19637
19658
  await getNextStepUsersInput(instance),
@@ -19954,7 +19975,7 @@ const getInstanceApprovalHistory = async ()=>{
19954
19975
  * @Author: baozhoutao@steedos.com
19955
19976
  * @Date: 2022-09-07 16:20:45
19956
19977
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19957
- * @LastEditTime: 2025-11-19 17:21:28
19978
+ * @LastEditTime: 2025-11-20 20:13:03
19958
19979
  * @Description:
19959
19980
  */
19960
19981
 
@@ -19977,7 +19998,24 @@ const isOpinionField = (field)=>{
19977
19998
  return (field_formula?.indexOf("{traces.") > -1 || field_formula?.indexOf("{signature.traces.") > -1 || field_formula?.indexOf("{yijianlan:") > -1 || field_formula?.indexOf("{\"yijianlan\":") > -1 || field_formula?.indexOf("{'yijianlan':") > -1)
19978
19999
  };
19979
20000
 
20001
+ const getArgumentsList = (func)=>{
20002
+ let funcString;
20003
+ if (typeof func === 'function') {
20004
+ funcString = func.toString();
20005
+ } else {
20006
+ funcString = func;
20007
+ }
20008
+ const regExp = /function\s*\w*\(([\s\S]*?)\)/;
20009
+ if (regExp.test(funcString)) {
20010
+ const argList = RegExp.$1.split(',');
20011
+ return argList.map(arg => arg.replace(/\s/g, ''));
20012
+ } else {
20013
+ return [];
20014
+ }
20015
+ };
20016
+
19980
20017
  const getFieldEditTpl = async (field, label)=>{
20018
+ console.log('field',field);
19981
20019
  const tpl = {
19982
20020
  label: label === true ? field.name : false,
19983
20021
  name: field.code,
@@ -20185,6 +20223,7 @@ const getFieldEditTpl = async (field, label)=>{
20185
20223
  break;
20186
20224
  case "number":
20187
20225
  tpl.type = "input-number";
20226
+ tpl.precision=2;
20188
20227
  break;
20189
20228
  case "date":
20190
20229
  tpl.type = "input-date";
@@ -20255,6 +20294,7 @@ const getFieldEditTpl = async (field, label)=>{
20255
20294
  tpl.options = getSelectOptions(field);
20256
20295
  break;
20257
20296
  case "odata":
20297
+ const argsName = getArgumentsList(field.filters);
20258
20298
  var labelField = field.formula.substr(1, field.formula.length - 2);
20259
20299
  labelField = labelField.substr(labelField.indexOf(".") + 1);
20260
20300
  tpl.type = "select";
@@ -20262,14 +20302,9 @@ const getFieldEditTpl = async (field, label)=>{
20262
20302
  // tpl.labelField = labelField;
20263
20303
  // tpl.valueField = "_value";
20264
20304
  tpl.source = {
20265
- url: _$1.startsWith(field.url, "http")
20266
- ? field.url
20267
- : `\${context.rootUrl}${field.url}`,
20305
+ url: field.url,
20268
20306
  method: "get",
20269
20307
  dataType: "json",
20270
- headers: {
20271
- Authorization: "Bearer ${context.tenantId},${context.authToken}",
20272
- },
20273
20308
  adaptor:`
20274
20309
  payload.data = {
20275
20310
  options: _.map(payload.value, (item)=>{
@@ -20285,8 +20320,34 @@ const getFieldEditTpl = async (field, label)=>{
20285
20320
  })
20286
20321
  }
20287
20322
  return payload;
20288
- `
20323
+ `,
20324
+ requestAdaptor: `
20325
+ const filters = ${_.replace(field.filters, /_.pluck/g, '_.map')};
20326
+ const url = ${field.url}
20327
+ if(filters){
20328
+ console.log('filters', filters);
20329
+ const joinKey = field.url.indexOf('?') > 0 ? '&' : '?';
20330
+ if(filters.startsWith('function(') || filters.startsWith('function (')){
20331
+ const argsName = ${JSON.stringify(argsName)};
20332
+ const fun = eval('_fun='+filters);
20333
+ const funArgs = [];
20334
+ for(const item of argsName){
20335
+ funArgs.push(context[item])
20336
+ }
20337
+ api.url = url + joinKey + "$filter=" + fun.apply({}, funArgs)
20338
+ }else{
20339
+ api.url = url + joinKey + "$filter=" + filters
20340
+ }
20341
+ }else{
20342
+ api.url = url
20343
+ }
20344
+ api.query = {};
20345
+ return api;
20346
+ `,
20347
+ trackExpression: _.join(_.map(argsName, (item)=>{return `\${${item}|json}`}), '-')
20289
20348
  };
20349
+ tpl.isAmis=true;
20350
+ console.log(`odata`, tpl);
20290
20351
  break;
20291
20352
  case "html":
20292
20353
  if (tpl.disabled) {
@@ -20363,7 +20424,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
20363
20424
  map[item.value] = item.label;
20364
20425
  });
20365
20426
  tpl.type = 'static';
20366
- tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data.${field.code}]) || ''%>`;
20427
+ tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data["${field.code}"]]) || ''%>`;
20367
20428
  }else if(field.type === 'odata'){
20368
20429
  tpl.type = 'static';
20369
20430
  tpl.tpl = `<div>\${${field.code}['@label']}</div>`;
@@ -20560,7 +20621,7 @@ const getFormTableView = async (instance) => {
20560
20621
  };
20561
20622
 
20562
20623
  const getFormSteps = async (instance) => {
20563
- const formMode = instance.form.current.mode || "normal";//normal,horizontal,inline
20624
+ const formMode = instance.formVersion.mode || "normal";//normal,horizontal,inline
20564
20625
  const stepsSchema = [];
20565
20626
  let stepFields = [];
20566
20627
  let fields = [];
@@ -20627,7 +20688,7 @@ const getFormSteps = async (instance) => {
20627
20688
  };
20628
20689
 
20629
20690
  const getFormWizardView = async (instance) => {
20630
- const wizardMode = instance.form.current.wizard_mode || "vertical";//vertical,horizontal
20691
+ const wizardMode = instance.formVersion.wizard_mode || "vertical";//vertical,horizontal
20631
20692
  const formSchema = {
20632
20693
  type: "wizard",
20633
20694
  className: `instance-form-view-wizard ${wizardMode === "horizontal" ? "pt-4" : "pt-1"} mt-3`,
@@ -20838,7 +20899,7 @@ const getScrollToBottomAutoOpenApproveDrawerScript = () => {
20838
20899
  };
20839
20900
 
20840
20901
  const getFlowFormSchema = async (instance, box) => {
20841
- const formStyle = instance.form.current.style || "table";
20902
+ const formStyle = instance.formVersion.style || "table";
20842
20903
  let formContentSchema;
20843
20904
  if (formStyle === "wizard") {
20844
20905
  formContentSchema = await getFormWizardView(instance);
@@ -20846,7 +20907,6 @@ const getFlowFormSchema = async (instance, box) => {
20846
20907
  else {
20847
20908
  formContentSchema = await getFormTableView(instance);
20848
20909
  }
20849
-
20850
20910
  const amisSchemaStr = instance.formVersion?.amis_schema;
20851
20911
 
20852
20912
  let initedEvents = [];
@@ -20861,7 +20921,7 @@ const getFlowFormSchema = async (instance, box) => {
20861
20921
  }
20862
20922
  // if (box == 'inbox' || box == 'draft') {
20863
20923
  // TODO: 临时去掉 AutoOpenApproveDrawer 功能因为测试到性能问题
20864
- if ((box == 'inbox' || box == 'draft') && window.disableAutoOpenApproveDrawer !== true) {
20924
+ if ((box == 'inbox' || box == 'draft') && window.enableAutoOpenApproveDrawer) {
20865
20925
  // 滚动条滚动到底部弹出底部签批drawer窗口
20866
20926
  initedEvents.push({
20867
20927
  "actionType": "custom",
@@ -20870,7 +20930,6 @@ const getFlowFormSchema = async (instance, box) => {
20870
20930
  });
20871
20931
  }
20872
20932
 
20873
- console.log('getFlowFormSchema formContentSchema', formContentSchema);
20874
20933
  return {
20875
20934
  type: "page",
20876
20935
  name: "instancePage",
@@ -21012,7 +21071,7 @@ const getFlowFormSchema = async (instance, box) => {
21012
21071
  "args": {
21013
21072
  "value": "${event.data.context.approveValues}"
21014
21073
  },
21015
- "expression": "${event.data.context.form.current.style === 'wizard'}"// 表单为 wizard 样式时需要初始同步表单数据,否则直接点击暂存按钮会清空数据
21074
+ "expression": "${event.data.context.flowVersion.style === 'wizard'}"// 表单为 wizard 样式时需要初始同步表单数据,否则直接点击暂存按钮会清空数据
21016
21075
  },
21017
21076
  ...initedEvents
21018
21077
  ]
@@ -21104,24 +21163,18 @@ const getApproveValues = ({ instance, trace, step, approve, box }) => {
21104
21163
  return instanceValues;
21105
21164
  };
21106
21165
 
21107
- const getFlowVersion = (instance) => {
21108
- if (instance.flow.current._id === instance.flow_version) {
21109
- return instance.flow.current;
21110
- } else {
21111
- return _$1.find(instance.flow.historys, (history) => {
21112
- return history._id === instance.flow_version;
21113
- });
21114
- }
21166
+ const getFlowVersion = async (instance) => {
21167
+ const result = await amisLib.fetchAPI(`/api/workflow/flow/${instance.flow._id}/version/${instance.flow_version}`, {
21168
+ method: "get"
21169
+ });
21170
+ return result;
21115
21171
  };
21116
21172
 
21117
- const getFormVersion = (instance) => {
21118
- if (instance.form.current._id === instance.form_version) {
21119
- return instance.form.current;
21120
- } else {
21121
- return _$1.find(instance.form.historys, (history) => {
21122
- return history._id === instance.form_version;
21123
- });
21124
- }
21173
+ const getFormVersion = async (instance) => {
21174
+ const result = await amisLib.fetchAPI(`/api/workflow/form/${instance.form._id}/version/${instance.form_version}`, {
21175
+ method: "get"
21176
+ });
21177
+ return result;
21125
21178
  };
21126
21179
 
21127
21180
  const getStep = ({ flowVersion, stepId }) => {
@@ -21214,17 +21267,13 @@ const getInstanceInfo = async (props) => {
21214
21267
  name,
21215
21268
  style,
21216
21269
  mode,
21217
- wizard_mode,
21218
- current,
21219
- historys
21270
+ wizard_mode
21220
21271
  },
21221
21272
  flow_version,
21222
21273
  flow:flow__expand{
21223
21274
  _id,
21224
21275
  name,
21225
- perms,
21226
- current,
21227
- historys
21276
+ perms
21228
21277
  }
21229
21278
  }
21230
21279
  }
@@ -21248,8 +21297,11 @@ const getInstanceInfo = async (props) => {
21248
21297
  if (box === "inbox" || box === "draft") {
21249
21298
  userApprove = getUserApprove({ instance, userId });
21250
21299
  }
21251
- const flowVersion = getFlowVersion(instance);
21252
- const formVersion = getFormVersion(instance);
21300
+ const flowVersion = await getFlowVersion(instance);
21301
+ const formVersion = await getFormVersion(instance);
21302
+
21303
+ instance.flowVersion = flowVersion;
21304
+ instance.formVersion = formVersion;
21253
21305
 
21254
21306
  if (userApprove) {
21255
21307
  trace = getTrace({ instance, traceId: userApprove.trace });