@steedos-widgets/amis-lib 6.10.16 → 6.10.18

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
@@ -1141,7 +1141,7 @@ function getRecordPermissionsQuery(object, recordId, options){
1141
1141
  function getApi$2 (isMobile){
1142
1142
  if(isMobile);else {
1143
1143
  // return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
1144
- return `\${context.rootUrl}/graphql?reload=\${additionalFilters|join}&listName=\${listName}`
1144
+ return `\${context.rootUrl}/graphql?reload=\${additionalFilters|join}`
1145
1145
  }
1146
1146
  }
1147
1147
 
@@ -5040,6 +5040,55 @@ async function getTableSchema$1(object, fields, options){
5040
5040
  }
5041
5041
 
5042
5042
 
5043
+ /**
5044
+ * 移除符合特定规则的sessionStorage项,用于清除列表视图组件请求接口的历史查询条件、翻页页码等本地存储参数数据,只保留最后一次的相关参数
5045
+ * 兼容列表视图的两栏和三栏模式,以及列表视图的简化版(不带/grid)路径
5046
+ * @param {string} suffix - 需要匹配的路径后缀,如"/crud"或"/crud/query"
5047
+ * @returns {string} 返回包含正则表达式和清除逻辑的代码字符串
5048
+ */
5049
+ function removeTableApiSessionStorageItems(suffix) {
5050
+ // 手动转义suffix中的斜线/以确保正则表达式能够正确匹配路径
5051
+ const escapedSuffix = suffix.replace(/\//g, '\\/');
5052
+
5053
+ return `
5054
+ /**
5055
+ * 正则表达式1:匹配不带 /grid 的路径,路径结尾为 ${escapedSuffix}
5056
+ * - 适用于路径格式:/app/{appName}/{objectName}${suffix}
5057
+ * - 可能的suffix值包括:"/crud", "/crud/query"
5058
+ */
5059
+ const noGridPattern = new RegExp('^\\\\/app\\\\/([^\\\\/]+)\\\\/([^\\\\/]+)${escapedSuffix}$');
5060
+
5061
+ /**
5062
+ * 正则表达式2:匹配带 /grid 的路径,路径结尾为 ${escapedSuffix}
5063
+ * - 适用于路径格式:/app/{appName}/{objectName}/grid/{listName}${suffix}
5064
+ * - 可能的suffix值包括:"/crud", "/crud/query"
5065
+ */
5066
+ const withGridPattern = new RegExp('^\\\\/app\\\\/([^\\\\/]+)\\\\/([^\\\\/]+)\\\\/grid\\\\/([^\\\\/]+)${escapedSuffix}$');
5067
+
5068
+ /**
5069
+ * 正则表达式3:匹配带 /view 的路径(列表三栏模式),路径结尾为 ${escapedSuffix}
5070
+ * - 适用于路径格式:/app/{appName}/{objectName}/view/{recordId}${suffix}
5071
+ * - 可能的suffix值包括:"/crud", "/crud/query"
5072
+ */
5073
+ const withViewPattern = new RegExp('^\\\\/app\\\\/([^\\\\/]+)\\\\/([^\\\\/]+)\\\\/view\\\\/([^\\\\/]+)${escapedSuffix}$');
5074
+
5075
+ // 清除 sessionStorage 中符合条件的历史数据
5076
+ for (let i = 0; i < sessionStorage.length; i++) {
5077
+ const key = sessionStorage.key(i);
5078
+
5079
+ /**
5080
+ * 检查是否匹配规则并移除匹配的sessionStorage项:
5081
+ * - noGridPattern 匹配简化版路径
5082
+ * - withGridPattern 匹配带有 /grid 的路径
5083
+ * - withViewPattern 匹配带有 /view 的路径
5084
+ */
5085
+ if (noGridPattern.test(key) || withGridPattern.test(key) || withViewPattern.test(key)) {
5086
+ sessionStorage.removeItem(key);
5087
+ i--; // 因为移除之后,索引也跟着变化,所以需要回退一步
5088
+ }
5089
+ }
5090
+ `;
5091
+ }
5043
5092
 
5044
5093
  /**
5045
5094
  *
@@ -5273,13 +5322,16 @@ async function getTableApi(mainObject, fields, options){
5273
5322
 
5274
5323
  //写入本次存储filters、sort
5275
5324
  const listViewPropsStoreKey = location.pathname + "/crud/query";
5276
- needToStoreListViewProps && sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify({
5277
- filters: filters,
5278
- sort: sort.trim(),
5279
- pageSize: pageSize,
5280
- skip: skip,
5281
- fields: ${JSON.stringify(___namespace.map(fields, 'name'))}
5282
- }));
5325
+ if(needToStoreListViewProps) {
5326
+ ${removeTableApiSessionStorageItems("/crud/query")};
5327
+ sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify({
5328
+ filters: filters,
5329
+ sort: sort.trim(),
5330
+ pageSize: pageSize,
5331
+ skip: skip,
5332
+ fields: ${JSON.stringify(___namespace.map(fields, 'name'))}
5333
+ }));
5334
+ }
5283
5335
  // console.log('table requestAdaptor', api);
5284
5336
  return api;
5285
5337
  `;
@@ -5415,7 +5467,10 @@ async function getTableApi(mainObject, fields, options){
5415
5467
 
5416
5468
  delete selfData.context;
5417
5469
  delete selfData.global;
5418
- needToStoreListViewProps && sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(selfData));
5470
+ if(needToStoreListViewProps) {
5471
+ ${removeTableApiSessionStorageItems("/crud")};
5472
+ sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(selfData));
5473
+ }
5419
5474
  // 返回页码到UI界面
5420
5475
  payload.data.page= selfData.page;
5421
5476
  }
@@ -6073,13 +6128,13 @@ function getCalendarRecordSaveApi(object, calendarOptions) {
6073
6128
  formData[calendarOptions.allDayExpr] = "${event.data.event.allDay}";
6074
6129
  // formData[calendarOptions.textExpr] = "${event.data.event.title}";
6075
6130
  const apiData = {
6076
- objectName: "${objectName}",
6131
+ objectName: object.name,
6077
6132
  $: formData,
6078
6133
  $self: "$$"
6079
6134
  };
6080
6135
  const saveDataTpl = `
6081
6136
  const formData = api.data.$;
6082
- const objectName = api.data.objectName;
6137
+ const objectName = ${object.name}};
6083
6138
  let query = \`mutation{record: \${objectName}__update(id: "\${formData.${idFieldName}}", doc: {__saveData}){${idFieldName}}}\`;
6084
6139
  delete formData.${idFieldName};
6085
6140
  let __saveData = JSON.stringify(JSON.stringify(formData));
@@ -6206,7 +6261,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6206
6261
  "body": [
6207
6262
  {
6208
6263
  "type": "steedos-object-form",
6209
- "objectApiName": "\${objectName}",
6264
+ "objectApiName": "${objectSchema.name}",
6210
6265
  "mode": "edit",
6211
6266
  "defaultData": doc,
6212
6267
  //改回为通用的提交事件
@@ -6405,14 +6460,14 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6405
6460
  }
6406
6461
  ]
6407
6462
  },
6408
- "getRef": {
6463
+ "setCalendarApi": {
6409
6464
  "weight": 0,
6410
6465
  "actions": [
6411
6466
  {
6412
6467
  "componentId": `service_${options.id}`,
6413
6468
  "args": {
6414
6469
  "value":{
6415
- "calendarRef": "${event.data.calendarRef}"
6470
+ "calendarApi": "${event.data.calendarApi}"
6416
6471
  }
6417
6472
  },
6418
6473
  "actionType": "setValue",
@@ -20771,7 +20826,7 @@ const getFormWizardView = async (instance) => {
20771
20826
  const getApplicantTableView = async (instance) => {
20772
20827
  let applicantInput = null;
20773
20828
  if(instance.state === 'draft'){
20774
- applicantInput = Object.assign({name: "applicant", value: amisLib.getSteedosAuth().userId, disabled: instance.box !== 'draft'}, await amisLib.lookupToAmis(
20829
+ applicantInput = Object.assign({name: "applicant", value: instance.applicant || amisLib.getSteedosAuth().userId, disabled: instance.box !== 'draft'}, await amisLib.lookupToAmis(
20775
20830
  {
20776
20831
  name: "applicant",
20777
20832
  label: false,