@gct-paas/render 0.1.4-dev.8 → 0.1.5-dev.0

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 (121) hide show
  1. package/dist/index.min.css +2 -0
  2. package/dist/loader.esm.min.js +1 -0
  3. package/es/Event/Dependency/controller.d.ts +13 -0
  4. package/es/Event/Dependency/controller.mjs +84 -0
  5. package/es/Event/Dependency/displayRule.d.ts +19 -0
  6. package/es/Event/Dependency/displayRule.mjs +138 -0
  7. package/es/Event/Dependency/useDependency.d.ts +7 -0
  8. package/es/Event/Dependency/useDependency.mjs +117 -0
  9. package/es/Event/Dependency/useDependencyToShow.d.ts +10 -0
  10. package/es/Event/Dependency/useDependencyToShow.mjs +113 -0
  11. package/es/Event/baseEvent.d.ts +156 -0
  12. package/es/Event/baseEvent.mjs +389 -0
  13. package/es/Event/bizServiceRequest.d.ts +26 -0
  14. package/es/Event/bizServiceRequest.mjs +35 -0
  15. package/es/Event/eventType.d.ts +20 -0
  16. package/es/Event/eventType.mjs +1 -0
  17. package/es/Event/index.d.ts +7 -0
  18. package/es/Event/index.mjs +7 -0
  19. package/es/Event/utils/appRedis.d.ts +29 -0
  20. package/es/Event/utils/appRedis.mjs +40 -0
  21. package/es/Event/utils/globalLoading.d.ts +13 -0
  22. package/es/Event/utils/globalLoading.mjs +104 -0
  23. package/es/Event/utils/processRovedInfo.d.ts +100 -0
  24. package/es/Event/utils/processRovedInfo.mjs +231 -0
  25. package/es/Event/utils/runGlobalByPage.d.ts +335 -0
  26. package/es/Event/utils/runGlobalByPage.mjs +302 -0
  27. package/es/Event/utils/verificationVar.d.ts +2 -0
  28. package/es/Event/utils/verificationVar.mjs +36 -0
  29. package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
  30. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  31. package/es/components/HandwritingPad.vue.d.ts +27 -0
  32. package/es/components/HandwritingPad.vue.mjs +7 -0
  33. package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
  34. package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
  35. package/es/components/index.d.ts +2 -0
  36. package/es/components/index.mjs +1 -0
  37. package/es/constant/data-format.d.ts +52 -0
  38. package/es/constant/data-format.mjs +66 -0
  39. package/es/constant/date-time.d.ts +99 -0
  40. package/es/constant/date-time.mjs +187 -0
  41. package/es/constant/index.d.ts +94 -0
  42. package/es/constant/index.mjs +100 -0
  43. package/es/controller/design-render/design-render.controller.d.ts +18 -0
  44. package/es/controller/design-render/design-render.controller.mjs +78 -0
  45. package/es/controller/design-render-base/design-render-base.controller.d.ts +9 -0
  46. package/es/controller/design-render-base/design-render-base.controller.mjs +12 -0
  47. package/es/controller/design-render-container/design-render-container.controller.d.ts +4 -0
  48. package/es/controller/design-render-container/design-render-container.controller.mjs +5 -0
  49. package/es/controller/design-render-item/design-render-item.controller.d.ts +4 -0
  50. package/es/controller/design-render-item/design-render-item.controller.mjs +5 -0
  51. package/es/controller/index.d.ts +4 -0
  52. package/es/controller/index.mjs +4 -0
  53. package/es/enums/index.d.ts +14 -0
  54. package/es/enums/index.mjs +18 -0
  55. package/es/hooks/index.d.ts +2 -0
  56. package/es/hooks/index.mjs +2 -0
  57. package/es/hooks/use-design-render-controller/use-design-render-controller.d.ts +11 -0
  58. package/es/hooks/use-design-render-controller/use-design-render-controller.mjs +32 -0
  59. package/es/hooks/useStorageRef.d.ts +9 -0
  60. package/es/hooks/useStorageRef.mjs +37 -0
  61. package/es/index.d.ts +6 -0
  62. package/es/index.mjs +36 -1
  63. package/es/interface/controller/i-design-render-base.controller.d.ts +43 -0
  64. package/es/interface/controller/i-design-render-container.controller.d.ts +7 -0
  65. package/es/interface/controller/i-design-render-item.controller.d.ts +7 -0
  66. package/es/interface/controller/i-design-render.controller.d.ts +93 -0
  67. package/es/interface/index.d.ts +12 -0
  68. package/es/interface/provider/i-render-base-node.provider.d.ts +45 -0
  69. package/es/interface/provider/i-render-container-node.provider.d.ts +30 -0
  70. package/es/interface/provider/i-render-editor-node.provider.d.ts +29 -0
  71. package/es/interface/provider/i-render-item-node.provider.d.ts +30 -0
  72. package/es/interface/state/i-design-render-base.state.d.ts +19 -0
  73. package/es/interface/state/i-design-render-container.state.d.ts +11 -0
  74. package/es/interface/state/i-design-render-item.state.d.ts +11 -0
  75. package/es/interface/state/i-design-render.state.d.ts +18 -0
  76. package/es/loader.d.ts +1 -0
  77. package/es/register/index.d.ts +2 -0
  78. package/es/register/index.mjs +2 -0
  79. package/es/register/node/node.register.d.ts +92 -0
  80. package/es/register/node/node.register.mjs +116 -0
  81. package/es/register/render-register/render-register.d.ts +54 -0
  82. package/es/register/render-register/render-register.mjs +64 -0
  83. package/es/state/design-render/design-render.state.d.ts +13 -0
  84. package/es/state/design-render/design-render.state.mjs +15 -0
  85. package/es/state/design-render-base/design-render-base.state.d.ts +4 -0
  86. package/es/state/design-render-base/design-render-base.state.mjs +6 -0
  87. package/es/state/design-render-container/design-render-container.state.d.ts +4 -0
  88. package/es/state/design-render-item/design-render-item.state.d.ts +4 -0
  89. package/es/state/index.d.ts +4 -0
  90. package/es/types/index.d.ts +6 -0
  91. package/es/utils/cacheAdapter.d.ts +7 -0
  92. package/es/utils/cacheAdapter.mjs +65 -0
  93. package/es/utils/expression/index.d.ts +6 -0
  94. package/es/utils/expression/index.mjs +116 -0
  95. package/es/utils/expression/regularExpression/methods.d.ts +77 -0
  96. package/es/utils/expression/regularExpression/methods.mjs +588 -0
  97. package/es/utils/field-attrs/basicAttrs.mjs +56 -80
  98. package/es/utils/field-attrs/index.d.ts +1 -1
  99. package/es/utils/field-attrs/index.mjs +16 -13
  100. package/es/utils/get-ref-data.d.ts +1 -0
  101. package/es/utils/get-ref-data.mjs +44 -0
  102. package/es/utils/getFieldSchema.d.ts +1 -3
  103. package/es/utils/getFieldSchema.mjs +69 -0
  104. package/es/utils/index.d.ts +8 -0
  105. package/es/utils/index.mjs +11 -0
  106. package/es/utils/model-transformer.d.ts +46 -0
  107. package/es/utils/model-transformer.mjs +87 -0
  108. package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.d.ts +43 -0
  109. package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.mjs +65 -0
  110. package/es/utils/search/index.d.ts +2 -0
  111. package/es/utils/search/index.mjs +2 -0
  112. package/es/utils/search/search-default-value.d.ts +7 -0
  113. package/es/utils/search/search-default-value.mjs +244 -0
  114. package/es/utils/search/search-hooks.d.ts +6 -0
  115. package/es/utils/search/search-hooks.mjs +67 -0
  116. package/es/utils/useStyle.d.ts +21 -0
  117. package/es/utils/useStyle.mjs +22 -0
  118. package/package.json +33 -11
  119. package/dist/index.esm.min.mjs +0 -89
  120. package/dist/index.min.cjs +0 -1
  121. package/dist/index.system.min.js +0 -1
