elementUI checkbox problem (check question Edit) --- update (and by value, all the parent-child id in an array)
<el-form-item v-for="(it, id) in parentChildMap" :key="id" :label="it.name"> <el-checkbox-group v-model="it.checkList"> <el-checkbox :label="item.id" v-for="item in it.children" :key="item.id" :checked="item.checkedFlag">{{ item.name }}</el-checkbox> </el-checkbox-group> </el-form-item>
Data: idArrs: [] // set ID (rear pass)
checkList: [], // the value of the check box
event: submitForm(formName) { let arrs = []; let brr = []; this.parentChildMap.filter(item => { if (item.checkList.length != 0) { brr = JSON.parse(JSON.stringify(item.checkList)); brr.unshift(item.id); // console.log(brr, "5555"); item.ids = brr; arrs = [...arrs, ...item.ids]; } }); this.idArrs = arrs; // id when the set trigger click Submit console.log(arrs, "9999999999999"); this.$refs[formName].validate(valid => { if (valid) { this.editList(); this.handelRole(); this.$refs[formName].resetFields(); this.$router.go(-1); } The else { the this . Message.Error An $ ( " Please enter the complete " ); return to false ; } }); } getListRoleList() { // Get the current role permissions edit data const REQ = { roleId: parseInt(this.$route.query.id) }; roleList (REQ) .then (({Data}) => { // definition of the role of the current received data the let currentRolePermissionData = data.data; . roleManagementPermissionlist () the then (({Data}) => { the this .roleBaseedVal = data.data; // use the first set of filters and a parent subset separate the this .roleBaseedVal.filter (Item => { IF (item.menuType == . 1 ) { the this .parentVal.push (Item); } else if (item.menuType == 2) { this.childBtnVal.push(item); } }); // The equivalence relation parentId and id to identify the corresponding parent child the this .parentVal.filter (Item => { // define an empty array, after re-assignment is determined relationship item.children = []; // = item.parentSwitchFlag to false; the this .childBtnVal.filter (items => { // iterate the character data and the current definition of the selected and non-selected (plus a hidden attribute controls the display of all the buttons) items.checkedFlag = to false ; for (the let I = 0 ; I <currentRolePermissionData.length; I ++ ) { // the button data determines whether all the characters in the current id of the same, if the selected value is true IF (items.id == currentRolePermissionData [I] .id) { // this prevents cycles is true items.checkedFlag = true; break; } } if (item.id == items.parentId) { item.children.push(items); } }); }); // assigned to an empty array, the loop can be for the this .parentChildMap = the this .parentVal; the this .parentChildMap.map (itemFlag => { the this .checkedFlagChild = itemFlag.children.map (itemChildFlag => { return itemChildFlag.checkedFlag; }); }); this.parentChildMap.filter(item => { this.$set(item, "checkList", []); this.$set(item, "ids", []); }); }); }); }