Browse Source

Merge branch 'dev' of https://gitea.anxinyun.cn/gao.zhiyuan/Highways4Good into dev

release_0.0.1
dengyinhuan 2 years ago
parent
commit
d8bf8ab801
  1. 19
      api/Dockerfile
  2. 2
      api/app/lib/models/bridge.js
  3. 2
      api/app/lib/models/report.js
  4. 19
      jenkinsfile_api
  5. 19
      jenkinsfile_web
  6. 2
      scripts/0.0.1/data/2_update_statistic_data.sql
  7. 17
      scripts/0.0.1/data/3_init_report_pic_data/.vscode/launch.json
  8. BIN
      scripts/0.0.1/data/3_init_report_pic_data/data/养护内容.xlsx
  9. 126
      scripts/0.0.1/data/3_init_report_pic_data/index.js
  10. 20
      scripts/0.0.1/data/3_init_report_pic_data/package.json
  11. 46
      scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js
  12. 4
      scripts/0.0.1/data/工具脚本(无需执行)/桥梁_数据脚本对应.sql
  13. 56597
      scripts/0.0.1/schema/1.init_table.sql
  14. 20
      web/Dockerfile
  15. 12
      web/client/src/sections/quanju/actions/example.js
  16. 47
      web/client/src/sections/quanju/containers/footer/conserve/chart/pie-chart.js
  17. 4
      web/client/src/sections/quanju/containers/footer/conserve/index.js
  18. 2
      web/client/src/sections/quanju/containers/footer/conserve/left/left-bottom.js
  19. 1
      web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js
  20. 2
      web/client/src/sections/quanju/containers/footer/conserve/right/right-bottom.js
  21. 29
      web/client/src/sections/quanju/containers/footer/operation/index.js
  22. 231
      web/client/src/sections/quanju/containers/footer/operation/left.js
  23. 31
      web/client/src/sections/quanju/containers/footer/operation/style.less
  24. 10
      web/client/src/utils/webapi.js

19
api/Dockerfile

@ -1,7 +1,4 @@
FROM repository.anxinyun.cn/devops/node:12-dev as builder
FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2
MAINTAINER liuxinyi "liu.xinyi@free-sun.com.cn"
COPY . /var/app COPY . /var/app
@ -9,6 +6,16 @@ WORKDIR /var/app
EXPOSE 8080 EXPOSE 8080
CMD ["-g", "postgres://FashionAdmin:123456@iota-m1:5433/SmartRiver", "--qnak", "5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu", "--qnsk", "w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5", "--qnbkt", "anxinyun-test", "--qndmn", "http://test.resources.anxinyun.cn"] RUN npm config set registry=http://10.8.30.22:7000
RUN echo "{\"time\":\"$BUILD_TIMESTAMP\",\"build\": \"$BUILD_NUMBER\",\"revision\": \"$SVN_REVISION_1\",\"URL\":\"$SVN_URL_1\"}" > version.json
RUN npm cache clean -f
RUN rm -rf package-lock.json
RUN npm install --registry http://10.8.30.22:7000
FROM registry.cn-hangzhou.aliyuncs.com/fs-devops/node:12
COPY --from=builder --chown=node /var/app /home/node/app
WORKDIR /home/node/app
ENTRYPOINT [ "node", "server.js" ] CMD ["node", "server.js"]

2
api/app/lib/models/bridge.js

