<el-table ref="multipleTable" :key="newAppForm.applyType" border stripe :data="tableData" row-key="id" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" align="center" /> <el-table-column label="資產(chǎn)編碼" prop="eq_code" /> <el-table-column label="設(shè)備序列號" prop="serial_no" /> <el-table-column label="設(shè)備類型" prop="category" /> <el-table-column label="下發(fā)日期" prop="release_date" /> </el-table> el-table 使用 ref、row-key getSelfEquipment().then(res => {
this.tableData = res.data
}).finally(() => {
// 表格回顯
this.$nextTick(() => {
const id_list = this.multipleSelection.map(item => item.id)
const selected_rows = this.tableData.filter((item, index, array) => {
return id_list.indexOf(item.id) !== -1 // 勾選的行
})
this.$nextTick(() => {
selected_rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row)
})
})
})
})用 id 匹配已選中的行 參考鏈接:https://blog.csdn.net/lyxgoodLucky/article/details/139357489
|
|
|