|
4 | 4 | <template> |
5 | 5 | <v-table |
6 | 6 | :width="1100" |
7 | | - :height="500" |
| 7 | + :height="350" |
8 | 8 | even-bg-color="#f2f2f2" |
9 | 9 | :title-rows="tableConfig.titleRows" |
10 | 10 | :columns="tableConfig.columns" |
|
33 | 33 | tableConfig: { |
34 | 34 | multipleSort: false, |
35 | 35 | tableData: [], |
36 | | - titleRows: [], |
37 | 36 | columns: [ |
38 | 37 | { |
39 | 38 | field: 'custome', width: 50, titleAlign: 'center', columnAlign: 'center', |
|
44 | 43 | {field: 'name', width: 100, columnAlign: 'center', isFrozen: true}, |
45 | 44 | {field: 'gender', width: 150, columnAlign: 'center', isFrozen: true}, |
46 | 45 | {field: 'height', width: 150, columnAlign: 'center', isFrozen: true}, |
47 | | - {field: 'tel', width: 150, columnAlign: 'center'}, |
48 | | - {field: 'email', width: 200, columnAlign: 'center'}, |
49 | | - {field: 'hobby', width: 200, columnAlign: 'left'}, |
50 | | - {field: 'job', width: 200, columnAlign: 'left'} |
51 | | - ] |
52 | | - } |
53 | | - } |
54 | | - }, |
55 | | - methods: { |
56 | | -
|
57 | | - getTitleRows(){ |
58 | | -
|
59 | | - var rows = []; |
60 | | - rows.push([ |
61 | | - {fields: ['custome'], title: '排序', titleAlign: 'center', rowspan: 2}, |
62 | | - {fields: ['name', 'gender', 'height'], title: '基础信息', titleAlign: 'center', colspan: 3}, |
63 | | - {fields: ['tel', 'email'], title: '联系方式', titleAlign: 'center', colspan: 2}, |
64 | | - {fields: ['hobby'], title: '爱好', titleAlign: 'center', rowspan: 2}, |
65 | | - {fields: ['job'], title: '职业', titleAlign: 'center', rowspan: 2} |
| 46 | + {field: 'tel', width: 190, columnAlign: 'center'}, |
| 47 | + {field: 'email', width: 230, columnAlign: 'center'}, |
| 48 | + {field: 'hobby', width: 230, columnAlign: 'center'}, |
| 49 | + {field: 'address', width: 330, columnAlign: 'left'} |
66 | 50 | ], |
67 | | - [ |
68 | | - {fields: ['name'], title: '姓名', titleAlign: 'center'}, |
69 | | - {fields: ['gender'], title: '性别', titleAlign: 'center', orderBy: 'asc'}, |
70 | | - {fields: ['height'], title: '身高', titleAlign: 'center', orderBy: 'desc'}, |
71 | | - {fields: ['tel'], title: '手机号码', titleAlign: 'center'}, |
72 | | - {fields: ['email'], title: '邮箱', titleAlign: 'center'} |
73 | | - ]); |
74 | | -
|
75 | | - var otherData = [ |
76 | | - { |
77 | | - name1: '行业均值(算术平均)', |
78 | | - name2: '14,400.39', |
79 | | - name3: '8.69', |
80 | | - name4: '2,785', |
81 | | - name5: '50.28', |
82 | | - name6: '11.7538' |
83 | | - }, |
84 | | - { |
85 | | - name1: '行业中位数', |
86 | | - name2: '14,400.39', |
87 | | - name3: '8.69', |
88 | | - name4: '2,785', |
89 | | - name5: '50.28', |
90 | | - name6: '11.7538' |
91 | | - }, |
92 | | - ] |
93 | 51 |
|
94 | | - otherData.forEach(item => { |
95 | | - rows.push([ |
96 | | - {fields: ['custome', 'name', 'gender'], title: item.name1, titleAlign: 'center', colspan: 3}, |
| 52 | + titleRows: [ |
| 53 | + [{fields: ['custome'], title: '排序', titleAlign: 'center', rowspan: 2}, |
| 54 | + {fields: ['name', 'gender', 'height'], title: '基础信息', titleAlign: 'center', colspan: 3}, |
| 55 | + {fields: ['tel', 'email'], title: '联系方式', titleAlign: 'center', colspan: 2}, |
| 56 | + {fields: ['hobby','address'], title: '爱好及地址', titleAlign: 'center', rowspan: 2,colspan: 2}], |
97 | 57 |
|
98 | | - {fields: ['height'], title: item.name2, titleAlign: 'center', titleCellClassName: 'title-cell-class-name-test1'}, |
99 | | - {fields: ['tel'], title: item.name3, titleAlign: 'center', titleCellClassName: 'title-cell-class-name-test2'}, |
100 | | - {fields: ['email'], title: item.name4, titleAlign: 'center', titleCellClassName: 'title-cell-class-name-test2'}, |
101 | | - {fields: ['hobby'], title: item.name5, titleAlign: 'center', titleCellClassName: 'title-cell-class-name-test2'}, |
102 | | - {fields: ['job'], title: item.name6, titleAlign: 'center', titleCellClassName: 'title-cell-class-name-test2'} |
103 | | - ]); |
104 | | - }) |
| 58 | + [{fields: ['name'], title: '姓名', titleAlign: 'center'}, |
| 59 | + {fields: ['gender'], title: '性别', titleAlign: 'center', orderBy: 'asc'}, |
| 60 | + {fields: ['height'], title: '身高', titleAlign: 'center', orderBy: 'desc'}, |
| 61 | + {fields: ['tel'], title: '手机号码', titleAlign: 'center'}, |
| 62 | + {fields: ['email'], title: '邮箱', titleAlign: 'center'}], |
105 | 63 |
|
106 | | - return rows; |
| 64 | + [{fields: ['custome','name','gender','height'], title: '平均值', titleAlign: 'center', colspan: 4,titleCellClassName:'title-cell-class-name-test1'}, |
| 65 | + {fields: ['tel'], title: '000', titleAlign: 'center',titleCellClassName:'title-cell-class-name-test2'}, |
| 66 | + {fields: ['email'], title: '111', titleAlign: 'center',titleCellClassName:'title-cell-class-name-test2'}, |
| 67 | + {fields: ['hobby'], title: '222', titleAlign: 'center',titleCellClassName:'title-cell-class-name-test2'}, |
| 68 | + {fields: ['address'], title: '333', titleAlign: 'center',titleCellClassName:'title-cell-class-name-test2'}] |
| 69 | + ] |
| 70 | + } |
107 | 71 | } |
108 | 72 | }, |
| 73 | +
|
109 | 74 | created(){ |
110 | 75 |
|
111 | | - this.tableConfig.titleRows = this.getTitleRows(); |
112 | 76 | this.tableConfig.tableData = mockData; |
113 | 77 | } |
114 | 78 | } |
|
0 commit comments