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

修改代码格式

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