cloud-web-corejs 1.0.307 → 1.0.308

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.307",
4
+ "version": "1.0.308",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "check:package-resources": "node build/check-package-resources.js",
@@ -190,6 +190,7 @@
190
190
 
191
191
  <script>
192
192
  import { openComponentDialog } from "@base/utils/componentDialog";
193
+ import { getCachedServiceName } from "@base/components/xform/utils/serviceNameCache";
193
194
  import {
194
195
  resolveActionButtons,
195
196
  hasButtonPermission,
@@ -561,14 +562,13 @@ export default {
561
562
  }
562
563
  const [formCode, scriptCode] = parts;
563
564
  this.$set(this.optionsLoadingMap, field.prop, true);
564
- this.$http({
565
- aes: true,
566
- url: USER_PREFIX + "/formScript/getServiceName",
567
- method: "post",
568
- data: { formCode, scriptCode },
565
+ getCachedServiceName(this, {
566
+ formCode,
567
+ scriptCode,
569
568
  isLoading: false,
570
- success: (res) => {
571
- const serviceName = res.objx;
569
+ aes: true,
570
+ }).then(
571
+ (serviceName) => {
572
572
  if (!serviceName) {
573
573
  this.$set(this.optionsLoadingMap, field.prop, false);
574
574
  this.$baseAlert("服务名不存在");
@@ -605,7 +605,10 @@ export default {
605
605
  },
606
606
  });
607
607
  },
608
- });
608
+ () => {
609
+ this.$set(this.optionsLoadingMap, field.prop, false);
610
+ }
611
+ );
609
612
  },
610
613
  // 搜索框默认禁止手输(值由选择回填),传 props: { editable: true } 可放开
611
614
  searchReadonly(field) {
@@ -30,6 +30,7 @@ import {
30
30
  } from "@base/components/xform/utils/formula-util";
31
31
  import * as formulajs from "@formulajs/formulajs";
32
32
  import settingConfig from "@/settings.js";
33
+ import { isQueryTableConditionWidget } from "@base/components/xform/utils/fixedQueryUtil";
33
34
 
34
35
  let modules = {};
35
36
  const isDev = process.env.NODE_ENV === "development";
@@ -755,6 +756,17 @@ modules = {
755
756
  }
756
757
  this.initGloatOptionItems(true);
757
758
  },
