el-table动态表格赋值任意单元格文本


  
  
 
rowClass ({row, column, rowIndex, columnIndex}) {
        if (this.subjectTwoConcatObjArr.length > 0) {
          for (let k = 0; k < this.subjectTwoConcatObjArr.length; k++) {
            if (this.subjectTwoConcatObjArr[k].customerName) {
              this.tableData[this.subjectTwoConcatObjArr[k].rowIndex][this.subjectTwoConcatObjArr[k].props] = this.subjectTwoConcatObjArr[k].customerName
// this.table[3].yyy = ‘动态赋值文本’    // 3为横坐标,yyy为后台对应纵坐标字段
            } else {
              this.tableData[this.subjectTwoConcatObjArr[k].rowIndex][this.subjectTwoConcatObjArr[k].props] = '+'
            }
            if (this.subjectTwoConcatObjArr[k].type === 2) {
              if (rowIndex === this.subjectTwoConcatObjArr[k].rowIndex && columnIndex === this.subjectTwoConcatObjArr[k].columnIndex) {
                return 'bacColorf4984e' // 科目二对应下面样式显示不同颜色
              }
            } else if (this.subjectTwoConcatObjArr[k].type === 3) {
              if (rowIndex === this.subjectTwoConcatObjArr[k].rowIndex && columnIndex === this.subjectTwoConcatObjArr[k].columnIndex) {
                return 'bacColor317eb0' // 科目三
              }
            } else if (this.subjectTwoConcatObjArr[k].type === 5) {
              if (rowIndex === this.subjectTwoConcatObjArr[k].rowIndex && columnIndex === this.subjectTwoConcatObjArr[k].columnIndex) {
                return 'rgb196'
              }
            }
          }
        }
      },
      cellClick (row, column, cell, event) {
        if (cell.className.indexOf('rgb196') !== -1 || cell.className.indexOf('bacColor317eb0') !== -1 || cell.className.indexOf('bacColorf4984e') !== -1) {
          this.customerNameArr = []
          let find = this.formList.find(item => item.prop === 'customerId')
          this.$set(find, 'optList', [])
          let carId = Number(column.property.split('f')[1])
          let coachId = Number(column.property.split('f')[2])
          let timeId = row.id
          let timeList = this.ajaxData['odts'].find(item => item.id === timeId)
          let filterList = this.ajaxData['cas'].find(item => item.carId === carId && item.coachId === coachId && item.beginTime === timeList.beginTime && item.endTime === timeList.endTime)
          this.tmpData.id = filterList.id
          this.tmpData.names = event.target.innerText
          if (cell.className.indexOf('rgb196') !== -1) {
            this.showDialog = 3
            this.tmpData.type = ''
            this.dialogOpen()
          } else if (cell.className.indexOf('bacColor317eb0') !== -1) { // 科三
            this.showDialog = 2
            this.tmpData.type = 3
            this.dialogOpen()
          } else if (cell.className.indexOf('bacColorf4984e') !== -1) { // 科目二
            this.showDialog = 1
            this.tmpData.type = 2
            this.dialogOpen()
          }
        }
      }
    
    
    }
  }


el-table动态表格赋值任意单元格文本_第1张图片

你可能感兴趣的:(element)