@ -579,7 +579,7 @@ module.exports = dc => {
defaultValue: null, defaultValue: null,
comment: "工程性质", comment: "工程性质",
primaryKey: false, primaryKey: false,
field: "engineering_properties_", field: "engineering_properties",
autoIncrement: false autoIncrement: false
}, },
reconstructionPart: { reconstructionPart: {

2
api/app/lib/models/report.js

@ -125,7 +125,7 @@ module.exports = dc => {
}, },
userId: { userId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: false, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,

19
jenkinsfile_api

@ -0,0 +1,19 @@
pipeline {
agent {
node{
label 'jnlp-slave'
}
}
stages {
stage('Highways4Good Api ......') {
steps {
sh 'switch-auth.sh anxinyun'
buildName "#${BUILD_NUMBER} ~/fs-cloud/${JOB_NAME}:${IMAGE_VERSION}"
buildDescription "registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}"
sh 'docker build -t registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION} ./api'
sh 'docker push registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}'
}
}
}
}

19
jenkinsfile_web

@ -0,0 +1,19 @@
pipeline {
agent {
node{
label 'jnlp-slave'
}
}
stages {
stage('Highways4Good Web......') {
steps {
sh 'switch-auth.sh anxinyun'
buildName "#${BUILD_NUMBER} ~/fs-cloud/${JOB_NAME}:${IMAGE_VERSION}"
buildDescription "registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}"
sh 'docker build -t registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION} ./web'
sh 'docker push registry.cn-hangzhou.aliyuncs.com/${CLOUD}/${JOB_NAME}:${IMAGE_VERSION}'
}
}
}
}

2
scripts/0.0.1/data/1_update_statistic_data.sql → scripts/0.0.1/data/2_update_statistic_data.sql

@ -5,5 +5,5 @@ INSERT INTO statistic (name, count, type) values ('标志牌', 0, 'road_manage')
INSERT INTO statistic (name, count, type) values ('防护栏', 0, 'road_manage'); INSERT INTO statistic (name, count, type) values ('防护栏', 0, 'road_manage');
INSERT INTO statistic (name, count, type) values ('检查井', 0, 'road_manage'); INSERT INTO statistic (name, count, type) values ('检查井', 0, 'road_manage');
INSERT INTO statistic (name, count, type) values ('雨水口', 0, 'road_manage'); INSERT INTO statistic (name, count, type) values ('雨水口', 0, 'road_manage');
INSERT INTO statistic (name, count, type) values ('', 0, 'road_manage'); INSERT INTO statistic (name, count, type) values ('', 0, 'road_manage');
INSERT INTO statistic (name, count, type) values ('养护责任牌', 0, 'road_manage'); INSERT INTO statistic (name, count, type) values ('养护责任牌', 0, 'road_manage');

17
scripts/0.0.1/data/3_init_report_pic_data/.vscode/launch.json

@ -0,0 +1,17 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "启动程序",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\index.js"
}
]
}

BIN
scripts/0.0.1/data/3_init_report_pic_data/data/养护内容.xlsx

Binary file not shown.

126
scripts/0.0.1/data/3_init_report_pic_data/index.js

@ -0,0 +1,126 @@
try {
const { Pool, Client } = require('pg')
const request = require('superagent');
const Hex = require('crypto-js/enc-hex');
const MD5 = require('crypto-js/md5');
const XLSX = require('xlsx')
const path = require('path')
const fs = require("fs");
const qiniu = require('qiniu');
const uuidv4 = require('uuid/v4');
// 连接数据库
const pool = new Pool({
user: 'postgres',
host: '10.8.30.32',
database: 'highways4good',
password: '123',
port: 5432,
})
// 7niu 验证
const accessKey = 'XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5'
const secretKey = 'yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa'
const bucket = 'dev-highways4good'
const fun = async () => {
// note: we don't try/catch this because if connecting throws an exception
// we don't need to dispose of the client (it will be undefined)
const client = await pool.connect()
try {
await client.query('BEGIN')
console.log(`开始`);
const upload7niu =
async (filePath, filename) => {
return new Promise((resolve, reject) => {
try {
const uploadPath = 'images'
// 7niu 鉴权
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
const config = {
scope: bucket,
// expires: 3600,
returnBody: '{"key":"$(key)","hash":"$(etag)","fsize":$(fsize),"bucket":"$(bucket)","name":"$(x:name)"}'
}
var putPolicy = new qiniu.rs.PutPolicy(config);
var uploadToken = putPolicy.uploadToken(mac);
// 上传文件
var formUploader = new qiniu.form_up.FormUploader(config);
var putExtra = new qiniu.form_up.PutExtra();
let key = path.posix.join(uploadPath, uuidv4(), filename);
formUploader.putFile(uploadToken, key, filePath, putExtra, function (respErr,
respBody, respInfo) {
if (respErr) {
reject(respErr);
throw respErr;
}
if (respInfo.statusCode == 200) {
console.log(respBody);
let qnkey = respBody.key;
resolve({ key: qnkey, url: `/${qnkey}` });
} else {
console.log(respInfo.statusCode);
console.log(respBody);
reject(new Error('failed to upload.'));
}
});
} catch (err) {
reject(err);
}
});
}
// 读取数据文件
let workbook = XLSX.readFile(path.join(__dirname, './data/养护内容.xlsx'));
let firstSheetName = workbook.SheetNames[0];
let worksheet = workbook.Sheets[firstSheetName];
let res = XLSX.utils.sheet_to_json(worksheet, {
defval: ''
});
// console.log(res);
res.sort((a, b) => { return Date.parse(a['时间']) - Date.parse(b['时间']) });
// 读取全部图片
let pic = [];
fs.readdirSync(path.join(__dirname, '/data/图片')).forEach((filename) => {
pic.push({
path: `./data/图片/${filename}`,
name: filename
})
});
for (let r of res) {
console.log(r);
let picList = pic.filter(p => {
const { name } = p
const no = name.split('-')[0]
return no == r['编号']
})
console.log(picList);
// 将图片上传至 7niu
for (let p of picList) {
await upload7niu(path.join(__dirname, p.path), p.name)
}
break
}
// await client.query('ROLLBACK')
await client.query('COMMIT')
console.log('执行完毕~')
} catch (e) {
await client.query('ROLLBACK')
console.log('执行错误~')
throw e
} finally {
client.release();
}
}
fun()
} catch (error) {
console.error(error)
}

