@steedos-widgets/amis-lib 6.10.12 → 6.10.14

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
@@ -4690,7 +4690,41 @@ async function getMobileTableColumns(fields, options){
4690
4690
  tpls.push({ field, tpl });
4691
4691
  }
4692
4692
  }
4693
- const url = getNameTplUrl(nameField, options);
4693
+ function getUrlParams(search = window.location.search) {
4694
+ const params = {};
4695
+ const queryString = search.startsWith('?') ? search.slice(1) : search;
4696
+
4697
+ if (!queryString) return params;
4698
+
4699
+ queryString.split('&').forEach(pair => {
4700
+ const [key, value] = pair.split('=');
4701
+ if (key) {
4702
+ const decodedKey = decodeURIComponent(key);
4703
+ const decodedValue = value ? decodeURIComponent(value.replace(/\+/g, ' ')) : '';
4704
+
4705
+ // 处理数组参数(如:?color=red&color=blue)
4706
+ if (params.hasOwnProperty(decodedKey)) {
4707
+ if (Array.isArray(params[decodedKey])) {
4708
+ params[decodedKey].push(decodedValue);
4709
+ } else {
4710
+ params[decodedKey] = [params[decodedKey], decodedValue];
4711
+ }
4712
+ } else {
4713
+ params[decodedKey] = decodedValue;
4714
+ }
4715
+ }
4716
+ });
4717
+
4718
+ return params;
4719
+ }
4720
+
4721
+ const urlParams = getUrlParams();
4722
+
4723
+ let url = getNameTplUrl(nameField, options);
4724
+ if(options.displayAs === 'split'){
4725
+ const additionalFilters = urlParams['additionalFilters'] || '';
4726
+ url = url + `&additionalFilters=${encodeURIComponent(additionalFilters)}`;
4727
+ }
4694
4728
 
4695
4729
  const columnLines = getMobileLines(tpls);
4696
4730
 
@@ -11175,7 +11209,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
11175
11209
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11176
11210
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11177
11211
  "tooltipPlacement": "top",
11178
- "className": "bg-white p-2 rounded text-gray-500 list-view-btn-reload",
11212
+ "className": `bg-white p-2 rounded text-gray-500 list-view-btn-reload ${formFactor === 'SMALL' ? 'hidden' : ''}`,
11179
11213
  "label": "",
11180
11214
  "icon": "fa fa-sync",
11181
11215
  // "visibleOn": "${!showFieldsFilter}",
@@ -11256,7 +11290,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
11256
11290
  // if(toolbarCount){
11257
11291
  // toolbars.push(toolbarCount);
11258
11292
  // }
11259
- // toolbars.push(toolbarReloadButton);
11293
+ toolbars.push(toolbarReloadButton);
11260
11294
  toolbars.push(toolbarDQuickSearchBox);
11261
11295
  if(toolbarFilter){
11262
11296
  toolbars.push(toolbarFilter);
@@ -11727,7 +11761,6 @@ async function getObjectCRUD(objectSchema, fields, options){
11727
11761
  }, bodyProps);
11728
11762
 
11729
11763
  }
11730
-
11731
11764
  body = defaultsDeep({}, listSchema, body);
11732
11765
  body = await getCrudSchemaWithDataFilter(body, { crudDataFilter, onCrudDataFilter, amisData, env });
11733
11766
 
@@ -15566,6 +15599,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15566
15599
  labelField: 'label',
15567
15600
  valueField: 'value'
15568
15601
  };
15602
+ if(field.isAmis){
15603
+ delete field.mode;
15604
+ convertData = {
15605
+ ...convertData,
15606
+ ...field
15607
+ };
15608
+ }
15569
15609
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
15570
15610
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
15571
15611
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
@@ -16803,7 +16843,7 @@ function getFormFields(props, mode = "edit") {
16803
16843
  fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
16804
16844
  }
16805
16845
  return (fields || []).map(function (item) {
16806
- let formItem = {
16846
+ let formItem = item.isAmis ? item : {
16807
16847
  "type": "steedos-field",
16808
16848
  "name": item.name,
16809
16849
  "config": item
@@ -16818,6 +16858,9 @@ function getFormFields(props, mode = "edit") {
16818
16858
  function getInputTableCell(field, showAsInlineEditMode) {
16819
16859
  if (showAsInlineEditMode) {
16820
16860
  // 这里不可以用quickEdit,因为amis存在bug:input-table内的字段在行编辑模式时会受到外层相同name的字段的影响 https://github.com/baidu/amis/issues/9653
16861
+ if(field.isAmis){
16862
+ return field;
16863
+ }
16821
16864
  return {
16822
16865
  "type": "steedos-field",
16823
16866
  "config": Object.assign({}, field, {
@@ -16836,6 +16879,16 @@ function getInputTableCell(field, showAsInlineEditMode) {
16836
16879
  }
16837
16880
  }
16838
16881
  else {
16882
+ if(field.isAmis){
16883
+ return {
16884
+ ...field,
16885
+ inInputTable: true,
16886
+ "static": true,
16887
+ "readonly": true,
16888
+ label: field.label,
16889
+ name: field.name
16890
+ };
16891
+ }
16839
16892
  return {
16840
16893
  "type": "steedos-field",
16841
16894
  "config": Object.assign({}, field, {
@@ -17238,6 +17291,7 @@ function getFormPaginationWrapper(props, form, mode) {
17238
17291
  "method": "get",
17239
17292
  "adaptor": `
17240
17293
  const formBody = ${JSON.stringify(formBody)};
17294
+ console.log('formBody===>', formBody);
17241
17295
  return {
17242
17296
  "body": formBody
17243
17297
  }
@@ -18978,7 +19032,6 @@ const showApproveSignImage = (judge) => {
18978
19032
  };
18979
19033
 
18980
19034
  const getUserApprove = ({ instance, userId }) => {
18981
- console.log(`getUserApprove===>`, instance, userId);
18982
19035
  const currentTrace = _$1.find(instance.traces, (trace) => {
18983
19036
  return trace.is_finished != true;
18984
19037
  });
@@ -19561,12 +19614,25 @@ const getSubmitActions = async (instance, submitEvents) => {
19561
19614
  expression: "${event.data.instanceFormValidate && event.data.approvalFormValidate}"
19562
19615
  },
19563
19616
  {
19564
- "componentId": "",
19565
- "args": {
19566
- "blank": false,
19567
- "url": amisLib.Router.getObjectListViewPath({appId: "${appId}", objectName: "${objectName}", listViewName: "${side_listview_id}"})
19568
- },
19569
- "actionType": "url",
19617
+ "actionType": "wait",
19618
+ "args": {
19619
+ "time": 300
19620
+ }
19621
+ },
19622
+ {
19623
+ "actionType": "custom",
19624
+ "script": `
19625
+ const appId = context.props.data.appId;
19626
+ const objectName = context.props.data.objectName;
19627
+ const side_listview_id = context.props.data.side_listview_id;
19628
+ const additionalFilters = context.props.data.additionalFilters;
19629
+ if(context.props.data.display === 'split'){
19630
+ window.navigate(\`/app/\${appId}/\${objectName}/view/none?side_object=\${objectName}&side_listview_id=\${side_listview_id}&additionalFilters=\${additionalFilters ? encodeURIComponent(additionalFilters) : ''}\`);
19631
+ window.$(".list-view-btn-reload").click();
19632
+ }else{
19633
+ window.navigate(\`/app/\${appId}/\${objectName}/grid/\${side_listview_id}\`);
19634
+ }
19635
+ `,
19570
19636
  expression: "${event.data.instanceFormValidate && event.data.approvalFormValidate}"
19571
19637
  },
19572
19638
  {
@@ -19995,6 +20061,7 @@ const getArgumentsList = (func)=>{
19995
20061
  };
19996
20062
 
19997
20063
  const getFieldEditTpl = async (field, label)=>{
20064
+ console.log('field',field);
19998
20065
  const tpl = {
19999
20066
  label: label === true ? field.name : false,
20000
20067
  name: field.code,
@@ -20202,6 +20269,7 @@ const getFieldEditTpl = async (field, label)=>{
20202
20269
  break;
20203
20270
  case "number":
20204
20271
  tpl.type = "input-number";
20272
+ tpl.precision=2;
20205
20273
  break;
20206
20274
  case "date":
20207
20275
  tpl.type = "input-date";
@@ -20272,7 +20340,6 @@ const getFieldEditTpl = async (field, label)=>{
20272
20340
  tpl.options = getSelectOptions(field);
20273
20341
  break;
20274
20342
  case "odata":
20275
- console.log('odata field', field);
20276
20343
  const argsName = getArgumentsList(field.filters);
20277
20344
  var labelField = field.formula.substr(1, field.formula.length - 2);
20278
20345
  labelField = labelField.substr(labelField.indexOf(".") + 1);
@@ -20281,9 +20348,7 @@ const getFieldEditTpl = async (field, label)=>{
20281
20348
  // tpl.labelField = labelField;
20282
20349
  // tpl.valueField = "_value";
20283
20350
  tpl.source = {
20284
- url: _$1.startsWith(field.url, "http")
20285
- ? field.url
20286
- : `\${context.rootUrl}${field.url}`,
20351
+ url: field.url,
20287
20352
  method: "get",
20288
20353
  dataType: "json",
20289
20354
  adaptor:`
@@ -20303,28 +20368,32 @@ const getFieldEditTpl = async (field, label)=>{
20303
20368
  return payload;
20304
20369
  `,
20305
20370
  requestAdaptor: `
20306
- const field = ${JSON.stringify(field)};
20307
- if(field.filters){
20371
+ const filters = ${_.replace(field.filters, /_.pluck/g, '_.map')};
20372
+ const url = ${field.url}
20373
+ if(filters){
20374
+ console.log('filters', filters);
20308
20375
  const joinKey = field.url.indexOf('?') > 0 ? '&' : '?';
20309
- if(field.filters.startsWith('function(') || field.filters.startsWith('function (')){
20376
+ if(filters.startsWith('function(') || filters.startsWith('function (')){
20310
20377
  const argsName = ${JSON.stringify(argsName)};
20311
- const fun = eval('_fun='+field.filters);
20378
+ const fun = eval('_fun='+filters);
20312
20379
  const funArgs = [];
20313
20380
  for(const item of argsName){
20314
20381
  funArgs.push(context[item])
20315
20382
  }
20316
- api.url = field.url + joinKey + "$filter=" + fun.apply({}, funArgs)
20383
+ api.url = url + joinKey + "$filter=" + fun.apply({}, funArgs)
20317
20384
  }else{
20318
- api.url = field.url + joinKey + "$filter=" + field.filters
20385
+ api.url = url + joinKey + "$filter=" + filters
20319
20386
  }
20387
+ }else{
20388
+ api.url = url
20320
20389
  }
20321
20390
  api.query = {};
20322
- console.log('api', api);
20323
20391
  return api;
20324
- `
20392
+ `,
20393
+ trackExpression: _.join(_.map(argsName, (item)=>{return `\${${item}|json}`}), '-')
20325
20394
  };
20326
- // delete tpl.source;
20327
- console.log('odata tpl', tpl);
20395
+ tpl.isAmis=true;
20396
+ console.log(`odata`, tpl);
20328
20397
  break;
20329
20398
  case "html":
20330
20399
  if (tpl.disabled) {
@@ -20401,7 +20470,7 @@ const getFieldReadonlyTpl = async (field, label)=>{
20401
20470
  map[item.value] = item.label;
20402
20471
  });
20403
20472
  tpl.type = 'static';
20404
- tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data.${field.code}]) || ''%>`;
20473
+ tpl.tpl = `<% var options = ${JSON.stringify(map)}; return (options && options[data["${field.code}"]]) || ''%>`;
20405
20474
  }else if(field.type === 'odata'){
20406
20475
  tpl.type = 'static';
20407
20476
  tpl.tpl = `<div>\${${field.code}['@label']}</div>`;
@@ -20552,7 +20621,6 @@ const getFormTrs = async (instance) => {
20552
20621
  const trs = [];
20553
20622
  let tdFields = [];
20554
20623
  let fields = [];
20555
- console.log('getFormTrs===>', instance.fields);
20556
20624
  _$1.each(instance.fields, (field) => {
20557
20625
  fields.push(field);
20558
20626
  if (field.type === "section" && field.fields) {
@@ -20885,7 +20953,6 @@ const getFlowFormSchema = async (instance, box) => {
20885
20953
  else {
20886
20954
  formContentSchema = await getFormTableView(instance);
20887
20955
  }
20888
- console.log(`formContentSchema`, formContentSchema);
20889
20956
  const amisSchemaStr = instance.formVersion?.amis_schema;
20890
20957
 
20891
20958
  let initedEvents = [];
@@ -20909,7 +20976,6 @@ const getFlowFormSchema = async (instance, box) => {
20909
20976
  });
20910
20977
  }
20911
20978
 
20912
- console.log('getFlowFormSchema formContentSchema', formContentSchema);
20913
20979
  return {
20914
20980
  type: "page",
20915
20981
  name: "instancePage",
@@ -21033,10 +21099,6 @@ const getFlowFormSchema = async (instance, box) => {
21033
21099
  onEvent: {
21034
21100
  "@data.@instanceDetail.changed": {
21035
21101
  actions: [
21036
- {
21037
- actionType: "custom",
21038
- script:"debugger;",
21039
- },
21040
21102
  {
21041
21103
  componentId:"u:instancePage",
21042
21104
  actionType: "reload"
@@ -21045,6 +21107,10 @@ const getFlowFormSchema = async (instance, box) => {
21045
21107
  },
21046
21108
  "inited": {
21047
21109
  "actions": [
21110
+ {
21111
+ actionType: 'broadcast',
21112
+ eventName: "recordLoaded"
21113
+ },
21048
21114
  {
21049
21115
  "actionType": "setValue",
21050
21116
  "componentId": "instance_form",
@@ -21094,6 +21160,9 @@ const getFlowFormSchema = async (instance, box) => {
21094
21160
  };
21095
21161
  };
21096
21162
 
21163
+ const flowVersionCache = new Map();
21164
+ const formVersionCache = new Map();
21165
+
21097
21166
  const getMoment = ()=>{
21098
21167
  if(window.amisRequire){
21099
21168
  return window.amisRequire("moment");
@@ -21144,19 +21213,29 @@ const getApproveValues = ({ instance, trace, step, approve, box }) => {
21144
21213
  };
21145
21214
 
21146
21215
  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;
21216
+ const cacheKey = `${instance.flow._id}_${instance.flow_version}`;
21217
+
21218
+ if (!flowVersionCache.has(cacheKey)) {
21219
+ const result = await amisLib.fetchAPI(`/api/workflow/flow/${instance.flow._id}/version/${instance.flow_version}`, {
21220
+ method: "get"
21221
+ });
21222
+ flowVersionCache.set(cacheKey, result);
21223
+ }
21224
+
21225
+ return flowVersionCache.get(cacheKey);
21152
21226
  };
21153
21227
 
21154
21228
  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;
21229
+ const cacheKey = `${instance.form._id}_${instance.form_version}`;
21230
+
21231
+ if (!formVersionCache.has(cacheKey)) {
21232
+ const result = await amisLib.fetchAPI(`/api/workflow/form/${instance.form._id}/version/${instance.form_version}`, {
21233
+ method: "get"
21234
+ });
21235
+ formVersionCache.set(cacheKey, result);
21236
+ }
21237
+
21238
+ return formVersionCache.get(cacheKey);
21160
21239
  };
21161
21240
 
21162
21241
  const getStep = ({ flowVersion, stepId }) => {
@@ -21213,12 +21292,29 @@ const isNeedToShowSignImage = (is_finished, judge, traceShowSignImage) => {
21213
21292
  return true;
21214
21293
  };
21215
21294
 
21295
+ // 缓存存储
21296
+ const signCache = new Map();
21216
21297
  const getSpaceUserSign = async (space, handler) => {
21298
+ // 生成缓存键
21299
+ const cacheKey = `${space}_${handler}`;
21300
+
21301
+ // 检查缓存
21302
+ if (signCache.has(cacheKey)) {
21303
+ return signCache.get(cacheKey);
21304
+ }
21305
+
21306
+ // 调用API
21217
21307
  const result = await amisLib.fetchAPI(`/api/v1/space_user_signs?filters=[["space","=","${space}"],["user","=","${handler}"]]&fields=["sign"]`);
21308
+
21309
+ let sign = null;
21218
21310
  if (result?.data?.items && result.data.items.length > 0) {
21219
- return result.data.items[0].sign;
21311
+ sign = result.data.items[0].sign;
21220
21312
  }
21221
- return null;
21313
+
21314
+ // 写入缓存
21315
+ signCache.set(cacheKey, sign);
21316
+
21317
+ return sign;
21222
21318
  };
21223
21319
 
21224
21320
  const getInstanceInfo = async (props) => {
@@ -21276,7 +21372,6 @@ const getInstanceInfo = async (props) => {
21276
21372
  if (!instance) {
21277
21373
  return undefined;
21278
21374
  }
21279
- console.log(`box====>`, box);
21280
21375
  if (box === "inbox" || box === "draft") {
21281
21376
  userApprove = getUserApprove({ instance, userId });
21282
21377
  }
@@ -21291,9 +21386,6 @@ const getInstanceInfo = async (props) => {
21291
21386
  step = getStep({ flowVersion, stepId: trace.step });
21292
21387
  }
21293
21388
 
21294
- console.log(`userApprove===>`, userApprove);
21295
- console.log(`step===>`, step);
21296
-
21297
21389
  let currentStep = getStep({ flowVersion, stepId: ___default["default"].last(instance.traces).step });
21298
21390
 
21299
21391
  const lastCCStep = getLastCCStep(instance, userId);