Blame view

src/components/table/mixin.js 2.31 KB
0d136465   梁灏   update Table
1
2
  export default {
      methods: {
891700ae   梁灏   update Table
3
          alignCls (column, row = {}) {
c211f717   梁灏   Table data suppor...
4
5
6
7
              let cellClassName = '';
              if (row.cellClassName && column.key && row.cellClassName[column.key]) {
                  cellClassName = row.cellClassName[column.key];
              }
5d0499ce   梁灏   update Table
8
9
              return [
                  {
c211f717   梁灏   Table data suppor...
10
                      [`${cellClassName}`]: cellClassName,    // cell className
891700ae   梁灏   update Table
11
                      [`${column.className}`]: column.className,    // column className
5d0499ce   梁灏   update Table
12
13
14
                      [`${this.prefixCls}-column-${column.align}`]: column.align,
                      [`${this.prefixCls}-hidden`]: (this.fixed === 'left' && column.fixed !== 'left') || (this.fixed === 'right' && column.fixed !== 'right') || (!this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right'))
                  }
b0893113   jingsam   :art: add eslint
15
              ];
5d0499ce   梁灏   update Table
16
17
18
          },
          isPopperShow (column) {
              return column.filters && ((!this.fixed && !column.fixed) || (this.fixed === 'left' && column.fixed === 'left') || (this.fixed === 'right' && column.fixed === 'right'));
5e7a3b29   梁灏   publish 0.9.9-rc-2
19
          },
3d6fa54b   梁灏   update Table
20
          setCellWidth (column, index, top) {
224a3ae5   梁灏   publish 0.9.9-rc-3
21
22
23
24
              let width = '';
              if (column.width) {
                  width = column.width;
              } else if (this.columnsWidth[column._index]) {
b0893113   jingsam   :art: add eslint
25
                  width = this.columnsWidth[column._index].width;
224a3ae5   梁灏   publish 0.9.9-rc-3
26
              }
3d6fa54b   梁灏   update Table
27
              // when browser has scrollBar,set a width to resolve scroll position bug
95e1720c   huanghong   fix ivu-table-fix...
28
              if (width && this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0 && column.fixed!=='left' && !this.fixed) {
47638ad8   huanghong   fixed table scrol...
29
                  let scrollBarWidth = this.$parent.scrollBarWidth;
f25f1252   huanghong   Refactor
30
                  if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
47638ad8   huanghong   fixed table scrol...
31
                  width += scrollBarWidth;
3d6fa54b   梁灏   update Table
32
33
              }
              // when fixed type,reset first right fixed column's width
9fea8e7d   huanghong   fixed ivu-table-f...
34
              if (this.fixed === 'right' && top ) {
c1115edd   huanghong   fixed table
35
36
                  //const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right');
                  if (this.columns.length  === index + 1) {
47638ad8   huanghong   fixed table scrol...
37
                      let scrollBarWidth = this.$parent.scrollBarWidth;
f25f1252   huanghong   Refactor
38
                      if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
47638ad8   huanghong   fixed table scrol...
39
40
                      width += scrollBarWidth;
                  }
3d6fa54b   梁灏   update Table
41
              }
51356c2c   梁灏   fixed #658
42
              if (width === '0') width = '';
224a3ae5   梁灏   publish 0.9.9-rc-3
43
              return width;
0d136465   梁灏   update Table
44
45
          }
      }
b0893113   jingsam   :art: add eslint
46
  };