|
@@ -225,12 +225,24 @@ export default {
|
|
const newAddclick = async (id,type) => {
|
|
const newAddclick = async (id,type) => {
|
|
let reqApi = getRoleTree;//id?getTreeByRole+id:getRoleTree
|
|
let reqApi = getRoleTree;//id?getTreeByRole+id:getRoleTree
|
|
let treeRes = await axios.get(reqApi, {roleId:id});
|
|
let treeRes = await axios.get(reqApi, {roleId:id});
|
|
|
|
+ data.selectShow = null;
|
|
data.selectId = id
|
|
data.selectId = id
|
|
if(type != '新增'){
|
|
if(type != '新增'){
|
|
let res = await axios.get(detailRole+id, {roleId:id});
|
|
let res = await axios.get(detailRole+id, {roleId:id});
|
|
let { roleName,perm,deptName} = res.data
|
|
let { roleName,perm,deptName} = res.data
|
|
- data.radioData = perm
|
|
|
|
- data.checkedList = Object.keys(perm)
|
|
|
|
|
|
+ let radioData = {},checkedList=[],halfCheckedKeys=[]
|
|
|
|
+ perm.forEach(ele => {
|
|
|
|
+ if(ele.type == 'button'){
|
|
|
|
+ checkedList.push(ele.permissionId)
|
|
|
|
+ radioData[ele.permissionId] = ele.dataScope || '1'
|
|
|
|
+ }else{
|
|
|
|
+ halfCheckedKeys.push(ele.permissionId)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ console.log('halfCheckedKeys',halfCheckedKeys,perm);
|
|
|
|
+ data.radioData = radioData
|
|
|
|
+ data.checkedList = checkedList
|
|
|
|
+ data.halfCheckedKeys = halfCheckedKeys
|
|
data.newData = {
|
|
data.newData = {
|
|
...data.newData,
|
|
...data.newData,
|
|
roleName,
|
|
roleName,
|
|
@@ -255,6 +267,7 @@ export default {
|
|
selectId:'',
|
|
selectId:'',
|
|
operateType:'新增',
|
|
operateType:'新增',
|
|
deptIdList: [],
|
|
deptIdList: [],
|
|
|
|
+ halfCheckedKeys:[],
|
|
radio: 1,
|
|
radio: 1,
|
|
roleLevel:sessionStorage.getItem('roleLevel'),
|
|
roleLevel:sessionStorage.getItem('roleLevel'),
|
|
radioData: {},
|
|
radioData: {},
|
|
@@ -309,6 +322,7 @@ export default {
|
|
console.log(checked);
|
|
console.log(checked);
|
|
console.log(data);
|
|
console.log(data);
|
|
this.checkedList = checked.checkedKeys
|
|
this.checkedList = checked.checkedKeys
|
|
|
|
+ this.halfCheckedKeys = checked.halfCheckedKeys
|
|
let CurrentKey = this.$refs.tree.getCurrentKey();
|
|
let CurrentKey = this.$refs.tree.getCurrentKey();
|
|
if (
|
|
if (
|
|
checked.checkedKeys.includes(data.id) &&
|
|
checked.checkedKeys.includes(data.id) &&
|
|
@@ -359,18 +373,24 @@ export default {
|
|
}
|
|
}
|
|
let perm = {}
|
|
let perm = {}
|
|
this.checkedList.map(ele =>{
|
|
this.checkedList.map(ele =>{
|
|
- perm[ele] = 1
|
|
|
|
|
|
+ if(this.radioData[ele]){
|
|
|
|
+ perm[ele] = this.radioData[ele]
|
|
|
|
+ }else{
|
|
|
|
+ perm[ele] = 1
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
+ this.halfCheckedKeys.forEach(element => {
|
|
|
|
+ perm[element] = 1
|
|
|
|
+ });
|
|
|
|
+ console.log("newSubmit", this.halfCheckedKeys,perm);
|
|
let id = this.selectId
|
|
let id = this.selectId
|
|
let apiinfo = await axios.post(updateRole, { //新增修改角色
|
|
let apiinfo = await axios.post(updateRole, { //新增修改角色
|
|
"id": id || '',
|
|
"id": id || '',
|
|
"perm": {
|
|
"perm": {
|
|
...perm,
|
|
...perm,
|
|
- ...this.radioData,
|
|
|
|
},
|
|
},
|
|
"roleName": this.newData.roleName
|
|
"roleName": this.newData.roleName
|
|
});
|
|
});
|
|
- console.log("newSubmit", apiinfo);
|
|
|
|
this.$message({ message: apiinfo.msg || "成功", type: "success" });
|
|
this.$message({ message: apiinfo.msg || "成功", type: "success" });
|
|
// await this.$confirm('每个组织只能创建一个总管理员~', '新增用户')
|
|
// await this.$confirm('每个组织只能创建一个总管理员~', '新增用户')
|
|
this.newData = {};
|
|
this.newData = {};
|