Detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template>
  2. <div class="app-container">
  3. <el-row
  4. :gutter="20"
  5. style="
  6. height: 200px;
  7. font-size: 12px;
  8. color: #333333;
  9. margin-bottom: 20px;
  10. "
  11. >
  12. <el-col :span="6">
  13. <el-card class="card">
  14. <strong>天气</strong>
  15. <span style="color: #999999; margin-left: 34px">
  16. {{ getDateTime() }}
  17. </span>
  18. <div style="clear: both" />
  19. <div style="margin-top: 30px">
  20. <el-image
  21. src="/images/rain@3x.png"
  22. style="width: 30px"
  23. v-if="qweather.now.weatherName === '雨'"
  24. />
  25. <el-image
  26. src="/images/snow@3x.png"
  27. style="width: 30px"
  28. v-else-if="qweather.now.weatherName === '雪'"
  29. />
  30. <el-image
  31. src="/images/cloud@3x.png"
  32. style="width: 30px"
  33. v-else-if="qweather.now.weatherName === '云'"
  34. />
  35. <el-image src="/images/sun@3x.png" style="width: 30px" v-else />
  36. <span style="font-size: 20px; margin-left: 24px">
  37. {{ qweather.now.temp }}
  38. </span>
  39. <span>℃</span>
  40. <span style="color: #ffaa33; margin-left: 10px">
  41. {{ qweatherAir.now.text }}
  42. </span>
  43. </div>
  44. <el-divider />
  45. <span style="color: #666666">
  46. {{ qweather.now.windDir }} {{ qweather.now.windScale }}级
  47. </span>
  48. <el-divider direction="vertical" style="padding: 0 10px" />
  49. <span
  50. style="
  51. display: inline-block;
  52. background: #f37868;
  53. padding: 2px 8px;
  54. color: white;
  55. border-radius: 2px;
  56. "
  57. >
  58. 体感温度&nbsp;&nbsp;{{
  59. sendibleTemperature(qweather.now.feelsLike)
  60. }}
  61. </span>
  62. </el-card>
  63. </el-col>
  64. <el-col :span="6">
  65. <el-card class="card">
  66. <strong>空气质量</strong>
  67. <el-row style="margin-top: 40px">
  68. <el-col :span="11" style="text-align: center">
  69. <div style="color: #999999">空气质量指数</div>
  70. <div style="color: #45ca9d; line-height: 85px; font-size: 50px">
  71. {{ qweatherAir.now.aqi }}
  72. </div>
  73. </el-col>
  74. <el-col :span="2">
  75. <el-divider direction="vertical" class="vertical-divider-100" />
  76. </el-col>
  77. <el-col :span="11" class="air-quality-info">
  78. <div>首要污染物:{{ qweatherAir.now.primary }}</div>
  79. <div>PM2.5:{{ qweatherAir.now.pm2p5 }}</div>
  80. <div>空气质量:{{ qweatherAir.now.category }}</div>
  81. </el-col>
  82. </el-row>
  83. </el-card>
  84. </el-col>
  85. <el-col :span="6">
  86. <el-card class="card">
  87. <strong>交通情况</strong>
  88. <div
  89. @click="goToTraffic()"
  90. style="
  91. color: #45ca9d;
  92. font-size: 30px;
  93. line-height: 50px;
  94. padding: 25px 0;
  95. text-align: center;
  96. "
  97. >
  98. 畅通
  99. </div>
  100. <el-row>
  101. <el-col :span="12">
  102. <div style="background: #d34400" class="sample-block" />
  103. 严重拥挤
  104. </el-col>
  105. <el-col :span="12">
  106. <div style="background: #ff8b33" class="sample-block" />
  107. 拥挤
  108. </el-col>
  109. </el-row>
  110. <div style="height: 10px" />
  111. <el-row>
  112. <el-col :span="12">
  113. <div style="background: #ffaa33" class="sample-block" />
  114. 缓行
  115. </el-col>
  116. <el-col :span="12">
  117. <div style="background: #45ca9d" class="sample-block" />
  118. 畅通
  119. </el-col>
  120. </el-row>
  121. </el-card>
  122. </el-col>
  123. <el-col :span="6">
  124. <el-card class="card">
  125. <strong>负氧离子</strong>
  126. <el-row style="margin-top: 40px">
  127. <el-col :span="11" style="text-align: center">
  128. <div style="color: #999999">负氧离子(个/cm3)</div>
  129. <div style="color: #45ca9d; line-height: 85px; font-size: 50px">
  130. 1688
  131. </div>
  132. </el-col>
  133. <el-col :span="2">
  134. <el-divider direction="vertical" class="vertical-divider-100" />
  135. </el-col>
  136. <el-col :span="11" class="air-quality-info">
  137. <div>湿度:{{ qweather.now.humidity }}%</div>
  138. <div>气压:{{ qweather.now.pressure }}Pa</div>
  139. </el-col>
  140. </el-row>
  141. </el-card>
  142. </el-col>
  143. </el-row>
  144. <el-row :gutter="20" style="margin-bottom: 20px">
  145. <el-col :span="8">
  146. <el-card>
  147. <div slot="header">节假日访客数量</div>
  148. <div id="visitorsListEchart" style="width: 100%; height: 200px"></div>
  149. </el-card>
  150. </el-col>
  151. <el-col :span="8">
  152. <el-card>
  153. <div slot="header">节假日访客停留时长(分钟)</div>
  154. <div id="timersListEchart" style="width: 100%; height: 200px"></div>
  155. </el-card>
  156. </el-col>
  157. <el-col :span="8">
  158. <el-card>
  159. <div slot="header">出入境数据</div>
  160. <div id="entryAndExitEchart" style="width: 100%; height: 200px"></div>
  161. </el-card>
  162. </el-col>
  163. </el-row>
  164. <el-card style="margin-bottom: 20px">
  165. <div slot="header">实时概况</div>
  166. <el-row>
  167. <el-col :span="4">
  168. <p style="font-size: 14px">流入量</p>
  169. <p style="font-size: 20px">{{ detailData.inCount }}</p>
  170. </el-col>
  171. <el-col :span="4">
  172. <p style="font-size: 14px">流出量</p>
  173. <p style="font-size: 20px">{{ detailData.outCount }}</p>
  174. </el-col>
  175. <el-col :span="4">
  176. <p style="font-size: 14px">总接待人数</p>
  177. <p style="font-size: 20px">
  178. {{ Number(detailData.inCount) + Number(detailData.outCount) }}
  179. </p>
  180. </el-col>
  181. <el-col :span="4">
  182. <p style="font-size: 14px">实时容量</p>
  183. <p style="font-size: 20px">
  184. {{ detailData.inCount - detailData.outCount > 0 ? detailData.inCount - detailData.outCount : 0 }}
  185. </p>
  186. </el-col>
  187. <el-col :span="4">
  188. <p style="font-size: 14px">平均停留时长</p>
  189. <p style="font-size: 20px">
  190. {{ detailData.avgStayTime ? detailData.avgStayTime : 0 }}
  191. </p>
  192. </el-col>
  193. </el-row>
  194. </el-card>
  195. <el-row :gutter="16">
  196. <el-col :span="12">
  197. <el-card>
  198. <div slot="header">性别</div>
  199. <div id="gender-box" style="width: 100%; height: 200px" />
  200. </el-card>
  201. </el-col>
  202. <el-col :span="12">
  203. <el-card>
  204. <div slot="header">来源</div>
  205. <div id="from-source-box" style="width: 100%; height: 200px" />
  206. </el-card>
  207. </el-col>
  208. <!-- <el-col :span="8">
  209. <el-card>
  210. <el-row
  211. v-for="item in detailData.listFromSource"
  212. :key="item.name"
  213. style="margin: 12px 0"
  214. >
  215. <el-col :span="12">{{ item.name }}</el-col>
  216. <el-col :span="12">{{ item.value }}人次</el-col>
  217. </el-row>
  218. </el-card>
  219. </el-col> -->
  220. </el-row>
  221. </div>
  222. </template>
  223. <style>
  224. .card {
  225. width: 100%;
  226. height: 200px;
  227. float: left;
  228. }
  229. .card strong {
  230. font-size: 24px;
  231. }
  232. .vertical-divider-100 {
  233. height: 88px;
  234. }
  235. .air-quality-info {
  236. font-size: 12px;
  237. color: #999999;
  238. line-height: 30px;
  239. }
  240. .sample-block {
  241. width: 20px;
  242. height: 10px;
  243. display: inline-block;
  244. margin-right: 5px;
  245. }
  246. </style>
  247. <script>
  248. import * as echarts from 'echarts'
  249. import { findDetail, qweatherGet, qweatherAir, ambitusRoadConditions } from '@/api/equipment/equipment_passenger'
  250. import { passenger } from '@/api/bz/monitor'
  251. export default {
  252. components: {},
  253. data() {
  254. return {
  255. detailData: {},
  256. qweather: { now: {} },
  257. qweatherAir: { now: {} }
  258. }
  259. },
  260. computed: {},
  261. mounted() {
  262. const id = this.$route.params.id
  263. const queryForm = this.$route.query;
  264. findDetail(id, queryForm.orgId).then(detailData => {
  265. if (detailData.latLng) {
  266. const latLng = detailData.latLng.split(/,/g);
  267. detailData.lat = latLng[0];
  268. detailData.lng = latLng[1];
  269. }
  270. this.detailData = detailData
  271. this.buildVisitorsList('visitorsListEchart', this.detailData.visitorsList);
  272. this.buildVisitorsList('timersListEchart', this.detailData.visitorsList.map(r => {
  273. r.value = r.value > 10000 ? 113 : 96;
  274. return r;
  275. }));
  276. this.loadQweather();
  277. const crj = [{ label: '出境', value: detailData.outCount }, { label: '入境', value: detailData.inCount }]
  278. this.buildVisitorsList('entryAndExitEchart', crj);
  279. this.buildFromSource(detailData.listFromSource.map(r => {
  280. r.name = r.label;
  281. return r;
  282. }));
  283. let gender = [{ name: '男', value: 0 }, { name: '女', value: 0 }]
  284. const genderBox = detailData.listGenders;
  285. if (genderBox) gender = [{ name: '男', value: genderBox.male }, { name: '女', value: genderBox.female }];
  286. this.buildGender(gender);
  287. })
  288. // passenger({ orgId: queryForm.orgId }).then(data => {
  289. // let gender = [{ name: '男', value: 0 }, { name: '女', value: 0 }]
  290. // const genderList = data.spot;
  291. // if (genderList != null && genderList.length > 0) {
  292. // gender = gender.map(r => {
  293. // const filter = genderList.filter(l => l.name === r.label);
  294. // if (filter != null && filter.length > 0) {
  295. // r.value = filter[0].value;
  296. // }
  297. // return r;
  298. // });
  299. // }
  300. // this.buildGender(gender);
  301. // })
  302. },
  303. methods: {
  304. loadQweather() {
  305. qweatherGet(this.detailData.lat, this.detailData.lng).then(data => {
  306. this.qweather = data;
  307. });
  308. qweatherAir(this.detailData.lat, this.detailData.lng).then(data => {
  309. this.qweatherAir = data;
  310. });
  311. ambitusRoadConditions(this.detailData.lat, this.detailData.lng).then(data => {
  312. console.log(data);
  313. });
  314. },
  315. sendibleTemperature(temperature) {
  316. if (temperature < 8) {
  317. return '冷';
  318. } else if (temperature < 18 && temperature >= 8) {
  319. return '凉爽';
  320. } else if (temperature < 29 && temperature >= 18) {
  321. return '舒适';
  322. } else if (temperature >= 29) {
  323. return '热';
  324. } else {
  325. return '正常';
  326. }
  327. },
  328. goToTraffic() {
  329. const lat = this.detailData.lat;
  330. const lng = this.detailData.lng;
  331. this.$router.push(`/equipment/passenger/traffic?lat=${lat}&lng=${lng}`)
  332. },
  333. dateFilter: function (date) {
  334. if (date < 10) {
  335. return "0" + date;
  336. }
  337. return date;
  338. },
  339. getDateTime() {
  340. var dateObj = new Date(); //表示当前系统时间的Date对象
  341. var year = dateObj.getFullYear(); //当前系统时间的完整年份值
  342. var month = dateObj.getMonth() + 1; //当前系统时间的月份值
  343. var date = dateObj.getDate(); //当前系统时间的月份中的日
  344. var day = dateObj.getDay(); //当前系统时间中的星期值
  345. var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  346. var week = weeks[day]; //根据星期值,从数组中获取对应的星期字符串
  347. var hour = dateObj.getHours(); //当前系统时间的小时值
  348. var timeValue = "" + ((hour >= 12) ? (hour >= 18) ? "晚上" : "下午" : "上午"); //当前时间属于上午、晚上还是下午
  349. return this.dateFilter(month) + "月" + this.dateFilter(date) + "日 " + " " + week + " " + timeValue;
  350. },
  351. buildVisitorsList(chartId, visitorsList) {
  352. const chart = echarts.init(document.getElementById(chartId));
  353. const data = visitorsList.map(v => v.label);
  354. const series = { name: '', type: 'bar', data: visitorsList.map(v => v.value) };
  355. chart.setOption({
  356. tooltip: {
  357. trigger: 'axis',
  358. axisPointer: {
  359. type: 'shadow'
  360. }
  361. },
  362. grid: {
  363. top: '10px',
  364. left: '80px',
  365. right: '25px',
  366. bottom: '20px'
  367. },
  368. xAxis: {
  369. type: 'category',
  370. data: data
  371. },
  372. yAxis: {
  373. type: 'value',
  374. boundaryGap: [0, 0.01]
  375. },
  376. series: series
  377. });
  378. },
  379. buildGender(listGenders) {
  380. const chart = echarts.init(document.getElementById('gender-box'))
  381. chart.setOption({
  382. tooltip: {
  383. trigger: 'item'
  384. },
  385. legend: {
  386. top: 'center',
  387. right: '0',
  388. orient: 'vertical'
  389. },
  390. grid: {
  391. left: '8%',
  392. right: '10%',
  393. bottom: '1%',
  394. containLabel: true
  395. },
  396. series: [
  397. {
  398. name: '客流性别',
  399. type: 'pie',
  400. radius: ['60%', '90%'],
  401. avoidLabelOverlap: false,
  402. label: {
  403. show: false
  404. },
  405. labelLine: {
  406. show: false
  407. },
  408. data: listGenders
  409. }
  410. ]
  411. })
  412. },
  413. buildFromSource(listFromSource) {
  414. const chart = echarts.init(document.getElementById('from-source-box'))
  415. chart.setOption({
  416. tooltip: {
  417. trigger: 'item'
  418. },
  419. legend: {
  420. top: 'center',
  421. right: '0',
  422. orient: 'vertical'
  423. },
  424. grid: {
  425. left: '8%',
  426. right: '10%',
  427. bottom: '1%',
  428. containLabel: true
  429. },
  430. series: [
  431. {
  432. name: '客流来源地',
  433. type: 'pie',
  434. radius: ['60%', '90%'],
  435. avoidLabelOverlap: false,
  436. label: {
  437. show: false
  438. },
  439. labelLine: {
  440. show: false
  441. },
  442. data: listFromSource
  443. }
  444. ]
  445. })
  446. }
  447. }
  448. }
  449. </script>