@@ -0,0 +1,113 @@
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
8
+ function useDependencyToShow(widget) {
9
+ if (widget.props?.displayRule && widget.props?.displayType === DisplayType.RULE)
10
+ /**老版本显隐逻辑 */
11
+ return useVisibileByRuleHook(widget.props, widget.id);
12
+ else return dependencyToShow(widget);
13
+ }
14
+ function dependencyToShow(widget, rowData) {
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);
51
+ }
52
+ /**直接返回计算结果的依赖显隐逻辑 */
53
+ async function dependencyToShowSync(widget, rowData) {
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;
86
+ }
87
+ /**组件集合处理 */
88
+ function useDependencyToShowList(widgetList, rowData) {
89
+ widgetList.forEach((widget) => {
90
+ dependencyToShow(widget, rowData);
91
+ });
92
+ return toRef(() => widgetList.filter((i) => !i.props.hidden));
93
+ }
94
+ function tableWidgetToShow(widget, callback) {
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);
100
+ }
101
+ function tableWidgetByDept(widget) {
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
+ });
111
+ }
112
+ //#endregion
113
+ export { dependencyToShow, dependencyToShowSync, tableWidgetByDept, tableWidgetToShow, useDependencyToShow, useDependencyToShowList };
@@ -0,0 +1,156 @@
1
+ import { ProcessOperateRequest } from '@gct-paas/api/apaas';
2
+ import { pageLayoutModeEnum } from '@gct-paas/core';
3
+ import { LowCodeWidget } from '@gct-paas/schema';
4
+ import { ComponentPublicInstance, Ref } from 'vue';
5
+ import { $httpBizService, $request } from './bizServiceRequest';
6
+ import { EventsConstructor, FunctionType, InitNodeOptions } from './eventType';
7
+ import { ProcessAppRovedData } from './utils/processRovedInfo';
8
+ type ContextConstructor<T extends Context> = new (args: {
9
+ $ref: (key: string) => GctComponent | undefined;
10
+ $asyncRef: (key: string) => Promise<GctComponent>;
11
+ }) => T;
12
+ export type ModalInstance = null | undefined | (ComponentPublicInstance & {
13
+ open: Fn;
14
+ close: Fn;
15
+ });
16
+ export declare class Events<TContext extends Context = Context> {
17
+ #private;
18
+ context: TContext;
19
+ searchVNodes: Record<string, {
20
+ callback: FunctionType;
21
+ comId: string;
22
+ }[]>;
23
+ cssData?: {
24
+ css: Ref<string>;
25
+ load: FunctionType;
26
+ unload: FunctionType;
27
+ };
28
+ pageKey?: string;
29
+ exports: Record<string, FunctionType>;
30
+ /**流程信息 */
31
+ ProcessAppRoved?: ProcessAppRovedData;
32
+ pageLayoutMode?: pageLayoutModeEnum;
33
+ constructor({ js, css, pageKey, ContextVm, }: EventsConstructor & {
34
+ ContextVm: ContextConstructor<TContext>;
35
+ });
36
+ /**初始化流程节点信息 */
37
+ runProcessBySaskId({ taskId, processInstanceId, examineAndApproveState, refFormId, }: IObject): Promise<void>;
38
+ /**保存所有组件的props*/
39
+ runContext(key: string, widget: LowCodeWidget.BasicSchema): void;
40
+ /**触发内置事件 */
41
+ runEventByName(eventName: string, events?: Record<string, IObject>, ...arg: unknown[]): Promise<unknown>;
42
+ /**执行公共函数事件 */
43
+ runExportByName(eventName: string, ...arg: unknown[]): Promise<unknown>;
44
+ /**异步执行公共函数事件 */
45
+ runAsyncExportByName(eventName: string, ...arg: unknown[]): Promise<unknown>;
46
+ initNode(key: string, options: InitNodeOptions): void;
47
+ /**组件销毁 */
48
+ destroyNode(key: string): void;
49
+ initSearchs(key: string, callback: FunctionType, comId: string): void;
50
+ cancelInitSearchs(key: string, comId: string): void;
51
+ runTableBySearch(key: string, data: IObject): void;
52
+ /**
53
+ * 获取组件公用方法 getComponent(identity),根据组件唯一标识获取组件。
54
+ * @param {*} key
55
+ * @returns
56
+ */
57
+ getComponent(key: string): GctComponent | undefined;
58
+ /**
59
+ * 获取组件公用方法 getComponent(identity),根据组件唯一标识获取组件。
60
+ * @param {*} key
61
+ * @returns
62
+ */
63
+ getSyncComponent(key?: string): Promise<GctComponent>;
64
+ /**
65
+ * 指定函数中使用到的组件初始化后才执行
66
+ * @param fun
67
+ * @returns
68
+ */
69
+ getReadyByFun(fun?: FunctionType): Promise<undefined>;
70
+ /**
71
+ * 流程处理
72
+ * @param processDateValue
73
+ * @param data
74
+ */
75
+ processHandle(data: IObject, { opinion, reassignId, signature, countersignUserIds, button, }: ProcessOperateRequest): Promise<void>;
76
+ /**流程审批校验 */
77
+ checkedProcess(formProcessId: string): Promise<undefined>;
78
+ }
79
+ /**作用域 上下文 */
80
+ export declare class Context {
81
+ /**根据key获取当前组件 */
82
+ $ref: (key: string) => GctComponent;
83
+ /**根据key异步获取获取组件 */
84
+ $asyncRef: (key: string) => Promise<GctComponent>;
85
+ /**根据id获取模态框 */
86
+ $getModal?: (key: string) => ModalInstance;
87
+ /**关闭当前上下文模态框 */
88
+ $closeModal?: () => void;
89
+ /**调用第三方服务 */
90
+ $customBizService: {
91
+ post: (path: import('./bizServiceRequest').PathType, query?: IObject, data?: IObject, config?: import('axios').AxiosRequestConfig) => Promise<unknown>;
92
+ get: (path: import('./bizServiceRequest').PathType, query?: IObject, data?: IObject, config?: import('axios').AxiosRequestConfig) => Promise<unknown>;
93
+ put: (path: import('./bizServiceRequest').PathType, query?: IObject, data?: IObject, config?: import('axios').AxiosRequestConfig) => Promise<unknown>;
94
+ delete: (path: import('./bizServiceRequest').PathType, query?: IObject, data?: IObject, config?: import('axios').AxiosRequestConfig) => Promise<unknown>;
95
+ };
96
+ /**组件id和widget 的map */
97
+ gctWidgets: Record<string, LowCodeWidget.BasicSchema>;
98
+ constructor({ $ref, $asyncRef }: IObject);
99
+ /**ctx 下的工具函数 */
100
+ readonly $utility: IObject;
101
+ $httpBizService: typeof $httpBizService;
102
+ $request: typeof $request;
103
+ /**全局loading */
104
+ $loading: {
105
+ mask: HTMLDivElement;
106
+ container: HTMLDivElement;
107
+ spinner: HTMLDivElement;
108
+ createLoadingElement(): void;
109
+ initStyle(): void;
110
+ show(): void;
111
+ hide(): void;
112
+ };
113
+ $getPremission(id: string): boolean;
114
+ /**
115
+ *
116
+ * @param key 组件权限标识
117
+ * @param id 组件id
118
+ */
119
+ $setPremission(key: string, id: string): void;
120
+ /**获取应用全局变量 */
121
+ $getAppGlobalVar(id: string): any;
122
+ /**设置应用全局变量 */
123
+ $setAppGlobalVar(id: string, value: string): void;
124
+ /**获取页面全局变量老版本兼容问题暂时不删除 后续不维护*/
125
+ $getPageGlobalVar(id: string): any;
126
+ /**设置页面变量老版本 兼容问题暂时不删除 后续不维护 */
127
+ $setPageGlobalVar(id: string, value: string): void;
128
+ /**获取页面全局变量 */
129
+ $getPageVar(id: string): any;
130
+ /**设置页面全局变量 */
131
+ $setPageVar(id: string, value: string): void;
132
+ /**根据模态框id 获取上下文 id不传默认页面上下文*/
133
+ $getCtxById(modalKey?: string): any;
134
+ /**设置组件的属性 */
135
+ $setPropsByKey(key: string, fromProp: LowCodeWidget.BasicSchema['props']): void;
136
+ /**获取组件的属性 */
137
+ $getPropsByKey(key: string, PropsKey?: string | string[], root?: boolean): IObject;
138
+ }
139
+ /**
140
+ * 获取组件实例公用方法
141
+ */
142
+ export declare class GctComponent {
143
+ modelKey?: string;
144
+ getValue?: () => {
145
+ id?: string;
146
+ [key: string]: string | [] | undefined;
147
+ };
148
+ setValue?: FunctionType;
149
+ /**提交 */
150
+ submit?: FunctionType;
151
+ /**刷新 */
152
+ reload?: FunctionType;
153
+ key: string;
154
+ constructor(key: string, options: InitNodeOptions);
155
+ }
156
+ export {};
@@ -0,0 +1,389 @@
1
+ import { transformData, transformSourceData } from "../utils/model-transformer.mjs";
2
+ import "../utils/index.mjs";
3
+ import { Globals } from "./utils/runGlobalByPage.mjs";
4
+ import { $httpBizService, $request, BizService } from "./bizServiceRequest.mjs";
5
+ import { globalLoading } from "./utils/globalLoading.mjs";
6
+ import { ProcessAppRovedData } from "./utils/processRovedInfo.mjs";
7
+ import { FormComponents, INNER_EVENT, t } from "@gct-paas/core";
8
+ import dayjs from "dayjs";
9
+ import * as _ from "lodash-es";
10
+ import { cloneDeep, differenceBy } from "lodash-es";
11
+ import BigNumberJS from "bignumber.js";
12
+ import { useStyleTag } from "@vueuse/core";
13
+ import { toRaw } from "vue";
14
+ //#region src/Event/baseEvent.ts
15
+ var Events = class {
16
+ context;
17
+ searchVNodes;
18
+ cssData;
19
+ pageKey;
20
+ exports;
21
+ #Oberver;
22
+ #VNodes;
23
+ /**流程信息 */
24
+ ProcessAppRoved;
25
+ pageLayoutMode;
26
+ constructor({ js, css, pageKey, ContextVm }) {
27
+ this.cssData = this.#createCss(css);
28
+ /**
29
+ * 绑定外部搜索的表格组件
30
+ */
31
+ this.searchVNodes = {};
32
+ /**
33
+ * 存放所有公共事件函数
34
+ */
35
+ this.exports = {};
36
+ /**
37
+ * 当前页面所有组件key和事件对象
38
+ */
39
+ this.#VNodes = {};
40
+ /**
41
+ * 组件订阅中心
42
+ */
43
+ this.#Oberver = {};
44
+ this.context = new ContextVm({
45
+ $ref: this.getComponent.bind(this),
46
+ $asyncRef: this.getSyncComponent.bind(this)
47
+ });
48
+ this.#createFunction(js);
49
+ Globals.setContextByKey(this.context, pageKey);
50
+ this.pageKey = pageKey;
51
+ }
52
+ /**初始化流程节点信息 */
53
+ async runProcessBySaskId({ taskId, processInstanceId, examineAndApproveState, refFormId }) {
54
+ this.ProcessAppRoved = new ProcessAppRovedData({
55
+ taskId,
56
+ processInstanceId,
57
+ examineAndApproveState,
58
+ refFormId
59
+ });
60
+ await this.ProcessAppRoved.readyProcess();
61
+ }
62
+ #createCss(str, attr = {}) {
63
+ if (!str) return;
64
+ const { css, load, unload } = useStyleTag(str, attr);
65
+ return {
66
+ css,
67
+ load,
68
+ unload
69
+ };
70
+ }
71
+ /**保存所有组件的props*/
72
+ runContext(key, widget) {
73
+ this.context.gctWidgets[key] = widget;
74
+ }
75
+ /**触发内置事件 */
76
+ async runEventByName(eventName, events = {}, ...arg) {
77
+ const E = events[eventName];
78
+ let data;
79
+ if (!E) return;
80
+ if (Array.isArray(E)) data = await builtInEvents(E, this.context, arg);
81
+ else {
82
+ const fun = this.exports[E.name];
83
+ if (!fun) throw `函数${E.name}不存在`;
84
+ data = await fun(...arg, toRaw(E.extraParams));
85
+ }
86
+ return data;
87
+ }
88
+ /**执行公共函数事件 */
89
+ async runExportByName(eventName, ...arg) {
90
+ try {
91
+ const fun = this.exports[eventName];
92
+ if (!fun) throw `函数${eventName}不存在`;
93
+ return fun(...arg);
94
+ } catch (error) {
95
+ console.error(error);
96
+ }
97
+ }
98
+ /**异步执行公共函数事件 */
99
+ async runAsyncExportByName(eventName, ...arg) {
100
+ try {
101
+ const fun = this.exports[eventName];
102
+ if (!fun) throw `函数${eventName}不存在`;
103
+ await this.getReadyByFun(fun);
104
+ return fun(...arg);
105
+ } catch (error) {
106
+ console.error(error);
107
+ }
108
+ }
109
+ #createFunction(jsJSON) {
110
+ if (!jsJSON) return;
111
+ try {
112
+ new Function("exports", "CTX", jsJSON)(this.exports, this.context);
113
+ } catch (error) {
114
+ console.error(error, "createFunction");
115
+ }
116
+ }
117
+ initNode(key, options) {
118
+ if (key) {
119
+ this.#VNodes[key] = options;
120
+ this.#publish(key, options);
121
+ }
122
+ }
123
+ /**组件销毁 */
124
+ destroyNode(key) {
125
+ delete this.#VNodes[key];
126
+ delete this.#Oberver[key];
127
+ }
128
+ initSearchs(key, callback, comId) {
129
+ if (!key) return;
130
+ if (this.searchVNodes[key]) {
131
+ /**添加 comId 组件标识 处理显隐藏控制引起的 重复注册回调函数的问题*/
132
+ const item = this.searchVNodes[key].find((i) => i.comId === comId);
133
+ if (item) item.callback = callback;
134
+ else this.searchVNodes[key].push({
135
+ callback,
136
+ comId
137
+ });
138
+ } else this.searchVNodes[key] = [{
139
+ callback,
140
+ comId
141
+ }];
142
+ }
143
+ cancelInitSearchs(key, comId) {
144
+ if (!key || !this.searchVNodes[key]) return;
145
+ this.searchVNodes[key] = this.searchVNodes[key].filter((i) => i.comId !== comId);
146
+ if (this.searchVNodes[key].length === 0) delete this.searchVNodes[key];
147
+ }
148
+ runTableBySearch(key, data) {
149
+ (this.searchVNodes[key] || []).forEach(({ callback }) => callback(data));
150
+ }
151
+ /**
152
+ * 组件初始化订阅
153
+ * @param {*} key 组件唯一key
154
+ * @param {*} eventName 事件名称
155
+ */
156
+ #subscribeready(key, callback) {
157
+ const options = this.#VNodes[key];
158
+ if (options) callback(key, options);
159
+ else if (this.#Oberver[key]) this.#Oberver[key].push(callback);
160
+ else this.#Oberver[key] = [callback];
161
+ }
162
+ /**
163
+ *
164
+ * @param key 执行回调
165
+ */
166
+ #publish(key, options) {
167
+ if (this.#Oberver[key]) this.#Oberver[key].forEach((fun) => {
168
+ fun(options);
169
+ });
170
+ }
171
+ /**
172
+ * 获取组件公用方法 getComponent(identity),根据组件唯一标识获取组件。
173
+ * @param {*} key
174
+ * @returns
175
+ */
176
+ getComponent(key) {
177
+ const options = this.#VNodes[key];
178
+ if (options) return new GctComponent(key, options);
179
+ console.error(key + "组件不存在或者未初始化");
180
+ }
181
+ /**
182
+ * 获取组件公用方法 getComponent(identity),根据组件唯一标识获取组件。
183
+ * @param {*} key
184
+ * @returns
185
+ */
186
+ getSyncComponent(key) {
187
+ if (!key) return Promise.reject("标识不能为空");
188
+ const options = this.#VNodes[key];
189
+ if (options) return Promise.resolve(new GctComponent(key, options));
190
+ return new Promise((resolve, reject) => {
191
+ const timer = setTimeout(() => {
192
+ reject(key + "不存在或者被隐藏");
193
+ }, 3e4);
194
+ this.#subscribeready(key, (options) => {
195
+ clearTimeout(timer);
196
+ resolve(new GctComponent(key, options));
197
+ });
198
+ });
199
+ }
200
+ /**
201
+ * 指定函数中使用到的组件初始化后才执行
202
+ * @param fun
203
+ * @returns
204
+ */
205
+ async getReadyByFun(fun) {
206
+ if (typeof fun !== "function") return Promise.reject("参数必须是函数");
207
+ const P = String(fun).match(/\$ref\((["'A-Za-z0-9_-]+)\)/g)?.map((i) => {
208
+ const key = i.match(/\$ref\(['|"]([A-Za-z0-9_-]+)['|"]\)/)?.[1];
209
+ return this.getSyncComponent(key);
210
+ }) || [];
211
+ await Promise.all(P);
212
+ }
213
+ /**
214
+ * 流程处理
215
+ * @param processDateValue
216
+ * @param data
217
+ */
218
+ async processHandle(data, { opinion, reassignId, signature, countersignUserIds, button }) {
219
+ const { taskId, processInstanceId } = this.ProcessAppRoved;
220
+ const processData = {
221
+ procInstId: processInstanceId,
222
+ data,
223
+ opinion,
224
+ button,
225
+ countersignUserIds,
226
+ taskId,
227
+ signature,
228
+ reassignId
229
+ };
230
+ await _gct.api.apaas.pmProcessEngine.postProcExecute(processData);
231
+ }
232
+ /**流程审批校验 */
233
+ async checkedProcess(formProcessId) {
234
+ const { processId } = this.ProcessAppRoved || {};
235
+ if (!processId) return Promise.reject(t("sys.process.pleaseInitiateTheProcessFirst"));
236
+ if (formProcessId !== processId) return Promise.reject(t("sys.process.processInstanceMismatch"));
237
+ }
238
+ };
239
+ /**作用域 上下文 */
240
+ var Context = class {
241
+ /**根据key获取当前组件 */
242
+ $ref;
243
+ /**根据key异步获取获取组件 */
244
+ $asyncRef;
245
+ /**根据id获取模态框 */
246
+ $getModal;
247
+ /**关闭当前上下文模态框 */
248
+ $closeModal;
249
+ /**调用第三方服务 */
250
+ $customBizService = BizService;
251
+ /**组件id和widget 的map */
252
+ gctWidgets = {};
253
+ constructor({ $ref, $asyncRef }) {
254
+ this.$asyncRef = $asyncRef;
255
+ this.$ref = $ref;
256
+ }
257
+ /**ctx 下的工具函数 */
258
+ $utility = {
259
+ _,
260
+ cloneDeep,
261
+ differenceBy,
262
+ dayjs,
263
+ BigNumber: BigNumberJS,
264
+ plus(a, b) {
265
+ return new BigNumberJS(a).plus(new BigNumberJS(b)).toNumber();
266
+ },
267
+ minus(a, b) {
268
+ return new BigNumberJS(a).minus(new BigNumberJS(b)).toNumber();
269
+ },
270
+ multipliedBy(a, b) {
271
+ return new BigNumberJS(a).multipliedBy(new BigNumberJS(b)).toNumber();
272
+ },
273
+ div(a, b) {
274
+ return new BigNumberJS(a).div(new BigNumberJS(b)).toNumber();
275
+ },
276
+ transformSourceData,
277
+ transformData
278
+ };
279
+ $httpBizService = $httpBizService;
280
+ $request = $request;
281
+ /**全局loading */
282
+ $loading = globalLoading;
283
+ $getPremission(id) {
284
+ return Globals.getPremission(id);
285
+ }
286
+ /**
287
+ *
288
+ * @param key 组件权限标识
289
+ * @param id 组件id
290
+ */
291
+ $setPremission(key, id) {
292
+ Globals.setPremission(key, id);
293
+ }
294
+ /**获取应用全局变量 */
295
+ $getAppGlobalVar(id) {
296
+ return Globals.getGlobalVar(id);
297
+ }
298
+ /**设置应用全局变量 */
299
+ $setAppGlobalVar(id, value) {
300
+ Globals.setGlobalVar(id, value);
301
+ }
302
+ /**获取页面全局变量老版本兼容问题暂时不删除 后续不维护*/
303
+ $getPageGlobalVar(id) {
304
+ return Globals.getPageGlobalVar(id);
305
+ }
306
+ /**设置页面变量老版本 兼容问题暂时不删除 后续不维护 */
307
+ $setPageGlobalVar(id, value) {
308
+ Globals.setPageGlobalVar(id, value);
309
+ }
310
+ /**获取页面全局变量 */
311
+ $getPageVar(id) {
312
+ return Globals.getPageVar(id);
313
+ }
314
+ /**设置页面全局变量 */
315
+ $setPageVar(id, value) {
316
+ Globals.setPageVar(id, value);
317
+ }
318
+ /**根据模态框id 获取上下文 id不传默认页面上下文*/
319
+ $getCtxById(modalKey) {
320
+ return Globals.getContextByKey(modalKey);
321
+ }
322
+ /**设置组件的属性 */
323
+ $setPropsByKey(key, fromProp) {
324
+ const toProps = this.gctWidgets[key]?.props;
325
+ if (!toProps) return;
326
+ for (const k in fromProp) toProps[k] = fromProp[k];
327
+ }
328
+ /**获取组件的属性 */
329
+ $getPropsByKey(key, PropsKey = [], root) {
330
+ const widget = this.gctWidgets[key];
331
+ if (!widget) return {};
332
+ const props = root || !widget.props ? widget : widget.props;
333
+ if (typeof PropsKey === "string") PropsKey = [PropsKey];
334
+ return PropsKey.reduce((pre, curr) => {
335
+ pre[curr] = props[curr];
336
+ return pre;
337
+ }, {});
338
+ }
339
+ };
340
+ /**
341
+ * 获取组件实例公用方法
342
+ */
343
+ var GctComponent = class {
344
+ modelKey;
345
+ getValue;
346
+ setValue;
347
+ /**提交 */
348
+ submit;
349
+ /**刷新 */
350
+ reload;
351
+ key;
352
+ constructor(key, options) {
353
+ this.key = key;
354
+ const elRef = options.elRef;
355
+ Object.keys(elRef).forEach((k) => {
356
+ this[k] = elRef[k];
357
+ });
358
+ }
359
+ };
360
+ /**
361
+ * 执行内置事件
362
+ * @param eventList
363
+ */
364
+ async function builtInEvents(eventList, context, args) {
365
+ const allEvent = eventList.map(transformEventFun.bind(context, args));
366
+ await Promise.all(allEvent);
367
+ }
368
+ async function transformEventFun(args, item) {
369
+ const { name, refId, scopeId, modalTitle } = item;
370
+ const ids = modalTitle?.split(".") || [];
371
+ let widget;
372
+ if (ids.length > 1) {
373
+ const orgWidget = this.gctWidgets?.[ids[0]] || {};
374
+ const opes = [];
375
+ getAllOpe(opes, orgWidget);
376
+ widget = opes.find((i) => i.id === ids[1]) || {};
377
+ } else if (ids.length) widget = this.gctWidgets?.[ids[0]];
378
+ if (name === INNER_EVENT.OPEN_MODAL) await this.$getModal(refId).open({ title: widget?.props?.title });
379
+ if (name === INNER_EVENT.CLOSE_MODAL) if (refId) await this.$getModal(refId).close();
380
+ else await this.$closeModal();
381
+ if (name === INNER_EVENT.REFRESH_TABLE) await (await this.$getCtxById(scopeId).$asyncRef(refId)).reload(args ? args[0] : null);
382
+ }
383
+ function getAllOpe(arr, widget) {
384
+ const children = widget.children || [];
385
+ for (const i of children) if (i.type && i.type == FormComponents.CustomButton) arr.push(i);
386
+ else if (i.children?.length) getAllOpe(arr, i);
387
+ }
388
+ //#endregion
389
+ export { Context, Events, GctComponent };
@@ -0,0 +1,26 @@
1
+ import { BizServiceEnum, EntityModelCategoryEnum } from '@gct-paas/core';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ export declare const BizService: {
4
+ post: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
5
+ get: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
6
+ put: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
7
+ delete: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
8
+ };
9
+ /**
10
+ * 系统内置业务服务请求
11
+ * @param path
12
+ * @param params
13
+ * @param config
14
+ * @returns
15
+ */
16
+ export declare function $httpBizService(path: PathType, params: Record<string, unknown>, ...config: IObject[]): Promise<unknown>;
17
+ /**post 业务服务请求 */
18
+ export declare function $request(modelKey: string, action: PathType['action'], { body, query }?: IObject, config?: AxiosRequestConfig): Promise<unknown>;
19
+ type BizServiceParams = Record<string, unknown>;
20
+ export interface PathType {
21
+ key: string;
22
+ action: keyof typeof BizServiceEnum;
23
+ modelCategory?: EntityModelCategoryEnum;
24
+ }
25
+ export type BizServiceMethod = (path: PathType, params: BizServiceParams, ...args: unknown[]) => Promise<unknown>;
26
+ export {};