cloud-web-corejs 1.1.0-dev.50 → 1.1.0-dev.51
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 +1 -1
- package/src/components/formDialog/index.vue +11 -8
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +14 -0
- package/src/components/xform/mixins/scriptHttp.js +13 -13
- package/src/components/xform/utils/fixedQueryUtil.js +29 -4
- package/src/components/xform/utils/serviceNameCache.js +69 -0
package/package.json
CHANGED
|
@@ -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
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
method: "post",
|
|
568
|
-
data: { formCode, scriptCode },
|
|
565
|
+
getCachedServiceName(this, {
|
|
566
|
+
formCode,
|
|
567
|
+
scriptCode,
|
|
569
568
|
isLoading: false,
|
|
570
|
-
|
|
571
|
-
|
|
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";
|
|
@@ -775,6 +776,17 @@ modules = {
|
|
|
775
776
|
}
|
|
776
777
|
this.initGloatOptionItems(true);
|
|
777
778
|
},
|
|
779
|
+
/**
|
|
780
|
+
* 查询表格条件区拉选项时不盖加载层。列组件(有 tableParam)和按钮区不走这里。
|
|
781
|
+
* @returns {Object}
|
|
782
|
+
*/
|
|
783
|
+
getQueryConditionHttpOption() {
|
|
784
|
+
if (this.tableParam) return {};
|
|
785
|
+
let formRef = this.getFormRef && this.getFormRef();
|
|
786
|
+
let widgetList = formRef && formRef.widgetList;
|
|
787
|
+
if (!isQueryTableConditionWidget(widgetList, this.field)) return {};
|
|
788
|
+
return { isLoading: false, modal: false };
|
|
789
|
+
},
|
|
778
790
|
initGloatOptionItems(initFlag) {
|
|
779
791
|
let t = this;
|
|
780
792
|
if (this.designState) {
|
|
@@ -812,6 +824,7 @@ modules = {
|
|
|
812
824
|
);
|
|
813
825
|
return this.formHttp({
|
|
814
826
|
scriptCode: scriptCode,
|
|
827
|
+
...this.getQueryConditionHttpOption(),
|
|
815
828
|
data: this.buildFormScriptData(reportTemplate, { ...accessParam }),
|
|
816
829
|
callback: (res) => {
|
|
817
830
|
let rows = res.objx?.records || res.objx || [];
|
|
@@ -961,6 +974,7 @@ modules = {
|
|
|
961
974
|
);
|
|
962
975
|
return this.formHttp({
|
|
963
976
|
scriptCode: scriptCode,
|
|
977
|
+
...this.getQueryConditionHttpOption(),
|
|
964
978
|
data: this.buildFormScriptData(reportTemplate, { ...accessParam }),
|
|
965
979
|
callback: (res) => {
|
|
966
980
|
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()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
method: `post`,
|
|
85
|
-
data: {
|
|
86
|
-
formCode,
|
|
87
|
-
scriptCode,
|
|
88
|
-
},
|
|
82
|
+
getCachedServiceName(this.getHttpTarget(), {
|
|
83
|
+
formCode,
|
|
84
|
+
scriptCode,
|
|
89
85
|
isLoading,
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @param {Array} 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
|
-
|
|
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,69 @@
|
|
|
1
|
+
import { findScope, getScopeParams } from "@base/views/bd/project/core/branchContext";
|
|
2
|
+
|
|
3
|
+
/** 会话内服务名。刷新页面即失效,不落本地存储。 */
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
/** 同一键进行中的请求,避免并发时各自打一次接口。 */
|
|
6
|
+
const pending = new Map();
|
|
7
|
+
|
|
8
|
+
function cacheKey(formCode, scriptCode, scopeParams, aes) {
|
|
9
|
+
const branchFlag =
|
|
10
|
+
scopeParams && scopeParams.branchFlag != null ? String(scopeParams.branchFlag) : "";
|
|
11
|
+
const branchCode =
|
|
12
|
+
scopeParams && scopeParams.branchCode ? String(scopeParams.branchCode) : "";
|
|
13
|
+
return [formCode, scriptCode, branchFlag, branchCode, aes ? "1" : "0"].join("\0");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 查询表单脚本所属服务名。
|
|
18
|
+
* 命中内存缓存直接返回;同一 formCode + scriptCode + 分支 + aes 的并发请求合并为一次。
|
|
19
|
+
* 只缓存成功且有服务名的结果。
|
|
20
|
+
*
|
|
21
|
+
* @param {Vue} vm 发起 $http 的实例,分支作用域沿它的父链查找
|
|
22
|
+
* @param {{formCode: string, scriptCode: string, isLoading?: boolean, modal?: boolean, aes?: boolean}} opts
|
|
23
|
+
* @returns {Promise<string>} 有服务名时 resolve 服务名;成功但没有服务名时 resolve 空字符串;请求失败 reject
|
|
24
|
+
*/
|
|
25
|
+
export function getCachedServiceName(vm, opts) {
|
|
26
|
+
const formCode = opts.formCode;
|
|
27
|
+
const scriptCode = opts.scriptCode;
|
|
28
|
+
const aes = !!opts.aes;
|
|
29
|
+
const scopeParams = getScopeParams(findScope(vm));
|
|
30
|
+
const key = cacheKey(formCode, scriptCode, scopeParams, aes);
|
|
31
|
+
|
|
32
|
+
if (cache.has(key)) {
|
|
33
|
+
return Promise.resolve(cache.get(key));
|
|
34
|
+
}
|
|
35
|
+
const inflight = pending.get(key);
|
|
36
|
+
if (inflight) {
|
|
37
|
+
return inflight;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const task = vm
|
|
41
|
+
.$http({
|
|
42
|
+
...(aes ? { aes: true } : {}),
|
|
43
|
+
url: USER_PREFIX + "/formScript/getServiceName",
|
|
44
|
+
method: "post",
|
|
45
|
+
data: {
|
|
46
|
+
formCode,
|
|
47
|
+
scriptCode,
|
|
48
|
+
},
|
|
49
|
+
isLoading: opts.isLoading,
|
|
50
|
+
modal: opts.modal,
|
|
51
|
+
})
|
|
52
|
+
.then((res) => {
|
|
53
|
+
if (!res || res.type !== "success") {
|
|
54
|
+
return Promise.reject(res);
|
|
55
|
+
}
|
|
56
|
+
const serviceName = res.objx;
|
|
57
|
+
if (serviceName) {
|
|
58
|
+
cache.set(key, serviceName);
|
|
59
|
+
return serviceName;
|
|
60
|
+
}
|
|
61
|
+
return "";
|
|
62
|
+
})
|
|
63
|
+
.finally(() => {
|
|
64
|
+
pending.delete(key);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
pending.set(key, task);
|
|
68
|
+
return task;
|
|
69
|
+
}
|