element 根据某多个属性合并列



日常渲染


 


 

 


methods: {
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      // 没办法循环判断具体是那一列 所以就只好写了多个if
      if (column.property === "a1")
        return this.mergeAction("a1", rowIndex, column);
      if (column.property === "a2")
        return this.mergeAction("a2", rowIndex, column);
      if (column.property === "a7")
        return this.mergeAction("a7", rowIndex, column);
      if (column.property === "a8")
        return this.mergeAction("a8", rowIndex, column);
      if (column.property === "a9")
        return this.mergeAction("a9", rowIndex, column);
    },

    mergeAction(val, rowIndex, colData) {
      let _row = this.rowMergeArrs[val].rowArr[rowIndex];
      let _col = _row > 0 ? 1 : 0;
      return [_row, _col];
    },

    rowMergeHandle(arr, data) {
      if (!Array.isArray(arr) && !arr.length) return false;
      if (!Array.isArray(data) && !data.length) return false;
      let needMerge = {};
      arr.forEach(i => {
        needMerge[i] = {
          rowArr: [],
          rowMergeNum: 0
        };
        data.forEach((item, index) => {
          if (index === 0) {
            needMerge[i].rowArr.push(1);
            needMerge[i].rowMergeNum = 0;
          } else {
            if (item[i] === data[index - 1][i]) {
              needMerge[i].rowArr[needMerge[i].rowMergeNum] += 1;
              needMerge[i].rowArr.push(0);
            } else {
              needMerge[i].rowArr.push(1);
              needMerge[i].rowMergeNum = index;
            }
          }
        });
      });
      return needMerge;
    },
  },

 

 

posted @ 2019-07-26 16:01  啾啾啾啾一口  阅读(762)  评论(0编辑  收藏  举报