Blame view

src/components/table/table-body.vue 4.07 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
486d4fda   梁灏   update Table
2
      <table cellspacing="0" cellpadding="0" border="0" :style="styleObject">
7f34c510   梁灏   update Table
3
          <colgroup>
eec3859c   huanghong   fixed table scollbar
4
              <col v-for="(column, index) in columns" :width="setCellWidth(column)">
7f34c510   梁灏   update Table
5
6
          </colgroup>
          <tbody :class="[prefixCls + '-tbody']">
08fd628d   Aresn   Table support expand
7
              <template v-for="(row, index) in data">
e40c5352   Aresn   fixed #1195
8
                  <table-tr
568ac30b   Aresn   change api name
9
                      :draggable="draggable"
e40c5352   Aresn   fixed #1195
10
                      :row="row"
76ae3e88   梁灏   fix #5380
11
                      :key="rowKey ? row._rowKey : index"
e40c5352   Aresn   fixed #1195
12
13
14
                      :prefix-cls="prefixCls"
                      @mouseenter.native.stop="handleMouseIn(row._index)"
                      @mouseleave.native.stop="handleMouseOut(row._index)"
8b530b1c   梁灏   fixed #1342
15
                      @click.native="clickCurrentRow(row._index)"
e40c5352   Aresn   fixed #1195
16
                      @dblclick.native.stop="dblclickCurrentRow(row._index)">
08fd628d   Aresn   Table support expand
17
                      <td v-for="column in columns" :class="alignCls(column, row)">
b55f59c6   Rookie_Zoe   fix #4258
18
                          <table-cell
08fd628d   Aresn   Table support expand
19
20
21
                              :fixed="fixed"
                              :prefix-cls="prefixCls"
                              :row="row"
68b308ee   梁灏   fixex #1353
22
                              :key="column._columnKey"
08fd628d   Aresn   Table support expand
23
24
25
26
27
28
                              :column="column"
                              :natural-index="index"
                              :index="row._index"
                              :checked="rowChecked(row._index)"
                              :disabled="rowDisabled(row._index)"
                              :expanded="rowExpanded(row._index)"
b55f59c6   Rookie_Zoe   fix #4258
29
                          ></table-cell>
08fd628d   Aresn   Table support expand
30
                      </td>
e40c5352   Aresn   fixed #1195
31
                  </table-tr>
55f90d87   梁灏   fixed #1648
32
                  <tr v-if="rowExpanded(row._index)" :class="{[prefixCls + '-expanded-hidden']: fixed}">
367a4196   Aresn   update Table
33
                      <td :colspan="columns.length" :class="prefixCls + '-expanded-cell'">
76ae3e88   梁灏   fix #5380
34
                          <Expand :key="rowKey ? row._rowKey : index" :row="row" :render="expandRender" :index="row._index"></Expand>
08fd628d   Aresn   Table support expand
35
36
37
                      </td>
                  </tr>
              </template>
7f34c510   梁灏   update Table
38
          </tbody>
3ef4dfb9   梁灏   update Table
39
      </table>
2cb8a6d9   梁灏   commit Table comp...
40
41
  </template>
  <script>
6cadeba4   梁灏   support Message
42
      // todo :key="row"
e40c5352   Aresn   fixed #1195
43
      import TableTr from './table-tr.vue';
b55f59c6   Rookie_Zoe   fix #4258
44
      import TableCell from './cell.vue';
718e773f   刘荣   -
45
      import Expand from './expand.js';
7f34c510   梁灏   update Table
46
47
      import Mixin from './mixin';
  
2cb8a6d9   梁灏   commit Table comp...
48
      export default {
486d4fda   梁灏   update Table
49
          name: 'TableBody',
7f34c510   梁灏   update Table
50
          mixins: [ Mixin ],
b55f59c6   Rookie_Zoe   fix #4258
51
          components: { TableCell, Expand, TableTr },
2cb8a6d9   梁灏   commit Table comp...
52
          props: {
7f34c510   梁灏   update Table
53
              prefixCls: String,
486d4fda   梁灏   update Table
54
              styleObject: Object,
7f34c510   梁灏   update Table
55
              columns: Array,
741b987a   梁灏   update Table
56
              data: Array,    // rebuildData
741b987a   梁灏   update Table
57
              objData: Object,
224a3ae5   梁灏   publish 0.9.9-rc-3
58
              columnsWidth: Object,
5d0499ce   梁灏   update Table
59
60
61
              fixed: {
                  type: [Boolean, String],
                  default: false
7e8e6ef8   forfire   add dragdrop for tr
62
              },
568ac30b   Aresn   change api name
63
64
65
              draggable: {
                  type: Boolean,
                  default: false
76ae3e88   梁灏   fix #5380
66
67
68
69
              },
              rowKey: {
                  type: Boolean,
                  default: false
5d0499ce   梁灏   update Table
70
              }
2cb8a6d9   梁灏   commit Table comp...
71
          },
08fd628d   Aresn   Table support expand
72
73
74
75
76
77
78
79
80
81
82
83
84
85
          computed: {
              expandRender () {
                  let render = function () {
                      return '';
                  };
                  for (let i = 0; i < this.columns.length; i++) {
                      const column = this.columns[i];
                      if (column.type && column.type === 'expand') {
                          if (column.render) render = column.render;
                      }
                  }
                  return render;
              }
          },
2cb8a6d9   梁灏   commit Table comp...
86
          methods: {
d3dfdb26   梁灏   update Table
87
              rowChecked (_index) {
97edb2eb   梁灏   update Table
88
                  return this.objData[_index] && this.objData[_index]._isChecked;
741b987a   梁灏   update Table
89
              },
0dcc9482   leonine   itable 添加禁用某行选中的功能
90
91
92
              rowDisabled(_index){
                  return this.objData[_index] && this.objData[_index]._isDisabled;
              },
08fd628d   Aresn   Table support expand
93
94
95
              rowExpanded(_index){
                  return this.objData[_index] && this.objData[_index]._isExpanded;
              },
d3dfdb26   梁灏   update Table
96
97
              handleMouseIn (_index) {
                  this.$parent.handleMouseIn(_index);
7f34c510   梁灏   update Table
98
              },
d3dfdb26   梁灏   update Table
99
100
              handleMouseOut (_index) {
                  this.$parent.handleMouseOut(_index);
7f34c510   梁灏   update Table
101
              },
da55375f   Rijn   Added click and d...
102
103
104
105
106
              clickCurrentRow (_index) {
                  this.$parent.clickCurrentRow(_index);
              },
              dblclickCurrentRow (_index) {
                  this.$parent.dblclickCurrentRow(_index);
7f34c510   梁灏   update Table
107
              }
2cb8a6d9   梁灏   commit Table comp...
108
          }
b0893113   jingsam   :art: add eslint
109
110
      };
  </script>