@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
|
@@ -0,0 +1,140 @@
|
|
|
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 WidgetASwitchFormObjVO {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createWidgetASwitch (VxeUI: VxeUIExport) {
|
|
9
|
+
const getWidgetASwitchConfig = (params: VxeGlobalRendererHandles.CreateFormDesignWidgetConfigParams): VxeGlobalRendererHandles.CreateFormDesignWidgetConfigObj<WidgetASwitchFormObjVO> => {
|
|
10
|
+
return {
|
|
11
|
+
title: '是/否',
|
|
12
|
+
icon: 'vxe-icon-switch',
|
|
13
|
+
options: {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const WidgetASwitchFormComponent = defineComponent({
|
|
19
|
+
props: {
|
|
20
|
+
renderOpts: {
|
|
21
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions>,
|
|
22
|
+
default: () => ({})
|
|
23
|
+
},
|
|
24
|
+
renderParams: {
|
|
25
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<WidgetASwitchFormObjVO>>,
|
|
26
|
+
default: () => ({})
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
emits: [],
|
|
30
|
+
setup (props) {
|
|
31
|
+
const VxeUIFormComponent = VxeUI.getComponent<VxeFormComponent>('VxeForm')
|
|
32
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
33
|
+
const VxeUISwitchComponent = VxeUI.getComponent<VxeSwitchComponent>('VxeSwitch')
|
|
34
|
+
const VxeUIInputComponent = VxeUI.getComponent<VxeInputComponent>('VxeInput')
|
|
35
|
+
|
|
36
|
+
return () => {
|
|
37
|
+
const { renderParams } = props
|
|
38
|
+
const { widget } = renderParams
|
|
39
|
+
|
|
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(VxeUIInputComponent, {
|
|
55
|
+
modelValue: widget.title,
|
|
56
|
+
'onUpdate:modelValue' (val: any) {
|
|
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: any) {
|
|
74
|
+
widget.required = val
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const WidgetASwitchViewComponent = defineComponent({
|
|
87
|
+
props: {
|
|
88
|
+
renderOpts: {
|
|
89
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewOptions>,
|
|
90
|
+
default: () => ({})
|
|
91
|
+
},
|
|
92
|
+
renderParams: {
|
|
93
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewParams<WidgetASwitchFormObjVO>>,
|
|
94
|
+
default: () => ({})
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
emits: [],
|
|
98
|
+
setup (props) {
|
|
99
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
100
|
+
|
|
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.updateItemStatus(widget, itemValue)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return () => {
|
|
111
|
+
const { renderParams } = props
|
|
112
|
+
const { widget, $formView } = renderParams
|
|
113
|
+
|
|
114
|
+
return h(VxeUIFormItemComponent, {
|
|
115
|
+
class: ['vxe-form-design--widget-render-form-item'],
|
|
116
|
+
field: widget.field,
|
|
117
|
+
title: widget.title
|
|
118
|
+
}, {
|
|
119
|
+
default () {
|
|
120
|
+
return h(resolveComponent('a-switch') as ComponentOptions, {
|
|
121
|
+
checked: $formView ? $formView.getItemValue(widget) : null,
|
|
122
|
+
onChange: changeEvent,
|
|
123
|
+
'onUpdate:checked' (val: any) {
|
|
124
|
+
if ($formView) {
|
|
125
|
+
$formView.setItemValue(widget, val)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
getWidgetASwitchConfig,
|
|
137
|
+
WidgetASwitchFormComponent,
|
|
138
|
+
WidgetASwitchViewComponent
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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 WidgetATextareaFormObjVO {
|
|
6
|
+
placeholder: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function createWidgetATextarea (VxeUI: VxeUIExport) {
|
|
10
|
+
const getWidgetATextareaConfig = (params: VxeGlobalRendererHandles.CreateFormDesignWidgetConfigParams): VxeGlobalRendererHandles.CreateFormDesignWidgetConfigObj<WidgetATextareaFormObjVO> => {
|
|
11
|
+
return {
|
|
12
|
+
title: '文本域',
|
|
13
|
+
icon: 'vxe-icon-textarea',
|
|
14
|
+
options: {
|
|
15
|
+
placeholder: '请输入'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const WidgetATextareaFormComponent = defineComponent({
|
|
21
|
+
props: {
|
|
22
|
+
renderOpts: {
|
|
23
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions>,
|
|
24
|
+
default: () => ({})
|
|
25
|
+
},
|
|
26
|
+
renderParams: {
|
|
27
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<WidgetATextareaFormObjVO>>,
|
|
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 WidgetATextareaViewComponent = defineComponent({
|
|
89
|
+
props: {
|
|
90
|
+
renderOpts: {
|
|
91
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewOptions>,
|
|
92
|
+
default: () => ({})
|
|
93
|
+
},
|
|
94
|
+
renderParams: {
|
|
95
|
+
type: Object as PropType<VxeGlobalRendererHandles.RenderFormDesignWidgetViewParams<WidgetATextareaFormObjVO>>,
|
|
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-textarea') as ComponentOptions, {
|
|
124
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
125
|
+
placeholder: options.placeholder,
|
|
126
|
+
autoSize: {
|
|
127
|
+
minRows: 2,
|
|
128
|
+
maxRows: 4
|
|
129
|
+
},
|
|
130
|
+
onChange: changeEvent,
|
|
131
|
+
'onUpdate:value' (val: any) {
|
|
132
|
+
if ($formView) {
|
|
133
|
+
$formView.setItemValue(widget, val)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
getWidgetATextareaConfig,
|
|
145
|
+
WidgetATextareaFormComponent,
|
|
146
|
+
WidgetATextareaViewComponent
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { VNode, h, onMounted, ref, watch } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { VxeUIExport, VxeGlobalRendererHandles, VxeFormItemComponent, VxeButtonComponent, VxeTextareaComponent, VxeTipComponent } from 'vxe-pc-ui'
|
|
4
|
+
|
|
5
|
+
export interface WidgetDataSourceOptionSubObjVO {
|
|
6
|
+
value: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WidgetDataSourceOptionObjVO {
|
|
10
|
+
value: string,
|
|
11
|
+
options?: WidgetDataSourceOptionSubObjVO[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useWidgetPropDataSource (VxeUI: VxeUIExport, props: {
|
|
15
|
+
readonly renderOpts: VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewOptions;
|
|
16
|
+
readonly renderParams: VxeGlobalRendererHandles.RenderFormDesignWidgetFormViewParams<{
|
|
17
|
+
options: WidgetDataSourceOptionObjVO[]
|
|
18
|
+
}>;
|
|
19
|
+
}, isSubOption: boolean) {
|
|
20
|
+
const VxeUIFormItemComponent = VxeUI.getComponent<VxeFormItemComponent>('VxeFormItem')
|
|
21
|
+
const VxeUIButtonComponent = VxeUI.getComponent<VxeButtonComponent>('VxeButton')
|
|
22
|
+
const VxeUITextareaComponent = VxeUI.getComponent<VxeTextareaComponent>('VxeTextarea')
|
|
23
|
+
const VxeUITipComponent = VxeUI.getComponent<VxeTipComponent>('VxeTip')
|
|
24
|
+
|
|
25
|
+
const optionsContent = ref('')
|
|
26
|
+
const expandIndexList = ref<number[]>([])
|
|
27
|
+
|
|
28
|
+
const addOptionEvent = () => {
|
|
29
|
+
const { renderParams } = props
|
|
30
|
+
const { widget } = renderParams
|
|
31
|
+
const options = widget.options.options || []
|
|
32
|
+
options.push({
|
|
33
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [options.length + 1])
|
|
34
|
+
})
|
|
35
|
+
widget.options.options = [...options]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const subRE = /^(\s|\t)+/
|
|
39
|
+
|
|
40
|
+
const hasSubOption = (str: string) => {
|
|
41
|
+
return subRE.test(str)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const expandAllOption = () => {
|
|
45
|
+
const { renderParams } = props
|
|
46
|
+
const { widget } = renderParams
|
|
47
|
+
const options = widget.options.options || []
|
|
48
|
+
const indexList: number[] = []
|
|
49
|
+
options.forEach((group, gIndex) => {
|
|
50
|
+
const { options } = group
|
|
51
|
+
if (options && options.length) {
|
|
52
|
+
indexList.push(gIndex)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
expandIndexList.value = indexList
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const toggleExpandOption = (item: WidgetDataSourceOptionSubObjVO, gIndex: number) => {
|
|
59
|
+
if (expandIndexList.value.includes(gIndex)) {
|
|
60
|
+
expandIndexList.value = expandIndexList.value.filter(num => num !== gIndex)
|
|
61
|
+
} else {
|
|
62
|
+
expandIndexList.value.push(gIndex)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const confirmBatchAddOptionEvent = () => {
|
|
67
|
+
const { renderParams } = props
|
|
68
|
+
const { widget } = renderParams
|
|
69
|
+
const optList: WidgetDataSourceOptionSubObjVO[] = []
|
|
70
|
+
const rowList = optionsContent.value.split('\n')
|
|
71
|
+
let prevGroup: Required<WidgetDataSourceOptionObjVO> | null = null
|
|
72
|
+
if (isSubOption) {
|
|
73
|
+
rowList.forEach((str, index) => {
|
|
74
|
+
const nextStr = rowList[index + 1]
|
|
75
|
+
const value = str.trim()
|
|
76
|
+
if (!value) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
const item: WidgetDataSourceOptionSubObjVO = {
|
|
80
|
+
value
|
|
81
|
+
}
|
|
82
|
+
if (prevGroup) {
|
|
83
|
+
if (hasSubOption(str)) {
|
|
84
|
+
prevGroup.options.push(item)
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
prevGroup = null
|
|
88
|
+
optList.push(item)
|
|
89
|
+
} else {
|
|
90
|
+
optList.push(item)
|
|
91
|
+
}
|
|
92
|
+
if (nextStr) {
|
|
93
|
+
if (hasSubOption(nextStr)) {
|
|
94
|
+
prevGroup = Object.assign(item, { options: [] })
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
} else {
|
|
99
|
+
rowList.forEach((str) => {
|
|
100
|
+
optList.push({
|
|
101
|
+
value: str.trim()
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
widget.options.options = optList
|
|
106
|
+
expandAllOption()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const openPopupEditEvent = () => {
|
|
110
|
+
const { renderParams } = props
|
|
111
|
+
const { widget } = renderParams
|
|
112
|
+
|
|
113
|
+
const contList: string[] = []
|
|
114
|
+
widget.options.options?.forEach(group => {
|
|
115
|
+
contList.push(group.value)
|
|
116
|
+
group.options?.forEach(item => {
|
|
117
|
+
contList.push(`\t${item.value}`)
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
optionsContent.value = contList.join('\n')
|
|
122
|
+
|
|
123
|
+
VxeUI.modal.open({
|
|
124
|
+
title: `${widget.title} - ${VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption')}`,
|
|
125
|
+
width: 500,
|
|
126
|
+
height: '50vh ',
|
|
127
|
+
resize: true,
|
|
128
|
+
showFooter: true,
|
|
129
|
+
showCancelButton: true,
|
|
130
|
+
showConfirmButton: true,
|
|
131
|
+
confirmButtonText: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.buildOption'),
|
|
132
|
+
onConfirm: confirmBatchAddOptionEvent,
|
|
133
|
+
slots: {
|
|
134
|
+
default () {
|
|
135
|
+
return h('div', {
|
|
136
|
+
class: 'vxe-form-design--widget-form-item-data-source-popup'
|
|
137
|
+
}, [
|
|
138
|
+
h(VxeUITipComponent, {
|
|
139
|
+
status: 'primary',
|
|
140
|
+
title: '',
|
|
141
|
+
content: VxeUI.getI18n(`vxe.formDesign.widgetProp.dataSource.${isSubOption ? 'batchEditSubTip' : 'batchEditTip'}`)
|
|
142
|
+
}),
|
|
143
|
+
h(VxeUITextareaComponent, {
|
|
144
|
+
resize: 'none',
|
|
145
|
+
modelValue: optionsContent.value,
|
|
146
|
+
'onUpdate:modelValue' (val: any) {
|
|
147
|
+
optionsContent.value = val
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
])
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const renderOption = (item: WidgetDataSourceOptionSubObjVO, hasFirstLevel: boolean, isExpand: boolean, gIndex: number, hasSub: boolean, isFirst: boolean, isLast: boolean) => {
|
|
157
|
+
return h('div', {
|
|
158
|
+
class: ['vxe-form-design--widget-form-item-data-source-option', {
|
|
159
|
+
'is--first': isFirst,
|
|
160
|
+
'is--last': isLast
|
|
161
|
+
}]
|
|
162
|
+
}, [
|
|
163
|
+
h('div', {
|
|
164
|
+
class: 'vxe-form-design--widget-expand-btn'
|
|
165
|
+
}, hasFirstLevel && hasSub
|
|
166
|
+
? [
|
|
167
|
+
h('i', {
|
|
168
|
+
class: isExpand ? VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_CLOSE : VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_OPEN,
|
|
169
|
+
onClick () {
|
|
170
|
+
toggleExpandOption(item, gIndex)
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
: []),
|
|
175
|
+
h('input', {
|
|
176
|
+
class: 'vxe-default-input',
|
|
177
|
+
value: item.value,
|
|
178
|
+
onInput (evnt: InputEvent & { target: HTMLInputElement }) {
|
|
179
|
+
item.value = evnt.target.value
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
h(VxeUIButtonComponent, {
|
|
183
|
+
status: 'danger',
|
|
184
|
+
mode: 'text',
|
|
185
|
+
icon: VxeUI.getIcon().FORM_DESIGN_WIDGET_DELETE
|
|
186
|
+
})
|
|
187
|
+
])
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const renderOptions = () => {
|
|
191
|
+
const { renderParams } = props
|
|
192
|
+
const { widget } = renderParams
|
|
193
|
+
const { options } = widget
|
|
194
|
+
const groups = options.options
|
|
195
|
+
const optVNs: VNode[] = []
|
|
196
|
+
if (groups) {
|
|
197
|
+
groups.forEach((group, gIndex) => {
|
|
198
|
+
const { options } = group
|
|
199
|
+
const isExpand = expandIndexList.value.includes(gIndex)
|
|
200
|
+
if (options && options.length) {
|
|
201
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, true, gIndex === 0, gIndex === groups.length - 1))
|
|
202
|
+
if (isExpand) {
|
|
203
|
+
optVNs.push(
|
|
204
|
+
h('div', {
|
|
205
|
+
class: 'vxe-form-design--widget-form-item-data-source-sub-option'
|
|
206
|
+
}, options.map(item => renderOption(item, false, isExpand, 0, false, false, false)))
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, false, gIndex === 0, gIndex === groups.length - 1))
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
return optVNs
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
watch(() => props.renderParams.widget, () => {
|
|
218
|
+
expandAllOption()
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
onMounted(() => {
|
|
222
|
+
expandAllOption()
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
renderDataSourceFormItem () {
|
|
227
|
+
return h(VxeUIFormItemComponent, {
|
|
228
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.name'),
|
|
229
|
+
field: 'options'
|
|
230
|
+
}, {
|
|
231
|
+
default () {
|
|
232
|
+
return [
|
|
233
|
+
h('div', {}, [
|
|
234
|
+
h(VxeUIButtonComponent, {
|
|
235
|
+
status: 'primary',
|
|
236
|
+
mode: 'text',
|
|
237
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.addOption'),
|
|
238
|
+
onClick: addOptionEvent
|
|
239
|
+
}),
|
|
240
|
+
h(VxeUIButtonComponent, {
|
|
241
|
+
status: 'primary',
|
|
242
|
+
mode: 'text',
|
|
243
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption'),
|
|
244
|
+
onClick: openPopupEditEvent
|
|
245
|
+
})
|
|
246
|
+
]),
|
|
247
|
+
h('div', {
|
|
248
|
+
class: 'vxe-form-design--widget-form-item-data-source'
|
|
249
|
+
}, renderOptions())
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
package/src/table/index.ts
CHANGED
|
@@ -132,12 +132,28 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
function formatDatePicker (defaultFormat
|
|
135
|
+
function formatDatePicker (defaultFormat?: string) {
|
|
136
136
|
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
137
137
|
return getCellLabelVNs(renderOpts, params, getDatePickerCellValue(renderOpts, params, defaultFormat))
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
function formatTimePicker (defaultFormat?: string) {
|
|
142
|
+
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
143
|
+
const { props = {} } = renderOpts
|
|
144
|
+
const { row, column } = params
|
|
145
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
146
|
+
try {
|
|
147
|
+
if (cellValue) {
|
|
148
|
+
if (!XEUtils.isString(cellValue)) {
|
|
149
|
+
cellValue = cellValue.format ? cellValue.format(props.format || props.valueFormat || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || props.valueFormat || defaultFormat))
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch (e) {}
|
|
153
|
+
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
141
157
|
function getSelectCellValue (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
142
158
|
const { options = [], optionGroups, props = {}, optionProps = {}, optionGroupProps = {} } = renderOpts
|
|
143
159
|
const { row, column } = params
|
|
@@ -201,12 +217,30 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
201
217
|
return cellValue
|
|
202
218
|
}
|
|
203
219
|
|
|
204
|
-
function getDatePickerCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams, defaultFormat
|
|
220
|
+
function getDatePickerCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams, defaultFormat?: string) {
|
|
205
221
|
const { props = {} } = renderOpts
|
|
206
222
|
const { row, column } = params
|
|
207
223
|
let cellValue = XEUtils.get(row, column.field)
|
|
208
224
|
try {
|
|
209
225
|
if (cellValue) {
|
|
226
|
+
if (!defaultFormat) {
|
|
227
|
+
if (renderOpts.name === 'ADatePicker') {
|
|
228
|
+
switch (props.picker) {
|
|
229
|
+
case 'week':
|
|
230
|
+
defaultFormat = 'YYYY-WW周'
|
|
231
|
+
break
|
|
232
|
+
case 'month':
|
|
233
|
+
defaultFormat = 'YYYY-MM'
|
|
234
|
+
break
|
|
235
|
+
case 'year':
|
|
236
|
+
defaultFormat = 'YYYY'
|
|
237
|
+
break
|
|
238
|
+
default:
|
|
239
|
+
defaultFormat = props.showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'
|
|
240
|
+
break
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
210
244
|
cellValue = cellValue.format ? cellValue.format(props.format || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || defaultFormat))
|
|
211
245
|
}
|
|
212
246
|
} catch (e) {}
|
|
@@ -302,7 +336,7 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
302
336
|
return [formatText(cellValue)]
|
|
303
337
|
}
|
|
304
338
|
|
|
305
|
-
function createDatePickerExportMethod (defaultFormat
|
|
339
|
+
function createDatePickerExportMethod (defaultFormat?: string) {
|
|
306
340
|
return function (params: VxeGlobalRendererHandles.ExportMethodParams) {
|
|
307
341
|
const { row, column, options } = params
|
|
308
342
|
return options && options.original ? XEUtils.get(row, column.field) : getDatePickerCellValue(column.editRender || column.cellRender, params, defaultFormat)
|
|
@@ -318,21 +352,21 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
318
352
|
|
|
319
353
|
VxeUI.renderer.mixin({
|
|
320
354
|
AAutoComplete: {
|
|
321
|
-
tableAutoFocus: 'input
|
|
355
|
+
tableAutoFocus: 'input',
|
|
322
356
|
renderTableDefault: createEditRender(),
|
|
323
357
|
renderTableEdit: createEditRender(),
|
|
324
358
|
renderTableFilter: createFilterRender(),
|
|
325
359
|
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
326
360
|
},
|
|
327
361
|
AInput: {
|
|
328
|
-
tableAutoFocus: 'input
|
|
362
|
+
tableAutoFocus: 'input',
|
|
329
363
|
renderTableDefault: createEditRender(),
|
|
330
364
|
renderTableEdit: createEditRender(),
|
|
331
365
|
renderTableFilter: createFilterRender(),
|
|
332
366
|
tableFilterDefaultMethod: defaultFuzzyFilterMethod
|
|
333
367
|
},
|
|
334
368
|
AInputNumber: {
|
|
335
|
-
tableAutoFocus: 'input
|
|
369
|
+
tableAutoFocus: 'input',
|
|
336
370
|
renderTableDefault: createEditRender(),
|
|
337
371
|
renderTableEdit: createEditRender(),
|
|
338
372
|
renderTableFilter: createFilterRender(),
|
|
@@ -433,8 +467,8 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
433
467
|
},
|
|
434
468
|
ADatePicker: {
|
|
435
469
|
renderTableEdit: createEditRender(),
|
|
436
|
-
renderTableCell: formatDatePicker(
|
|
437
|
-
tableExportMethod: createDatePickerExportMethod(
|
|
470
|
+
renderTableCell: formatDatePicker(),
|
|
471
|
+
tableExportMethod: createDatePickerExportMethod()
|
|
438
472
|
},
|
|
439
473
|
AMonthPicker: {
|
|
440
474
|
renderTableEdit: createEditRender(),
|
|
@@ -455,7 +489,7 @@ export function defineTableRender (VxeUI: VxeUIExport) {
|
|
|
455
489
|
},
|
|
456
490
|
ATimePicker: {
|
|
457
491
|
renderTableEdit: createEditRender(),
|
|
458
|
-
renderTableCell:
|
|
492
|
+
renderTableCell: formatTimePicker('HH:mm:ss'),
|
|
459
493
|
tableExportMethod: createDatePickerExportMethod('HH:mm:ss')
|
|
460
494
|
},
|
|
461
495
|
ATreeSelect: {
|