Blame view

src/components/table/table-body.vue 2.98 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
7
          </colgroup>
          <tbody :class="[prefixCls + '-tbody']">
              <tr
486d4fda   梁灏   update Table
8
                  v-for="(row, index) in data"
d3dfdb26   梁灏   update Table
9
10
11
                  :class="rowClasses(row._index)"
                  @mouseenter.stop="handleMouseIn(row._index)"
                  @mouseleave.stop="handleMouseOut(row._index)"
da55375f   Rijn   Added click and d...
12
13
                  @click.stop="clickCurrentRow(row._index)"
                  @dblclick.stop="dblclickCurrentRow(row._index)">
891700ae   梁灏   update Table
14
                  <td v-for="column in columns" :class="alignCls(column, row)">
7f34c510   梁灏   update Table
15
16
17
18
19
                      <Cell
                          :fixed="fixed"
                          :prefix-cls="prefixCls"
                          :row="row"
                          :column="column"
741b987a   梁灏   update Table
20
21
                          :natural-index="index"
                          :index="row._index"
0dcc9482   leonine   itable 添加禁用某行选中的功能
22
23
24
                          :checked="rowChecked(row._index)"
                          :disabled="rowDisabled(row._index)"
                          ></Cell>
7f34c510   梁灏   update Table
25
26
27
                  </td>
              </tr>
          </tbody>
3ef4dfb9   梁灏   update Table
28
      </table>
2cb8a6d9   梁灏   commit Table comp...
29
30
  </template>
  <script>
7f34c510   梁灏   update Table
31
32
33
      import Cell from './cell.vue';
      import Mixin from './mixin';
  
2cb8a6d9   梁灏   commit Table comp...
34
      export default {
486d4fda   梁灏   update Table
35
          name: 'TableBody',
7f34c510   梁灏   update Table
36
37
          mixins: [ Mixin ],
          components: { Cell },
2cb8a6d9   梁灏   commit Table comp...
38
          props: {
7f34c510   梁灏   update Table
39
              prefixCls: String,
486d4fda   梁灏   update Table
40
              styleObject: Object,
7f34c510   梁灏   update Table
41
              columns: Array,
741b987a   梁灏   update Table
42
              data: Array,    // rebuildData
741b987a   梁灏   update Table
43
              objData: Object,
224a3ae5   梁灏   publish 0.9.9-rc-3
44
              columnsWidth: Object,
5d0499ce   梁灏   update Table
45
46
47
48
              fixed: {
                  type: [Boolean, String],
                  default: false
              }
2cb8a6d9   梁灏   commit Table comp...
49
50
          },
          methods: {
d3dfdb26   梁灏   update Table
51
              rowClasses (_index) {
c6f21c2f   jingsam   :bug: fix ie bug
52
53
                  return [
                      `${this.prefixCls}-row`,
741b987a   梁灏   update Table
54
                      this.rowClsName(_index),
c6f21c2f   jingsam   :bug: fix ie bug
55
                      {
97edb2eb   梁灏   update Table
56
                          [`${this.prefixCls}-row-highlight`]: this.objData[_index] && this.objData[_index]._isHighlight,
87379c82   leonine   去掉禁用行的 tr>td 的dis...
57
                          [`${this.prefixCls}-row-hover`]: this.objData[_index] && this.objData[_index]._isHover
c6f21c2f   jingsam   :bug: fix ie bug
58
                      }
b0893113   jingsam   :art: add eslint
59
                  ];
c6f21c2f   jingsam   :bug: fix ie bug
60
              },
d3dfdb26   梁灏   update Table
61
              rowChecked (_index) {
97edb2eb   梁灏   update Table
62
                  return this.objData[_index] && this.objData[_index]._isChecked;
741b987a   梁灏   update Table
63
              },
0dcc9482   leonine   itable 添加禁用某行选中的功能
64
65
66
              rowDisabled(_index){
                  return this.objData[_index] && this.objData[_index]._isDisabled;
              },
d3dfdb26   梁灏   update Table
67
68
              rowClsName (_index) {
                  return this.$parent.rowClassName(this.objData[_index], _index);
7f34c510   梁灏   update Table
69
              },
d3dfdb26   梁灏   update Table
70
71
              handleMouseIn (_index) {
                  this.$parent.handleMouseIn(_index);
7f34c510   梁灏   update Table
72
              },
d3dfdb26   梁灏   update Table
73
74
              handleMouseOut (_index) {
                  this.$parent.handleMouseOut(_index);
7f34c510   梁灏   update Table
75
              },
da55375f   Rijn   Added click and d...
76
77
78
79
80
              clickCurrentRow (_index) {
                  this.$parent.clickCurrentRow(_index);
              },
              dblclickCurrentRow (_index) {
                  this.$parent.dblclickCurrentRow(_index);
7f34c510   梁灏   update Table
81
              }
2cb8a6d9   梁灏   commit Table comp...
82
          }
b0893113   jingsam   :art: add eslint
83
84
      };
  </script>