@gct-paas/render 0.1.4-dev.11 → 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.
Files changed (35) hide show
  1. package/dist/index.esm.min.js +6118 -0
  2. package/es/Event/Dependency/controller.mjs +81 -94
  3. package/es/Event/Dependency/displayRule.mjs +65 -67
  4. package/es/Event/Dependency/useDependency.mjs +117 -0
  5. package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
  6. package/es/Event/baseEvent.d.ts +6 -5
  7. package/es/Event/baseEvent.mjs +382 -423
  8. package/es/Event/bizServiceRequest.mjs +28 -40
  9. package/es/Event/index.d.ts +2 -1
  10. package/es/Event/index.mjs +4 -0
  11. package/es/Event/utils/appRedis.mjs +39 -49
  12. package/es/Event/utils/globalLoading.mjs +95 -94
  13. package/es/Event/utils/processRovedInfo.mjs +228 -294
  14. package/es/Event/utils/runGlobalByPage.mjs +296 -300
  15. package/es/Event/utils/verificationVar.mjs +32 -38
  16. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  17. package/es/enums/index.mjs +17 -5
  18. package/es/hooks/useStorageRef.mjs +35 -31
  19. package/es/index.mjs +18 -21
  20. package/es/register/render-register/render-register.mjs +63 -58
  21. package/es/utils/cacheAdapter.mjs +62 -54
  22. package/es/utils/expression/index.mjs +105 -122
  23. package/es/utils/expression/regularExpression/methods.mjs +426 -567
  24. package/es/utils/field-attrs/basicAttrs.mjs +56 -80
  25. package/es/utils/field-attrs/index.mjs +16 -13
  26. package/es/utils/get-ref-data.mjs +41 -59
  27. package/es/utils/getFieldSchema.mjs +66 -80
  28. package/es/utils/index.d.ts +1 -1
  29. package/es/utils/index.mjs +6 -0
  30. package/es/utils/model-transformer.mjs +74 -64
  31. package/es/utils/useStyle.mjs +12 -15
  32. package/package.json +7 -7
  33. package/dist/index.esm.min.mjs +0 -7042
  34. package/dist/index.min.cjs +0 -17
  35. package/dist/index.system.min.js +0 -17
