@steedos-widgets/amis-lib 6.10.11 → 6.10.12

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
@@ -18978,6 +18978,7 @@ const showApproveSignImage = (judge) => {
18978
18978
  };
18979
18979
 
18980
18980
  const getUserApprove = ({ instance, userId }) => {
18981
+ console.log(`getUserApprove===>`, instance, userId);
18981
18982
  const currentTrace = _$1.find(instance.traces, (trace) => {
18982
18983
  return trace.is_finished != true;
18983
18984
  });
@@ -19617,21 +19618,21 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19617
19618
  placeholder: amisLib.i18next.t('frontend_workflow_suggestion_placeholder'),//"请填写意见",
19618
19619
  requiredOn: "${judge === 'rejected'}",
19619
19620
  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
- }
19621
+ // "onEvent": {
19622
+ // "blur": {
19623
+ // "actions": [
19624
+ // {
19625
+ // "componentId": "u:instancePage",
19626
+ // "actionType": "setValue",
19627
+ // "args": {
19628
+ // "value": {
19629
+ // "instance_my_approve_description": "${value}"
19630
+ // }
19631
+ // }
19632
+ // }
19633
+ // ]
19634
+ // }
19635
+ // }
19635
19636
  },
19636
19637
  await getNextStepInput(instance),
19637
19638
  await getNextStepUsersInput(instance),
