Blame view

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