Commit 730a995b authored by 徐乐's avatar 徐乐

feat: 修改

parent 276fe2e3
...@@ -56,8 +56,9 @@ const QuotaSelect = ({ ...@@ -56,8 +56,9 @@ const QuotaSelect = ({
const [selectDevice, setSelectDevice] = useState({}); // 选中的设备 const [selectDevice, setSelectDevice] = useState({}); // 选中的设备
const [selectData, setSelectData] = useState([]); // 选中的指标数据 const [selectData, setSelectData] = useState([]); // 选中的指标数据
const [confParams, setConfParams] = useState({}); const [confParams, setConfParams] = useState({});
const [search, setSearch] = useState('');
const fetchData = (item = {}) => { const fetchData = (item = {}) => {
console.log(1221, item)
// 请求指标列表 // 请求指标列表
getQuataList({ getQuataList({
accountName: item.deviceType, accountName: item.deviceType,
...@@ -73,6 +74,8 @@ const QuotaSelect = ({ ...@@ -73,6 +74,8 @@ const QuotaSelect = ({
key: child.sensorName, key: child.sensorName,
})) }))
: []; : [];
let k = data.find(function (a) { return a.isShow == 1 });
setTargetValue(k ? 'emphasis' : 'all');
setAllQuotaList(data); setAllQuotaList(data);
setSelectData(data.filter((child) => child.checked)); setSelectData(data.filter((child) => child.checked));
} else { } else {
...@@ -132,7 +135,8 @@ const QuotaSelect = ({ ...@@ -132,7 +135,8 @@ const QuotaSelect = ({
if (targetValue === 'emphasis') { if (targetValue === 'emphasis') {
filterEmphasisQuota(); filterEmphasisQuota();
} else { } else {
setQuotaList(allQuotaList); let newQuotaList = allQuotaList.filter((item) => item.sensorName.indexOf(search) >= 0);
setQuotaList(newQuotaList);
} }
}, [allQuotaList]); }, [allQuotaList]);
...@@ -154,7 +158,7 @@ const QuotaSelect = ({ ...@@ -154,7 +158,7 @@ const QuotaSelect = ({
// 过滤重点指标 // 过滤重点指标
const filterEmphasisQuota = () => { const filterEmphasisQuota = () => {
let newQuotaList = [...allQuotaList]; let newQuotaList = [...allQuotaList];
newQuotaList = newQuotaList.filter((item) => item.isShow === 1); newQuotaList = newQuotaList.filter((item) => item.isShow === 1 && item.sensorName.indexOf(search) >= 0);
setQuotaList(newQuotaList); setQuotaList(newQuotaList);
}; };
...@@ -204,7 +208,8 @@ const QuotaSelect = ({ ...@@ -204,7 +208,8 @@ const QuotaSelect = ({
// 切换重点与全部 // 切换重点与全部
const onRadioChange = (e) => { const onRadioChange = (e) => {
if (e.target.value === 'all') { if (e.target.value === 'all') {
setQuotaList(allQuotaList); let newQuotaList = allQuotaList.filter((item) => item.sensorName.indexOf(search) >= 0);
setQuotaList(newQuotaList);
} else { } else {
filterEmphasisQuota(); filterEmphasisQuota();
} }
...@@ -214,6 +219,7 @@ const QuotaSelect = ({ ...@@ -214,6 +219,7 @@ const QuotaSelect = ({
// 搜索指标 // 搜索指标
const onSearch = (e) => { const onSearch = (e) => {
if (e.type === 'keydown' || e.target.value === '') { if (e.type === 'keydown' || e.target.value === '') {
setSearch(e.target.value);
if (e.target.value !== '') { if (e.target.value !== '') {
let newQuotaList = []; let newQuotaList = [];
quotaList.forEach((item) => { quotaList.forEach((item) => {
...@@ -462,10 +468,10 @@ QuotaSelect.defaultProps = { ...@@ -462,10 +468,10 @@ QuotaSelect.defaultProps = {
deviceList: [], deviceList: [],
confList: [], confList: [],
treeProps: {}, treeProps: {},
onSelect: () => {}, onSelect: () => { },
onModalCancel: () => {}, onModalCancel: () => { },
onModalOk: () => {}, onModalOk: () => { },
onModalClose: () => {}, onModalClose: () => { },
defaultSelect: 'emphasis', defaultSelect: 'emphasis',
}; };
......
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