Browse Source

*大屏运营左侧条件过滤修改为只展示搜索的对应数据

release_0.0.4
wanyiwei 2 years ago
parent
commit
ffa95765cd
  1. 41
      web/client/src/sections/quanju/containers/footer/operation/left.js

41
web/client/src/sections/quanju/containers/footer/operation/left.js

@ -10,6 +10,7 @@ const Left = (props) => {
const [treeData, setTreeData] = useState([])
const [treeDataList, setTreeDataList] = useState([])
const [expandedKeys, setExpandedKeys] = useState([]);
const [searchValue, setSearchValue] = useState('');
const [autoExpandParent, setAutoExpandParent] = useState(true);
const onExpand = (newExpandedKeys) => {
@ -20,6 +21,7 @@ const Left = (props) => {
useEffect(() => {
const { dispatch } = props
dispatch(getBusTierList())
}, [])
const { busTier } = props
const style = { height: "97%", marginTop: "3%" }
@ -35,10 +37,45 @@ const Left = (props) => {
setSearchValue(value);
setAutoExpandParent(true);
};
const loop = (treeData) =>
treeData.map((item) => {
const index = item.title.indexOf(searchValue);
const beforeStr = item.title.substr(0, index);
const afterStr = item.title.substr(index + searchValue.length);
const title =
index > -1 ? (
<span>
{beforeStr}
<span className="site-tree-search-value">{searchValue}</span>
{afterStr}
</span>
) : (
<span>{item.title}</span>
);
if (item.children && item.children.length > 0) {
const children = loop(item.children);
return {
...item,
title: index > -1 || children.length ? title : null,
children: children.length ? children : undefined
};
}
return index > -1
? {
...item,
title
}
: {
...item,
title: null
};
})
.filter((item) => !!item.title);
useEffect(() => {
let busTierList = []
let busTierOpen = []
let dataList = []
busTier && busTier.data && busTier.data.forEach((e, index) => {
if (index == 0) {
busTierOpen.push(e.name)
@ -115,8 +152,8 @@ const Left = (props) => {
onExpand={onExpand}
expandedKeys={expandedKeys}
autoExpandParent={autoExpandParent}
treeData={treeData}
/> : <div style={{width:'100%',color:'#fff',textAlign:'center',marginTop:'90%'}}></div>
treeData={loop(treeData)}
/> : <div style={{ width: '100%', color: '#fff', textAlign: 'center', marginTop: '90%' }}></div>
}
</div>

Loading…
Cancel
Save