Compare commits

...

3 Commits

  1. 12
      web/client/src/sections/quanju/actions/example.js
  2. 29
      web/client/src/sections/quanju/containers/footer/operation/index.js
  3. 231
      web/client/src/sections/quanju/containers/footer/operation/left.js
  4. 29
      web/client/src/sections/quanju/containers/footer/operation/style.less
  5. 10
      web/client/src/utils/webapi.js

12
web/client/src/sections/quanju/actions/example.js

@ -62,4 +62,16 @@ export function getxuanchuan() {
msg: { error: '获取宣传信息失败' }, msg: { error: '获取宣传信息失败' },
// reducer: { name: 'members' } // reducer: { name: 'members' }
}); });
}
//获取公交车辆层级信息
export function getBusTierList() {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
actionType: 'GET_BUSTIER',
url: ApiTable.getBusTier,
msg: { error: '获取公交车辆层级信息失败' },
reducer: { name: 'busTier' }
});
} }

29
web/client/src/sections/quanju/containers/footer/operation/index.js

@ -1,13 +1,32 @@
import React from 'react' import React, { useEffect, useState } from 'react'
import Left from './left' import Left from './left'
import Right from './right' import Right from './right'
import { connect } from 'react-redux'
import { getBusTierList } from '../../../actions/example'
const Operation = (props) => {
const [roadData, setRoadData] = useState()
const [loading, setLoading] = useState(true)
const { dispatch } = props
useEffect(() => {
dispatch(getBusTierList()).then(res => {
setLoading(false)
setRoadData(res.payload.data || {})
})
}, [])
const Operation = () => {
return ( return (
<div style={{ display: 'flex', width: '100%',height: '100%',justifyContent: 'space-between' }}> <div style={{ display: 'flex', width: '100%',height: '100%',justifyContent: 'space-between' }}>
<Left /> <Left roadData={roadData} loading={loading} />
<Right /> <Right roadData={roadData} loading={loading} />
</div> </div>
) )
} }
export default Operation function mapStateToProps(state) {
return {
}
}
export default connect(mapStateToProps)(Operation)

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

