@gct-paas/render 0.1.4-dev.10 → 0.1.4-dev.12
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.esm.min.js +6118 -0
- package/es/Event/Dependency/controller.mjs +81 -94
- package/es/Event/Dependency/displayRule.mjs +65 -67
- package/es/Event/Dependency/useDependency.mjs +117 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
- package/es/Event/baseEvent.d.ts +7 -6
- package/es/Event/baseEvent.mjs +382 -423
- package/es/Event/bizServiceRequest.mjs +28 -40
- package/es/Event/index.d.ts +2 -1
- package/es/Event/index.mjs +4 -0
- package/es/Event/utils/appRedis.mjs +39 -49
- package/es/Event/utils/globalLoading.mjs +95 -94
- package/es/Event/utils/processRovedInfo.mjs +228 -294
- package/es/Event/utils/runGlobalByPage.mjs +296 -300
- package/es/Event/utils/verificationVar.mjs +32 -38
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/enums/index.mjs +17 -5
- package/es/hooks/useStorageRef.mjs +35 -31
- package/es/index.mjs +18 -21
- package/es/register/render-register/render-register.mjs +63 -58
- package/es/utils/cacheAdapter.mjs +62 -54
- package/es/utils/expression/index.mjs +105 -122
- package/es/utils/expression/regularExpression/methods.mjs +426 -567
- package/es/utils/field-attrs/basicAttrs.mjs +56 -80
- package/es/utils/field-attrs/index.mjs +16 -13
- package/es/utils/get-ref-data.mjs +41 -59
- package/es/utils/getFieldSchema.mjs +66 -80
- package/es/utils/index.d.ts +1 -1
- package/es/utils/index.mjs +6 -0
- package/es/utils/model-transformer.mjs +74 -64
- package/es/utils/useStyle.d.ts +2 -2
- package/es/utils/useStyle.mjs +12 -14
- package/package.json +8 -8
- package/dist/index.esm.min.mjs +0 -7825
- package/dist/index.min.cjs +0 -17
- package/dist/index.system.min.js +0 -17
|
@@ -1,97 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
cacheFormFileds,
|
|
57
|
-
() => {
|
|
58
|
-
playValueByRule(cacheFormFileds.value);
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
debounce: 200,
|
|
62
|
-
immediate: !rowData
|
|
63
|
-
}
|
|
64
|
-
);
|
|
1
|
+
import { calculate, identify } from "../../utils/expression/index.mjs";
|
|
2
|
+
import "../../utils/index.mjs";
|
|
3
|
+
import { formMap, globalVarCaches, pageGlobaVariables } from "../utils/runGlobalByPage.mjs";
|
|
4
|
+
import { watchDebounced } from "@vueuse/core";
|
|
5
|
+
import { computed } from "vue";
|
|
6
|
+
//#region src/Event/Dependency/controller.ts
|
|
7
|
+
/**组件依赖触发器 */
|
|
8
|
+
function insetDep({ expression = "", rowData = null }, callback) {
|
|
9
|
+
if (!expression || expression === "true") {
|
|
10
|
+
callback(true);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const identifyArgs = identify(expression);
|
|
14
|
+
const formCacheMap = identifyArgs.reduce((total, i) => {
|
|
15
|
+
const arg = i.split(".");
|
|
16
|
+
total[i] = {
|
|
17
|
+
formKey: arg[0],
|
|
18
|
+
itemKey: arg[1]
|
|
19
|
+
};
|
|
20
|
+
return total;
|
|
21
|
+
}, {});
|
|
22
|
+
/**收集依赖 函数显隐控制 关联组件字段收集 */
|
|
23
|
+
const cacheFormFileds = computed(() => {
|
|
24
|
+
return identifyArgs.reduce((total, i) => {
|
|
25
|
+
const arg = i.split(".");
|
|
26
|
+
const formKey = arg[0] + "";
|
|
27
|
+
const filedKey = arg[1];
|
|
28
|
+
if (filedKey) {
|
|
29
|
+
const value = (rowData ? rowData[filedKey] : formMap.value[formKey]?.[filedKey]) ?? "";
|
|
30
|
+
if (total[formKey]) total[formKey][filedKey] = value;
|
|
31
|
+
else total[formKey] = { [filedKey]: value };
|
|
32
|
+
} else if (formKey.startsWith("$VAR_") || formKey.startsWith("$IVAR_")) total[formKey] = globalVarCaches.value[formKey]?.value ?? "";
|
|
33
|
+
else if (formKey.startsWith("$PAGERVAR_") || formKey.startsWith("$IPAGERVAR_")) total[formKey] = pageGlobaVariables.value[formKey]?.value ?? "";
|
|
34
|
+
return total;
|
|
35
|
+
}, {});
|
|
36
|
+
});
|
|
37
|
+
function playValueByRule(form) {
|
|
38
|
+
const cache = {};
|
|
39
|
+
Object.keys(formCacheMap).forEach((k) => {
|
|
40
|
+
const { formKey, itemKey } = formCacheMap[k];
|
|
41
|
+
cache[k] = itemKey ? form[formKey]?.[itemKey] : form[formKey];
|
|
42
|
+
});
|
|
43
|
+
calculate(expression, cache).then(callback);
|
|
44
|
+
}
|
|
45
|
+
/**当处于行内场景的时候需要立即执行 快速响应 */
|
|
46
|
+
if (rowData) playValueByRule(cacheFormFileds.value);
|
|
47
|
+
/**
|
|
48
|
+
* 监听收集的依赖
|
|
49
|
+
*/
|
|
50
|
+
watchDebounced(cacheFormFileds, () => {
|
|
51
|
+
playValueByRule(cacheFormFileds.value);
|
|
52
|
+
}, {
|
|
53
|
+
debounce: 200,
|
|
54
|
+
immediate: !rowData
|
|
55
|
+
});
|
|
65
56
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
cache[k] = value;
|
|
93
|
-
});
|
|
94
|
-
return calculate(expression, cache);
|
|
57
|
+
/**
|
|
58
|
+
* 直接计算表达式结果,不进行依赖监控
|
|
59
|
+
* 用于一次性计算场景,快速获取表达式判断结果
|
|
60
|
+
*/
|
|
61
|
+
async function calculateDepResult({ expression = "", rowData = null }) {
|
|
62
|
+
if (!expression || expression === "true") return true;
|
|
63
|
+
const formCacheMap = identify(expression).reduce((total, i) => {
|
|
64
|
+
const arg = i.split(".");
|
|
65
|
+
total[i] = {
|
|
66
|
+
formKey: arg[0],
|
|
67
|
+
itemKey: arg[1]
|
|
68
|
+
};
|
|
69
|
+
return total;
|
|
70
|
+
}, {});
|
|
71
|
+
const cache = {};
|
|
72
|
+
Object.keys(formCacheMap).forEach((k) => {
|
|
73
|
+
const { formKey, itemKey } = formCacheMap[k];
|
|
74
|
+
let value = "";
|
|
75
|
+
if (formKey.startsWith("$VAR_")) value = globalVarCaches.value[formKey]?.value ?? "";
|
|
76
|
+
else if (formKey.startsWith("$PAGERVAR_")) value = pageGlobaVariables.value[formKey]?.value ?? "";
|
|
77
|
+
else if (itemKey) value = (rowData ? rowData[itemKey] : formMap.value[formKey]?.[itemKey]) ?? "";
|
|
78
|
+
else value = (rowData ? rowData[formKey] : formMap.value[formKey]) ?? "";
|
|
79
|
+
cache[k] = value;
|
|
80
|
+
});
|
|
81
|
+
return calculate(expression, cache);
|
|
95
82
|
}
|
|
96
|
-
|
|
83
|
+
//#endregion
|
|
97
84
|
export { calculateDepResult, insetDep };
|
|
@@ -1,76 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { watchDebounced } from '@vueuse/core';
|
|
10
|
-
|
|
1
|
+
import { calculate, identify } from "../../utils/expression/index.mjs";
|
|
2
|
+
import "../../utils/index.mjs";
|
|
3
|
+
import { formMap, getPremission } from "../utils/runGlobalByPage.mjs";
|
|
4
|
+
import { DisplayType } from "@gct-paas/core";
|
|
5
|
+
import { watchDebounced } from "@vueuse/core";
|
|
6
|
+
import { ref, toRef } from "vue";
|
|
7
|
+
//#region src/Event/Dependency/displayRule.ts
|
|
8
|
+
/**单组件显隐控制 */
|
|
11
9
|
function useVisibileByRuleHook(props, id) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} else {
|
|
17
|
-
return useDisplayRule(props);
|
|
18
|
-
}
|
|
10
|
+
/**按钮权限 */
|
|
11
|
+
if (!getPremission(id)) return false;
|
|
12
|
+
else if (props.displayType === DisplayType.CONFIG) return toRef(() => !props.hidden);
|
|
13
|
+
else return useDisplayRule(props);
|
|
19
14
|
}
|
|
20
15
|
function useDisplayRule(rule) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
const formCache = ref(false);
|
|
17
|
+
getOptionsByDisplayRule(rule, (f) => {
|
|
18
|
+
formCache.value = !!f;
|
|
19
|
+
});
|
|
20
|
+
return formCache;
|
|
26
21
|
}
|
|
22
|
+
/**组件显示规则 */
|
|
27
23
|
function getOptionsByDisplayRule({ displayRule, tableForm }, callback) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
24
|
+
if (!displayRule)
|
|
25
|
+
/**没有配置规则 */
|
|
26
|
+
callback(true);
|
|
27
|
+
else {
|
|
28
|
+
const identifyArgs = identify(displayRule);
|
|
29
|
+
const formCacheMap = identifyArgs.reduce((total, i) => {
|
|
30
|
+
const arg = i.split(".");
|
|
31
|
+
total[i] = {
|
|
32
|
+
formKey: arg[0],
|
|
33
|
+
itemKey: arg[1]
|
|
34
|
+
};
|
|
35
|
+
return total;
|
|
36
|
+
}, {});
|
|
37
|
+
/**收集依赖 函数显隐控制 关联组件字段收集 */
|
|
38
|
+
const cacheFormFileds = toRef(() => {
|
|
39
|
+
return identifyArgs.reduce((total, i) => {
|
|
40
|
+
const arg = i.split(".");
|
|
41
|
+
const formKey = arg[0] + "", filedKey = arg[1] + "";
|
|
42
|
+
const value = {
|
|
43
|
+
...tableForm,
|
|
44
|
+
...formMap.value
|
|
45
|
+
}[formKey]?.[filedKey];
|
|
46
|
+
if (total[formKey]) total[formKey][filedKey] = value;
|
|
47
|
+
else total[formKey] = { [filedKey]: value };
|
|
48
|
+
return total;
|
|
49
|
+
}, {});
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* 监听收集的依赖
|
|
53
|
+
*/
|
|
54
|
+
watchDebounced(cacheFormFileds, () => {
|
|
55
|
+
playValueByRule(cacheFormFileds.value, formCacheMap, displayRule, (flag) => {
|
|
56
|
+
callback(flag);
|
|
57
|
+
});
|
|
58
|
+
}, {
|
|
59
|
+
immediate: true,
|
|
60
|
+
debounce: 300
|
|
61
|
+
});
|
|
62
|
+
}
|
|
65
63
|
}
|
|
64
|
+
/**分析表达式调用api获取布尔值 */
|
|
66
65
|
function playValueByRule(form, formCacheMap, displayRule, callback) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
calculate(displayRule, cache).then(callback);
|
|
66
|
+
const cache = {};
|
|
67
|
+
Object.keys(formCacheMap).forEach((k) => {
|
|
68
|
+
const { formKey, itemKey } = formCacheMap[k];
|
|
69
|
+
cache[k] = form?.[formKey]?.[itemKey];
|
|
70
|
+
});
|
|
71
|
+
calculate(displayRule, cache).then(callback);
|
|
74
72
|
}
|
|
75
|
-
|
|
73
|
+
//#endregion
|
|
76
74
|
export { useVisibileByRuleHook };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getRefInfoId } from "../../utils/get-ref-data.mjs";
|
|
2
|
+
import "../../utils/index.mjs";
|
|
3
|
+
import "../utils/processRovedInfo.mjs";
|
|
4
|
+
import { insetDep } from "./controller.mjs";
|
|
5
|
+
import { ASSIGNMENTSTRATEGY_ENUM, Dependency_ENUM } from "@gct-paas/core";
|
|
6
|
+
import { watchDebounced } from "@vueuse/core";
|
|
7
|
+
import { computed, inject, toRef } from "vue";
|
|
8
|
+
//#region src/Event/Dependency/useDependency.ts
|
|
9
|
+
function useDependency(widget, formState = {}, isRow = false) {
|
|
10
|
+
const { readonly, field, isFieldModel, bindFieldLink, refOriginField, refOriginModelKey, refOriginFieldType } = widget.props;
|
|
11
|
+
const configDependency = widget.props.componentDependency?.configDependency || {};
|
|
12
|
+
const formReadonly = inject("formReadonly", void 0);
|
|
13
|
+
const useProcessFieldEvent = inject("useProcessFieldEvent", void 0);
|
|
14
|
+
if (useProcessFieldEvent) useProcessFieldEvent.useFieldWidget(widget);
|
|
15
|
+
if (!useProcessFieldEvent && widget.formItem && formReadonly?.value !== void 0) widget.props.readonly = formReadonly?.value || widget.props.readonly;
|
|
16
|
+
if (!useProcessFieldEvent && !formReadonly?.value) {
|
|
17
|
+
const readonly_expression = configDependency[Dependency_ENUM.READONLY]?.expression;
|
|
18
|
+
const readonly_field_value = configDependency[Dependency_ENUM.READONLY]?.fieldValue;
|
|
19
|
+
const readonly_value = configDependency[Dependency_ENUM.READONLY]?.value;
|
|
20
|
+
if (!readonly_field_value && readonly_value && readonly_expression) insetDep({
|
|
21
|
+
expression: readonly_expression,
|
|
22
|
+
rowData: isRow ? formState : null
|
|
23
|
+
}, (res) => {
|
|
24
|
+
widget.props.readonly = !!res;
|
|
25
|
+
});
|
|
26
|
+
const required_expression = configDependency[Dependency_ENUM.REQUIRED]?.expression;
|
|
27
|
+
const required_value = configDependency[Dependency_ENUM.REQUIRED]?.value;
|
|
28
|
+
if (!configDependency[Dependency_ENUM.REQUIRED]?.fieldValue && required_value && required_expression) insetDep({
|
|
29
|
+
expression: required_expression,
|
|
30
|
+
rowData: isRow ? formState : null
|
|
31
|
+
}, (res) => {
|
|
32
|
+
widget.props.required = !!res;
|
|
33
|
+
if (res) widget.props.readonly = false;
|
|
34
|
+
else widget.props.readonly = readonly;
|
|
35
|
+
});
|
|
36
|
+
const disabled_expression = configDependency[Dependency_ENUM.DISABLED]?.expression;
|
|
37
|
+
if (configDependency[Dependency_ENUM.DISABLED]?.value && disabled_expression) insetDep({
|
|
38
|
+
expression: disabled_expression,
|
|
39
|
+
rowData: isRow ? formState : null
|
|
40
|
+
}, (res) => {
|
|
41
|
+
widget.props.disabled = !!res;
|
|
42
|
+
if (res) widget.props.readonly = false;
|
|
43
|
+
else widget.props.readonly = readonly;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const assignment_expression = configDependency[Dependency_ENUM.ASSIGNMENT]?.expression;
|
|
47
|
+
const strategy = configDependency[Dependency_ENUM.ASSIGNMENT]?.strategy;
|
|
48
|
+
if (assignment_expression) insetDep({
|
|
49
|
+
expression: assignment_expression,
|
|
50
|
+
rowData: isRow ? formState : null
|
|
51
|
+
}, (res) => {
|
|
52
|
+
formState[field] = res;
|
|
53
|
+
});
|
|
54
|
+
const fieldKey = isFieldModel ? bindFieldLink?.join(".") : field;
|
|
55
|
+
if (!formState._OPCT) formState._OPCT = { _DICT: {} };
|
|
56
|
+
const formRowData = computed(() => {
|
|
57
|
+
if (isFieldModel) return formState._OPCT;
|
|
58
|
+
return formState;
|
|
59
|
+
});
|
|
60
|
+
const value = computed({
|
|
61
|
+
get() {
|
|
62
|
+
if (fieldKey) return formRowData.value[fieldKey];
|
|
63
|
+
return "";
|
|
64
|
+
},
|
|
65
|
+
set(val) {
|
|
66
|
+
if (!!assignment_expression && strategy === ASSIGNMENTSTRATEGY_ENUM.alwaysCover) return;
|
|
67
|
+
formRowData.value[fieldKey] = val;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (isFieldModel && refOriginField) {
|
|
71
|
+
/**
|
|
72
|
+
* 多级字段显示逻辑
|
|
73
|
+
* 监听源字段
|
|
74
|
+
* */
|
|
75
|
+
const originField = toRef(() => {
|
|
76
|
+
return formState[bindFieldLink[0]];
|
|
77
|
+
});
|
|
78
|
+
const foreignFields = bindFieldLink.length > 2 ? [bindFieldLink[1] + ".*"] : void 0;
|
|
79
|
+
watchDebounced(originField, async () => {
|
|
80
|
+
try {
|
|
81
|
+
const data = await getRefInfoId({
|
|
82
|
+
ids: originField.value,
|
|
83
|
+
refOriginField: bindFieldLink[0],
|
|
84
|
+
refOriginFieldType,
|
|
85
|
+
model: refOriginModelKey,
|
|
86
|
+
foreignFields
|
|
87
|
+
});
|
|
88
|
+
formRowData.value[fieldKey] = data._OPCT[fieldKey];
|
|
89
|
+
if (!formRowData.value._DICT) formRowData.value._DICT = {};
|
|
90
|
+
formRowData.value._DICT[fieldKey] = data._OPCT._DICT[fieldKey];
|
|
91
|
+
} catch {
|
|
92
|
+
for (const key in formRowData.value) if (key.startsWith(fieldKey)) formRowData.value[key] = void 0;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
debounce: 100,
|
|
96
|
+
immediate: true
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
value,
|
|
101
|
+
formRowData,
|
|
102
|
+
fieldKey
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function useDependencyByRequired(widget) {
|
|
106
|
+
const { readonly } = widget.props;
|
|
107
|
+
const configDependency = widget.props.componentDependency?.configDependency || {};
|
|
108
|
+
const required_expression = configDependency[Dependency_ENUM.REQUIRED]?.expression;
|
|
109
|
+
const required_value = configDependency[Dependency_ENUM.REQUIRED]?.value;
|
|
110
|
+
if (!configDependency[Dependency_ENUM.REQUIRED]?.fieldValue && required_value && required_expression) insetDep({ expression: required_expression }, (res) => {
|
|
111
|
+
widget.props.required = !!res;
|
|
112
|
+
if (res) widget.props.readonly = false;
|
|
113
|
+
else widget.props.readonly = readonly;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { useDependency, useDependencyByRequired };
|
|
@@ -1,109 +1,113 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { useVisibileByRuleHook } from
|
|
5
|
-
import { Dependency_ENUM, DisplayType } from
|
|
6
|
-
|
|
1
|
+
import { getPremission } from "../utils/runGlobalByPage.mjs";
|
|
2
|
+
import "../utils/processRovedInfo.mjs";
|
|
3
|
+
import { calculateDepResult, insetDep } from "./controller.mjs";
|
|
4
|
+
import { useVisibileByRuleHook } from "./displayRule.mjs";
|
|
5
|
+
import { Dependency_ENUM, DisplayType } from "@gct-paas/core";
|
|
6
|
+
import { inject, toRef } from "vue";
|
|
7
|
+
//#region src/Event/Dependency/useDependencyToShow.ts
|
|
7
8
|
function useDependencyToShow(widget) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
9
|
+
if (widget.props?.displayRule && widget.props?.displayType === DisplayType.RULE)
|
|
10
|
+
/**老版本显隐逻辑 */
|
|
11
|
+
return useVisibileByRuleHook(widget.props, widget.id);
|
|
12
|
+
else return dependencyToShow(widget);
|
|
13
13
|
}
|
|
14
14
|
function dependencyToShow(widget, rowData) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
if (!widget.id) return false;
|
|
16
|
+
if (!getPremission(widget.id)) {
|
|
17
|
+
/**权限不存在就直接返回false */
|
|
18
|
+
widget.props.hidden = true;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const useProcessFieldEvent = inject("useProcessFieldEvent", void 0);
|
|
22
|
+
if (useProcessFieldEvent) {
|
|
23
|
+
/**流程节点隐藏的字段 */
|
|
24
|
+
useProcessFieldEvent.useFieldToShow(widget);
|
|
25
|
+
return !widget.props.hidden;
|
|
26
|
+
}
|
|
27
|
+
const { displayType, displayRule } = widget.props || {};
|
|
28
|
+
const { value, expression } = (widget.props.componentDependency?.configDependency || {})[Dependency_ENUM.HIDDEN] || {};
|
|
29
|
+
if (value && expression) {
|
|
30
|
+
widget.props.hidden = true;
|
|
31
|
+
insetDep({
|
|
32
|
+
expression,
|
|
33
|
+
rowData
|
|
34
|
+
}, (res) => {
|
|
35
|
+
widget.props.hidden = !!res;
|
|
36
|
+
});
|
|
37
|
+
} else if (value)
|
|
38
|
+
/**开启组件依赖没有配置隐藏条件 */
|
|
39
|
+
widget.props.hidden = true;
|
|
40
|
+
else if (displayType === DisplayType.RULE && displayRule) {
|
|
41
|
+
/**老数据显示隐藏配置兼容 */
|
|
42
|
+
widget.props.hidden = true;
|
|
43
|
+
insetDep({
|
|
44
|
+
expression: displayRule,
|
|
45
|
+
rowData
|
|
46
|
+
}, (res) => {
|
|
47
|
+
widget.props.hidden = !res;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return toRef(() => !widget.props.hidden);
|
|
45
51
|
}
|
|
52
|
+
/**直接返回计算结果的依赖显隐逻辑 */
|
|
46
53
|
async function dependencyToShowSync(widget, rowData) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
if (!widget.id) return false;
|
|
55
|
+
if (!getPremission(widget.id)) {
|
|
56
|
+
/**权限不存在就直接返回false */
|
|
57
|
+
widget.props.hidden = true;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const useProcessFieldEvent = inject("useProcessFieldEvent", void 0);
|
|
61
|
+
if (useProcessFieldEvent) {
|
|
62
|
+
/**流程节点隐藏的字段 */
|
|
63
|
+
useProcessFieldEvent.useFieldToShow(widget);
|
|
64
|
+
return !widget.props.hidden;
|
|
65
|
+
}
|
|
66
|
+
const { displayType, displayRule } = widget.props || {};
|
|
67
|
+
const { value, expression } = (widget.props.componentDependency?.configDependency || {})[Dependency_ENUM.HIDDEN] || {};
|
|
68
|
+
if (value && expression) {
|
|
69
|
+
widget.props.hidden = true;
|
|
70
|
+
widget.props.hidden = !!await calculateDepResult({
|
|
71
|
+
expression,
|
|
72
|
+
rowData
|
|
73
|
+
});
|
|
74
|
+
} else if (value)
|
|
75
|
+
/**开启组件依赖没有配置隐藏条件 */
|
|
76
|
+
widget.props.hidden = true;
|
|
77
|
+
else if (displayType === DisplayType.RULE && displayRule) {
|
|
78
|
+
/**老数据显示隐藏配置兼容 */
|
|
79
|
+
widget.props.hidden = true;
|
|
80
|
+
widget.props.hidden = !!await calculateDepResult({
|
|
81
|
+
expression: displayRule,
|
|
82
|
+
rowData
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return !widget.props.hidden;
|
|
76
86
|
}
|
|
87
|
+
/**组件集合处理 */
|
|
77
88
|
function useDependencyToShowList(widgetList, rowData) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
widgetList.forEach((widget) => {
|
|
90
|
+
dependencyToShow(widget, rowData);
|
|
91
|
+
});
|
|
92
|
+
return toRef(() => widgetList.filter((i) => !i.props.hidden));
|
|
82
93
|
}
|
|
83
94
|
function tableWidgetToShow(widget, callback) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
callback(widget.props.hidden);
|
|
95
|
+
const { value, expression } = (widget.props.componentDependency?.configDependency || {})[Dependency_ENUM.HIDDEN] || {};
|
|
96
|
+
if (value && expression) insetDep({ expression }, (res) => {
|
|
97
|
+
callback(res);
|
|
98
|
+
});
|
|
99
|
+
callback(widget.props.hidden);
|
|
92
100
|
}
|
|
93
101
|
function tableWidgetByDept(widget) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
insetDep({ expression: required_expression }, (res) => {
|
|
104
|
-
widget.props.required = !!res;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
102
|
+
const configDependency = widget.props.componentDependency?.configDependency || {};
|
|
103
|
+
const { value, expression } = configDependency[Dependency_ENUM.HIDDEN] || {};
|
|
104
|
+
if (value && expression) insetDep({ expression }, (res) => {
|
|
105
|
+
widget.props.hidden = !!res;
|
|
106
|
+
});
|
|
107
|
+
const { value: required_value, expression: required_expression } = configDependency[Dependency_ENUM.REQUIRED] || {};
|
|
108
|
+
if (required_value && required_expression) insetDep({ expression: required_expression }, (res) => {
|
|
109
|
+
widget.props.required = !!res;
|
|
110
|
+
});
|
|
107
111
|
}
|
|
108
|
-
|
|
112
|
+
//#endregion
|
|
109
113
|
export { dependencyToShow, dependencyToShowSync, tableWidgetByDept, tableWidgetToShow, useDependencyToShow, useDependencyToShowList };
|