@vxe-ui/plugin-render-antd 4.0.2 → 4.0.4
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/README.md +6 -4
- package/dist/all.common.js +2412 -0
- package/dist/form/index.js +235 -0
- package/dist/form-design/checkbox-widget.js +162 -0
- package/dist/form-design/date-picker-widget.js +143 -0
- package/dist/form-design/index.js +177 -0
- package/dist/form-design/input-widget.js +143 -0
- package/dist/form-design/number-input-widget.js +143 -0
- package/dist/form-design/radio-widget.js +162 -0
- package/dist/form-design/select-widget.js +154 -0
- package/dist/form-design/switch-widget.js +139 -0
- package/dist/form-design/textarea-widget.js +147 -0
- package/dist/form-design/use.js +225 -0
- package/dist/index.common.js +8 -607
- package/dist/index.js +69 -0
- package/dist/index.umd.js +2595 -635
- package/dist/index.umd.min.js +1 -1
- package/dist/style.css +2 -1
- package/dist/style.min.css +1 -1
- package/dist/table/index.js +499 -0
- package/package.json +6 -5
- package/src/form/index.ts +244 -0
- package/src/form-design/checkbox-widget.ts +164 -0
- package/src/form-design/date-picker-widget.ts +144 -0
- package/src/form-design/index.ts +101 -0
- package/src/form-design/input-widget.ts +144 -0
- package/src/form-design/number-input-widget.ts +144 -0
- package/src/form-design/radio-widget.ts +164 -0
- package/src/form-design/select-widget.ts +156 -0
- package/src/form-design/switch-widget.ts +140 -0
- package/src/form-design/textarea-widget.ts +148 -0
- package/src/form-design/use.ts +255 -0
- package/src/index.ts +71 -0
- package/src/table/index.ts +508 -0
- package/index.ts +0 -701
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, resolveComponent, ComponentOptions } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormComponent, VxeFormItemComponent, VxeSwitchComponent, VxeInputComponent } from 'vxe-pc-ui'
|
|
4
|
+
|
|
5
|
+
interface WidgetAInputFormObjVO {
|
|
6
|
+
placeholder: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function createWidgetAInput (VxeUI: VxeUIExport) {
|
|
10
|
+
const getWidgetAInputConfig = (params: VxeGlobalRendererHandles.CreateFormDesignWidgetConfigParams): VxeGlobalRendererHandles.CreateFormDesignWidgetConfigObj<WidgetAInputFormObjVO> => {
|
|
11
|
+
return {
|
|
12
|
+
title: '输入框',
|
|
13
|
+
icon: 'vxe-icon-input',
|
|
14
|
+
options: {
|
|
15
|
+
placeholder: ''
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const WidgetAInputFormComponent = defineComponent({
|
|
21
|
+
props: {
|
|
22
|
+
renderOpts: {
|
|
23
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions>,
|
|
24
|
+
default: () => ({})
|
|
25
|
+
},
|
|
26
|
+
renderParams: {
|
|
27
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<WidgetAInputFormObjVO>>,
|
|
28
|
+
default: () => ({})
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [],
|
|
32
|
+
setup (props) {
|
|
33
|
+
const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
|
|
34
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
35
|
+
const VxeUISwitchComponent = VxeUI.getComponent<VxeSwitchComponent>('VxeSwitch')
|
|
36
|
+
const VxeUIInputComponent = VxeUI.getComponent<VxeInputComponent>('VxeInput')
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
const { renderParams } = props
|
|
40
|
+
const { widget } = renderParams
|
|
41
|
+
const { options } = widget
|
|
42
|
+
|
|
43
|
+
return h(VxeUIFormComponent, {
|
|
44
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
45
|
+
vertical: true,
|
|
46
|
+
span: 24,
|
|
47
|
+
titleBold: true,
|
|
48
|
+
titleOverflow: true,
|
|
49
|
+
data: options
|
|
50
|
+
}, {
|
|
51
|
+
default () {
|
|
52
|
+
return [
|
|
53
|
+
h(VxeUIFormItemComponent, {
|
|
54
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
55
|
+
}, {
|
|
56
|
+
default () {
|
|
57
|
+
return h(VxeUIInputComponent, {
|
|
58
|
+
modelValue: widget.title,
|
|
59
|
+
placeholder: options.placeholder,
|
|
60
|
+
'onUpdate:modelValue' (val: any) {
|
|
61
|
+
widget.title = val
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
h(VxeUIFormItemComponent, {
|
|
67
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
68
|
+
field: 'placeholder',
|
|
69
|
+
itemRender: { name: 'VxeInput' }
|
|
70
|
+
}),
|
|
71
|
+
h(VxeUIFormItemComponent, {
|
|
72
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
73
|
+
}, {
|
|
74
|
+
default () {
|
|
75
|
+
return h(VxeUISwitchComponent, {
|
|
76
|
+
modelValue: widget.required,
|
|
77
|
+
'onUpdate:modelValue' (val: any) {
|
|
78
|
+
widget.required = val
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const WidgetAInputViewComponent = defineComponent({
|
|
91
|
+
props: {
|
|
92
|
+
renderOpts: {
|
|
93
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewOptions>,
|
|
94
|
+
default: () => ({})
|
|
95
|
+
},
|
|
96
|
+
renderParams: {
|
|
97
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewParams<WidgetAInputFormObjVO>>,
|
|
98
|
+
default: () => ({})
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
emits: [],
|
|
102
|
+
setup (props) {
|
|
103
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
104
|
+
|
|
105
|
+
const changeEvent = () => {
|
|
106
|
+
const { renderParams } = props
|
|
107
|
+
const { widget, $formView } = renderParams
|
|
108
|
+
if ($formView) {
|
|
109
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null
|
|
110
|
+
$formView.updateItemStatus(widget, itemValue)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return () => {
|
|
115
|
+
const { renderParams } = props
|
|
116
|
+
const { widget, $formView } = renderParams
|
|
117
|
+
|
|
118
|
+
return h(VxeUIFormItemComponent, {
|
|
119
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
120
|
+
field: widget.field,
|
|
121
|
+
title: widget.title
|
|
122
|
+
}, {
|
|
123
|
+
default () {
|
|
124
|
+
return h(resolveComponent('a-input') as ComponentOptions, {
|
|
125
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
126
|
+
onChange: changeEvent,
|
|
127
|
+
'onUpdate:value' (val: any) {
|
|
128
|
+
if ($formView) {
|
|
129
|
+
$formView.setItemValue(widget, val)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
getWidgetAInputConfig,
|
|
141
|
+
WidgetAInputFormComponent,
|
|
142
|
+
WidgetAInputViewComponent
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, resolveComponent, ComponentOptions } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormComponent, VxeFormItemComponent, VxeSwitchComponent, VxeInputComponent } from 'vxe-pc-ui'
|
|
4
|
+
|
|
5
|
+
interface WidgetAInputNumberFormObjVO {
|
|
6
|
+
placeholder: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function createWidgetAInputNumber (VxeUI: VxeUIExport) {
|
|
10
|
+
const getWidgetAInputNumberConfig = (params: VxeGlobalRendererHandles.CreateFormDesignWidgetConfigParams): VxeGlobalRendererHandles.CreateFormDesignWidgetConfigObj<WidgetAInputNumberFormObjVO> => {
|
|
11
|
+
return {
|
|
12
|
+
title: '数字',
|
|
13
|
+
icon: 'vxe-icon-number',
|
|
14
|
+
options: {
|
|
15
|
+
placeholder: '请输入'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const WidgetAInputNumberFormComponent = defineComponent({
|
|
21
|
+
props: {
|
|
22
|
+
renderOpts: {
|
|
23
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions>,
|
|
24
|
+
default: () => ({})
|
|
25
|
+
},
|
|
26
|
+
renderParams: {
|
|
27
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<WidgetAInputNumberFormObjVO>>,
|
|
28
|
+
default: () => ({})
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [],
|
|
32
|
+
setup (props) {
|
|
33
|
+
const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
|
|
34
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
35
|
+
const VxeUISwitchComponent = VxeUI.getComponent<VxeSwitchComponent>('VxeSwitch')
|
|
36
|
+
const VxeUIInputComponent = VxeUI.getComponent<VxeInputComponent>('VxeInput')
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
const { renderParams } = props
|
|
40
|
+
const { widget } = renderParams
|
|
41
|
+
|
|
42
|
+
return h(VxeUIFormComponent, {
|
|
43
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
44
|
+
vertical: true,
|
|
45
|
+
span: 24,
|
|
46
|
+
titleBold: true,
|
|
47
|
+
titleOverflow: true,
|
|
48
|
+
data: widget.options
|
|
49
|
+
}, {
|
|
50
|
+
default () {
|
|
51
|
+
return [
|
|
52
|
+
h(VxeUIFormItemComponent, {
|
|
53
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
54
|
+
}, {
|
|
55
|
+
default () {
|
|
56
|
+
return h(VxeUIInputComponent, {
|
|
57
|
+
modelValue: widget.title,
|
|
58
|
+
'onUpdate:modelValue' (val: any) {
|
|
59
|
+
widget.title = val
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
h(VxeUIFormItemComponent, {
|
|
65
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
66
|
+
field: 'placeholder',
|
|
67
|
+
itemRender: { name: 'ElInput' }
|
|
68
|
+
}),
|
|
69
|
+
h(VxeUIFormItemComponent, {
|
|
70
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
71
|
+
}, {
|
|
72
|
+
default () {
|
|
73
|
+
return h(VxeUISwitchComponent, {
|
|
74
|
+
modelValue: widget.required,
|
|
75
|
+
'onUpdate:modelValue' (val: any) {
|
|
76
|
+
widget.required = val
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const WidgetAInputNumberViewComponent = defineComponent({
|
|
89
|
+
props: {
|
|
90
|
+
renderOpts: {
|
|
91
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewOptions>,
|
|
92
|
+
default: () => ({})
|
|
93
|
+
},
|
|
94
|
+
renderParams: {
|
|
95
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewParams<WidgetAInputNumberFormObjVO>>,
|
|
96
|
+
default: () => ({})
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
emits: [],
|
|
100
|
+
setup (props) {
|
|
101
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
102
|
+
|
|
103
|
+
const changeEvent = () => {
|
|
104
|
+
const { renderParams } = props
|
|
105
|
+
const { widget, $formView } = renderParams
|
|
106
|
+
if ($formView) {
|
|
107
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null
|
|
108
|
+
$formView.updateItemStatus(widget, itemValue)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
const { renderParams } = props
|
|
114
|
+
const { widget, $formView } = renderParams
|
|
115
|
+
const { options } = widget
|
|
116
|
+
|
|
117
|
+
return h(VxeUIFormItemComponent, {
|
|
118
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
119
|
+
field: widget.field,
|
|
120
|
+
title: widget.title
|
|
121
|
+
}, {
|
|
122
|
+
default () {
|
|
123
|
+
return h(resolveComponent('a-input-number') as ComponentOptions, {
|
|
124
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
125
|
+
placeholder: options.placeholder,
|
|
126
|
+
onChange: changeEvent,
|
|
127
|
+
'onUpdate:value' (val: any) {
|
|
128
|
+
if ($formView) {
|
|
129
|
+
$formView.setItemValue(widget, val)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
getWidgetAInputNumberConfig,
|
|
141
|
+
WidgetAInputNumberFormComponent,
|
|
142
|
+
WidgetAInputNumberViewComponent
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, resolveComponent, ComponentOptions, computed } from 'vue'
|
|
2
|
+
import { useWidgetPropDataSource, WidgetDataSourceOptionObjVO } from './use'
|
|
3
|
+
import XEUtils from 'xe-utils'
|
|
4
|
+
|
|
5
|
+
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormComponent, VxeFormItemComponent, VxeSwitchComponent, VxeInputComponent } from 'vxe-pc-ui'
|
|
6
|
+
|
|
7
|
+
interface WidgetARadioFormObjVO {
|
|
8
|
+
options: WidgetDataSourceOptionObjVO[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createWidgetARadio (VxeUI: VxeUIExport) {
|
|
12
|
+
const getWidgetARadioConfig = (params: VxeGlobalRendererHandles.CreateFormDesignWidgetConfigParams): VxeGlobalRendererHandles.CreateFormDesignWidgetConfigObj<WidgetARadioFormObjVO> => {
|
|
13
|
+
return {
|
|
14
|
+
title: '单选框',
|
|
15
|
+
icon: 'vxe-icon-radio-checked',
|
|
16
|
+
options: {
|
|
17
|
+
options: XEUtils.range(0, 3).map((v, i) => {
|
|
18
|
+
return {
|
|
19
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [i + 1])
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const WidgetARadioFormComponent = defineComponent({
|
|
27
|
+
props: {
|
|
28
|
+
renderOpts: {
|
|
29
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions>,
|
|
30
|
+
default: () => ({})
|
|
31
|
+
},
|
|
32
|
+
renderParams: {
|
|
33
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<WidgetARadioFormObjVO>>,
|
|
34
|
+
default: () => ({})
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
emits: [],
|
|
38
|
+
setup (props) {
|
|
39
|
+
const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
|
|
40
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
41
|
+
const VxeUISwitchComponent = VxeUI.getComponent<VxeSwitchComponent>('VxeSwitch')
|
|
42
|
+
const VxeUIInputComponent = VxeUI.getComponent<VxeInputComponent>('VxeInput')
|
|
43
|
+
|
|
44
|
+
const { renderDataSourceFormItem } = useWidgetPropDataSource(VxeUI, props, false)
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
const { renderParams } = props
|
|
48
|
+
const { widget } = renderParams
|
|
49
|
+
|
|
50
|
+
return h(VxeUIFormComponent, {
|
|
51
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
52
|
+
vertical: true,
|
|
53
|
+
span: 24,
|
|
54
|
+
titleBold: true,
|
|
55
|
+
titleOverflow: true,
|
|
56
|
+
data: widget.options
|
|
57
|
+
}, {
|
|
58
|
+
default () {
|
|
59
|
+
return [
|
|
60
|
+
h(VxeUIFormItemComponent, {
|
|
61
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
62
|
+
}, {
|
|
63
|
+
default () {
|
|
64
|
+
return h(VxeUIInputComponent, {
|
|
65
|
+
modelValue: widget.title,
|
|
66
|
+
'onUpdate:modelValue' (val: any) {
|
|
67
|
+
widget.title = val
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
h(VxeUIFormItemComponent, {
|
|
73
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
74
|
+
field: 'placeholder',
|
|
75
|
+
itemRender: { name: 'ElInput' }
|
|
76
|
+
}),
|
|
77
|
+
h(VxeUIFormItemComponent, {
|
|
78
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
79
|
+
}, {
|
|
80
|
+
default () {
|
|
81
|
+
return h(VxeUISwitchComponent, {
|
|
82
|
+
modelValue: widget.required,
|
|
83
|
+
'onUpdate:modelValue' (val: any) {
|
|
84
|
+
widget.required = val
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
renderDataSourceFormItem()
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const WidgetARadioViewComponent = defineComponent({
|
|
98
|
+
props: {
|
|
99
|
+
renderOpts: {
|
|
100
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewOptions>,
|
|
101
|
+
default: () => ({})
|
|
102
|
+
},
|
|
103
|
+
renderParams: {
|
|
104
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewParams<WidgetARadioFormObjVO>>,
|
|
105
|
+
default: () => ({})
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
emits: [],
|
|
109
|
+
setup (props) {
|
|
110
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
111
|
+
|
|
112
|
+
const radioOptions = computed(() => {
|
|
113
|
+
const { renderParams } = props
|
|
114
|
+
const { widget } = renderParams
|
|
115
|
+
const { options } = widget
|
|
116
|
+
return options.options.map(item => {
|
|
117
|
+
return {
|
|
118
|
+
label: item.value,
|
|
119
|
+
value: item.value
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
const changeEvent = () => {
|
|
125
|
+
const { renderParams } = props
|
|
126
|
+
const { widget, $formView } = renderParams
|
|
127
|
+
if ($formView) {
|
|
128
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null
|
|
129
|
+
$formView.updateItemStatus(widget, itemValue)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return () => {
|
|
134
|
+
const { renderParams } = props
|
|
135
|
+
const { widget, $formView } = renderParams
|
|
136
|
+
|
|
137
|
+
return h(VxeUIFormItemComponent, {
|
|
138
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
139
|
+
field: widget.field,
|
|
140
|
+
title: widget.title
|
|
141
|
+
}, {
|
|
142
|
+
default () {
|
|
143
|
+
return h(resolveComponent('a-radio-group') as ComponentOptions, {
|
|
144
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
145
|
+
options: radioOptions.value,
|
|
146
|
+
onChange: changeEvent,
|
|
147
|
+
'onUpdate:value' (val: any) {
|
|
148
|
+
if ($formView) {
|
|
149
|
+
$formView.setItemValue(widget, val)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
getWidgetARadioConfig,
|
|
161
|
+
WidgetARadioFormComponent,
|
|
162
|
+
WidgetARadioViewComponent
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, resolveComponent, ComponentOptions } from 'vue'
|
|
2
|
+
import { useWidgetPropDataSource, WidgetDataSourceOptionObjVO } from './use'
|
|
3
|
+
import XEUtils from 'xe-utils'
|
|
4
|
+
|
|
5
|
+
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormComponent, VxeFormItemComponent, VxeSwitchComponent, VxeInputComponent } from 'vxe-pc-ui'
|
|
6
|
+
|
|
7
|
+
interface WidgetASelectFormObjVO {
|
|
8
|
+
placeholder: string
|
|
9
|
+
options: WidgetDataSourceOptionObjVO[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function createWidgetASelect (VxeUI: VxeUIExport) {
|
|
13
|
+
const getWidgetASelectConfig = (params: VxeGlobalRendererHandles.CreateFormDesignWidgetConfigParams): VxeGlobalRendererHandles.CreateFormDesignWidgetConfigObj<WidgetASelectFormObjVO> => {
|
|
14
|
+
return {
|
|
15
|
+
title: '下拉框',
|
|
16
|
+
icon: 'vxe-icon-select',
|
|
17
|
+
options: {
|
|
18
|
+
placeholder: '请选择',
|
|
19
|
+
options: XEUtils.range(0, 3).map((v, i) => {
|
|
20
|
+
return {
|
|
21
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [i + 1])
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const WidgetASelectFormComponent = defineComponent({
|
|
29
|
+
props: {
|
|
30
|
+
renderOpts: {
|
|
31
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions>,
|
|
32
|
+
default: () => ({})
|
|
33
|
+
},
|
|
34
|
+
renderParams: {
|
|
35
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<WidgetASelectFormObjVO>>,
|
|
36
|
+
default: () => ({})
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
emits: [],
|
|
40
|
+
setup (props) {
|
|
41
|
+
const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
|
|
42
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
43
|
+
const VxeUISwitchComponent = VxeUI.getComponent<VxeSwitchComponent>('VxeSwitch')
|
|
44
|
+
const VxeUIInputComponent = VxeUI.getComponent<VxeInputComponent>('VxeInput')
|
|
45
|
+
|
|
46
|
+
const { renderDataSourceFormItem } = useWidgetPropDataSource(VxeUI, props, false)
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
const { renderParams } = props
|
|
50
|
+
const { widget } = renderParams
|
|
51
|
+
|
|
52
|
+
return h(VxeUIFormComponent, {
|
|
53
|
+
class: 'vxe-form-design--widget-render-form-wrapper',
|
|
54
|
+
vertical: true,
|
|
55
|
+
span: 24,
|
|
56
|
+
titleBold: true,
|
|
57
|
+
titleOverflow: true,
|
|
58
|
+
data: widget.options
|
|
59
|
+
}, {
|
|
60
|
+
default () {
|
|
61
|
+
return [
|
|
62
|
+
h(VxeUIFormItemComponent, {
|
|
63
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
64
|
+
}, {
|
|
65
|
+
default () {
|
|
66
|
+
return h(VxeUIInputComponent, {
|
|
67
|
+
modelValue: widget.title,
|
|
68
|
+
'onUpdate:modelValue' (val: any) {
|
|
69
|
+
widget.title = val
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
h(VxeUIFormItemComponent, {
|
|
75
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
76
|
+
field: 'placeholder',
|
|
77
|
+
itemRender: { name: 'ElInput' }
|
|
78
|
+
}),
|
|
79
|
+
h(VxeUIFormItemComponent, {
|
|
80
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
81
|
+
}, {
|
|
82
|
+
default () {
|
|
83
|
+
return h(VxeUISwitchComponent, {
|
|
84
|
+
modelValue: widget.required,
|
|
85
|
+
'onUpdate:modelValue' (val: any) {
|
|
86
|
+
widget.required = val
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
renderDataSourceFormItem()
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const WidgetASelectViewComponent = defineComponent({
|
|
100
|
+
props: {
|
|
101
|
+
renderOpts: {
|
|
102
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewOptions>,
|
|
103
|
+
default: () => ({})
|
|
104
|
+
},
|
|
105
|
+
renderParams: {
|
|
106
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewParams<WidgetASelectFormObjVO>>,
|
|
107
|
+
default: () => ({})
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
emits: [],
|
|
111
|
+
setup (props) {
|
|
112
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
113
|
+
|
|
114
|
+
const changeEvent = () => {
|
|
115
|
+
const { renderParams } = props
|
|
116
|
+
const { widget, $formView } = renderParams
|
|
117
|
+
if ($formView) {
|
|
118
|
+
const itemValue = $formView ? $formView.getItemValue(widget) : null
|
|
119
|
+
$formView.updateItemStatus(widget, itemValue)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return () => {
|
|
124
|
+
const { renderParams } = props
|
|
125
|
+
const { widget, $formView } = renderParams
|
|
126
|
+
const { options } = widget
|
|
127
|
+
|
|
128
|
+
return h(VxeUIFormItemComponent, {
|
|
129
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
130
|
+
field: widget.field,
|
|
131
|
+
title: widget.title
|
|
132
|
+
}, {
|
|
133
|
+
default () {
|
|
134
|
+
return h(resolveComponent('a-select') as ComponentOptions, {
|
|
135
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
136
|
+
options: options.options,
|
|
137
|
+
placeholder: options.placeholder,
|
|
138
|
+
onChange: changeEvent,
|
|
139
|
+
'onUpdate:value' (val: any) {
|
|
140
|
+
if ($formView) {
|
|
141
|
+
$formView.setItemValue(widget, val)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
getWidgetASelectConfig,
|
|
153
|
+
WidgetASelectFormComponent,
|
|
154
|
+
WidgetASelectViewComponent
|
|
155
|
+
}
|
|
156
|
+
}
|