20
scripts/0.0.1/data/3_init_report_pic_data/package.json

@ -0,0 +1,20 @@
{
"name": "appkey-generator",
"version": "1.0.0",
"description": "tool",
"main": "index.js",
"scripts": {
"test": "mocha",
"start": "set NODE_ENV=development&&node index"
},
"author": "liu",
"license": "ISC",
"dependencies": {
"crypto-js": "^4.1.1",
"pg": "^7.18.2",
"qiniu": "^7.7.0",
"superagent": "^8.0.0",
"uuid": "3.1.0",
"xlsx": "^0.17.1"
}
}

46
scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js

@ -12,6 +12,7 @@ try {
user: 'postgres', user: 'postgres',
host: '10.8.30.32', host: '10.8.30.32',
database: 'highways4good', database: 'highways4good',
// database: 'highways4good_initdata',
password: '123', password: '123',
port: 5432, port: 5432,
}) })
@ -46,6 +47,11 @@ try {
// defaultValue: ['乡'], // defaultValue: ['乡'],
// }, // },
// { // {
// path: ['./data/桥梁/桥第三方.xls'],
// n: '桥梁',
// tableName: 'bridge'
// },
// {
// path: (() => { // path: (() => {
// let p = []; // let p = [];
// fs.readdirSync(path.join(__dirname, '/data/运政/车辆/出租车')).forEach((filename) => { // fs.readdirSync(path.join(__dirname, '/data/运政/车辆/出租车')).forEach((filename) => {
@ -71,26 +77,26 @@ try {
// defaultKey: ['type'], // defaultKey: ['type'],
// defaultValue: ['危货'], // defaultValue: ['危货'],
// }, // },
{ // {
path: ['./data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx'], // path: ['./data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx'],
n: '运政业户', // n: '运政业户',
tableName: 'municipal_business', // tableName: 'municipal_business',
defaultKey: ['type'], // defaultKey: ['type'],
defaultValue: ['出租车'], // defaultValue: ['出租车'],
}, // },
{ // {
path: (() => { // path: (() => {
let p = []; // let p = [];
fs.readdirSync(path.join(__dirname, '/data/运政/业户/危货')).forEach((filename) => { // fs.readdirSync(path.join(__dirname, '/data/运政/业户/危货')).forEach((filename) => {
p.push(`./data/运政/业户/危货/${filename}`) // p.push(`./data/运政/业户/危货/${filename}`)
}); // });
return p; // return p;
})(), // })(),
n: '运政业户', // n: '运政业户',
tableName: 'municipal_business', // tableName: 'municipal_business',
defaultKey: ['type'], // defaultKey: ['type'],
defaultValue: ['危货'], // defaultValue: ['危货'],
}, // },
// { // {
// path: ['./data/工程一览/道路.xls'], // path: ['./data/工程一览/道路.xls'],
// n: '工程一览', // n: '工程一览',

4
scripts/0.0.1/data/工具脚本(无需执行)/桥梁_数据脚本对应.sql

@ -65,8 +65,8 @@ ON column bridge.Nature_Of_Management_And_Maintenance_Unit is '管养单位性
ON column bridge.Management_And_Maintenance_Unit is '管养单位'; alter TABLE bridge add Supervision_Unit varchar(1024); comment ON column bridge.Management_And_Maintenance_Unit is '管养单位'; alter TABLE bridge add Supervision_Unit varchar(1024); comment
ON column bridge.Supervision_Unit is '监管单位'; alter TABLE bridge add Reconstruction_Construction_Unit varchar(1024); comment ON column bridge.Supervision_Unit is '监管单位'; alter TABLE bridge add Reconstruction_Construction_Unit varchar(1024); comment
ON column bridge.Reconstruction_Construction_Unit is '改造施工单位'; alter TABLE bridge add Whether_It_Is_A_Subsidy_Project_Of_The_Ministry varchar(1024); comment ON column bridge.Reconstruction_Construction_Unit is '改造施工单位'; alter TABLE bridge add Whether_It_Is_A_Subsidy_Project_Of_The_Ministry varchar(1024); comment
ON column bridge.Whether_It_Is_A_Subsidy_Project_Of_The_Ministry is '是否部补助项目'; alter TABLE bridge add Engineering_Properties_ varchar(1024); comment ON column bridge.Whether_It_Is_A_Subsidy_Project_Of_The_Ministry is '是否部补助项目'; alter TABLE bridge add Engineering_Properties varchar(1024); comment
ON column bridge.Engineering_Properties_ is '工程性质'; alter TABLE bridge add Reconstruction_Part varchar(1024); comment ON column bridge.Engineering_Properties is '工程性质'; alter TABLE bridge add Reconstruction_Part varchar(1024); comment
ON column bridge.Reconstruction_Part is '改造部位'; alter TABLE bridge add Modification_Completion_Date varchar(1024); comment ON column bridge.Reconstruction_Part is '改造部位'; alter TABLE bridge add Modification_Completion_Date varchar(1024); comment
ON column bridge.Modification_Completion_Date is '改造完工日期'; alter TABLE bridge add Year_1 varchar(1024); comment ON column bridge.Modification_Completion_Date is '改造完工日期'; alter TABLE bridge add Year_1 varchar(1024); comment
ON column bridge.Year_1 is '年份1'; alter TABLE bridge add Span_Combination_1 varchar(1024); comment ON column bridge.Year_1 is '年份1'; alter TABLE bridge add Span_Combination_1 varchar(1024); comment

56597
scripts/0.0.1/schema/1.init_table.sql

File diff suppressed because it is too large

20
web/Dockerfile

@ -1,5 +1,4 @@
FROM repository.anxinyun.cn/devops/node:12-dev as builder
FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2
COPY . /var/app COPY . /var/app
@ -7,6 +6,19 @@ WORKDIR /var/app
EXPOSE 8080 EXPOSE 8080
CMD ["-u", "http://localhost:8088"] RUN npm config set registry=http://10.8.30.22:7000
RUN echo "{\"time\":\"$BUILD_TIMESTAMP\",\"build\": \"$BUILD_NUMBER\",\"revision\": \"$SVN_REVISION_1\",\"URL\":\"$SVN_URL_1\"}" > version.json
RUN npm cache clean -f
RUN npm install --registry http://10.8.30.22:7000
RUN npm run build
RUN rm -rf client/src
RUN rm -rf node_modules
RUN npm install --production --registry http://10.8.30.22:7000
FROM registry.cn-hangzhou.aliyuncs.com/fs-devops/node-16:7.22-06-20
COPY --from=builder --chown=node /var/app /home/node/app
WORKDIR /home/node/app
ENTRYPOINT [ "node", "server.js" ] CMD ["node", "server.js"]

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

@ -63,3 +63,15 @@ export function getxuanchuan() {
// 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' }
});
}

