|
|
@ -13,7 +13,7 @@ |
|
|
|
<div class="cursor-pointer d-flex align-center" @click="open"><a-icon class="mr-2" type="menu-fold" />全部展开</div> |
|
|
|
</div> |
|
|
|
<div class="d-flex align-center"> |
|
|
|
<a-input-search style="width: 260px" class="mr-4" placeholder="搜索部门/职位/角色" @change="onChange" /> |
|
|
|
<!-- <a-input-search style="width: 260px" class="mr-4" placeholder="搜索部门/职位/角色" @change="onChange" /> --> |
|
|
|
<a-button type="primary" icon="plus" @click="createDepartment">新建部门</a-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -71,17 +71,17 @@ |
|
|
|
</a-form-item> |
|
|
|
</a-form> |
|
|
|
</a-modal> |
|
|
|
<a-modal :visible="roleModal" title="修改关联角色" @cancel="roleModal = false" @ok="handleOk"> |
|
|
|
<a-modal :visible="roleModal" title="修改关联角色" @cancel="roleModal = false" @ok="changeRoleList"> |
|
|
|
<div> |
|
|
|
<h2>已选角色:</h2> |
|
|
|
<template v-if="changeRoleInfo.roleList"> |
|
|
|
<template v-if="chooseRoleList.length"> |
|
|
|
<a-tag |
|
|
|
class="my-2 mx-2" |
|
|
|
color="#2db7f5" |
|
|
|
closable |
|
|
|
v-for="tagItem in changeRoleInfo.roleList" |
|
|
|
:key="tagItem.rId" |
|
|
|
@close="chooseRole(tagItem.rid, 1, tagItem.rname)" |
|
|
|
v-for="tagItem in chooseRoleList" |
|
|
|
:key="tagItem.rid" |
|
|
|
@close="delRole(tagItem.rid)" |
|
|
|
> |
|
|
|
{{ tagItem.rname }} |
|
|
|
</a-tag> |
|
|
@ -89,8 +89,8 @@ |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<h2>可选角色:</h2> |
|
|
|
<template v-if="roleList.length"> |
|
|
|
<a-tag class="my-2 mx-2" v-for="tagItem in roleList" :key="tagItem.typeId" @click="chooseRole(tagItem.typeId, 0, tagItem.name)"> |
|
|
|
<template v-if="allRoleList.length"> |
|
|
|
<a-tag class="my-2 mx-2" v-for="tagItem in allRoleList" :key="tagItem.typeId" @click="chooseRole(tagItem.typeId)"> |
|
|
|
{{ tagItem.name }} |
|
|
|
</a-tag> |
|
|
|
</template> |
|
|
@ -169,6 +169,8 @@ export default { |
|
|
|
parentId: '', |
|
|
|
departmentId: '', |
|
|
|
positionName: '', |
|
|
|
chooseRoleList: [], |
|
|
|
allRoleList: [], |
|
|
|
}; |
|
|
|
}, |
|
|
|
computed: { ...mapState('home', ['hospitalInfo', 'level', 'area', 'roleList']) }, |
|
|
@ -181,32 +183,78 @@ export default { |
|
|
|
this.getHospitalInfo(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 添加关联角色 |
|
|
|
// type: 0(增加) 1(删除) |
|
|
|
async chooseRole(id, type, name) { |
|
|
|
try { |
|
|
|
let positionTypeIdList = []; |
|
|
|
let newRoleArr = []; |
|
|
|
for (let i = 0; i < this.changeRoleInfo.roleList.length; i++) { |
|
|
|
positionTypeIdList.push(this.changeRoleInfo.roleList[i].rid); |
|
|
|
// 点击添加角色 |
|
|
|
chooseRole(id) { |
|
|
|
const arr = [...this.allRoleList]; |
|
|
|
const arr1 = [...this.chooseRoleList]; |
|
|
|
for (let i = 0; i < arr.length; i++) { |
|
|
|
if (arr[i].typeId === id) { |
|
|
|
const obj = { |
|
|
|
rid: arr[i].typeId, |
|
|
|
rname: arr[i].name, |
|
|
|
}; |
|
|
|
arr1.push(obj); |
|
|
|
arr.splice(i, 1); |
|
|
|
} |
|
|
|
if (type === 0) { |
|
|
|
positionTypeIdList.push(id); |
|
|
|
} else if (type === 1) { |
|
|
|
positionTypeIdList = positionTypeIdList.filter(item => { |
|
|
|
return item !== id; |
|
|
|
}); |
|
|
|
} |
|
|
|
this.allRoleList = [...arr]; |
|
|
|
this.chooseRoleList = [...arr1]; |
|
|
|
}, |
|
|
|
// 点击删除角色 |
|
|
|
delRole(id) { |
|
|
|
const arr = [...this.chooseRoleList]; |
|
|
|
const arr1 = [...this.roleList]; |
|
|
|
let arr2 = [...this.allRoleList]; |
|
|
|
for (let i = 0; i < arr.length; i++) { |
|
|
|
if (arr[i].rid === id) { |
|
|
|
arr.splice(i, 1); |
|
|
|
} |
|
|
|
for (let i = 0; i < this.roleList.length; i++) { |
|
|
|
for (let j = 0; j < positionTypeIdList.length; j++) { |
|
|
|
if (this.roleList[i].typeId === positionTypeIdList[j]) { |
|
|
|
const obj = { |
|
|
|
rid: this.roleList[i].typeId, |
|
|
|
rname: this.roleList[i].name, |
|
|
|
}; |
|
|
|
newRoleArr.push(obj); |
|
|
|
} |
|
|
|
for (let i = 0; i < arr1.length; i++) { |
|
|
|
if (arr1[i].typeId === id) { |
|
|
|
arr2.push(arr1[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
this.chooseRoleList = [...arr]; |
|
|
|
this.allRoleList = [...arr2]; |
|
|
|
}, |
|
|
|
// 显示关联角色modal框 |
|
|
|
changeRole(item) { |
|
|
|
this.changeRoleInfo = item; |
|
|
|
this.chooseRoleList = item.roleList; |
|
|
|
this.getAllRole(); |
|
|
|
this.roleModal = true; |
|
|
|
}, |
|
|
|
// 获取当前所有的角色(不包含已选择的) |
|
|
|
getAllRole() { |
|
|
|
let newArr = []; |
|
|
|
const arr = [...this.roleList]; |
|
|
|
const arr1 = [...this.chooseRoleList]; |
|
|
|
for (let i = 0; i < arr.length; i++) { |
|
|
|
const item = arr[i]; |
|
|
|
if (arr1.length) { |
|
|
|
for (let j = 0; j < arr1.length; j++) { |
|
|
|
const role = arr1[j]; |
|
|
|
if (item.typeId === role.rid) { |
|
|
|
break; |
|
|
|
} else if (item.typeId !== role.rid && j === arr1.length - 1) { |
|
|
|
newArr.push(item); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
newArr = [...arr]; |
|
|
|
} |
|
|
|
} |
|
|
|
this.allRoleList = [...newArr]; |
|
|
|
}, |
|
|
|
// 修改关联角色 |
|
|
|
async changeRoleList() { |
|
|
|
try { |
|
|
|
let positionTypeIdList = []; |
|
|
|
if (this.chooseRoleList.length) { |
|
|
|
for (let i = 0; i < this.chooseRoleList.length; i++) { |
|
|
|
positionTypeIdList.push(this.chooseRoleList[i].rid); |
|
|
|
} |
|
|
|
} |
|
|
|
const params = { |
|
|
|
param: { |
|
|
@ -217,14 +265,15 @@ export default { |
|
|
|
const res = await bindPositionType(params); |
|
|
|
const { code, msg } = res.data; |
|
|
|
if (code === 200) { |
|
|
|
this.changeRoleInfo.roleList = [...newRoleArr]; |
|
|
|
this.$message.success('修改成功'); |
|
|
|
this.getHospitalInfo(); |
|
|
|
this.roleModal = false; |
|
|
|
} else { |
|
|
|
this.$message.warning('添加错误:', msg); |
|
|
|
this.$message.warning('修改错误:', msg); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
this.$message.warning('添加错误:', error); |
|
|
|
this.$message.warning('修改错误:', error); |
|
|
|
} |
|
|
|
console.log(id); |
|
|
|
}, |
|
|
|
// 显示修改部门的modal框 |
|
|
|
editDepartmentModal(item) { |
|
|
@ -236,7 +285,13 @@ export default { |
|
|
|
//修改部门信息 |
|
|
|
async editDepartment() { |
|
|
|
try { |
|
|
|
const params = { param: { did: this.departmentInfo.did, departmentName: this.departmentName } }; |
|
|
|
const params = { |
|
|
|
param: { |
|
|
|
did: this.departmentInfo.did, |
|
|
|
departmentName: this.departmentName, |
|
|
|
oid: this.hospitalInfo.id, |
|
|
|
}, |
|
|
|
}; |
|
|
|
const res = await updateDepartment(params); |
|
|
|
const { code, msg, data } = res.data; |
|
|
|
if (code === 200) { |
|
|
@ -252,15 +307,22 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 显示修改职位modal框 |
|
|
|
editPositionModal(item) { |
|
|
|
editPositionModal(item, did) { |
|
|
|
this.positionInfo = item; |
|
|
|
this.positionInfo.did = did; |
|
|
|
this.positionName = this.positionInfo.pname; |
|
|
|
this.positionModal = true; |
|
|
|
}, |
|
|
|
// 修改职位信息 |
|
|
|
async editPosition() { |
|
|
|
try { |
|
|
|
const params = { param: { positionId: this.positionInfo.pid, positionName: this.positionName } }; |
|
|
|
const params = { |
|
|
|
param: { |
|
|
|
positionId: this.positionInfo.pid, |
|
|
|
positionName: this.positionName, |
|
|
|
departmentId: this.positionInfo.did, |
|
|
|
}, |
|
|
|
}; |
|
|
|
const res = await updatePosition(params); |
|
|
|
const { code, msg, data } = res.data; |
|
|
|
if (code === 200) { |
|
|
@ -274,11 +336,6 @@ export default { |
|
|
|
this.$message.error(e); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 显示关联角色modal框 |
|
|
|
changeRole(item) { |
|
|
|
this.changeRoleInfo = item; |
|
|
|
this.roleModal = true; |
|
|
|
}, |
|
|
|
//新建职位/子部门 |
|
|
|
async addPosition() { |
|
|
|
if (this.addType === 'department') { |
|
|
|