|
1 | 1 | <template> |
2 | 2 | <div> |
3 | | - <vxe-button status="primary" @click="handleClear">手动清除校验</vxe-button> |
4 | | - <vxe-button status="primary" @click="handleReset">手动重置</vxe-button> |
5 | | - <vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid> |
| 3 | + X:<vxe-radio-group v-model="scrollbarConfig.xConfig.position"> |
| 4 | + <vxe-radio-button checked-value="top" content="top"></vxe-radio-button> |
| 5 | + <vxe-radio-button checked-value="bottom" content="bottom"></vxe-radio-button> |
| 6 | + </vxe-radio-group> |
| 7 | + Y:<vxe-radio-group v-model="scrollbarConfig.yConfig.position"> |
| 8 | + <vxe-radio-button checked-value="left" content="left"></vxe-radio-button> |
| 9 | + <vxe-radio-button checked-value="right" content="right"></vxe-radio-button> |
| 10 | + </vxe-radio-group> |
| 11 | + 边距:<vxe-switch v-model="scrollbarConfig.padding"></vxe-switch> |
| 12 | + |
| 13 | + <vxe-grid v-bind="gridOptions"></vxe-grid> |
6 | 14 | </div> |
7 | 15 | </template> |
8 | 16 |
|
9 | | -<script> |
10 | | -export default { |
| 17 | +<script lang="ts"> |
| 18 | +import Vue from 'vue' |
| 19 | +import { VxeGridProps, VxeTablePropTypes, VxeWithRequired } from '../../../types' |
| 20 | +
|
| 21 | +interface RowVO { |
| 22 | + id: number |
| 23 | + name: string |
| 24 | + role: string |
| 25 | + sex: string |
| 26 | + age: number |
| 27 | + address: string |
| 28 | +} |
| 29 | +
|
| 30 | +export default Vue.extend({ |
11 | 31 | data () { |
12 | | - const gridOptions = { |
13 | | - showOverflow: true, |
14 | | - border: true, |
15 | | - height: 500, |
16 | | - formConfig: { |
17 | | - data: { |
18 | | - name: '', |
19 | | - role: '', |
20 | | - sex: '', |
21 | | - num: '', |
22 | | - address: '' |
23 | | - }, |
24 | | - items: [ |
25 | | - { field: 'name', title: 'Name', span: 12, itemRender: { name: 'VxeInput' } }, |
26 | | - { field: 'role', title: 'Role', span: 12, itemRender: { name: 'VxeInput' } }, |
27 | | - { field: 'age', title: 'Age', span: 12, itemRender: { name: 'VxeInput' } }, |
28 | | - { |
29 | | - span: 6, |
30 | | - itemRender: { |
31 | | - name: 'VxeButtonGroup', |
32 | | - options: [ |
33 | | - { type: 'submit', content: '搜索', status: 'primary' }, |
34 | | - { type: 'reset', content: '重置' } |
35 | | - ] |
36 | | - } |
37 | | - } |
38 | | - ], |
39 | | - rules: { |
40 | | - name: [{ required: true, message: 'name不能为空' }] |
41 | | - } |
| 32 | + const scrollbarConfig: VxeWithRequired<VxeTablePropTypes.ScrollbarConfig, 'xConfig' | 'yConfig'> = { |
| 33 | + padding: false, |
| 34 | + xConfig: { |
| 35 | + position: 'top' |
42 | 36 | }, |
| 37 | + yConfig: { |
| 38 | + position: 'left' |
| 39 | + } |
| 40 | + } |
| 41 | +
|
| 42 | + const gridOptions: VxeGridProps<RowVO> = { |
| 43 | + border: true, |
| 44 | + height: 300, |
| 45 | + useScrollbar: true, |
| 46 | + scrollbarConfig, |
43 | 47 | columns: [ |
44 | 48 | { field: 'seq', type: 'seq', width: 70 }, |
45 | | - { field: 'name', title: 'Name' }, |
46 | | - { field: 'sex', title: 'Sex' }, |
47 | | - { field: 'num', title: 'Num' }, |
48 | | - { field: 'address', title: 'Address' } |
| 49 | + { field: 'name', title: 'Name', minWidth: 300 }, |
| 50 | + { field: 'sex', title: 'Sex', minWidth: 200 }, |
| 51 | + { field: 'age', title: 'Age', minWidth: 200 }, |
| 52 | + { field: 'address', title: 'Address', minWidth: 400 } |
49 | 53 | ], |
50 | 54 | data: [ |
51 | | - { id: '10001', name: 'Test1', role: 'Develop', sex: 'Man', num: '28', address: 'test abc' }, |
52 | | - { id: '10002', name: 'Test2', role: 'Test', sex: 'Women', num: '22', address: 'Guangzhou' }, |
53 | | - { id: '10003', name: 'Test3', role: 'PM', sex: 'Man', num: '32', address: 'Shanghai' }, |
54 | | - { id: '10004', name: 'Test4', role: 'Designer', sex: 'Women', num: '24', address: 'Shanghai' }, |
55 | | - { id: '10005', name: 'Test5', role: 'Develop', sex: 'Man', num: '42', address: 'Guangzhou' }, |
56 | | - { id: '10006', name: 'Test6', role: 'Test', sex: 'Women', num: '39', address: 'Shanghai' }, |
57 | | - { id: '10007', name: 'Test7', role: 'Develop', sex: 'Man', num: '46', address: 'Shanghai' }, |
58 | | - { id: '10008', name: 'Test8', role: 'PM', sex: 'Women', num: '49', address: 'Guangzhou' } |
| 55 | + { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' }, |
| 56 | + { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' }, |
| 57 | + { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 24, address: 'Shanghai' }, |
| 58 | + { id: 10004, name: 'Test4', role: 'PM', sex: 'Man', age: 19, address: 'Shanghai' }, |
| 59 | + { id: 10005, name: 'Test5', role: 'Test', sex: 'Man', age: 18, address: 'Guangzhou' }, |
| 60 | + { id: 10006, name: 'Test6', role: 'Develop', sex: 'Man', age: 32, address: 'Guangzhou' }, |
| 61 | + { id: 10007, name: 'Test7', role: 'Test', sex: 'Women', age: 22, address: 'Shanghai' }, |
| 62 | + { id: 10008, name: 'Test8', role: 'PM', sex: 'Women', age: 32, address: 'Shanghai' }, |
| 63 | + { id: 10009, name: 'Test9', role: 'Develop', sex: 'Women', age: 44, address: 'Shanghai' }, |
| 64 | + { id: 10010, name: 'Test10', role: 'Develop', sex: 'Man', age: 39, address: 'Shanghai' } |
59 | 65 | ] |
60 | 66 | } |
| 67 | +
|
61 | 68 | return { |
62 | | - gridOptions |
63 | | - } |
64 | | - }, |
65 | | - methods: { |
66 | | - handleClear () { |
67 | | - this.$refs.gridRef.clearFormValidate() |
68 | | - console.log('111') |
69 | | - }, |
70 | | - handleReset () { |
71 | | - this.$refs.gridRef.resetForm() |
72 | | - console.log('222') |
| 69 | + gridOptions, |
| 70 | + scrollbarConfig |
73 | 71 | } |
74 | 72 | } |
75 | | -} |
| 73 | +}) |
76 | 74 | </script> |
0 commit comments