Commit 798c46fb authored by 皮倩雯's avatar 皮倩雯

修改时间权限无法提交bug

parent 4f4219c4
Pipeline #41226 skipped with stages
...@@ -14,21 +14,14 @@ ...@@ -14,21 +14,14 @@
/* eslint-disable array-callback-return */ /* eslint-disable array-callback-return */
/* eslint-disable eqeqeq */ /* eslint-disable eqeqeq */
/* eslint-disable no-plusplus */ /* eslint-disable no-plusplus */
import React, { useState, useEffect, useCallback, useRef } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Modal, Checkbox, Tabs, Input, Button, Pagination } from 'antd'; import { Modal, Checkbox, Tabs, Input, Button, Pagination } from 'antd';
import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api'; import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api';
import styles from './incident.less'; import styles from './incident.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const { TabPane } = Tabs; const { TabPane } = Tabs;
const ChangeAdd = props => { const ChangeAdd = props => {
const usePrevious = value => {
const ref = useRef();
useEffect(() => {
ref.current = value;
});
return ref.current;
};
const { const {
callBackSubmit = () => {}, callBackSubmit = () => {},
isType, isType,
...@@ -42,7 +35,6 @@ const ChangeAdd = props => { ...@@ -42,7 +35,6 @@ const ChangeAdd = props => {
const [title, setTitle] = useState([]); const [title, setTitle] = useState([]);
const [checkedList, setCheckedList] = useState([]); // 选中复选框内容 const [checkedList, setCheckedList] = useState([]); // 选中复选框内容
const [flagg, setFlagg] = useState(0); const [flagg, setFlagg] = useState(0);
const [type, setType] = useState(); // 是否全选
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
const { Search } = Input; const { Search } = Input;
const [total, setTotal] = useState(); const [total, setTotal] = useState();
...@@ -65,9 +57,7 @@ const ChangeAdd = props => { ...@@ -65,9 +57,7 @@ const ChangeAdd = props => {
const [list, setList] = useState([]); const [list, setList] = useState([]);
const [listPm, setListPm] = useState([]); const [listPm, setListPm] = useState([]);
const [listSite, setListSite] = useState([]); const [listSite, setListSite] = useState([]);
const prevAmount = usePrevious({ list }); const [keyValue, setKeyValue] = useState('0');
const prevAmountPm = usePrevious({ checkDataPm });
const prevAmountSite = usePrevious({ listSite });
const onSubmit = () => { const onSubmit = () => {
// 没有勾选部门下的选项 // 没有勾选部门下的选项
...@@ -117,56 +107,22 @@ const ChangeAdd = props => { ...@@ -117,56 +107,22 @@ const ChangeAdd = props => {
setIsCheck(0); setIsCheck(0);
setIsCheck1(0); setIsCheck1(0);
setIsCheck2(0); setIsCheck2(0);
setList([]); // setList([]);
setKeyValue('0');
setSearchWord(''); setSearchWord('');
}; };
// const onCheckAllChange = e => {
// setData(1);
// const indeterminateArr = [...indeterminate];
// const checkAllArr = [...checkAll];
// const checkedListArr = [...checkedList];
// checkAllArr[e.target.index] = e.target.checked;
// indeterminateArr[e.target.index] = false;
// e.target.checked
// ? (checkedListArr[e.target.index] = e.target.checkvalue)
// : (checkedListArr[e.target.index] = []);
// setCheckedList(checkedListArr);
// setType(e.target.checked);
// setIndeterminate(indeterminateArr);
// setCheckAll(checkAllArr);
// };
useEffect(() => { useEffect(() => {
console.log(filed11);
setKeepOption1(filed11['部门']); setKeepOption1(filed11['部门']);
setKeepOption2(filed11['站点']); setKeepOption2(filed11['站点']);
getRoles('角色', '', pageSize, 1); getRoles('角色', '', pageSize, 1);
console.log(filed1);
setRoleValue(filed1); setRoleValue(filed1);
setFlagg(1); setFlagg(1);
console.log(filed1);
let arr = Object.keys(filed1); let arr = Object.keys(filed1);
console.log(arr, 'arr');
setTitle(arr); setTitle(arr);
let checkArr = []; let checkArr = [];
console.log(newCheckedList); // 已选中数组 console.log(newCheckedList); // 已选中数组
// arr.map((item, index) => {
// checkArr[index] = [];
// newCheckedList.map(checkItem => {
// if (filed1[item].includes(checkItem)) {
// checkArr[index].push(checkItem);
// }
// });
// });
// console.log(characterValue);
// let newArr = characterValue.length ? characterValue.split(',') : [];
// console.log(newArr);
// let newArr1 = newCheckedList.map(item => ({ name: item }));
// if (newArr1.length === 1 && newArr1[0].name === '') {
// newArr1 = [];
// }
// console.log(newArr1);
let listdata = []; let listdata = [];
newCheckedList.map(checkItem => { newCheckedList.map(checkItem => {
if (filed11['角色'].includes(checkItem)) { if (filed11['角色'].includes(checkItem)) {
...@@ -197,7 +153,6 @@ const ChangeAdd = props => { ...@@ -197,7 +153,6 @@ const ChangeAdd = props => {
}, [visible]); }, [visible]);
const submitSearchUser = () => { const submitSearchUser = () => {
console.log(keepTabKey);
if (searchWord != '') { if (searchWord != '') {
setSearchFlag(1); setSearchFlag(1);
} }
...@@ -223,8 +178,7 @@ const ChangeAdd = props => { ...@@ -223,8 +178,7 @@ const ChangeAdd = props => {
// 监听分页 // 监听分页
const paginationChange = (page, pageSizes) => { const paginationChange = (page, pageSizes) => {
console.log(searchWord) if (searchWord) {
if(searchWord){
if (keepTabKey == 0) { if (keepTabKey == 0) {
getRoles('角色', searchWord, pageSizes, page); getRoles('角色', searchWord, pageSizes, page);
} }
...@@ -234,7 +188,7 @@ const ChangeAdd = props => { ...@@ -234,7 +188,7 @@ const ChangeAdd = props => {
if (keepTabKey == 2) { if (keepTabKey == 2) {
getRoles('站点', searchWord, pageSizes, page); getRoles('站点', searchWord, pageSizes, page);
} }
}else{ } else {
if (keepTabKey == 0) { if (keepTabKey == 0) {
getRoles('角色', '', pageSizes, page); getRoles('角色', '', pageSizes, page);
} }
...@@ -247,11 +201,10 @@ const ChangeAdd = props => { ...@@ -247,11 +201,10 @@ const ChangeAdd = props => {
} }
// 分页时清空复选框 // 分页时清空复选框
setCurrentPage(page); setCurrentPage(page);
setPageSize(pageSizes); setPageSize(pageSizes);
}; };
// 搜索时获取数据 // 搜索时获取数据
const sreachRoles = (type, keywords, pageSizes, pageIndex) => { const sreachRoles = (type, keywords, pageSizes, pageIndex) => {
console.log(type);
CM_Event_LoadDepartmentAndRoles({ CM_Event_LoadDepartmentAndRoles({
type, type,
keywords, keywords,
...@@ -259,11 +212,8 @@ const ChangeAdd = props => { ...@@ -259,11 +212,8 @@ const ChangeAdd = props => {
pageIndex, pageIndex,
}).then(res => { }).then(res => {
if (res.msg === 'Ok') { if (res.msg === 'Ok') {
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'));
console.log(checkedList);
console.log(checkDataRole);
let data = []; let data = [];
if (type == '角色') { if (type == '角色') {
checkDataRole.forEach(item => { checkDataRole.forEach(item => {
...@@ -294,7 +244,7 @@ const ChangeAdd = props => { ...@@ -294,7 +244,7 @@ const ChangeAdd = props => {
}); });
} }
setkeepSearchList(data); setkeepSearchList(data);
setCurrentPage(1) setCurrentPage(1);
setTotal(res.data.count); setTotal(res.data.count);
} }
}); });
...@@ -318,8 +268,6 @@ const ChangeAdd = props => { ...@@ -318,8 +268,6 @@ const ChangeAdd = props => {
}; };
const getRoles = (type, keywords, pageSizes, pageIndex) => { const getRoles = (type, keywords, pageSizes, pageIndex) => {
console.log(type);
console.log(keywords);
CM_Event_LoadDepartmentAndRoles({ CM_Event_LoadDepartmentAndRoles({
type, type,
keywords, keywords,
...@@ -328,7 +276,6 @@ const ChangeAdd = props => { ...@@ -328,7 +276,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'));
} }
...@@ -447,6 +394,7 @@ const ChangeAdd = props => { ...@@ -447,6 +394,7 @@ const ChangeAdd = props => {
setIsCheck(1); 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);
...@@ -480,6 +428,7 @@ const ChangeAdd = props => { ...@@ -480,6 +428,7 @@ const ChangeAdd = props => {
setIsCheck1(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);
...@@ -513,6 +462,7 @@ const ChangeAdd = props => { ...@@ -513,6 +462,7 @@ const ChangeAdd = props => {
setIsCheck(1); 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);
...@@ -540,10 +490,10 @@ const ChangeAdd = props => { ...@@ -540,10 +490,10 @@ const ChangeAdd = props => {
setCheckedList(checkedListArr); setCheckedList(checkedListArr);
}, [listSite]); }, [listSite]);
const handleParChange = key => { const handleParChange = key => {
setSearchWord('') setKeyValue(key);
setSearchWord('');
setSearchFlag(0); setSearchFlag(0);
setCurrentPage(1); setCurrentPage(1);
console.log(key);
setKeepTabKey(key); setKeepTabKey(key);
let value; let value;
if (key == 0) { if (key == 0) {
...@@ -558,7 +508,6 @@ const ChangeAdd = props => { ...@@ -558,7 +508,6 @@ const ChangeAdd = props => {
value = '站点'; value = '站点';
getRoles('站点', '', pageSize, 1); getRoles('站点', '', pageSize, 1);
} }
console.log(value);
}; };
const onChangeListNew = list => { const onChangeListNew = list => {
...@@ -605,7 +554,7 @@ const ChangeAdd = props => { ...@@ -605,7 +554,7 @@ const ChangeAdd = props => {
<div className={styles.cardItem1}> <div className={styles.cardItem1}>
<div className={styles.cardContent1}> <div className={styles.cardContent1}>
<Tabs <Tabs
defaultActiveKey="0" activeKey={keyValue}
className={styles.tab} className={styles.tab}
onChange={handleParChange} onChange={handleParChange}
> >
...@@ -641,7 +590,12 @@ const ChangeAdd = props => { ...@@ -641,7 +590,12 @@ const ChangeAdd = props => {
</div> </div>
<div className={styles.cardItem11}> <div className={styles.cardItem11}>
<div className={styles.cardContent1}> <div className={styles.cardContent1}>
<Tabs defaultActiveKey="0" className={styles.tab}> <Tabs
// defaultActiveKey="0"
className={styles.tab}
activeKey={keyValue}
onChange={handleParChange}
>
<TabPane tab="角色" key="0"> <TabPane tab="角色" key="0">
{checkDataRole.map((item, index) => ( {checkDataRole.map((item, index) => (
<div <div
......
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