47
web/client/src/sections/quanju/containers/footer/conserve/chart/pie-chart.js

@ -4,7 +4,7 @@ import * as echarts from 'echarts';
const PieChart = (props) => { const PieChart = (props) => {
const { width, height, data, colorList, underColorList, total, text } = props const { width, height, data, colorList, underColorList, total, text, textLeft,numLeft } = props
const chartRef = useRef(null); const chartRef = useRef(null);
let name = [], emptyName = [] let name = [], emptyName = []
// const name = data?.map(d) // const name = data?.map(d)
@ -43,13 +43,13 @@ const PieChart = (props) => {
a: { a: {
color: '#E9F7FF', color: '#E9F7FF',
fontSize: 14, fontSize: 14,
padding:[0,2] padding: [0, 2]
}, },
b: { b: {
fontSize: 16, fontSize: 16,
fontFamily: 'YouSheBiaoTiHei', fontFamily: 'YouSheBiaoTiHei',
color: '#fff', color: '#fff',
padding:[0,0,0,10] padding: [0, 0, 0, 10]
}, },
} }
} }
@ -57,40 +57,17 @@ const PieChart = (props) => {
grid: { grid: {
left: '10%' left: '10%'
}, },
// title: [
// {
// text: text,
// top: "58%",
// left: '16%',
// textStyle: {
// color: "#E9F7FF",
// fontSize: 14,
// },
// },
// {
// text: total,
// top: "40%",
// left: '10%',
// textStyle: {
// fontSize: "30",
// color: "#FFFFFF",
// fontFamily: "YouSheBiaoTiHei",
// },
// },
// ],
graphic: { graphic: {
elements: [ elements: [
{ {
type: 'image', type: 'image',
style: { style: {
image: 'assets/images/quanju/chart-circle.png', image: 'assets/images/quanju/chart-circle.png',
width: 120, width: 110,
height: 120, height: 110,
align: 'center', align: 'center',
// x:90,
// y:100
}, },
left: '14%', left: '12.8%',
top: 'center', top: 'center',
bounding: 'raw' bounding: 'raw'
@ -101,11 +78,11 @@ const PieChart = (props) => {
style: { style: {
text: text, text: text,
align: 'center', align: 'center',
fill: '#fff', fill: '#E9F7FF',
font: '12px "YouSheBiaoTiHei", sans-serif', font: '12px',
}, },
left: '17%', left: textLeft,
top: '55%', top: '58%',
}, },
{ {
type: 'text', type: 'text',
@ -115,7 +92,7 @@ const PieChart = (props) => {
fill: '#fff', fill: '#fff',
font: '20px "YouSheBiaoTiHei", sans-serif', font: '20px "YouSheBiaoTiHei", sans-serif',
}, },
left: '18.5%', left: numLeft,
top: 'center', top: 'center',
}, },
], ],
@ -142,7 +119,7 @@ const PieChart = (props) => {
data: emptyName, data: emptyName,
}, },
{ {
name: "已绿化里程统计", name: text,
type: "pie", type: "pie",
radius: ["65%", "75%"], radius: ["65%", "75%"],
center: ['25%', '50%'], center: ['25%', '50%'],

4
web/client/src/sections/quanju/containers/footer/conserve/index.js

@ -28,10 +28,12 @@ const Conserve = (props) => {
}, []) }, [])
return ( return (
<div style={{ display: 'flex', width: '100%', height: '100%', justifyContent: 'space-between' }}> <div style={{ width: '100%', height: '100%', }}>
<div style={{ display: 'flex', width: '100%', height: '100%', justifyContent: 'space-between' }}>
<Left roadData={roadData} loading={loading} /> <Left roadData={roadData} loading={loading} />
<Right highwaysData={highwaysData} roadMaintenances={roadMaintenances}/> <Right highwaysData={highwaysData} roadMaintenances={roadMaintenances}/>
</div> </div>
</div>
) )
} }
function mapStateToProps(state) { function mapStateToProps(state) {

2
web/client/src/sections/quanju/containers/footer/conserve/left/left-bottom.js

@ -36,6 +36,8 @@ const LeftBottom = (props) => {
text='已绿化里程' text='已绿化里程'
total={totalData?.toFixed(3) || 0} total={totalData?.toFixed(3) || 0}
colorList={colorList} colorList={colorList}
textLeft={'20%'}
numLeft={'16%'}
underColorList={underColorList} underColorList={underColorList}
/> />
</Module> </Module>

1
web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js

@ -37,6 +37,7 @@ const LeftCenter = (props) => {
axisPointer: { axisPointer: {
type: "none", type: "none",
}, },
formatter: "{b}:{c}",
}, },
grid: { grid: {
left: "5%", left: "5%",

2
web/client/src/sections/quanju/containers/footer/conserve/right/right-bottom.js

@ -56,6 +56,8 @@ const RightBottom = (props) => {
width='100%' width='100%'
height='100%' height='100%'
text='养护总数' text='养护总数'
textLeft={'21%'}
numLeft={'23%'}
total={totalData || 0} total={totalData || 0}
colorList={colorList} colorList={colorList}
underColorList={underColorList} underColorList={underColorList}

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);

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

@ -0,0 +1,31 @@
.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;
// border: 1px solid rgba(10, 114, 255, 1);
}
}
.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