lw-cdp-ui 1.1.28 → 1.1.29
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/components/lwFormMini/index.vue +15 -17
- package/dist/components/lwLayout/components/lang.vue +0 -1
- package/dist/components/lwTable/index.js +1 -1
- package/dist/components/lwTableForm/index.vue +152 -256
- package/dist/lw-cdp-ui.esm.js +2933 -3074
- package/dist/lw-cdp-ui.umd.js +16 -16
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
<el-checkbox-group v-model="form[item.name]">
|
|
78
78
|
<el-checkbox v-for="_item in item.options.items"
|
|
79
79
|
:key="_item.value"
|
|
80
|
-
:
|
|
80
|
+
:value="_item.value">{{ _item.label }}</el-checkbox>
|
|
81
81
|
</el-checkbox-group>
|
|
82
82
|
</template>
|
|
83
83
|
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
:disabled="item.options.disabled">
|
|
151
151
|
<el-radio v-for="_item in item.options.items"
|
|
152
152
|
:key="_item.value"
|
|
153
|
-
:
|
|
153
|
+
:value="_item.value">{{ _item.label }}</el-radio>
|
|
154
154
|
</el-radio-group>
|
|
155
155
|
</template>
|
|
156
156
|
<!-- color -->
|
|
@@ -279,17 +279,23 @@ export default {
|
|
|
279
279
|
}
|
|
280
280
|
},
|
|
281
281
|
watch: {
|
|
282
|
-
modelValue
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
modelValue: {
|
|
283
|
+
handler(val, old) {
|
|
284
|
+
if (this.hasConfig && this.isChange) {
|
|
285
|
+
this.form = this.flattenObject(val)
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
deep: true
|
|
287
289
|
},
|
|
288
290
|
config() {
|
|
289
291
|
this.render()
|
|
290
292
|
},
|
|
291
293
|
form: {
|
|
292
294
|
handler(val) {
|
|
295
|
+
this.isChange = false;
|
|
296
|
+
setTimeout(() => {
|
|
297
|
+
this.isChange = true
|
|
298
|
+
}, 1000)
|
|
293
299
|
this.$emit("update:modelValue", this.unflattenObject(val))
|
|
294
300
|
},
|
|
295
301
|
deep: true
|
|
@@ -361,8 +367,6 @@ export default {
|
|
|
361
367
|
},
|
|
362
368
|
unflattenObject(obj) {
|
|
363
369
|
const result = {};
|
|
364
|
-
this.isChange = false;
|
|
365
|
-
|
|
366
370
|
for (let key in obj) {
|
|
367
371
|
if (obj.hasOwnProperty(key)) {
|
|
368
372
|
const keys = key.split('.'); // 按 `.` 分割键名
|
|
@@ -421,14 +425,8 @@ export default {
|
|
|
421
425
|
// 增加tag
|
|
422
426
|
tagInputConfirm(item, row) {
|
|
423
427
|
if (this.tagValue) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
row[item.name][item.options.name] = row[item.name][item.options.name] || [];
|
|
427
|
-
row[item.name][item.options.name].push(this.tagValue)
|
|
428
|
-
} else {
|
|
429
|
-
row[item.name] = row[item.name] || []
|
|
430
|
-
row[item.name].push(this.tagValue)
|
|
431
|
-
}
|
|
428
|
+
row[item.name] = row[item.name] || []
|
|
429
|
+
row[item.name].push(this.tagValue)
|
|
432
430
|
}
|
|
433
431
|
this.tagVisible = false
|
|
434
432
|
this.tagValue = ''
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
orderPage: { type: Boolean, default: false },
|
|
28
28
|
tableSize: { type: String, default: 'large' },
|
|
29
29
|
loading: { type: Boolean, default: false },
|
|
30
|
-
rowSelection: {
|
|
30
|
+
rowSelection: { type: Boolean, default: false },
|
|
31
31
|
selectedKeys: { type: Array },
|
|
32
32
|
selectDatas: { type: Array },
|
|
33
33
|
hideTool: { type: Boolean, default: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-table :data="
|
|
2
|
+
<el-table :data="tableData"
|
|
3
3
|
stripe
|
|
4
4
|
:columns="config.formItems"
|
|
5
5
|
:max-height="maxHeight"
|
|
@@ -26,43 +26,23 @@
|
|
|
26
26
|
<template #default="{ row, $index, column }">
|
|
27
27
|
<!-- input -->
|
|
28
28
|
<template v-if="item.component=='input'">
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
show-word-limit></el-input>
|
|
38
|
-
</template>
|
|
39
|
-
<template v-else>
|
|
40
|
-
<el-input v-model="row[item.name]"
|
|
41
|
-
:placeholder="item.options.placeholder"
|
|
42
|
-
clearable
|
|
43
|
-
size="small"
|
|
44
|
-
:type="item.options.type"
|
|
45
|
-
:disabled="isDisabled(item, row)"
|
|
46
|
-
:maxlength="item.options.maxlength"
|
|
47
|
-
show-word-limit></el-input>
|
|
48
|
-
</template>
|
|
29
|
+
<el-input v-model="row[item.name]"
|
|
30
|
+
:placeholder="item.options.placeholder"
|
|
31
|
+
clearable
|
|
32
|
+
size="small"
|
|
33
|
+
:type="item.options.type"
|
|
34
|
+
:disabled="isDisabled(item, row)"
|
|
35
|
+
:maxlength="item.options.maxlength"
|
|
36
|
+
show-word-limit></el-input>
|
|
49
37
|
</template>
|
|
50
38
|
<!-- upload -->
|
|
51
39
|
<template v-else-if="item.component=='upload'">
|
|
52
40
|
<el-col v-for="(_item, _index) in item.options.items"
|
|
53
41
|
:key="_index">
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{{ row['errorMsg'][item.name][_item.name] }}</div>
|
|
59
|
-
</template>
|
|
60
|
-
<template v-else>
|
|
61
|
-
<lw-upload v-model="row[_item.name]"
|
|
62
|
-
:title="_item.label"></lw-upload>
|
|
63
|
-
<div class="error-tips">
|
|
64
|
-
{{ row['errorMsg'][_item.name] }}</div>
|
|
65
|
-
</template>
|
|
42
|
+
<lw-upload v-model="row[_item.name]"
|
|
43
|
+
:title="_item.label"></lw-upload>
|
|
44
|
+
<div class="error-tips">
|
|
45
|
+
{{ row['errorMsg'][_item.name] }}</div>
|
|
66
46
|
|
|
67
47
|
</el-col>
|
|
68
48
|
</template>
|
|
@@ -71,11 +51,11 @@
|
|
|
71
51
|
<template v-if="item.name">
|
|
72
52
|
<template v-for="(_item, _index) in item.options.items"
|
|
73
53
|
:key="_index">
|
|
74
|
-
<el-checkbox v-model="row[item.name]
|
|
54
|
+
<el-checkbox v-model="row[item.name]"
|
|
75
55
|
:label="_item.label"
|
|
76
56
|
size="small"></el-checkbox>
|
|
77
57
|
<div class="error-tips">
|
|
78
|
-
{{ row['errorMsg'][item.name]
|
|
58
|
+
{{ row['errorMsg'][item.name] }}</div>
|
|
79
59
|
</template>
|
|
80
60
|
|
|
81
61
|
</template>
|
|
@@ -90,244 +70,120 @@
|
|
|
90
70
|
</template>
|
|
91
71
|
<!-- checkboxGroup -->
|
|
92
72
|
<template v-else-if="item.component=='checkboxGroup'">
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</el-checkbox-group>
|
|
100
|
-
</template>
|
|
101
|
-
<template v-else>
|
|
102
|
-
<el-checkbox-group v-model="row[item.name]"
|
|
103
|
-
size="small">
|
|
104
|
-
<el-checkbox v-for="_item in item.options.items"
|
|
105
|
-
:key="_item.value"
|
|
106
|
-
:label="_item.value">{{_item.label}}</el-checkbox>
|
|
107
|
-
</el-checkbox-group>
|
|
108
|
-
</template>
|
|
73
|
+
<el-checkbox-group v-model="row[item.name]"
|
|
74
|
+
size="small">
|
|
75
|
+
<el-checkbox v-for="_item in item.options.items"
|
|
76
|
+
:key="_item.value"
|
|
77
|
+
:label="_item.value">{{_item.label}}</el-checkbox>
|
|
78
|
+
</el-checkbox-group>
|
|
109
79
|
|
|
110
80
|
</template>
|
|
111
81
|
|
|
112
82
|
<!-- switch -->
|
|
113
83
|
<template v-else-if="item.component=='switch'">
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
v-model="row[item.name][item.options.name]" />
|
|
118
|
-
</template>
|
|
119
|
-
<template v-else>
|
|
120
|
-
<el-switch size="small"
|
|
121
|
-
:disabled="isDisabled(item, row)"
|
|
122
|
-
v-model="row[item.name]" />
|
|
123
|
-
</template>
|
|
84
|
+
<el-switch size="small"
|
|
85
|
+
:disabled="isDisabled(item, row)"
|
|
86
|
+
v-model="row[item.name]" />
|
|
124
87
|
</template>
|
|
125
88
|
<!-- select -->
|
|
126
89
|
<template v-else-if="item.component=='select'">
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
</el-select>
|
|
143
|
-
</template>
|
|
144
|
-
<template v-else>
|
|
145
|
-
<el-select v-model="row[item.name]"
|
|
146
|
-
:multiple="item.options?.multiple"
|
|
147
|
-
:allow-create="item.options?.allowCreate"
|
|
148
|
-
default-first-option
|
|
149
|
-
:placeholder="item.options?.placeholder || ''"
|
|
150
|
-
:clearable="item.options?.clearable"
|
|
151
|
-
:disabled="isDisabled(item, row)"
|
|
152
|
-
filterable
|
|
153
|
-
size="small"
|
|
154
|
-
style="width: 100%;">
|
|
155
|
-
<el-option v-for="option in item.options.items"
|
|
156
|
-
:key="option.value"
|
|
157
|
-
:label="option.label"
|
|
158
|
-
:value="option.value"></el-option>
|
|
159
|
-
</el-select>
|
|
160
|
-
</template>
|
|
90
|
+
<el-select v-model="row[item.name]"
|
|
91
|
+
:multiple="item.options?.multiple"
|
|
92
|
+
:allow-create="item.options?.allowCreate"
|
|
93
|
+
default-first-option
|
|
94
|
+
:placeholder="item.options?.placeholder || ''"
|
|
95
|
+
:clearable="item.options?.clearable"
|
|
96
|
+
:disabled="isDisabled(item, row)"
|
|
97
|
+
filterable
|
|
98
|
+
size="small"
|
|
99
|
+
style="width: 100%;">
|
|
100
|
+
<el-option v-for="option in item.options.items"
|
|
101
|
+
:key="option.value"
|
|
102
|
+
:label="option.label"
|
|
103
|
+
:value="option.value"></el-option>
|
|
104
|
+
</el-select>
|
|
161
105
|
|
|
162
106
|
</template>
|
|
163
107
|
<!-- cascader -->
|
|
164
108
|
<template v-else-if="item.component=='cascader'">
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
clearable></el-cascader>
|
|
171
|
-
</template>
|
|
172
|
-
<template v-else>
|
|
173
|
-
<el-cascader size="small"
|
|
174
|
-
v-model="row[item.name]"
|
|
175
|
-
:options="item.options.items"
|
|
176
|
-
:disabled="isDisabled(item, row)"
|
|
177
|
-
clearable></el-cascader>
|
|
178
|
-
</template>
|
|
179
|
-
|
|
109
|
+
<el-cascader size="small"
|
|
110
|
+
v-model="row[item.name]"
|
|
111
|
+
:options="item.options.items"
|
|
112
|
+
:disabled="isDisabled(item, row)"
|
|
113
|
+
clearable></el-cascader>
|
|
180
114
|
</template>
|
|
181
115
|
<!-- date -->
|
|
182
116
|
<template v-else-if="item.component=='date'">
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
:placeholder="item.options.placeholder || '请选择'"></el-date-picker>
|
|
195
|
-
</template>
|
|
196
|
-
<template v-else>
|
|
197
|
-
<el-date-picker v-model="row[item.name]"
|
|
198
|
-
style="width: 100%;"
|
|
199
|
-
size="small"
|
|
200
|
-
:type="item.options.type"
|
|
201
|
-
:disabled="isDisabled(item, row)"
|
|
202
|
-
:start-placeholder="item.options.startPlaceholder"
|
|
203
|
-
:end-placeholder="item.options.endPlaceholder"
|
|
204
|
-
:shortcuts="item.options.shortcuts"
|
|
205
|
-
:default-time="item.options.defaultTime"
|
|
206
|
-
:value-rowat="item.options.valuerowat"
|
|
207
|
-
:placeholder="item.options.placeholder || '请选择'"></el-date-picker>
|
|
208
|
-
</template>
|
|
117
|
+
<el-date-picker v-model="row[item.name]"
|
|
118
|
+
style="width: 100%;"
|
|
119
|
+
size="small"
|
|
120
|
+
:type="item.options.type"
|
|
121
|
+
:disabled="isDisabled(item, row)"
|
|
122
|
+
:start-placeholder="item.options.startPlaceholder"
|
|
123
|
+
:end-placeholder="item.options.endPlaceholder"
|
|
124
|
+
:shortcuts="item.options.shortcuts"
|
|
125
|
+
:default-time="item.options.defaultTime"
|
|
126
|
+
:value-rowat="item.options.valuerowat"
|
|
127
|
+
:placeholder="item.options.placeholder || '请选择'"></el-date-picker>
|
|
209
128
|
|
|
210
129
|
</template>
|
|
211
130
|
<!-- number -->
|
|
212
131
|
<template v-else-if="item.component=='number'">
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
v-bind="{
|
|
218
|
-
min: item?.options?.min !== undefined ? item.options.min : null,
|
|
219
|
-
max: item?.options?.max !== undefined ? item.options.max : null,
|
|
220
|
-
placeholder: item?.options?.placeholder || ''
|
|
221
|
-
}"
|
|
222
|
-
controls-position="right"></el-input-number>
|
|
223
|
-
</template>
|
|
224
|
-
<template v-else>
|
|
225
|
-
<el-input-number v-model="row[item.name]"
|
|
226
|
-
size="small"
|
|
227
|
-
:disabled="isDisabled(item, row)"
|
|
228
|
-
v-bind="{
|
|
132
|
+
<el-input-number v-model="row[item.name]"
|
|
133
|
+
size="small"
|
|
134
|
+
:disabled="isDisabled(item, row)"
|
|
135
|
+
v-bind="{
|
|
229
136
|
min: item?.options?.min !== undefined ? item.options.min : null,
|
|
230
137
|
max: item?.options?.max !== undefined ? item.options.max : null,
|
|
231
138
|
placeholder: item?.options?.placeholder || ''
|
|
232
139
|
}"
|
|
233
|
-
|
|
234
|
-
</template>
|
|
140
|
+
controls-position="right"></el-input-number>
|
|
235
141
|
|
|
236
142
|
</template>
|
|
237
143
|
<!-- radio -->
|
|
238
144
|
<template v-else-if="item.component=='radio'">
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
</el-radio-group>
|
|
248
|
-
</template>
|
|
249
|
-
<template v-else>
|
|
250
|
-
<el-radio-group v-model="row[item.name]"
|
|
251
|
-
:disabled="isDisabled(item, row)"
|
|
252
|
-
size="small">
|
|
253
|
-
<el-radio v-for="_item in item.options.items"
|
|
254
|
-
:key="_item.value"
|
|
255
|
-
:disabled="isDisabled(item, row)"
|
|
256
|
-
:label="_item.value">{{_item.label}}</el-radio>
|
|
257
|
-
</el-radio-group>
|
|
258
|
-
</template>
|
|
259
|
-
|
|
145
|
+
<el-radio-group v-model="row[item.name]"
|
|
146
|
+
:disabled="isDisabled(item, row)"
|
|
147
|
+
size="small">
|
|
148
|
+
<el-radio v-for="_item in item.options.items"
|
|
149
|
+
:key="_item.value"
|
|
150
|
+
:disabled="isDisabled(item, row)"
|
|
151
|
+
:label="_item.value">{{_item.label}}</el-radio>
|
|
152
|
+
</el-radio-group>
|
|
260
153
|
</template>
|
|
261
154
|
<!-- color -->
|
|
262
155
|
<template v-else-if="item.component=='color'">
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
size="small" />
|
|
267
|
-
</template>
|
|
268
|
-
<template v-else>
|
|
269
|
-
<el-color-picker v-model="row[item.name]"
|
|
270
|
-
:disabled="isDisabled(item, row)"
|
|
271
|
-
size="small" />
|
|
272
|
-
</template>
|
|
273
|
-
|
|
156
|
+
<el-color-picker v-model="row[item.name]"
|
|
157
|
+
:disabled="isDisabled(item, row)"
|
|
158
|
+
size="small" />
|
|
274
159
|
</template>
|
|
275
160
|
<!-- rate -->
|
|
276
161
|
<template v-else-if="item.component=='rate'">
|
|
277
|
-
<
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
size="small"></el-rate>
|
|
282
|
-
</template>
|
|
283
|
-
<template v-else>
|
|
284
|
-
<el-rate style="margin-top: 6px;"
|
|
285
|
-
:disabled="isDisabled(item, row)"
|
|
286
|
-
v-model="row[item.name]"
|
|
287
|
-
size="small"></el-rate>
|
|
288
|
-
</template>
|
|
162
|
+
<el-rate style="margin-top: 6px;"
|
|
163
|
+
:disabled="isDisabled(item, row)"
|
|
164
|
+
v-model="row[item.name]"
|
|
165
|
+
size="small"></el-rate>
|
|
289
166
|
|
|
290
167
|
</template>
|
|
291
168
|
<!-- slider -->
|
|
292
169
|
<template v-else-if="item.component=='slider'">
|
|
293
|
-
<
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
size="small"></el-slider>
|
|
298
|
-
</template>
|
|
299
|
-
<template v-else>
|
|
300
|
-
<el-slider v-model="row[item.name]"
|
|
301
|
-
:marks="item.options.marks"
|
|
302
|
-
:disabled="isDisabled(item, row)"
|
|
303
|
-
size="small"></el-slider>
|
|
304
|
-
</template>
|
|
170
|
+
<el-slider v-model="row[item.name]"
|
|
171
|
+
:marks="item.options.marks"
|
|
172
|
+
:disabled="isDisabled(item, row)"
|
|
173
|
+
size="small"></el-slider>
|
|
305
174
|
|
|
306
175
|
</template>
|
|
307
176
|
|
|
308
177
|
<!-- tags -->
|
|
309
178
|
<template v-else-if="item.component=='tags'">
|
|
310
179
|
<div class="tags-list">
|
|
311
|
-
<
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
{{ tag }}
|
|
319
|
-
</el-tag>
|
|
320
|
-
</template>
|
|
321
|
-
</template>
|
|
322
|
-
<template v-else>
|
|
323
|
-
<el-tag v-for="tag in row[item.name]"
|
|
324
|
-
:key="tag"
|
|
325
|
-
closable
|
|
326
|
-
:disable-transitions="false"
|
|
327
|
-
@close="tagClose(tag, row[item.name])">
|
|
328
|
-
{{ tag }}
|
|
329
|
-
</el-tag>
|
|
330
|
-
</template>
|
|
180
|
+
<el-tag v-for="tag in row[item.name]"
|
|
181
|
+
:key="tag"
|
|
182
|
+
closable
|
|
183
|
+
:disable-transitions="false"
|
|
184
|
+
@close="tagClose(tag, row[item.name])">
|
|
185
|
+
{{ tag }}
|
|
186
|
+
</el-tag>
|
|
331
187
|
<el-input v-if="row?.tagVisible"
|
|
332
188
|
v-model="tagValue"
|
|
333
189
|
class="w-20"
|
|
@@ -444,26 +300,34 @@ export default {
|
|
|
444
300
|
/**
|
|
445
301
|
* 是否是查看模式
|
|
446
302
|
*/
|
|
447
|
-
|
|
303
|
+
isView: { type: Boolean, default: false },
|
|
448
304
|
},
|
|
449
305
|
data() {
|
|
450
306
|
return {
|
|
451
307
|
tableData: [],
|
|
452
308
|
tagValue: '',
|
|
453
309
|
ids: [],
|
|
310
|
+
isChange: true,
|
|
454
311
|
tagVisible: false,
|
|
455
312
|
}
|
|
456
313
|
},
|
|
457
314
|
watch: {
|
|
458
315
|
tableData: {
|
|
459
|
-
handler(val) {
|
|
460
|
-
this
|
|
316
|
+
async handler(val) {
|
|
317
|
+
this.isChange = false;
|
|
318
|
+
setTimeout(() => {
|
|
319
|
+
this.isChange = true
|
|
320
|
+
}, 1000)
|
|
321
|
+
this.$emit("update:modelValue", await this.unflattenObject(val))
|
|
461
322
|
},
|
|
462
323
|
deep: true
|
|
463
324
|
},
|
|
464
325
|
modelValue: {
|
|
465
|
-
handler(val) {
|
|
466
|
-
this.
|
|
326
|
+
async handler(val) {
|
|
327
|
+
if (this.isChange) {
|
|
328
|
+
this.tableData = await this.flattenObject(val)
|
|
329
|
+
}
|
|
330
|
+
this.isChange = true;
|
|
467
331
|
},
|
|
468
332
|
deep: true
|
|
469
333
|
}
|
|
@@ -478,9 +342,58 @@ export default {
|
|
|
478
342
|
|
|
479
343
|
},
|
|
480
344
|
mounted() {
|
|
481
|
-
this.tableData = this.modelValue
|
|
345
|
+
this.tableData = this.flattenObject(this.modelValue)
|
|
482
346
|
},
|
|
483
347
|
methods: {
|
|
348
|
+
flattenObject(array) {
|
|
349
|
+
let list = []
|
|
350
|
+
function getObj(obj, prefix = '') {
|
|
351
|
+
let result = {};
|
|
352
|
+
|
|
353
|
+
for (let key in obj) {
|
|
354
|
+
if (obj.hasOwnProperty(key)) {
|
|
355
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
356
|
+
|
|
357
|
+
if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
358
|
+
// 递归处理嵌套对象
|
|
359
|
+
Object.assign(result, getObj(obj[key], newKey));
|
|
360
|
+
} else {
|
|
361
|
+
result[newKey] = obj[key];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return result;
|
|
367
|
+
}
|
|
368
|
+
array?.forEach(obj => {
|
|
369
|
+
list.push(getObj(obj))
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
return list;
|
|
373
|
+
},
|
|
374
|
+
unflattenObject(array) {
|
|
375
|
+
let list = []
|
|
376
|
+
array?.forEach(obj => {
|
|
377
|
+
const result = {};
|
|
378
|
+
for (let key in obj) {
|
|
379
|
+
if (obj.hasOwnProperty(key)) {
|
|
380
|
+
const keys = key.split('.'); // 按 `.` 分割键名
|
|
381
|
+
keys.reduce((acc, part, index) => {
|
|
382
|
+
if (index === keys.length - 1) {
|
|
383
|
+
acc[part] = obj[key];
|
|
384
|
+
} else {
|
|
385
|
+
acc[part] = acc[part] || {}; // 如果没有该键,创建一个空对象
|
|
386
|
+
}
|
|
387
|
+
return acc[part];
|
|
388
|
+
}, result);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
list.push(result)
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
return list;
|
|
396
|
+
},
|
|
484
397
|
// 非空校验
|
|
485
398
|
isEmpty(value) {
|
|
486
399
|
if (value == null) return true; // null 和 undefined
|
|
@@ -526,15 +439,6 @@ export default {
|
|
|
526
439
|
}
|
|
527
440
|
data['errorMsg'][item.name] = rule.message
|
|
528
441
|
|
|
529
|
-
validationMessages.push(`${item.label} ${rule.message}`);
|
|
530
|
-
} else if (rule.required && item?.options?.name && this.isEmpty(data[item.name][item.options.name])) {
|
|
531
|
-
if (!data?.errorMsg) {
|
|
532
|
-
data.errorMsg = {}
|
|
533
|
-
}
|
|
534
|
-
if (!data['errorMsg'][item.name]) {
|
|
535
|
-
data['errorMsg'][item.name] = {}
|
|
536
|
-
}
|
|
537
|
-
data['errorMsg'][item.name][item.options.name] = rule.message
|
|
538
442
|
validationMessages.push(`${item.label} ${rule.message}`);
|
|
539
443
|
} else {
|
|
540
444
|
if (data?.errorMsg) {
|
|
@@ -561,16 +465,15 @@ export default {
|
|
|
561
465
|
addItem(tableData = this.tableData) {
|
|
562
466
|
let form = {};
|
|
563
467
|
let formItems = JSON.parse(JSON.stringify(this.config.formItems));
|
|
564
|
-
|
|
565
468
|
let isVal = this.isValue(tableData, formItems)
|
|
566
469
|
if (isVal) { return false }
|
|
567
470
|
|
|
568
471
|
formItems.forEach((item) => {
|
|
569
472
|
if (item.component == 'checkbox' || item.component == 'upload') {
|
|
570
473
|
if (item.name) {
|
|
571
|
-
const value =
|
|
474
|
+
const value = [];
|
|
572
475
|
item.options.items.forEach((option) => {
|
|
573
|
-
value
|
|
476
|
+
value.push(option.value)
|
|
574
477
|
});
|
|
575
478
|
form[item.name] = value;
|
|
576
479
|
} else if (item?.options?.items) {
|
|
@@ -579,14 +482,7 @@ export default {
|
|
|
579
482
|
});
|
|
580
483
|
}
|
|
581
484
|
} else {
|
|
582
|
-
|
|
583
|
-
if (!form[item.name]) {
|
|
584
|
-
form[item.name] = {};
|
|
585
|
-
}
|
|
586
|
-
form[item.name][item?.options?.name] = item.value;
|
|
587
|
-
} else if (item.name) {
|
|
588
|
-
form[item.name] = item.value;
|
|
589
|
-
}
|
|
485
|
+
form[item.name] = item.value;
|
|
590
486
|
}
|
|
591
487
|
});
|
|
592
488
|
|