From 315dceea12321685c44f7ca43d22fed1e51d4d09 Mon Sep 17 00:00:00 2001 From: wenlele Date: Thu, 19 Jan 2023 19:45:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/containers/authority.js | 260 +++++++++--------- 1 file changed, 130 insertions(+), 130 deletions(-) diff --git a/web/client/src/sections/organization/containers/authority.js b/web/client/src/sections/organization/containers/authority.js index ad46746..5ef2cdd 100644 --- a/web/client/src/sections/organization/containers/authority.js +++ b/web/client/src/sections/organization/containers/authority.js @@ -6,144 +6,144 @@ import { getResource, getUserResource, postUserRes } from '../actions/authority' import Resource from '../components/resource'; const Authority = (props) => { - const { dispatch, loading, depMessage, depUser, resource, userResource, clientHeight } = props - const [depSelectedKeys, setDepSelectedKeys] = useState([]) - const [userSelectedKeys, setUserSelectedKeys] = useState([]) - const [depSelected, setDepSelected] = useState() - const [userSelected, setUserSelected] = useState() - const [resCode, setResCode] = useState({}) - const [useName, setUseName] = useState()// 选中名字 - const [userType,setUserType]=useState() - console.log(resource) - useEffect(() => { - dispatch(getResource()) - if (!(depMessage && depMessage.length)) { - dispatch(getDepMessage()) - } + const { dispatch, loading, depMessage, depUser, resource, userResource, clientHeight } = props + const [depSelectedKeys, setDepSelectedKeys] = useState([]) + const [userSelectedKeys, setUserSelectedKeys] = useState([]) + const [depSelected, setDepSelected] = useState() + const [userSelected, setUserSelected] = useState() + const [resCode, setResCode] = useState({}) + const [useName, setUseName] = useState()// 选中名字 + const [userType, setUserType] = useState() + console.log(resource) + useEffect(() => { + dispatch(getResource()) + if (!(depMessage && depMessage.length)) { + dispatch(getDepMessage()) + } - }, []) - useEffect(() => { - if (depMessage.length) { - setDepSelectedKeys([depMessage[0].id]) - setDepSelected([depMessage[0].name]) - dispatch(getDepUser(depMessage[0].id)) - } + }, []) + useEffect(() => { + if (depMessage.length) { + setDepSelectedKeys([depMessage[0].id]) + setDepSelected([depMessage[0].name]) + dispatch(getDepUser(depMessage[0].id)) + } - }, [depMessage]) - useEffect(() => { - if (depUser.length) { - setUserSelectedKeys([depUser[0].id]) - setUserSelected(depUser[0].username) - dispatch(getUserResource(depUser[0].id)) - setUseName(depUser[0].name) - } - console.log(depUser, 'depUser') - }, [depUser]) + }, [depMessage]) + useEffect(() => { + if (depUser.length) { + setUserSelectedKeys([depUser[0].id]) + setUserSelected(depUser[0].username) + dispatch(getUserResource(depUser[0].id)) + setUseName(depUser[0].name) + } + console.log(depUser, 'depUser') + }, [depUser]) - const handleSave = () => { - dispatch(postUserRes({ userId: userSelectedKeys[0], resCode: resCode })).then(res => { - if (res.success) { - dispatch(getUserResource(userSelectedKeys[0])) - } - }) - } - return ( - - - - - { - depMessage.length ? - { - setUserType(selectedNodes[0].type) - if (selected) { - setDepSelectedKeys(selectedKeys) - setDepSelected(selectedNodes[0].name || "") - dispatch(getDepUser(selectedKeys[0])) - } + const handleSave = () => { + dispatch(postUserRes({ userId: userSelectedKeys[0], resCode: resCode })).then(res => { + if (res.success) { + dispatch(getUserResource(userSelectedKeys[0])) + } + }) + } + return ( + + + + + { + depMessage.length ? + { + setUserType(selectedNodes[0].type) + if (selected) { + setDepSelectedKeys(selectedKeys) + setDepSelected(selectedNodes[0].name || "") + dispatch(getDepUser(selectedKeys[0])) + } - }} - treeData={depMessage} - fieldNames={{ - title: 'name', - key: 'id', - children: 'subordinate' - }} - /> : '' - } - - - - - { - depUser.length ? - { - const name = node.name - setUseName(name) + }} + treeData={depMessage} + fieldNames={{ + title: 'name', + key: 'id', + children: 'subordinate' + }} + /> : '' + } + + + + + { + depUser.length ? + { + const name = node.name + setUseName(name) - if (selected) { - setUserSelectedKeys(selectedKeys) - setUserSelected(selectedNodes[0].username || '') - dispatch(getUserResource(selectedKeys[0])) - } + if (selected) { + setUserSelectedKeys(selectedKeys) + setUserSelected(selectedNodes[0].username || '') + dispatch(getUserResource(selectedKeys[0])) + } - }} - treeData={depUser} - fieldNames={{ - title: 'name', - key: 'id' - }} - /> : - } - - - - {depUser.length ? - - - - - - - - : - - - } - - - - ) + }} + treeData={depUser} + fieldNames={{ + title: 'name', + key: 'id' + }} + /> : + } + + + + {depUser.length ? + + + + + + + + : + + + } + + + + ) } -function mapStateToProps(state) { - const { userResource, resource, depMessage, depUser, global } = state; - return { - clientHeight: global.clientHeight, - loading: depMessage.isRequesting || depUser.isRequesting || resource.isRequesting, - userResource: userResource.data || [], - resource: resource.data || [], - depMessage: depMessage.data || [], - depUser: depUser.data || [] - }; +function mapStateToProps (state) { + const { userResource, resource, depMessage, depUser, global } = state; + return { + clientHeight: global.clientHeight, + loading: depMessage.isRequesting || depUser.isRequesting || resource.isRequesting, + userResource: userResource.data || [], + resource: resource.data || [], + depMessage: depMessage.data || [], + depUser: depUser.data || [] + }; } export default connect(mapStateToProps)(Authority); \ No newline at end of file