Commit f4001def authored by 皮倩雯's avatar 皮倩雯

fix: '巡检反馈搜索'

parent 37bbc3ba
Pipeline #77021 waiting for manual action with stages
/* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable camelcase */
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { Space, Table, Popconfirm, Tooltip, Button, notification, Spin, Card, Input } from 'antd';
import {
CM_Feedback_LoadPatrolFeedbacks,
......@@ -36,7 +36,10 @@ const patrolFeedback = () => {
const [treeVisible, setTreeVisible] = useState(true); // 左边列表是否可见
const [pickItem, setPickItem] = useState('区域巡检');
const [hoverItemIndex, setHoverItemIndex] = useState('');
const [searchValue, setSearchValue] = useState('');
// const [searchValue, setSearchValue] = useState('');
const searchValue = useRef(null);
const [keepSearch, setKeepSearch] = useState([]);
const [newTableData, setNewTableData] = useState([]);
const columns = [
{
......@@ -203,9 +206,16 @@ const patrolFeedback = () => {
];
useEffect(() => {
getTableList();
}, []);
const getTableList = val => {
setTreeLoading(true);
CM_Feedback_LoadPatrolFeedbacks({ pageIndex: 1, pageSize: 20, keyword: searchValue }).then(
res => {
CM_Feedback_LoadPatrolFeedbacks({
pageIndex: 1,
pageSize: 20,
keyword: val ? val : searchValue.current,
}).then(res => {
setTreeLoading(false);
if (res.code === 0) {
let data = {};
......@@ -237,6 +247,11 @@ const patrolFeedback = () => {
setGroupName(['区域巡检', 'DMA巡检']);
}
}
if (searchValue.current) {
setNewTableData(res.data.list);
} else {
setNewTableData(data[pickItem]);
}
setTableData(data);
let list = [];
res.data.list.map(i => {
......@@ -244,9 +259,8 @@ const patrolFeedback = () => {
});
setKeepTableData(list);
}
},
);
}, [flag]);
});
};
const add = () => {
setAddVisible(true);
......@@ -265,7 +279,7 @@ const patrolFeedback = () => {
duration: 3,
description: '删除成功',
});
setFlag(flag + 1);
getTableList();
} else {
notification.error({
message: '提示',
......@@ -277,7 +291,7 @@ const patrolFeedback = () => {
};
const onOK = () => {
setFlag(flag + 1);
getTableList();
};
const sort = () => {
......@@ -303,7 +317,7 @@ const patrolFeedback = () => {
description: '批量删除成功',
});
setSelectedRowKeys([]);
setFlag(flag + 1);
getTableList();
} else {
notification.error({
message: '提示',
......@@ -320,12 +334,9 @@ const patrolFeedback = () => {
};
// 搜索
const handleSearch = text => {
setFlag(flag + 1);
};
// 搜索框改变时存储输入的值
const handleChange = e => {
setSearchValue(e.target.value);
const handleSearch = e => {
searchValue.current = e;
getTableList(e);
};
return (
......@@ -426,8 +437,6 @@ const patrolFeedback = () => {
allowClear
placeholder="请输入巡检对象名称"
onSearch={handleSearch}
onChange={handleChange}
value={searchValue}
enterButton
style={{ width: '300px' }}
/>
......@@ -485,7 +494,7 @@ const patrolFeedback = () => {
}, // 双击
})}
columns={columns}
dataSource={tableData[pickItem]}
dataSource={newTableData}
scroll={{ y: 'calc(100% - 40px)', x: 'max-content' }}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
......
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