@@ -1,97 +1,84 @@
1
- import { computed } from 'vue';
2
- import { formMap, globalVarCaches, pageGlobaVariables } from '../utils/runGlobalByPage.mjs';
3
- import { watchDebounced } from '@vueuse/core';
4
- import '@gct-paas/core';
5
- import 'lodash-es';
6
- import '../../utils/field-attrs/basicAttrs.mjs';
7
- import '@gct-paas/schema';
8
- import { identify, calculate } from '../../utils/expression/index.mjs';
9
- import 'qs';
10
-
11
- function insetDep({
12
- expression = "",
13
- rowData = null
14
- }, callback) {
15
- if (!expression || expression === "true") {
16
- callback(true);
17
- return;
18
- }
19
- const identifyArgs = identify(expression);
20
- const formCacheMap = identifyArgs.reduce((total, i) => {
21
- const arg = i.split(".");
22
- total[i] = { formKey: arg[0], itemKey: arg[1] };
23
- return total;
24
- }, {});
25
- const cacheFormFileds = computed(() => {
26
- return identifyArgs.reduce((total, i) => {
27
- const arg = i.split(".");
28
- const formKey = arg[0] + "";
29
- const filedKey = arg[1];
30
- if (filedKey) {
31
- const value = (rowData ? rowData[filedKey] : formMap.value[formKey]?.[filedKey]) ?? "";
32
- if (total[formKey]) {
33
- total[formKey][filedKey] = value;
34
- } else {
35
- total[formKey] = { [filedKey]: value };
36
- }
37
- } else if (formKey.startsWith("$VAR_") || formKey.startsWith("$IVAR_")) {
38
- total[formKey] = globalVarCaches.value[formKey]?.value ?? "";
39
- } else if (formKey.startsWith("$PAGERVAR_") || formKey.startsWith("$IPAGERVAR_")) {
40
- total[formKey] = pageGlobaVariables.value[formKey]?.value ?? "";
41
- }
42
- return total;
43
- }, {});
44
- });
45
- function playValueByRule(form) {
46
- const cache = {};
47
- Object.keys(formCacheMap).forEach((k) => {
48
- const { formKey, itemKey } = formCacheMap[k];
49
- const value = itemKey ? form[formKey]?.[itemKey] : form[formKey];
50
- cache[k] = value;
51
- });
52
- calculate(expression, cache).then(callback);
53
- }
54
- if (rowData) playValueByRule(cacheFormFileds.value);
55
- watchDebounced(
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
- async function calculateDepResult({
67
- expression = "",
68
- rowData = null
69
- }) {
70
- if (!expression || expression === "true") {
71
- return true;
72
- }
73
- const identifyArgs = identify(expression);
74
- const formCacheMap = identifyArgs.reduce((total, i) => {
75
- const arg = i.split(".");
76
- total[i] = { formKey: arg[0], itemKey: arg[1] };
77
- return total;
78
- }, {});
79
- const cache = {};
80
- Object.keys(formCacheMap).forEach((k) => {
81
- const { formKey, itemKey } = formCacheMap[k];
82
- let value = "";
83
- if (formKey.startsWith("$VAR_")) {
84
- value = globalVarCaches.value[formKey]?.value ?? "";
85
- } else if (formKey.startsWith("$PAGERVAR_")) {
86
- value = pageGlobaVariables.value[formKey]?.value ?? "";
87
- } else if (itemKey) {
88
- value = (rowData ? rowData[itemKey] : formMap.value[formKey]?.[itemKey]) ?? "";
89
- } else {
90
- value = (rowData ? rowData[formKey] : formMap.value[formKey]) ?? "";
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 { DisplayType } from '@gct-paas/core';
2
- import 'lodash-es';
3
- import '../../utils/field-attrs/basicAttrs.mjs';
4
- import '@gct-paas/schema';
5
- import { identify, calculate } from '../../utils/expression/index.mjs';
6
- import 'qs';
7
- import { toRef, ref } from 'vue';
8
- import { getPremission, formMap } from '../utils/runGlobalByPage.mjs';
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
- if (!getPremission(id)) {
13
- return false;
14
- } else if (props.displayType === DisplayType.CONFIG) {
15
- return toRef(() => !props.hidden);
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
- const formCache = ref(false);
22
- getOptionsByDisplayRule(rule, (f) => {
23
- formCache.value = !!f;
24
- });
25
- return formCache;
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
- if (!displayRule) {
29
- callback(true);
30
- } else {
31
- const identifyArgs = identify(displayRule);
32
- const formCacheMap = identifyArgs.reduce((total, i) => {
33
- const arg = i.split(".");
34
- total[i] = { formKey: arg[0], itemKey: arg[1] };
35
- return total;
36
- }, {});
37
- const cacheFormFileds = toRef(() => {
38
- return identifyArgs.reduce((total, i) => {
39
- const arg = i.split(".");
40
- const formKey = arg[0] + "", filedKey = arg[1] + "";
41
- const value = { ...tableForm, ...formMap.value }[formKey]?.[filedKey];
42
- if (total[formKey]) {
43
- total[formKey][filedKey] = value;
44
- } else {
45
- total[formKey] = { [filedKey]: value };
46
- }
47
- return total;
48
- }, {});
49
- });
50
- watchDebounced(
51
- cacheFormFileds,
52
- () => {
53
- playValueByRule(
54
- cacheFormFileds.value,
55
- formCacheMap,
56
- displayRule,
57
- (flag) => {
58
- callback(flag);
59
- }
60
- );
61
- },
62
- { immediate: true, debounce: 300 }
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
- const cache = {};
68
- Object.keys(formCacheMap).forEach((k) => {
69
- const { formKey, itemKey } = formCacheMap[k];
70
- const value = form?.[formKey]?.[itemKey];
71
- cache[k] = value;
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 { inject, toRef } from 'vue';
2
- import { getPremission } from '../utils/runGlobalByPage.mjs';
3
- import { insetDep, calculateDepResult } from './controller.mjs';
4
- import { useVisibileByRuleHook } from './displayRule.mjs';
5
- import { Dependency_ENUM, DisplayType } from '@gct-paas/core';
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
- if (widget.props?.displayRule && widget.props?.displayType === DisplayType.RULE) {
9
- return useVisibileByRuleHook(widget.props, widget.id);
10
- } else {
11
- return dependencyToShow(widget);
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
- if (!widget.id) return false;
16
- if (!getPremission(widget.id)) {
17
- widget.props.hidden = true;
18
- return false;
19
- }
20
- const useProcessFieldEvent = inject(
21
- "useProcessFieldEvent",
22
- void 0
23
- );
24
- if (useProcessFieldEvent) {
25
- useProcessFieldEvent.useFieldToShow(widget);
26
- return !widget.props.hidden;
27
- }
28
- const { displayType, displayRule } = widget.props || {};
29
- const configDependency = widget.props.componentDependency?.configDependency || {};
30
- const { value, expression } = configDependency[Dependency_ENUM.HIDDEN] || {};
31
- if (value && expression) {
32
- widget.props.hidden = true;
33
- insetDep({ expression, rowData }, (res) => {
34
- widget.props.hidden = !!res;
35
- });
36
- } else if (value) {
37
- widget.props.hidden = true;
38
- } else if (displayType === DisplayType.RULE && displayRule) {
39
- widget.props.hidden = true;
40
- insetDep({ expression: displayRule, rowData }, (res) => {
41
- widget.props.hidden = !res;
42
- });
43
- }
44
- return toRef(() => !widget.props.hidden);
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
- if (!widget.id) return false;
48
- if (!getPremission(widget.id)) {
49
- widget.props.hidden = true;
50
- return false;
51
- }
52
- const useProcessFieldEvent = inject(
53
- "useProcessFieldEvent",
54
- void 0
55
- );
56
- if (useProcessFieldEvent) {
57
- useProcessFieldEvent.useFieldToShow(widget);
58
- return !widget.props.hidden;
59
- }
60
- const { displayType, displayRule } = widget.props || {};
61
- const configDependency = widget.props.componentDependency?.configDependency || {};
62
- const { value, expression } = configDependency[Dependency_ENUM.HIDDEN] || {};
63
- if (value && expression) {
64
- widget.props.hidden = true;
65
- widget.props.hidden = !!await calculateDepResult({ expression, rowData });
66
- } else if (value) {
67
- widget.props.hidden = true;
68
- } else if (displayType === DisplayType.RULE && displayRule) {
69
- widget.props.hidden = true;
70
- widget.props.hidden = !!await calculateDepResult({
71
- expression: displayRule,
72
- rowData
73
- });
74
- }
75
- return !widget.props.hidden;
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
- widgetList.forEach((widget) => {
79
- dependencyToShow(widget, rowData);
80
- });
81
- return toRef(() => widgetList.filter((i) => !i.props.hidden));
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
- const configDependency = widget.props.componentDependency?.configDependency || {};
85
- const { value, expression } = configDependency[Dependency_ENUM.HIDDEN] || {};
86
- if (value && expression) {
87
- insetDep({ expression }, (res) => {
88
- callback(res);
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
- const configDependency = widget.props.componentDependency?.configDependency || {};
95
- const { value, expression } = configDependency[Dependency_ENUM.HIDDEN] || {};
96
- if (value && expression) {
97
- insetDep({ expression }, (res) => {
98
- widget.props.hidden = !!res;
99
- });
100
- }
101
- const { value: required_value, expression: required_expression } = configDependency[Dependency_ENUM.REQUIRED] || {};
102
- if (required_value && required_expression) {
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 };