|
1 | 1 | <template> |
2 | 2 | <div> |
3 | | - <vxe-table |
4 | | - border |
5 | | - :data="tableData"> |
6 | | - <vxe-column type="checkbox" width="60"></vxe-column> |
7 | | - <vxe-column type="seq" width="60"></vxe-column> |
8 | | - <vxe-column field="name" title="Name"></vxe-column> |
9 | | - |
10 | | - </vxe-table> |
| 3 | + <vxe-grid v-bind="gridOptions"></vxe-grid> |
11 | 4 | </div> |
12 | 5 | </template> |
13 | 6 |
|
14 | | -<script> |
15 | | -export default { |
16 | | - data () { |
17 | | - return { |
18 | | - tableData: [], |
19 | | - gridOptions: { |
20 | | - virtualYConfig: { |
21 | | - enabled: true, |
22 | | - gt: 0 |
23 | | - }, |
24 | | - virtualXConfig: { |
25 | | - enabled: true, |
26 | | - gt: 0 |
27 | | - }, |
28 | | - columns: [ |
29 | | - { type: 'seq', width: 60, fixed: 'left' }, |
30 | | - { field: 'name', title: 'Name', width: '100px' }, |
31 | | - { field: 'sex', title: 'Sex', minWidth: '100px' }, |
32 | | - { field: 'date', title: 'Date', minWidth: '100px' }, |
33 | | - { field: 'address', title: 'Address', minWidth: '100px' }, |
34 | | - { type: 'seq', width: 60, fixed: 'right' } |
35 | | - ], |
36 | | - data: [], |
37 | | - height: '114px' |
38 | | - } |
39 | | - } |
| 7 | +<script setup> |
| 8 | +import { reactive } from 'vue' |
| 9 | +const gridOptions = reactive({ |
| 10 | + border: true, |
| 11 | + columnConfig: { |
| 12 | + drag: true |
40 | 13 | }, |
41 | | - created () { |
42 | | - const list1 = [] |
43 | | - const list2 = [] |
44 | | - for (let index = 0; index < 3; index++) { |
45 | | - list2.push({ |
46 | | - name: 'test' + index, |
47 | | - role: 'developer', |
48 | | - sex: 'Man', |
49 | | - date: '2019-05-01', |
50 | | - time: 1556677810888 + index * 500, |
51 | | - region: 'ShenZhen', |
52 | | - address: 'address abc' + index |
53 | | - }) |
54 | | - } |
55 | | - this.gridOptions.data = list2 |
| 14 | + columnDragConfig: { |
| 15 | + isCrossDrag: true, |
| 16 | + isSelfToChildDrag: true |
56 | 17 | }, |
57 | | - methods: { |
58 | | - remove () { |
59 | | - const last = this.$refs.$ref.getTableData().fullData[0] |
60 | | - this.$refs.$ref.remove(last) |
| 18 | + columns: [ |
| 19 | + { field: 'name', title: 'Name' }, |
| 20 | + { field: 'role', title: 'Role', dragSort: true }, |
| 21 | + { |
| 22 | + title: '分组1', |
| 23 | + field: 'group1', |
| 24 | + children: [ |
| 25 | + { field: 'sex', title: 'Sex' } |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + title: '分组6', |
| 30 | + field: 'group6', |
| 31 | + children: [ |
| 32 | + { |
| 33 | + title: '分组9', |
| 34 | + field: 'group9', |
| 35 | + children: [ |
| 36 | + { field: 'age', title: 'Age' }, |
| 37 | + { field: 'address', title: 'Address' } |
| 38 | + ] |
| 39 | + } |
| 40 | + ] |
61 | 41 | } |
62 | | - } |
63 | | -} |
| 42 | + ], |
| 43 | + data: [ |
| 44 | + { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' }, |
| 45 | + { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' }, |
| 46 | + { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' }, |
| 47 | + { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' } |
| 48 | + ] |
| 49 | +}) |
| 50 | +
|
64 | 51 | </script> |
0 commit comments