@steedos-widgets/amis-lib 6.10.13 → 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
 
@@ -19581,12 +19614,25 @@ const getSubmitActions = async (instance, submitEvents) => {
19581
19614
  expression: "${event.data.instanceFormValidate && event.data.approvalFormValidate}"
19582
19615
  },
19583
19616
  {
19584
- "componentId": "",
19585
- "args": {
19586
- "blank": false,
19587
- "url": amisLib.Router.getObjectListViewPath({appId: "${appId}", objectName: "${objectName}", listViewName: "${side_listview_id}"})
19588
- },
19589
- "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
+ `,
19590
19636
  expression: "${event.data.instanceFormValidate && event.data.approvalFormValidate}"
19591
19637
  },
19592
19638
  {
@@ -21053,10 +21099,6 @@ const getFlowFormSchema = async (instance, box) => {
21053
21099
  onEvent: {
21054
21100
  "@data.@instanceDetail.changed": {
21055
21101
  actions: [
21056
- {
21057
- actionType: "custom",
21058
- script:"debugger;",
21059
- },
21060
21102
  {
21061
21103
  componentId:"u:instancePage",
21062
21104
  actionType: "reload"
@@ -21065,6 +21107,10 @@ const getFlowFormSchema = async (instance, box) => {
21065
21107
  },
21066
21108
  "inited": {
21067
21109
  "actions": [
21110
+ {
21111
+ actionType: 'broadcast',
21112
+ eventName: "recordLoaded"
21113
+ },
21068
21114
  {
21069
21115
  "actionType": "setValue",
21070
21116
  "componentId": "instance_form",
@@ -21114,6 +21160,9 @@ const getFlowFormSchema = async (instance, box) => {
21114
21160
  };
21115
21161
  };
21116
21162
 
21163
+ const flowVersionCache = new Map();
21164
+ const formVersionCache = new Map();
21165
+
21117
21166
  const getMoment = ()=>{
21118
21167
  if(window.amisRequire){
21119
21168
  return window.amisRequire("moment");
@@ -21164,17 +21213,29 @@ const getApproveValues = ({ instance, trace, step, approve, box }) => {
21164
21213
  };
21165
21214
 
21166
21215
  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;
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);
21171
21226
  };
21172
21227
 
21173
21228
  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;
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);
21178
21239
  };
21179
21240
 
21180
21241
  const getStep = ({ flowVersion, stepId }) => {
@@ -21231,12 +21292,29 @@ const isNeedToShowSignImage = (is_finished, judge, traceShowSignImage) => {
21231
21292
  return true;
21232
21293
  };
21233
21294
 
21295
+ // 缓存存储
21296
+ const signCache = new Map();
21234
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
21235
21307
  const result = await amisLib.fetchAPI(`/api/v1/space_user_signs?filters=[["space","=","${space}"],["user","=","${handler}"]]&fields=["sign"]`);
21308
+
21309
+ let sign = null;
21236
21310
  if (result?.data?.items && result.data.items.length > 0) {
21237
- return result.data.items[0].sign;
21311
+ sign = result.data.items[0].sign;
21238
21312
  }
21239
- return null;
21313
+
21314
+ // 写入缓存
21315
+ signCache.set(cacheKey, sign);
21316
+
21317
+ return sign;
21240
21318
  };
21241
21319
 
21242
21320
  const getInstanceInfo = async (props) => {