Blame view

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