|
|
@ -16,6 +16,9 @@ const EmployeeAuth = (props) => { |
|
|
|
const [eidtRole, setEidtRole] = useState(null); |
|
|
|
const [eidtTit, setEidtTit] = useState(null); |
|
|
|
const [visibleUser, setVisibleUser] = useState(false); |
|
|
|
const [allChecked, setAllChecked] = useState(false); |
|
|
|
let Alltwo = null; |
|
|
|
let AllCheckedList = null; |
|
|
|
const getRoleList = () => { |
|
|
|
dispatch(actions.humanAffairs.getRoleList()) |
|
|
|
dispatch(actions.humanAffairs.getUserRoleList()) |
|
|
@ -117,6 +120,46 @@ const EmployeeAuth = (props) => { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
const getValues = () => { |
|
|
|
let two = {} |
|
|
|
let checkedList = []; |
|
|
|
treeList.map(r => { |
|
|
|
if (r.child && r.child.length) { |
|
|
|
two[r.id] = true; |
|
|
|
r.child.map(c => { |
|
|
|
if (c.child && c.child.length) { |
|
|
|
two[c.id] = true; |
|
|
|
c.child.map(cc => { |
|
|
|
if (cc.child && cc.child.length) { |
|
|
|
two[cc.id] = true; |
|
|
|
} else { |
|
|
|
checkedList.push(cc.id) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
two[c.id] = true; |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
return { two, checkedList }; |
|
|
|
} |
|
|
|
const onChangeAll = (value) => { |
|
|
|
// if (value.target.checked) { |
|
|
|
// setAllChecked(true); |
|
|
|
// let values = getValues(); |
|
|
|
// if (!Alltwo) |
|
|
|
// Alltwo = values.two; |
|
|
|
// if (!AllCheckedList) |
|
|
|
// AllCheckedList = values.checkedList; |
|
|
|
// setTwo(values.two); |
|
|
|
// setCheckedList(values.checkedList); |
|
|
|
// } else { |
|
|
|
// setAllChecked(false); |
|
|
|
// setTwo({}) |
|
|
|
// setCheckedList([]); |
|
|
|
// } |
|
|
|
} |
|
|
|
const onChangeOne = (value, recod) => { |
|
|
|
let twos = two |
|
|
|
let selList = [] |
|
|
@ -222,13 +265,31 @@ const EmployeeAuth = (props) => { |
|
|
|
two[e.resId] = true |
|
|
|
return e.resId |
|
|
|
}) |
|
|
|
// let resourceIdAll = []; |
|
|
|
// if (!Alltwo) { |
|
|
|
// const values = getValues(); |
|
|
|
// resourceIdAll = Object.values(values.two); |
|
|
|
// resourceIdAll = [...values.checkedList, ...resourceIdAll]; |
|
|
|
// resourceIdAll.sort(); |
|
|
|
// } else { |
|
|
|
// resourceIdAll = [...AllCheckedList, ...Alltwo]; |
|
|
|
// resourceIdAll.sort(); |
|
|
|
// } |
|
|
|
// let resourceIds = [] |
|
|
|
setCheckedList(checkList) |
|
|
|
setTwo(two) |
|
|
|
// resourceIdAll = [...checkList, ...two]; |
|
|
|
// resourceIds.sort(); |
|
|
|
// if (resourceIds.toString() === resourceIdAll.toString()) { |
|
|
|
// setAllChecked(true); |
|
|
|
// } else { |
|
|
|
// setAllChecked(false); |
|
|
|
// } |
|
|
|
} else { |
|
|
|
// setAllChecked(false); |
|
|
|
setCheckedList([]) |
|
|
|
setTwo(two) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
@ -243,7 +304,7 @@ const EmployeeAuth = (props) => { |
|
|
|
if (roleId == undefined || resourceId.length == 0) { |
|
|
|
Toast.error('请选择角色和权限!') |
|
|
|
} else { |
|
|
|
dispatch(actions.humanAffairs.addRoleResource({ roleId, resourceId })) |
|
|
|
dispatch(actions.humanAffairs.addRoleResource({ roleId, resourceId, dataRange })) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -303,13 +364,13 @@ const EmployeeAuth = (props) => { |
|
|
|
<div className='dataRange'> |
|
|
|
<h2>数据范围:</h2> |
|
|
|
<RadioGroup onChange={dataRangeChange} value={dataRange} style={{ float: 'left', marginTop: 17, }}> |
|
|
|
<Radio value={1}>本部门</Radio> |
|
|
|
<Radio value={2}>全公司</Radio> |
|
|
|
<Radio value={2}>本部门</Radio> |
|
|
|
<Radio value={1}>全公司</Radio> |
|
|
|
</RadioGroup> |
|
|
|
</div> |
|
|
|
<div className='dataRange'> |
|
|
|
<h2>权限范围:</h2> |
|
|
|
<Checkbox style={{ float: 'left', marginTop: 17, }} >全部权限</Checkbox> |
|
|
|
<Checkbox style={{ float: 'left', marginTop: 17, }} checked={allChecked} onChange={(value) => { onChangeAll(value) }}>全部权限</Checkbox> |
|
|
|
</div> |
|
|
|
{treeList.map(e => { |
|
|
|
return <div className='codeList'> |
|
|
|