@vxe-ui/plugin-render-antd 4.2.2 → 4.3.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/dist/index.umd.js +2730 -2876
- package/dist/index.umd.min.js +1 -1
- package/es/form/index.js +265 -0
- package/es/form-design/checkbox-widget.js +148 -0
- package/es/form-design/date-picker-widget.js +130 -0
- package/es/form-design/index.js +97 -0
- package/es/form-design/input-widget.js +130 -0
- package/es/form-design/number-input-widget.js +130 -0
- package/es/form-design/radio-widget.js +148 -0
- package/es/form-design/select-widget.js +140 -0
- package/es/form-design/switch-widget.js +126 -0
- package/es/form-design/textarea-widget.js +134 -0
- package/es/form-design/use.js +226 -0
- package/es/index.esm.js +105 -0
- package/es/index.js +105 -0
- package/es/store/index.js +2 -0
- package/es/style.css +63 -0
- package/es/style.min.css +1 -0
- package/es/table/index.js +472 -0
- package/es/util/comp.js +9 -0
- package/{dist → lib}/form/index.js +3 -0
- package/{dist → lib}/index.common.js +3 -3
- package/{dist → lib}/index.js +3 -3
- package/lib/index.umd.js +2731 -0
- package/lib/index.umd.min.js +1 -0
- package/lib/style.css +63 -0
- package/lib/style.min.css +1 -0
- package/package.json +16 -19
- package/src/form/index.ts +5 -2
- package/dist/all.common.js +0 -2619
- /package/{dist → lib}/form-design/checkbox-widget.js +0 -0
- /package/{dist → lib}/form-design/date-picker-widget.js +0 -0
- /package/{dist → lib}/form-design/index.js +0 -0
- /package/{dist → lib}/form-design/input-widget.js +0 -0
- /package/{dist → lib}/form-design/number-input-widget.js +0 -0
- /package/{dist → lib}/form-design/radio-widget.js +0 -0
- /package/{dist → lib}/form-design/select-widget.js +0 -0
- /package/{dist → lib}/form-design/switch-widget.js +0 -0
- /package/{dist → lib}/form-design/textarea-widget.js +0 -0
- /package/{dist → lib}/form-design/use.js +0 -0
- /package/{dist → lib}/store/index.js +0 -0
- /package/{dist → lib}/table/index.js +0 -0
- /package/{dist → lib}/util/comp.js +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { useWidgetPropDataSource } from './use';
|
|
3
|
+
import { getCurrComponent } from '../util/comp';
|
|
4
|
+
import XEUtils from 'xe-utils';
|
|
5
|
+
export function createWidgetASelect(VxeUI) {
|
|
6
|
+
const getWidgetASelectConfig = (params) => {
|
|
7
|
+
return {
|
|
8
|
+
title: '下拉框',
|
|
9
|
+
icon: 'vxe-icon-select',
|
|
10
|
+
options: {
|
|
11
|
+
placeholder: '请选择',
|
|
12
|
+
options: XEUtils.range(0, 3).map((v, i) => {
|
|
13
|
+
return {
|
|
14
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [i + 1])
|
|
15
|
+
};
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const WidgetASelectFormComponent = defineComponent({
|
|
21
|
+
props: {
|
|
22
|
+
renderOpts: {
|
|
23
|
+
type: Object,
|
|
24
|
+
default: () => ({})
|
|
25
|
+
},
|
|
26
|
+
renderParams: {
|
|
27
|
+
type: Object,
|
|
28
|
+
default: () => ({})
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [],
|
|
32
|
+
setup(props) {
|
|
33
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
34
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
35
|
+
const VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
36
|
+
const VxeUIInputComponent = VxeUI.getComponent('VxeInput');
|
|
37
|
+
const { renderDataSourceFormItem } = useWidgetPropDataSource(VxeUI, props, false);
|
|
38
|
+
return () => {
|
|
39
|
+
const { renderParams } = props;
|
|
40
|
+
const { widget } = renderParams;
|
|
41
|
+
return h(VxeUIFormComponent, {
|
|
42
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
43
|
+
vertical: true,
|
|
44
|
+
span: 24,
|
|
45
|
+
titleBold: true,
|
|
46
|
+
titleOverflow: true,
|
|
47
|
+
data: widget.options
|
|
48
|
+
}, {
|
|
49
|
+
default() {
|
|
50
|
+
return [
|
|
51
|
+
h(VxeUIFormItemComponent, {
|
|
52
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
53
|
+
}, {
|
|
54
|
+
default() {
|
|
55
|
+
return h(VxeUIInputComponent, {
|
|
56
|
+
modelValue: widget.title,
|
|
57
|
+
'onUpdate:modelValue'(val) {
|
|
58
|
+
widget.title = val;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
h(VxeUIFormItemComponent, {
|
|
64
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
65
|
+
field: 'placeholder',
|
|
66
|
+
itemRender: { name: 'ElInput' }
|
|
67
|
+
}),
|
|
68
|
+
h(VxeUIFormItemComponent, {
|
|
69
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
70
|
+
}, {
|
|
71
|
+
default() {
|
|
72
|
+
return h(VxeUISwitchComponent, {
|
|
73
|
+
modelValue: widget.required,
|
|
74
|
+
'onUpdate:modelValue'(val) {
|
|
75
|
+
widget.required = val;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
renderDataSourceFormItem()
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const WidgetASelectViewComponent = defineComponent({
|
|
88
|
+
props: {
|
|
89
|
+
renderOpts: {
|
|
90
|
+
type: Object,
|
|
91
|
+
default: () => ({})
|
|
92
|
+
},
|
|
93
|
+
renderParams: {
|
|
94
|
+
type: Object,
|
|
95
|
+
default: () => ({})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
emits: [],
|
|
99
|
+
setup(props) {
|
|
100
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
101
|
+
const changeEvent = () => {
|
|
102
|
+
const { renderParams } = props;
|
|
103
|
+
const { widget, $formView } = renderParams;
|
|
104
|
+
if ($formView) {
|
|
105
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
106
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return () => {
|
|
110
|
+
const { renderParams } = props;
|
|
111
|
+
const { widget, $formView } = renderParams;
|
|
112
|
+
const { options } = widget;
|
|
113
|
+
return h(VxeUIFormItemComponent, {
|
|
114
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
115
|
+
field: widget.field,
|
|
116
|
+
title: widget.title
|
|
117
|
+
}, {
|
|
118
|
+
default() {
|
|
119
|
+
return h(getCurrComponent('a-select'), {
|
|
120
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
121
|
+
options: options.options,
|
|
122
|
+
placeholder: options.placeholder,
|
|
123
|
+
onChange: changeEvent,
|
|
124
|
+
'onUpdate:value'(val) {
|
|
125
|
+
if ($formView) {
|
|
126
|
+
$formView.setItemValue(widget, val);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
getWidgetASelectConfig,
|
|
137
|
+
WidgetASelectFormComponent,
|
|
138
|
+
WidgetASelectViewComponent
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { getCurrComponent } from '../util/comp';
|
|
3
|
+
export function createWidgetASwitch(VxeUI) {
|
|
4
|
+
const getWidgetASwitchConfig = (params) => {
|
|
5
|
+
return {
|
|
6
|
+
title: '是/否',
|
|
7
|
+
icon: 'vxe-icon-switch',
|
|
8
|
+
options: {}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const WidgetASwitchFormComponent = defineComponent({
|
|
12
|
+
props: {
|
|
13
|
+
renderOpts: {
|
|
14
|
+
type: Object,
|
|
15
|
+
default: () => ({})
|
|
16
|
+
},
|
|
17
|
+
renderParams: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => ({})
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
emits: [],
|
|
23
|
+
setup(props) {
|
|
24
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
25
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
26
|
+
const VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
27
|
+
const VxeUIInputComponent = VxeUI.getComponent('VxeInput');
|
|
28
|
+
return () => {
|
|
29
|
+
const { renderParams } = props;
|
|
30
|
+
const { widget } = renderParams;
|
|
31
|
+
return h(VxeUIFormComponent, {
|
|
32
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
33
|
+
vertical: true,
|
|
34
|
+
span: 24,
|
|
35
|
+
titleBold: true,
|
|
36
|
+
titleOverflow: true,
|
|
37
|
+
data: widget.options
|
|
38
|
+
}, {
|
|
39
|
+
default() {
|
|
40
|
+
return [
|
|
41
|
+
h(VxeUIFormItemComponent, {
|
|
42
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
43
|
+
}, {
|
|
44
|
+
default() {
|
|
45
|
+
return h(VxeUIInputComponent, {
|
|
46
|
+
modelValue: widget.title,
|
|
47
|
+
'onUpdate:modelValue'(val) {
|
|
48
|
+
widget.title = val;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
h(VxeUIFormItemComponent, {
|
|
54
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
55
|
+
field: 'placeholder',
|
|
56
|
+
itemRender: { name: 'ElInput' }
|
|
57
|
+
}),
|
|
58
|
+
h(VxeUIFormItemComponent, {
|
|
59
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
60
|
+
}, {
|
|
61
|
+
default() {
|
|
62
|
+
return h(VxeUISwitchComponent, {
|
|
63
|
+
modelValue: widget.required,
|
|
64
|
+
'onUpdate:modelValue'(val) {
|
|
65
|
+
widget.required = val;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const WidgetASwitchViewComponent = defineComponent({
|
|
77
|
+
props: {
|
|
78
|
+
renderOpts: {
|
|
79
|
+
type: Object,
|
|
80
|
+
default: () => ({})
|
|
81
|
+
},
|
|
82
|
+
renderParams: {
|
|
83
|
+
type: Object,
|
|
84
|
+
default: () => ({})
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
emits: [],
|
|
88
|
+
setup(props) {
|
|
89
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
90
|
+
const changeEvent = () => {
|
|
91
|
+
const { renderParams } = props;
|
|
92
|
+
const { widget, $formView } = renderParams;
|
|
93
|
+
if ($formView) {
|
|
94
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
95
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return () => {
|
|
99
|
+
const { renderParams } = props;
|
|
100
|
+
const { widget, $formView } = renderParams;
|
|
101
|
+
return h(VxeUIFormItemComponent, {
|
|
102
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
103
|
+
field: widget.field,
|
|
104
|
+
title: widget.title
|
|
105
|
+
}, {
|
|
106
|
+
default() {
|
|
107
|
+
return h(getCurrComponent('a-switch'), {
|
|
108
|
+
checked: $formView ? $formView.getItemValue(widget) : null,
|
|
109
|
+
onChange: changeEvent,
|
|
110
|
+
'onUpdate:checked'(val) {
|
|
111
|
+
if ($formView) {
|
|
112
|
+
$formView.setItemValue(widget, val);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
getWidgetASwitchConfig,
|
|
123
|
+
WidgetASwitchFormComponent,
|
|
124
|
+
WidgetASwitchViewComponent
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { getCurrComponent } from '../util/comp';
|
|
3
|
+
export function createWidgetATextarea(VxeUI) {
|
|
4
|
+
const getWidgetATextareaConfig = (params) => {
|
|
5
|
+
return {
|
|
6
|
+
title: '文本域',
|
|
7
|
+
icon: 'vxe-icon-textarea',
|
|
8
|
+
options: {
|
|
9
|
+
placeholder: '请输入'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const WidgetATextareaFormComponent = defineComponent({
|
|
14
|
+
props: {
|
|
15
|
+
renderOpts: {
|
|
16
|
+
type: Object,
|
|
17
|
+
default: () => ({})
|
|
18
|
+
},
|
|
19
|
+
renderParams: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => ({})
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
emits: [],
|
|
25
|
+
setup(props) {
|
|
26
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
27
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
28
|
+
const VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
29
|
+
const VxeUIInputComponent = VxeUI.getComponent('VxeInput');
|
|
30
|
+
return () => {
|
|
31
|
+
const { renderParams } = props;
|
|
32
|
+
const { widget } = renderParams;
|
|
33
|
+
return h(VxeUIFormComponent, {
|
|
34
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
35
|
+
vertical: true,
|
|
36
|
+
span: 24,
|
|
37
|
+
titleBold: true,
|
|
38
|
+
titleOverflow: true,
|
|
39
|
+
data: widget.options
|
|
40
|
+
}, {
|
|
41
|
+
default() {
|
|
42
|
+
return [
|
|
43
|
+
h(VxeUIFormItemComponent, {
|
|
44
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
45
|
+
}, {
|
|
46
|
+
default() {
|
|
47
|
+
return h(VxeUIInputComponent, {
|
|
48
|
+
modelValue: widget.title,
|
|
49
|
+
'onUpdate:modelValue'(val) {
|
|
50
|
+
widget.title = val;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
h(VxeUIFormItemComponent, {
|
|
56
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
57
|
+
field: 'placeholder',
|
|
58
|
+
itemRender: { name: 'ElInput' }
|
|
59
|
+
}),
|
|
60
|
+
h(VxeUIFormItemComponent, {
|
|
61
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
62
|
+
}, {
|
|
63
|
+
default() {
|
|
64
|
+
return h(VxeUISwitchComponent, {
|
|
65
|
+
modelValue: widget.required,
|
|
66
|
+
'onUpdate:modelValue'(val) {
|
|
67
|
+
widget.required = val;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const WidgetATextareaViewComponent = defineComponent({
|
|
79
|
+
props: {
|
|
80
|
+
renderOpts: {
|
|
81
|
+
type: Object,
|
|
82
|
+
default: () => ({})
|
|
83
|
+
},
|
|
84
|
+
renderParams: {
|
|
85
|
+
type: Object,
|
|
86
|
+
default: () => ({})
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
emits: [],
|
|
90
|
+
setup(props) {
|
|
91
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
92
|
+
const changeEvent = () => {
|
|
93
|
+
const { renderParams } = props;
|
|
94
|
+
const { widget, $formView } = renderParams;
|
|
95
|
+
if ($formView) {
|
|
96
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
97
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return () => {
|
|
101
|
+
const { renderParams } = props;
|
|
102
|
+
const { widget, $formView } = renderParams;
|
|
103
|
+
const { options } = widget;
|
|
104
|
+
return h(VxeUIFormItemComponent, {
|
|
105
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
106
|
+
field: widget.field,
|
|
107
|
+
title: widget.title
|
|
108
|
+
}, {
|
|
109
|
+
default() {
|
|
110
|
+
return h(getCurrComponent('a-textarea'), {
|
|
111
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
112
|
+
placeholder: options.placeholder,
|
|
113
|
+
autoSize: {
|
|
114
|
+
minRows: 2,
|
|
115
|
+
maxRows: 4
|
|
116
|
+
},
|
|
117
|
+
onChange: changeEvent,
|
|
118
|
+
'onUpdate:value'(val) {
|
|
119
|
+
if ($formView) {
|
|
120
|
+
$formView.setItemValue(widget, val);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
getWidgetATextareaConfig,
|
|
131
|
+
WidgetATextareaFormComponent,
|
|
132
|
+
WidgetATextareaViewComponent
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { h, onMounted, ref, watch } from 'vue';
|
|
2
|
+
export function useWidgetPropDataSource(VxeUI, props, isSubOption) {
|
|
3
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
4
|
+
const VxeUIButtonComponent = VxeUI.getComponent('VxeButton');
|
|
5
|
+
const VxeUITextareaComponent = VxeUI.getComponent('VxeTextarea');
|
|
6
|
+
const VxeUITipComponent = VxeUI.getComponent('VxeTip');
|
|
7
|
+
const optionsContent = ref('');
|
|
8
|
+
const expandIndexList = ref([]);
|
|
9
|
+
const addOptionEvent = () => {
|
|
10
|
+
const { renderParams } = props;
|
|
11
|
+
const { widget } = renderParams;
|
|
12
|
+
const options = widget.options.options || [];
|
|
13
|
+
options.push({
|
|
14
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [options.length + 1])
|
|
15
|
+
});
|
|
16
|
+
widget.options.options = [...options];
|
|
17
|
+
};
|
|
18
|
+
const subRE = /^(\s|\t)+/;
|
|
19
|
+
const hasSubOption = (str) => {
|
|
20
|
+
return subRE.test(str);
|
|
21
|
+
};
|
|
22
|
+
const expandAllOption = () => {
|
|
23
|
+
const { renderParams } = props;
|
|
24
|
+
const { widget } = renderParams;
|
|
25
|
+
const options = widget.options.options || [];
|
|
26
|
+
const indexList = [];
|
|
27
|
+
options.forEach((group, gIndex) => {
|
|
28
|
+
const { options } = group;
|
|
29
|
+
if (options && options.length) {
|
|
30
|
+
indexList.push(gIndex);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
expandIndexList.value = indexList;
|
|
34
|
+
};
|
|
35
|
+
const toggleExpandOption = (item, gIndex) => {
|
|
36
|
+
if (expandIndexList.value.includes(gIndex)) {
|
|
37
|
+
expandIndexList.value = expandIndexList.value.filter(num => num !== gIndex);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
expandIndexList.value.push(gIndex);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const confirmBatchAddOptionEvent = () => {
|
|
44
|
+
const { renderParams } = props;
|
|
45
|
+
const { widget } = renderParams;
|
|
46
|
+
const optList = [];
|
|
47
|
+
const rowList = optionsContent.value.split('\n');
|
|
48
|
+
let prevGroup = null;
|
|
49
|
+
if (isSubOption) {
|
|
50
|
+
rowList.forEach((str, index) => {
|
|
51
|
+
const nextStr = rowList[index + 1];
|
|
52
|
+
const value = str.trim();
|
|
53
|
+
if (!value) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const item = {
|
|
57
|
+
value
|
|
58
|
+
};
|
|
59
|
+
if (prevGroup) {
|
|
60
|
+
if (hasSubOption(str)) {
|
|
61
|
+
prevGroup.options.push(item);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
prevGroup = null;
|
|
65
|
+
optList.push(item);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
optList.push(item);
|
|
69
|
+
}
|
|
70
|
+
if (nextStr) {
|
|
71
|
+
if (hasSubOption(nextStr)) {
|
|
72
|
+
prevGroup = Object.assign(item, { options: [] });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
rowList.forEach((str) => {
|
|
79
|
+
optList.push({
|
|
80
|
+
value: str.trim()
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
widget.options.options = optList;
|
|
85
|
+
expandAllOption();
|
|
86
|
+
};
|
|
87
|
+
const openPopupEditEvent = () => {
|
|
88
|
+
var _a;
|
|
89
|
+
const { renderParams } = props;
|
|
90
|
+
const { widget } = renderParams;
|
|
91
|
+
const contList = [];
|
|
92
|
+
(_a = widget.options.options) === null || _a === void 0 ? void 0 : _a.forEach(group => {
|
|
93
|
+
var _a;
|
|
94
|
+
contList.push(group.value);
|
|
95
|
+
(_a = group.options) === null || _a === void 0 ? void 0 : _a.forEach(item => {
|
|
96
|
+
contList.push(`\t${item.value}`);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
optionsContent.value = contList.join('\n');
|
|
100
|
+
VxeUI.modal.open({
|
|
101
|
+
title: `${widget.title} - ${VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption')}`,
|
|
102
|
+
width: 500,
|
|
103
|
+
height: '50vh ',
|
|
104
|
+
resize: true,
|
|
105
|
+
showFooter: true,
|
|
106
|
+
showCancelButton: true,
|
|
107
|
+
showConfirmButton: true,
|
|
108
|
+
confirmButtonText: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.buildOption'),
|
|
109
|
+
onConfirm: confirmBatchAddOptionEvent,
|
|
110
|
+
slots: {
|
|
111
|
+
default() {
|
|
112
|
+
return h('div', {
|
|
113
|
+
class: 'vxe-form-design--widget-form-item-data-source-popup'
|
|
114
|
+
}, [
|
|
115
|
+
h(VxeUITipComponent, {
|
|
116
|
+
status: 'primary',
|
|
117
|
+
title: '',
|
|
118
|
+
content: VxeUI.getI18n(`vxe.formDesign.widgetProp.dataSource.${isSubOption ? 'batchEditSubTip' : 'batchEditTip'}`)
|
|
119
|
+
}),
|
|
120
|
+
h(VxeUITextareaComponent, {
|
|
121
|
+
resize: 'none',
|
|
122
|
+
modelValue: optionsContent.value,
|
|
123
|
+
'onUpdate:modelValue'(val) {
|
|
124
|
+
optionsContent.value = val;
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const renderOption = (item, hasFirstLevel, isExpand, gIndex, hasSub, isFirst, isLast) => {
|
|
133
|
+
return h('div', {
|
|
134
|
+
class: ['vxe-form-design--widget-form-item-data-source-option', {
|
|
135
|
+
'is--first': isFirst,
|
|
136
|
+
'is--last': isLast
|
|
137
|
+
}]
|
|
138
|
+
}, [
|
|
139
|
+
h('div', {
|
|
140
|
+
class: 'vxe-form-design--widget-expand-btn'
|
|
141
|
+
}, hasFirstLevel && hasSub
|
|
142
|
+
? [
|
|
143
|
+
h('i', {
|
|
144
|
+
class: isExpand ? VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_CLOSE : VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_OPEN,
|
|
145
|
+
onClick() {
|
|
146
|
+
toggleExpandOption(item, gIndex);
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
: []),
|
|
151
|
+
h('input', {
|
|
152
|
+
class: 'vxe-default-input',
|
|
153
|
+
value: item.value,
|
|
154
|
+
onInput(evnt) {
|
|
155
|
+
item.value = evnt.currentTarget.value;
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
h(VxeUIButtonComponent, {
|
|
159
|
+
status: 'danger',
|
|
160
|
+
mode: 'text',
|
|
161
|
+
icon: VxeUI.getIcon().FORM_DESIGN_WIDGET_DELETE
|
|
162
|
+
})
|
|
163
|
+
]);
|
|
164
|
+
};
|
|
165
|
+
const renderOptions = () => {
|
|
166
|
+
const { renderParams } = props;
|
|
167
|
+
const { widget } = renderParams;
|
|
168
|
+
const { options } = widget;
|
|
169
|
+
const groups = options.options;
|
|
170
|
+
const optVNs = [];
|
|
171
|
+
if (groups) {
|
|
172
|
+
groups.forEach((group, gIndex) => {
|
|
173
|
+
const { options } = group;
|
|
174
|
+
const isExpand = expandIndexList.value.includes(gIndex);
|
|
175
|
+
if (options && options.length) {
|
|
176
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, true, gIndex === 0, gIndex === groups.length - 1));
|
|
177
|
+
if (isExpand) {
|
|
178
|
+
optVNs.push(h('div', {
|
|
179
|
+
class: 'vxe-form-design--widget-form-item-data-source-sub-option'
|
|
180
|
+
}, options.map(item => renderOption(item, false, isExpand, 0, false, false, false))));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, false, gIndex === 0, gIndex === groups.length - 1));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return optVNs;
|
|
189
|
+
};
|
|
190
|
+
watch(() => props.renderParams.widget, () => {
|
|
191
|
+
expandAllOption();
|
|
192
|
+
});
|
|
193
|
+
onMounted(() => {
|
|
194
|
+
expandAllOption();
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
renderDataSourceFormItem() {
|
|
198
|
+
return h(VxeUIFormItemComponent, {
|
|
199
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.name'),
|
|
200
|
+
field: 'options'
|
|
201
|
+
}, {
|
|
202
|
+
default() {
|
|
203
|
+
return [
|
|
204
|
+
h('div', {}, [
|
|
205
|
+
h(VxeUIButtonComponent, {
|
|
206
|
+
status: 'primary',
|
|
207
|
+
mode: 'text',
|
|
208
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.addOption'),
|
|
209
|
+
onClick: addOptionEvent
|
|
210
|
+
}),
|
|
211
|
+
h(VxeUIButtonComponent, {
|
|
212
|
+
status: 'primary',
|
|
213
|
+
mode: 'text',
|
|
214
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption'),
|
|
215
|
+
onClick: openPopupEditEvent
|
|
216
|
+
})
|
|
217
|
+
]),
|
|
218
|
+
h('div', {
|
|
219
|
+
class: 'vxe-form-design--widget-form-item-data-source'
|
|
220
|
+
}, renderOptions())
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|