el-table合並表格


 

獲取到的數據

 

 

獲取數據預先處理

    //獲取考核指標列表
    async getData() {
      if (this.dataObj) {
        const loading = sys_startLoading(this, 1);
        const res = await listAllItemAndQuotaSeting(this.dataObj.id);
        console.log(res.data);
        loading.close();
        let tableData = res.data;
        let newArr = [];
        let numAll = 0;
        for (let i = 0; i < tableData.length; i++) {
          for (let j = 0; j < tableData[i].quotaDetailDtos.length; j++) {
            newArr.push({
              ...tableData[i],
              newquotaObj: tableData[i].quotaDetailDtos[j],
              lengthNum: tableData[i].quotaDetailDtos.length,
              numAll,
            });
          }
          numAll = numAll + tableData[i].quotaDetailDtos.length;
        }
        console.log(newArr);
        this.tableData = newArr;
      }
    },

合並函數

   objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      let addIndex = 0;
      if (
        columnIndex === 0 ||
        columnIndex === 1 ||
        columnIndex === 2 ||
        columnIndex === 3
      ) {
        if (rowIndex == row.numAll) {
          return {
            rowspan: row.lengthNum,
            colspan: 1,
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
    },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM