Blame view

src/components/table/table-body.vue 3.84 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
                  <table-tr
7e8e6ef8   forfire   add dragdrop for tr
9
                      :drag="drag"
e40c5352   Aresn   fixed #1195
10
                      :row="row"
68b308ee   梁灏   fixex #1353
11
                      :key="row._rowKey"
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
18
19
20
21
                      <td v-for="column in columns" :class="alignCls(column, row)">
                          <Cell
                              :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)"
0dcc9482   leonine   itable 添加禁用某行选中的功能
29
                          ></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'">
68b308ee   梁灏   fixex #1353
34
                          <Expand :key="row._rowKey" :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';
7f34c510   梁灏   update Table
44
      import Cell 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 ],
e40c5352   Aresn   fixed #1195
51
          components: { Cell, 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
63
              },
              drag:Boolean
2cb8a6d9   梁灏   commit Table comp...
64
          },
08fd628d   Aresn   Table support expand
65
66
67
68
69
70
71
72
73
74
75
76
77
78
          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...
79
          methods: {
d3dfdb26   梁灏   update Table
80
              rowChecked (_index) {
97edb2eb   梁灏   update Table
81
                  return this.objData[_index] && this.objData[_index]._isChecked;
741b987a   梁灏   update Table
82
              },
0dcc9482   leonine   itable 添加禁用某行选中的功能
83
84
85
              rowDisabled(_index){
                  return this.objData[_index] && this.objData[_index]._isDisabled;
              },
08fd628d   Aresn   Table support expand
86
87
88
              rowExpanded(_index){
                  return this.objData[_index] && this.objData[_index]._isExpanded;
              },
d3dfdb26   梁灏   update Table
89
90
              handleMouseIn (_index) {
                  this.$parent.handleMouseIn(_index);
7f34c510   梁灏   update Table
91
              },
d3dfdb26   梁灏   update Table
92
93
              handleMouseOut (_index) {
                  this.$parent.handleMouseOut(_index);
7f34c510   梁灏   update Table
94
              },
da55375f   Rijn   Added click and d...
95
96
97
98
99
              clickCurrentRow (_index) {
                  this.$parent.clickCurrentRow(_index);
              },
              dblclickCurrentRow (_index) {
                  this.$parent.dblclickCurrentRow(_index);
7f34c510   梁灏   update Table
100
              }
2cb8a6d9   梁灏   commit Table comp...
101
          }
b0893113   jingsam   :art: add eslint
102
103
      };
  </script>