@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,240 +1,240 @@
|
|
|
1
|
-
import { formBeanUtilsService } from "./form-bean-utils.service";
|
|
2
|
-
|
|
3
|
-
interface NodeContrast {
|
|
4
|
-
id: string;
|
|
5
|
-
parentId: string;
|
|
6
|
-
children: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface NzNodeContrast {
|
|
10
|
-
title: string;
|
|
11
|
-
key: string;
|
|
12
|
-
icon?: string;
|
|
13
|
-
isLeaf?: string;
|
|
14
|
-
checked?: string;
|
|
15
|
-
selected?: string;
|
|
16
|
-
selectable?: string;
|
|
17
|
-
disabled?: string;
|
|
18
|
-
disableCheckbox?: string;
|
|
19
|
-
expanded?: string;
|
|
20
|
-
children: string;
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface NzCascaderOptionContrast {
|
|
25
|
-
value: string;
|
|
26
|
-
label: string;
|
|
27
|
-
title?: string;
|
|
28
|
-
disabled?: string;
|
|
29
|
-
loading?: string;
|
|
30
|
-
isLeaf?: string;
|
|
31
|
-
parent?: string;
|
|
32
|
-
children: string;
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface NzTreeNodeOptions {
|
|
37
|
-
title: string;
|
|
38
|
-
key: string;
|
|
39
|
-
icon?: string;
|
|
40
|
-
isLeaf?: boolean;
|
|
41
|
-
checked?: boolean;
|
|
42
|
-
selected?: boolean;
|
|
43
|
-
selectable?: boolean;
|
|
44
|
-
disabled?: boolean;
|
|
45
|
-
disableCheckbox?: boolean;
|
|
46
|
-
expanded?: boolean;
|
|
47
|
-
children?: NzTreeNodeOptions[];
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface MapNodeItem {
|
|
52
|
-
key?: string;
|
|
53
|
-
title?: string;
|
|
54
|
-
value?: string;
|
|
55
|
-
children?: MapNodeOptions;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface MapNodeOptions {
|
|
59
|
-
[key: string]: MapNodeItem;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
class FormTreeNodeConvertService {
|
|
63
|
-
constructor() {}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @description: 数组转换为树形结构
|
|
67
|
-
* @author ChenRui
|
|
68
|
-
* @date 2020/10/30 10:18
|
|
69
|
-
*/
|
|
70
|
-
arrayConvertToTreeNode(data: any[], nodeContrast: NodeContrast, parentId?: string): any[] {
|
|
71
|
-
if (data != null && data.length > 0) {
|
|
72
|
-
let nds: any[] = data.filter((item) => (item[nodeContrast.parentId] || "") === (parentId || ""));
|
|
73
|
-
if (nds != null && nds.length > 0) {
|
|
74
|
-
nds = formBeanUtilsService.copy(nds);
|
|
75
|
-
nds.forEach((item) => {
|
|
76
|
-
const children = this.arrayConvertToTreeNode(data, nodeContrast, item[nodeContrast.id]);
|
|
77
|
-
if (children != null && children.length > 0) {
|
|
78
|
-
item[nodeContrast.children] = [...children];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return nds;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @description: 树形结构转换为Nz树形结构
|
|
89
|
-
* @author ChenRui
|
|
90
|
-
* @date 2020/10/30 10:21
|
|
91
|
-
*/
|
|
92
|
-
treeNodeConvertToNzTreeNode(data: any[], nzNodeContrast: NzNodeContrast, isDisabledLeaf = false): any[] {
|
|
93
|
-
const nodes: any[] = [];
|
|
94
|
-
if (data != null && data.length > 0) {
|
|
95
|
-
data.forEach((item) => {
|
|
96
|
-
const node: any = {
|
|
97
|
-
title: "",
|
|
98
|
-
key: "",
|
|
99
|
-
icon: "",
|
|
100
|
-
isLeaf: true,
|
|
101
|
-
checked: false,
|
|
102
|
-
selected: false,
|
|
103
|
-
selectable: true,
|
|
104
|
-
disabled: isDisabledLeaf,
|
|
105
|
-
disableCheckbox: false,
|
|
106
|
-
expanded: true,
|
|
107
|
-
children: [],
|
|
108
|
-
};
|
|
109
|
-
for (const propName of Object.keys(nzNodeContrast)) {
|
|
110
|
-
if (nzNodeContrast[propName] != null && nzNodeContrast[propName] !== "") {
|
|
111
|
-
node[propName] = item[nzNodeContrast[propName]];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
node.children = [];
|
|
115
|
-
if (item[nzNodeContrast.children] != null && item[nzNodeContrast.children].length > 0) {
|
|
116
|
-
const children = this.treeNodeConvertToNzTreeNode(item[nzNodeContrast.children], nzNodeContrast, isDisabledLeaf);
|
|
117
|
-
node.disabled = false;
|
|
118
|
-
node.isLeaf = false;
|
|
119
|
-
node.children = children;
|
|
120
|
-
}
|
|
121
|
-
nodes.push(node);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return nodes;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @description: 数组转换为Nz树形结构
|
|
129
|
-
* @author ChenRui
|
|
130
|
-
* @date 2020/10/30 10:41
|
|
131
|
-
*/
|
|
132
|
-
arrayConvertToNzTreeNode(data: any[], nodeContrast: NodeContrast, nzNodeContrast: NzNodeContrast, isDisabledLeaf = false): any[] {
|
|
133
|
-
const treeNode = this.arrayConvertToTreeNode(data, nodeContrast);
|
|
134
|
-
if (treeNode != null && treeNode.length > 0) {
|
|
135
|
-
return this.treeNodeConvertToNzTreeNode(treeNode, nzNodeContrast, isDisabledLeaf);
|
|
136
|
-
}
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @description: 树形结构转换为Nz树形结构
|
|
142
|
-
* @author ChenRui
|
|
143
|
-
* @date 2020/10/30 10:21
|
|
144
|
-
*/
|
|
145
|
-
treeNodeConvertToCascaderOption(data: any[], nzCascaderOptionContrast: NzCascaderOptionContrast, isDisabledLeaf = false): any[] {
|
|
146
|
-
const nodes: any[] = [];
|
|
147
|
-
if (data != null && data.length > 0) {
|
|
148
|
-
data.forEach((item) => {
|
|
149
|
-
const node: any = {
|
|
150
|
-
value: "",
|
|
151
|
-
label: "",
|
|
152
|
-
title: "",
|
|
153
|
-
disabled: isDisabledLeaf,
|
|
154
|
-
loading: "",
|
|
155
|
-
isLeaf: true,
|
|
156
|
-
parent: "",
|
|
157
|
-
children: "",
|
|
158
|
-
};
|
|
159
|
-
for (const propName of Object.keys(nzCascaderOptionContrast)) {
|
|
160
|
-
if (nzCascaderOptionContrast[propName] != null && nzCascaderOptionContrast[propName] !== "") {
|
|
161
|
-
node[propName] = item[nzCascaderOptionContrast[propName]];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
node.children = [];
|
|
165
|
-
if (item[nzCascaderOptionContrast.children] != null && item[nzCascaderOptionContrast.children].length > 0) {
|
|
166
|
-
const children = this.treeNodeConvertToCascaderOption(item[nzCascaderOptionContrast.children], nzCascaderOptionContrast, isDisabledLeaf);
|
|
167
|
-
node.disabled = false;
|
|
168
|
-
node.isLeaf = false;
|
|
169
|
-
node.children = children;
|
|
170
|
-
}
|
|
171
|
-
nodes.push(node);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return nodes;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @description: 插件树结构转map
|
|
179
|
-
* @author ChenRui
|
|
180
|
-
* @date 2022/1/18 19:19
|
|
181
|
-
*/
|
|
182
|
-
nzTreeNodeConvertToMap(data: NzTreeNodeOptions[]): MapNodeOptions | undefined {
|
|
183
|
-
if (data != null && data.length > 0) {
|
|
184
|
-
const mapNodeOptions: MapNodeOptions = {};
|
|
185
|
-
data.forEach((item) => {
|
|
186
|
-
if (item.value) {
|
|
187
|
-
mapNodeOptions[item.value] = {
|
|
188
|
-
key: item.key,
|
|
189
|
-
title: item.title,
|
|
190
|
-
value: item.value,
|
|
191
|
-
};
|
|
192
|
-
if (item.children && item.children.length > 0) {
|
|
193
|
-
mapNodeOptions[item.value].children = this.nzTreeNodeConvertToMap(item.children) || undefined;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
return mapNodeOptions;
|
|
198
|
-
}
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* @description: 数组转换为Nz树形结构
|
|
204
|
-
* @author ChenRui
|
|
205
|
-
* @date 2020/10/30 10:41
|
|
206
|
-
*/
|
|
207
|
-
arrayConvertToCascaderOption(data: any[], nodeContrast: NodeContrast, nzCascaderOptionContrast: NzCascaderOptionContrast, isDisabledLeaf = false): any[] {
|
|
208
|
-
const treeNode = this.arrayConvertToTreeNode(data, nodeContrast);
|
|
209
|
-
if (treeNode != null && treeNode.length > 0) {
|
|
210
|
-
return this.treeNodeConvertToCascaderOption(treeNode, nzCascaderOptionContrast, isDisabledLeaf);
|
|
211
|
-
}
|
|
212
|
-
return [];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @Description: 树形数据转为数组
|
|
217
|
-
* @author LiuBo
|
|
218
|
-
* @date 2021/11/5
|
|
219
|
-
* @time 16:59
|
|
220
|
-
* @param treeNode 树形数据
|
|
221
|
-
* @param data 数组 传入空数组即可[]
|
|
222
|
-
* @param childName 子节点名称
|
|
223
|
-
*/
|
|
224
|
-
treeNodeConvertToArray(treeNode: any[], data: any[], childName: string): any[] {
|
|
225
|
-
data = data || [];
|
|
226
|
-
treeNode = JSON.parse(JSON.stringify(treeNode));
|
|
227
|
-
treeNode.forEach((val: any) => {
|
|
228
|
-
data.push(val);
|
|
229
|
-
if (val[childName] && val[childName].length) {
|
|
230
|
-
formTreeNodeConvertService.treeNodeConvertToArray(val[childName], data, childName);
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
data.forEach((val: any) => {
|
|
234
|
-
delete val[childName];
|
|
235
|
-
});
|
|
236
|
-
return data;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
const formTreeNodeConvertService: FormTreeNodeConvertService = new FormTreeNodeConvertService();
|
|
240
|
-
export { NodeContrast, NzNodeContrast, NzCascaderOptionContrast, NzTreeNodeOptions, MapNodeItem, MapNodeOptions, formTreeNodeConvertService };
|
|
1
|
+
import { formBeanUtilsService } from "./form-bean-utils.service";
|
|
2
|
+
|
|
3
|
+
interface NodeContrast {
|
|
4
|
+
id: string;
|
|
5
|
+
parentId: string;
|
|
6
|
+
children: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface NzNodeContrast {
|
|
10
|
+
title: string;
|
|
11
|
+
key: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
isLeaf?: string;
|
|
14
|
+
checked?: string;
|
|
15
|
+
selected?: string;
|
|
16
|
+
selectable?: string;
|
|
17
|
+
disabled?: string;
|
|
18
|
+
disableCheckbox?: string;
|
|
19
|
+
expanded?: string;
|
|
20
|
+
children: string;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface NzCascaderOptionContrast {
|
|
25
|
+
value: string;
|
|
26
|
+
label: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
disabled?: string;
|
|
29
|
+
loading?: string;
|
|
30
|
+
isLeaf?: string;
|
|
31
|
+
parent?: string;
|
|
32
|
+
children: string;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface NzTreeNodeOptions {
|
|
37
|
+
title: string;
|
|
38
|
+
key: string;
|
|
39
|
+
icon?: string;
|
|
40
|
+
isLeaf?: boolean;
|
|
41
|
+
checked?: boolean;
|
|
42
|
+
selected?: boolean;
|
|
43
|
+
selectable?: boolean;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
disableCheckbox?: boolean;
|
|
46
|
+
expanded?: boolean;
|
|
47
|
+
children?: NzTreeNodeOptions[];
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface MapNodeItem {
|
|
52
|
+
key?: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
value?: string;
|
|
55
|
+
children?: MapNodeOptions;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface MapNodeOptions {
|
|
59
|
+
[key: string]: MapNodeItem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class FormTreeNodeConvertService {
|
|
63
|
+
constructor() {}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @description: 数组转换为树形结构
|
|
67
|
+
* @author ChenRui
|
|
68
|
+
* @date 2020/10/30 10:18
|
|
69
|
+
*/
|
|
70
|
+
arrayConvertToTreeNode(data: any[], nodeContrast: NodeContrast, parentId?: string): any[] {
|
|
71
|
+
if (data != null && data.length > 0) {
|
|
72
|
+
let nds: any[] = data.filter((item) => (item[nodeContrast.parentId] || "") === (parentId || ""));
|
|
73
|
+
if (nds != null && nds.length > 0) {
|
|
74
|
+
nds = formBeanUtilsService.copy(nds);
|
|
75
|
+
nds.forEach((item) => {
|
|
76
|
+
const children = this.arrayConvertToTreeNode(data, nodeContrast, item[nodeContrast.id]);
|
|
77
|
+
if (children != null && children.length > 0) {
|
|
78
|
+
item[nodeContrast.children] = [...children];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return nds;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @description: 树形结构转换为Nz树形结构
|
|
89
|
+
* @author ChenRui
|
|
90
|
+
* @date 2020/10/30 10:21
|
|
91
|
+
*/
|
|
92
|
+
treeNodeConvertToNzTreeNode(data: any[], nzNodeContrast: NzNodeContrast, isDisabledLeaf = false): any[] {
|
|
93
|
+
const nodes: any[] = [];
|
|
94
|
+
if (data != null && data.length > 0) {
|
|
95
|
+
data.forEach((item) => {
|
|
96
|
+
const node: any = {
|
|
97
|
+
title: "",
|
|
98
|
+
key: "",
|
|
99
|
+
icon: "",
|
|
100
|
+
isLeaf: true,
|
|
101
|
+
checked: false,
|
|
102
|
+
selected: false,
|
|
103
|
+
selectable: true,
|
|
104
|
+
disabled: isDisabledLeaf,
|
|
105
|
+
disableCheckbox: false,
|
|
106
|
+
expanded: true,
|
|
107
|
+
children: [],
|
|
108
|
+
};
|
|
109
|
+
for (const propName of Object.keys(nzNodeContrast)) {
|
|
110
|
+
if (nzNodeContrast[propName] != null && nzNodeContrast[propName] !== "") {
|
|
111
|
+
node[propName] = item[nzNodeContrast[propName]];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
node.children = [];
|
|
115
|
+
if (item[nzNodeContrast.children] != null && item[nzNodeContrast.children].length > 0) {
|
|
116
|
+
const children = this.treeNodeConvertToNzTreeNode(item[nzNodeContrast.children], nzNodeContrast, isDisabledLeaf);
|
|
117
|
+
node.disabled = false;
|
|
118
|
+
node.isLeaf = false;
|
|
119
|
+
node.children = children;
|
|
120
|
+
}
|
|
121
|
+
nodes.push(node);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return nodes;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @description: 数组转换为Nz树形结构
|
|
129
|
+
* @author ChenRui
|
|
130
|
+
* @date 2020/10/30 10:41
|
|
131
|
+
*/
|
|
132
|
+
arrayConvertToNzTreeNode(data: any[], nodeContrast: NodeContrast, nzNodeContrast: NzNodeContrast, isDisabledLeaf = false): any[] {
|
|
133
|
+
const treeNode = this.arrayConvertToTreeNode(data, nodeContrast);
|
|
134
|
+
if (treeNode != null && treeNode.length > 0) {
|
|
135
|
+
return this.treeNodeConvertToNzTreeNode(treeNode, nzNodeContrast, isDisabledLeaf);
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @description: 树形结构转换为Nz树形结构
|
|
142
|
+
* @author ChenRui
|
|
143
|
+
* @date 2020/10/30 10:21
|
|
144
|
+
*/
|
|
145
|
+
treeNodeConvertToCascaderOption(data: any[], nzCascaderOptionContrast: NzCascaderOptionContrast, isDisabledLeaf = false): any[] {
|
|
146
|
+
const nodes: any[] = [];
|
|
147
|
+
if (data != null && data.length > 0) {
|
|
148
|
+
data.forEach((item) => {
|
|
149
|
+
const node: any = {
|
|
150
|
+
value: "",
|
|
151
|
+
label: "",
|
|
152
|
+
title: "",
|
|
153
|
+
disabled: isDisabledLeaf,
|
|
154
|
+
loading: "",
|
|
155
|
+
isLeaf: true,
|
|
156
|
+
parent: "",
|
|
157
|
+
children: "",
|
|
158
|
+
};
|
|
159
|
+
for (const propName of Object.keys(nzCascaderOptionContrast)) {
|
|
160
|
+
if (nzCascaderOptionContrast[propName] != null && nzCascaderOptionContrast[propName] !== "") {
|
|
161
|
+
node[propName] = item[nzCascaderOptionContrast[propName]];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
node.children = [];
|
|
165
|
+
if (item[nzCascaderOptionContrast.children] != null && item[nzCascaderOptionContrast.children].length > 0) {
|
|
166
|
+
const children = this.treeNodeConvertToCascaderOption(item[nzCascaderOptionContrast.children], nzCascaderOptionContrast, isDisabledLeaf);
|
|
167
|
+
node.disabled = false;
|
|
168
|
+
node.isLeaf = false;
|
|
169
|
+
node.children = children;
|
|
170
|
+
}
|
|
171
|
+
nodes.push(node);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return nodes;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @description: 插件树结构转map
|
|
179
|
+
* @author ChenRui
|
|
180
|
+
* @date 2022/1/18 19:19
|
|
181
|
+
*/
|
|
182
|
+
nzTreeNodeConvertToMap(data: NzTreeNodeOptions[]): MapNodeOptions | undefined {
|
|
183
|
+
if (data != null && data.length > 0) {
|
|
184
|
+
const mapNodeOptions: MapNodeOptions = {};
|
|
185
|
+
data.forEach((item) => {
|
|
186
|
+
if (item.value) {
|
|
187
|
+
mapNodeOptions[item.value] = {
|
|
188
|
+
key: item.key,
|
|
189
|
+
title: item.title,
|
|
190
|
+
value: item.value,
|
|
191
|
+
};
|
|
192
|
+
if (item.children && item.children.length > 0) {
|
|
193
|
+
mapNodeOptions[item.value].children = this.nzTreeNodeConvertToMap(item.children) || undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return mapNodeOptions;
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @description: 数组转换为Nz树形结构
|
|
204
|
+
* @author ChenRui
|
|
205
|
+
* @date 2020/10/30 10:41
|
|
206
|
+
*/
|
|
207
|
+
arrayConvertToCascaderOption(data: any[], nodeContrast: NodeContrast, nzCascaderOptionContrast: NzCascaderOptionContrast, isDisabledLeaf = false): any[] {
|
|
208
|
+
const treeNode = this.arrayConvertToTreeNode(data, nodeContrast);
|
|
209
|
+
if (treeNode != null && treeNode.length > 0) {
|
|
210
|
+
return this.treeNodeConvertToCascaderOption(treeNode, nzCascaderOptionContrast, isDisabledLeaf);
|
|
211
|
+
}
|
|
212
|
+
return [];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @Description: 树形数据转为数组
|
|
217
|
+
* @author LiuBo
|
|
218
|
+
* @date 2021/11/5
|
|
219
|
+
* @time 16:59
|
|
220
|
+
* @param treeNode 树形数据
|
|
221
|
+
* @param data 数组 传入空数组即可[]
|
|
222
|
+
* @param childName 子节点名称
|
|
223
|
+
*/
|
|
224
|
+
treeNodeConvertToArray(treeNode: any[], data: any[], childName: string): any[] {
|
|
225
|
+
data = data || [];
|
|
226
|
+
treeNode = JSON.parse(JSON.stringify(treeNode));
|
|
227
|
+
treeNode.forEach((val: any) => {
|
|
228
|
+
data.push(val);
|
|
229
|
+
if (val[childName] && val[childName].length) {
|
|
230
|
+
formTreeNodeConvertService.treeNodeConvertToArray(val[childName], data, childName);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
data.forEach((val: any) => {
|
|
234
|
+
delete val[childName];
|
|
235
|
+
});
|
|
236
|
+
return data;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const formTreeNodeConvertService: FormTreeNodeConvertService = new FormTreeNodeConvertService();
|
|
240
|
+
export { NodeContrast, NzNodeContrast, NzCascaderOptionContrast, NzTreeNodeOptions, MapNodeItem, MapNodeOptions, formTreeNodeConvertService };
|