|
@@ -108,6 +108,10 @@ export default {
|
|
|
tableData:[],
|
|
|
spanArr: [], // 用于存放需要合并的行的个数
|
|
|
spanIndex: 0, // 记录spanArr数组的下标
|
|
|
+ spanArr2: [], // 用于存放需要合并的行的个数
|
|
|
+ spanIndex2: 0, // 记录spanArr数组的下标
|
|
|
+ spanArr3:[],
|
|
|
+ spanIndex:0,
|
|
|
map:{
|
|
|
input:"",
|
|
|
startTime:null,
|
|
@@ -189,6 +193,16 @@ export default {
|
|
|
sums[index] = '';
|
|
|
return;
|
|
|
}
|
|
|
+ if(index === 2){
|
|
|
+ let sum=new BigNumber(0);
|
|
|
+ data.forEach((row,rowIndex)=>{
|
|
|
+ if(rowIndex ==0 || row.gmId != data[rowIndex-1].gmId){
|
|
|
+ sum=sum.plus(row.gmTonnage);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ sums[index] = sum.toNumber();
|
|
|
+ return;
|
|
|
+ }
|
|
|
const values = data.map(item => Number(item[column.property]));
|
|
|
if (!values.every(value => isNaN(value))) {
|
|
|
sums[index] = values.reduce((prev, curr) => {
|
|
@@ -208,12 +222,18 @@ export default {
|
|
|
//处理数据,得到合并数组
|
|
|
getSpanArr(data) {
|
|
|
this.spanArr=[];
|
|
|
+ this.spanArr2=[];
|
|
|
+ this.spanArr3=[];
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
if (i == 0) {
|
|
|
this.spanArr.push(1);
|
|
|
+ this.spanArr2.push(1);
|
|
|
+ this.spanArr3.push(1);
|
|
|
this.spanIndex = 0;
|
|
|
+ this.spanIndex2 = 0;
|
|
|
+ this.spanIndex3 = 0;
|
|
|
} else {
|
|
|
- // 判断当前行与前一行内容是否相同
|
|
|
+ // 判断当前行与前一行内容是否相同:港口名
|
|
|
if (data[i].portName == data[i - 1].portName) {
|
|
|
this.spanArr[this.spanIndex] += 1; // 相同的话,当前下标所代表的值加一,例如:第一列的前三行可合并
|
|
|
this.spanArr.push(0);// 记录完毕后,再往数组里添加一个元素0,作为下一次合并的初始值
|
|
@@ -221,6 +241,22 @@ export default {
|
|
|
this.spanArr.push(1); // 否则,依旧是一行
|
|
|
this.spanIndex = i;
|
|
|
}
|
|
|
+ // 判断当前行与前一行内容是否相同:发货通知
|
|
|
+ if (data[i].productName == data[i - 1].productName) {
|
|
|
+ this.spanArr2[this.spanIndex2] += 1; // 相同的话,当前下标所代表的值加一,例如:第一列的前三行可合并
|
|
|
+ this.spanArr2.push(0);// 记录完毕后,再往数组里添加一个元素0,作为下一次合并的初始值
|
|
|
+ } else {
|
|
|
+ this.spanArr2.push(1); // 否则,依旧是一行
|
|
|
+ this.spanIndex2 = i;
|
|
|
+ }
|
|
|
+ // 判断当前行与前一行内容是否相同:港口库存
|
|
|
+ if (data[i].gmId == data[i - 1].gmId) {
|
|
|
+ this.spanArr3[this.spanIndex3] += 1; // 相同的话,当前下标所代表的值加一,例如:第一列的前三行可合并
|
|
|
+ this.spanArr3.push(0);// 记录完毕后,再往数组里添加一个元素0,作为下一次合并的初始值
|
|
|
+ } else {
|
|
|
+ this.spanArr3.push(1); // 否则,依旧是一行
|
|
|
+ this.spanIndex3 = i;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
console.log("spanArr",this.spanArr);
|
|
@@ -234,6 +270,20 @@ export default {
|
|
|
rowspan: _row,
|
|
|
colspan: _col
|
|
|
};
|
|
|
+ }else if(columnIndex === 1){
|
|
|
+ const _row = this.spanArr2[rowIndex]; // 行数
|
|
|
+ const _col = _row > 0 ? 1 : 0; // 列数
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col
|
|
|
+ };
|
|
|
+ }else if(columnIndex === 2){
|
|
|
+ const _row = this.spanArr3[rowIndex]; // 行数
|
|
|
+ const _col = _row > 0 ? 1 : 0; // 列数
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col
|
|
|
+ };
|
|
|
}
|
|
|
},
|
|
|
},
|