759
+ /**
760
+ * 查询表格条件区拉选项时不盖加载层。列组件(有 tableParam)和按钮区不走这里。
761
+ * @returns {Object}
762
+ */
763
+ getQueryConditionHttpOption() {
764
+ if (this.tableParam) return {};
765
+ let formRef = this.getFormRef && this.getFormRef();
766
+ let widgetList = formRef && formRef.widgetList;
767
+ if (!isQueryTableConditionWidget(widgetList, this.field)) return {};
768
+ return { isLoading: false, modal: false };
769
+ },
758
770
  initGloatOptionItems(initFlag) {
759
771
  let t = this;
760
772
  if (this.designState) {
@@ -792,6 +804,7 @@ modules = {
792
804
  );
793
805
  return this.formHttp({
794
806
  scriptCode: scriptCode,
807
+ ...this.getQueryConditionHttpOption(),
795
808
  data: this.buildFormScriptData(reportTemplate, { ...accessParam }),
796
809
  callback: (res) => {
797
810
  let rows = res.objx?.records || res.objx || [];
@@ -941,6 +954,7 @@ modules = {
941
954
  );
942
955
  return this.formHttp({
943
956
  scriptCode: scriptCode,
957
+ ...this.getQueryConditionHttpOption(),
944
958
  data: this.buildFormScriptData(reportTemplate, { ...accessParam }),
945
959
  callback: (res) => {
946
960
  let rows = res.objx || [];
@@ -1,5 +1,6 @@
1
1
  import { initWf } from "../../../components/wf/wfUtil";
2
2
  import { getReportGlobalMap } from "../../../components/xform/utils/util";
3
+ import { getCachedServiceName } from "../../../components/xform/utils/serviceNameCache";
3
4
  import { decrypt } from "@base/utils/aes";
4
5
 
5
6
  let modules = {};
@@ -78,26 +79,25 @@ modules = {
78
79
 
79
80
  let getServiceName = (callback) => {
80
81
  if (formCode && formCode !== reportTemplate.formCode) {
81
- this.getHttpTarget().$http({
82
- aes: true,
83
- url: USER_PREFIX + `/formScript/getServiceName`,
84
- method: `post`,
85
- data: {
86
- formCode,
87
- scriptCode,
88
- },
82
+ getCachedServiceName(this.getHttpTarget(), {
83
+ formCode,
84
+ scriptCode,
89
85
  isLoading,
90
- // loadingTarget: this.getLoadingTarget(),
91
- // modalStrictly: true,
92
- success: (res) => {
93
- let serviceName = res.objx;
86
+ // 调用方关掉 modal 时,查服务名这一跳也别再盖遮罩
87
+ modal: opts.modal,
88
+ aes: true,
89
+ }).then(
90
+ (serviceName) => {
94
91
  if (serviceName) {
95
92
  callback(serviceName);
96
93
  } else {
97
94
  this.$baseAlert("服务名不存在");
98
95
  }
99
96
  },
100
- });
97
+ () => {
98
+ // 失败提示由请求层处理,不继续请求脚本
99
+ }
100
+ );
101
101
  } else {
102
102
  callback(reportTemplate.serviceName);
103
103
  }
@@ -63,13 +63,14 @@ export function isLockedSearchColumn(column) {
63
63
  }
64
64
 
65
65
  /**
66
- * 组件是否位于某个数据表格的查询区(data-table 的 widgetList 分支,不含 buttons、
67
- * 不含表格列组件)。属性面板据此决定要不要显示「固定查询条件」开关。
68
- * @param {Array} widgetList 表单顶层组件列表(designer.widgetList)
66
+ * 字段是否落在某个数据表格的查询区(data-table 的 widgetList 分支,不含 buttons、
67
+ * 不含表格列组件)。
68
+ * @param {Array} widgetList 表单顶层组件列表
69
69
  * @param {Object} widget 待判定的字段组件
70
+ * @param {Function} [acceptTable] 额外过滤数据表格节点,返回 false 则跳过该表
70
71
  * @returns {Boolean}
71
72
  */
72
- export function isQueryAreaWidget(widgetList, widget) {
73
+ function isInDataTableQueryArea(widgetList, widget, acceptTable) {
73
74
  if (!widget || !widget.id || !Array.isArray(widgetList)) return false;
74
75
  let inQueryArea = false;
75
76
  widgetList.forEach((item) => {
@@ -79,6 +80,7 @@ export function isQueryAreaWidget(widgetList, widget) {
79
80
  node.category !== "container"
80
81
  || node.type !== "data-table"
81
82
  || !Array.isArray(node.widgetList)
83
+ || (acceptTable && !acceptTable(node))
82
84
  ) {
83
85
  return;
84
86
  }
@@ -91,3 +93,26 @@ export function isQueryAreaWidget(widgetList, widget) {
91
93
  });
92
94
  return inQueryArea;
93
95
  }
96
+
97
+ /**
98
+ * 组件是否位于某个数据表格的查询区。属性面板据此决定要不要显示「固定查询条件」开关。
99
+ * @param {Array} widgetList 表单顶层组件列表(designer.widgetList)
100
+ * @param {Object} widget 待判定的字段组件
101
+ * @returns {Boolean}
102
+ */
103
+ export function isQueryAreaWidget(widgetList, widget) {
104
+ return isInDataTableQueryArea(widgetList, widget);
105
+ }
106
+
107
+ /**
108
+ * 字段是否位于「查询表格」的查询条件区:数据表格已打开 isQueryTable,且字段在其
109
+ * widgetList 里(含栅格等容器嵌套)。按钮区、表格列、主表单字段都不算。
110
+ * @param {Array} widgetList 表单顶层组件列表
111
+ * @param {Object} widget 待判定的字段组件
112
+ * @returns {Boolean}
113
+ */
114
+ export function isQueryTableConditionWidget(widgetList, widget) {
115
+ return isInDataTableQueryArea(widgetList, widget, (node) => {
116
+ return !!(node.options && node.options.isQueryTable);
117
+ });
118
+ }
@@ -0,0 +1,62 @@
1
+ /** 会话内服务名。刷新页面即失效,不落本地存储。 */
2
+ const cache = new Map();
3
+ /** 同一键进行中的请求,避免并发时各自打一次接口。 */
4
+ const pending = new Map();
5
+
6
+ function cacheKey(formCode, scriptCode, aes) {
7
+ return [formCode, scriptCode, aes ? "1" : "0"].join("\0");
8
+ }
9
+
10
+ /**
11
+ * 查询表单脚本所属服务名。
12
+ * 命中内存缓存直接返回;同一 formCode + scriptCode + aes 的并发请求合并为一次。
13
+ * 只缓存成功且有服务名的结果。
14
+ *
15
+ * @param {Vue} vm 发起 $http 的实例
16
+ * @param {{formCode: string, scriptCode: string, isLoading?: boolean, modal?: boolean, aes?: boolean}} opts
17
+ * @returns {Promise<string>} 有服务名时 resolve 服务名;成功但没有服务名时 resolve 空字符串;请求失败 reject
18
+ */
19
+ export function getCachedServiceName(vm, opts) {
20
+ const formCode = opts.formCode;
21
+ const scriptCode = opts.scriptCode;
22
+ const aes = !!opts.aes;
23
+ const key = cacheKey(formCode, scriptCode, aes);
24
+
25
+ if (cache.has(key)) {
26
+ return Promise.resolve(cache.get(key));
27
+ }
28
+ const inflight = pending.get(key);
29
+ if (inflight) {
30
+ return inflight;
31
+ }
32
+
33
+ const task = vm
34
+ .$http({
35
+ ...(aes ? { aes: true } : {}),
36
+ url: USER_PREFIX + "/formScript/getServiceName",
37
+ method: "post",
38
+ data: {
39
+ formCode,
40
+ scriptCode,
41
+ },
42
+ isLoading: opts.isLoading,
43
+ modal: opts.modal,
44
+ })
45
+ .then((res) => {
46
+ if (!res || res.type !== "success") {
47
+ return Promise.reject(res);
48
+ }
49
+ const serviceName = res.objx;
50
+ if (serviceName) {
51
+ cache.set(key, serviceName);
52
+ return serviceName;
53
+ }
54
+ return "";
55
+ })
56
+ .finally(() => {
57
+ pending.delete(key);
58
+ });
59
+
60
+ pending.set(key, task);
61
+ return task;
62
+ }