npm test
This commit is contained in:
parent
9d304dd635
commit
9d3aada306
1 changed files with 81 additions and 81 deletions
|
@ -347,35 +347,55 @@
|
||||||
},
|
},
|
||||||
handleResize () {
|
handleResize () {
|
||||||
//let tableWidth = parseInt(getStyle(this.$el, 'width')) - 1;
|
//let tableWidth = parseInt(getStyle(this.$el, 'width')) - 1;
|
||||||
let tableWidth = this.$el.offsetWidth - 1;
|
let tableWidth = this.$el.offsetWidth - 1;
|
||||||
let columnsWidth = {};
|
let columnsWidth = {};
|
||||||
|
|
||||||
let hasWidthColumns = [];
|
let hasWidthColumns = [];
|
||||||
let noWidthColumns = [];
|
let noWidthColumns = [];
|
||||||
let minWidthColumns = this.minWidthColumns;
|
let minWidthColumns = this.minWidthColumns;
|
||||||
let maxWidthColumns = this.maxWidthColumns;
|
let maxWidthColumns = this.maxWidthColumns;
|
||||||
this.cloneColumns.forEach((col) => {
|
this.cloneColumns.forEach((col) => {
|
||||||
if (col.width) {
|
if (col.width) {
|
||||||
hasWidthColumns.push(col);
|
hasWidthColumns.push(col);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
noWidthColumns.push(col);
|
||||||
|
}
|
||||||
|
col._width = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let unUsableWidth = hasWidthColumns.map(cell => cell.width).reduce((a, b) => a + b, 0);
|
||||||
|
let usableWidth = tableWidth - unUsableWidth - (this.showVerticalScrollBar?this.scrollBarWidth:0);
|
||||||
|
let usableLength = noWidthColumns.length;
|
||||||
|
let columnWidth = 0;
|
||||||
|
if(usableWidth > 0 && usableLength > 0){
|
||||||
|
columnWidth = parseInt(usableWidth / usableLength);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < maxWidthColumns.length; i++) {
|
||||||
|
if(columnWidth > maxWidthColumns[i].maxWidth){
|
||||||
|
maxWidthColumns[i]._width = maxWidthColumns[i].maxWidth;
|
||||||
|
usableWidth -= maxWidthColumns[i].maxWidth;
|
||||||
|
usableLength--;
|
||||||
|
if (usableWidth>0) {
|
||||||
|
if (usableLength === 0) {
|
||||||
|
columnWidth = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
columnWidth = parseInt(usableWidth / usableLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
noWidthColumns.push(col);
|
columnWidth = 0;
|
||||||
}
|
}
|
||||||
col._width = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
let unUsableWidth = hasWidthColumns.map(cell => cell.width).reduce((a, b) => a + b, 0);
|
|
||||||
let usableWidth = tableWidth - unUsableWidth - (this.showVerticalScrollBar?this.scrollBarWidth:0);
|
|
||||||
let usableLength = noWidthColumns.length;
|
|
||||||
let columnWidth = 0;
|
|
||||||
if(usableWidth > 0 && usableLength > 0){
|
|
||||||
columnWidth = parseInt(usableWidth / usableLength);
|
|
||||||
}
|
}
|
||||||
for (let i = 0; i < maxWidthColumns.length; i++) {
|
}
|
||||||
if(columnWidth > maxWidthColumns[i].maxWidth){
|
|
||||||
maxWidthColumns[i]._width = maxWidthColumns[i].maxWidth;
|
for (let i = 0; i < minWidthColumns.length; i++) {
|
||||||
usableWidth -= maxWidthColumns[i].maxWidth;
|
if(columnWidth < minWidthColumns[i].minWidth && !minWidthColumns[i].width){
|
||||||
|
if(!minWidthColumns[i]._width){
|
||||||
|
minWidthColumns[i]._width = minWidthColumns[i].minWidth;
|
||||||
|
usableWidth -= minWidthColumns[i].minWidth;
|
||||||
usableLength--;
|
usableLength--;
|
||||||
if (usableWidth>0) {
|
if (usableWidth>0) {
|
||||||
if (usableLength === 0) {
|
if (usableLength === 0) {
|
||||||
|
@ -389,75 +409,55 @@
|
||||||
columnWidth = 0;
|
columnWidth = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < minWidthColumns.length; i++) {
|
}
|
||||||
if(columnWidth < minWidthColumns[i].minWidth && !minWidthColumns[i].width){
|
}
|
||||||
if(!minWidthColumns[i]._width){
|
|
||||||
minWidthColumns[i]._width = minWidthColumns[i].minWidth;
|
|
||||||
usableWidth -= minWidthColumns[i].minWidth;
|
for (let i = 0; i < this.cloneColumns.length; i++) {
|
||||||
usableLength--;
|
const column = this.cloneColumns[i];
|
||||||
if (usableWidth>0) {
|
let width = columnWidth;
|
||||||
if (usableLength === 0) {
|
if(column.width){
|
||||||
columnWidth = 0;
|
width = column.width;
|
||||||
}
|
}
|
||||||
else {
|
else{
|
||||||
columnWidth = parseInt(usableWidth / usableLength);
|
if (column._width) {
|
||||||
}
|
width = column._width;
|
||||||
|
}
|
||||||
|
else if (column.minWidth > width){
|
||||||
|
width = column.minWidth;
|
||||||
|
}
|
||||||
|
else if (column.maxWidth < width){
|
||||||
|
width = column.maxWidth;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (usableWidth>0) {
|
||||||
|
if (usableLength > 1) {
|
||||||
|
usableLength--;
|
||||||
|
usableWidth -= width;
|
||||||
|
columnWidth = parseInt(usableWidth / usableLength);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
columnWidth = 0;
|
columnWidth = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
columnWidth = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.cloneColumns[i]._width = width;
|
||||||
|
|
||||||
for (let i = 0; i < this.cloneColumns.length; i++) {
|
columnsWidth[column._index] = {
|
||||||
const column = this.cloneColumns[i];
|
width: width
|
||||||
let width = columnWidth;
|
};
|
||||||
if(column.width){
|
|
||||||
width = column.width;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if (column._width) {
|
|
||||||
width = column._width;
|
|
||||||
}
|
|
||||||
else if (column.minWidth > width){
|
|
||||||
width = column.minWidth;
|
|
||||||
}
|
|
||||||
else if (column.maxWidth < width){
|
|
||||||
width = column.maxWidth;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (usableWidth>0) {
|
|
||||||
if (usableLength > 1) {
|
|
||||||
usableLength--;
|
|
||||||
usableWidth -= width;
|
|
||||||
columnWidth = parseInt(usableWidth / usableLength);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
columnWidth = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
columnWidth = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cloneColumns[i]._width = width;
|
}
|
||||||
|
|
||||||
columnsWidth[column._index] = {
|
|
||||||
width: width
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
//this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0);
|
//this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0);
|
||||||
this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0) + (this.showVerticalScrollBar?this.scrollBarWidth:0);
|
this.tableWidth = this.cloneColumns.map(cell => cell._width).reduce((a, b) => a + b, 0) + (this.showVerticalScrollBar?this.scrollBarWidth:0);
|
||||||
this.columnsWidth = columnsWidth;
|
this.columnsWidth = columnsWidth;
|
||||||
this.fixedHeader();
|
this.fixedHeader();
|
||||||
},
|
},
|
||||||
handleMouseIn (_index) {
|
handleMouseIn (_index) {
|
||||||
if (this.disabledHover) return;
|
if (this.disabledHover) return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue