Commit 36469bf1 authored by 涂伟's avatar 涂伟

feat: '设备巡检配置新增搜索'

parent 576595e1
Pipeline #93609 canceled with stages
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* eslint-disable react-hooks/rules-of-hooks */ /* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
import React, { useState, createContext, useEffect, useMemo, useReducer, useRef } from 'react'; import React, { useState, createContext, useEffect, useMemo, useReducer, useRef } from 'react';
import { Space, Table, Popconfirm, Tooltip, Button, notification, Tag, message } from 'antd'; import { Space, Table, Popconfirm, Tooltip, Button, notification, Tag, message, Input } from 'antd';
import { import {
CM_XWBPlan_DataList, CM_XWBPlan_DataList,
NewCM_XWBPlan_DataList, NewCM_XWBPlan_DataList,
...@@ -42,10 +42,13 @@ const maintenance = () => { ...@@ -42,10 +42,13 @@ const maintenance = () => {
const [flag, setFlag] = useState(0); const [flag, setFlag] = useState(0);
const [sortVisible, setSortVisible] = useState(false); const [sortVisible, setSortVisible] = useState(false);
const [tableData, setTableData] = useState([]); const [tableData, setTableData] = useState([]);
const [filterTableData, setFilterTableData] = useState([]);
const [keepTableData, setKeepTableData] = useState([]); const [keepTableData, setKeepTableData] = useState([]);
const [activeName, setActiveName] = useState('project'); const [activeName, setActiveName] = useState('project');
const [selectColor, setSelectColor] = useState({}); const [selectColor, setSelectColor] = useState({});
const [searchWord, setSearchWord] = useState(''); // 关键字
const QRCodeDesignRef = useRef(null) const QRCodeDesignRef = useRef(null)
const { Search } = Input;
const setRowClassName = nodeID => { const setRowClassName = nodeID => {
return nodeID == selectColor ? styles.clickRowStyle : ''; return nodeID == selectColor ? styles.clickRowStyle : '';
...@@ -60,6 +63,7 @@ const maintenance = () => { ...@@ -60,6 +63,7 @@ const maintenance = () => {
} else { } else {
getConfigList(); getConfigList();
} }
setSearchWord('')
}, [flag, activeName]); }, [flag, activeName]);
const getDataList = () => { const getDataList = () => {
...@@ -67,6 +71,7 @@ const maintenance = () => { ...@@ -67,6 +71,7 @@ const maintenance = () => {
setTreeLoading(false); setTreeLoading(false);
if (res.code === 0) { if (res.code === 0) {
setTableData(res.data); setTableData(res.data);
setFilterTableData(res.data)
let list = []; let list = [];
res.data.map(i => { res.data.map(i => {
list.push(i.businessName); list.push(i.businessName);
...@@ -74,6 +79,7 @@ const maintenance = () => { ...@@ -74,6 +79,7 @@ const maintenance = () => {
setKeepTableData(list); setKeepTableData(list);
} else { } else {
setTableData([]); setTableData([]);
setFilterTableData([])
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -88,6 +94,7 @@ const maintenance = () => { ...@@ -88,6 +94,7 @@ const maintenance = () => {
setTreeLoading(false); setTreeLoading(false);
if (res.code === 0) { if (res.code === 0) {
setTableData(res.data); setTableData(res.data);
setFilterTableData(res.data)
let list = []; let list = [];
res.data.map(i => { res.data.map(i => {
list.push(i.businessName); list.push(i.businessName);
...@@ -95,6 +102,7 @@ const maintenance = () => { ...@@ -95,6 +102,7 @@ const maintenance = () => {
setKeepTableData(list); setKeepTableData(list);
} else { } else {
setTableData([]); setTableData([]);
setFilterTableData([])
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -109,8 +117,10 @@ const maintenance = () => { ...@@ -109,8 +117,10 @@ const maintenance = () => {
setTreeLoading(false); setTreeLoading(false);
if (res.code === 0) { if (res.code === 0) {
setTableData(res.data); setTableData(res.data);
setFilterTableData(res.data)
} else { } else {
setTableData([]); setTableData([]);
setFilterTableData([])
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -861,6 +871,19 @@ const maintenance = () => { ...@@ -861,6 +871,19 @@ const maintenance = () => {
} }
}; };
// 过滤人员
const searchDevice = (e) => {
setFilterTableData(tableData.filter(item => (item.accountName || item.AccountName).includes(searchWord)))
}
// 获取搜索框的值
const handleSearch = e => {
setSearchWord(e.target.value);
if(!e.target.value) {
setFilterTableData(tableData)
}
};
return ( return (
<Context.Provider value={{ state, dispatch }}> <Context.Provider value={{ state, dispatch }}>
<div className={styles.maintenanceContainer}> <div className={styles.maintenanceContainer}>
...@@ -881,6 +904,15 @@ const maintenance = () => { ...@@ -881,6 +904,15 @@ const maintenance = () => {
> >
设备库配置 设备库配置
</div> </div>
<Search
style={{ width: 260, marginRight: '15px' }}
placeholder="搜索设备名"
onSearch={e => searchDevice(e)}
onChange={e => handleSearch(e)}
enterButton
value={searchWord}
allowClear
/>
{/* <div {/* <div
className={activeName === 'template' ? styles.active : ''} className={activeName === 'template' ? styles.active : ''}
onClick={() => { onClick={() => {
...@@ -935,7 +967,7 @@ const maintenance = () => { ...@@ -935,7 +967,7 @@ const maintenance = () => {
editEventType={editEventType} editEventType={editEventType}
setSelectColor={setSelectColor} setSelectColor={setSelectColor}
columns={columns} columns={columns}
dataSource={tableData} dataSource={filterTableData}
scroll={{ y: 'calc(100vh - 215px)', x: 'max-content' }} scroll={{ y: 'calc(100vh - 215px)', x: 'max-content' }}
pagination={{ pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`, showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
...@@ -962,7 +994,7 @@ const maintenance = () => { ...@@ -962,7 +994,7 @@ const maintenance = () => {
}, // 双击 }, // 双击
})} })}
columns={columns} columns={columns}
dataSource={tableData} dataSource={filterTableData}
scroll={{ y: 'calc(100vh - 215px)', x: 'max-content' }} scroll={{ y: 'calc(100vh - 215px)', x: 'max-content' }}
pagination={{ pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`, showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
...@@ -1003,7 +1035,7 @@ const maintenance = () => { ...@@ -1003,7 +1035,7 @@ const maintenance = () => {
<SortModal <SortModal
title="调整顺序" title="调整顺序"
visible={sortVisible} visible={sortVisible}
sortData={tableData} sortData={filterTableData}
onCancel={() => setSortVisible(false)} onCancel={() => setSortVisible(false)}
callBackSubmit={onOK} callBackSubmit={onOK}
/> />
......
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