@gct-paas/render 0.1.4-dev.11 → 0.1.4-dev.13

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 (46) hide show
  1. package/dist/index.esm.min.js +6189 -0
  2. package/dist/index.min.css +2 -0
  3. package/es/Event/Dependency/controller.mjs +81 -94
  4. package/es/Event/Dependency/displayRule.mjs +65 -67
  5. package/es/Event/Dependency/useDependency.mjs +117 -0
  6. package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
  7. package/es/Event/baseEvent.d.ts +8 -7
  8. package/es/Event/baseEvent.mjs +382 -423
  9. package/es/Event/bizServiceRequest.mjs +28 -40
  10. package/es/Event/eventType.d.ts +1 -1
  11. package/es/Event/eventType.mjs +1 -0
  12. package/es/Event/index.d.ts +4 -3
  13. package/es/Event/index.mjs +5 -0
  14. package/es/Event/utils/appRedis.mjs +39 -49
  15. package/es/Event/utils/globalLoading.mjs +95 -94
  16. package/es/Event/utils/processRovedInfo.mjs +228 -294
  17. package/es/Event/utils/runGlobalByPage.mjs +297 -301
  18. package/es/Event/utils/verificationVar.mjs +32 -38
  19. package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
  20. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  21. package/es/components/HandwritingPad.vue.d.ts +27 -0
  22. package/es/components/HandwritingPad.vue.mjs +7 -0
  23. package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
  24. package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
  25. package/es/components/index.d.ts +2 -0
  26. package/es/components/index.mjs +1 -0
  27. package/es/enums/index.mjs +17 -5
  28. package/es/hooks/useStorageRef.mjs +35 -31
  29. package/es/index.d.ts +1 -0
  30. package/es/index.mjs +20 -21
  31. package/es/register/render-register/render-register.mjs +63 -58
  32. package/es/utils/cacheAdapter.mjs +62 -54
  33. package/es/utils/expression/index.mjs +105 -122
  34. package/es/utils/expression/regularExpression/methods.mjs +426 -567
  35. package/es/utils/field-attrs/basicAttrs.mjs +56 -80
  36. package/es/utils/field-attrs/index.mjs +16 -13
  37. package/es/utils/get-ref-data.mjs +41 -59
  38. package/es/utils/getFieldSchema.mjs +66 -80
  39. package/es/utils/index.d.ts +2 -2
  40. package/es/utils/index.mjs +6 -0
  41. package/es/utils/model-transformer.mjs +74 -64
  42. package/es/utils/useStyle.mjs +20 -16
  43. package/package.json +10 -10
  44. package/dist/index.esm.min.mjs +0 -7042
  45. package/dist/index.min.cjs +0 -17
  46. package/dist/index.system.min.js +0 -17
@@ -0,0 +1,2 @@
1
+ .handwriting-pad[data-v-d5b980b7]{display:inline-block}.canvas[data-v-d5b980b7]{touch-action:none;background:0 0;display:block}
2
+ /*$vite$:1*/
@@ -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 };