|
|
@ -10,7 +10,10 @@ const Authority = (props) => { |
|
|
|
const CheckboxGroup = Checkbox.Group; |
|
|
|
const { dispatch, loading, depMessage, depUser, resource, userResource, clientHeight, user } = props |
|
|
|
const r1 = ['USERMANAGE', 'AUTHORIMANAGE', 'OVERLOADMANAGE', 'ROADMANAGE', 'BRIDGEMANAGE', 'MAINTENANCEMANAGE', 'TRANSPORTATIONMANAGE', |
|
|
|
'CONSERVATIONMANAGE', 'PATROLMANAGE', 'PUBLICTRANSPORTMANAGE', 'FILEMANAGE', 'PUBLICITYVIDEO', 'FEEDBACKMANAGE', 'REPORTMANAGE'] |
|
|
|
'CONSERVATIONMANAGE', 'PATROLMANAGE', 'PUBLICTRANSPORTMANAGE', 'FILEMANAGE', 'PUBLICITYVIDEO', 'FEEDBACKMANAGE', 'REPORTMANAGE', |
|
|
|
'WXPATROLREPORT', 'WXMAINTENANCEREPORT', 'WXFEEDBACKMANAGE', 'WXBUILDINGROAD' |
|
|
|
] |
|
|
|
const [depUserCopy, setDepUserCopy] = useState([])//用于存放除了自己的管理的数组,即自己不能调整自己是否为管理员
|
|
|
|
const [depSelectedKeys, setDepSelectedKeys] = useState([]) |
|
|
|
const [userSelectedKeys, setUserSelectedKeys] = useState([]) |
|
|
|
const [depSelected, setDepSelected] = useState() |
|
|
@ -26,6 +29,7 @@ const Authority = (props) => { |
|
|
|
const [checkAll, setCheckAll] = useState(true); |
|
|
|
const [rescheckAll, setrescheckAll] = useState(false) |
|
|
|
const [isshow, setisshow] = useState(false); |
|
|
|
|
|
|
|
let plainOptions = depUser.map(i => ({ label: i.name, value: i.id })); |
|
|
|
const [checkedList, setCheckedList] = useState(depUser.map(i => i.id)); |
|
|
|
const onChange = (list) => { |
|
|
@ -79,24 +83,45 @@ const Authority = (props) => { |
|
|
|
useEffect(() => { |
|
|
|
if (depMessage.length) { |
|
|
|
console.log('depMessage', depMessage) |
|
|
|
setdepMessagedata(depMessage) |
|
|
|
setDepSelectedKeys([depMessage[0]?.id]) |
|
|
|
setDepSelected([depMessage[0]?.name]) |
|
|
|
dispatch(getDepUser(depMessage[0]?.id)) |
|
|
|
//超级管理员展示所有部门
|
|
|
|
if (user?.username === 'SuperAdmin') { |
|
|
|
setdepMessagedata(depMessage) |
|
|
|
dispatch(getDepUser(depMessage[0]?.id)) |
|
|
|
setDepSelectedKeys([depMessage[0]?.id]) |
|
|
|
setDepSelected([depMessage[0]?.name]) |
|
|
|
} else { |
|
|
|
//不是超级管理员,展示相应部门的数据
|
|
|
|
let authDep = [] |
|
|
|
depMessage.map((item) => { |
|
|
|
if (item.id === user?.departmentId) { |
|
|
|
authDep.push(item) |
|
|
|
} |
|
|
|
}) |
|
|
|
setdepMessagedata(authDep) |
|
|
|
if (authDep.length > 0) { |
|
|
|
dispatch(getDepUser(authDep[0]?.id)) |
|
|
|
setDepSelectedKeys([authDep[0]?.id]) |
|
|
|
setDepSelected([authDep[0]?.name]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, [depMessage]) |
|
|
|
useEffect(() => { |
|
|
|
if (depUser.length) { |
|
|
|
setUserSelectedKeys([depUser[0].id]) |
|
|
|
setUserSelected(depUser[0].username) |
|
|
|
dispatch(getUserResource(depUser[0].id)) |
|
|
|
setUseName(depUser[0].name) |
|
|
|
const copy = depUser.filter((item) => { |
|
|
|
return item.name !== user.name//把自己筛选出去
|
|
|
|
}) |
|
|
|
setDepUserCopy(copy) |
|
|
|
if (copy.length) { |
|
|
|
setUserSelectedKeys([copy[0].id]) |
|
|
|
setUserSelected(copy[0].username) |
|
|
|
dispatch(getUserResource(copy[0].id)) |
|
|
|
setUseName(copy[0].name) |
|
|
|
} |
|
|
|
setCheckedList(depUser.map(i => i.id)) |
|
|
|
|
|
|
|
|
|
|
|
setCheckedList(copy.map(i => i.id)) |
|
|
|
}, [depUser]) |
|
|
|
// console.log(depUser,'用户信息')
|
|
|
|
const handleSave = () => { |
|
|
@ -131,12 +156,12 @@ const Authority = (props) => { |
|
|
|
selectedKeys={depSelectedKeys} |
|
|
|
onSelect={(selectedKeys, { selected, selectedNodes, node }) => { |
|
|
|
setUserType(selectedNodes[0].type) |
|
|
|
setCheckedList(depUser.map(i => i.id)) |
|
|
|
setCheckedList(depUserCopy.map(i => i.id)) |
|
|
|
// setResCode(userResource.map(i=>i.resourceId))
|
|
|
|
|
|
|
|
|
|
|
|
if (selected) { |
|
|
|
setCheckedList(depUser.map(i => i.id)) |
|
|
|
setCheckedList(depUserCopy.map(i => i.id)) |
|
|
|
setDepSelectedKeys(selectedKeys) |
|
|
|
setDepSelected(selectedNodes[0].name || "") |
|
|
|
dispatch(getDepUser(selectedKeys[0])) |
|
|
@ -159,10 +184,10 @@ const Authority = (props) => { |
|
|
|
<Col span={4} style={{ height: '100%', }}> |
|
|
|
<Card title={` 用户列表`} bordered={false} bodyStyle={{ padding: 8, paddingTop: 24 }}> |
|
|
|
{ |
|
|
|
depUser.length ? |
|
|
|
depUserCopy?.length ? |
|
|
|
<Tree |
|
|
|
height={clientHeight - 100} |
|
|
|
defaultSelectedKeys={[depUser[0].id]} |
|
|
|
defaultSelectedKeys={[depUserCopy[0]?.id]} |
|
|
|
selectedKeys={userSelectedKeys} |
|
|
|
onSelect={(selectedKeys, { selected, selectedNodes, node, event }) => { |
|
|
|
const name = node.name |
|
|
@ -178,7 +203,7 @@ const Authority = (props) => { |
|
|
|
} |
|
|
|
|
|
|
|
}} |
|
|
|
treeData={depUser} |
|
|
|
treeData={depUserCopy} |
|
|
|
fieldNames={{ |
|
|
|
title: 'name', |
|
|
|
key: 'id' |
|
|
@ -200,7 +225,7 @@ const Authority = (props) => { |
|
|
|
<Checkbox onChange={onshowchange} checked={isshow} disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'AUTHORIMANAGE')[0]?.isshow === "true" ? true : ''}> |
|
|
|
不可编辑 |
|
|
|
</Checkbox> |
|
|
|
{depUser.length ? |
|
|
|
{depUserCopy?.length ? |
|
|
|
<Card title={` 功能范围`} bordered={false} bodyStyle={{ padding: 8, paddingTop: 24 }}> |
|
|
|
{/* <Resource |
|
|
|
userSelected={userSelected} |
|
|
|