Blame view

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