@dhccmobile/vue3-lo-form 1.0.2 → 1.0.3
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/dist/vue3-lo-form.common.js +249 -162
- 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 +249 -162
- package/dist/vue3-lo-form.umd.js.map +1 -1
- package/dist/vue3-lo-form.umd.min.js +10 -10
- package/dist/vue3-lo-form.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/DvForm.vue +17 -1
- package/src/components/form/DvFormLayout.vue +7 -4
- package/src/core/FormApi.ts +24 -12
- package/src/domain/FormConfig.ts +1 -0
- package/src/services/form-tools.service.ts +154 -99
- package/types/domain/FormConfig.d.ts +1 -0
- package/types/services/form-tools.service.d.ts +6 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div v-if="desForm?.controls?.length" :class="'lo-form-container ' + ('lo-' + (edit ? 'enable' : 'disable') + '-edit') + ' lo-class-style-' + styleMode">
|
|
2
|
+
<div v-if="desForm?.controls?.length" ref="formView" :class="'lo-form-container ' + ('lo-' + (edit ? 'enable' : 'disable') + '-edit') + ' lo-class-style-' + styleMode">
|
|
3
3
|
<dv-form-layout v-for="(item, i) in desForm.controls" :key="i" :control="item" :customFormats="customFormats" :index="i" @change="onChange($event)" @focus="onFocus($event)" @blur="onBlur($event)" @click="onClick($event)" @addon-before="onAddonBeforeHandler($event)" @addon-after="onAddonAfterHandler($event)" @add-item="selectAddItem($event)">
|
|
4
4
|
<template v-for="propName in Object.keys(this.$slots)" v-slot:[propName]="slotProps">
|
|
5
5
|
<slot :name="propName" :content="slotProps.content" :control="slotProps.control" :onChange="slotProps.onChange"></slot>
|
|
@@ -185,6 +185,22 @@ export default class DyForm extends Vue {
|
|
|
185
185
|
this.formApi?.setFieldChangeHistory(this.history);
|
|
186
186
|
}
|
|
187
187
|
this.$emit("complete");
|
|
188
|
+
this.$nextTick(() => {
|
|
189
|
+
try {
|
|
190
|
+
const formView: any = this.$refs.formView;
|
|
191
|
+
const cons = formView.getElementsByClassName("lo-control-container");
|
|
192
|
+
const len = cons.length;
|
|
193
|
+
if (len > 2) {
|
|
194
|
+
const con1 = cons[len - 1];
|
|
195
|
+
const con2 = cons[len - 2];
|
|
196
|
+
if (con1.clientWidth === con1.clientWidth && con1.offsetLeft !== con2.offsetLeft) {
|
|
197
|
+
con1.style.width = "200%";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch (e) {
|
|
201
|
+
console.error("自动修改表单宽度错误" + e);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
188
204
|
}
|
|
189
205
|
}
|
|
190
206
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div v-if="(control.type === formFieldClass.Base.code || control.type === formFieldClass.Senior.code) && !controlAttr.isHideControl" class="lo-control-container" :style="{ width: divWidthCompatibleToIe }">
|
|
3
3
|
<div class="lo-control-box">
|
|
4
4
|
<a-form-item
|
|
5
5
|
:labelCol="{
|
|
@@ -262,14 +262,14 @@
|
|
|
262
262
|
</a-form-item>
|
|
263
263
|
</div>
|
|
264
264
|
</div>
|
|
265
|
-
<a-form :class="'w-100 lo-empty-layout-container' + (controlAttr.layoutName ? ' lo-form-layout-' + controlAttr.layoutName : '')" :layout="layout" :style="emptyLayoutContainerStyle"
|
|
265
|
+
<a-form v-else-if="control.type === formFieldClass.Layout.code && control.code === formFieldType.Empty.code" :class="'w-100 lo-empty-layout-container' + (controlAttr.layoutName ? ' lo-form-layout-' + controlAttr.layoutName : '')" :layout="layout" :style="emptyLayoutContainerStyle">
|
|
266
266
|
<dv-form-layout v-for="(item, i) in control.subControls" :key="i" :index="i" :customFormats="customFormats" :control="item" :parentControl="control" @change="onChange($event)" @click="onClick($event)" @focus="onFocus($event)" @blur="onBlur($event)" @addon-before="onAddonBeforeHandler($event)" @addon-after="onAddonAfterHandler($event)" @add-item="selectAddItem($event)">
|
|
267
267
|
<template v-for="scopedPropName in Object.keys($slots)" v-slot:[scopedPropName]="{ content, control, onChange }">
|
|
268
268
|
<slot v-bind:content="content" v-bind:control="control" v-bind:onChange="onChange" :name="scopedPropName"></slot>
|
|
269
269
|
</template>
|
|
270
270
|
</dv-form-layout>
|
|
271
271
|
</a-form>
|
|
272
|
-
<a-form :class="'w-100 lo-general-layout-container' + (controlAttr.layoutName ? ' lo-form-layout-' + controlAttr.layoutName : '')" :layout="layout" :style="generalLayoutContainerStyle"
|
|
272
|
+
<a-form v-else-if="control.type === formFieldClass.Layout.code && control.code !== formFieldType.Empty.code" :class="'w-100 lo-general-layout-container' + (controlAttr.layoutName ? ' lo-form-layout-' + controlAttr.layoutName : '')" :layout="layout" :style="generalLayoutContainerStyle">
|
|
273
273
|
<dv-form-layout
|
|
274
274
|
v-for="(item, i) in control.subControls"
|
|
275
275
|
:key="i"
|
|
@@ -1479,7 +1479,8 @@ export default class DvFormLayout extends Vue {
|
|
|
1479
1479
|
}
|
|
1480
1480
|
.lo-control-container {
|
|
1481
1481
|
box-sizing: border-box;
|
|
1482
|
-
border: 1px solid #
|
|
1482
|
+
border-right: 1px solid #e8e8e8;
|
|
1483
|
+
border-bottom: 1px solid #e8e8e8;
|
|
1483
1484
|
.lo-control-box {
|
|
1484
1485
|
height: 100%;
|
|
1485
1486
|
.ant-form-item {
|
|
@@ -1654,6 +1655,8 @@ export default class DvFormLayout extends Vue {
|
|
|
1654
1655
|
.lo-empty-layout-container {
|
|
1655
1656
|
box-sizing: border-box;
|
|
1656
1657
|
display: grid;
|
|
1658
|
+
border-top: 1px #e8e8e8 solid;
|
|
1659
|
+
border-left: 1px #e8e8e8 solid;
|
|
1657
1660
|
}
|
|
1658
1661
|
.lo-general-layout-container {
|
|
1659
1662
|
box-sizing: border-box;
|
package/src/core/FormApi.ts
CHANGED
|
@@ -241,7 +241,8 @@ export class FormApi {
|
|
|
241
241
|
*/
|
|
242
242
|
getText(key: string): any {
|
|
243
243
|
const control: AbstractControl = this.getControl(key);
|
|
244
|
-
if (control
|
|
244
|
+
if (control) {
|
|
245
|
+
//control && control instanceof FormControl
|
|
245
246
|
return control.text();
|
|
246
247
|
}
|
|
247
248
|
return "";
|
|
@@ -254,7 +255,8 @@ export class FormApi {
|
|
|
254
255
|
*/
|
|
255
256
|
getOptions(key: string): any[] {
|
|
256
257
|
const control: AbstractControl = this.getControl(key);
|
|
257
|
-
if (control && control
|
|
258
|
+
if (control && control.controlAttr) {
|
|
259
|
+
//control && control instanceof FormControl && control.controlAttr
|
|
258
260
|
return extractOptions(control.controlAttr);
|
|
259
261
|
}
|
|
260
262
|
return [];
|
|
@@ -284,7 +286,8 @@ export class FormApi {
|
|
|
284
286
|
*/
|
|
285
287
|
getAttribute(key: string, attribute: Attribute): any {
|
|
286
288
|
const control: AbstractControl = this.getControl(key);
|
|
287
|
-
if (control && control
|
|
289
|
+
if (control && control.controlAttr) {
|
|
290
|
+
//control && control instanceof FormControl && control.controlAttr
|
|
288
291
|
return control.controlAttr[attribute];
|
|
289
292
|
}
|
|
290
293
|
}
|
|
@@ -312,7 +315,8 @@ export class FormApi {
|
|
|
312
315
|
*/
|
|
313
316
|
getValidate(key: string, name: string): any {
|
|
314
317
|
const control: AbstractControl = this.getControl(key);
|
|
315
|
-
if (control
|
|
318
|
+
if (control) {
|
|
319
|
+
//control && control instanceof FormControl
|
|
316
320
|
return control.getValidate(name);
|
|
317
321
|
}
|
|
318
322
|
}
|
|
@@ -324,7 +328,8 @@ export class FormApi {
|
|
|
324
328
|
*/
|
|
325
329
|
removeValidate(key: string, validateName: string): void {
|
|
326
330
|
const control: AbstractControl = this.getControl(key);
|
|
327
|
-
if (control
|
|
331
|
+
if (control) {
|
|
332
|
+
//control && control instanceof FormControl
|
|
328
333
|
const validates: Validate[] = control.validates;
|
|
329
334
|
if (validates && validates.length > 0) {
|
|
330
335
|
const index = validates.findIndex((item) => item.name === validateName);
|
|
@@ -342,7 +347,8 @@ export class FormApi {
|
|
|
342
347
|
*/
|
|
343
348
|
removeAllValidates(key: string): void {
|
|
344
349
|
const control: AbstractControl = this.getControl(key);
|
|
345
|
-
if (control
|
|
350
|
+
if (control) {
|
|
351
|
+
//control && control instanceof FormControl
|
|
346
352
|
control.validates = [];
|
|
347
353
|
}
|
|
348
354
|
}
|
|
@@ -354,7 +360,8 @@ export class FormApi {
|
|
|
354
360
|
*/
|
|
355
361
|
getValidates(key: string): Validate[] {
|
|
356
362
|
const control: AbstractControl = this.getControl(key);
|
|
357
|
-
if (control
|
|
363
|
+
if (control) {
|
|
364
|
+
//control && control instanceof FormControl
|
|
358
365
|
return control.validates;
|
|
359
366
|
}
|
|
360
367
|
return [];
|
|
@@ -383,7 +390,8 @@ export class FormApi {
|
|
|
383
390
|
if (control == null) {
|
|
384
391
|
setTimeout(() => {
|
|
385
392
|
control = this.getControl(key);
|
|
386
|
-
if (control
|
|
393
|
+
if (control) {
|
|
394
|
+
//control && control instanceof FormControl
|
|
387
395
|
this.setValidateInner(control, validate, isCover);
|
|
388
396
|
}
|
|
389
397
|
});
|
|
@@ -567,7 +575,8 @@ export class FormApi {
|
|
|
567
575
|
if (control == null) {
|
|
568
576
|
setTimeout(() => {
|
|
569
577
|
control = this.getControl(propertyName, undefined, false);
|
|
570
|
-
if (control
|
|
578
|
+
if (control) {
|
|
579
|
+
//control && control instanceof FormControl
|
|
571
580
|
const history = (fieldChangeHistory[propertyName] || []).sort((a, b) => {
|
|
572
581
|
const aTime = new Date(a.time).getTime();
|
|
573
582
|
const bTime = new Date(b.time).getTime();
|
|
@@ -578,7 +587,8 @@ export class FormApi {
|
|
|
578
587
|
});
|
|
579
588
|
} else {
|
|
580
589
|
control = this.getControl(propertyName, undefined, false);
|
|
581
|
-
if (control
|
|
590
|
+
if (control) {
|
|
591
|
+
//control && control instanceof FormControl
|
|
582
592
|
const history = (fieldChangeHistory[propertyName] || []).sort((a, b) => {
|
|
583
593
|
const aTime = new Date(a.time).getTime();
|
|
584
594
|
const bTime = new Date(b.time).getTime();
|
|
@@ -719,7 +729,8 @@ export class FormApi {
|
|
|
719
729
|
* @date 2021/4/13 15:09
|
|
720
730
|
*/
|
|
721
731
|
private setControlOptions(control: AbstractControl, key: string, data: any[], defaultVal?: any): void {
|
|
722
|
-
if (control && control
|
|
732
|
+
if (control && control.controlAttr) {
|
|
733
|
+
//control && control instanceof FormControl && control.controlAttr)
|
|
723
734
|
storageOptions(control.controlAttr, data);
|
|
724
735
|
this.setAttribute(key, Attribute.IsOptionType, OptionType.Fixed.code);
|
|
725
736
|
this.setAttribute(key, Attribute.OptionConfig, data);
|
|
@@ -735,7 +746,8 @@ export class FormApi {
|
|
|
735
746
|
* @date 2021/4/13 15:11
|
|
736
747
|
*/
|
|
737
748
|
private setControlAttribute(control: AbstractControl, attribute: Attribute, data: any): void {
|
|
738
|
-
if (control &&
|
|
749
|
+
if (control && attribute) {
|
|
750
|
+
//control && control instanceof FormControl && attribute
|
|
739
751
|
control.controlAttr[attribute] = data;
|
|
740
752
|
}
|
|
741
753
|
}
|
package/src/domain/FormConfig.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Vue, { createApp } from "vue";
|
|
2
1
|
import { FormConfig } from "../domain/FormConfig";
|
|
3
2
|
import { FormRestfulResponse } from "../domain/FormRestfulResponse";
|
|
4
3
|
import { DesForm } from "../domain/DesForm";
|
|
@@ -15,7 +14,7 @@ import { formStore } from "../store/form.store";
|
|
|
15
14
|
import { DynamicOptionType } from "../constants/enum/dynamic-option-type.enum";
|
|
16
15
|
import { dictStore } from "../store";
|
|
17
16
|
import { SysDictInfo } from "../domain/SysDictInfo";
|
|
18
|
-
import { DEFAULT_DICT_URL } from "../constants/config/form.config";
|
|
17
|
+
import { DEFAULT_DICT_URL, DEFAULT_FORM_FILE_NAME } from "../constants/config/form.config";
|
|
19
18
|
import { CacheType } from "../constants/enum/cache-type.enum";
|
|
20
19
|
import { routerService } from "./router.service";
|
|
21
20
|
import { FormApi } from "../core/FormApi";
|
|
@@ -96,8 +95,7 @@ class FormToolsService {
|
|
|
96
95
|
this.desForms = forms;
|
|
97
96
|
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
98
97
|
} else {
|
|
99
|
-
|
|
100
|
-
return this.loadDesign(url!, "static");
|
|
98
|
+
return this.loadDesign([this.formConfig.url || DEFAULT_FORM_FILE_NAME]);
|
|
101
99
|
}
|
|
102
100
|
} else if (this.formConfig.loadMode === "dynamic") {
|
|
103
101
|
if (this.formConfig.appId != null && this.formConfig.appId !== "") {
|
|
@@ -110,7 +108,8 @@ class FormToolsService {
|
|
|
110
108
|
if (res != null && res.code === 1) {
|
|
111
109
|
if (res.data != null && res.data.desCacheVersion != null) {
|
|
112
110
|
if (String(formVersion) !== String(res.data.desCacheVersion.cacheVersionNumber)) {
|
|
113
|
-
|
|
111
|
+
const formUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=" + res.data.desCacheVersion.storageAddress;
|
|
112
|
+
return this.loadDesign([formUrl]).then((resEx: FormRestfulResponse) => {
|
|
114
113
|
if (resEx.code === 1) {
|
|
115
114
|
formStore.setVersion(res.data.desCacheVersion.cacheVersionNumber);
|
|
116
115
|
}
|
|
@@ -120,6 +119,7 @@ class FormToolsService {
|
|
|
120
119
|
if (forms != null) {
|
|
121
120
|
this.desForms = forms;
|
|
122
121
|
}
|
|
122
|
+
console.log(this.desForms);
|
|
123
123
|
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
124
124
|
}
|
|
125
125
|
} else {
|
|
@@ -135,55 +135,91 @@ class FormToolsService {
|
|
|
135
135
|
msg: "动态加载需指定当前系统编号(appId)",
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
+
} else if (this.formConfig.loadMode === "merge") {
|
|
139
|
+
if (this.formConfig.urls) {
|
|
140
|
+
return new Promise((resolve) => {
|
|
141
|
+
this.loadDesign(this.formConfig.urls || []).then(() => {
|
|
142
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
return this.mergeUrlByType(CacheType.FORM.code).then((response: any) => {
|
|
147
|
+
if (formVersion === response.cacheVersionNumber) {
|
|
148
|
+
if (forms) {
|
|
149
|
+
this.desForms = forms;
|
|
150
|
+
}
|
|
151
|
+
return Promise.resolve(FormToolsService.LOAD_SUCCESS);
|
|
152
|
+
} else {
|
|
153
|
+
return new Promise((resolve) => {
|
|
154
|
+
this.loadDesign(response.storageAddress).then(() => {
|
|
155
|
+
formStore.setVersion(response.cacheVersionNumber);
|
|
156
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
138
162
|
}
|
|
139
163
|
return Promise.resolve(FormToolsService.LOAD_FAIL);
|
|
140
164
|
});
|
|
141
165
|
}
|
|
142
166
|
|
|
167
|
+
/**
|
|
168
|
+
* @description: 获取表单或字典数据地址
|
|
169
|
+
* @author ZPFly
|
|
170
|
+
* @date 2022/10/18 20:43
|
|
171
|
+
*/
|
|
172
|
+
private mergeUrlByType(type: string): Promise<any> {
|
|
173
|
+
const reqAddress: any = [];
|
|
174
|
+
const appIds = this.formConfig.appId?.split(",");
|
|
175
|
+
const url = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/query-cacheversion-by-appid-cachetype";
|
|
176
|
+
const downloadUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=";
|
|
177
|
+
appIds?.forEach((appId: string) => {
|
|
178
|
+
const query = {
|
|
179
|
+
appId: appId,
|
|
180
|
+
cacheType: type,
|
|
181
|
+
};
|
|
182
|
+
reqAddress.push(this.fetch(url!, query));
|
|
183
|
+
});
|
|
184
|
+
return Promise.all(reqAddress).then((resp: any[]) => {
|
|
185
|
+
const response: any = {};
|
|
186
|
+
const address: string[] = [];
|
|
187
|
+
const cacheVersionNumber: any[] = [];
|
|
188
|
+
resp.forEach((res: any) => {
|
|
189
|
+
// 数据下载地址
|
|
190
|
+
if (res?.data?.desCacheVersion?.storageAddress) {
|
|
191
|
+
cacheVersionNumber.push(res.data.desCacheVersion.cacheVersionNumber);
|
|
192
|
+
address.push(downloadUrl + res.data.desCacheVersion.storageAddress);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
response.cacheVersionNumber = cacheVersionNumber.join(",");
|
|
196
|
+
response.storageAddress = address;
|
|
197
|
+
return response;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
143
201
|
/**
|
|
144
202
|
* @description: 加载远程表单配置
|
|
145
203
|
* @author ChenRui
|
|
146
204
|
* @date 2020/11/20 17:30
|
|
147
205
|
*/
|
|
148
|
-
private loadDesign(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.desForms = newDesForms;
|
|
166
|
-
formStore.setForms(this.desForms);
|
|
167
|
-
return FormToolsService.LOAD_SUCCESS;
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
return this.mergeFetchDesign(url).then((desForms: DesForm[]) => {
|
|
171
|
-
const newDesForms: DesForm[] = [];
|
|
172
|
-
if (desForms != null && desForms.length > 0) {
|
|
173
|
-
desForms
|
|
174
|
-
.filter((item) => item.desFormLayouts != null && item.desFormLayouts.length > 0)
|
|
175
|
-
.forEach((item) => {
|
|
176
|
-
const newDesForm: DesForm | undefined = this.formatDesForm(item);
|
|
177
|
-
if (newDesForm != null) {
|
|
178
|
-
newDesForms.push(newDesForm);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
this.desForms = newDesForms;
|
|
183
|
-
formStore.setForms(this.desForms);
|
|
184
|
-
return FormToolsService.LOAD_SUCCESS;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
206
|
+
private loadDesign(urls: string[]): Promise<FormRestfulResponse> {
|
|
207
|
+
return this.mergeFetchDesign(urls).then((desForms: DesForm[]) => {
|
|
208
|
+
const newDesForms: DesForm[] = [];
|
|
209
|
+
if (desForms != null && desForms.length > 0) {
|
|
210
|
+
desForms
|
|
211
|
+
.filter((item) => item.desFormLayouts != null && item.desFormLayouts.length > 0)
|
|
212
|
+
.forEach((item) => {
|
|
213
|
+
const newDesForm: DesForm | undefined = this.formatDesForm(item);
|
|
214
|
+
if (newDesForm != null) {
|
|
215
|
+
newDesForms.push(newDesForm);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
this.desForms = newDesForms;
|
|
220
|
+
formStore.setForms(this.desForms);
|
|
221
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
222
|
+
});
|
|
187
223
|
}
|
|
188
224
|
|
|
189
225
|
/**
|
|
@@ -191,11 +227,12 @@ class FormToolsService {
|
|
|
191
227
|
* @author ZPFly
|
|
192
228
|
* @date 2022/10/17 15:39
|
|
193
229
|
*/
|
|
194
|
-
private mergeFetchDesign(
|
|
195
|
-
const
|
|
230
|
+
private mergeFetchDesign(urls: string[]) {
|
|
231
|
+
const onlySimpleLoadConfig = !!this.formConfig.onlySimpleLoadConfig;
|
|
232
|
+
const headers = this.createFileDownloadAuthorizationHeader();
|
|
196
233
|
const fetches: any = [];
|
|
197
234
|
urls.forEach((url: string) => {
|
|
198
|
-
fetches.push(this.fetch(url, {}, undefined, "GET",
|
|
235
|
+
fetches.push(this.fetch(url, {}, undefined, "GET", headers, onlySimpleLoadConfig));
|
|
199
236
|
});
|
|
200
237
|
return Promise.all(fetches).then((desForms: DesForm[]) => {
|
|
201
238
|
let newDesForms: DesForm[] = [];
|
|
@@ -222,7 +259,7 @@ class FormToolsService {
|
|
|
222
259
|
this.mapSysDictTreeDetailOptions = mapTreeDicts;
|
|
223
260
|
return FormToolsService.LOAD_SUCCESS;
|
|
224
261
|
} else {
|
|
225
|
-
return this.loadDict(url
|
|
262
|
+
return this.loadDict([url]);
|
|
226
263
|
}
|
|
227
264
|
} else if (this.formConfig.loadMode === "dynamic") {
|
|
228
265
|
if (this.formConfig.appId) {
|
|
@@ -245,8 +282,9 @@ class FormToolsService {
|
|
|
245
282
|
if (res.data && res.data instanceof Array && res.data.length > 0) {
|
|
246
283
|
desCacheVersion = res.data[0].desCacheVersion;
|
|
247
284
|
}
|
|
285
|
+
const distUrl = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=" + desCacheVersion.storageAddress;
|
|
248
286
|
if (String(dictVersion) !== String(desCacheVersion.cacheVersionNumber)) {
|
|
249
|
-
return this.loadDict(
|
|
287
|
+
return this.loadDict([distUrl]).then((resEx: FormRestfulResponse) => {
|
|
250
288
|
if (resEx.code === 1) {
|
|
251
289
|
dictStore.setVersion(desCacheVersion.cacheVersionNumber);
|
|
252
290
|
}
|
|
@@ -271,6 +309,25 @@ class FormToolsService {
|
|
|
271
309
|
} else {
|
|
272
310
|
return { code: 0, msg: "动态加载需指定当前系统编号(appId)" };
|
|
273
311
|
}
|
|
312
|
+
} else if (this.formConfig.loadMode === "merge") {
|
|
313
|
+
return this.mergeUrlByType(CacheType.DICT.code).then((response: any) => {
|
|
314
|
+
if (dictVersion === response.cacheVersionNumber) {
|
|
315
|
+
if (dicts != null || treeDicts != null) {
|
|
316
|
+
this.sysDictDetailOptions = dicts;
|
|
317
|
+
this.sysDictTreeDetailOptions = treeDicts;
|
|
318
|
+
this.mapSysDictDetailOptions = mapDicts;
|
|
319
|
+
this.mapSysDictTreeDetailOptions = mapTreeDicts;
|
|
320
|
+
}
|
|
321
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
322
|
+
} else {
|
|
323
|
+
return new Promise((resolve) => {
|
|
324
|
+
this.loadDict(response.storageAddress).then(() => {
|
|
325
|
+
formStore.setVersion(response.cacheVersionNumber);
|
|
326
|
+
resolve(FormToolsService.LOAD_SUCCESS);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
});
|
|
274
331
|
}
|
|
275
332
|
return FormToolsService.LOAD_FAIL;
|
|
276
333
|
});
|
|
@@ -281,55 +338,54 @@ class FormToolsService {
|
|
|
281
338
|
* @author ChenRui
|
|
282
339
|
* @date 2020/11/20 17:30
|
|
283
340
|
*/
|
|
284
|
-
private loadDict(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
this.sysDictTreeDetailOptions = dictionaryFormatCollection.sysDictTreeDetailOptions || [];
|
|
297
|
-
this.mapSysDictDetailOptions = dictionaryFormatCollection.mapSysDictDetailOptions;
|
|
298
|
-
this.mapSysDictTreeDetailOptions = dictionaryFormatCollection.mapSysDictTreeDetailOptions;
|
|
299
|
-
// 字典本地存储
|
|
300
|
-
if (dictionaryFormatCollection.sysDictDetailOptions && dictionaryFormatCollection.sysDictDetailOptions.length > 0) {
|
|
301
|
-
dictStore.setDicts(dictionaryFormatCollection.sysDictDetailOptions);
|
|
302
|
-
}
|
|
303
|
-
if (dictionaryFormatCollection.sysDictTreeDetailOptions && dictionaryFormatCollection.sysDictTreeDetailOptions.length > 0) {
|
|
304
|
-
dictStore.setTreeDicts(dictionaryFormatCollection.sysDictTreeDetailOptions);
|
|
305
|
-
}
|
|
306
|
-
dictStore.setMapDicts(dictionaryFormatCollection.mapSysDictDetailOptions || null);
|
|
307
|
-
dictStore.setMapTreeDicts(dictionaryFormatCollection.mapSysDictTreeDetailOptions || null);
|
|
341
|
+
private loadDict(urls: string[]): Promise<FormRestfulResponse> {
|
|
342
|
+
return this.mergeFetchDict(urls).then((sysDictInfos: any) => {
|
|
343
|
+
if (sysDictInfos != null) {
|
|
344
|
+
// 数据格式化
|
|
345
|
+
const dictionaryFormatCollection: DictionaryFormatCollection = this.inidDictOptions(sysDictInfos);
|
|
346
|
+
this.sysDictDetailOptions = dictionaryFormatCollection.sysDictDetailOptions || [];
|
|
347
|
+
this.sysDictTreeDetailOptions = dictionaryFormatCollection.sysDictTreeDetailOptions || [];
|
|
348
|
+
this.mapSysDictDetailOptions = dictionaryFormatCollection.mapSysDictDetailOptions;
|
|
349
|
+
this.mapSysDictTreeDetailOptions = dictionaryFormatCollection.mapSysDictTreeDetailOptions;
|
|
350
|
+
// 字典本地存储
|
|
351
|
+
if (dictionaryFormatCollection.sysDictDetailOptions && dictionaryFormatCollection.sysDictDetailOptions.length > 0) {
|
|
352
|
+
dictStore.setDicts(dictionaryFormatCollection.sysDictDetailOptions);
|
|
308
353
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
} else {
|
|
312
|
-
return this.mergeFetchDict(url).then((sysDictInfos: any) => {
|
|
313
|
-
if (sysDictInfos != null) {
|
|
314
|
-
// 数据格式化
|
|
315
|
-
const dictionaryFormatCollection: DictionaryFormatCollection = this.inidDictOptions(sysDictInfos);
|
|
316
|
-
this.sysDictDetailOptions = dictionaryFormatCollection.sysDictDetailOptions || [];
|
|
317
|
-
this.sysDictTreeDetailOptions = dictionaryFormatCollection.sysDictTreeDetailOptions || [];
|
|
318
|
-
this.mapSysDictDetailOptions = dictionaryFormatCollection.mapSysDictDetailOptions;
|
|
319
|
-
this.mapSysDictTreeDetailOptions = dictionaryFormatCollection.mapSysDictTreeDetailOptions;
|
|
320
|
-
// 字典本地存储
|
|
321
|
-
if (dictionaryFormatCollection.sysDictDetailOptions && dictionaryFormatCollection.sysDictDetailOptions.length > 0) {
|
|
322
|
-
dictStore.setDicts(dictionaryFormatCollection.sysDictDetailOptions);
|
|
323
|
-
}
|
|
324
|
-
if (dictionaryFormatCollection.sysDictTreeDetailOptions && dictionaryFormatCollection.sysDictTreeDetailOptions.length > 0) {
|
|
325
|
-
dictStore.setTreeDicts(dictionaryFormatCollection.sysDictTreeDetailOptions);
|
|
326
|
-
}
|
|
327
|
-
dictStore.setMapDicts(dictionaryFormatCollection.mapSysDictDetailOptions || null);
|
|
328
|
-
dictStore.setMapTreeDicts(dictionaryFormatCollection.mapSysDictTreeDetailOptions || null);
|
|
354
|
+
if (dictionaryFormatCollection.sysDictTreeDetailOptions && dictionaryFormatCollection.sysDictTreeDetailOptions.length > 0) {
|
|
355
|
+
dictStore.setTreeDicts(dictionaryFormatCollection.sysDictTreeDetailOptions);
|
|
329
356
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
357
|
+
dictStore.setMapDicts(dictionaryFormatCollection.mapSysDictDetailOptions || null);
|
|
358
|
+
dictStore.setMapTreeDicts(dictionaryFormatCollection.mapSysDictTreeDetailOptions || null);
|
|
359
|
+
}
|
|
360
|
+
return FormToolsService.LOAD_SUCCESS;
|
|
361
|
+
});
|
|
362
|
+
// const onlySimpleLoadConfig = !!this.formConfig.onlySimpleLoadConfig;
|
|
363
|
+
// let sysDictInfos: SysDictInfo[] = [];
|
|
364
|
+
// if (loadMode === "dynamic") {
|
|
365
|
+
// const headers = this.createFileDownloadAuthorizationHeader();
|
|
366
|
+
// url = this.formConfig.url + "/ms-loong/api/v1/des-cache-info/permit_endpoint/download?storageAddress=" + url;
|
|
367
|
+
// return this.fetch(url, {}, undefined, "GET", headers, onlySimpleLoadConfig).then((res: any) => {
|
|
368
|
+
// sysDictInfos = res;
|
|
369
|
+
// if (sysDictInfos != null && sysDictInfos.length > 0) {
|
|
370
|
+
// // 数据格式化
|
|
371
|
+
// const dictionaryFormatCollection: DictionaryFormatCollection = this.inidDictOptions(sysDictInfos);
|
|
372
|
+
// this.sysDictDetailOptions = dictionaryFormatCollection.sysDictDetailOptions || [];
|
|
373
|
+
// this.sysDictTreeDetailOptions = dictionaryFormatCollection.sysDictTreeDetailOptions || [];
|
|
374
|
+
// this.mapSysDictDetailOptions = dictionaryFormatCollection.mapSysDictDetailOptions;
|
|
375
|
+
// this.mapSysDictTreeDetailOptions = dictionaryFormatCollection.mapSysDictTreeDetailOptions;
|
|
376
|
+
// // 字典本地存储
|
|
377
|
+
// if (dictionaryFormatCollection.sysDictDetailOptions && dictionaryFormatCollection.sysDictDetailOptions.length > 0) {
|
|
378
|
+
// dictStore.setDicts(dictionaryFormatCollection.sysDictDetailOptions);
|
|
379
|
+
// }
|
|
380
|
+
// if (dictionaryFormatCollection.sysDictTreeDetailOptions && dictionaryFormatCollection.sysDictTreeDetailOptions.length > 0) {
|
|
381
|
+
// dictStore.setTreeDicts(dictionaryFormatCollection.sysDictTreeDetailOptions);
|
|
382
|
+
// }
|
|
383
|
+
// dictStore.setMapDicts(dictionaryFormatCollection.mapSysDictDetailOptions || null);
|
|
384
|
+
// dictStore.setMapTreeDicts(dictionaryFormatCollection.mapSysDictTreeDetailOptions || null);
|
|
385
|
+
// }
|
|
386
|
+
// return FormToolsService.LOAD_SUCCESS;
|
|
387
|
+
// });
|
|
388
|
+
// }
|
|
333
389
|
}
|
|
334
390
|
|
|
335
391
|
/**
|
|
@@ -337,10 +393,9 @@ class FormToolsService {
|
|
|
337
393
|
* @author ZPFly
|
|
338
394
|
* @date 2022/10/17 15:39
|
|
339
395
|
*/
|
|
340
|
-
private mergeFetchDict(dictUrl
|
|
341
|
-
const urls: any = this.formConfig.dictUrls || [dictUrl];
|
|
396
|
+
private mergeFetchDict(dictUrl: string[]) {
|
|
342
397
|
const fetchDicts: any = [];
|
|
343
|
-
|
|
398
|
+
dictUrl.forEach((url: string) => {
|
|
344
399
|
fetchDicts.push(this.fetch(url, {}, undefined, "GET", undefined, !!this.formConfig.onlySimpleLoadConfig));
|
|
345
400
|
});
|
|
346
401
|
return Promise.all(fetchDicts).then((dictInfos: SysDictInfo[]) => {
|
|
@@ -44,6 +44,12 @@ declare class FormToolsService {
|
|
|
44
44
|
* @date 2020/11/20 10:55
|
|
45
45
|
*/
|
|
46
46
|
initDesign(): Promise<FormRestfulResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* @description: 获取表单或字典数据地址
|
|
49
|
+
* @author ZPFly
|
|
50
|
+
* @date 2022/10/18 20:43
|
|
51
|
+
*/
|
|
52
|
+
private mergeUrlByType;
|
|
47
53
|
/**
|
|
48
54
|
* @description: 加载远程表单配置
|
|
49
55
|
* @author ChenRui
|