Browse Source

(*)数据范围取值

master
zmh 2 years ago
parent
commit
b7149174d0
  1. 71
      web/client/src/sections/humanAffairs/containers/employeeAuth.jsx

71
web/client/src/sections/humanAffairs/containers/employeeAuth.jsx

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

Loading…
Cancel
Save