Browse Source

更换组织树api

feature
是小王呀\24601 1 year ago
parent
commit
75cbb38ded
  1. 59
      src/views/modules/base/organization/organization.vue

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

@ -611,7 +611,7 @@
v-model.trim="peoForm.manageScopes" v-model.trim="peoForm.manageScopes"
:options="orgOptions" :options="orgOptions"
:props="orgOptionProps" :props="orgOptionProps"
:show-all-levels="false" :show-all-levels="true"
clearable></el-cascader> clearable></el-cascader>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -1330,10 +1330,15 @@ export default {
orgOptionProps :{ orgOptionProps :{
multiple: true, multiple: true,
emitPath: true, emitPath: true,
value: 'agencyId', value: 'id',
label: 'agencyName', label: 'label',
children: 'subAgencyList', children: 'children',
checkStrictly: true checkStrictly: true,
lazy: true,
lazyLoad: (node, resolve) => {
this.loadOptions(node, resolve)
},
}, },
dialogVisiblePeoAgency:false,// dialogVisiblePeoAgency:false,//
peoFormAgency:{ peoFormAgency:{
@ -1401,12 +1406,11 @@ export default {
methods: { methods: {
getOrgTreeList () { getOrgTreeList () {
this.$http this.$http
.post('/gov/org/customeragency/agencygridtree', {}) .get('/actual/base/communityBuilding/tree/initTree', {})
.then(({ data: res }) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} else { } else {
console.log('获取组织树成功', res.data)
this.orgOptions = [] this.orgOptions = []
this.orgOptions.push(res.data) this.orgOptions.push(res.data)
} }
@ -1415,10 +1419,31 @@ export default {
return this.$message.error('网络错误') return this.$message.error('网络错误')
}) })
}, },
async loadOptions(node, resolve) {
let data1 =node.data;
if (data1.level == 'district') {
resolve(this.orgOptions);
} else {
if(data1.level !== "building"){
const url = "/actual/base/communityBuilding/tree/nextTreeNode";
let params = {
level:data1.level,
id:data1.id
};
const { data, code, msg } =await requestGet(url, params);
console.log(data);
data1.children=data
resolve(data);
console.log(resolve);
}else{
return resolve()
}
}
},
// id // id
handleChangeTransferCascader (e) { handleChangeTransferCascader (e) {
console.log("*********************");
function findItem (valueArr, coll) { function findItem (valueArr, coll) {
console.log("--------------------"); console.log("--------------------");
console.log(valueArr); console.log(valueArr);
@ -1663,7 +1688,6 @@ export default {
// level agencyId // level agencyId
this.extractLevelAndAgencyId(this.orgOptions[0], targetAgencyIds, result); this.extractLevelAndAgencyId(this.orgOptions[0], targetAgencyIds, result);
// Set
const manageScopeArray = Array.from(result); const manageScopeArray = Array.from(result);
const url = "/gov/org/staff/addstaffv2"; const url = "/gov/org/staff/addstaffv2";
const { const {
@ -1721,20 +1745,15 @@ export default {
}, },
// //
async updatePeoDo () { async updatePeoDo () {
const targetAgencyIds = this.peoForm.manageScopes.map(innerArray => innerArray[innerArray.length - 1]); const targetAgencyIds = this.peoForm.manageScopes.map(innerArray => innerArray[innerArray.length - 1]);
// Set // Set
const result = new Set(); const result = new Set();
console.log(this.orgOptions[0],targetAgencyIds,'11111112');
// level agencyId // level agencyId
this.extractLevelAndAgencyId(this.orgOptions[0], targetAgencyIds, result); this.extractLevelAndAgencyId(this.orgOptions[0], targetAgencyIds, result);
// Set // Set
const manageScopeArray = Array.from(result); const manageScopeArray = Array.from(result);
const url = "/gov/org/staff/editstaff"; const url = "/gov/org/staff/editstaff";
let params = { let params = {
staffId: this.userStaffId, staffId: this.userStaffId,
name: this.peoForm.name, name: this.peoForm.name,
@ -1768,12 +1787,14 @@ export default {
// JSON level agencyId // JSON level agencyId
extractLevelAndAgencyId(obj, agencyIds, result) { extractLevelAndAgencyId(obj, agencyIds, result) {
if (obj && typeof obj === 'object') { if (obj && typeof obj === 'object') {
if (obj.level && obj.agencyId && agencyIds.includes(obj.agencyId)) { console.log(obj,"1111");
result.add(`${obj.level}:${obj.agencyId}`); if (obj.level && obj.id && agencyIds.includes(obj.id)) {
result.add(`${obj.level}:${obj.id}`);
} }
if (Array.isArray(obj.subAgencyList)) { if (Array.isArray(obj.children)) {
obj.subAgencyList.forEach(subObj => { obj.children.forEach(subObj => {
this.extractLevelAndAgencyId(subObj, agencyIds, result); this.extractLevelAndAgencyId(subObj, agencyIds, result);
}); });
} }

Loading…
Cancel
Save