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

修改时间权限无法提交bug

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