@dhccmobile/vue3-lo-form 1.1.41 → 2.0.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.
- package/.env.local.bak +6 -6
- package/.eslintrc.js +28 -28
- package/README.md +70 -62
- package/babel.config.js +3 -3
- package/dist/vue3-lo-form.common.js +7700 -107778
- package/dist/vue3-lo-form.common.js.map +1 -1
- package/dist/vue3-lo-form.css +1 -1
- package/dist/vue3-lo-form.umd.js +7773 -107851
- package/dist/vue3-lo-form.umd.js.map +1 -1
- package/dist/vue3-lo-form.umd.min.js +1 -56
- package/dist/vue3-lo-form.umd.min.js.map +1 -1
- package/package.json +65 -61
- package/public/index.html +17 -17
- package/public/js/pinyin.ts +101 -101
- package/src/App.vue +741 -741
- package/src/components/form/DvForm.vue +642 -642
- package/src/components/form/DvFormLayout.vue +1569 -1569
- package/src/components/form/StretchText.vue +90 -90
- package/src/components/index.ts +3 -3
- package/src/constants/config/form-template.config.ts +32 -32
- package/src/constants/config/form.config.ts +4 -4
- package/src/constants/config/storage.config.ts +4 -4
- package/src/constants/encode-assets/svg.ts +11 -11
- package/src/constants/enum/builtIn-label.enum.ts +5 -5
- package/src/constants/enum/cache-type.enum.ts +7 -7
- package/src/constants/enum/control-format-type.enum.ts +9 -9
- package/src/constants/enum/dynamic-option-type.enum.ts +6 -6
- package/src/constants/enum/form-bus-attr.enum.ts +8 -8
- package/src/constants/enum/form-field-class.enum.ts +7 -7
- package/src/constants/enum/form-field-type.enum.ts +25 -25
- package/src/constants/enum/form-type.enum.ts +5 -5
- package/src/constants/enum/index.ts +19 -19
- package/src/constants/enum/lateral-arrangement.enum.ts +9 -9
- package/src/constants/enum/money-unit.enum.ts +6 -6
- package/src/constants/enum/option-type.enum.ts +5 -5
- package/src/constants/enum/submitted-type.enum.ts +32 -31
- package/src/constants/enum/support-upload-type.enum.ts +5 -5
- package/src/constants/enum/switch.enum.ts +5 -5
- package/src/constants/enum/upload-type.enum.ts +17 -17
- package/src/constants/enum/validate-rules.enum.ts +25 -25
- package/src/constants/enum/validate-status.enum.ts +8 -8
- package/src/constants/enum/vertical-arrangement.enum.ts +7 -7
- package/src/constants/enum/zoom-type.ts +6 -6
- package/src/constants/index.ts +3 -3
- package/src/core/FormApi.ts +1238 -1238
- package/src/core/index.ts +1 -1
- package/src/domain/AbstractControl.ts +6 -6
- package/src/domain/Control.ts +14 -14
- package/src/domain/CustomFormat.ts +6 -6
- package/src/domain/DesForm.ts +48 -48
- package/src/domain/DesFormControl.ts +241 -241
- package/src/domain/DesFormLayout.ts +51 -51
- package/src/domain/FieldChangeHistory.ts +9 -9
- package/src/domain/FormConfig.ts +15 -15
- package/src/domain/FormControl.ts +125 -125
- package/src/domain/FormEnum.ts +9 -9
- package/src/domain/FormGroup.ts +42 -42
- package/src/domain/FormRestfulResponse.ts +6 -6
- package/src/domain/ProvideInjectData.ts +10 -10
- package/src/domain/SysDictDetail.ts +38 -38
- package/src/domain/SysDictInfo.ts +40 -40
- package/src/domain/SysDictTreeDetail.ts +52 -52
- package/src/domain/index.ts +12 -12
- package/src/filtres/amount-capitalization.filter.ts +154 -147
- package/src/filtres/extract-options.filter.ts +53 -53
- package/src/filtres/generate-grid-column-end.filter.ts +22 -22
- package/src/filtres/generate-grid-template-columns.filter.ts +24 -24
- package/src/filtres/switch-enum-convert.filter.ts +18 -18
- package/src/filtres/zoom-multiple.filter.ts +32 -32
- package/src/index.ts +73 -73
- package/src/main.ts +17 -17
- package/src/services/api.service.ts +73 -73
- package/src/services/clean-local-forage.service.ts +58 -58
- package/src/services/date-format.service.ts +74 -74
- package/src/services/dict-local-forage.service.ts +58 -58
- package/src/services/form-bean-utils.service.ts +41 -41
- package/src/services/form-local-forage.service.ts +59 -59
- package/src/services/form-tools.service.ts +739 -659
- package/src/services/form-tree-node-convert.service.ts +240 -240
- package/src/services/form-validate.service.ts +103 -103
- package/src/services/index.ts +9 -9
- package/src/services/router.service.ts +96 -96
- package/src/services/validate-generator.service.ts +710 -710
- package/src/shims-vue.d.ts +6 -6
- package/src/store/dict.store.ts +63 -63
- package/src/store/form.store.ts +32 -32
- package/src/store/index.ts +2 -2
- package/src/styles/datePicker.scss +125 -125
- package/src/styles/index.scss +195 -195
- package/src/styles/theme1.scss +277 -277
- package/src/styles/theme2.scss +376 -376
- package/src/styles/themes.scss +9 -9
- package/src/types/vfForm.ts +11 -11
- package/tsconfig.json +40 -40
- package/types/components/index.d.ts +3 -3
- package/types/constants/config/form-template.config.d.ts +30 -30
- package/types/constants/config/form.config.d.ts +4 -4
- package/types/constants/config/storage.config.d.ts +4 -4
- package/types/constants/encode-assets/svg.d.ts +5 -5
- package/types/constants/enum/builtIn-label.enum.d.ts +7 -7
- package/types/constants/enum/cache-type.enum.d.ts +15 -15
- package/types/constants/enum/control-format-type.enum.d.ts +23 -23
- package/types/constants/enum/dynamic-option-type.enum.d.ts +11 -11
- package/types/constants/enum/form-bus-attr.enum.d.ts +19 -19
- package/types/constants/enum/form-field-class.enum.d.ts +18 -18
- package/types/constants/enum/form-field-type.enum.d.ts +111 -111
- package/types/constants/enum/form-type.enum.d.ts +11 -11
- package/types/constants/enum/index.d.ts +19 -19
- package/types/constants/enum/lateral-arrangement.enum.d.ts +23 -23
- package/types/constants/enum/money-unit.enum.d.ts +15 -15
- package/types/constants/enum/option-type.enum.d.ts +11 -11
- package/types/constants/enum/submitted-type.enum.d.ts +115 -111
- package/types/constants/enum/support-upload-type.enum.d.ts +11 -11
- package/types/constants/enum/switch.enum.d.ts +11 -11
- package/types/constants/enum/upload-type.enum.d.ts +59 -59
- package/types/constants/enum/validate-rules.enum.d.ts +2 -2
- package/types/constants/enum/validate-status.enum.d.ts +2 -2
- package/types/constants/enum/vertical-arrangement.enum.d.ts +21 -21
- package/types/constants/enum/zoom-type.d.ts +15 -15
- package/types/constants/index.d.ts +3 -3
- package/types/core/FormApi.d.ts +376 -376
- package/types/core/index.d.ts +1 -1
- package/types/domain/AbstractControl.d.ts +5 -5
- package/types/domain/Control.d.ts +13 -13
- package/types/domain/CustomFormat.d.ts +5 -5
- package/types/domain/DesForm.d.ts +32 -32
- package/types/domain/DesFormControl.d.ts +160 -160
- package/types/domain/DesFormLayout.d.ts +33 -33
- package/types/domain/FieldChangeHistory.d.ts +9 -9
- package/types/domain/FormConfig.d.ts +15 -15
- package/types/domain/FormControl.d.ts +60 -60
- package/types/domain/FormEnum.d.ts +10 -10
- package/types/domain/FormGroup.d.ts +27 -27
- package/types/domain/FormRestfulResponse.d.ts +6 -6
- package/types/domain/ProvideInjectData.d.ts +10 -10
- package/types/domain/SysDictDetail.d.ts +24 -24
- package/types/domain/SysDictInfo.d.ts +26 -26
- package/types/domain/SysDictTreeDetail.d.ts +34 -34
- package/types/domain/index.d.ts +12 -12
- package/types/filtres/amount-capitalization.filter.d.ts +7 -7
- package/types/filtres/extract-options.filter.d.ts +13 -13
- package/types/filtres/generate-grid-column-end.filter.d.ts +11 -11
- package/types/filtres/generate-grid-template-columns.filter.d.ts +11 -11
- package/types/filtres/switch-enum-convert.filter.d.ts +2 -2
- package/types/filtres/zoom-multiple.filter.d.ts +3 -3
- package/types/index.d.ts +13 -13
- package/types/main.d.ts +2 -2
- package/types/services/api.service.d.ts +25 -25
- package/types/services/clean-local-forage.service.d.ts +28 -28
- package/types/services/date-format.service.d.ts +21 -21
- package/types/services/dict-local-forage.service.d.ts +28 -28
- package/types/services/form-bean-utils.service.d.ts +23 -23
- package/types/services/form-local-forage.service.d.ts +28 -28
- package/types/services/form-tools.service.d.ts +153 -144
- package/types/services/form-tree-node-convert.service.d.ts +104 -104
- package/types/services/form-validate.service.d.ts +32 -32
- package/types/services/index.d.ts +9 -9
- package/types/services/router.service.d.ts +40 -40
- package/types/services/validate-generator.service.d.ts +154 -154
- package/types/store/dict.store.d.ts +29 -29
- package/types/store/form.store.d.ts +17 -17
- package/types/store/index.d.ts +2 -2
- package/types/types/vfForm.d.ts +10 -10
- package/vue.config.js +38 -29
- package/dhccmobile-vue3-lo-form-1.1.41.tgz +0 -0
|
@@ -1,659 +1,739 @@
|
|
|
1
|
-
import { FormConfig } from "../domain/FormConfig";
|
|
2
|
-
import { FormRestfulResponse } from "../domain/FormRestfulResponse";
|
|
3
|
-
import { DesForm } from "../domain/DesForm";
|
|
4
|
-
import { DesFormControl } from "../domain/DesFormControl";
|
|
5
|
-
import { DesFormLayout } from "../domain/DesFormLayout";
|
|
6
|
-
import { FormFieldClass } from "../constants/enum/form-field-class.enum";
|
|
7
|
-
import { Control } from "../domain/Control";
|
|
8
|
-
import { FormFieldType } from "../constants/enum/form-field-type.enum";
|
|
9
|
-
import { Switch } from "../constants/enum/switch.enum";
|
|
10
|
-
import { formTreeNodeConvertService, MapNodeOptions, NodeContrast, NzNodeContrast, NzTreeNodeOptions } from "./form-tree-node-convert.service";
|
|
11
|
-
import { formBeanUtilsService } from "./form-bean-utils.service";
|
|
12
|
-
import { apiService } from "./api.service";
|
|
13
|
-
import { formStore } from "../store/form.store";
|
|
14
|
-
import { DynamicOptionType } from "../constants/enum/dynamic-option-type.enum";
|
|
15
|
-
import { dictStore } from "../store";
|
|
16
|
-
import { SysDictInfo } from "../domain/SysDictInfo";
|
|
17
|
-
import { DEFAULT_DICT_URL, DEFAULT_FORM_FILE_NAME } from "../constants/config/form.config";
|
|
18
|
-
import { CacheType } from "../constants/enum/cache-type.enum";
|
|
19
|
-
import { routerService } from "./router.service";
|
|
20
|
-
import { FormApi } from "../core/FormApi";
|
|
21
|
-
import { formValidateService } from "./form-validate.service";
|
|
22
|
-
|
|
23
|
-
interface DictionaryFormatCollection {
|
|
24
|
-
sysDictDetailOptions?: NzTreeNodeOptions[];
|
|
25
|
-
sysDictTreeDetailOptions?: NzTreeNodeOptions[];
|
|
26
|
-
mapSysDictDetailOptions?: MapNodeOptions;
|
|
27
|
-
mapSysDictTreeDetailOptions?: MapNodeOptions;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class FormToolsService {
|
|
31
|
-
private static readonly LOAD_SUCCESS = { code: 1, msg: "加载成功" }; // 操作成功提示
|
|
32
|
-
private static readonly LOAD_FAIL = { code: 1, msg: "加载失败" }; // 操作失败提示
|
|
33
|
-
private static IS_FIRST_LOADED = false; // 是否经过首次初始化
|
|
34
|
-
private nodeContrast: NodeContrast = { id: "layoutId", parentId: "parentLayoutId", children: "subDesFormLayout" };
|
|
35
|
-
private dictDetailsContrast: NodeContrast = { id: "dicEntryPk", parentId: "suprDicPk", children: "children" };
|
|
36
|
-
private nzDictDetailsContrastContrast: NzNodeContrast = { key: "dicEntryPk", title: "dicValue", children: "children", value: "dicKey" };
|
|
37
|
-
private dictTreeDetailsContrast: NodeContrast = { id: "dicEntryPk", parentId: "suprDicPk", children: "children" };
|
|
38
|
-
private nzDictTreeDetailsContrastContrast: NzNodeContrast = { key: "dicEntryPk", title: "dicValue", children: "children", value: "dicKey" };
|
|
39
|
-
private desForms: DesForm[] = []; // 表单配置缓存
|
|
40
|
-
|
|
41
|
-
sysDictDetailOptions: NzTreeNodeOptions[] = [];
|
|
42
|
-
sysDictTreeDetailOptions: NzTreeNodeOptions[] = [];
|
|
43
|
-
mapSysDictDetailOptions: MapNodeOptions | undefined;
|
|
44
|
-
mapSysDictTreeDetailOptions: MapNodeOptions | undefined;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* @
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return this.
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
* @
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
* @
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
* @
|
|
495
|
-
* @
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
1
|
+
import { FormConfig } from "../domain/FormConfig";
|
|
2
|
+
import { FormRestfulResponse } from "../domain/FormRestfulResponse";
|
|
3
|
+
import { DesForm } from "../domain/DesForm";
|
|
4
|
+
import { DesFormControl } from "../domain/DesFormControl";
|
|
5
|
+
import { DesFormLayout } from "../domain/DesFormLayout";
|
|
6
|
+
import { FormFieldClass } from "../constants/enum/form-field-class.enum";
|
|
7
|
+
import { Control } from "../domain/Control";
|
|
8
|
+
import { FormFieldType } from "../constants/enum/form-field-type.enum";
|
|
9
|
+
import { Switch } from "../constants/enum/switch.enum";
|
|
10
|
+
import { formTreeNodeConvertService, MapNodeOptions, NodeContrast, NzNodeContrast, NzTreeNodeOptions } from "./form-tree-node-convert.service";
|
|
11
|
+
import { formBeanUtilsService } from "./form-bean-utils.service";
|
|
12
|
+
import { apiService } from "./api.service";
|
|
13
|
+
import { formStore } from "../store/form.store";
|
|
14
|
+
import { DynamicOptionType } from "../constants/enum/dynamic-option-type.enum";
|
|
15
|
+
import { dictStore } from "../store";
|
|
16
|
+
import { SysDictInfo } from "../domain/SysDictInfo";
|
|
17
|
+
import { DEFAULT_DICT_URL, DEFAULT_FORM_FILE_NAME } from "../constants/config/form.config";
|
|
18
|
+
import { CacheType } from "../constants/enum/cache-type.enum";
|
|
19
|
+
import { routerService } from "./router.service";
|
|
20
|
+
import { FormApi } from "../core/FormApi";
|
|
21
|
+
import { formValidateService } from "./form-validate.service";
|
|
22
|
+
|
|
23
|
+
interface DictionaryFormatCollection {
|
|
24
|
+
sysDictDetailOptions?: NzTreeNodeOptions[];
|
|
25
|
+
sysDictTreeDetailOptions?: NzTreeNodeOptions[];
|
|
26
|
+
mapSysDictDetailOptions?: MapNodeOptions;
|
|
27
|
+
mapSysDictTreeDetailOptions?: MapNodeOptions;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class FormToolsService {
|
|
31
|
+
private static readonly LOAD_SUCCESS = { code: 1, msg: "加载成功" }; // 操作成功提示
|
|
32
|
+
private static readonly LOAD_FAIL = { code: 1, msg: "加载失败" }; // 操作失败提示
|
|
33
|
+
private static IS_FIRST_LOADED = false; // 是否经过首次初始化
|
|
34
|
+
private nodeContrast: NodeContrast = { id: "layoutId", parentId: "parentLayoutId", children: "subDesFormLayout" };
|
|
35
|
+
private dictDetailsContrast: NodeContrast = { id: "dicEntryPk", parentId: "suprDicPk", children: "children" };
|
|
36
|
+
private nzDictDetailsContrastContrast: NzNodeContrast = { key: "dicEntryPk", title: "dicValue", children: "children", value: "dicKey" };
|
|
37
|
+
private dictTreeDetailsContrast: NodeContrast = { id: "dicEntryPk", parentId: "suprDicPk", children: "children" };
|
|
38
|
+
private nzDictTreeDetailsContrastContrast: NzNodeContrast = { key: "dicEntryPk", title: "dicValue", children: "children", value: "dicKey" };
|
|
39
|
+
private desForms: DesForm[] = []; // 表单配置缓存
|
|
40
|
+
|
|
41
|
+
sysDictDetailOptions: NzTreeNodeOptions[] = [];
|
|
42
|
+
sysDictTreeDetailOptions: NzTreeNodeOptions[] = [];
|
|
43
|
+
mapSysDictDetailOptions: MapNodeOptions | undefined;
|
|
44
|
+
mapSysDictTreeDetailOptions: MapNodeOptions | undefined;
|
|
45
|
+
|
|
46
|
+
supHoliday?: boolean = false; // 节假日支持
|
|
47
|
+
|
|
48
|
+
constructor() {}
|
|
49
|
+
|
|
50
|
+
get formConfig(): Partial<FormConfig> {
|
|
51
|
+
if ((window as any).$app.config.globalProperties.$qlForm != null) {
|
|
52
|
+
return (window as any).$app.config.globalProperties.$qlForm;
|
|
53
|
+
}
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setSupHoliday(bool: boolean) {
|
|
58
|
+
this.supHoliday = bool;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setFormDisabledColor(color = "#f0f0f0") {
|
|
62
|
+
document.body.style.setProperty("--lo-form-disabled", color);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @description: 检查是否经过首次初始化并初始化
|
|
67
|
+
* @author ChenRui
|
|
68
|
+
* @date 2021/1/5 23:04
|
|
69
|
+
*/
|
|
70
|
+
checkFirstLoadAndInitDesign(): Promise<FormRestfulResponse> {
|
|
71
|
+
if (FormToolsService.IS_FIRST_LOADED) {
|
|
72
|
+
return Promise.resolve({
|
|
73
|
+
code: 1,
|
|
74
|
+
msg: "检查到已经过首次加载,不在执行加载逻辑",
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
return this.init().then((res: FormRestfulResponse) => {
|
|
78
|
+
FormToolsService.IS_FIRST_LOADED = true;
|
|
79
|
+
return res;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @description: 初始化
|
|
86
|
+
* @author ChenRui
|
|
87
|
+
* @date 2021/3/12 11:02
|
|
88
|
+
*/
|
|
89
|
+
init(): Promise<FormRestfulResponse> {
|
|
90
|
+
return Promise.all([this.initDesign(), this.initDict(), this.selectHolidays()]).then(([designRes, dictRes]: any) => {
|
|
91
|
+
const code = designRes.code === 1 && dictRes.code === 1 ? 1 : 0;
|
|
92
|
+
return { code, msg: designRes.msg + "; " + dictRes.msg };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @Description 初始化节假日数据
|
|
98
|
+
* @Author JiangTao
|
|
99
|
+
* @Date 2024-04-16 下午 04:11
|
|
100
|
+
*/
|
|
101
|
+
selectHolidays(): Promise<FormRestfulResponse> {
|
|
102
|
+
if (this.formConfig.url && this.supHoliday) {
|
|
103
|
+
const url = this.formConfig.url + "/ms-loong/api/v1/basic-form-weekday/query-all-by-year";
|
|
104
|
+
return this.fetch(url, {}, undefined, "POST").then((res: FormRestfulResponse) => {
|
|
105
|
+
if (res != null && (res.code === 1 || String(res.code) === String(200))) {
|
|
106
|
+
if (res.data != null) {
|
|
107
|
+
localStorage.setItem("traddayList", JSON.stringify(res.data.traddayList)); // 交易日集合
|
|
108
|
+
localStorage.setItem("weekdayList", JSON.stringify(res.data.weekdayList)); // 节假日集合
|
|
109
|
+
localStorage.setItem("workdayList", JSON.stringify(res.data.workdayList)); // 工作日集合
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @description: 初始化表单设计
|
|
120
|
+
* @author ChenRui
|
|
121
|
+
* @date 2020/11/20 10:55
|
|
122
|
+
*/
|
|
123
|
+
initDesign(): Promise<FormRestfulResponse> {
|
|
124
|
+
return Promise.all([formStore.getForms(), formStore.getVersion()]).then(([forms, formVersion]: any[]) => {
|
|
125
|
+
if (this.formConfig.loadMode === "static") {
|
|
126
|
+
if (forms != null) {
|
|
127
|
+
this.desForms = forms;
|
|
128
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
129
|
+
} else {
|
|
130
|
+
return this.loadDesign([this.formConfig.url || DEFAULT_FORM_FILE_NAME]);
|
|
131
|
+
}
|
|
132
|
+
} else if (this.formConfig.loadMode === "dynamic") {
|
|
133
|
+
if (this.formConfig.appId != null && this.formConfig.appId !== "") {
|
|
134
|
+
const query = {
|
|
135
|
+
appId: this.formConfig.appId,
|
|
136
|
+
cacheType: CacheType.FORM.code,
|
|
137
|
+
};
|
|
138
|
+
const url = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/query-cacheversion-by-appid-cachetype";
|
|
139
|
+
return this.fetch(url!, query).then((res: FormRestfulResponse) => {
|
|
140
|
+
if (res != null && res.code === 1) {
|
|
141
|
+
if (res.data != null && res.data.desCacheVersion != null) {
|
|
142
|
+
if (String(formVersion) !== String(res.data.desCacheVersion.cacheVersionNumber)) {
|
|
143
|
+
const formUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=" + res.data.desCacheVersion.storageAddress;
|
|
144
|
+
return this.loadDesign([formUrl]).then((resEx: FormRestfulResponse) => {
|
|
145
|
+
if (resEx.code === 1) {
|
|
146
|
+
formStore.setVersion(res.data.desCacheVersion.cacheVersionNumber);
|
|
147
|
+
}
|
|
148
|
+
return resEx;
|
|
149
|
+
});
|
|
150
|
+
} else {
|
|
151
|
+
if (forms != null) {
|
|
152
|
+
this.desForms = forms;
|
|
153
|
+
}
|
|
154
|
+
console.log(this.desForms);
|
|
155
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
return Promise.resolve({ code: 1, msg: "暂无版本数据" });
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
return Promise.resolve(FormToolsService.LOAD_FAIL);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
return Promise.resolve({
|
|
166
|
+
code: 0,
|
|
167
|
+
msg: "动态加载需指定当前系统编号(appId)",
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
} else if (this.formConfig.loadMode === "merge") {
|
|
171
|
+
if (this.formConfig.urls) {
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
this.loadDesign(this.formConfig.urls || []).then(() => {
|
|
174
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
return this.mergeUrlByType(CacheType.FORM.code).then((response: any) => {
|
|
179
|
+
if (formVersion === response.cacheVersionNumber) {
|
|
180
|
+
if (forms) {
|
|
181
|
+
this.desForms = forms;
|
|
182
|
+
}
|
|
183
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
184
|
+
} else {
|
|
185
|
+
return new Promise((resolve) => {
|
|
186
|
+
this.loadDesign(response.storageAddress).then(() => {
|
|
187
|
+
formStore.setVersion(response.cacheVersionNumber);
|
|
188
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
} else if (this.formConfig.loadMode === "merge_cacheId") {
|
|
195
|
+
// 按照缓存编号查询表单数据,2024年8月15日14:03:24
|
|
196
|
+
return this.mergeUrlByCacheId(CacheType.FORM.code).then((response: any) => {
|
|
197
|
+
if (formVersion === response.cacheVersionNumber) {
|
|
198
|
+
if (forms) {
|
|
199
|
+
this.desForms = forms;
|
|
200
|
+
}
|
|
201
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
202
|
+
} else {
|
|
203
|
+
return new Promise((resolve) => {
|
|
204
|
+
this.loadDesign(response.storageAddress).then(() => {
|
|
205
|
+
formStore.setVersion(response.cacheVersionNumber);
|
|
206
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return Promise.resolve(FormToolsService.LOAD_FAIL);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @description: 获取表单或字典数据地址
|
|
218
|
+
* @author ZPFly
|
|
219
|
+
* @date 2022/10/18 20:43
|
|
220
|
+
*/
|
|
221
|
+
private mergeUrlByType(type: string): Promise<any> {
|
|
222
|
+
const url = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/query-batch-appids-cachetype";
|
|
223
|
+
const downloadUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=";
|
|
224
|
+
const query = {
|
|
225
|
+
appIds: this.formConfig.appId,
|
|
226
|
+
cacheType: type,
|
|
227
|
+
};
|
|
228
|
+
return this.fetch(url!, query).then((resp: any) => {
|
|
229
|
+
const response: any = {};
|
|
230
|
+
const address: string[] = [];
|
|
231
|
+
const cacheVersionNumber: any[] = [];
|
|
232
|
+
const cacheVersionMap: any = {};
|
|
233
|
+
resp?.data?.forEach((item: any) => {
|
|
234
|
+
// 数据下载地址
|
|
235
|
+
if (item.cacheType == type && item.desCacheVersion?.storageAddress && query.appIds && query.appIds.indexOf(item.appId) > -1) {
|
|
236
|
+
cacheVersionMap[item.appId] = item.desCacheVersion.cacheVersionNumber;
|
|
237
|
+
address.push(downloadUrl + item.desCacheVersion.storageAddress);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
query.appIds?.split(",").forEach((appId) => {
|
|
241
|
+
cacheVersionNumber.push(cacheVersionMap[appId]);
|
|
242
|
+
});
|
|
243
|
+
response.cacheVersionNumber = cacheVersionNumber.join(",");
|
|
244
|
+
response.storageAddress = address;
|
|
245
|
+
return response;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @description: 获取表单或字典数据地址-按照缓存版本号查询字典/表单
|
|
250
|
+
* @author ZPFly
|
|
251
|
+
* @date 2022/10/18 20:43
|
|
252
|
+
*/
|
|
253
|
+
private mergeUrlByCacheId(type: string): Promise<any> {
|
|
254
|
+
const url = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/query-batch-appids-cachetype";
|
|
255
|
+
const downloadUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/downloadById?cacheVersionId=";
|
|
256
|
+
const query = {
|
|
257
|
+
appIds: this.formConfig.appId,
|
|
258
|
+
cacheType: type,
|
|
259
|
+
};
|
|
260
|
+
const appIds: string[] = query.appIds?.split(",") || [];
|
|
261
|
+
return this.fetch(url!, query).then((resp: any) => {
|
|
262
|
+
const response: any = {};
|
|
263
|
+
const address: string[] = [];
|
|
264
|
+
const cacheVersionNumber: any[] = [];
|
|
265
|
+
const cacheVersionMap: any = {};
|
|
266
|
+
resp?.data?.forEach((item: any) => {
|
|
267
|
+
// 数据下载地址
|
|
268
|
+
if (item.cacheType == type && item.desCacheVersion?.cacheVersionId && query.appIds && appIds.indexOf(item.appId) > -1) {
|
|
269
|
+
cacheVersionMap[item.appId] = item.desCacheVersion.cacheVersionNumber;
|
|
270
|
+
address.push(downloadUrl + item.desCacheVersion.cacheVersionId + "&appId=" + item.appId + "&cacheType=" + type);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
query.appIds?.split(",").forEach((appId) => {
|
|
274
|
+
cacheVersionNumber.push(cacheVersionMap[appId]);
|
|
275
|
+
});
|
|
276
|
+
response.cacheVersionNumber = cacheVersionNumber.join(",");
|
|
277
|
+
response.storageAddress = address;
|
|
278
|
+
return response;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @description: 加载远程表单配置
|
|
284
|
+
* @author ChenRui
|
|
285
|
+
* @date 2020/11/20 17:30
|
|
286
|
+
*/
|
|
287
|
+
private loadDesign(urls: string[]): Promise<FormRestfulResponse> {
|
|
288
|
+
return this.mergeFetchDesign(urls).then((desForms: DesForm[]) => {
|
|
289
|
+
const newDesForms: DesForm[] = [];
|
|
290
|
+
if (desForms != null && desForms.length > 0) {
|
|
291
|
+
desForms
|
|
292
|
+
.filter((item) => item.desFormLayouts != null && item.desFormLayouts.length > 0)
|
|
293
|
+
.forEach((item) => {
|
|
294
|
+
const newDesForm: DesForm | undefined = this.formatDesForm(item);
|
|
295
|
+
if (newDesForm != null) {
|
|
296
|
+
newDesForms.push(newDesForm);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
this.desForms = newDesForms;
|
|
301
|
+
formStore.setForms(this.desForms);
|
|
302
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @description: 合并多个应用表单
|
|
308
|
+
* @author ZPFly
|
|
309
|
+
* @date 2022/10/17 15:39
|
|
310
|
+
*/
|
|
311
|
+
private mergeFetchDesign(urls: string[]) {
|
|
312
|
+
const onlySimpleLoadConfig = !!this.formConfig.onlySimpleLoadConfig;
|
|
313
|
+
const headers = this.createFileDownloadAuthorizationHeader();
|
|
314
|
+
const fetches: any = [];
|
|
315
|
+
urls.forEach((url: string) => {
|
|
316
|
+
fetches.push(this.fetch(url, {}, undefined, "GET", headers, onlySimpleLoadConfig));
|
|
317
|
+
});
|
|
318
|
+
return Promise.all(fetches).then((desForms: DesForm[]) => {
|
|
319
|
+
let newDesForms: DesForm[] = [];
|
|
320
|
+
desForms?.forEach((desForm: any) => {
|
|
321
|
+
newDesForms = newDesForms.concat(desForm);
|
|
322
|
+
});
|
|
323
|
+
return newDesForms;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @description: 初始化字典
|
|
329
|
+
* @author ChenRui
|
|
330
|
+
* @date 2021/3/11 14:32
|
|
331
|
+
*/
|
|
332
|
+
initDict(): Promise<FormRestfulResponse> {
|
|
333
|
+
return Promise.all([dictStore.getDicts(), dictStore.getTreeDicts(), dictStore.getMapDicts(), dictStore.getMapTreeDicts(), dictStore.getVersion()]).then(([dicts, treeDicts, mapDicts, mapTreeDicts, dictVersion]: any[]) => {
|
|
334
|
+
if (this.formConfig.loadMode === "static") {
|
|
335
|
+
const url = this.formConfig.dictUrl ? this.formConfig.dictUrl : DEFAULT_DICT_URL;
|
|
336
|
+
if (dicts != null || treeDicts != null) {
|
|
337
|
+
this.sysDictDetailOptions = dicts;
|
|
338
|
+
this.sysDictTreeDetailOptions = treeDicts;
|
|
339
|
+
this.mapSysDictDetailOptions = mapDicts;
|
|
340
|
+
this.mapSysDictTreeDetailOptions = mapTreeDicts;
|
|
341
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
342
|
+
} else {
|
|
343
|
+
return this.loadDict([url]);
|
|
344
|
+
}
|
|
345
|
+
} else if (this.formConfig.loadMode === "dynamic") {
|
|
346
|
+
if (this.formConfig.appId) {
|
|
347
|
+
const url1 = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/query-cacheversion-by-appid-cachetype";
|
|
348
|
+
const url: string = this.formConfig.dictUrl ? this.formConfig.dictUrl : url1 || "";
|
|
349
|
+
const path: string = routerService.getPathFromUrl(url);
|
|
350
|
+
let query: any = routerService.getParamsFromUrl(url) || {};
|
|
351
|
+
query.appId = query.appId ? query.appId : this.formConfig.appId;
|
|
352
|
+
query.cacheType = query.cacheType ? query.cacheType : CacheType.DICT.code;
|
|
353
|
+
query = this.formConfig.dictRestLoadOnlyBody ? {} : query;
|
|
354
|
+
const body: any = (this.formConfig.dictRestLoadMode || "GET").toLocaleUpperCase() === "GET" ? undefined : this.formConfig.dictRestLoadBody;
|
|
355
|
+
let headers: any = this.formConfig.dictRestLoadHeaders;
|
|
356
|
+
if (headers != null && typeof headers === "function") {
|
|
357
|
+
headers = (headers as any)();
|
|
358
|
+
}
|
|
359
|
+
return this.fetch(path, query, body, this.formConfig.dictRestLoadMode, headers).then((res: FormRestfulResponse) => {
|
|
360
|
+
if (res != null && (res.code === 1 || String(res.code) === String(200))) {
|
|
361
|
+
if (res.data != null) {
|
|
362
|
+
let desCacheVersion: any = res.data.desCacheVersion;
|
|
363
|
+
if (res.data && res.data instanceof Array && res.data.length > 0) {
|
|
364
|
+
desCacheVersion = res.data[0].desCacheVersion;
|
|
365
|
+
}
|
|
366
|
+
const distUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=" + desCacheVersion.storageAddress;
|
|
367
|
+
if (String(dictVersion) !== String(desCacheVersion.cacheVersionNumber)) {
|
|
368
|
+
return this.loadDict([distUrl]).then((resEx: FormRestfulResponse) => {
|
|
369
|
+
if (resEx.code === 1) {
|
|
370
|
+
dictStore.setVersion(desCacheVersion.cacheVersionNumber);
|
|
371
|
+
}
|
|
372
|
+
return resEx;
|
|
373
|
+
});
|
|
374
|
+
} else {
|
|
375
|
+
if (dicts != null || treeDicts != null) {
|
|
376
|
+
this.sysDictDetailOptions = dicts;
|
|
377
|
+
this.sysDictTreeDetailOptions = treeDicts;
|
|
378
|
+
this.mapSysDictDetailOptions = mapDicts;
|
|
379
|
+
this.mapSysDictTreeDetailOptions = mapTreeDicts;
|
|
380
|
+
}
|
|
381
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
return { code: 1, msg: "暂无版本数据" };
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
return FormToolsService.LOAD_FAIL;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
} else {
|
|
391
|
+
return { code: 0, msg: "动态加载需指定当前系统编号(appId)" };
|
|
392
|
+
}
|
|
393
|
+
} else if (this.formConfig.loadMode === "merge") {
|
|
394
|
+
return this.mergeUrlByType(CacheType.DICT.code).then((response: any) => {
|
|
395
|
+
if (dictVersion === response.cacheVersionNumber) {
|
|
396
|
+
if (dicts != null || treeDicts != null) {
|
|
397
|
+
this.sysDictDetailOptions = dicts;
|
|
398
|
+
this.sysDictTreeDetailOptions = treeDicts;
|
|
399
|
+
this.mapSysDictDetailOptions = mapDicts;
|
|
400
|
+
this.mapSysDictTreeDetailOptions = mapTreeDicts;
|
|
401
|
+
}
|
|
402
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
403
|
+
} else {
|
|
404
|
+
return new Promise((resolve) => {
|
|
405
|
+
this.loadDict(response.storageAddress).then(() => {
|
|
406
|
+
dictStore.setVersion(response.cacheVersionNumber);
|
|
407
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
} else if (this.formConfig.loadMode === "merge_cacheId") {
|
|
413
|
+
// 按照缓存编号查询表单数据,2024年8月15日14:03:24
|
|
414
|
+
return this.mergeUrlByCacheId(CacheType.DICT.code).then((response: any) => {
|
|
415
|
+
if (dictVersion === response.cacheVersionNumber) {
|
|
416
|
+
if (dicts != null || treeDicts != null) {
|
|
417
|
+
this.sysDictDetailOptions = dicts;
|
|
418
|
+
this.sysDictTreeDetailOptions = treeDicts;
|
|
419
|
+
this.mapSysDictDetailOptions = mapDicts;
|
|
420
|
+
this.mapSysDictTreeDetailOptions = mapTreeDicts;
|
|
421
|
+
}
|
|
422
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
423
|
+
} else {
|
|
424
|
+
return new Promise((resolve) => {
|
|
425
|
+
this.loadDict(response.storageAddress).then(() => {
|
|
426
|
+
dictStore.setVersion(response.cacheVersionNumber);
|
|
427
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return FormToolsService.LOAD_FAIL;
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @description: 加载远程字典配置
|
|
439
|
+
* @author ChenRui
|
|
440
|
+
* @date 2020/11/20 17:30
|
|
441
|
+
*/
|
|
442
|
+
private loadDict(urls: string[]): Promise<FormRestfulResponse> {
|
|
443
|
+
return this.mergeFetchDict(urls).then((sysDictInfos: any) => {
|
|
444
|
+
if (sysDictInfos != null) {
|
|
445
|
+
// 数据格式化
|
|
446
|
+
const dictionaryFormatCollection: DictionaryFormatCollection = this.inidDictOptions(sysDictInfos);
|
|
447
|
+
this.sysDictDetailOptions = dictionaryFormatCollection.sysDictDetailOptions || [];
|
|
448
|
+
this.sysDictTreeDetailOptions = dictionaryFormatCollection.sysDictTreeDetailOptions || [];
|
|
449
|
+
this.mapSysDictDetailOptions = dictionaryFormatCollection.mapSysDictDetailOptions;
|
|
450
|
+
this.mapSysDictTreeDetailOptions = dictionaryFormatCollection.mapSysDictTreeDetailOptions;
|
|
451
|
+
// 字典本地存储
|
|
452
|
+
if (dictionaryFormatCollection.sysDictDetailOptions && dictionaryFormatCollection.sysDictDetailOptions.length > 0) {
|
|
453
|
+
dictStore.setDicts(dictionaryFormatCollection.sysDictDetailOptions);
|
|
454
|
+
}
|
|
455
|
+
if (dictionaryFormatCollection.sysDictTreeDetailOptions && dictionaryFormatCollection.sysDictTreeDetailOptions.length > 0) {
|
|
456
|
+
dictStore.setTreeDicts(dictionaryFormatCollection.sysDictTreeDetailOptions);
|
|
457
|
+
}
|
|
458
|
+
dictStore.setMapDicts(dictionaryFormatCollection.mapSysDictDetailOptions || null);
|
|
459
|
+
dictStore.setMapTreeDicts(dictionaryFormatCollection.mapSysDictTreeDetailOptions || null);
|
|
460
|
+
}
|
|
461
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
462
|
+
});
|
|
463
|
+
// const onlySimpleLoadConfig = !!this.formConfig.onlySimpleLoadConfig;
|
|
464
|
+
// let sysDictInfos: SysDictInfo[] = [];
|
|
465
|
+
// if (loadMode === "dynamic") {
|
|
466
|
+
// const headers = this.createFileDownloadAuthorizationHeader();
|
|
467
|
+
// url = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=" + url;
|
|
468
|
+
// return this.fetch(url, {}, undefined, "GET", headers, onlySimpleLoadConfig).then((res: any) => {
|
|
469
|
+
// sysDictInfos = res;
|
|
470
|
+
// if (sysDictInfos != null && sysDictInfos.length > 0) {
|
|
471
|
+
// // 数据格式化
|
|
472
|
+
// const dictionaryFormatCollection: DictionaryFormatCollection = this.inidDictOptions(sysDictInfos);
|
|
473
|
+
// this.sysDictDetailOptions = dictionaryFormatCollection.sysDictDetailOptions || [];
|
|
474
|
+
// this.sysDictTreeDetailOptions = dictionaryFormatCollection.sysDictTreeDetailOptions || [];
|
|
475
|
+
// this.mapSysDictDetailOptions = dictionaryFormatCollection.mapSysDictDetailOptions;
|
|
476
|
+
// this.mapSysDictTreeDetailOptions = dictionaryFormatCollection.mapSysDictTreeDetailOptions;
|
|
477
|
+
// // 字典本地存储
|
|
478
|
+
// if (dictionaryFormatCollection.sysDictDetailOptions && dictionaryFormatCollection.sysDictDetailOptions.length > 0) {
|
|
479
|
+
// dictStore.setDicts(dictionaryFormatCollection.sysDictDetailOptions);
|
|
480
|
+
// }
|
|
481
|
+
// if (dictionaryFormatCollection.sysDictTreeDetailOptions && dictionaryFormatCollection.sysDictTreeDetailOptions.length > 0) {
|
|
482
|
+
// dictStore.setTreeDicts(dictionaryFormatCollection.sysDictTreeDetailOptions);
|
|
483
|
+
// }
|
|
484
|
+
// dictStore.setMapDicts(dictionaryFormatCollection.mapSysDictDetailOptions || null);
|
|
485
|
+
// dictStore.setMapTreeDicts(dictionaryFormatCollection.mapSysDictTreeDetailOptions || null);
|
|
486
|
+
// }
|
|
487
|
+
// return FormToolsService.LOAD_SUCCESS;
|
|
488
|
+
// });
|
|
489
|
+
// }
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @description: 合并多个应用字典
|
|
494
|
+
* @author ZPFly
|
|
495
|
+
* @date 2022/10/17 15:39
|
|
496
|
+
*/
|
|
497
|
+
private mergeFetchDict(dictUrl: string[]) {
|
|
498
|
+
const fetchDicts: any = [];
|
|
499
|
+
dictUrl.forEach((url: string) => {
|
|
500
|
+
fetchDicts.push(this.fetch(url, {}, undefined, "GET", undefined, !!this.formConfig.onlySimpleLoadConfig));
|
|
501
|
+
});
|
|
502
|
+
return Promise.all(fetchDicts).then((dictInfos: SysDictInfo[]) => {
|
|
503
|
+
let newDictInfos: SysDictInfo[] = [];
|
|
504
|
+
const empObj: any = {};
|
|
505
|
+
const filterDist: SysDictInfo[] = [];
|
|
506
|
+
dictInfos?.forEach((desForm: any) => {
|
|
507
|
+
newDictInfos = newDictInfos.concat(desForm);
|
|
508
|
+
});
|
|
509
|
+
// 去除重复字典
|
|
510
|
+
newDictInfos.forEach((item: SysDictInfo) => {
|
|
511
|
+
if (!empObj[item.dictId]) {
|
|
512
|
+
filterDist.push(item);
|
|
513
|
+
empObj[item.dictId] = true;
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
return filterDist;
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* @description: 初始化字典可选项
|
|
521
|
+
* @author ChenRui
|
|
522
|
+
* @date 2020/11/10 20:38
|
|
523
|
+
*/
|
|
524
|
+
public inidDictOptions(sysDictInfos: SysDictInfo[]): DictionaryFormatCollection {
|
|
525
|
+
const sysDictDetailOptions: NzTreeNodeOptions[] = [];
|
|
526
|
+
const sysDictTreeDetailOptions: NzTreeNodeOptions[] = [];
|
|
527
|
+
sysDictInfos.forEach((sysDictInfo) => {
|
|
528
|
+
const node: NzTreeNodeOptions = {
|
|
529
|
+
key: sysDictInfo.dictId,
|
|
530
|
+
value: sysDictInfo.dictCd,
|
|
531
|
+
title: sysDictInfo.dictNm,
|
|
532
|
+
isLeaf: true,
|
|
533
|
+
expanded: false,
|
|
534
|
+
children: [],
|
|
535
|
+
};
|
|
536
|
+
if (sysDictInfo.dictTp === DynamicOptionType.GeneralDictionary.code) {
|
|
537
|
+
node.isLeaf = false;
|
|
538
|
+
node.children = formTreeNodeConvertService.arrayConvertToNzTreeNode(
|
|
539
|
+
sysDictInfo.comDictKeyValues.filter((it) => !!it.dictId),
|
|
540
|
+
this.dictDetailsContrast,
|
|
541
|
+
this.nzDictDetailsContrastContrast,
|
|
542
|
+
true
|
|
543
|
+
);
|
|
544
|
+
sysDictDetailOptions.push(node);
|
|
545
|
+
} else if (sysDictInfo.dictTp === DynamicOptionType.TreeDictionary.code) {
|
|
546
|
+
if (sysDictInfo.treeDictKeyValues != null && sysDictInfo.treeDictKeyValues.length > 0) {
|
|
547
|
+
node.isLeaf = false;
|
|
548
|
+
sysDictInfo.treeDictKeyValues.forEach((item) => {
|
|
549
|
+
if (item.suprDicPk === "0") {
|
|
550
|
+
item.suprDicPk = "";
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
node.children = formTreeNodeConvertService.arrayConvertToNzTreeNode(
|
|
554
|
+
sysDictInfo.treeDictKeyValues.filter((it) => !!it.dictId),
|
|
555
|
+
this.dictTreeDetailsContrast,
|
|
556
|
+
this.nzDictTreeDetailsContrastContrast,
|
|
557
|
+
true
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
sysDictTreeDetailOptions.push(node);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
const mapNodeOptions: MapNodeOptions | undefined = formTreeNodeConvertService.nzTreeNodeConvertToMap(sysDictDetailOptions);
|
|
564
|
+
const mapTreeNodeOptions: MapNodeOptions | undefined = formTreeNodeConvertService.nzTreeNodeConvertToMap(sysDictTreeDetailOptions);
|
|
565
|
+
return {
|
|
566
|
+
sysDictDetailOptions: sysDictDetailOptions,
|
|
567
|
+
sysDictTreeDetailOptions: sysDictTreeDetailOptions,
|
|
568
|
+
mapSysDictDetailOptions: mapNodeOptions,
|
|
569
|
+
mapSysDictTreeDetailOptions: mapTreeNodeOptions,
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @description: 格式化表单
|
|
575
|
+
* @author ChenRui
|
|
576
|
+
* @date 2020/11/30 15:48
|
|
577
|
+
*/
|
|
578
|
+
formatDesForm(sourceDesForm: DesForm): DesForm | undefined {
|
|
579
|
+
if (sourceDesForm != null) {
|
|
580
|
+
const newDesForm: DesForm = new DesForm(sourceDesForm);
|
|
581
|
+
const desFormLayouts: DesFormLayout[] = formTreeNodeConvertService.arrayConvertToTreeNode(sourceDesForm.desFormLayouts, this.nodeContrast);
|
|
582
|
+
const controls = this.recursionFormatForm([], desFormLayouts);
|
|
583
|
+
this.sortControls(controls);
|
|
584
|
+
newDesForm.desFormLayouts = [];
|
|
585
|
+
newDesForm.controls = controls;
|
|
586
|
+
return newDesForm;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* @description: 递归格式化
|
|
592
|
+
* @author ChenRui
|
|
593
|
+
* @date 2020/11/17 10:16
|
|
594
|
+
*/
|
|
595
|
+
private recursionFormatForm(desFormControls: DesFormControl[], desFormLayouts: DesFormLayout[]): Control[] {
|
|
596
|
+
const controls: Control[] = [];
|
|
597
|
+
if (desFormControls != null && desFormControls.length > 0) {
|
|
598
|
+
desFormControls
|
|
599
|
+
.filter((item) => !!item.formFieldId)
|
|
600
|
+
.forEach((desFormControl) => {
|
|
601
|
+
const control: Control = {
|
|
602
|
+
code: desFormControl.controlType,
|
|
603
|
+
name: (Object.values(FormFieldType).find((item) => item.code === desFormControl.controlType) || {}).name || "",
|
|
604
|
+
type: Number(desFormControl.controlType) < 50 ? FormFieldClass.Base.code : FormFieldClass.Senior.code,
|
|
605
|
+
active: false,
|
|
606
|
+
subControls: undefined,
|
|
607
|
+
controlAttr: desFormControl,
|
|
608
|
+
};
|
|
609
|
+
const controlAttr = control.controlAttr as DesFormControl;
|
|
610
|
+
controlAttr.isBoldTitle = desFormControl.isBoldTitle === Switch.Enable.code;
|
|
611
|
+
controlAttr.isHideTitle = desFormControl.isHideTitle === Switch.Enable.code;
|
|
612
|
+
controlAttr.isNotEdit = desFormControl.isNotEdit === Switch.Enable.code;
|
|
613
|
+
controlAttr.isShowHoliday = desFormControl.isShowHoliday === Switch.Enable.code;
|
|
614
|
+
controlAttr.isHideControl = desFormControl.isHideControl === Switch.Enable.code;
|
|
615
|
+
controlAttr.isPasswordBox = desFormControl.isPasswordBox === Switch.Enable.code;
|
|
616
|
+
controlAttr.enableAutoComplete = desFormControl.enableAutoComplete === Switch.Enable.code;
|
|
617
|
+
controlAttr.isFixedRowHeight = desFormControl.isFixedRowHeight === Switch.Enable.code;
|
|
618
|
+
controlAttr.thousandthPercentileFormat = desFormControl.thousandthPercentileFormat === Switch.Enable.code;
|
|
619
|
+
controlAttr.isShowCapitalization = desFormControl.isShowCapitalization === Switch.Enable.code;
|
|
620
|
+
controlAttr.isLineFeedDisplay = desFormControl.isLineFeedDisplay === Switch.Enable.code;
|
|
621
|
+
controlAttr.optionConfig = formBeanUtilsService.parse(desFormControl.optionConfig);
|
|
622
|
+
controlAttr.generalDictionaryOptions = formBeanUtilsService.parse(desFormControl.generalDictionaryOptions);
|
|
623
|
+
controlAttr.treeShapeOptions = formBeanUtilsService.parse(desFormControl.treeShapeOptions);
|
|
624
|
+
controlAttr.isSupportMultiple = desFormControl.isSupportMultiple === Switch.Enable.code;
|
|
625
|
+
if (Array.isArray(desFormControl.customUploadType) && desFormControl.customUploadType.length > 0) {
|
|
626
|
+
controlAttr.customUploadType = desFormControl.customUploadType.join(",");
|
|
627
|
+
}
|
|
628
|
+
controlAttr.isMultipleChoice = desFormControl.isMultipleChoice === Switch.Enable.code;
|
|
629
|
+
controlAttr.isSearchable = desFormControl.isSearchable === Switch.Enable.code;
|
|
630
|
+
controlAttr.canAddEntry = desFormControl.canAddEntry === Switch.Enable.code;
|
|
631
|
+
controlAttr.isClearButton = desFormControl.isClearButton === Switch.Enable.code;
|
|
632
|
+
controlAttr.hiddenDropdown = desFormControl.hiddenDropdown === Switch.Enable.code;
|
|
633
|
+
controlAttr.textFold = desFormControl.textFold === Switch.Enable.code;
|
|
634
|
+
controlAttr.verificationRules = formBeanUtilsService.parse(desFormControl.verificationRules);
|
|
635
|
+
controls.push(control);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
if (desFormLayouts != null && desFormLayouts.length > 0) {
|
|
639
|
+
desFormLayouts
|
|
640
|
+
.filter((item) => !!item.layoutId)
|
|
641
|
+
.forEach((desFormLayout) => {
|
|
642
|
+
const layoutControl: Control = {
|
|
643
|
+
code: desFormLayout.layoutType,
|
|
644
|
+
name: (Object.values(FormFieldType).find((item) => item.code === desFormLayout.layoutType) || {}).name || "",
|
|
645
|
+
type: FormFieldClass.Layout.code,
|
|
646
|
+
active: false,
|
|
647
|
+
subControls: [],
|
|
648
|
+
controlAttr: new DesFormLayout(desFormLayout),
|
|
649
|
+
};
|
|
650
|
+
const controlAttr = layoutControl.controlAttr as DesFormLayout;
|
|
651
|
+
controlAttr.gridColumnConfig = formBeanUtilsService.parse(desFormLayout.gridColumnConfig);
|
|
652
|
+
controlAttr.desFormControls = [];
|
|
653
|
+
controlAttr.subDesFormLayout = [];
|
|
654
|
+
if ((desFormLayout.subDesFormLayout != null && desFormLayout.subDesFormLayout.length > 0) || (desFormLayout.desFormControls != null && desFormLayout.desFormControls.length > 0)) {
|
|
655
|
+
layoutControl.subControls = this.recursionFormatForm(desFormLayout.desFormControls, desFormLayout.subDesFormLayout);
|
|
656
|
+
}
|
|
657
|
+
controls.push(layoutControl);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return controls;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* @description: 控件排序
|
|
665
|
+
* @author ChenRui
|
|
666
|
+
* @date 2020/11/17 11:59
|
|
667
|
+
*/
|
|
668
|
+
private sortControls(controls: Control[]): void {
|
|
669
|
+
controls.sort((controlA, controlB) => {
|
|
670
|
+
let x = 0;
|
|
671
|
+
let y = 0;
|
|
672
|
+
if (controlA.type === FormFieldClass.Layout.code) {
|
|
673
|
+
x = Number((controlA.controlAttr as DesFormLayout).layoutOrder);
|
|
674
|
+
} else {
|
|
675
|
+
x = Number((controlA.controlAttr as DesFormControl).tableFieldOrder);
|
|
676
|
+
}
|
|
677
|
+
if (controlB.type === FormFieldClass.Layout.code) {
|
|
678
|
+
y = Number((controlB.controlAttr as DesFormLayout).layoutOrder);
|
|
679
|
+
} else {
|
|
680
|
+
y = Number((controlB.controlAttr as DesFormControl).tableFieldOrder);
|
|
681
|
+
}
|
|
682
|
+
return x - y;
|
|
683
|
+
});
|
|
684
|
+
controls.forEach((item) => {
|
|
685
|
+
if (item.subControls != null && item.subControls.length > 0) {
|
|
686
|
+
this.sortControls(item.subControls);
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* @description: 加载资源
|
|
693
|
+
* @author ChenRui
|
|
694
|
+
* @date 2020/11/23 11:00
|
|
695
|
+
*/
|
|
696
|
+
loadResource(formId: string): DesForm {
|
|
697
|
+
const desForm: DesForm | undefined = this.desForms.find((item) => item.formId === formId);
|
|
698
|
+
if (desForm != null) {
|
|
699
|
+
return formBeanUtilsService.copy(desForm);
|
|
700
|
+
} else {
|
|
701
|
+
return new DesForm({ formId: formId });
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* @description: rest客户端
|
|
707
|
+
* @author ChenRui
|
|
708
|
+
* @date 2020/11/19 21:02
|
|
709
|
+
*/
|
|
710
|
+
private fetch(path: string, params: { [key: string]: any }, body?: any, method = "GET", headers?: any, simple = false): Promise<any> {
|
|
711
|
+
headers = headers ? headers : apiService.createBasicHeaders();
|
|
712
|
+
return simple ? fetch(path).then((response) => response.json()) : apiService.fetch(path, params, body, method, headers);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* @description: 校验提示
|
|
717
|
+
* @author ChenRui
|
|
718
|
+
* @date 2021/8/18 17:14
|
|
719
|
+
*/
|
|
720
|
+
validateTips(formApis: FormApi | FormApi[], scrollView?: any): boolean {
|
|
721
|
+
return formValidateService.validateTips(formApis, scrollView);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* @description: 创建认证下载消息头
|
|
726
|
+
* @author ChenRui
|
|
727
|
+
* @date 2020/8/28 15:18
|
|
728
|
+
*/
|
|
729
|
+
createFileDownloadAuthorizationHeader() {
|
|
730
|
+
return {
|
|
731
|
+
headers: {
|
|
732
|
+
"Content-Type": "application/json",
|
|
733
|
+
},
|
|
734
|
+
responseType: "blob",
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const formToolsService: FormToolsService = new FormToolsService();
|
|
739
|
+
export { formToolsService, FormToolsService, DictionaryFormatCollection };
|