@vxe-ui/plugin-render-element 4.2.3 → 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 +164 -37
- package/dist/index.umd.min.js +1 -1
- package/es/form/index.js +279 -0
- package/es/form-design/checkbox-widget.js +151 -0
- package/es/form-design/date-picker-widget.js +129 -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 +129 -0
- package/es/form-design/radio-widget.js +151 -0
- package/es/form-design/select-widget.js +149 -0
- package/es/form-design/switch-widget.js +125 -0
- package/es/form-design/textarea-widget.js +134 -0
- package/es/form-design/use.js +226 -0
- package/es/index.esm.js +111 -0
- package/es/index.js +111 -0
- package/es/store/index.js +2 -0
- package/es/style.css +38 -0
- package/es/style.min.css +1 -0
- package/es/table/index.js +633 -0
- package/es/util/comp.js +18 -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 +2962 -0
- package/lib/index.umd.min.js +1 -0
- package/lib/style.css +38 -0
- package/lib/style.min.css +1 -0
- package/{dist → lib}/table/index.js +140 -26
- package/{dist → lib}/util/comp.js +10 -0
- package/package.json +14 -17
- package/src/form/index.ts +5 -2
- package/src/table/index.ts +157 -39
- package/src/util/comp.ts +11 -0
- /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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { getCurrComponent } from '../util/comp';
|
|
3
|
+
export function createWidgetElInput(VxeUI) {
|
|
4
|
+
const getWidgetElInputConfig = (params) => {
|
|
5
|
+
return {
|
|
6
|
+
title: '输入框',
|
|
7
|
+
icon: 'vxe-icon-input',
|
|
8
|
+
options: {
|
|
9
|
+
placeholder: '请输入'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const WidgetElInputFormComponent = 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
|
+
return () => {
|
|
30
|
+
const { renderParams } = props;
|
|
31
|
+
const { widget } = renderParams;
|
|
32
|
+
const { options } = widget;
|
|
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: options
|
|
40
|
+
}, {
|
|
41
|
+
default() {
|
|
42
|
+
return [
|
|
43
|
+
h(VxeUIFormItemComponent, {
|
|
44
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
45
|
+
}, {
|
|
46
|
+
default() {
|
|
47
|
+
return h(getCurrComponent('el-input'), {
|
|
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 WidgetElInputViewComponent = 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('el-input'), {
|
|
111
|
+
modelValue: $formView ? $formView.getItemValue(widget) : null,
|
|
112
|
+
placeholder: options.placeholder,
|
|
113
|
+
onChange: changeEvent,
|
|
114
|
+
'onUpdate:modelValue'(val) {
|
|
115
|
+
if ($formView) {
|
|
116
|
+
$formView.setItemValue(widget, val);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
getWidgetElInputConfig,
|
|
127
|
+
WidgetElInputFormComponent,
|
|
128
|
+
WidgetElInputViewComponent
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { getCurrComponent } from '../util/comp';
|
|
3
|
+
export function createWidgetElInputNumber(VxeUI) {
|
|
4
|
+
const getWidgetElInputNumberConfig = (params) => {
|
|
5
|
+
return {
|
|
6
|
+
title: '数字',
|
|
7
|
+
icon: 'vxe-icon-number',
|
|
8
|
+
options: {
|
|
9
|
+
placeholder: '请输入'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const WidgetElInputNumberFormComponent = 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
|
+
return () => {
|
|
30
|
+
const { renderParams } = props;
|
|
31
|
+
const { widget } = renderParams;
|
|
32
|
+
return h(VxeUIFormComponent, {
|
|
33
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
34
|
+
vertical: true,
|
|
35
|
+
span: 24,
|
|
36
|
+
titleBold: true,
|
|
37
|
+
titleOverflow: true,
|
|
38
|
+
data: widget.options
|
|
39
|
+
}, {
|
|
40
|
+
default() {
|
|
41
|
+
return [
|
|
42
|
+
h(VxeUIFormItemComponent, {
|
|
43
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
44
|
+
}, {
|
|
45
|
+
default() {
|
|
46
|
+
return h(getCurrComponent('el-input'), {
|
|
47
|
+
modelValue: widget.title,
|
|
48
|
+
'onUpdate:modelValue'(val) {
|
|
49
|
+
widget.title = val;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
h(VxeUIFormItemComponent, {
|
|
55
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
56
|
+
field: 'placeholder',
|
|
57
|
+
itemRender: { name: 'ElInput' }
|
|
58
|
+
}),
|
|
59
|
+
h(VxeUIFormItemComponent, {
|
|
60
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
61
|
+
}, {
|
|
62
|
+
default() {
|
|
63
|
+
return h(VxeUISwitchComponent, {
|
|
64
|
+
modelValue: widget.required,
|
|
65
|
+
'onUpdate:modelValue'(val) {
|
|
66
|
+
widget.required = val;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const WidgetElInputNumberViewComponent = defineComponent({
|
|
78
|
+
props: {
|
|
79
|
+
renderOpts: {
|
|
80
|
+
type: Object,
|
|
81
|
+
default: () => ({})
|
|
82
|
+
},
|
|
83
|
+
renderParams: {
|
|
84
|
+
type: Object,
|
|
85
|
+
default: () => ({})
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
emits: [],
|
|
89
|
+
setup(props) {
|
|
90
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
91
|
+
const changeEvent = () => {
|
|
92
|
+
const { renderParams } = props;
|
|
93
|
+
const { widget, $formView } = renderParams;
|
|
94
|
+
if ($formView) {
|
|
95
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
96
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return () => {
|
|
100
|
+
const { renderParams } = props;
|
|
101
|
+
const { widget, $formView } = renderParams;
|
|
102
|
+
const { options } = widget;
|
|
103
|
+
return h(VxeUIFormItemComponent, {
|
|
104
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
105
|
+
field: widget.field,
|
|
106
|
+
title: widget.title
|
|
107
|
+
}, {
|
|
108
|
+
default() {
|
|
109
|
+
return h(getCurrComponent('el-input-number'), {
|
|
110
|
+
modelValue: $formView ? $formView.getItemValue(widget) : null,
|
|
111
|
+
placeholder: options.placeholder,
|
|
112
|
+
onChange: changeEvent,
|
|
113
|
+
'onUpdate:modelValue'(val) {
|
|
114
|
+
if ($formView) {
|
|
115
|
+
$formView.setItemValue(widget, val);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
getWidgetElInputNumberConfig,
|
|
126
|
+
WidgetElInputNumberFormComponent,
|
|
127
|
+
WidgetElInputNumberViewComponent
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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 createWidgetElRadio(VxeUI) {
|
|
6
|
+
const getWidgetElRadioConfig = (params) => {
|
|
7
|
+
return {
|
|
8
|
+
title: '单选框',
|
|
9
|
+
icon: 'vxe-icon-radio-checked',
|
|
10
|
+
options: {
|
|
11
|
+
options: XEUtils.range(0, 3).map((v, i) => {
|
|
12
|
+
return {
|
|
13
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [i + 1])
|
|
14
|
+
};
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const WidgetElRadioFormComponent = defineComponent({
|
|
20
|
+
props: {
|
|
21
|
+
renderOpts: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: () => ({})
|
|
24
|
+
},
|
|
25
|
+
renderParams: {
|
|
26
|
+
type: Object,
|
|
27
|
+
default: () => ({})
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
emits: [],
|
|
31
|
+
setup(props) {
|
|
32
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
33
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
34
|
+
const VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
35
|
+
const { renderDataSourceFormItem } = useWidgetPropDataSource(VxeUI, props, false);
|
|
36
|
+
return () => {
|
|
37
|
+
const { renderParams } = props;
|
|
38
|
+
const { widget } = renderParams;
|
|
39
|
+
return h(VxeUIFormComponent, {
|
|
40
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
41
|
+
vertical: true,
|
|
42
|
+
span: 24,
|
|
43
|
+
titleBold: true,
|
|
44
|
+
titleOverflow: true,
|
|
45
|
+
data: widget.options
|
|
46
|
+
}, {
|
|
47
|
+
default() {
|
|
48
|
+
return [
|
|
49
|
+
h(VxeUIFormItemComponent, {
|
|
50
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
51
|
+
}, {
|
|
52
|
+
default() {
|
|
53
|
+
return h(getCurrComponent('el-input'), {
|
|
54
|
+
modelValue: widget.title,
|
|
55
|
+
'onUpdate:modelValue'(val) {
|
|
56
|
+
widget.title = val;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
h(VxeUIFormItemComponent, {
|
|
62
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
63
|
+
field: 'placeholder',
|
|
64
|
+
itemRender: { name: 'ElInput' }
|
|
65
|
+
}),
|
|
66
|
+
h(VxeUIFormItemComponent, {
|
|
67
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
68
|
+
}, {
|
|
69
|
+
default() {
|
|
70
|
+
return h(VxeUISwitchComponent, {
|
|
71
|
+
modelValue: widget.required,
|
|
72
|
+
'onUpdate:modelValue'(val) {
|
|
73
|
+
widget.required = val;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
renderDataSourceFormItem()
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const WidgetElRadioViewComponent = defineComponent({
|
|
86
|
+
props: {
|
|
87
|
+
renderOpts: {
|
|
88
|
+
type: Object,
|
|
89
|
+
default: () => ({})
|
|
90
|
+
},
|
|
91
|
+
renderParams: {
|
|
92
|
+
type: Object,
|
|
93
|
+
default: () => ({})
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
emits: [],
|
|
97
|
+
setup(props) {
|
|
98
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
99
|
+
const changeEvent = () => {
|
|
100
|
+
const { renderParams } = props;
|
|
101
|
+
const { widget, $formView } = renderParams;
|
|
102
|
+
if ($formView) {
|
|
103
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
104
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return () => {
|
|
108
|
+
const { renderParams } = props;
|
|
109
|
+
const { widget, $formView } = renderParams;
|
|
110
|
+
const { options } = widget;
|
|
111
|
+
return h(VxeUIFormItemComponent, {
|
|
112
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
113
|
+
field: widget.field,
|
|
114
|
+
title: widget.title
|
|
115
|
+
}, {
|
|
116
|
+
default() {
|
|
117
|
+
return h(getCurrComponent('el-radio-group'), {
|
|
118
|
+
modelValue: $formView ? $formView.getItemValue(widget) : null,
|
|
119
|
+
onChange: changeEvent,
|
|
120
|
+
'onUpdate:modelValue'(val) {
|
|
121
|
+
if ($formView) {
|
|
122
|
+
$formView.setItemValue(widget, val);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
default: () => {
|
|
127
|
+
return options.options
|
|
128
|
+
? options.options.map((item, index) => {
|
|
129
|
+
return h(getCurrComponent('el-radio'), {
|
|
130
|
+
key: index,
|
|
131
|
+
value: item.value
|
|
132
|
+
}, {
|
|
133
|
+
default() {
|
|
134
|
+
return `${item.value || ''}`;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
})
|
|
138
|
+
: [];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
getWidgetElRadioConfig,
|
|
148
|
+
WidgetElRadioFormComponent,
|
|
149
|
+
WidgetElRadioViewComponent
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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 createWidgetElSelect(VxeUI) {
|
|
6
|
+
const getWidgetElSelectConfig = (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 WidgetElSelectFormComponent = 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 { renderDataSourceFormItem } = useWidgetPropDataSource(VxeUI, props, false);
|
|
37
|
+
return () => {
|
|
38
|
+
const { renderParams } = props;
|
|
39
|
+
const { widget } = renderParams;
|
|
40
|
+
return h(VxeUIFormComponent, {
|
|
41
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
42
|
+
vertical: true,
|
|
43
|
+
span: 24,
|
|
44
|
+
titleBold: true,
|
|
45
|
+
titleOverflow: true,
|
|
46
|
+
data: widget.options
|
|
47
|
+
}, {
|
|
48
|
+
default() {
|
|
49
|
+
return [
|
|
50
|
+
h(VxeUIFormItemComponent, {
|
|
51
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
52
|
+
}, {
|
|
53
|
+
default() {
|
|
54
|
+
return h(getCurrComponent('el-input'), {
|
|
55
|
+
modelValue: widget.title,
|
|
56
|
+
'onUpdate:modelValue'(val) {
|
|
57
|
+
widget.title = val;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
h(VxeUIFormItemComponent, {
|
|
63
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
64
|
+
field: 'placeholder',
|
|
65
|
+
itemRender: { name: 'ElInput' }
|
|
66
|
+
}),
|
|
67
|
+
h(VxeUIFormItemComponent, {
|
|
68
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
69
|
+
}, {
|
|
70
|
+
default() {
|
|
71
|
+
return h(VxeUISwitchComponent, {
|
|
72
|
+
modelValue: widget.required,
|
|
73
|
+
'onUpdate:modelValue'(val) {
|
|
74
|
+
widget.required = val;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
renderDataSourceFormItem()
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const WidgetElSelectViewComponent = defineComponent({
|
|
87
|
+
props: {
|
|
88
|
+
renderOpts: {
|
|
89
|
+
type: Object,
|
|
90
|
+
default: () => ({})
|
|
91
|
+
},
|
|
92
|
+
renderParams: {
|
|
93
|
+
type: Object,
|
|
94
|
+
default: () => ({})
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
emits: [],
|
|
98
|
+
setup(props) {
|
|
99
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
100
|
+
const changeEvent = () => {
|
|
101
|
+
const { renderParams } = props;
|
|
102
|
+
const { widget, $formView } = renderParams;
|
|
103
|
+
if ($formView) {
|
|
104
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
105
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return () => {
|
|
109
|
+
const { renderParams } = props;
|
|
110
|
+
const { widget, $formView } = renderParams;
|
|
111
|
+
const { options } = widget;
|
|
112
|
+
return h(VxeUIFormItemComponent, {
|
|
113
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
114
|
+
field: widget.field,
|
|
115
|
+
title: widget.title
|
|
116
|
+
}, {
|
|
117
|
+
default() {
|
|
118
|
+
return h(getCurrComponent('el-select'), {
|
|
119
|
+
modelValue: $formView ? $formView.getItemValue(widget) : null,
|
|
120
|
+
placeholder: options.placeholder,
|
|
121
|
+
onChange: changeEvent,
|
|
122
|
+
'onUpdate:modelValue'(val) {
|
|
123
|
+
if ($formView) {
|
|
124
|
+
$formView.setItemValue(widget, val);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
default: () => {
|
|
129
|
+
return options.options
|
|
130
|
+
? options.options.map(item => {
|
|
131
|
+
return h(getCurrComponent('el-option'), {
|
|
132
|
+
label: item.value,
|
|
133
|
+
value: item.value
|
|
134
|
+
});
|
|
135
|
+
})
|
|
136
|
+
: [];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
getWidgetElSelectConfig,
|
|
146
|
+
WidgetElSelectFormComponent,
|
|
147
|
+
WidgetElSelectViewComponent
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { getCurrComponent } from '../util/comp';
|
|
3
|
+
export function createWidgetElSwitch(VxeUI) {
|
|
4
|
+
const getWidgetElSwitchConfig = (params) => {
|
|
5
|
+
return {
|
|
6
|
+
title: '是/否',
|
|
7
|
+
icon: 'vxe-icon-switch',
|
|
8
|
+
options: {}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const WidgetElSwitchFormComponent = 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
|
+
return () => {
|
|
28
|
+
const { renderParams } = props;
|
|
29
|
+
const { widget } = renderParams;
|
|
30
|
+
return h(VxeUIFormComponent, {
|
|
31
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
32
|
+
vertical: true,
|
|
33
|
+
span: 24,
|
|
34
|
+
titleBold: true,
|
|
35
|
+
titleOverflow: true,
|
|
36
|
+
data: widget.options
|
|
37
|
+
}, {
|
|
38
|
+
default() {
|
|
39
|
+
return [
|
|
40
|
+
h(VxeUIFormItemComponent, {
|
|
41
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
42
|
+
}, {
|
|
43
|
+
default() {
|
|
44
|
+
return h(getCurrComponent('el-input'), {
|
|
45
|
+
modelValue: widget.title,
|
|
46
|
+
'onUpdate:modelValue'(val) {
|
|
47
|
+
widget.title = val;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
h(VxeUIFormItemComponent, {
|
|
53
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
54
|
+
field: 'placeholder',
|
|
55
|
+
itemRender: { name: 'ElInput' }
|
|
56
|
+
}),
|
|
57
|
+
h(VxeUIFormItemComponent, {
|
|
58
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
59
|
+
}, {
|
|
60
|
+
default() {
|
|
61
|
+
return h(VxeUISwitchComponent, {
|
|
62
|
+
modelValue: widget.required,
|
|
63
|
+
'onUpdate:modelValue'(val) {
|
|
64
|
+
widget.required = val;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const WidgetElSwitchViewComponent = defineComponent({
|
|
76
|
+
props: {
|
|
77
|
+
renderOpts: {
|
|
78
|
+
type: Object,
|
|
79
|
+
default: () => ({})
|
|
80
|
+
},
|
|
81
|
+
renderParams: {
|
|
82
|
+
type: Object,
|
|
83
|
+
default: () => ({})
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
emits: [],
|
|
87
|
+
setup(props) {
|
|
88
|
+
const VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
89
|
+
const changeEvent = () => {
|
|
90
|
+
const { renderParams } = props;
|
|
91
|
+
const { widget, $formView } = renderParams;
|
|
92
|
+
if ($formView) {
|
|
93
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
94
|
+
$formView.updateWidgetStatus(widget, itemValue);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return () => {
|
|
98
|
+
const { renderParams } = props;
|
|
99
|
+
const { widget, $formView } = renderParams;
|
|
100
|
+
return h(VxeUIFormItemComponent, {
|
|
101
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
102
|
+
field: widget.field,
|
|
103
|
+
title: widget.title
|
|
104
|
+
}, {
|
|
105
|
+
default() {
|
|
106
|
+
return h(getCurrComponent('el-switch'), {
|
|
107
|
+
modelValue: $formView ? $formView.getItemValue(widget) : null,
|
|
108
|
+
onChange: changeEvent,
|
|
109
|
+
'onUpdate:modelValue'(val) {
|
|
110
|
+
if ($formView) {
|
|
111
|
+
$formView.setItemValue(widget, val);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
getWidgetElSwitchConfig,
|
|
122
|
+
WidgetElSwitchFormComponent,
|
|
123
|
+
WidgetElSwitchViewComponent
|
|
124
|
+
};
|
|
125
|
+
}
|