Blame view

src/components/table/table-head.vue 2.12 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
7f34c510   梁灏   update Table
2
3
4
5
6
7
8
      <table cellspacing="0" cellpadding="0" border="0" :style="style">
          <colgroup>
              <col v-for="column in columns" :width="setCellWidth(column, $index)">
          </colgroup>
          <thead>
              <tr>
                  <th v-for="column in columns" :class="alignCls(column)">
c6f21c2f   jingsam   :bug: fix ie bug
9
                      <div :class="cellClasses(column)">
7f34c510   梁灏   update Table
10
11
12
13
14
15
16
                          <template v-if="column.type === 'selection'"><Checkbox :checked="isSelectAll" @on-change="selectAll"></Checkbox></template>
                          <template v-else>{{{ renderHeader(column, $index) }}}</template>
                      </div>
                  </th>
              </tr>
          </thead>
      </table>
2cb8a6d9   梁灏   commit Table comp...
17
18
  </template>
  <script>
0d136465   梁灏   update Table
19
20
21
22
      import Checkbox from '../checkbox/checkbox.vue';
      import Mixin from './mixin';
      import { deepCopy } from '../../utils/assist';
  
2cb8a6d9   梁灏   commit Table comp...
23
      export default {
0d136465   梁灏   update Table
24
25
          mixins: [ Mixin ],
          components: { Checkbox },
2cb8a6d9   梁灏   commit Table comp...
26
27
          props: {
              prefixCls: String,
7f34c510   梁灏   update Table
28
              style: Object,
0d136465   梁灏   update Table
29
              columns: Array,
7f34c510   梁灏   update Table
30
31
              cloneData: Array,
              fixed: Boolean
2cb8a6d9   梁灏   commit Table comp...
32
33
          },
          computed: {
0d136465   梁灏   update Table
34
35
36
              isSelectAll () {
                  return !this.cloneData.some(data => !data._isChecked);
              }
2cb8a6d9   梁灏   commit Table comp...
37
38
          },
          methods: {
c6f21c2f   jingsam   :bug: fix ie bug
39
40
41
42
43
44
45
46
              cellClasses (column) {
                  return [
                      `${this.prefixCls}-cell`,
                      {
                          [`${this.prefixCls}-hidden`]: !this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right')
                      }
                  ]
              },
7f34c510   梁灏   update Table
47
48
49
              setCellWidth (column, index) {
                  return this.$parent.setCellWidth(column, index);
              },
2cb8a6d9   梁灏   commit Table comp...
50
51
52
53
54
55
              renderHeader (column, $index) {
                  if ('renderHeader' in this.columns[$index]) {
                      return this.columns[$index].renderHeader(column, $index);
                  } else {
                      return column.title || '#';
                  }
744eb0af   梁灏   update Table comp...
56
              },
0d136465   梁灏   update Table
57
58
              selectAll () {
                  const status = !this.isSelectAll;
3d9e4f20   梁灏   update Table
59
                  this.$parent.selectAll(status);
2cb8a6d9   梁灏   commit Table comp...
60
61
62
              }
          }
      }
c6f21c2f   jingsam   :bug: fix ie bug
63
  </script>