Browse Source

(*)全部权限

master
zmh 1 year ago
parent
commit
3e7778d6c5
  1. 109
      web/client/src/sections/humanAffairs/containers/employeeAuth.jsx

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

@ -145,20 +145,46 @@ const EmployeeAuth = (props) => {
return { two, checkedList }; return { two, checkedList };
} }
const onChangeAll = (value) => { const onChangeAll = (value) => {
// if (value.target.checked) { if (value.target.checked) {
// setAllChecked(true); setAllChecked(true);
// let values = getValues(); let values = getValues();
// if (!Alltwo) if (!Alltwo)
// Alltwo = values.two; Alltwo = values.two;
// if (!AllCheckedList) if (!AllCheckedList)
// AllCheckedList = values.checkedList; AllCheckedList = values.checkedList;
// setTwo(values.two); setTwo(values.two);
// setCheckedList(values.checkedList); setCheckedList(values.checkedList);
// } else { } else {
// setAllChecked(false); setAllChecked(false);
// setTwo({}) setTwo({})
// setCheckedList([]); setCheckedList([]);
// } }
}
const getResourceIdAll = () => {
let resourceIdAll = [];
if (!Alltwo) {
const values = getValues();
resourceIdAll = Object.keys(values.two);
resourceIdAll = [...values.checkedList, ...resourceIdAll];
resourceIdAll = resourceIdAll.sort((a, b) => (a - b));
} else {
resourceIdAll = [...AllCheckedList, ...Alltwo];
resourceIdAll = resourceIdAll.sort((a, b) => (a - b));
}
return resourceIdAll;
}
const getResourceIds = (two, checkedList) => {
let resourceIds = [];
for (let item in two) {
if (two[item]) {
resourceIds.push(parseInt(item));
}
}
resourceIds = [...(new Set([...checkedList, ...resourceIds]))];
resourceIds = resourceIds.sort((a, b) => (a - b));
return resourceIds;
} }
const onChangeOne = (value, recod) => { const onChangeOne = (value, recod) => {
let twos = two let twos = two
@ -179,7 +205,15 @@ const EmployeeAuth = (props) => {
twos[value.target.value] = true twos[value.target.value] = true
setTwo(twos) setTwo(twos)
setCheckedList([...checkedList, ...selList]) setCheckedList([...checkedList, ...selList])
const resourceIdAll = getResourceIdAll();
const resourceIds = getResourceIds(twos, [...checkedList, ...selList])
if (resourceIds.toString() === resourceIdAll.toString()) {
setAllChecked(true);
} else {
setAllChecked(false);
}
} else { } else {
setAllChecked(false);
twos[value.target.value] = false twos[value.target.value] = false
setCheckedList(getDiffer(checkedList, selList)); setCheckedList(getDiffer(checkedList, selList));
setTwo(twos) setTwo(twos)
@ -202,7 +236,15 @@ const EmployeeAuth = (props) => {
twos[value.target.value] = true twos[value.target.value] = true
twos[recod.id] = true twos[recod.id] = true
setTwo(two) setTwo(two)
const resourceIdAll = getResourceIdAll();
const resourceIds = getResourceIds(two, [...checkedList, ...selList])
if (resourceIds.toString() === resourceIdAll.toString()) {
setAllChecked(true);
} else {
setAllChecked(false);
}
} else { } else {
setAllChecked(false);
setCheckedList(getDiffer(checkedList, selList)); setCheckedList(getDiffer(checkedList, selList));
twos[value.target.value] = false twos[value.target.value] = false
setTwo(two) setTwo(two)
@ -222,7 +264,15 @@ const EmployeeAuth = (props) => {
twos[twosid] = true twos[twosid] = true
twos[recod.id] = true twos[recod.id] = true
setTwo(twos) setTwo(twos)
const resourceIdAll = getResourceIdAll();
const resourceIds = getResourceIds(twos, [...checkedList, ...check])
if (resourceIds.toString() === resourceIdAll.toString()) {
setAllChecked(true);
} else {
setAllChecked(false);
}
} else { } else {
setAllChecked(false);
setCheckedList(getDiffer(checkedList, check)); setCheckedList(getDiffer(checkedList, check));
} }
} }
@ -265,28 +315,17 @@ 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]; const resourceIdAll = getResourceIdAll();
// resourceIds.sort(); const resourceIds = getResourceIds(two, checkList);
// if (resourceIds.toString() === resourceIdAll.toString()) { if (resourceIds.toString() === resourceIdAll.toString()) {
// setAllChecked(true); setAllChecked(true);
// } else { } else {
// setAllChecked(false); setAllChecked(false);
// } }
} else { } else {
// setAllChecked(false); setAllChecked(false);
setCheckedList([]) setCheckedList([])
setTwo(two) setTwo(two)
} }
@ -300,10 +339,12 @@ const EmployeeAuth = (props) => {
resourceId.push(parseInt(item)); resourceId.push(parseInt(item));
} }
} }
resourceId = [...resourceId] resourceId = [...checkedList, ...resourceId]
if (roleId == undefined || resourceId.length == 0) { if (roleId == undefined || resourceId.length == 0) {
Toast.error('请选择角色和权限!') Toast.error('请选择角色和权限!')
} else { } else {
resourceId = [...(new Set(resourceId))];
resourceId = resourceId.sort((a, b) => (a - b));
dispatch(actions.humanAffairs.addRoleResource({ roleId, resourceId, dataRange })) dispatch(actions.humanAffairs.addRoleResource({ roleId, resourceId, dataRange }))
} }
} }

Loading…
Cancel
Save