@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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, has, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, last, groupBy, sortBy, indexOf, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, has, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, last, groupBy, sortBy, indexOf } from 'lodash';
3
3
  import i18next from 'i18next';
4
4
  export { default as i18next } from 'i18next';
5
5
  import { initReactI18next } from 'react-i18next';
@@ -15539,6 +15539,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15539
15539
  labelField: 'label',
15540
15540
  valueField: 'value'
15541
15541
  };
15542
+ if(field.isAmis){
15543
+ delete field.mode;
15544
+ convertData = {
15545
+ ...convertData,
15546
+ ...field
15547
+ };
15548
+ }
15542
15549
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
15543
15550
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
15544
15551
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
@@ -16776,7 +16783,7 @@ function getFormFields(props, mode = "edit") {
16776
16783
  fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
16777
16784
  }
16778
16785
  return (fields || []).map(function (item) {
16779
- let formItem = {
16786
+ let formItem = item.isAmis ? item : {
16780
16787
  "type": "steedos-field",
16781
16788
  "name": item.name,
16782
16789
  "config": item
@@ -16791,6 +16798,9 @@ function getFormFields(props, mode = "edit") {
16791
16798
  function getInputTableCell(field, showAsInlineEditMode) {
16792
16799
  if (showAsInlineEditMode) {
16793
16800
  // 这里不可以用quickEdit,因为amis存在bug:input-table内的字段在行编辑模式时会受到外层相同name的字段的影响 https://github.com/baidu/amis/issues/9653
16801
+ if(field.isAmis){
16802
+ return field;
16803
+ }
16794
16804
  return {
16795
16805
  "type": "steedos-field",
16796
16806
  "config": Object.assign({}, field, {
@@ -16809,6 +16819,16 @@ function getInputTableCell(field, showAsInlineEditMode) {
16809
16819
  }
16810
16820
  }
16811
16821
  else {
16822
+ if(field.isAmis){
16823
+ return {
16824
+ ...field,
16825
+ inInputTable: true,
16826
+ "static": true,
16827
+ "readonly": true,
16828
+ label: field.label,
16829
+ name: field.name
16830
+ };
16831
+ }
16812
16832
  return {
16813
16833
  "type": "steedos-field",
16814
16834
  "config": Object.assign({}, field, {
@@ -17211,6 +17231,7 @@ function getFormPaginationWrapper(props, form, mode) {
17211
17231
  "method": "get",
17212
17232
  "adaptor": `
17213
17233
  const formBody = ${JSON.stringify(formBody)};
17234
+ console.log('formBody===>', formBody);
17214
17235
  return {
17215
17236
  "body": formBody
17216
17237
  }
@@ -19590,21 +19611,21 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19590
19611
  placeholder: i18next$1.t('frontend_workflow_suggestion_placeholder'),//"请填写意见",
19591
19612
  requiredOn: "${judge === 'rejected'}",
19592
19613
  value: userApprove?.description,
19593
- "onEvent": {
19594
- "change": {
19595
- "actions": [
19596
- {
19597
- "componentId": "u:instancePage",
19598
- "actionType": "setValue",
19599
- "args": {
19600
- "value": {
19601
- "instance_my_approve_description": "${value}"
19602
- }
19603
- }
19604
- }
19605
- ]
19606
- }
19607
- }
19614
+ // "onEvent": {
19615
+ // "blur": {
19616
+ // "actions": [
19617
+ // {
19618
+ // "componentId": "u:instancePage",
19619
+ // "actionType": "setValue",
19620
+ // "args": {
19621
+ // "value": {
19622
+ // "instance_my_approve_description": "${value}"
19623
+ // }
19624
+ // }
19625
+ // }
19626
+ // ]
19627
+ // }
19628
+ // }
19608
19629
  },
19609
19630
  await getNextStepInput(instance),
19610
19631
  await getNextStepUsersInput(instance),
@@ -19927,7 +19948,7 @@ const getInstanceApprovalHistory = async ()=>{
19927
19948
  * @Author: baozhoutao@steedos.com
19928
19949
  * @Date: 2022-09-07 16:20:45
19929
19950
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19930
- * @LastEditTime: 2025-11-19 17:21:28
19951
+ * @LastEditTime: 2025-11-20 20:13:03
19931
19952
  * @Description:
19932
19953
  */
19933
19954
 
@@ -19950,7 +19971,24 @@ const isOpinionField = (field)=>{
19950
19971
  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)
19951
19972
  };
19952
19973
 
19974
+ const getArgumentsList = (func)=>{
19975
+ let funcString;
19976
+ if (typeof func === 'function') {
19977
+ funcString = func.toString();
19978
+ } else {
19979
+ funcString = func;
19980
+ }
19981
+ const regExp = /function\s*\w*\(([\s\S]*?)\)/;
19982
+ if (regExp.test(funcString)) {
19983
+ const argList = RegExp.$1.split(',');
19984
+ return argList.map(arg => arg.replace(/\s/g, ''));
19985
+ } else {
19986
+ return [];
19987
+ }
19988
+ };
19989
+
19953
19990
  const getFieldEditTpl = async (field, label)=>{
19991
+ console.log('field',field);
19954
19992
  const tpl = {
19955
19993
  label: label === true ? field.name : false,
19956
19994
  name: field.code,
@@ -20158,6 +20196,7 @@ const getFieldEditTpl = async (field, label)=>{
20158
20196
  break;
20159
20197
  case "number":
20160
20198
  tpl.type = "input-number";
20199
+ tpl.precision=2;
20161
20200
  break;
20162
20201
  case "date":
20163
20202
  tpl.type = "input-date";
@@ -20228,6 +20267,7 @@ const getFieldEditTpl = async (field, label)=>{
20228
20267
  tpl.options = getSelectOptions(field);
20229
20268
  break;
20230
20269
  case "odata":
20270
+ const argsName = getArgumentsList(field.filters);
20231
20271
  var labelField = field.formula.substr(1, field.formula.length - 2);
20232
20272
  labelField = labelField.substr(labelField.indexOf(".") + 1);
20233
20273
  tpl.type = "select";
@@ -20235,14 +20275,9 @@ const getFieldEditTpl = async (field, label)=>{
20235
20275
  // tpl.labelField = labelField;
20236
20276
  // tpl.valueField = "_value";
20237
20277
  tpl.source = {
20238
- url: startsWith(field.url, "http")
20239
- ? field.url
20240
- : `\${context.rootUrl}${field.url}`,
20278
+ url: field.url,
20241
20279
  method: "get",
20242
20280
  dataType: "json",
20243
- headers: {
20244
- Authorization: "Bearer ${context.tenantId},${context.authToken}",
20245
- },
20246
20281
  adaptor:`
20247
20282
  payload.data = {
20248
20283
  options: _.map(payload.value, (item)=>{
@@ -20258,8 +20293,34 @@ const getFieldEditTpl = async (field, label)=>{
20258
20293
  })
20259
20294
  }
20260
20295
  return payload;
20261
- `
20296
+ `,
20297
+ requestAdaptor: `
20298
+ const filters = ${_.replace(field.filters, /_.pluck/g, '_.map')};
20299
+ const url = ${field.url}
20300
+ if(filters){
20301
+ console.log('filters', filters);
20302
+ const joinKey = field.url.indexOf('?') > 0 ? '&' : '?';
20303
+ if(filters.startsWith('function(') || filters.startsWith('function (')){
20304
+ const argsName = ${JSON.stringify(argsName)};
20305
+ const fun = eval('_fun='+filters);
20306
+ const funArgs = [];
20307
+ for(const item of argsName){
20308
+ funArgs.push(context[item])
20309
+ }
20310
+ api.url = url + joinKey + "$filter=" + fun.apply({}, funArgs)
20311
+ }else{
20312
+ api.url = url + joinKey + "$filter=" + filters
20313
+ }
20314
+ }else{
20315
+ api.url = url
20316
+ }
20317
+ api.query = {};
20318
+ return api;
20319
+ `,
20320
+ trackExpression: _.join(_.map(argsName, (item)=>{return `\${${item}|json}`}), '-')
20262
20321
  };
20322
+ tpl.isAmis=true;
20323
+ console.log(`odata`, tpl);
20263
20324
  break;
20264
20325
  case "html":
20265
20326
  if (tpl.disabled) {
@@ -20336,7 +20397,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
20336
20397
  map[item.value] = item.label;
20337
20398
  });
20338
20399
  tpl.type = 'static';
20339
- tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data.${field.code}]) || ''%>`;
20400
+ tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data["${field.code}"]]) || ''%>`;
20340
20401
  }else if(field.type === 'odata'){
20341
20402
  tpl.type = 'static';
20342
20403
  tpl.tpl = `<div>\${${field.code}['@label']}</div>`;
@@ -20533,7 +20594,7 @@ const getFormTableView = async (instance) => {
20533
20594
  };
20534
20595
 
20535
20596
  const getFormSteps = async (instance) => {
20536
- const formMode = instance.form.current.mode || "normal";//normal,horizontal,inline
20597
+ const formMode = instance.formVersion.mode || "normal";//normal,horizontal,inline
20537
20598
  const stepsSchema = [];
20538
20599
  let stepFields = [];
20539
20600
  let fields = [];
@@ -20600,7 +20661,7 @@ const getFormSteps = async (instance) => {
20600
20661
  };
20601
20662
 
20602
20663
  const getFormWizardView = async (instance) => {
20603
- const wizardMode = instance.form.current.wizard_mode || "vertical";//vertical,horizontal
20664
+ const wizardMode = instance.formVersion.wizard_mode || "vertical";//vertical,horizontal
20604
20665
  const formSchema = {
20605
20666
  type: "wizard",
20606
20667
  className: `instance-form-view-wizard ${wizardMode === "horizontal" ? "pt-4" : "pt-1"} mt-3`,
@@ -20811,7 +20872,7 @@ const getScrollToBottomAutoOpenApproveDrawerScript = () => {
20811
20872
  };
20812
20873
 
20813
20874
  const getFlowFormSchema = async (instance, box) => {
20814
- const formStyle = instance.form.current.style || "table";
20875
+ const formStyle = instance.formVersion.style || "table";
20815
20876
  let formContentSchema;
20816
20877
  if (formStyle === "wizard") {
20817
20878
  formContentSchema = await getFormWizardView(instance);
@@ -20819,7 +20880,6 @@ const getFlowFormSchema = async (instance, box) => {
20819
20880
  else {
20820
20881
  formContentSchema = await getFormTableView(instance);
20821
20882
  }
20822
-
20823
20883
  const amisSchemaStr = instance.formVersion?.amis_schema;
20824
20884
 
20825
20885
  let initedEvents = [];
@@ -20834,7 +20894,7 @@ const getFlowFormSchema = async (instance, box) => {
20834
20894
  }
20835
20895
  // if (box == 'inbox' || box == 'draft') {
20836
20896
  // TODO: 临时去掉 AutoOpenApproveDrawer 功能因为测试到性能问题
20837
- if ((box == 'inbox' || box == 'draft') && window.disableAutoOpenApproveDrawer !== true) {
20897
+ if ((box == 'inbox' || box == 'draft') && window.enableAutoOpenApproveDrawer) {
20838
20898
  // 滚动条滚动到底部弹出底部签批drawer窗口
20839
20899
  initedEvents.push({
20840
20900
  "actionType": "custom",
@@ -20843,7 +20903,6 @@ const getFlowFormSchema = async (instance, box) => {
20843
20903
  });
20844
20904
  }
20845
20905
 
20846
- console.log('getFlowFormSchema formContentSchema', formContentSchema);
20847
20906
  return {
20848
20907
  type: "page",
20849
20908
  name: "instancePage",
@@ -20985,7 +21044,7 @@ const getFlowFormSchema = async (instance, box) => {
20985
21044
  "args": {
20986
21045
  "value": "${event.data.context.approveValues}"
20987
21046
  },
20988
- "expression": "${event.data.context.form.current.style === 'wizard'}"// 表单为 wizard 样式时需要初始同步表单数据,否则直接点击暂存按钮会清空数据
21047
+ "expression": "${event.data.context.flowVersion.style === 'wizard'}"// 表单为 wizard 样式时需要初始同步表单数据,否则直接点击暂存按钮会清空数据
20989
21048
  },
20990
21049
  ...initedEvents
20991
21050
  ]
@@ -21077,24 +21136,18 @@ const getApproveValues = ({ instance, trace, step, approve, box }) => {
21077
21136
  return instanceValues;
21078
21137
  };
21079
21138
 
21080
- const getFlowVersion = (instance) => {
21081
- if (instance.flow.current._id === instance.flow_version) {
21082
- return instance.flow.current;
21083
- } else {
21084
- return find(instance.flow.historys, (history) => {
21085
- return history._id === instance.flow_version;
21086
- });
21087
- }
21139
+ const getFlowVersion = async (instance) => {
21140
+ const result = await fetchAPI$1(`/api/workflow/flow/${instance.flow._id}/version/${instance.flow_version}`, {
21141
+ method: "get"
21142
+ });
21143
+ return result;
21088
21144
  };
21089
21145
 
21090
- const getFormVersion = (instance) => {
21091
- if (instance.form.current._id === instance.form_version) {
21092
- return instance.form.current;
21093
- } else {
21094
- return find(instance.form.historys, (history) => {
21095
- return history._id === instance.form_version;
21096
- });
21097
- }
21146
+ const getFormVersion = async (instance) => {
21147
+ const result = await fetchAPI$1(`/api/workflow/form/${instance.form._id}/version/${instance.form_version}`, {
21148
+ method: "get"
21149
+ });
21150
+ return result;
21098
21151
  };
21099
21152
 
21100
21153
  const getStep = ({ flowVersion, stepId }) => {
@@ -21187,17 +21240,13 @@ const getInstanceInfo = async (props) => {
21187
21240
  name,
21188
21241
  style,
21189
21242
  mode,
21190
- wizard_mode,
21191
- current,
21192
- historys
21243
+ wizard_mode
21193
21244
  },
21194
21245
  flow_version,
21195
21246
  flow:flow__expand{
21196
21247
  _id,
21197
21248
  name,
21198
- perms,
21199
- current,
21200
- historys
21249
+ perms
21201
21250
  }
21202
21251
  }
21203
21252
  }
@@ -21221,8 +21270,11 @@ const getInstanceInfo = async (props) => {
21221
21270
  if (box === "inbox" || box === "draft") {
21222
21271
  userApprove = getUserApprove({ instance, userId });
21223
21272
  }
21224
- const flowVersion = getFlowVersion(instance);
21225
- const formVersion = getFormVersion(instance);
21273
+ const flowVersion = await getFlowVersion(instance);
21274
+ const formVersion = await getFormVersion(instance);
21275
+
21276
+ instance.flowVersion = flowVersion;
21277
+ instance.formVersion = formVersion;
21226
21278
 
21227
21279
  if (userApprove) {
21228
21280
  trace = getTrace({ instance, traceId: userApprove.trace });