Browse Source

组织架构-工作人员添加管理权限范围

V4.3.3
duanliangtao 1 year ago
parent
commit
e33e77b0eb
  1. 66
      src/views/modules/base/organization/organization.vue

66
src/views/modules/base/organization/organization.vue

@ -487,7 +487,7 @@
v-model="peoForm.manageScopes"
:options="orgOptions"
:props="orgOptionProps"
:show-all-levels="false"
:show-all-levels="true"
clearable></el-cascader>
</el-form-item>
</el-form>
@ -1328,7 +1328,8 @@ export default {
//
orgOptions: [],
orgOptionProps :{
multiple: false,
multiple: true,
emitPath: true,
value: 'agencyId',
label: 'agencyName',
children: 'subAgencyList',
@ -1710,6 +1711,18 @@ export default {
},
//
async updatePeoDo () {
const targetAgencyIds = this.peoForm.manageScopes.map(innerArray => innerArray[innerArray.length - 1]);
// Set
const result = new Set();
// level agencyId
this.extractLevelAndAgencyId(this.orgOptions[0], targetAgencyIds, result);
// Set
const manageScopeArray = Array.from(result);
const url = "/gov/org/staff/editstaff";
let params = {
@ -1723,7 +1736,7 @@ export default {
newRoles: this.peoForm.newRoles,
agencyId: this.currentAgencyId,
idCard: this.peoForm.idCard,
manageScopes:this.peoForm.manageScopes
manageScopes:manageScopeArray
};
const { data, code, msg } = await requestPost(url, params);
@ -1743,6 +1756,20 @@ export default {
}
},
// JSON level agencyId
extractLevelAndAgencyId(obj, agencyIds, result) {
if (obj && typeof obj === 'object') {
if (obj.level && obj.agencyId && agencyIds.includes(obj.agencyId)) {
result.add(`${obj.level}:${obj.agencyId}`);
}
if (Array.isArray(obj.subAgencyList)) {
obj.subAgencyList.forEach(subObj => {
this.extractLevelAndAgencyId(subObj, agencyIds, result);
});
}
}
},
//
async getDictionaries () {
const url = "/sys/dict/data/dictlist";
@ -2043,6 +2070,7 @@ export default {
},
//
async xiuGridPeo (row) {
console.log("修改网格人员");
this.modifyPeo = true;
this.peoForm.orgType = "grid";
@ -2085,6 +2113,7 @@ export default {
},
//
async xiuPeo (row) {
console.log("修改人员");
this.modifyPeo = true;
this.peoForm.orgType = "agency";
@ -2119,13 +2148,42 @@ export default {
}
});
this.peoForm.newRoles = existedRoleArr;
this.peoForm.manageScopes = data.manageScopes
var paths = this.findParentPath(this.orgOptions[0], data.manageScopes);
this.peoForm.manageScopes = paths;
} else {
this.$message.error(msg);
}
},
findParentPath(data,agencyIds) {
let paths = [];
function findPathRecursive(agencyId, node, path) {
if (node.agencyId === agencyId) {
path.push(agencyId);
paths.push(path.slice()); // Make a copy of the path array before pushing
return true;
}
if (node.subAgencyList) {
for (let i = 0; i < node.subAgencyList.length; i++) {
if (findPathRecursive(agencyId, node.subAgencyList[i], path.concat(node.agencyId))) {
return true;
}
}
}
return false;
}
agencyIds.forEach(agencyId => {
findPathRecursive(agencyId, data, []);
});
return paths;
},
//
async xiuCommunityPeo (row) {
console.log("修改社区人员");
this.modifyPeo = true;
this.peoForm.orgType = "dept";

Loading…
Cancel
Save