Commit 2a56353a authored by 皮倩雯's avatar 皮倩雯

添加搜索为空状态提示

parent 5369c2b2
Pipeline #41258 skipped with stages
......@@ -3,7 +3,7 @@
/* eslint-disable no-unused-expressions */
/* eslint-disable no-shadow */
import React, { useState, useEffect } from 'react';
import { Modal, Checkbox, Tabs, Input, Button, Pagination } from 'antd';
import { Modal, Checkbox, Tabs, Input, Button, Pagination, Empty } from 'antd';
import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api';
import styles from './incident.less';
......@@ -45,6 +45,7 @@ const ChangeAddFlows = props => {
const [listPm, setListPm] = useState([]);
const [listSite, setListSite] = useState([]);
const [keyValue, setKeyValue] = useState('0');
const [emptyValue, setEmptyValue] = useState(0);
const onSubmit = () => {
// 没有勾选部门下的选项
......@@ -76,14 +77,21 @@ const ChangeAddFlows = props => {
saveCheckValue.map((item, index) => {
data = data.concat(item);
});
callBackSubmit({
saveCheckValue,
str: data.join(','),
pickItem,
stt: data,
title,
filed22: filed1,
});
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);
......@@ -156,28 +164,15 @@ const ChangeAddFlows = props => {
// 监听分页
const paginationChange = (page, pageSizes) => {
if (searchWord) {
if (keepTabKey == 0) {
getRoles('角色', searchWord, pageSizes, page);
}
if (keepTabKey == 1) {
getRoles('部门', searchWord, pageSizes, page);
}
if (keepTabKey == 2) {
getRoles('站点', searchWord, pageSizes, page);
}
} else {
if (keepTabKey == 0) {
getRoles('角色', '', pageSizes, page);
}
if (keepTabKey == 1) {
getRoles('部门', '', pageSizes, page);
}
if (keepTabKey == 2) {
getRoles('站点', '', pageSizes, page);
}
if (keepTabKey == 0) {
getRoles('角色', searchWord, pageSizes, page);
}
if (keepTabKey == 1) {
getRoles('部门', searchWord, pageSizes, page);
}
if (keepTabKey == 2) {
getRoles('站点', searchWord, pageSizes, page);
}
// 分页时清空复选框
setCurrentPage(page);
setPageSize(pageSizes);
};
......@@ -192,38 +187,14 @@ const ChangeAddFlows = props => {
if (res.msg === 'Ok') {
setRoleValue(formateArrDataA1(res.data, 'groupType'));
setFiled1(formateArrDataA1(res.data, 'groupType'));
let data = [];
if (type == '角色') {
checkDataRole.forEach(item => {
if (
formateArrDataA1(res.data, 'groupType')[type].indexOf(item) != -1
) {
data.push(item);
}
});
}
if (type == '部门') {
checkDataPm.forEach(item => {
if (
formateArrDataA1(res.data, 'groupType')[type].indexOf(item) != -1
) {
data.push(item);
}
});
// setListPm(data);
}
if (type == '站点') {
checkDataSite.forEach(item => {
if (
formateArrDataA1(res.data, 'groupType')[type].indexOf(item) != -1
) {
data.push(item);
}
});
}
setkeepSearchList(data);
console.log(res.data.count);
setCurrentPage(1);
setTotal(res.data.count);
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
}
});
};
......@@ -256,6 +227,11 @@ const ChangeAddFlows = props => {
setTotal(res.data.count);
setRoleValue(formateArrDataA1(res.data, 'groupType'));
setFiled1(formateArrDataA1(res.data, 'groupType'));
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
}
});
};
......@@ -465,22 +441,22 @@ const ChangeAddFlows = props => {
}, [listSite]);
const handleParChange = key => {
setKeyValue(key);
setSearchWord('');
// setSearchWord('');
setSearchFlag(0);
setCurrentPage(1);
setKeepTabKey(key);
let value;
if (key == 0) {
value = '角色';
getRoles('角色', '', pageSize, 1);
getRoles('角色', searchWord, pageSize, 1);
}
if (key == 1) {
value = '部门';
getRoles('部门', '', pageSize, 1);
getRoles('部门', searchWord, pageSize, 1);
}
if (key == 2) {
value = '站点';
getRoles('站点', '', pageSize, 1);
getRoles('站点', searchWord, pageSize, 1);
}
};
......@@ -493,7 +469,6 @@ const ChangeAddFlows = props => {
const onChangeListNew2 = list => {
setListSite(list);
};
return (
<Modal
title="权限选择"
......@@ -508,6 +483,10 @@ const ChangeAddFlows = props => {
onOk={() => onSubmit()}
forceRender
getContainer={false}
afterClose={() => {
setKeyValue('0');
setSearchWord('');
}}
>
<Search
style={{
......@@ -535,29 +514,50 @@ const ChangeAddFlows = props => {
>
<TabPane tab="角色" key="0">
<div className={styles.cardItemData1}>
<CheckboxGroup
options={roleValue['角色']}
value={checkedList[0]}
onChange={onChangeListNew}
/>
{emptyValue == 0 ? (
<CheckboxGroup
options={roleValue['角色']}
value={checkedList[0]}
onChange={onChangeListNew}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="暂无数据"
/>
)}
</div>
</TabPane>
<TabPane tab="部门" key="1">
<div className={styles.cardItemData1}>
<CheckboxGroup
options={roleValue['部门']}
value={checkedList[1]}
onChange={onChangeListNew1}
/>
{emptyValue == 0 ? (
<CheckboxGroup
options={roleValue['部门']}
value={checkedList[1]}
onChange={onChangeListNew}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="暂无数据"
/>
)}
</div>
</TabPane>
<TabPane tab="站点" key="2">
<div className={styles.cardItemData1}>
<CheckboxGroup
options={roleValue['站点']}
value={checkedList[2]}
onChange={onChangeListNew2}
/>
{emptyValue == 0 ? (
<CheckboxGroup
options={roleValue['站点']}
value={checkedList[2]}
onChange={onChangeListNew}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="暂无数据"
/>
)}
</div>
</TabPane>
</Tabs>
......
......@@ -15,7 +15,7 @@
/* eslint-disable eqeqeq */
/* eslint-disable no-plusplus */
import React, { useState, useEffect } from 'react';
import { Modal, Checkbox, Tabs, Input, Button, Pagination } from 'antd';
import { Modal, Checkbox, Tabs, Input, Button, Pagination, Empty } from 'antd';
import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api';
import styles from './incident.less';
......@@ -38,7 +38,7 @@ const ChangeAdd = props => {
const [searchWord, setSearchWord] = useState(''); // 关键字
const { Search } = Input;
const [total, setTotal] = useState();
const [pageSize, setPageSize] = useState(42);
const [pageSize, setPageSize] = useState(40);
const [currentPage, setCurrentPage] = useState(1);
const [roleValue, setRoleValue] = useState([]);
const [checkDataRole, setCheckDataRole] = useState([]);
......@@ -53,11 +53,11 @@ const ChangeAdd = props => {
const [keepOption2, setKeepOption2] = useState([]); // 保存了获取的站点列表数据
const [keepTabKey, setKeepTabKey] = useState(0);
const [searchFlag, setSearchFlag] = useState(0);
const [keepSearchList, setkeepSearchList] = useState([]); // 保存搜索后出现的选中列表
const [list, setList] = useState([]);
const [listPm, setListPm] = useState([]);
const [listSite, setListSite] = useState([]);
const [keyValue, setKeyValue] = useState('0');
const [emptyValue, setEmptyValue] = useState(0);
const onSubmit = () => {
// 没有勾选部门下的选项
......@@ -176,28 +176,15 @@ const ChangeAdd = props => {
// 监听分页
const paginationChange = (page, pageSizes) => {
if (searchWord) {
if (keepTabKey == 0) {
getRoles('角色', searchWord, pageSizes, page);
}
if (keepTabKey == 1) {
getRoles('部门', searchWord, pageSizes, page);
}
if (keepTabKey == 2) {
getRoles('站点', searchWord, pageSizes, page);
}
} else {
if (keepTabKey == 0) {
getRoles('角色', '', pageSizes, page);
}
if (keepTabKey == 1) {
getRoles('部门', '', pageSizes, page);
}
if (keepTabKey == 2) {
getRoles('站点', '', pageSizes, page);
}
if (keepTabKey == 0) {
getRoles('角色', searchWord, pageSizes, page);
}
if (keepTabKey == 1) {
getRoles('部门', searchWord, pageSizes, page);
}
if (keepTabKey == 2) {
getRoles('站点', searchWord, pageSizes, page);
}
// 分页时清空复选框
setCurrentPage(page);
setPageSize(pageSizes);
};
......@@ -212,38 +199,14 @@ const ChangeAdd = props => {
if (res.msg === 'Ok') {
setRoleValue(formateArrDataA1(res.data, 'groupType'));
setFiled1(formateArrDataA1(res.data, 'groupType'));
let data = [];
if (type == '角色') {
checkDataRole.forEach(item => {
if (
formateArrDataA1(res.data, 'groupType')[type].indexOf(item) != -1
) {
data.push(item);
}
});
}
if (type == '部门') {
checkDataPm.forEach(item => {
if (
formateArrDataA1(res.data, 'groupType')[type].indexOf(item) != -1
) {
data.push(item);
}
});
// setListPm(data);
}
if (type == '站点') {
checkDataSite.forEach(item => {
if (
formateArrDataA1(res.data, 'groupType')[type].indexOf(item) != -1
) {
data.push(item);
}
});
}
setkeepSearchList(data);
console.log(res.data.count);
setCurrentPage(1);
setTotal(res.data.count);
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
}
});
};
......@@ -276,6 +239,11 @@ const ChangeAdd = props => {
setTotal(res.data.count);
setRoleValue(formateArrDataA1(res.data, 'groupType'));
setFiled1(formateArrDataA1(res.data, 'groupType'));
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
}
});
};
......@@ -485,22 +453,22 @@ const ChangeAdd = props => {
}, [listSite]);
const handleParChange = key => {
setKeyValue(key);
setSearchWord('');
// setSearchWord('');
setSearchFlag(0);
setCurrentPage(1);
setKeepTabKey(key);
let value;
if (key == 0) {
value = '角色';
getRoles('角色', '', pageSize, 1);
getRoles('角色', searchWord, pageSize, 1);
}
if (key == 1) {
value = '部门';
getRoles('部门', '', pageSize, 1);
getRoles('部门', searchWord, pageSize, 1);
}
if (key == 2) {
value = '站点';
getRoles('站点', '', pageSize, 1);
getRoles('站点', searchWord, pageSize, 1);
}
};
......@@ -558,29 +526,50 @@ const ChangeAdd = props => {
>
<TabPane tab="角色" key="0">
<div className={styles.cardItemData1}>
<CheckboxGroup
options={roleValue['角色']}
value={checkedList[0]}
onChange={onChangeListNew}
/>
{emptyValue == 0 ? (
<CheckboxGroup
options={roleValue['角色']}
value={checkedList[0]}
onChange={onChangeListNew}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="暂无数据"
/>
)}
</div>
</TabPane>
<TabPane tab="部门" key="1">
<div className={styles.cardItemData1}>
<CheckboxGroup
options={roleValue['部门']}
value={checkedList[1]}
onChange={onChangeListNew1}
/>
{emptyValue == 0 ? (
<CheckboxGroup
options={roleValue['部门']}
value={checkedList[1]}
onChange={onChangeListNew}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="暂无数据"
/>
)}
</div>
</TabPane>
<TabPane tab="站点" key="2">
<div className={styles.cardItemData1}>
<CheckboxGroup
options={roleValue['站点']}
value={checkedList[2]}
onChange={onChangeListNew2}
/>
{emptyValue == 0 ? (
<CheckboxGroup
options={roleValue['站点']}
value={checkedList[2]}
onChange={onChangeListNew}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="暂无数据"
/>
)}
</div>
</TabPane>
</Tabs>
......
......@@ -237,7 +237,7 @@
padding: 0rem 1rem;
margin-bottom: 1rem;
width: 100%;
height: 28rem;
// height: 28re;
}
}
.doctorTable {
......
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