Browse Source

管理员权限修改

dev
wenlele 2 years ago
parent
commit
c8167edcd6
  1. 7
      api/app/lib/controllers/organization/index.js
  2. 7
      web/client/src/sections/install/containers/roles.jsx

7
api/app/lib/controllers/organization/index.js

@ -74,7 +74,7 @@ async function editUser (ctx) {
if (existUserRes) { if (existUserRes) {
// 存在且传递id 或者 不传id也存在 // 存在且传递id 或者 不传id也存在
// 修改 update // 修改 update
storageData.deleted = false
if ( if (
role.includes('admin') role.includes('admin')
) { ) {
@ -89,6 +89,8 @@ async function editUser (ctx) {
// 正在修改成员 但是此时还是管理员 // 正在修改成员 但是此时还是管理员
storageData.disabled = true storageData.disabled = true
storageData.role = [...role, 'admin'] storageData.role = [...role, 'admin']
}else{
storageData.deleted = false
} }
await models.User.update(storageData, { await models.User.update(storageData, {
where: { where: {
@ -165,6 +167,9 @@ async function delAdmin (ctx) {
let adminIndex = updateValues.role.findIndex(r => r == 'admin') let adminIndex = updateValues.role.findIndex(r => r == 'admin')
if (adminIndex > -1) { if (adminIndex > -1) {
updateValues.role.splice(adminIndex, 1) updateValues.role.splice(adminIndex, 1)
if (updateValues.role.length < 1) {
updateValues.deleted = true
}
} }
await models.User.update(updateValues, { await models.User.update(updateValues, {
where: { where: {

7
web/client/src/sections/install/containers/roles.jsx

@ -344,6 +344,8 @@ const Roles = (props) => {
const mylimits = useRef(); // const mylimits = useRef(); //
const [pepList, setPepList] = useState([])// const [pepList, setPepList] = useState([])//
const [pomsList, setPomsList] = useState([])// const [pomsList, setPomsList] = useState([])//
const userAdmin = user?.pomsUserInfo?.role.includes('admin') //
useEffect(() => { useEffect(() => {
getUserList(); getUserList();
}, [query, roleChoose]); }, [query, roleChoose]);
@ -367,6 +369,7 @@ const Roles = (props) => {
for (let i = 0; i < notCreatedNum; i++) { for (let i = 0; i < notCreatedNum; i++) {
notCreatedArr.push('') notCreatedArr.push('')
} }
if (userAdmin) notCreatedArr = []
setRoleAssignment(res.payload.data.admin.concat(notCreatedArr)) setRoleAssignment(res.payload.data.admin.concat(notCreatedArr))
setLimits(res.payload.data.users.count) setLimits(res.payload.data.users.count)
mylimits.current = res.payload.data.users.rows.length mylimits.current = res.payload.data.users.rows.length
@ -462,7 +465,7 @@ const Roles = (props) => {
) )
} }
<div style={{ marginLeft: 4, cursor: "pointer", }} onClick={() => { {userAdmin ? "" : <><div style={{ marginLeft: 4, cursor: "pointer", }} onClick={() => {
if (item.id) { if (item.id) {
setEditObj(item) setEditObj(item)
setAdminEdit(true) setAdminEdit(true)
@ -492,7 +495,7 @@ const Roles = (props) => {
</Popconfirm> </Popconfirm>
) : ('') ) : ('')
} }</>}
</div> </div>
<div style={{ fontSize: 12, color: '#969799', marginTop: 28, marginLeft: 50 }}>角色说明拥有全平台的权限</div> <div style={{ fontSize: 12, color: '#969799', marginTop: 28, marginLeft: 50 }}>角色说明拥有全平台的权限</div>

Loading…
Cancel
Save