@vxe-ui/plugin-render-antd 4.0.3 → 4.0.5
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 +1398 -99
- package/dist/form-design/checkbox-widget.js +162 -0
- package/dist/form-design/{a-date-picker.js → date-picker-widget.js} +4 -3
- package/dist/form-design/index.js +129 -6
- package/dist/form-design/{a-input.js → input-widget.js} +4 -3
- 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.umd.js +1470 -108
- 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 +53 -18
- package/package.json +3 -3
- package/src/form-design/checkbox-widget.ts +164 -0
- package/src/form-design/{a-date-picker.ts → date-picker-widget.ts} +5 -4
- package/src/form-design/index.ts +71 -4
- package/src/form-design/{a-input.ts → input-widget.ts} +5 -4
- 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/table/index.ts +43 -9
package/src/form-design/index.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { h } from 'vue'
|
|
2
|
-
import { createWidgetAInput } from './
|
|
3
|
-
import {
|
|
2
|
+
import { createWidgetAInput } from './input-widget'
|
|
3
|
+
import { createWidgetATextarea } from './textarea-widget'
|
|
4
|
+
import { createWidgetAInputNumber } from './number-input-widget'
|
|
5
|
+
import { createWidgetADatePicker } from './date-picker-widget'
|
|
6
|
+
import { createWidgetASelect } from './select-widget'
|
|
7
|
+
import { createWidgetARadio } from './radio-widget'
|
|
8
|
+
import { createWidgetACheckbox } from './checkbox-widget'
|
|
9
|
+
import { createWidgetASwitch } from './switch-widget'
|
|
4
10
|
|
|
5
11
|
import type { VxeUIExport } from 'vxe-pc-ui'
|
|
6
12
|
|
|
@@ -9,10 +15,16 @@ import type { VxeUIExport } from 'vxe-pc-ui'
|
|
|
9
15
|
*/
|
|
10
16
|
export function defineFormDesignRender (VxeUI: VxeUIExport) {
|
|
11
17
|
const { getWidgetAInputConfig, WidgetAInputViewComponent, WidgetAInputFormComponent } = createWidgetAInput(VxeUI)
|
|
18
|
+
const { getWidgetATextareaConfig, WidgetATextareaViewComponent, WidgetATextareaFormComponent } = createWidgetATextarea(VxeUI)
|
|
19
|
+
const { getWidgetAInputNumberConfig, WidgetAInputNumberViewComponent, WidgetAInputNumberFormComponent } = createWidgetAInputNumber(VxeUI)
|
|
12
20
|
const { getWidgetADatePickerConfig, WidgetADatePickerViewComponent, WidgetADatePickerFormComponent } = createWidgetADatePicker(VxeUI)
|
|
21
|
+
const { getWidgetASelectConfig, WidgetASelectViewComponent, WidgetASelectFormComponent } = createWidgetASelect(VxeUI)
|
|
22
|
+
const { getWidgetARadioConfig, WidgetARadioViewComponent, WidgetARadioFormComponent } = createWidgetARadio(VxeUI)
|
|
23
|
+
const { getWidgetACheckboxConfig, WidgetACheckboxViewComponent, WidgetACheckboxFormComponent } = createWidgetACheckbox(VxeUI)
|
|
24
|
+
const { getWidgetASwitchConfig, WidgetASwitchViewComponent, WidgetASwitchFormComponent } = createWidgetASwitch(VxeUI)
|
|
13
25
|
|
|
14
26
|
VxeUI.renderer.mixin({
|
|
15
|
-
|
|
27
|
+
AInputWidget: {
|
|
16
28
|
createFormDesignWidgetConfig: getWidgetAInputConfig,
|
|
17
29
|
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
18
30
|
return h(WidgetAInputViewComponent, { renderOpts, renderParams })
|
|
@@ -21,7 +33,25 @@ export function defineFormDesignRender (VxeUI: VxeUIExport) {
|
|
|
21
33
|
return h(WidgetAInputFormComponent, { renderOpts, renderParams })
|
|
22
34
|
}
|
|
23
35
|
},
|
|
24
|
-
|
|
36
|
+
ATextareaWidget: {
|
|
37
|
+
createFormDesignWidgetConfig: getWidgetATextareaConfig,
|
|
38
|
+
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
39
|
+
return h(WidgetATextareaViewComponent, { renderOpts, renderParams })
|
|
40
|
+
},
|
|
41
|
+
renderFormDesignWidgetFormView (renderOpts, renderParams) {
|
|
42
|
+
return h(WidgetATextareaFormComponent, { renderOpts, renderParams })
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
ANumberInputWidget: {
|
|
46
|
+
createFormDesignWidgetConfig: getWidgetAInputNumberConfig,
|
|
47
|
+
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
48
|
+
return h(WidgetAInputNumberViewComponent, { renderOpts, renderParams })
|
|
49
|
+
},
|
|
50
|
+
renderFormDesignWidgetFormView (renderOpts, renderParams) {
|
|
51
|
+
return h(WidgetAInputNumberFormComponent, { renderOpts, renderParams })
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
ADatePickerWidget: {
|
|
25
55
|
createFormDesignWidgetConfig: getWidgetADatePickerConfig,
|
|
26
56
|
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
27
57
|
return h(WidgetADatePickerViewComponent, { renderOpts, renderParams })
|
|
@@ -29,6 +59,43 @@ export function defineFormDesignRender (VxeUI: VxeUIExport) {
|
|
|
29
59
|
renderFormDesignWidgetFormView (renderOpts, renderParams) {
|
|
30
60
|
return h(WidgetADatePickerFormComponent, { renderOpts, renderParams })
|
|
31
61
|
}
|
|
62
|
+
},
|
|
63
|
+
ASelectWidget: {
|
|
64
|
+
createFormDesignWidgetConfig: getWidgetASelectConfig,
|
|
65
|
+
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
66
|
+
return h(WidgetASelectViewComponent, { renderOpts, renderParams })
|
|
67
|
+
},
|
|
68
|
+
renderFormDesignWidgetFormView (renderOpts, renderParams) {
|
|
69
|
+
return h(WidgetASelectFormComponent, { renderOpts, renderParams })
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
ARadioWidget: {
|
|
73
|
+
createFormDesignWidgetConfig: getWidgetARadioConfig,
|
|
74
|
+
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
75
|
+
return h(WidgetARadioViewComponent, { renderOpts, renderParams })
|
|
76
|
+
},
|
|
77
|
+
renderFormDesignWidgetFormView (renderOpts, renderParams) {
|
|
78
|
+
return h(WidgetARadioFormComponent, { renderOpts, renderParams })
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
ACheckboxWidget: {
|
|
82
|
+
createFormDesignWidgetConfig: getWidgetACheckboxConfig,
|
|
83
|
+
createFormDesignWidgetFieldValue: () => [],
|
|
84
|
+
renderFormDesignWidgetView (renderOpts: any, renderParams: any) {
|
|
85
|
+
return h(WidgetACheckboxViewComponent, { renderOpts, renderParams })
|
|
86
|
+
},
|
|
87
|
+
renderFormDesignWidgetFormView (renderOpts: any, renderParams: any) {
|
|
88
|
+
return h(WidgetACheckboxFormComponent, { renderOpts, renderParams })
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
ASwitchWidget: {
|
|
92
|
+
createFormDesignWidgetConfig: getWidgetASwitchConfig,
|
|
93
|
+
renderFormDesignWidgetView (renderOpts, renderParams) {
|
|
94
|
+
return h(WidgetASwitchViewComponent, { renderOpts, renderParams })
|
|
95
|
+
},
|
|
96
|
+
renderFormDesignWidgetFormView (renderOpts, renderParams) {
|
|
97
|
+
return h(WidgetASwitchFormComponent, { renderOpts, renderParams })
|
|
98
|
+
}
|
|
32
99
|
}
|
|
33
100
|
})
|
|
34
101
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, h, PropType, resolveComponent, ComponentOptions } from 'vue'
|
|
2
2
|
|
|
3
|
-
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormComponent, VxeFormItemComponent, VxeSwitchComponent } from 'vxe-pc-ui'
|
|
3
|
+
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormComponent, VxeFormItemComponent, VxeSwitchComponent, VxeInputComponent } from 'vxe-pc-ui'
|
|
4
4
|
|
|
5
5
|
interface WidgetAInputFormObjVO {
|
|
6
6
|
placeholder: string
|
|
@@ -33,6 +33,7 @@ export function createWidgetAInput (VxeUI: VxeUIExport) {
|
|
|
33
33
|
const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
|
|
34
34
|
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
35
35
|
const VxeUISwitchComponent = VxeUI.getComponent<VxeSwitchComponent>('VxeSwitch')
|
|
36
|
+
const VxeUIInputComponent = VxeUI.getComponent<VxeInputComponent>('VxeInput')
|
|
36
37
|
|
|
37
38
|
return () => {
|
|
38
39
|
const { renderParams } = props
|
|
@@ -53,7 +54,7 @@ export function createWidgetAInput (VxeUI: VxeUIExport) {
|
|
|
53
54
|
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
54
55
|
}, {
|
|
55
56
|
default () {
|
|
56
|
-
return h(
|
|
57
|
+
return h(VxeUIInputComponent, {
|
|
57
58
|
modelValue: widget.title,
|
|
58
59
|
placeholder: options.placeholder,
|
|
59
60
|
'onUpdate:modelValue' (val: any) {
|
|
@@ -121,9 +122,9 @@ export function createWidgetAInput (VxeUI: VxeUIExport) {
|
|
|
121
122
|
}, {
|
|
122
123
|
default () {
|
|
123
124
|
return h(resolveComponent('a-input') as ComponentOptions, {
|
|
124
|
-
|
|
125
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
125
126
|
onChange: changeEvent,
|
|
126
|
-
'onUpdate:
|
|
127
|
+
'onUpdate:value' (val: any) {
|
|
127
128
|
if ($formView) {
|
|
128
129
|
$formView.setItemValue(widget, val)
|
|
129
130
|
}
|
|
@@ -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
|
+
}
|