Commit 2550bf0c authored by 皮倩雯's avatar 皮倩雯

修改代码格式

parent 84757bdc
Pipeline #41539 skipped with stages
...@@ -30,11 +30,8 @@ const ChangeAdd = props => { ...@@ -30,11 +30,8 @@ const ChangeAdd = props => {
filed11, filed11,
newCheckedList, newCheckedList,
} = props; } = props;
const [value, setValue] = useState('');
const [checkValue, setCheckValue] = useState([]);
const [title, setTitle] = useState([]); const [title, setTitle] = useState([]);
const [checkedList, setCheckedList] = useState([]); // 选中复选框内容 const [checkedList, setCheckedList] = useState([]); // 选中复选框内容
const [flagg, setFlagg] = useState(0);
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
const { Search } = Input; const { Search } = Input;
const [total, setTotal] = useState(); const [total, setTotal] = useState();
...@@ -46,13 +43,9 @@ const ChangeAdd = props => { ...@@ -46,13 +43,9 @@ const ChangeAdd = props => {
const [checkDataSite, setCheckDataSite] = useState([]); const [checkDataSite, setCheckDataSite] = useState([]);
const [filed1, setFiled1] = useState([]); // 角色全部数据 const [filed1, setFiled1] = useState([]); // 角色全部数据
const [saveCheckValue, setSaveCheckValue] = useState([]); // 保存选中值 const [saveCheckValue, setSaveCheckValue] = useState([]); // 保存选中值
const [isCheck, setIsCheck] = useState(0); // 是否点击了角色复选框下的 const [keepOption1, setKeepOption1] = useState([]); // 保存了首次获取的部门列表数据
const [isCheck1, setIsCheck1] = useState(0); // 是否点击了部门复选框下的 const [keepOption2, setKeepOption2] = useState([]); // 保存了首次获取的站点列表数据
const [isCheck2, setIsCheck2] = useState(0); // 是否点击了站点复选框下的 const [keepTabKey, setKeepTabKey] = useState(0); // 保存tabs的key
const [keepOption1, setKeepOption1] = useState([]); // 保存了获取的部门列表数据
const [keepOption2, setKeepOption2] = useState([]); // 保存了获取的站点列表数据
const [keepTabKey, setKeepTabKey] = useState(0);
const [searchFlag, setSearchFlag] = useState(0);
const [list, setList] = useState([]); const [list, setList] = useState([]);
const [listPm, setListPm] = useState([]); const [listPm, setListPm] = useState([]);
const [listSite, setListSite] = useState([]); const [listSite, setListSite] = useState([]);
...@@ -68,10 +61,8 @@ const ChangeAdd = props => { ...@@ -68,10 +61,8 @@ const ChangeAdd = props => {
data.push(checkItem); data.push(checkItem);
} }
}); });
console.log(data);
saveCheckValue[1] = data; saveCheckValue[1] = data;
} }
console.log(saveCheckValue);
// 没有勾选站点下的选项 // 没有勾选站点下的选项
if (saveCheckValue[2] == undefined) { if (saveCheckValue[2] == undefined) {
let data = []; let data = [];
...@@ -80,22 +71,13 @@ const ChangeAdd = props => { ...@@ -80,22 +71,13 @@ const ChangeAdd = props => {
data.push(checkItem); data.push(checkItem);
} }
}); });
console.log(data);
saveCheckValue[2] = data; saveCheckValue[2] = data;
} }
console.log(newCheckedList);
console.log(saveCheckValue);
let data = []; let data = [];
saveCheckValue.map((item, index) => { saveCheckValue.map((item, index) => {
data = data.concat(item); data = data.concat(item);
}); });
isType === 'rule' callBackSubmit({
? callBackSubmit(
`${
value === '无' || value === '' ? '' : `${value},`
}${checkValue.join(',')}`,
)
: callBackSubmit({
saveCheckValue, saveCheckValue,
str: data.join(','), str: data.join(','),
pickItem, pickItem,
...@@ -104,9 +86,6 @@ const ChangeAdd = props => { ...@@ -104,9 +86,6 @@ const ChangeAdd = props => {
filed22: filed1, filed22: filed1,
isType, isType,
}); });
setIsCheck(0);
setIsCheck1(0);
setIsCheck2(0);
setKeyValue('0'); setKeyValue('0');
setSearchWord(''); setSearchWord('');
}; };
...@@ -116,20 +95,17 @@ const ChangeAdd = props => { ...@@ -116,20 +95,17 @@ const ChangeAdd = props => {
setKeepOption2(filed11['站点']); setKeepOption2(filed11['站点']);
getRoles('角色', '', pageSize, 1); getRoles('角色', '', pageSize, 1);
setRoleValue(filed1); setRoleValue(filed1);
setFlagg(1);
let arr = Object.keys(filed1); let arr = Object.keys(filed1);
setTitle(arr); setTitle(arr);
let checkArr = []; let checkArr = [];
console.log(newCheckedList); // 已选中数组
let listdata = []; let listdata = [];
newCheckedList.map(checkItem => { newCheckedList.map(checkItem => {
if (filed11['角色'].includes(checkItem)) { if (filed11['角色'].includes(checkItem)) {
listdata.push(checkItem); listdata.push(checkItem);
} }
}); });
setCheckDataRole(listdata); setCheckDataRole(listdata); // 用于设置首次展示已选列表角色数据
checkArr[0] = listdata; checkArr[0] = listdata;
console.log(listdata); // 按对象数组格式
setSaveCheckValue(checkArr); setSaveCheckValue(checkArr);
setCheckedList(checkArr); setCheckedList(checkArr);
let pmdata = []; let pmdata = [];
...@@ -138,7 +114,6 @@ const ChangeAdd = props => { ...@@ -138,7 +114,6 @@ const ChangeAdd = props => {
pmdata.push(checkItem); pmdata.push(checkItem);
} }
}); });
console.log(pmdata);
setCheckDataPm(pmdata); setCheckDataPm(pmdata);
let sitedata = []; let sitedata = [];
newCheckedList.map(checkItem => { newCheckedList.map(checkItem => {
...@@ -146,15 +121,10 @@ const ChangeAdd = props => { ...@@ -146,15 +121,10 @@ const ChangeAdd = props => {
sitedata.push(checkItem); sitedata.push(checkItem);
} }
}); });
console.log(sitedata);
setCheckDataSite(sitedata); setCheckDataSite(sitedata);
}, [visible]); }, [visible]);
const submitSearchUser = () => { const submitSearchUser = () => {
if (searchWord != '') {
setSearchFlag(1);
}
if (keepTabKey == 0) { if (keepTabKey == 0) {
sreachRoles('角色', searchWord, pageSize, 1); sreachRoles('角色', searchWord, pageSize, 1);
} }
...@@ -168,9 +138,6 @@ const ChangeAdd = props => { ...@@ -168,9 +138,6 @@ const ChangeAdd = props => {
// 获取搜索框的值 // 获取搜索框的值
const handleSearch = e => { const handleSearch = e => {
if (e.target.value == '') {
setSearchFlag(0);
}
setSearchWord(e.target.value); setSearchWord(e.target.value);
}; };
...@@ -199,7 +166,6 @@ const ChangeAdd = props => { ...@@ -199,7 +166,6 @@ const ChangeAdd = props => {
if (res.msg === 'Ok') { if (res.msg === 'Ok') {
setRoleValue(formateArrDataA1(res.data, 'groupType')); setRoleValue(formateArrDataA1(res.data, 'groupType'));
setFiled1(formateArrDataA1(res.data, 'groupType')); setFiled1(formateArrDataA1(res.data, 'groupType'));
console.log(res.data.count);
setCurrentPage(1); setCurrentPage(1);
setTotal(res.data.count); setTotal(res.data.count);
if (res.data.count == 0) { if (res.data.count == 0) {
...@@ -213,7 +179,6 @@ const ChangeAdd = props => { ...@@ -213,7 +179,6 @@ const ChangeAdd = props => {
// 重置 // 重置
const onReset = () => { const onReset = () => {
setSearchFlag(0);
// setListPm([]); // setListPm([]);
if (keepTabKey == 0) { if (keepTabKey == 0) {
getRoles('角色', '', pageSize, 1); getRoles('角色', '', pageSize, 1);
...@@ -229,7 +194,6 @@ const ChangeAdd = props => { ...@@ -229,7 +194,6 @@ const ChangeAdd = props => {
}; };
const getRoles = (type, keywords, pageSizes, pageIndex) => { const getRoles = (type, keywords, pageSizes, pageIndex) => {
console.log(type);
CM_Event_LoadDepartmentAndRoles({ CM_Event_LoadDepartmentAndRoles({
type, type,
keywords, keywords,
...@@ -238,7 +202,6 @@ const ChangeAdd = props => { ...@@ -238,7 +202,6 @@ const ChangeAdd = props => {
}).then(res => { }).then(res => {
if (res.msg === 'Ok') { if (res.msg === 'Ok') {
setTotal(res.data.count); setTotal(res.data.count);
console.log(formateArrDataA1(res.data, 'groupType'));
setRoleValue(formateArrDataA1(res.data, 'groupType')); setRoleValue(formateArrDataA1(res.data, 'groupType'));
setFiled1(formateArrDataA1(res.data, 'groupType')); setFiled1(formateArrDataA1(res.data, 'groupType'));
if (res.data.count == 0) { if (res.data.count == 0) {
...@@ -249,13 +212,11 @@ const ChangeAdd = props => { ...@@ -249,13 +212,11 @@ const ChangeAdd = props => {
} }
}); });
}; };
// 页面数据改变重新赋值
useEffect(() => { useEffect(() => {
let arr = Object.keys(filed1); let arr = Object.keys(filed1);
setTitle(arr); setTitle(arr);
let checkArr = []; let checkArr = [];
console.log(saveCheckValue);
console.log(newCheckedList); // 已选中数组
let data = []; let data = [];
saveCheckValue.map((item, index) => { saveCheckValue.map((item, index) => {
data = data.concat(item); data = data.concat(item);
...@@ -268,10 +229,7 @@ const ChangeAdd = props => { ...@@ -268,10 +229,7 @@ const ChangeAdd = props => {
checkArr[0].push(checkItem); checkArr[0].push(checkItem);
} }
}); });
// setCheckDataRole(checkArr[0]); setCheckedList(checkArr); // 按对象数组格式
console.log(arr);
console.log(checkArr); // 按对象数组格式
setCheckedList(checkArr);
} else if (item == '部门') { } else if (item == '部门') {
checkArr[1] = []; checkArr[1] = [];
checkDataPm.map(checkItem => { checkDataPm.map(checkItem => {
...@@ -279,19 +237,14 @@ const ChangeAdd = props => { ...@@ -279,19 +237,14 @@ const ChangeAdd = props => {
checkArr[1].push(checkItem); checkArr[1].push(checkItem);
} }
}); });
// setCheckDataPm(checkArr[1]);
console.log(checkArr); // 按对象数组格式
setCheckedList(checkArr); setCheckedList(checkArr);
} else if (item == '站点') { } else if (item == '站点') {
checkArr[2] = []; checkArr[2] = [];
console.log(checkDataSite);
checkDataSite.map(checkItem => { checkDataSite.map(checkItem => {
if (filed1['站点'].includes(checkItem)) { if (filed1['站点'].includes(checkItem)) {
checkArr[2].push(checkItem); checkArr[2].push(checkItem);
} }
}); });
// setCheckDataSite(checkArr[2]);
console.log(checkArr); // 按对象数组格式
setCheckedList(checkArr); setCheckedList(checkArr);
} }
}); });
...@@ -358,16 +311,14 @@ const ChangeAdd = props => { ...@@ -358,16 +311,14 @@ const ChangeAdd = props => {
useEffect(() => { useEffect(() => {
let checkedListArr = [...saveCheckValue]; let checkedListArr = [...saveCheckValue];
setIsCheck(1);
let data = checkDataRole; let data = checkDataRole;
let DataValue = []; let DataValue = [];
console.log(roleValue); // 拿到当前页数据
checkDataRole.forEach(item => { checkDataRole.forEach(item => {
if (roleValue['角色'].indexOf(item) != -1) { if (roleValue['角色'].indexOf(item) != -1) {
DataValue.push(item); DataValue.push(item);
} }
}); });
console.log(DataValue);
// del // del
if (DataValue.length > list.length) { if (DataValue.length > list.length) {
DataValue.forEach(item => { DataValue.forEach(item => {
...@@ -391,17 +342,14 @@ const ChangeAdd = props => { ...@@ -391,17 +342,14 @@ const ChangeAdd = props => {
useEffect(() => { useEffect(() => {
let checkedListArr = [...saveCheckValue]; let checkedListArr = [...saveCheckValue];
setIsCheck(1);
setIsCheck1(1);
let data = checkDataPm; let data = checkDataPm;
let DataValue = []; let DataValue = [];
console.log(roleValue); // 拿到当前页数据
checkDataPm.forEach(item => { checkDataPm.forEach(item => {
if (roleValue['部门'].indexOf(item) != -1) { if (roleValue['部门'].indexOf(item) != -1) {
DataValue.push(item); DataValue.push(item);
} }
}); });
console.log(DataValue);
// del // del
if (DataValue.length > listPm.length) { if (DataValue.length > listPm.length) {
DataValue.forEach(item => { DataValue.forEach(item => {
...@@ -424,18 +372,15 @@ const ChangeAdd = props => { ...@@ -424,18 +372,15 @@ const ChangeAdd = props => {
}, [listPm]); }, [listPm]);
useEffect(() => { useEffect(() => {
setIsCheck(1);
const checkedListArr = [...saveCheckValue]; const checkedListArr = [...saveCheckValue];
setIsCheck(1);
let data = checkDataSite; let data = checkDataSite;
let DataValue = []; let DataValue = [];
console.log(roleValue); // 拿到当前页数据
checkDataSite.forEach(item => { checkDataSite.forEach(item => {
if (roleValue['站点'].indexOf(item) != -1) { if (roleValue['站点'].indexOf(item) != -1) {
DataValue.push(item); DataValue.push(item);
} }
}); });
console.log(DataValue);
// del // del
if (DataValue.length > listSite.length) { if (DataValue.length > listSite.length) {
DataValue.forEach(item => { DataValue.forEach(item => {
...@@ -459,7 +404,6 @@ const ChangeAdd = props => { ...@@ -459,7 +404,6 @@ const ChangeAdd = props => {
const handleParChange = key => { const handleParChange = key => {
setKeyValue(key); setKeyValue(key);
// setSearchWord(''); // setSearchWord('');
setSearchFlag(0);
setCurrentPage(1); setCurrentPage(1);
setKeepTabKey(key); setKeepTabKey(key);
let value; let value;
...@@ -583,7 +527,6 @@ const ChangeAdd = props => { ...@@ -583,7 +527,6 @@ const ChangeAdd = props => {
<div className={styles.cardItem11}> <div className={styles.cardItem11}>
<div className={styles.cardContent1}> <div className={styles.cardContent1}>
<Tabs <Tabs
// defaultActiveKey="0"
className={styles.tab} className={styles.tab}
activeKey={keyValue} activeKey={keyValue}
onChange={handleParChange} onChange={handleParChange}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment