Blame view

examples/routers/table.vue 4.48 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
367a4196   Aresn   update Table
2
      <Table border :columns="columns7" :data="data6" @on-expand="expand"></Table>
2cb8a6d9   梁灏   commit Table comp...
3
4
  </template>
  <script>
718e773f   刘荣   -
5
      import TableExpand from '../components/tableExpand.vue';
08fd628d   Aresn   Table support expand
6
      import etable from '../components/table.vue';
2cb8a6d9   梁灏   commit Table comp...
7
      export default {
08fd628d   Aresn   Table support expand
8
          components: { etable },
2cb8a6d9   梁灏   commit Table comp...
9
10
          data () {
              return {
08fd628d   Aresn   Table support expand
11
                  columns7: [
10d3a323   Aresn   fixed #1011
12
                      {
08fd628d   Aresn   Table support expand
13
14
15
16
                          type: 'expand',
                          width: 50,
                          render: (h, params) => {
  //                            return h(etable);
718e773f   刘荣   -
17
18
  //                            return h('div', params.row.name)
                              return h(TableExpand, { props: { name: params.row.name } })
08fd628d   Aresn   Table support expand
19
                          }
10d3a323   Aresn   fixed #1011
20
                      },
2404849c   leonine   合并原作者更新
21
                      {
7409cb3c   梁灏   fixed #549
22
                          title: '姓名',
64f99c05   梁灏   Table support ren...
23
                          key: 'name',
10d3a323   Aresn   fixed #1011
24
                          render: (h, params) => {
08fd628d   Aresn   Table support expand
25
26
27
28
29
30
31
32
                              return h('div', [
                                  h('Icon', {
                                      props: {
                                          type: 'person'
                                      }
                                  }),
                                  h('strong', params.row.name)
                              ]);
64f99c05   梁灏   Table support ren...
33
                          }
b89a982e   梁灏   fixed #205
34
35
                      },
                      {
7409cb3c   梁灏   fixed #549
36
                          title: '年龄',
10d3a323   Aresn   fixed #1011
37
38
                          key: 'age',
                          sortable: true
99d0429e   梁灏   update Button & T...
39
40
                      },
                      {
7409cb3c   梁灏   fixed #549
41
42
                          title: '地址',
                          key: 'address'
08fd628d   Aresn   Table support expand
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
                      },
                      {
                          title: '操作',
                          key: 'action',
                          width: 150,
                          align: 'center',
                          render: (h, params) => {
                              return h('div', [
                                  h('Button', {
                                      props: {
                                          type: 'primary',
                                          size: 'small'
                                      },
                                      style: {
                                          marginRight: '5px'
                                      },
                                      on: {
                                          click: () => {
                                              this.show(params.index)
                                          }
                                      }
                                  }, '查看'),
                                  h('Button', {
                                      props: {
                                          type: 'error',
                                          size: 'small'
                                      },
                                      on: {
                                          click: () => {
                                              this.remove(params.index)
                                          }
                                      }
                                  }, '删除')
                              ]);
                          }
64f99c05   梁灏   Table support ren...
78
79
                      }
                  ],
08fd628d   Aresn   Table support expand
80
                  data6: [
7409cb3c   梁灏   fixed #549
81
82
83
                      {
                          name: '王小明',
                          age: 18,
08fd628d   Aresn   Table support expand
84
                          address: '北京市朝阳区芍药居'
3c38e4f7   梁灏   update Table cell
85
                      },
891f61d8   梁灏   fixed #577
86
                      {
7409cb3c   梁灏   fixed #549
87
88
                          name: '张小刚',
                          age: 25,
e4e8711d   Aresn   Table support dis...
89
90
                          address: '北京市海淀区西二旗',
                          _disableExpand: true
08fd628d   Aresn   Table support expand
91
92
93
94
                      },
                      {
                          name: '李小红',
                          age: 30,
d6070b23   Aresn   update Table
95
96
                          address: '上海市浦东新区世纪大道',
                          _expanded: true
08fd628d   Aresn   Table support expand
97
98
99
100
101
                      },
                      {
                          name: '周小伟',
                          age: 26,
                          address: '深圳市南山区深南大道'
891f61d8   梁灏   fixed #577
102
                      }
d16dce64   梁灏   fixed #193
103
                  ]
2cb8a6d9   梁灏   commit Table comp...
104
              }
08fd628d   Aresn   Table support expand
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
          },
          methods: {
              show (index) {
                  this.$Modal.info({
                      title: '用户信息',
                      content: `姓名:${this.data6[index].name}<br>年龄:${this.data6[index].age}<br>地址:${this.data6[index].address}`
                  })
              },
              remove (index) {
                  this.data6.splice(index, 1);
              },
              expand (row, s) {
  //                console.log(row);
  //                console.log(s);
              }
2cb8a6d9   梁灏   commit Table comp...
120
121
          }
      }
d0e206c5   梁灏   Table add content...
122
  </script>