@ -1,89 +1,15 @@
import React, { useMemo, useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { SearchOutlined } from '@ant-design/icons'; import { connect } from 'react-redux';
import { Col, Row, Input, Tree } from 'antd' import { Input, Tree } from 'antd'
import Module from '../../public/module' import Module from '../../public/module'
import { getBusTierList } from '../../../actions/example'
import './style.less'
const { Search } = Input;
const x = 3;
const y = 2;
const z = 1;
const defaultData = [];
const generateData = (_level, _preKey, _tns) => { const Left = (props) => {
const preKey = _preKey || '0'; const [treeData, setTreeData] = useState([])
const tns = _tns || defaultData; const [treeDataList, setTreeDataList] = useState([])
const children = [];
for (let i = 0; i < x; i++) {
const key = `${preKey}-${i}`;
tns.push({
title: key,
key,
});
if (i < y) {
children.push(key);
}
}
if (_level < 0) {
return tns;
}
const level = _level - 1;
children.forEach((key, index) => {
tns[index].children = [];
return generateData(level, key, tns[index].children);
});
};
generateData(z);
const dataList = [];
const generateList = (data) => {
for (let i = 0; i < data.length; i++) {
const node = data[i];
const { key } = node;
dataList.push({
key,
title: key,
});
if (node.children) {
generateList(node.children);
}
}
};
generateList(defaultData);
const getParentKey = (key, tree) => {
let parentKey;
for (let i = 0; i < tree.length; i++) {
const node = tree[i];
if (node.children) {
if (node.children.some((item) => item.key === key)) {
parentKey = node.key;
} else if (getParentKey(key, node.children)) {
parentKey = getParentKey(key, node.children);
}
}
}
return parentKey;
};
const Left = () => {
useEffect(() => {
}, [])
const style = { height: "97%", marginTop: "3%" }
const [expandedKeys, setExpandedKeys] = useState([]); const [expandedKeys, setExpandedKeys] = useState([]);
const [searchValue, setSearchValue] = useState('');
const [autoExpandParent, setAutoExpandParent] = useState(true); const [autoExpandParent, setAutoExpandParent] = useState(true);
const onExpand = (newExpandedKeys) => { const onExpand = (newExpandedKeys) => {
@ -91,60 +17,76 @@ const Left = () => {
setAutoExpandParent(false); setAutoExpandParent(false);
}; };
useEffect(() => {
const { dispatch } = props
dispatch(getBusTierList())
}, [])
const { busTier } = props
const style = { height: "97%", marginTop: "3%" }
const onChange = (e) => { const onChange = (e) => {
const { value } = e.target; const { value } = e.target;
const newExpandedKeys = dataList let keys = []
.map((item) => { const newExpandedKeys = treeDataList.filter(e=> e.key.match(value))
if (item.title.indexOf(value) > -1) { newExpandedKeys.forEach(e=>{
return getParentKey(item.key, defaultData); keys.push(e.key)
} })
setExpandedKeys(keys);
return null;
})
.filter((item, i, self) => item && self.indexOf(item) === i);
setExpandedKeys(newExpandedKeys);
setSearchValue(value); setSearchValue(value);
setAutoExpandParent(true); setAutoExpandParent(true);
}; };
useEffect(() => {
const treeData = useMemo(() => { let busTierList = []
const loop = (data) => let busTierOpen = []
data.map((item) => { let dataList = []
const strTitle = item.title; busTier && busTier.data && busTier.data.forEach((e, index) => {
const index = strTitle.indexOf(searchValue); if (index == 0) {
const beforeStr = strTitle.substring(0, index); busTierOpen.push(e.name)
const afterStr = strTitle.slice(index + searchValue.length); }
const title = busTierList.push({
index > -1 ? ( key: e.name,
<span> title: e.name,
{beforeStr} children: e.child.map(s => {
<span className="site-tree-search-value">{searchValue}</span>
{afterStr}
</span>
) : (
<span>{strTitle}</span>
);
if (item.children) {
return { return {
title, key: s.name,
key: item.key, title: s.name,
children: loop(item.children), children: s.child.map(i => {
}; return {
} key: i.vehicleLicensePlateNumber,
title: i.vehicleLicensePlateNumber,
return { }
title, })
key: item.key, }
};
}); })
})
return loop(defaultData); })
}, [searchValue]); busTier && busTier.data && busTier.data.forEach(e => {
dataList.push({
key: e.name,
title: e.name,
})
e.child.forEach(i=>{
dataList.push({
key: i.name,
title: i.name,
})
i.child.forEach(s=>{
dataList.push({
key: s.vehicleLicensePlateNumber,
title: s.vehicleLicensePlateNumber,
})
})
})
})
setTreeData(busTierList)
setExpandedKeys(busTierOpen)
setTreeDataList(dataList)
}, [busTier])
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', width: "23%", height: "100%", marginLeft: "1%" }}> <div style={{ display: 'flex', flexDirection: 'column', width: "23%", height: "100%", marginLeft: "1%" }}>
<Module style={style} title={"公交车辆信息"}> <Module style={style} customize={true} title={"公交车辆信息"}>
<div style={{ width: '90%', height: '96', margin: '2% 5%', }}> <div style={{ width: '90%', height: '96%', margin: '2% 5%', overflow: 'hidden' }}>
<div style={{ border: '1px solid rgba(10, 114, 255, 1)', backgroundColor: 'rgba(10, 114, 255, 0.1)' }}> <div style={{ border: '1px solid rgba(10, 114, 255, 1)', backgroundColor: 'rgba(10, 114, 255, 0.1)' }}>
<img src='assets/images/quanju/search.png' style={{ width: '5%', margin: '0 1.5% 1% 3.5%' }} /> <img src='assets/images/quanju/search.png' style={{ width: '5%', margin: '0 1.5% 1% 3.5%' }} />
<Input <Input
@ -160,21 +102,30 @@ const Left = () => {
onChange={onChange} onChange={onChange}
/> />
</div> </div>
<Tree <div className='busList'>
rootStyle={{ <Tree
background: 'none', rootStyle={{
borderColor: 'none', marginTop: '1%',
color: 'rgba(255, 255, 255, 1)' background: 'none',
}} borderColor: 'none',
onExpand={onExpand} color: 'rgba(255, 255, 255, 1)'
expandedKeys={expandedKeys} }}
autoExpandParent={autoExpandParent} onExpand={onExpand}
treeData={treeData} expandedKeys={expandedKeys}
/> autoExpandParent={autoExpandParent}
treeData={treeData}
/>
</div>
</div> </div>
</Module> </Module>
</div> </div>
); );
}; };
function mapStateToProps(state) {
const { busTier } = state
return {
busTier: busTier
}
}
export default Left; export default connect(mapStateToProps)(Left);

29
web/client/src/sections/quanju/containers/footer/operation/style.less

@ -0,0 +1,29 @@
.busList {
width: 100%;
height: 96%;
overflow-x: hidden;
overflow-y: auto;
.ant-tree .ant-tree-node-content-wrapper.ant-tree-node-selected{
background: none;
background-color: none !important;
border: 1px solid rgba(10, 114, 255, 1);
}
.ant-tree .ant-tree-node-content-wrapper &:hover {
background-color: none;
background: none;
}
}
.busList::-webkit-scrollbar-track {
background-color: rgba(3, 60, 158, 0.3);
border-radius: 1px
}
.busList::-webkit-scrollbar {
width: 5px;
}
.busList::-webkit-scrollbar-thumb {
background-color: rgba(28, 96, 254, 1);
border-radius: 1px
}

10
web/client/src/utils/webapi.js

@ -57,7 +57,10 @@ export const ApiTable = {
getzhichaomanager: 'manage/overspeed/processed', getzhichaomanager: 'manage/overspeed/processed',
//获取治超详情数据 //获取治超详情数据
getzhichaodetail: 'manage/overspeed', getzhichaodetail: '/manage/overspeed',
//大屏运营 —— 公交车辆层级信息
getBusTier:'/operation/car_level',
//获取路政列表 //获取路政列表
getHighways: 'road_manage', getHighways: 'road_manage',
@ -66,11 +69,10 @@ export const ApiTable = {
getRoadMaintenance: 'conserve/statistic', getRoadMaintenance: 'conserve/statistic',
//获取宣传数据 //获取宣传数据
getpropagata:'publicity' getpropagata:'publicity',
};
};
export const RouteTable = { export const RouteTable = {

Loading…
Cancel
Save