vue table重新整理單行資料
阿新 • • 發佈:2022-12-10
1.給el-table加上標記方法
<el-table v-loading="loading" :data="tagList1" @selection-change="handleSelectionChange1" :row-class-name="tableRowClassName">
tableRowClassName({ row, rowIndex }) {
row.index = rowIndex;
},
2.提交資料到後臺,重新獲取此行資料
confirmBut(row, type, tabIndex){
let _this = this
let putParam = {"confirmId": row.confirmId, "type":type}
editConfirmInfo(putParam).then(res =>{
if(res.code == 200){
//更改單行資料
//重新去資料庫中獲取
this.msgSuccess("成功");
_this.changeLine(row, tabIndex)
}else{
this.msgError("失敗,重新整理頁面檢視事件是否已被確認!")
}
})
},
changeLine(row, tabIndex){
selectSmtTagAllById(row.id).then(response => {
if(tabIndex==1){
this.tagList1.splice(row.index,1,response.data)
}else if(tabIndex==2){
this.tagList2.splice(row.index,1,response.data)
}else if(tabIndex==3){
this.tagList3.splice(row.index,1,response.data)
}
});
},