el-table针对已有的数据进行默认选中
主页已有的数据,进入弹框时表格已是选中状态
弹框代码
<el-table v-loading="loadingC" :data="weldingCartypeList" height=100% size="mini"
@selection-change="handleSelectionChange"
:header-cell-style="{ fontSize: '14px', height: '48px', padding: '0px', background: 'white' }"
:row-style="{ height: 56 + 'px' }" ref="multipleTable">
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column label="车型" align="left" prop="itemKey" :show-overflow-tooltip="true" />
<el-table-column label="MOM值" align="left" prop="itemValue"
:show-overflow-tooltip="true" />
<el-table-column label="描述" align="left" prop="description"
:show-overflow-tooltip="true" />
<el-table-column label="自动线编码" align="left" prop="extend1"
:show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="left" prop="createTime"
:show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
</template>
</el-table-column>
</el-table>
js
//选择车型
//打开弹框的事件
carSelect() {
this.title1 = "选择车型"
this.carSelectDialog = true
this.$nextTick(() => {
this.weldingCartypeList.forEach(row => {
//后端返回已经有的数据
this.selectCartypeList.forEach(selected => {
if (selected.itemValue === row.itemValue) {
//表格选中状态
this.$refs.multipleTable.toggleRowSelection(row, true)
}
})
})
})
},