fixed-head

This commit is contained in:
梁灏 2018-03-23 17:35:19 +08:00
parent 3f14387d1a
commit c1e965c371
4 changed files with 37 additions and 27 deletions

View file

@ -1,5 +1,20 @@
import { deepCopy } from '../../utils/assist';
const convertColumnOrder = (columns, fixedType) => {
let list = [];
let other = [];
columns.forEach((col) => {
if (col.fixed && col.fixed === fixedType) {
list.push(col);
} else {
other.push(col);
}
});
return list.concat(other);
};
export {convertColumnOrder};
// set forTableHead to true when convertToRows, false in normal cases like table.vue
const getAllColumns = (cols, forTableHead = false) => {
const columns = deepCopy(cols);
@ -17,8 +32,8 @@ const getAllColumns = (cols, forTableHead = false) => {
export {getAllColumns};
const convertToRows = (columns) => {
const originColumns = deepCopy(columns);
const convertToRows = (columns, fixedType = false) => {
const originColumns = fixedType ? fixedType === 'left' ? deepCopy(convertColumnOrder(columns, 'left')) : deepCopy(convertColumnOrder(columns, 'right')) : deepCopy(columns);
let maxLevel = 1;
const traverse = (column, parent) => {
if (parent) {
@ -63,19 +78,4 @@ const convertToRows = (columns) => {
return rows;
};
export {convertToRows};
const convertColumnOrder = (columns, FixedType) => {
let list = [];
let other = [];
columns.forEach((col) => {
if (col.fixed && col.fixed === FixedType) {
list.push(col);
} else {
other.push(col);
}
});
return list.concat(other);
};
export {convertColumnOrder};
export {convertToRows};