lw-cdp-ui 1.2.7 → 1.2.9
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/lwFormJson/JsonItem.vue +22 -4
- package/dist/components/lwFormJson/StatsConfig.vue +92 -15
- package/dist/components/lwFormJson/TreeItem.vue +149 -0
- package/dist/components/lwFormJson/index.vue +14 -21
- package/dist/components/lwFormMini/FormItem.vue +34 -27
- package/dist/components/lwFormMini/index.vue +7 -15
- package/dist/lw-cdp-ui.esm.js +4607 -4370
- package/dist/lw-cdp-ui.umd.js +12 -12
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -10,15 +10,23 @@
|
|
|
10
10
|
<el-col :span="['list'].includes(item.component) ? 24 : item.span || 24"
|
|
11
11
|
:class="{ borderItem: hideBorder, cur: hideBorder && curIndex == (item.name || item?.options?.items[0]?.name) }"
|
|
12
12
|
v-if="!hideHandle(item)">
|
|
13
|
-
<!--
|
|
13
|
+
<!-- 组合 -->
|
|
14
14
|
<template v-if="['object'].includes(item.component)">
|
|
15
15
|
<el-form-item :label="item.label"
|
|
16
16
|
@click.capture="changeClick(item)">
|
|
17
17
|
<JsonItem :formItems="item.value"
|
|
18
18
|
:form="form[item.name]"
|
|
19
19
|
class="object-item"
|
|
20
|
+
:custom="custom"
|
|
20
21
|
:hideBorder="hideBorder"
|
|
21
|
-
@curClick="changeClick"
|
|
22
|
+
@curClick="changeClick">
|
|
23
|
+
<template v-for="c in custom"
|
|
24
|
+
v-slot:[c.component]="{ itemCur, formCur }">
|
|
25
|
+
<slot :name="c.component"
|
|
26
|
+
:itemCur="itemCur"
|
|
27
|
+
:formCur="formCur"></slot>
|
|
28
|
+
</template>
|
|
29
|
+
</JsonItem>
|
|
22
30
|
</el-form-item>
|
|
23
31
|
|
|
24
32
|
</template>
|
|
@@ -41,9 +49,17 @@
|
|
|
41
49
|
:class="{borderItem: hideBorder}">
|
|
42
50
|
<JsonItem v-if="form[item.name]"
|
|
43
51
|
:formItems="x"
|
|
52
|
+
:custom="custom"
|
|
44
53
|
:form="form[item.name][xIndex]"
|
|
45
54
|
:hideBorder="hideBorder"
|
|
46
|
-
@curClick="changeClick"
|
|
55
|
+
@curClick="changeClick">
|
|
56
|
+
<template v-for="c in custom"
|
|
57
|
+
v-slot:[c.component]="{ itemCur, formCur }">
|
|
58
|
+
<slot :name="c.component"
|
|
59
|
+
:itemCur="itemCur"
|
|
60
|
+
:formCur="formCur"></slot>
|
|
61
|
+
</template>
|
|
62
|
+
</JsonItem>
|
|
47
63
|
<el-icon class="remove-btn"
|
|
48
64
|
size="14"
|
|
49
65
|
v-if="!hideBorder && item.value.length > 1"
|
|
@@ -105,7 +121,9 @@ export default {
|
|
|
105
121
|
default: () => { }
|
|
106
122
|
},
|
|
107
123
|
// 是否是显示边界
|
|
108
|
-
hideBorder: { type: Boolean, default: true }
|
|
124
|
+
hideBorder: { type: Boolean, default: true },
|
|
125
|
+
// 自定义组件
|
|
126
|
+
custom: { type: Array, default: () => [] },
|
|
109
127
|
},
|
|
110
128
|
computed: {
|
|
111
129
|
curIndex() {
|
|
@@ -310,17 +310,37 @@
|
|
|
310
310
|
<el-form-item label="提交校验">
|
|
311
311
|
<el-select v-model="item.rules"
|
|
312
312
|
multiple
|
|
313
|
+
value-key="label"
|
|
313
314
|
clearable
|
|
314
315
|
placeholder="请选择">
|
|
315
316
|
<el-option v-for="item in rules"
|
|
317
|
+
:key="item.label"
|
|
316
318
|
:label="item.label"
|
|
317
|
-
:value="item
|
|
319
|
+
:value="item" />
|
|
318
320
|
</el-select>
|
|
319
321
|
</el-form-item>
|
|
320
|
-
<el-form-item label="隐藏校验">
|
|
321
|
-
<
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
<el-form-item label="隐藏校验(满足条件时将隐藏该项)">
|
|
323
|
+
<div class="input-body">
|
|
324
|
+
<el-cascader v-model="hideForm.label"
|
|
325
|
+
:show-all-levels="false"
|
|
326
|
+
:props="{ emitPath: false }"
|
|
327
|
+
style="flex:1.2;"
|
|
328
|
+
:options="strList" />
|
|
329
|
+
<el-select v-model="hideForm.filter"
|
|
330
|
+
clearable
|
|
331
|
+
style="flex:1;"
|
|
332
|
+
placeholder="条件">
|
|
333
|
+
<el-option v-for="item in filter"
|
|
334
|
+
:key="item.label"
|
|
335
|
+
:label="item.label"
|
|
336
|
+
:value="item.value" />
|
|
337
|
+
</el-select>
|
|
338
|
+
<el-input v-model="hideForm.value"
|
|
339
|
+
style="flex:1;"
|
|
340
|
+
placeholder="值"
|
|
341
|
+
clearable />
|
|
342
|
+
</div>
|
|
343
|
+
|
|
324
344
|
</el-form-item>
|
|
325
345
|
|
|
326
346
|
</div>
|
|
@@ -345,26 +365,38 @@
|
|
|
345
365
|
</el-select>
|
|
346
366
|
</el-form-item>
|
|
347
367
|
</div>
|
|
348
|
-
|
|
368
|
+
<div class="form-title">数据层级</div>
|
|
369
|
+
<TreeItem :formItems="config.formItems" />
|
|
349
370
|
</template>
|
|
350
371
|
</el-form>
|
|
351
372
|
</template>
|
|
352
373
|
|
|
353
374
|
<script>
|
|
375
|
+
import TreeItem from './TreeItem.vue'
|
|
354
376
|
export default {
|
|
355
377
|
name: 'StatsConfig',
|
|
378
|
+
components: {
|
|
379
|
+
TreeItem
|
|
380
|
+
},
|
|
356
381
|
data() {
|
|
357
382
|
return {
|
|
358
383
|
tagVisible: {},
|
|
384
|
+
hideForm: {},
|
|
359
385
|
tagValue: '',
|
|
386
|
+
filter: [
|
|
387
|
+
{ label: '等于', value: '==' },
|
|
388
|
+
{ label: '大于', value: '>' },
|
|
389
|
+
{ label: '大于等于', value: '>=' },
|
|
390
|
+
{ label: '小于', value: '<' },
|
|
391
|
+
{ label: '小于等于', value: '<=' },
|
|
392
|
+
{ label: '不等于', value: '!=' }
|
|
393
|
+
],
|
|
360
394
|
rules: [
|
|
361
395
|
{
|
|
362
|
-
label: '必填',
|
|
363
|
-
value: { required: true, message: '请输入', trigger: 'blur' }
|
|
396
|
+
label: '必填', required: true, message: '请输入', trigger: 'blur'
|
|
364
397
|
},
|
|
365
398
|
{
|
|
366
|
-
label: '必选',
|
|
367
|
-
value: { required: true, message: '请选择', trigger: 'change' }
|
|
399
|
+
label: '必选', required: true, message: '请选择', trigger: 'change'
|
|
368
400
|
},
|
|
369
401
|
]
|
|
370
402
|
}
|
|
@@ -374,13 +406,53 @@ export default {
|
|
|
374
406
|
type: Object,
|
|
375
407
|
default: () => ({})
|
|
376
408
|
},
|
|
377
|
-
|
|
409
|
+
config: {
|
|
378
410
|
type: Object,
|
|
379
411
|
default: () => ({})
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
watch: {
|
|
415
|
+
hideForm: {
|
|
416
|
+
handler(val) {
|
|
417
|
+
if (!val?.label || !val.filter || !val.value) {
|
|
418
|
+
this.item.hideHandle = ''
|
|
419
|
+
return
|
|
420
|
+
}
|
|
421
|
+
this.item.hideHandle = `$.${val.label} ${val.filter} ${val.value}`
|
|
422
|
+
},
|
|
423
|
+
deep: true
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
computed: {
|
|
427
|
+
// 字段
|
|
428
|
+
strList() {
|
|
429
|
+
function parse(data) {
|
|
430
|
+
const parseItem = (item) => {
|
|
431
|
+
let node = {
|
|
432
|
+
label: item.label,
|
|
433
|
+
value: item.name || item.label
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
if (item.component === 'object' || item.component === 'list') {
|
|
437
|
+
// 如果是组合或者列表,递归处理子节点
|
|
438
|
+
node.children = (item.value || []).map((subItem) => {
|
|
439
|
+
if (Array.isArray(subItem)) {
|
|
440
|
+
return subItem.map(parseItem); // 处理二维数组的情况
|
|
441
|
+
}
|
|
442
|
+
return parseItem(subItem);
|
|
443
|
+
}).flat();
|
|
444
|
+
} else if (item.component === 'checkbox' || item.component === 'upload') {
|
|
445
|
+
// 如果是复选框或者上传组件,从 options.items 中提取子节点
|
|
446
|
+
node.value = item.options?.items[0].name
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return node;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
return data.formItems.map(parseItem);
|
|
453
|
+
}
|
|
454
|
+
let list = parse(this.config)
|
|
455
|
+
return list
|
|
384
456
|
}
|
|
385
457
|
},
|
|
386
458
|
methods: {
|
|
@@ -437,5 +509,10 @@ export default {
|
|
|
437
509
|
.w-20 {
|
|
438
510
|
width: 100px;
|
|
439
511
|
}
|
|
512
|
+
|
|
513
|
+
.input-body {
|
|
514
|
+
display: flex;
|
|
515
|
+
align-items: center;
|
|
516
|
+
}
|
|
440
517
|
}
|
|
441
518
|
</style>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<draggable :list="formItems"
|
|
3
|
+
item-key="name"
|
|
4
|
+
group="people"
|
|
5
|
+
class="draggable-item"
|
|
6
|
+
ghost-class="draggable-ghost">
|
|
7
|
+
<template #item="{element: item, index}">
|
|
8
|
+
<div>
|
|
9
|
+
<!-- 组合 -->
|
|
10
|
+
<template v-if="['object'].includes(item.component)">
|
|
11
|
+
<div class="form-item">
|
|
12
|
+
{{item.label}}<span>「{{item.name || item.options?.items[0]?.name}}」</span>
|
|
13
|
+
<div class="tool-list">
|
|
14
|
+
<el-icon class="btn"
|
|
15
|
+
size="14"
|
|
16
|
+
@click="copyItem(item, index)"
|
|
17
|
+
title="复制"><el-icon-copy-document /></el-icon>
|
|
18
|
+
<el-icon class="btn"
|
|
19
|
+
size="14"
|
|
20
|
+
@click="deleteItem(index)"
|
|
21
|
+
title="删除"><el-icon-delete /></el-icon>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<TreeItem :formItems="item.value"></TreeItem>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<!-- 列表 显示时 -->
|
|
28
|
+
<template v-else-if="['list'].includes(item.component)">
|
|
29
|
+
<div class="list-item">
|
|
30
|
+
<div class="form-item">
|
|
31
|
+
{{item.label}}<span>「{{item.name || item.options?.items[0]?.name}}」</span>
|
|
32
|
+
<div class="tool-list">
|
|
33
|
+
<el-icon class="btn"
|
|
34
|
+
size="14"
|
|
35
|
+
@click="copyItem(item, index)"
|
|
36
|
+
title="复制"><el-icon-copy-document /></el-icon>
|
|
37
|
+
<el-icon class="btn"
|
|
38
|
+
size="14"
|
|
39
|
+
@click="deleteItem(index)"
|
|
40
|
+
title="删除"><el-icon-delete /></el-icon>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<TreeItem :formItems="x"
|
|
44
|
+
v-for="x in item.value"></TreeItem>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<div v-else
|
|
50
|
+
class="form-item">
|
|
51
|
+
{{item.label}}<span>「{{item.name || item.options?.items[0]?.name}}」</span>
|
|
52
|
+
<div class="tool-list">
|
|
53
|
+
<el-icon class="btn"
|
|
54
|
+
size="14"
|
|
55
|
+
@click="copyItem(item, index)"
|
|
56
|
+
title="复制"><el-icon-copy-document /></el-icon>
|
|
57
|
+
<el-icon class="btn"
|
|
58
|
+
size="14"
|
|
59
|
+
@click="deleteItem(index)"
|
|
60
|
+
title="删除"><el-icon-delete /></el-icon>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
</draggable>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
import draggable from 'vuedraggable'
|
|
70
|
+
export default {
|
|
71
|
+
name: 'TreeItem',
|
|
72
|
+
components: {
|
|
73
|
+
draggable
|
|
74
|
+
},
|
|
75
|
+
props: {
|
|
76
|
+
formItems: {
|
|
77
|
+
type: Object,
|
|
78
|
+
default: []
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
computed: {
|
|
82
|
+
curIndex() {
|
|
83
|
+
return this.$store.state?.curIndex || ''
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
emits: ['curClick'],
|
|
87
|
+
methods: {
|
|
88
|
+
// 删除
|
|
89
|
+
deleteItem(index) {
|
|
90
|
+
this.formItems.splice(index, 1)
|
|
91
|
+
},
|
|
92
|
+
// 复制
|
|
93
|
+
copyItem(item, index) {
|
|
94
|
+
let x = JSON.parse(JSON.stringify(item))
|
|
95
|
+
x.name = `${item.component}-${this.$tool.getUUID('', 2)}`
|
|
96
|
+
this.formItems.splice(index + 1, 0, x)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
<style lang="scss" scoped>
|
|
102
|
+
.draggable-item {
|
|
103
|
+
// padding-left: 10px;
|
|
104
|
+
border-left: 10px solid rgba($color: #000, $alpha: 0.05);
|
|
105
|
+
background-color: rgba($color: #000, $alpha: 0.01);
|
|
106
|
+
backdrop-filter: blur(10px);
|
|
107
|
+
color: var(--el-text-color-regular);
|
|
108
|
+
cursor: move;
|
|
109
|
+
.list-item {
|
|
110
|
+
}
|
|
111
|
+
.form-item {
|
|
112
|
+
padding: 8px 0 8px 10px;
|
|
113
|
+
border-bottom: 1px solid rgba($color: #000, $alpha: 0.1);
|
|
114
|
+
position: relative;
|
|
115
|
+
span{
|
|
116
|
+
color: var(--el-color-primary-light-6);
|
|
117
|
+
}
|
|
118
|
+
.tool-list {
|
|
119
|
+
display: none;
|
|
120
|
+
}
|
|
121
|
+
&:hover {
|
|
122
|
+
// border: 1px dashed var(--el-color-primary) !important;
|
|
123
|
+
background-color: var(--el-color-primary-light-9);
|
|
124
|
+
.tool-list {
|
|
125
|
+
position: absolute;
|
|
126
|
+
bottom: 0;
|
|
127
|
+
right: 0;
|
|
128
|
+
display: block;
|
|
129
|
+
border-top-left-radius: 10px;
|
|
130
|
+
z-index: 8;
|
|
131
|
+
background-color: var(--el-color-primary);
|
|
132
|
+
color: #fff;
|
|
133
|
+
display: flex;
|
|
134
|
+
gap: 10px;
|
|
135
|
+
padding: 2px 10px;
|
|
136
|
+
.btn {
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
width: 20px;
|
|
139
|
+
height: 20px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
:deep(.draggable-ghost) {
|
|
145
|
+
background: var(--el-border-color-light);
|
|
146
|
+
width: 100%;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
@@ -32,21 +32,22 @@
|
|
|
32
32
|
<el-form ref="form"
|
|
33
33
|
@click.capture="back(config)"
|
|
34
34
|
:model="form"
|
|
35
|
-
:label-width="
|
|
36
|
-
:label-position="$i18n.locale == 'en-us' ? 'top' :
|
|
35
|
+
:label-width="config.labelWidth"
|
|
36
|
+
:label-position="$i18n.locale == 'en-us' ? 'top' : config.labelPosition"
|
|
37
37
|
v-loading="loading"
|
|
38
38
|
:disabled="isView"
|
|
39
39
|
element-loading-text="Loading...">
|
|
40
40
|
<el-row>
|
|
41
|
-
<JsonItem :formItems="
|
|
41
|
+
<JsonItem :formItems="config.formItems"
|
|
42
42
|
:hideBorder="hideBorder"
|
|
43
43
|
:form="form"
|
|
44
|
+
:custom="custom"
|
|
44
45
|
@curClick="selectItem">
|
|
45
46
|
<template v-for="item in custom"
|
|
46
|
-
v-slot:[item.component]>
|
|
47
|
+
v-slot:[item.component]="{ itemCur, formCur }">
|
|
47
48
|
<slot :name="item.component"
|
|
48
|
-
:itemCur="
|
|
49
|
-
:formCur="
|
|
49
|
+
:itemCur="itemCur"
|
|
50
|
+
:formCur="formCur"></slot>
|
|
50
51
|
</template>
|
|
51
52
|
</JsonItem>
|
|
52
53
|
</el-row>
|
|
@@ -58,7 +59,8 @@
|
|
|
58
59
|
<el-aside v-if="hideTool"
|
|
59
60
|
width="300px"
|
|
60
61
|
class="aside-right">
|
|
61
|
-
<StatsConfig :item="curItem"
|
|
62
|
+
<StatsConfig :item="curItem"
|
|
63
|
+
:config="config" />
|
|
62
64
|
</el-aside>
|
|
63
65
|
</el-container>
|
|
64
66
|
</template>
|
|
@@ -125,7 +127,6 @@ export default {
|
|
|
125
127
|
data() {
|
|
126
128
|
return {
|
|
127
129
|
form: {},
|
|
128
|
-
localConfig: {},
|
|
129
130
|
curItem: {},
|
|
130
131
|
scrollObserverEnabled: true,
|
|
131
132
|
renderLoading: false,
|
|
@@ -143,19 +144,11 @@ export default {
|
|
|
143
144
|
deep: true
|
|
144
145
|
},
|
|
145
146
|
config: {
|
|
146
|
-
handler(val) {
|
|
147
|
-
this.render()
|
|
148
|
-
this.localConfig = JSON.parse(JSON.stringify(val))
|
|
149
|
-
},
|
|
150
|
-
immediate: true,
|
|
151
|
-
deep: true
|
|
152
|
-
},
|
|
153
|
-
localConfig: {
|
|
154
147
|
handler(val) {
|
|
155
148
|
this.render(val)
|
|
156
149
|
this.$emit("update:config", val)
|
|
157
|
-
|
|
158
150
|
},
|
|
151
|
+
immediate: true,
|
|
159
152
|
deep: true
|
|
160
153
|
},
|
|
161
154
|
},
|
|
@@ -238,10 +231,10 @@ export default {
|
|
|
238
231
|
}
|
|
239
232
|
|
|
240
233
|
let form = parse(config.formItems, this.modelValue);
|
|
241
|
-
form = {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
234
|
+
// form = {
|
|
235
|
+
// ...this.modelValue,
|
|
236
|
+
// ...form
|
|
237
|
+
// }
|
|
245
238
|
this.form = this.parseNestedObject(form)
|
|
246
239
|
this.$emit("update:modelValue", this.form);
|
|
247
240
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
<!-- input -->
|
|
33
33
|
<template v-if="item.component == 'input'">
|
|
34
|
-
<el-input v-model="
|
|
34
|
+
<el-input v-model="objItem.value"
|
|
35
35
|
:placeholder="item?.options?.placeholder"
|
|
36
36
|
clearable
|
|
37
37
|
:type="item?.options?.type"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
</template>
|
|
48
48
|
<!-- upload -->
|
|
49
49
|
<template v-else-if="item.component == 'upload'">
|
|
50
|
-
<template v-for="(_item, _index) in
|
|
50
|
+
<template v-for="(_item, _index) in objItem?.options.items"
|
|
51
51
|
:key="_index">
|
|
52
52
|
<lw-upload v-model="_item.value"
|
|
53
53
|
:height="item.height"
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
<template v-else-if="item.component == 'checkbox'">
|
|
70
70
|
<el-checkbox v-model="_item.value"
|
|
71
71
|
:label="_item.label"
|
|
72
|
-
v-for="(_item, _index) in
|
|
72
|
+
v-for="(_item, _index) in objItem?.options.items"
|
|
73
73
|
:key="_index"></el-checkbox>
|
|
74
74
|
</template>
|
|
75
75
|
<!-- checkboxGroup -->
|
|
76
76
|
<template v-else-if="item.component == 'checkboxGroup'">
|
|
77
|
-
<el-checkbox-group v-model="
|
|
77
|
+
<el-checkbox-group v-model="objItem.value">
|
|
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>
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
|
|
84
84
|
<!-- switch -->
|
|
85
85
|
<template v-else-if="item.component == 'switch'">
|
|
86
|
-
<el-switch v-model="
|
|
86
|
+
<el-switch v-model="objItem.value"
|
|
87
87
|
inline-prompt
|
|
88
88
|
:active-text="item?.options?.activeText"
|
|
89
89
|
:inactive-text="item?.options?.inactiveText" />
|
|
90
90
|
</template>
|
|
91
91
|
<!-- select -->
|
|
92
92
|
<template v-else-if="item.component == 'select'">
|
|
93
|
-
<el-select v-model="
|
|
93
|
+
<el-select v-model="objItem.value"
|
|
94
94
|
:multiple="item?.options?.multiple"
|
|
95
95
|
:allow-create="item?.options?.allowCreate"
|
|
96
96
|
default-first-option
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
</template>
|
|
111
111
|
<!-- treeSelect -->
|
|
112
112
|
<template v-else-if="item.component == 'treeSelect'">
|
|
113
|
-
<el-tree-select v-model="
|
|
113
|
+
<el-tree-select v-model="objItem.value"
|
|
114
114
|
:props="item?.options?.props"
|
|
115
115
|
:node-Key="item?.options?.nodeKey"
|
|
116
116
|
:multiple="item?.options?.multiple"
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
</template>
|
|
121
121
|
<!-- cascader -->
|
|
122
122
|
<template v-else-if="item.component == 'cascader'">
|
|
123
|
-
<el-cascader v-model="
|
|
123
|
+
<el-cascader v-model="objItem.value"
|
|
124
124
|
style="width: 100%;"
|
|
125
125
|
:props="item?.options?.props"
|
|
126
126
|
:separator="item?.options?.separator"
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
</template>
|
|
131
131
|
<!-- date -->
|
|
132
132
|
<template v-else-if="item.component == 'date'">
|
|
133
|
-
<el-date-picker v-model="
|
|
133
|
+
<el-date-picker v-model="objItem.value"
|
|
134
134
|
style="width: 100%;"
|
|
135
135
|
:type="item?.options?.type"
|
|
136
136
|
:start-placeholder="item?.options?.startPlaceholder"
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
</template>
|
|
146
146
|
<!-- number -->
|
|
147
147
|
<template v-else-if="item.component == 'number'">
|
|
148
|
-
<el-input-number v-model="
|
|
148
|
+
<el-input-number v-model="objItem.value"
|
|
149
149
|
:disabled="item?.options?.disabled"
|
|
150
150
|
:min="item?.options?.min"
|
|
151
151
|
:max="item?.options?.max"
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
</template>
|
|
162
162
|
<!-- radio -->
|
|
163
163
|
<template v-else-if="item.component == 'radio'">
|
|
164
|
-
<el-radio-group v-model="
|
|
164
|
+
<el-radio-group v-model="objItem.value"
|
|
165
165
|
:disabled="item?.options.disabled">
|
|
166
166
|
<el-radio v-for="_item in item?.options.items"
|
|
167
167
|
:key="_item.value"
|
|
@@ -170,35 +170,35 @@
|
|
|
170
170
|
</template>
|
|
171
171
|
<!-- color -->
|
|
172
172
|
<template v-else-if="item.component == 'color'">
|
|
173
|
-
<el-color-picker v-model="
|
|
173
|
+
<el-color-picker v-model="objItem.value" />
|
|
174
174
|
</template>
|
|
175
175
|
<!-- rate -->
|
|
176
176
|
<template v-else-if="item.component == 'rate'">
|
|
177
177
|
<el-rate style="margin-top: 6px;"
|
|
178
|
-
v-model="
|
|
178
|
+
v-model="objItem.value"></el-rate>
|
|
179
179
|
</template>
|
|
180
180
|
<!-- slider -->
|
|
181
181
|
<template v-else-if="item.component == 'slider'">
|
|
182
|
-
<el-slider v-model="
|
|
182
|
+
<el-slider v-model="objItem.value"
|
|
183
183
|
:marks="item?.options.marks"></el-slider>
|
|
184
184
|
</template>
|
|
185
185
|
|
|
186
186
|
<!-- tags -->
|
|
187
187
|
<template v-else-if="item.component == 'tags'">
|
|
188
188
|
<div class="tags-list">
|
|
189
|
-
<el-tag v-for="tag in
|
|
189
|
+
<el-tag v-for="tag in objItem.value"
|
|
190
190
|
:key="tag"
|
|
191
191
|
closable
|
|
192
192
|
:disable-transitions="false"
|
|
193
|
-
@close="tagClose(tag,
|
|
193
|
+
@close="tagClose(tag, objItem.value)">
|
|
194
194
|
{{ tag }}
|
|
195
195
|
</el-tag>
|
|
196
196
|
<el-input v-if="tagVisible[item.name]"
|
|
197
197
|
v-model="tagValue"
|
|
198
198
|
class="w-20"
|
|
199
199
|
size="small"
|
|
200
|
-
@keyup.enter="tagInputConfirm(item,
|
|
201
|
-
@blur="tagInputConfirm(item,
|
|
200
|
+
@keyup.enter="tagInputConfirm(item, objItem.value)"
|
|
201
|
+
@blur="tagInputConfirm(item, objItem.value)" />
|
|
202
202
|
<el-button v-else
|
|
203
203
|
class="button-new-tag"
|
|
204
204
|
size="small"
|
|
@@ -230,6 +230,7 @@ export default {
|
|
|
230
230
|
return {
|
|
231
231
|
tagVisible: {},
|
|
232
232
|
dataForm: {},
|
|
233
|
+
objItem: {},
|
|
233
234
|
tagValue: ''
|
|
234
235
|
}
|
|
235
236
|
},
|
|
@@ -254,28 +255,35 @@ export default {
|
|
|
254
255
|
form: {
|
|
255
256
|
handler(val) {
|
|
256
257
|
if (this.item.component === 'checkbox' || this.item.component === 'upload') {
|
|
257
|
-
this.
|
|
258
|
+
this.objItem.options?.items?.forEach((option) => {
|
|
258
259
|
option.value = this.flattenObject(this.form, option.name, option.value)
|
|
259
260
|
});
|
|
260
261
|
} else {
|
|
261
|
-
this.
|
|
262
|
+
this.objItem.value= this.flattenObject(this.form, this.item.name, this.objItem.value)
|
|
262
263
|
}
|
|
263
264
|
},
|
|
264
265
|
immediate: true,
|
|
265
266
|
deep: true
|
|
266
267
|
},
|
|
267
268
|
item: {
|
|
269
|
+
handler(val) {
|
|
270
|
+
this.objItem = val
|
|
271
|
+
},
|
|
272
|
+
immediate: true,
|
|
273
|
+
deep: true
|
|
274
|
+
},
|
|
275
|
+
objItem: {
|
|
268
276
|
handler(val) {
|
|
269
277
|
if (val.component === 'checkbox' || val.component === 'upload') {
|
|
270
278
|
val.options?.items?.forEach((option) => {
|
|
271
279
|
this.unflattenObject(this.form, option.name, option.value)
|
|
272
280
|
});
|
|
273
281
|
} else {
|
|
274
|
-
this.unflattenObject(this.form,
|
|
282
|
+
this.unflattenObject(this.form, val.name, val.value)
|
|
275
283
|
}
|
|
276
284
|
},
|
|
277
285
|
deep: true
|
|
278
|
-
}
|
|
286
|
+
},
|
|
279
287
|
},
|
|
280
288
|
methods: {
|
|
281
289
|
flattenObject(obj, key, defaultValue = '') {
|
|
@@ -297,18 +305,17 @@ export default {
|
|
|
297
305
|
unflattenObject(obj, path, value) {
|
|
298
306
|
if (!path || !obj) { return false }
|
|
299
307
|
const keys = path.split('.'); // 按点分隔路径
|
|
300
|
-
let current = obj; // 指向传入的对象(如 this.form)
|
|
301
308
|
|
|
302
309
|
keys.forEach((key, index) => {
|
|
303
310
|
if (index === keys.length - 1) {
|
|
304
311
|
// 最后一级,直接赋值
|
|
305
|
-
|
|
312
|
+
obj[key] = value || obj[path];
|
|
306
313
|
} else {
|
|
307
314
|
// 如果不存在该层级,创建空对象
|
|
308
|
-
if (!
|
|
309
|
-
|
|
315
|
+
if (!obj[key] || typeof obj[key] !== 'object') {
|
|
316
|
+
obj[key] = {};
|
|
310
317
|
}
|
|
311
|
-
|
|
318
|
+
obj = obj[key]; // 进入下一层
|
|
312
319
|
}
|
|
313
320
|
});
|
|
314
321
|
|