Blame view

examples/routers/table.vue 5.68 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
68b308ee   梁灏   fixex #1353
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
      <div>
          <div style="margin: 10px">
              显示边框 <i-switch v-model="showBorder" style="margin-right: 5px"></i-switch>
              显示斑马纹 <i-switch v-model="showStripe" style="margin-right: 5px"></i-switch>
              显示索引 <i-switch v-model="showIndex" style="margin-right: 5px"></i-switch>
              显示多选框 <i-switch v-model="showCheckbox" style="margin-right: 5px"></i-switch>
              显示表头 <i-switch v-model="showHeader" style="margin-right: 5px"></i-switch>
              表格滚动 <i-switch v-model="fixedHeader" style="margin-right: 5px"></i-switch>
              <br>
              <br>
              表格尺寸
              <Radio-group v-model="tableSize" type="button">
              <Radio label="large">大</Radio>
              <Radio label="default">中</Radio>
              <Radio label="small">小</Radio>
          </Radio-group>
          </div>
          <Table :border="showBorder" :stripe="showStripe" :show-header="showHeader" :height="fixedHeader ? 250 : ''" :size="tableSize" :data="tableData3" :columns="tableColumns3"></Table>
      </div>
2cb8a6d9   梁灏   commit Table comp...
21
22
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
23
      export default {
2cb8a6d9   梁灏   commit Table comp...
24
25
          data () {
              return {
68b308ee   梁灏   fixex #1353
26
                  tableData3: [
10d3a323   Aresn   fixed #1011
27
                      {
68b308ee   梁灏   fixex #1353
28
29
30
31
                          name: '王小明',
                          age: 18,
                          address: '北京市朝阳区芍药居',
                          date: '2016-10-03'
10d3a323   Aresn   fixed #1011
32
                      },
2404849c   leonine   合并原作者更新
33
                      {
68b308ee   梁灏   fixex #1353
34
35
36
37
                          name: '张小刚',
                          age: 24,
                          address: '北京市海淀区西二旗',
                          date: '2016-10-01'
b89a982e   梁灏   fixed #205
38
39
                      },
                      {
68b308ee   梁灏   fixex #1353
40
41
42
43
                          name: '李小红',
                          age: 30,
                          address: '上海市浦东新区世纪大道',
                          date: '2016-10-02'
99d0429e   梁灏   update Button & T...
44
45
                      },
                      {
68b308ee   梁灏   fixex #1353
46
47
48
49
                          name: '周小伟',
                          age: 26,
                          address: '深圳市南山区深南大道',
                          date: '2016-10-04'
08fd628d   Aresn   Table support expand
50
51
                      },
                      {
7409cb3c   梁灏   fixed #549
52
53
                          name: '王小明',
                          age: 18,
4098c176   Aresn   update Table
54
55
                          address: '北京市朝阳区芍药居',
                          date: '2016-10-03'
3c38e4f7   梁灏   update Table cell
56
                      },
891f61d8   梁灏   fixed #577
57
                      {
7409cb3c   梁灏   fixed #549
58
                          name: '张小刚',
68b308ee   梁灏   fixex #1353
59
                          age: 24,
e4e8711d   Aresn   Table support dis...
60
                          address: '北京市海淀区西二旗',
4098c176   Aresn   update Table
61
                          date: '2016-10-01'
08fd628d   Aresn   Table support expand
62
63
64
65
                      },
                      {
                          name: '李小红',
                          age: 30,
d6070b23   Aresn   update Table
66
                          address: '上海市浦东新区世纪大道',
4098c176   Aresn   update Table
67
                          date: '2016-10-02'
08fd628d   Aresn   Table support expand
68
69
70
71
                      },
                      {
                          name: '周小伟',
                          age: 26,
4098c176   Aresn   update Table
72
73
                          address: '深圳市南山区深南大道',
                          date: '2016-10-04'
68b308ee   梁灏   fixex #1353
74
75
76
77
78
79
80
81
82
                      }
                  ],
                  showBorder: false,
                  showStripe: false,
                  showHeader: true,
                  showIndex: true,
                  showCheckbox: false,
                  fixedHeader: false,
                  tableSize: 'default'
2cb8a6d9   梁灏   commit Table comp...
83
              }
b0f1c61f   Rijn   add a event @on-s...
84
          },
68b308ee   梁灏   fixex #1353
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
          computed: {
              tableColumns3 () {
                  let columns = [];
                  if (this.showCheckbox) {
                      columns.push({
                          type: 'selection',
                          width: 60,
                          align: 'center'
                      })
                  }
                  if (this.showIndex) {
                      columns.push({
                          type: 'index',
                          width: 60,
                          align: 'center'
                      })
                  }
                  columns.push({
                      title: '日期',
                      key: 'date',
                      sortable: true
                  });
                  columns.push({
                      title: '姓名',
                      key: 'name'
                  });
                  columns.push({
                      title: '年龄',
                      key: 'age',
                      sortable: true,
                      filters: [
                          {
                              label: '大于25岁',
                              value: 1
                          },
                          {
                              label: '小于25岁',
                              value: 2
                          }
                      ],
                      filterMultiple: false,
                      filterMethod (value, row) {
                          if (value === 1) {
                              return row.age > 25;
                          } else if (value === 2) {
                              return row.age < 25;
                          }
                      }
                  });
                  columns.push({
                      title: '地址',
                      key: 'address',
                      filters: [
                          {
                              label: '北京',
                              value: '北京'
                          },
                          {
                              label: '上海',
                              value: '上海'
                          },
                          {
                              label: '深圳',
                              value: '深圳'
                          }
                      ],
                      filterMethod (value, row) {
                          return row.address.indexOf(value) > -1;
                      }
                  });
                  return columns;
b0f1c61f   Rijn   add a event @on-s...
156
              }
2cb8a6d9   梁灏   commit Table comp...
157
158
          }
      }
68b308ee   梁灏   fixex #1353
159
  </script>