<el-dropdown-item>
<el-checkbox
:ref="
(el) => {
if (el) {
oprRefs[index] = el;
}
}
"
@change="resetOprChecked(index, item)"
v-for="(item, index) in data.sysOperationList"
:key="item.id"
:label="item.title"
size="small"
/>
</el-dropdown-item>
const oprRefs = <any>ref([]);
// 确保在每次更新之前重置ref
onBeforeUpdate(() => {
oprRefs.value = [];
});
//设置选中的操作id列表
const resetOprChecked = (index: any, item: any) => {
//如果选中,若没有id则增加id
const isInList = roleForm.operationIdList.indexOf(item.id);
if (oprRefs.value[index].isChecked && isInList == -1) {
roleForm.operationIdList.push(item.id);
//如果非选中,若有则删除id
} else if (!oprRefs.value[index].isChecked && isInList != -1) {
roleForm.operationIdList.splice(isInList, 1);
}
console.log('roleForm.operationIdList...', roleForm.operationIdList);
};