页面部门:
<el-table ref="SanTable" :data="threeLevelTaskList" border size="mini" @row-click="selectRowThree"
highlight-current-row :cell-style="cellStyle">
<el-table-column type="index" width="50" label="序号" />
<el-table-column prop="CTR_NO" label="箱号" width="120" show-overflow-tooltip></el-table-column>
</el-table>
逻辑JS部门:
// 设置箱号背景色
cellStyle({ row, column,columnIndex }) { //在表格赋值的地方调用这个方法就行
// console.log(row, "====",column,columnIndex);
let str1, str2, str3, str4 = ''
let tableColumn = false
if (columnIndex === 1 && column.label === '箱号') {
str1 = new Date(row.CTR_PCDATE).getTime();//派车时间
str2 = new Date(row.CTR_YTDATE).getTime();//提箱时间
str3 = new Date(row.CTR_TYDATE).getTime();//送达时间
str4 = new Date().getTime()
if (!str1 && !str2 && !str3) {
tableColumn = false
} else if (!str2 && Math.abs(str2 - str4) > (30 * 60 * 1000) ) {
tableColumn = true
}else if (!str1 && Math.abs(str1 - str4) > (30 * 60 * 1000)) {
tableColumn = true
} else {
tableColumn = false
}
}
return tableColumn ? {background: '#fb041b'} : {background: '#fff'}
},