@@ -19954,7 +19955,7 @@ const getInstanceApprovalHistory = async ()=>{
19954
19955
  * @Author: baozhoutao@steedos.com
19955
19956
  * @Date: 2022-09-07 16:20:45
19956
19957
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19957
- * @LastEditTime: 2025-11-19 17:21:28
19958
+ * @LastEditTime: 2025-11-20 20:13:03
19958
19959
  * @Description:
19959
19960
  */
19960
19961
 
@@ -19977,6 +19978,22 @@ const isOpinionField = (field)=>{
19977
19978
  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
19979
  };
19979
19980
 
19981
+ const getArgumentsList = (func)=>{
19982
+ let funcString;
19983
+ if (typeof func === 'function') {
19984
+ funcString = func.toString();
19985
+ } else {
19986
+ funcString = func;
19987
+ }
19988
+ const regExp = /function\s*\w*\(([\s\S]*?)\)/;
19989
+ if (regExp.test(funcString)) {
19990
+ const argList = RegExp.$1.split(',');
19991
+ return argList.map(arg => arg.replace(/\s/g, ''));
19992
+ } else {
19993
+ return [];
19994
+ }
19995
+ };
19996
+
19980
19997
  const getFieldEditTpl = async (field, label)=>{
19981
19998
  const tpl = {
19982
19999
  label: label === true ? field.name : false,
@@ -20255,6 +20272,8 @@ const getFieldEditTpl = async (field, label)=>{
20255
20272
  tpl.options = getSelectOptions(field);
20256
20273
  break;
20257
20274
  case "odata":
20275
+ console.log('odata field', field);
20276
+ const argsName = getArgumentsList(field.filters);
20258
20277
  var labelField = field.formula.substr(1, field.formula.length - 2);
20259
20278
  labelField = labelField.substr(labelField.indexOf(".") + 1);
20260
20279
  tpl.type = "select";
@@ -20267,9 +20286,6 @@ const getFieldEditTpl = async (field, label)=>{
20267
20286
  : `\${context.rootUrl}${field.url}`,
20268
20287
  method: "get",
20269
20288
  dataType: "json",
20270
- headers: {
20271
- Authorization: "Bearer ${context.tenantId},${context.authToken}",
20272
- },
20273
20289
  adaptor:`
20274
20290
  payload.data = {
20275
20291
  options: _.map(payload.value, (item)=>{
@@ -20285,8 +20301,30 @@ const getFieldEditTpl = async (field, label)=>{
20285
20301
  })
20286
20302
  }
20287
20303
  return payload;
20304
+ `,
20305
+ requestAdaptor: `
20306
+ const field = ${JSON.stringify(field)};
20307
+ if(field.filters){
20308
+ const joinKey = field.url.indexOf('?') > 0 ? '&' : '?';
20309
+ if(field.filters.startsWith('function(') || field.filters.startsWith('function (')){
20310
+ const argsName = ${JSON.stringify(argsName)};
20311
+ const fun = eval('_fun='+field.filters);
20312
+ const funArgs = [];
20313
+ for(const item of argsName){
20314
+ funArgs.push(context[item])
20315
+ }
20316
+ api.url = field.url + joinKey + "$filter=" + fun.apply({}, funArgs)
20317
+ }else{
20318
+ api.url = field.url + joinKey + "$filter=" + field.filters
20319
+ }
20320
+ }
20321
+ api.query = {};
20322
+ console.log('api', api);
20323
+ return api;
20288
20324
  `
20289
20325
  };
20326
+ // delete tpl.source;
20327
+ console.log('odata tpl', tpl);
20290
20328
  break;
20291
20329
  case "html":
20292
20330
  if (tpl.disabled) {
@@ -20514,6 +20552,7 @@ const getFormTrs = async (instance) => {
20514
20552
  const trs = [];
20515
20553
  let tdFields = [];
20516
20554
  let fields = [];
20555
+ console.log('getFormTrs===>', instance.fields);
20517
20556
  _$1.each(instance.fields, (field) => {
20518
20557
  fields.push(field);
20519
20558
  if (field.type === "section" && field.fields) {
@@ -20560,7 +20599,7 @@ const getFormTableView = async (instance) => {
20560
20599
  };
20561
20600
 
20562
20601
  const getFormSteps = async (instance) => {
20563
- const formMode = instance.form.current.mode || "normal";//normal,horizontal,inline
20602
+ const formMode = instance.formVersion.mode || "normal";//normal,horizontal,inline
20564
20603
  const stepsSchema = [];
20565
20604
  let stepFields = [];
20566
20605
  let fields = [];
@@ -20627,7 +20666,7 @@ const getFormSteps = async (instance) => {
20627
20666
  };
20628
20667
 
20629
20668
  const getFormWizardView = async (instance) => {
20630
- const wizardMode = instance.form.current.wizard_mode || "vertical";//vertical,horizontal
20669
+ const wizardMode = instance.formVersion.wizard_mode || "vertical";//vertical,horizontal
20631
20670
  const formSchema = {
20632
20671
  type: "wizard",
20633
20672
  className: `instance-form-view-wizard ${wizardMode === "horizontal" ? "pt-4" : "pt-1"} mt-3`,
@@ -20838,7 +20877,7 @@ const getScrollToBottomAutoOpenApproveDrawerScript = () => {
20838
20877
  };
20839
20878
 
20840
20879
  const getFlowFormSchema = async (instance, box) => {
20841
- const formStyle = instance.form.current.style || "table";
20880
+ const formStyle = instance.formVersion.style || "table";
20842
20881
  let formContentSchema;
20843
20882
  if (formStyle === "wizard") {
20844
20883
  formContentSchema = await getFormWizardView(instance);
@@ -20846,7 +20885,7 @@ const getFlowFormSchema = async (instance, box) => {
20846
20885
  else {
20847
20886
  formContentSchema = await getFormTableView(instance);
20848
20887
  }
20849
-
20888
+ console.log(`formContentSchema`, formContentSchema);
20850
20889
  const amisSchemaStr = instance.formVersion?.amis_schema;
20851
20890
 
20852
20891
  let initedEvents = [];
@@ -20861,7 +20900,7 @@ const getFlowFormSchema = async (instance, box) => {
20861
20900
  }
20862
20901
  // if (box == 'inbox' || box == 'draft') {
20863
20902
  // TODO: 临时去掉 AutoOpenApproveDrawer 功能因为测试到性能问题
20864
- if ((box == 'inbox' || box == 'draft') && window.disableAutoOpenApproveDrawer !== true) {
20903
+ if ((box == 'inbox' || box == 'draft') && window.enableAutoOpenApproveDrawer) {
20865
20904
  // 滚动条滚动到底部弹出底部签批drawer窗口
20866
20905
  initedEvents.push({
20867
20906
  "actionType": "custom",
@@ -21012,7 +21051,7 @@ const getFlowFormSchema = async (instance, box) => {
21012
21051
  "args": {
21013
21052
  "value": "${event.data.context.approveValues}"
21014
21053
  },
21015
- "expression": "${event.data.context.form.current.style === 'wizard'}"// 表单为 wizard 样式时需要初始同步表单数据,否则直接点击暂存按钮会清空数据
21054
+ "expression": "${event.data.context.flowVersion.style === 'wizard'}"// 表单为 wizard 样式时需要初始同步表单数据,否则直接点击暂存按钮会清空数据
21016
21055
  },
21017
21056
  ...initedEvents
21018
21057
  ]
@@ -21104,24 +21143,20 @@ const getApproveValues = ({ instance, trace, step, approve, box }) => {
21104
21143
  return instanceValues;
21105
21144
  };
21106
21145
 
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
- }
21146
+ const getFlowVersion = async (instance) => {
21147
+ const result = await amisLib.fetchAPI(`/api/workflow/flow/${instance.flow._id}/version/${instance.flow_version}`, {
21148
+ method: "get"
21149
+ });
21150
+ console.log(`getFlowVersion: `, result);
21151
+ return result;
21115
21152
  };
21116
21153
 
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
- }
21154
+ const getFormVersion = async (instance) => {
21155
+ const result = await amisLib.fetchAPI(`/api/workflow/form/${instance.form._id}/version/${instance.form_version}`, {
21156
+ method: "get"
21157
+ });
21158
+ console.log(`getFormVersion: `, result);
21159
+ return result;
21125
21160
  };
21126
21161
 
21127
21162
  const getStep = ({ flowVersion, stepId }) => {
@@ -21214,17 +21249,13 @@ const getInstanceInfo = async (props) => {
21214
21249
  name,
21215
21250
  style,
21216
21251
  mode,
21217
- wizard_mode,
21218
- current,
21219
- historys
21252
+ wizard_mode
21220
21253
  },
21221
21254
  flow_version,
21222
21255
  flow:flow__expand{
21223
21256
  _id,
21224
21257
  name,
21225
- perms,
21226
- current,
21227
- historys
21258
+ perms
21228
21259
  }
21229
21260
  }
21230
21261
  }
@@ -21245,17 +21276,24 @@ const getInstanceInfo = async (props) => {
21245
21276
  if (!instance) {
21246
21277
  return undefined;
21247
21278
  }
21279
+ console.log(`box====>`, box);
21248
21280
  if (box === "inbox" || box === "draft") {
21249
21281
  userApprove = getUserApprove({ instance, userId });
21250
21282
  }
21251
- const flowVersion = getFlowVersion(instance);
21252
- const formVersion = getFormVersion(instance);
21283
+ const flowVersion = await getFlowVersion(instance);
21284
+ const formVersion = await getFormVersion(instance);
21285
+
21286
+ instance.flowVersion = flowVersion;
21287
+ instance.formVersion = formVersion;
21253
21288
 
21254
21289
  if (userApprove) {
21255
21290
  trace = getTrace({ instance, traceId: userApprove.trace });
21256
21291
  step = getStep({ flowVersion, stepId: trace.step });
21257
21292
  }
21258
21293
 
21294
+ console.log(`userApprove===>`, userApprove);
21295
+ console.log(`step===>`, step);
21296
+
21259
21297
  let currentStep = getStep({ flowVersion, stepId: ___default["default"].last(instance.traces).step });
21260
21298
 
21261
21299
  const lastCCStep = getLastCCStep(instance, userId);