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

feat: 修改

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