瀏覽代碼

修改

master
yangzhou-cyber 3 年之前
父節點
當前提交
8b93c36c4c
共有 1 個檔案被更改,包括 53 行新增0 行删除
  1. +53
    -0
      src/utils/mixin.js

+ 53
- 0
src/utils/mixin.js 查看文件

@@ -250,4 +250,57 @@ export let categoryName = {

}
},
}

export function mergeSpan(params) {
return {
methods: {
reduceData(data) {
let arr = data;
let prev = new Array(params.length).fill(undefined);
try {
return arr.map((item, index) => {
params.forEach((param, ind) => {
if (item[param.name].trim() != prev[ind]) {
let num = ind;
while (num--) {
if (prev[num] !== undefined && item[params[num].name].trim() !== prev[num]) {
break;
}
}
if (num < 0) {
prev[ind] = item[param.name]
let spans = [];
for (let i = 0; i <= ind; i++) {
spans.push(params[i].name)
}
item[param.name + 'Row'] = getNumber(item, index, arr, spans)
}
}
})
return item;
})
} catch (e) {
console.log(e)
}
},
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
for (let param of params) {
if (param.col.includes(columnIndex)) {
if (row[param.name + 'Row']) {
return {
rowspan: row[param.name + "Row"],
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 1
}
}
}
}
},
}
}
}

Loading…
取消
儲存