@gct-paas/render 0.1.4-dev.9 → 0.1.5-dev.1

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