@steedos-widgets/amis-lib 6.10.12 → 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
  }
@@ -18951,7 +18972,6 @@ const showApproveSignImage = (judge) => {
18951
18972
  };
18952
18973
 
18953
18974
  const getUserApprove = ({ instance, userId }) => {
18954
- console.log(`getUserApprove===>`, instance, userId);
18955
18975
  const currentTrace = find(instance.traces, (trace) => {
18956
18976
  return trace.is_finished != true;
18957
18977
  });
@@ -19968,6 +19988,7 @@ const getArgumentsList = (func)=>{
19968
19988
  };
19969
19989
 
19970
19990
  const getFieldEditTpl = async (field, label)=>{
19991
+ console.log('field',field);
19971
19992
  const tpl = {
19972
19993
  label: label === true ? field.name : false,
19973
19994
  name: field.code,
@@ -20175,6 +20196,7 @@ const getFieldEditTpl = async (field, label)=>{
20175
20196
  break;
20176
20197
  case "number":
20177
20198
  tpl.type = "input-number";
20199
+ tpl.precision=2;
20178
20200
  break;
20179
20201
  case "date":
20180
20202
  tpl.type = "input-date";
@@ -20245,7 +20267,6 @@ const getFieldEditTpl = async (field, label)=>{
20245
20267
  tpl.options = getSelectOptions(field);
20246
20268
  break;
20247
20269
  case "odata":
20248
- console.log('odata field', field);
20249
20270
  const argsName = getArgumentsList(field.filters);
20250
20271
  var labelField = field.formula.substr(1, field.formula.length - 2);
20251
20272
  labelField = labelField.substr(labelField.indexOf(".") + 1);
@@ -20254,9 +20275,7 @@ const getFieldEditTpl = async (field, label)=>{
20254
20275
  // tpl.labelField = labelField;
20255
20276
  // tpl.valueField = "_value";
20256
20277
  tpl.source = {
20257
- url: startsWith(field.url, "http")
20258
- ? field.url
20259
- : `\${context.rootUrl}${field.url}`,
20278
+ url: field.url,
20260
20279
  method: "get",
20261
20280
  dataType: "json",
20262
20281
  adaptor:`
@@ -20276,28 +20295,32 @@ const getFieldEditTpl = async (field, label)=>{
20276
20295
  return payload;
20277
20296
  `,
20278
20297
  requestAdaptor: `
20279
- const field = ${JSON.stringify(field)};
20280
- if(field.filters){
20298
+ const filters = ${_.replace(field.filters, /_.pluck/g, '_.map')};
20299
+ const url = ${field.url}
20300
+ if(filters){
20301
+ console.log('filters', filters);
20281
20302
  const joinKey = field.url.indexOf('?') > 0 ? '&' : '?';
20282
- if(field.filters.startsWith('function(') || field.filters.startsWith('function (')){
20303
+ if(filters.startsWith('function(') || filters.startsWith('function (')){
20283
20304
  const argsName = ${JSON.stringify(argsName)};
20284
- const fun = eval('_fun='+field.filters);
20305
+ const fun = eval('_fun='+filters);
20285
20306
  const funArgs = [];
20286
20307
  for(const item of argsName){
20287
20308
  funArgs.push(context[item])
20288
20309
  }
20289
- api.url = field.url + joinKey + "$filter=" + fun.apply({}, funArgs)
20310
+ api.url = url + joinKey + "$filter=" + fun.apply({}, funArgs)
20290
20311
  }else{
20291
- api.url = field.url + joinKey + "$filter=" + field.filters
20312
+ api.url = url + joinKey + "$filter=" + filters
20292
20313
  }
20314
+ }else{
20315
+ api.url = url
20293
20316
  }
20294
20317
  api.query = {};
20295
- console.log('api', api);
20296
20318
  return api;
20297
- `
20319
+ `,
20320
+ trackExpression: _.join(_.map(argsName, (item)=>{return `\${${item}|json}`}), '-')
20298
20321
  };
20299
- // delete tpl.source;
20300
- console.log('odata tpl', tpl);
20322
+ tpl.isAmis=true;
20323
+ console.log(`odata`, tpl);
20301
20324
  break;
20302
20325
  case "html":
20303
20326
  if (tpl.disabled) {
@@ -20374,7 +20397,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
20374
20397
  map[item.value] = item.label;
20375
20398
  });
20376
20399
  tpl.type = 'static';
20377
- 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}"]]) || ''%>`;
20378
20401
  }else if(field.type === 'odata'){
20379
20402
  tpl.type = 'static';
20380
20403
  tpl.tpl = `<div>\${${field.code}['@label']}</div>`;
@@ -20525,7 +20548,6 @@ const getFormTrs = async (instance) => {
20525
20548
  const trs = [];
20526
20549
  let tdFields = [];
20527
20550
  let fields = [];
20528
- console.log('getFormTrs===>', instance.fields);
20529
20551
  each(instance.fields, (field) => {
20530
20552
  fields.push(field);
20531
20553
  if (field.type === "section" && field.fields) {
@@ -20858,7 +20880,6 @@ const getFlowFormSchema = async (instance, box) => {
20858
20880
  else {
20859
20881
  formContentSchema = await getFormTableView(instance);
20860
20882
  }
20861
- console.log(`formContentSchema`, formContentSchema);
20862
20883
  const amisSchemaStr = instance.formVersion?.amis_schema;
20863
20884
 
20864
20885
  let initedEvents = [];
@@ -20882,7 +20903,6 @@ const getFlowFormSchema = async (instance, box) => {
20882
20903
  });
20883
20904
  }
20884
20905
 
20885
- console.log('getFlowFormSchema formContentSchema', formContentSchema);
20886
20906
  return {
20887
20907
  type: "page",
20888
20908
  name: "instancePage",
@@ -21120,7 +21140,6 @@ const getFlowVersion = async (instance) => {
21120
21140
  const result = await fetchAPI$1(`/api/workflow/flow/${instance.flow._id}/version/${instance.flow_version}`, {
21121
21141
  method: "get"
21122
21142
  });
21123
- console.log(`getFlowVersion: `, result);
21124
21143
  return result;
21125
21144
  };
21126
21145
 
@@ -21128,7 +21147,6 @@ const getFormVersion = async (instance) => {
21128
21147
  const result = await fetchAPI$1(`/api/workflow/form/${instance.form._id}/version/${instance.form_version}`, {
21129
21148
  method: "get"
21130
21149
  });
21131
- console.log(`getFormVersion: `, result);
21132
21150
  return result;
21133
21151
  };
21134
21152
 
@@ -21249,7 +21267,6 @@ const getInstanceInfo = async (props) => {
21249
21267
  if (!instance) {
21250
21268
  return undefined;
21251
21269
  }
21252
- console.log(`box====>`, box);
21253
21270
  if (box === "inbox" || box === "draft") {
21254
21271
  userApprove = getUserApprove({ instance, userId });
21255
21272
  }
@@ -21264,9 +21281,6 @@ const getInstanceInfo = async (props) => {
21264
21281
  step = getStep({ flowVersion, stepId: trace.step });
21265
21282
  }
21266
21283
 
21267
- console.log(`userApprove===>`, userApprove);
21268
- console.log(`step===>`, step);
21269
-
21270
21284
  let currentStep = getStep({ flowVersion, stepId: ___default.last(instance.traces).step });
21271
21285
 
21272
21286
  const lastCCStep = getLastCCStep(instance, userId);