作用域和重新赋值的问题。
// 修改
doEdit(item) {
this.checkedOne = this.checkedOne == false ? this.checkedOne : false;
this.checkedTwo = false;
this.checkedThree = true;
this.form = {
name: item.name,
code: item.code,
description: item.description,
type: item.type,
state: item.state,
menuIds: [],
};
getroleeditApi(item.id).then((data) => {
this.form.menuIds = data.data;
data.data.forEach((item) => {
// 在每一次循环之前都清空一次数据
this.getEditId = [];
this.getId(item);
});
this.$refs.attrList.setCheckedKeys(this.getEditId);
});
this.dialogInfo.isShow = true;
this.dialogInfo.isAdd = false;
this.form.type = this.form.type == "0" ? "功能" : "数据";
},
getId(dto) {
if (dto.selected === true) {
this.getEditId.push(dto.id);
}
if (dto.children != null) {
dto.children.forEach((item) => {
this.getId(item);
});
}
},