LineAnalysis.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <template>
  2. <Layout>
  3. <template #left>
  4. <div class="left">
  5. <div class="left-top">
  6. <Box
  7. v-for="(item, index) in leftContent.tCharts"
  8. :key="index"
  9. :width="680"
  10. :height="406"
  11. :name="item.name"
  12. >
  13. <Echart :option="item.option" />
  14. </Box>
  15. </div>
  16. <Box
  17. class="left-bottom"
  18. :width="1370"
  19. :height="818"
  20. :name="'近期调整线路'"
  21. >
  22. <div class="content">
  23. <div class="control">
  24. <SelectDate
  25. @date-change="selectDatechange"
  26. />
  27. <n-date-picker
  28. v-model:value="lineAdjustData.range"
  29. :bordered="false"
  30. type="daterange"
  31. style="width: 260px;"
  32. />
  33. </div>
  34. <div class="content-top">
  35. <div class="title">
  36. <icon
  37. :name="'1-6'"
  38. :size="30"
  39. />
  40. <div>线路调整总览</div>
  41. </div>
  42. <div class="overview">
  43. <div
  44. v-for="item,key in lineAdjustData.overview"
  45. :key="key"
  46. class="item"
  47. >
  48. <icon
  49. :name="'1-6'"
  50. :size="40"
  51. />
  52. <div class="name">
  53. {{ lineAdjustData.map[key] }}
  54. </div>
  55. <div class="num">
  56. {{ item }}
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="content-bottom">
  62. <div class="title">
  63. <icon
  64. :name="'1-6'"
  65. :size="30"
  66. />
  67. <div>线路调整详情</div>
  68. </div>
  69. <n-table
  70. striped
  71. size="large"
  72. :bordered="false"
  73. single-column
  74. :bottom-bordered="false"
  75. class="table"
  76. >
  77. <thead>
  78. <tr>
  79. <th> 序号 </th>
  80. <th> 措施 </th>
  81. <th> 区域 </th>
  82. <th> 线路 </th>
  83. <th> 线路类型 </th>
  84. <th> 时间 </th>
  85. </tr>
  86. </thead>
  87. <tbody>
  88. <tr
  89. v-for="item,index in lineAdjustData.tableData"
  90. :key="item"
  91. >
  92. <td> {{ index+1 }} </td>
  93. <td> {{ lineAdjustData.map[item.measure] }} </td>
  94. <td> {{ item.region }} </td>
  95. <td> {{ item.lineName }} </td>
  96. <td> {{ item.lineType }} </td>
  97. <td> {{ item.time }}</td>
  98. </tr>
  99. </tbody>
  100. </n-table>
  101. </div>
  102. </div>
  103. </Box>
  104. </div>
  105. </template>
  106. <template #right>
  107. <div class="right">
  108. <div class="right-top">
  109. <Box
  110. v-for="(item, index) in rightContent.tCharts"
  111. :key="index"
  112. :width="680"
  113. :height="406"
  114. :name="item.name"
  115. >
  116. <Echart :option="item.option" />
  117. </Box>
  118. </div>
  119. <Box
  120. class="right-center"
  121. :width="1370"
  122. :height="406"
  123. :name="'线路运行速度'"
  124. >
  125. <Echart :option="rightContent.center" />
  126. <div class="control">
  127. <SelectDate
  128. @date-change="rankDatechange"
  129. />
  130. <n-date-picker
  131. v-model:value="rankRange"
  132. :bordered="false"
  133. type="daterange"
  134. style="width: 260px;"
  135. />
  136. </div>
  137. </Box>
  138. <Box
  139. class="right-bottom"
  140. :width="1370"
  141. :height="406"
  142. :name="'站点客流排名'"
  143. >
  144. <Echart :option="rightContent.bottom" />
  145. <div class="control">
  146. <SelectDate
  147. @date-change="stationRankchange"
  148. />
  149. <n-date-picker
  150. v-model:value="stationRankRange"
  151. :bordered="false"
  152. type="daterange"
  153. style="width: 260px;"
  154. />
  155. </div>
  156. </Box>
  157. </div>
  158. </template>
  159. </Layout>
  160. </template>
  161. <script setup lang='ts'>
  162. import Layout from '@/components/layout.vue'
  163. import Box from '@/components/box.vue'
  164. import Echart from '@/components/chart.vue'
  165. import SelectDate from '@/components/selectDate.vue'
  166. import { ref, watch } from 'vue'
  167. import { graphic } from 'echarts'
  168. import LineAnalysisService from '../services/lineAnalysis.service'
  169. import { format, subDays } from 'date-fns'
  170. const leftContent = ref({
  171. tCharts: [
  172. {
  173. name: '线路类型',
  174. option: {
  175. grid: {
  176. containLabel: true
  177. },
  178. // 图表图例
  179. legend: {
  180. show: true,
  181. type: 'scroll',
  182. orient: 'horizontal', // 图例排列方向
  183. icon: 'circle', // 图例样式为圆形
  184. itemWidth: 10, // 图例图形的宽度
  185. itemHeight: 16, // 图例图形的高度
  186. itemGap: 10, // 图例项之间的间隔
  187. left: 'center', // 图例距离容器右侧的距离
  188. bottom: 0, // 图例垂直居中
  189. textStyle: {
  190. color: 'white', // 图例文字颜色
  191. fontSize: 20
  192. }
  193. },
  194. // color: [ '#6386e0', '#fb9a55', '#6bd98d', '#8dfd15', '#6bd98d', '#fff' ],
  195. series: [
  196. {
  197. type: 'pie', // 图表类型为饼图
  198. radius: '60%', // 控制内外圆环的半径,30%代表内圆,60%代表外圆
  199. avoidLabelOverlap: true, // 是否启用防止标签重叠策略
  200. showEmptyCircle: true, // 是否在无数据的时候显示一个占位圆
  201. label: {
  202. show: true,
  203. formatter: '{b}: {c}条',
  204. color: 'white'
  205. },
  206. data: [
  207. { key: 2, name: '常规', value: 130 },
  208. { key: 2, name: '快线', value: 50 },
  209. { key: 2, name: '特色线路', value: 50 }
  210. ]
  211. }
  212. ]
  213. }
  214. },
  215. {
  216. name: '区域里程',
  217. option: {
  218. tooltip: {
  219. trigger: 'axis',
  220. axisPointer: {
  221. type: 'shadow'
  222. }
  223. },
  224. grid: {
  225. top: 20,
  226. left: 20,
  227. bottom: 20,
  228. right: 20,
  229. containLabel: true
  230. },
  231. xAxis: {
  232. type: 'value',
  233. splitLine: {
  234. lineStyle: {
  235. color: '#fff'
  236. }
  237. },
  238. axisLabel: {
  239. color: '#fff',
  240. fontSize: 18
  241. }
  242. },
  243. yAxis: {
  244. type: 'category',
  245. inverse: true,
  246. axisTick: {
  247. alignWithLabel: true,
  248. lineStyle: {
  249. color: '#fff'
  250. }
  251. },
  252. axisLine: {
  253. lineStyle: {
  254. color: '#fff'
  255. }
  256. },
  257. data: [ '雨城区', '雨城区', '雨城区', '雨城区', '雨城区', '雨城区', '雨城区', '雨城区' ],
  258. axisLabel: {
  259. fontSize: 18,
  260. color: '#fff',
  261. margin: 10,
  262. rich: {
  263. a1: {
  264. backgroundColor: '#FFFF0050',
  265. width: 30,
  266. height: 28,
  267. align: 'center',
  268. borderRadius: 15,
  269. fontSize: 18,
  270. borderColor: '#FFFF00',
  271. borderType: 'solid',
  272. borderWidth: 1,
  273. padding: [ 2, 0, 0, 0 ]
  274. },
  275. a2: {
  276. backgroundColor: '#F2F2F250',
  277. width: 30,
  278. height: 28,
  279. align: 'center',
  280. borderRadius: 15,
  281. fontSize: 18,
  282. borderColor: '#F2F2F2',
  283. borderType: 'solid',
  284. borderWidth: 1,
  285. padding: [ 2, 0, 0, 0 ]
  286. },
  287. a3: {
  288. backgroundColor: '#FAAD0E50',
  289. width: 30,
  290. height: 28,
  291. align: 'center',
  292. borderRadius: 15,
  293. fontSize: 18,
  294. borderColor: '#FAAD0E',
  295. borderType: 'solid',
  296. borderWidth: 1,
  297. padding: [ 2, 0, 0, 0 ]
  298. },
  299. b: {
  300. backgroundColor: '#00FFFF50',
  301. width: 30,
  302. height: 28,
  303. align: 'center',
  304. borderRadius: 15,
  305. fontSize: 18,
  306. borderColor: '#00FFFF',
  307. borderType: 'solid',
  308. borderWidth: 1,
  309. padding: [ 2, 0, 0, 0 ]
  310. }
  311. },
  312. formatter: (params: string, _id: number) => {
  313. const id = _id + 1
  314. if (_id < 3) {
  315. return `{a${id}|${id}} ${params}`
  316. }
  317. return `{b|${id}} ${params}`
  318. }
  319. }
  320. },
  321. series: [
  322. {
  323. z: 2,
  324. name: 'value',
  325. type: 'bar',
  326. barWidth: 25,
  327. zlevel: 1,
  328. data: [ '80', '70', '60', '50', '40', '30', '20', '10' ],
  329. itemStyle: {
  330. borderRadius: [ 0, 16, 16, 0 ],
  331. color: new graphic.LinearGradient(0, 0, 1, 0, [
  332. {
  333. offset: 0,
  334. color: 'rgba(20,167,250,0.3)'
  335. },
  336. {
  337. offset: 1,
  338. color: 'rgba(0,255,209,1)'
  339. }
  340. ])
  341. },
  342. label: {
  343. position: 'inside',
  344. color: '#fff',
  345. fontSize: 16
  346. }
  347. }
  348. ]
  349. }
  350. }
  351. ]
  352. })
  353. const rightContent = ref({
  354. tCharts: [
  355. {
  356. name: '线路长度分布',
  357. option: {
  358. title: {
  359. text: '总', // 图标内容文本
  360. subtext: '200',
  361. left: 'center', // 图标内容水平居中
  362. top: 'center', // 图标内容垂直居中
  363. // 文本样式
  364. textStyle: {
  365. color: '#fff', // 图标内容文字颜色
  366. fontSize: '18px', // 图标内容文字大小
  367. fontWeight: 'normal'
  368. },
  369. subtextStyle: {
  370. color: '#fff', // 图标内容文字颜色
  371. fontSize: '18px', // 图标内容文字大小
  372. fontWeight: 'normal'
  373. }
  374. },
  375. grid: {
  376. containLabel: true
  377. },
  378. // 图表图例
  379. legend: {
  380. show: true,
  381. type: 'scroll',
  382. orient: 'horizontal', // 图例排列方向
  383. icon: 'circle', // 图例样式为圆形
  384. itemWidth: 10, // 图例图形的宽度
  385. itemHeight: 16, // 图例图形的高度
  386. itemGap: 10, // 图例项之间的间隔
  387. left: 'center', // 图例距离容器右侧的距离
  388. bottom: 0, // 图例垂直居中
  389. textStyle: {
  390. color: 'white', // 图例文字颜色
  391. fontSize: 20
  392. }
  393. },
  394. // color: [ '#6386e0', '#fb9a55', '#6bd98d', '#8dfd15', '#6bd98d', '#fff' ],
  395. series: [
  396. {
  397. type: 'pie', // 图表类型为饼图
  398. radius: [ '45%', '65%' ], // 控制内外圆环的半径,30%代表内圆,60%代表外圆
  399. avoidLabelOverlap: true, // 是否启用防止标签重叠策略
  400. showEmptyCircle: true, // 是否在无数据的时候显示一个占位圆
  401. label: {
  402. show: true,
  403. formatter: '{b} : {d}%',
  404. color: 'white'
  405. },
  406. data: [
  407. { key: 2, name: '5km', value: 180 },
  408. { key: 2, name: '5-10km', value: 50 },
  409. { key: 2, name: '10-15km', value: 30 },
  410. { key: 2, name: '15-20km', value: 20 },
  411. { key: 2, name: '20km', value: 10 }
  412. ]
  413. }
  414. ]
  415. }
  416. },
  417. {
  418. name: '线路占据分布',
  419. option: {
  420. title: {
  421. text: '总', // 图标内容文本
  422. subtext: '190',
  423. left: 'center', // 图标内容水平居中
  424. top: 'center', // 图标内容垂直居中
  425. // 文本样式
  426. textStyle: {
  427. color: '#fff', // 图标内容文字颜色
  428. fontSize: '18px', // 图标内容文字大小
  429. fontWeight: 'normal'
  430. },
  431. subtextStyle: {
  432. color: '#fff', // 图标内容文字颜色
  433. fontSize: '18px', // 图标内容文字大小
  434. fontWeight: 'normal'
  435. }
  436. },
  437. grid: {
  438. containLabel: true
  439. },
  440. // 图表图例
  441. legend: {
  442. show: true,
  443. type: 'scroll',
  444. orient: 'horizontal', // 图例排列方向
  445. icon: 'circle', // 图例样式为圆形
  446. itemWidth: 10, // 图例图形的宽度
  447. itemHeight: 16, // 图例图形的高度
  448. itemGap: 10, // 图例项之间的间隔
  449. left: 'center', // 图例距离容器右侧的距离
  450. bottom: 0, // 图例垂直居中
  451. textStyle: {
  452. color: 'white', // 图例文字颜色
  453. fontSize: 20
  454. }
  455. },
  456. // color: [ '#6386e0', '#fb9a55', '#6bd98d', '#8dfd15', '#6bd98d', '#fff' ],
  457. series: [
  458. {
  459. type: 'pie', // 图表类型为饼图
  460. radius: [ '45%', '65%' ], // 控制内外圆环的半径,30%代表内圆,60%代表外圆
  461. avoidLabelOverlap: true, // 是否启用防止标签重叠策略
  462. showEmptyCircle: true, // 是否在无数据的时候显示一个占位圆
  463. label: {
  464. show: true,
  465. formatter: '{b} : {d}%',
  466. color: 'white'
  467. },
  468. data: [
  469. { key: 2, name: '<300m', value: 180 },
  470. { key: 2, name: '300-500m', value: 50 },
  471. { key: 2, name: '300-1000m', value: 30 },
  472. { key: 2, name: '>1000m', value: 20 }
  473. ]
  474. }
  475. ]
  476. }
  477. }
  478. ],
  479. center: {
  480. grid: {
  481. containLabel: true,
  482. right: 30,
  483. left: 50,
  484. bottom: '25%',
  485. top: '20%'
  486. },
  487. legend: {
  488. show: true,
  489. left: 'center',
  490. bottom: '15%',
  491. itemWidth: 15,
  492. itemHeight: 10,
  493. textStyle: {
  494. color: '#646464',
  495. fontSize: 18
  496. }
  497. },
  498. xAxis: [ {
  499. type: 'category',
  500. axisLine: {
  501. show: false
  502. },
  503. axisLabel: {
  504. color: '#fff',
  505. fontSize: 18
  506. // formatter: (value: number) => format( 1'时')
  507. },
  508. splitLine: {
  509. show: false
  510. },
  511. axisTick: {
  512. show: false
  513. },
  514. data: [ '1时', '2时', '3时', '4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时' ]
  515. } ],
  516. yAxis: [ {
  517. name: 'km/h',
  518. nameLocation: 'center',
  519. nameGap: 50,
  520. nameTextStyle: {
  521. color: '#fff',
  522. fontSize: 18
  523. },
  524. padding: 5,
  525. // max: 1000,
  526. splitLine: {
  527. show: true,
  528. lineStyle: {
  529. color: '#A1A7B3'
  530. // type: 'dashed'
  531. }
  532. },
  533. axisLine: {
  534. show: false
  535. },
  536. axisLabel: {
  537. show: true,
  538. margin: 10,
  539. textStyle: {
  540. color: '#fff'
  541. }
  542. },
  543. axisTick: {
  544. show: false
  545. }
  546. }
  547. ],
  548. series: [ {
  549. name: '常规',
  550. type: 'line',
  551. smooth: true,
  552. symbolSize: 0,
  553. itemStyle: {
  554. normal: {
  555. // color: '#4293FD',
  556. lineStyle: {
  557. // color: '#4293FD',
  558. width: 2
  559. }
  560. }
  561. },
  562. data: [ 120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330 ]
  563. },
  564. {
  565. name: '快线',
  566. type: 'line',
  567. smooth: true,
  568. symbolSize: 0,
  569. itemStyle: {
  570. normal: {
  571. // color: '#23D0C4',
  572. lineStyle: {
  573. // color: '#23D0C4',
  574. width: 2
  575. }
  576. }
  577. },
  578. data: [ 220, 182, 191, 234, 290, 330, 310, 201, 154, 190, 330, 410 ]
  579. },
  580. {
  581. name: '特色线路',
  582. type: 'line',
  583. smooth: true,
  584. symbolSize: 0,
  585. itemStyle: {
  586. normal: {
  587. // color: '#23D0C4',
  588. lineStyle: {
  589. // color: '#23D0C4',
  590. width: 2
  591. }
  592. }
  593. },
  594. data: [ 220, 182, 191, 234, 290, 330, 310, 201, 154, 190, 330, 410 ]
  595. }
  596. ],
  597. dataZoom: {}
  598. },
  599. bottom: {
  600. grid: {
  601. containLabel: true,
  602. top: '35%',
  603. right: 30,
  604. left: 50,
  605. bottom: 0
  606. },
  607. tooltip: {
  608. trigger: 'axis',
  609. axisPointer: {
  610. type: 'shadow'
  611. }
  612. },
  613. legend: {
  614. top: 70,
  615. left: '50%',
  616. itemWidth: 18,
  617. itemHeight: 18,
  618. itemGap: 30,
  619. textStyle: {
  620. fontSize: 18,
  621. color: '#C9D2FA'
  622. }
  623. },
  624. xAxis: {
  625. // name: "班级",
  626. triggerEvent: true,
  627. data: [
  628. '雨城区',
  629. '芦山县',
  630. '名山县',
  631. '天全县',
  632. '宝兴县',
  633. '汉源县',
  634. '雨城区',
  635. '芦山县',
  636. '名山县',
  637. '天全县',
  638. '宝兴县',
  639. '汉源县'
  640. ],
  641. axisLabel: {
  642. interval: 0,
  643. show: true,
  644. fontSize: 18,
  645. color: '#C9D2FA'
  646. },
  647. axisLine: {
  648. show: false,
  649. lineStyle: {
  650. show: false,
  651. color: '#F3F3F3',
  652. width: 2
  653. }
  654. },
  655. axisTick: {
  656. show: false
  657. }
  658. },
  659. yAxis: [
  660. {
  661. name: '人数',
  662. nameLocation: 'center',
  663. nameGap: 50,
  664. nameTextStyle: {
  665. color: '#fff',
  666. fontSize: 18
  667. },
  668. splitNumber: 2,
  669. axisLabel: {
  670. show: true,
  671. fontSize: 18,
  672. color: '#C9D2FA'
  673. },
  674. axisLine: {
  675. show: false
  676. },
  677. axisTick: {
  678. show: false
  679. },
  680. splitLine: {
  681. lineStyle: {
  682. type: 'dashed',
  683. color: '#3E4A82'
  684. }
  685. }
  686. }
  687. ],
  688. series: [
  689. {
  690. name: '客流量',
  691. type: 'bar',
  692. silent: true,
  693. itemStyle: {
  694. normal: {
  695. color: new graphic.LinearGradient(
  696. 0,
  697. 0,
  698. 0,
  699. 1,
  700. [
  701. {
  702. offset: 0,
  703. color: '#FFD35D'// 0% 处的颜色
  704. },
  705. {
  706. offset: 0.5,
  707. color: '#7ec2f382'// 0% 处的颜色
  708. },
  709. {
  710. offset: 1,
  711. color: '#1890ff21' // 100% 处的颜色
  712. }
  713. ],
  714. false
  715. )
  716. }
  717. },
  718. barWidth: 30,
  719. data: [ 200, 108, 200, 40, 210, 100, 200, 108, 200, 40, 210, 100 ]
  720. }
  721. ]
  722. }
  723. })
  724. const lineAnalysisService = new LineAnalysisService()
  725. async function getAnalysisLineType() {
  726. const res = await lineAnalysisService.getAnalysisLineType()
  727. leftContent.value.tCharts[0].option.series[0].data = res.map((item:any) => ({
  728. name: item.type,
  729. value: item.number
  730. }))
  731. }
  732. getAnalysisLineType()
  733. async function getAnalysisRegionFlow() {
  734. const res = await lineAnalysisService.getAnalysisRegionFlow()
  735. const yData = []
  736. const seriesData = []
  737. for (let i = 0; i < res.length; i++) {
  738. const item = res[i]
  739. yData.push(item.region)
  740. seriesData.push(item.flow)
  741. }
  742. leftContent.value.tCharts[1].option.yAxis.data = yData
  743. leftContent.value.tCharts[1].option.series[0].data = seriesData
  744. }
  745. getAnalysisRegionFlow()
  746. const lineAdjustData = ref({
  747. range: [ subDays(Date.now(), 7), Date.now() ],
  748. type: 1,
  749. tableData: [] as any[],
  750. overview: {
  751. // 新辟
  752. 1: 0,
  753. // 撤销
  754. 2: 0,
  755. // 调整
  756. 3: 0
  757. },
  758. map: {
  759. 1: '新辟',
  760. 2: '撤销',
  761. 3: '调整'
  762. }as any
  763. })
  764. async function getAnalysisLineAdjust(params:any) {
  765. const res = await lineAnalysisService.getAnalysisLineAdjust(params)
  766. let total1 = 0
  767. let total2 = 0
  768. let total3 = 0
  769. for (let i = 0; i < res.length; i++) {
  770. const item = res[i]
  771. if (item.measure === 1) {
  772. total1++
  773. }
  774. if (item.measure === 2) {
  775. total2++
  776. }
  777. if (item.measure === 3) {
  778. total3++
  779. }
  780. }
  781. lineAdjustData.value.overview[1] = total1
  782. lineAdjustData.value.overview[2] = total2
  783. lineAdjustData.value.overview[3] = total3
  784. lineAdjustData.value.tableData = res
  785. }
  786. function selectDatechange(type: number) {
  787. lineAdjustData.value.type = type
  788. const params = {
  789. type: lineAdjustData.value.type
  790. }
  791. getAnalysisLineAdjust(params)
  792. }
  793. watch(() => lineAdjustData.value.range, () => {
  794. const params = {
  795. startTime: format(lineAdjustData.value.range[0], 'yyyy-MM-dd'),
  796. endTime: format(lineAdjustData.value.range[1], 'yyyy-MM-dd')
  797. }
  798. getAnalysisLineAdjust(params)
  799. }, { immediate: true })
  800. async function getAnalysisLineLength() {
  801. const res = await lineAnalysisService.getAnalysisLineLength()
  802. const seriesData = []
  803. let total = 0
  804. for (let i = 0; i < res.length; i++) {
  805. const item = res[i]
  806. seriesData.push({
  807. name: item.lengthType,
  808. value: item.proportion
  809. })
  810. total += +item.proportion
  811. }
  812. rightContent.value.tCharts[0].option.series[0].data = seriesData
  813. rightContent.value.tCharts[0].option.title.subtext = total
  814. }
  815. getAnalysisLineLength()
  816. async function getAnalysisLineDistance() {
  817. const res = await lineAnalysisService.getAnalysisLineDistance()
  818. const seriesData = []
  819. let total = 0
  820. for (let i = 0; i < res.length; i++) {
  821. const item = res[i]
  822. seriesData.push({
  823. name: item.distanceType,
  824. value: item.proportion
  825. })
  826. total += +item.proportion
  827. }
  828. rightContent.value.tCharts[1].option.series[0].data = seriesData
  829. rightContent.value.tCharts[1].option.title.subtext = total
  830. }
  831. getAnalysisLineDistance()
  832. const rankRange = ref([ subDays(Date.now(), 7), Date.now() ])
  833. async function getAnalysisLineOperate(params:any) {
  834. const res = await lineAnalysisService.getAnalysisLineOperate(params)
  835. const xAxisData = []
  836. const seriesData1 = []
  837. const seriesData2 = []
  838. const seriesData3 = []
  839. for (let i = 0; i < res.length; i++) {
  840. const item = res[i]
  841. xAxisData.push(item.time)
  842. seriesData1.push(item.conventionLine)
  843. seriesData2.push(item.expressLine)
  844. seriesData3.push(item.characteristicLine)
  845. }
  846. rightContent.value.center.xAxis[0].data = xAxisData
  847. rightContent.value.center.series[0].data = seriesData1
  848. rightContent.value.center.series[1].data = seriesData2
  849. rightContent.value.center.series[2].data = seriesData3
  850. }
  851. function rankDatechange(type: number) {
  852. const params = {
  853. type
  854. }
  855. getAnalysisLineOperate(params)
  856. }
  857. watch(() => rankRange.value, () => {
  858. const params = {
  859. startTime: format(rankRange.value[0], 'yyyy-MM-dd'),
  860. endTime: format(rankRange.value[1], 'yyyy-MM-dd')
  861. }
  862. getAnalysisLineOperate(params)
  863. }, { immediate: true })
  864. const stationRankRange = ref([ subDays(Date.now(), 7), Date.now() ])
  865. async function getAnalysisStationRank(params:any) {
  866. const res = await lineAnalysisService.getAnalysisStationRank(params)
  867. const groupData = groupBy(res, 'stationName')
  868. console.log(groupData, 'groupData')
  869. const xAxisData = []
  870. const seriesData1 = []
  871. for (const key in groupData) {
  872. const item = groupData[key]
  873. xAxisData.push(key)
  874. const total = item.reduce((prev: any, item: { flow: number }) => {
  875. prev += item.flow
  876. return prev
  877. }, 0)
  878. seriesData1.push(total)
  879. }
  880. rightContent.value.bottom.xAxis.data = xAxisData
  881. rightContent.value.bottom.series[0].data = seriesData1
  882. }
  883. function stationRankchange(type: number) {
  884. const params = {
  885. type
  886. }
  887. getAnalysisStationRank(params)
  888. }
  889. watch(() => stationRankRange.value, () => {
  890. const params = {
  891. startTime: format(stationRankRange.value[0], 'yyyy-MM-dd HH:mm:ss'),
  892. endTime: format(stationRankRange.value[1], 'yyyy-MM-dd HH:mm:ss')
  893. }
  894. getAnalysisStationRank(params)
  895. }, { immediate: true })
  896. function groupBy(array: any[], id: string) {
  897. const groups:any = {}
  898. array.forEach((o) => {
  899. let group = JSON.stringify(o[id])
  900. if (typeof o[id] === 'string') {
  901. group = o[id]
  902. }
  903. groups[group] = groups[group] || []
  904. groups[group].push(o)
  905. })
  906. // return Object.values(groups);
  907. return groups
  908. }
  909. </script>
  910. <style lang="scss" scoped>
  911. .left {
  912. &-top {
  913. display: flex;
  914. justify-content: space-between;
  915. }
  916. &-bottom {
  917. .content {
  918. width: 100%;
  919. padding: 35px;
  920. position: relative;
  921. .title {
  922. display: flex;
  923. gap: 10px;
  924. color: #FFFFFF;
  925. text-shadow: 1px 1px 10px rgba(0, 255, 255, 0.7);
  926. font-size: 20px;
  927. .icon {
  928. width: 30px;
  929. height: 30px;
  930. background: #000;
  931. }
  932. }
  933. .overview {
  934. display: flex;
  935. padding: 34px;
  936. justify-content: space-between;
  937. .item {
  938. width: 375px;
  939. height: 65px;
  940. background: rgba(27, 175, 255, 0.298);
  941. border: 1px solid #00FFFF;
  942. display: flex;
  943. align-items: center;
  944. justify-content: center;
  945. color: #FFFFFF;
  946. font-size: 20px;
  947. gap: 10px;
  948. .icon {
  949. width: 30px;
  950. height: 30px;
  951. background: #000;
  952. }
  953. .num {
  954. color: #00FFFF;
  955. font-size: 30px;
  956. font-family: Impact Normal;
  957. }
  958. }
  959. }
  960. .table{
  961. margin-top: 30px;
  962. text-align: center;
  963. th{
  964. border: 0;
  965. }
  966. }
  967. .control{
  968. position: absolute;
  969. top: 30px;
  970. right: 125px;
  971. .selectDate{
  972. top: 0px;
  973. left: -300px;
  974. }
  975. }
  976. }
  977. }
  978. }
  979. .right{
  980. &-top {
  981. display: flex;
  982. justify-content: space-between;
  983. }
  984. &-center,&-bottom {
  985. position: relative;
  986. .control{
  987. position: absolute;
  988. top: 60px;
  989. right: 110px;
  990. .selectDate{
  991. top: 0px;
  992. left: -300px;
  993. }
  994. }
  995. }
  996. }
  997. </style>