@vxe-ui/plugin-render-element 4.3.1 → 4.4.1
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/LICENSE +20 -20
- package/README.md +176 -176
- package/dist/index.umd.js +56 -17
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +3 -3
- package/es/index.js +3 -3
- package/es/table/index.js +35 -6
- package/lib/index.common.js +3 -3
- package/lib/index.js +3 -3
- package/lib/index.umd.js +56 -17
- package/lib/index.umd.min.js +1 -1
- package/lib/table/index.js +48 -9
- package/package.json +77 -78
- package/src/form/index.ts +326 -326
- package/src/form-design/checkbox-widget.ts +167 -167
- package/src/form-design/date-picker-widget.ts +144 -144
- package/src/form-design/index.ts +101 -101
- package/src/form-design/input-widget.ts +145 -145
- package/src/form-design/number-input-widget.ts +144 -144
- package/src/form-design/radio-widget.ts +167 -167
- package/src/form-design/select-widget.ts +166 -166
- package/src/form-design/switch-widget.ts +140 -140
- package/src/form-design/textarea-widget.ts +149 -149
- package/src/form-design/use.ts +255 -255
- package/src/index.ts +124 -124
- package/src/store/index.ts +5 -5
- package/src/table/index.ts +759 -729
- package/src/util/comp.ts +21 -21
- package/types/index.d.ts +19 -19
package/src/form-design/use.ts
CHANGED
|
@@ -1,255 +1,255 @@
|
|
|
1
|
-
import { VNode, h, onMounted, ref, watch } from 'vue'
|
|
2
|
-
|
|
3
|
-
import type { VxeUIExport, VxeGlobalRendererHandles } from 'vxe-pc-ui'
|
|
4
|
-
|
|
5
|
-
export interface WidgetDataSourceOptionSubObjVO {
|
|
6
|
-
value: string,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface WidgetDataSourceOptionObjVO {
|
|
10
|
-
value: string,
|
|
11
|
-
options?: WidgetDataSourceOptionSubObjVO[]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function useWidgetPropDataSource (VxeUI: VxeUIExport, props: {
|
|
15
|
-
readonly renderOpts: VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions;
|
|
16
|
-
readonly renderParams: VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<{
|
|
17
|
-
options: WidgetDataSourceOptionObjVO[]
|
|
18
|
-
}>;
|
|
19
|
-
}, isSubOption: boolean) {
|
|
20
|
-
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem')
|
|
21
|
-
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
|
|
22
|
-
const VxeUITextareaComponent = VxeUI.getComponent('VxeTextarea')
|
|
23
|
-
const VxeUITipComponent = VxeUI.getComponent('VxeTip')
|
|
24
|
-
|
|
25
|
-
const optionsContent = ref('')
|
|
26
|
-
const expandIndexList = ref<number[]>([])
|
|
27
|
-
|
|
28
|
-
const addOptionEvent = () => {
|
|
29
|
-
const { renderParams } = props
|
|
30
|
-
const { widget } = renderParams
|
|
31
|
-
const options = widget.options.options || []
|
|
32
|
-
options.push({
|
|
33
|
-
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [options.length + 1])
|
|
34
|
-
})
|
|
35
|
-
widget.options.options = [...options]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const subRE = /^(\s|\t)+/
|
|
39
|
-
|
|
40
|
-
const hasSubOption = (str: string) => {
|
|
41
|
-
return subRE.test(str)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const expandAllOption = () => {
|
|
45
|
-
const { renderParams } = props
|
|
46
|
-
const { widget } = renderParams
|
|
47
|
-
const options = widget.options.options || []
|
|
48
|
-
const indexList: number[] = []
|
|
49
|
-
options.forEach((group, gIndex) => {
|
|
50
|
-
const { options } = group
|
|
51
|
-
if (options && options.length) {
|
|
52
|
-
indexList.push(gIndex)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
expandIndexList.value = indexList
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const toggleExpandOption = (item: WidgetDataSourceOptionSubObjVO, gIndex: number) => {
|
|
59
|
-
if (expandIndexList.value.includes(gIndex)) {
|
|
60
|
-
expandIndexList.value = expandIndexList.value.filter(num => num !== gIndex)
|
|
61
|
-
} else {
|
|
62
|
-
expandIndexList.value.push(gIndex)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const confirmBatchAddOptionEvent = () => {
|
|
67
|
-
const { renderParams } = props
|
|
68
|
-
const { widget } = renderParams
|
|
69
|
-
const optList: WidgetDataSourceOptionSubObjVO[] = []
|
|
70
|
-
const rowList = optionsContent.value.split('\n')
|
|
71
|
-
let prevGroup: Required<WidgetDataSourceOptionObjVO> | null = null
|
|
72
|
-
if (isSubOption) {
|
|
73
|
-
rowList.forEach((str, index) => {
|
|
74
|
-
const nextStr = rowList[index + 1]
|
|
75
|
-
const value = str.trim()
|
|
76
|
-
if (!value) {
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
const item: WidgetDataSourceOptionSubObjVO = {
|
|
80
|
-
value
|
|
81
|
-
}
|
|
82
|
-
if (prevGroup) {
|
|
83
|
-
if (hasSubOption(str)) {
|
|
84
|
-
prevGroup.options.push(item)
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
prevGroup = null
|
|
88
|
-
optList.push(item)
|
|
89
|
-
} else {
|
|
90
|
-
optList.push(item)
|
|
91
|
-
}
|
|
92
|
-
if (nextStr) {
|
|
93
|
-
if (hasSubOption(nextStr)) {
|
|
94
|
-
prevGroup = Object.assign(item, { options: [] })
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
} else {
|
|
99
|
-
rowList.forEach((str) => {
|
|
100
|
-
optList.push({
|
|
101
|
-
value: str.trim()
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
widget.options.options = optList
|
|
106
|
-
expandAllOption()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const openPopupEditEvent = () => {
|
|
110
|
-
const { renderParams } = props
|
|
111
|
-
const { widget } = renderParams
|
|
112
|
-
|
|
113
|
-
const contList: string[] = []
|
|
114
|
-
widget.options.options?.forEach(group => {
|
|
115
|
-
contList.push(group.value)
|
|
116
|
-
group.options?.forEach(item => {
|
|
117
|
-
contList.push(`\t${item.value}`)
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
optionsContent.value = contList.join('\n')
|
|
122
|
-
|
|
123
|
-
VxeUI.modal.open({
|
|
124
|
-
title: `${widget.title} - ${VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption')}`,
|
|
125
|
-
width: 500,
|
|
126
|
-
height: '50vh ',
|
|
127
|
-
resize: true,
|
|
128
|
-
showFooter: true,
|
|
129
|
-
showCancelButton: true,
|
|
130
|
-
showConfirmButton: true,
|
|
131
|
-
confirmButtonText: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.buildOption'),
|
|
132
|
-
onConfirm: confirmBatchAddOptionEvent,
|
|
133
|
-
slots: {
|
|
134
|
-
default () {
|
|
135
|
-
return h('div', {
|
|
136
|
-
class: 'vxe-form-design--widget-form-item-data-source-popup'
|
|
137
|
-
}, [
|
|
138
|
-
h(VxeUITipComponent, {
|
|
139
|
-
status: 'primary',
|
|
140
|
-
title: '',
|
|
141
|
-
content: VxeUI.getI18n(`vxe.formDesign.widgetProp.dataSource.${isSubOption ? 'batchEditSubTip' : 'batchEditTip'}`)
|
|
142
|
-
}),
|
|
143
|
-
h(VxeUITextareaComponent, {
|
|
144
|
-
resize: 'none',
|
|
145
|
-
modelValue: optionsContent.value,
|
|
146
|
-
'onUpdate:modelValue' (val: any) {
|
|
147
|
-
optionsContent.value = val
|
|
148
|
-
}
|
|
149
|
-
})
|
|
150
|
-
])
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const renderOption = (item: WidgetDataSourceOptionSubObjVO, hasFirstLevel: boolean, isExpand: boolean, gIndex: number, hasSub: boolean, isFirst: boolean, isLast: boolean) => {
|
|
157
|
-
return h('div', {
|
|
158
|
-
class: ['vxe-form-design--widget-form-item-data-source-option', {
|
|
159
|
-
'is--first': isFirst,
|
|
160
|
-
'is--last': isLast
|
|
161
|
-
}]
|
|
162
|
-
}, [
|
|
163
|
-
h('div', {
|
|
164
|
-
class: 'vxe-form-design--widget-expand-btn'
|
|
165
|
-
}, hasFirstLevel && hasSub
|
|
166
|
-
? [
|
|
167
|
-
h('i', {
|
|
168
|
-
class: isExpand ? VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_CLOSE : VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_OPEN,
|
|
169
|
-
onClick () {
|
|
170
|
-
toggleExpandOption(item, gIndex)
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
]
|
|
174
|
-
: []),
|
|
175
|
-
h('input', {
|
|
176
|
-
class: 'vxe-default-input',
|
|
177
|
-
value: item.value,
|
|
178
|
-
onInput (evnt: InputEvent & { currentTarget: HTMLInputElement }) {
|
|
179
|
-
item.value = evnt.currentTarget.value
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
h(VxeUIButtonComponent, {
|
|
183
|
-
status: 'danger',
|
|
184
|
-
mode: 'text',
|
|
185
|
-
icon: VxeUI.getIcon().FORM_DESIGN_WIDGET_DELETE
|
|
186
|
-
})
|
|
187
|
-
])
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const renderOptions = () => {
|
|
191
|
-
const { renderParams } = props
|
|
192
|
-
const { widget } = renderParams
|
|
193
|
-
const { options } = widget
|
|
194
|
-
const groups = options.options
|
|
195
|
-
const optVNs: VNode[] = []
|
|
196
|
-
if (groups) {
|
|
197
|
-
groups.forEach((group, gIndex) => {
|
|
198
|
-
const { options } = group
|
|
199
|
-
const isExpand = expandIndexList.value.includes(gIndex)
|
|
200
|
-
if (options && options.length) {
|
|
201
|
-
optVNs.push(renderOption(group, true, isExpand, gIndex, true, gIndex === 0, gIndex === groups.length - 1))
|
|
202
|
-
if (isExpand) {
|
|
203
|
-
optVNs.push(
|
|
204
|
-
h('div', {
|
|
205
|
-
class: 'vxe-form-design--widget-form-item-data-source-sub-option'
|
|
206
|
-
}, options.map(item => renderOption(item, false, isExpand, 0, false, false, false)))
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
} else {
|
|
210
|
-
optVNs.push(renderOption(group, true, isExpand, gIndex, false, gIndex === 0, gIndex === groups.length - 1))
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
return optVNs
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
watch(() => props.renderParams.widget, () => {
|
|
218
|
-
expandAllOption()
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
onMounted(() => {
|
|
222
|
-
expandAllOption()
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
renderDataSourceFormItem () {
|
|
227
|
-
return h(VxeUIFormItemComponent, {
|
|
228
|
-
title: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.name'),
|
|
229
|
-
field: 'options'
|
|
230
|
-
}, {
|
|
231
|
-
default () {
|
|
232
|
-
return [
|
|
233
|
-
h('div', {}, [
|
|
234
|
-
h(VxeUIButtonComponent, {
|
|
235
|
-
status: 'primary',
|
|
236
|
-
mode: 'text',
|
|
237
|
-
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.addOption'),
|
|
238
|
-
onClick: addOptionEvent
|
|
239
|
-
}),
|
|
240
|
-
h(VxeUIButtonComponent, {
|
|
241
|
-
status: 'primary',
|
|
242
|
-
mode: 'text',
|
|
243
|
-
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption'),
|
|
244
|
-
onClick: openPopupEditEvent
|
|
245
|
-
})
|
|
246
|
-
]),
|
|
247
|
-
h('div', {
|
|
248
|
-
class: 'vxe-form-design--widget-form-item-data-source'
|
|
249
|
-
}, renderOptions())
|
|
250
|
-
]
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
1
|
+
import { VNode, h, onMounted, ref, watch } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { VxeUIExport, VxeGlobalRendererHandles } from 'vxe-pc-ui'
|
|
4
|
+
|
|
5
|
+
export interface WidgetDataSourceOptionSubObjVO {
|
|
6
|
+
value: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WidgetDataSourceOptionObjVO {
|
|
10
|
+
value: string,
|
|
11
|
+
options?: WidgetDataSourceOptionSubObjVO[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useWidgetPropDataSource (VxeUI: VxeUIExport, props: {
|
|
15
|
+
readonly renderOpts: VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions;
|
|
16
|
+
readonly renderParams: VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<{
|
|
17
|
+
options: WidgetDataSourceOptionObjVO[]
|
|
18
|
+
}>;
|
|
19
|
+
}, isSubOption: boolean) {
|
|
20
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem')
|
|
21
|
+
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
|
|
22
|
+
const VxeUITextareaComponent = VxeUI.getComponent('VxeTextarea')
|
|
23
|
+
const VxeUITipComponent = VxeUI.getComponent('VxeTip')
|
|
24
|
+
|
|
25
|
+
const optionsContent = ref('')
|
|
26
|
+
const expandIndexList = ref<number[]>([])
|
|
27
|
+
|
|
28
|
+
const addOptionEvent = () => {
|
|
29
|
+
const { renderParams } = props
|
|
30
|
+
const { widget } = renderParams
|
|
31
|
+
const options = widget.options.options || []
|
|
32
|
+
options.push({
|
|
33
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [options.length + 1])
|
|
34
|
+
})
|
|
35
|
+
widget.options.options = [...options]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const subRE = /^(\s|\t)+/
|
|
39
|
+
|
|
40
|
+
const hasSubOption = (str: string) => {
|
|
41
|
+
return subRE.test(str)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const expandAllOption = () => {
|
|
45
|
+
const { renderParams } = props
|
|
46
|
+
const { widget } = renderParams
|
|
47
|
+
const options = widget.options.options || []
|
|
48
|
+
const indexList: number[] = []
|
|
49
|
+
options.forEach((group, gIndex) => {
|
|
50
|
+
const { options } = group
|
|
51
|
+
if (options && options.length) {
|
|
52
|
+
indexList.push(gIndex)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
expandIndexList.value = indexList
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const toggleExpandOption = (item: WidgetDataSourceOptionSubObjVO, gIndex: number) => {
|
|
59
|
+
if (expandIndexList.value.includes(gIndex)) {
|
|
60
|
+
expandIndexList.value = expandIndexList.value.filter(num => num !== gIndex)
|
|
61
|
+
} else {
|
|
62
|
+
expandIndexList.value.push(gIndex)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const confirmBatchAddOptionEvent = () => {
|
|
67
|
+
const { renderParams } = props
|
|
68
|
+
const { widget } = renderParams
|
|
69
|
+
const optList: WidgetDataSourceOptionSubObjVO[] = []
|
|
70
|
+
const rowList = optionsContent.value.split('\n')
|
|
71
|
+
let prevGroup: Required<WidgetDataSourceOptionObjVO> | null = null
|
|
72
|
+
if (isSubOption) {
|
|
73
|
+
rowList.forEach((str, index) => {
|
|
74
|
+
const nextStr = rowList[index + 1]
|
|
75
|
+
const value = str.trim()
|
|
76
|
+
if (!value) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
const item: WidgetDataSourceOptionSubObjVO = {
|
|
80
|
+
value
|
|
81
|
+
}
|
|
82
|
+
if (prevGroup) {
|
|
83
|
+
if (hasSubOption(str)) {
|
|
84
|
+
prevGroup.options.push(item)
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
prevGroup = null
|
|
88
|
+
optList.push(item)
|
|
89
|
+
} else {
|
|
90
|
+
optList.push(item)
|
|
91
|
+
}
|
|
92
|
+
if (nextStr) {
|
|
93
|
+
if (hasSubOption(nextStr)) {
|
|
94
|
+
prevGroup = Object.assign(item, { options: [] })
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
} else {
|
|
99
|
+
rowList.forEach((str) => {
|
|
100
|
+
optList.push({
|
|
101
|
+
value: str.trim()
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
widget.options.options = optList
|
|
106
|
+
expandAllOption()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const openPopupEditEvent = () => {
|
|
110
|
+
const { renderParams } = props
|
|
111
|
+
const { widget } = renderParams
|
|
112
|
+
|
|
113
|
+
const contList: string[] = []
|
|
114
|
+
widget.options.options?.forEach(group => {
|
|
115
|
+
contList.push(group.value)
|
|
116
|
+
group.options?.forEach(item => {
|
|
117
|
+
contList.push(`\t${item.value}`)
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
optionsContent.value = contList.join('\n')
|
|
122
|
+
|
|
123
|
+
VxeUI.modal.open({
|
|
124
|
+
title: `${widget.title} - ${VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption')}`,
|
|
125
|
+
width: 500,
|
|
126
|
+
height: '50vh ',
|
|
127
|
+
resize: true,
|
|
128
|
+
showFooter: true,
|
|
129
|
+
showCancelButton: true,
|
|
130
|
+
showConfirmButton: true,
|
|
131
|
+
confirmButtonText: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.buildOption'),
|
|
132
|
+
onConfirm: confirmBatchAddOptionEvent,
|
|
133
|
+
slots: {
|
|
134
|
+
default () {
|
|
135
|
+
return h('div', {
|
|
136
|
+
class: 'vxe-form-design--widget-form-item-data-source-popup'
|
|
137
|
+
}, [
|
|
138
|
+
h(VxeUITipComponent, {
|
|
139
|
+
status: 'primary',
|
|
140
|
+
title: '',
|
|
141
|
+
content: VxeUI.getI18n(`vxe.formDesign.widgetProp.dataSource.${isSubOption ? 'batchEditSubTip' : 'batchEditTip'}`)
|
|
142
|
+
}),
|
|
143
|
+
h(VxeUITextareaComponent, {
|
|
144
|
+
resize: 'none',
|
|
145
|
+
modelValue: optionsContent.value,
|
|
146
|
+
'onUpdate:modelValue' (val: any) {
|
|
147
|
+
optionsContent.value = val
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
])
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const renderOption = (item: WidgetDataSourceOptionSubObjVO, hasFirstLevel: boolean, isExpand: boolean, gIndex: number, hasSub: boolean, isFirst: boolean, isLast: boolean) => {
|
|
157
|
+
return h('div', {
|
|
158
|
+
class: ['vxe-form-design--widget-form-item-data-source-option', {
|
|
159
|
+
'is--first': isFirst,
|
|
160
|
+
'is--last': isLast
|
|
161
|
+
}]
|
|
162
|
+
}, [
|
|
163
|
+
h('div', {
|
|
164
|
+
class: 'vxe-form-design--widget-expand-btn'
|
|
165
|
+
}, hasFirstLevel && hasSub
|
|
166
|
+
? [
|
|
167
|
+
h('i', {
|
|
168
|
+
class: isExpand ? VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_CLOSE : VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_OPEN,
|
|
169
|
+
onClick () {
|
|
170
|
+
toggleExpandOption(item, gIndex)
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
: []),
|
|
175
|
+
h('input', {
|
|
176
|
+
class: 'vxe-default-input',
|
|
177
|
+
value: item.value,
|
|
178
|
+
onInput (evnt: InputEvent & { currentTarget: HTMLInputElement }) {
|
|
179
|
+
item.value = evnt.currentTarget.value
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
h(VxeUIButtonComponent, {
|
|
183
|
+
status: 'danger',
|
|
184
|
+
mode: 'text',
|
|
185
|
+
icon: VxeUI.getIcon().FORM_DESIGN_WIDGET_DELETE
|
|
186
|
+
})
|
|
187
|
+
])
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const renderOptions = () => {
|
|
191
|
+
const { renderParams } = props
|
|
192
|
+
const { widget } = renderParams
|
|
193
|
+
const { options } = widget
|
|
194
|
+
const groups = options.options
|
|
195
|
+
const optVNs: VNode[] = []
|
|
196
|
+
if (groups) {
|
|
197
|
+
groups.forEach((group, gIndex) => {
|
|
198
|
+
const { options } = group
|
|
199
|
+
const isExpand = expandIndexList.value.includes(gIndex)
|
|
200
|
+
if (options && options.length) {
|
|
201
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, true, gIndex === 0, gIndex === groups.length - 1))
|
|
202
|
+
if (isExpand) {
|
|
203
|
+
optVNs.push(
|
|
204
|
+
h('div', {
|
|
205
|
+
class: 'vxe-form-design--widget-form-item-data-source-sub-option'
|
|
206
|
+
}, options.map(item => renderOption(item, false, isExpand, 0, false, false, false)))
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, false, gIndex === 0, gIndex === groups.length - 1))
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
return optVNs
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
watch(() => props.renderParams.widget, () => {
|
|
218
|
+
expandAllOption()
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
onMounted(() => {
|
|
222
|
+
expandAllOption()
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
renderDataSourceFormItem () {
|
|
227
|
+
return h(VxeUIFormItemComponent, {
|
|
228
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.name'),
|
|
229
|
+
field: 'options'
|
|
230
|
+
}, {
|
|
231
|
+
default () {
|
|
232
|
+
return [
|
|
233
|
+
h('div', {}, [
|
|
234
|
+
h(VxeUIButtonComponent, {
|
|
235
|
+
status: 'primary',
|
|
236
|
+
mode: 'text',
|
|
237
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.addOption'),
|
|
238
|
+
onClick: addOptionEvent
|
|
239
|
+
}),
|
|
240
|
+
h(VxeUIButtonComponent, {
|
|
241
|
+
status: 'primary',
|
|
242
|
+
mode: 'text',
|
|
243
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption'),
|
|
244
|
+
onClick: openPopupEditEvent
|
|
245
|
+
})
|
|
246
|
+
]),
|
|
247
|
+
h('div', {
|
|
248
|
+
class: 'vxe-form-design--widget-form-item-data-source'
|
|
249
|
+
}, renderOptions())
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|