健康同学微信公众号h5项目
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. <template>
  2. <!-- 周/月报 -->
  3. <div class="report">
  4. <NavBar title="周报" @on-click-left="onNavBack" right-text="历史"> </NavBar>
  5. <div class="main">
  6. <div class="periodNav">
  7. <div
  8. class="periodItem minPeriodItem"
  9. :class="{ active: signActive == index }"
  10. v-for="(item, index) in signList"
  11. :key="index"
  12. @click="onSignClick(index)"
  13. >
  14. <span>{{ item.name }}</span>
  15. </div>
  16. </div>
  17. <!-- 总评 -->
  18. <div class="overall-rating">
  19. <div class="con">
  20. <p class="space-between">
  21. <span class="bold">本周总评</span>
  22. <span class="time">{{ resetDate(weekResult.StartDate, weekResult.EndDate) || '--' }}</span>
  23. </p>
  24. <p class="bold-pro" :style="{ color: calcResultColor(weekResult.SummaryLevel) || '--' }">
  25. {{ weekResult.Summary }}
  26. </p>
  27. <p class="normal">监测次数: {{ weekResult.Total || '--' }}次</p>
  28. <p class="normal">{{ weekResult.Explain || '--' }}</p>
  29. </div>
  30. </div>
  31. <div class="line"></div>
  32. <div class="pie-chart-top">
  33. <p class="bold">上周趋势对比</p>
  34. <p>{{ resetDate(weekResult.StartDate, weekResult.EndDate) || '--' }}</p>
  35. </div>
  36. <div class="count">
  37. <p>监测次数:{{ weekResult.LastTotal || '--' }}次</p>
  38. </div>
  39. <!-- 趋势对比-饼状图 -->
  40. <div class="pie-chart-con">
  41. <div class="pie-chart-left">
  42. <div id="pieChart" ref="pieChart"></div>
  43. </div>
  44. <div class="pie-chart-right">
  45. <div class="list">
  46. <div class="item" v-for="(item, index) in pieRightList" :key="index">
  47. <div class="item-left">
  48. <div class="circle" :style="{ backgroundColor: item.color }"></div>
  49. <span class="text">{{ item.text || '--' }}</span>
  50. </div>
  51. <div class="item-right">
  52. <span :style="{ color: item.color }">{{ item.count ? item.count + '次' : '0次' }}</span>
  53. <label :style="{ color: item.color }">{{
  54. item.percentage ? '(' + item.percentage + '%' + ')' : '(0%)'
  55. }}</label>
  56. </div>
  57. <div class="status">
  58. <img :src="calcImg(item.percentage, item.lastPercentage)" alt="" />
  59. <span :style="{ color: calcImg(item.percentage, item.lastPercentage, true) != 0 ? item.color : '' }">{{
  60. calcImg(item.percentage, item.lastPercentage, true)
  61. ? Math.abs(calcImg(item.percentage, item.lastPercentage, true)) + '%'
  62. : '持平'
  63. }}</span>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <div class="statistics">
  70. <div class="list">
  71. <div
  72. class="item"
  73. v-for="(item, index) in statisticsList"
  74. :key="index"
  75. :style="{ backgroundColor: item.bgColor }"
  76. >
  77. <div class="top">
  78. <span>{{ item.label || '--' }}</span>
  79. </div>
  80. <div class="middle">
  81. <span>{{ item.value || '--' }}</span>
  82. </div>
  83. <div class="bottom">
  84. <span>{{ item.time || '--' }}</span>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="line"></div>
  90. <!-- 24小时 -->
  91. <!-- <div class="chart-title">
  92. <p>24小时{{ emoName }}时间分布图</p>
  93. </div> -->
  94. <div class="scatter">
  95. <EchartBox
  96. echartId="scatterCharts"
  97. outTitle="24小时抑郁时间分布图"
  98. :border="false"
  99. height="200"
  100. width="200"
  101. :options="scatterOptions"
  102. >
  103. <template #custom-bot>
  104. <div class="custom-bot">
  105. <div class="list">
  106. <div class="item" v-for="(item, index) in timeList" :key="index">
  107. <span>{{ item }}</span>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. </EchartBox>
  113. </div>
  114. <div class="chart-title">
  115. <p>{{ echartsTitle }}</p>
  116. </div>
  117. <!-- 数据图-柱形图 -->
  118. <div class="bar-chart">
  119. <div class="echart">
  120. <EchartBox echartId="charts" height="200" width="200" :legend="emoLegend" :options="emoOptions"></EchartBox>
  121. </div>
  122. </div>
  123. <div class="line"></div>
  124. <!-- 建议 -->
  125. <div class="advice">
  126. <div class="content">
  127. <p class="title">健康建议</p>
  128. <!-- <p>{{ weekResult.Advice || '--' }}</p> -->
  129. <p>
  130. 健康建议抑郁是一种负性情绪,是人们遇到具体生活事件后,出现
  131. 的一种不愉快、烦闷压抑的内心体验。情绪受挫折的影响是很正常
  132. 的反应,不要任由情绪跟着负面想法走,让自己陷入抑郁之中。与
  133. 人沟通,有助于排解不良情绪;把注意力放到当下真正需要关注的 事情中来,积极应对困难,有助于改善现状。
  134. </p>
  135. </div>
  136. </div>
  137. <!-- 概览 -->
  138. <div class="overview">
  139. <div class="content">
  140. <div class="title">
  141. <span class="title-text">{{ surveyTitle }}</span>
  142. <div class="mood-list">
  143. <div
  144. class="item"
  145. v-for="(item, index) in emotionList"
  146. :key="index"
  147. :style="{ backgroundColor: item.color }"
  148. >
  149. <p>
  150. <span class="day">{{ item.days }}</span>
  151. <span class="day-text">天</span>
  152. <img :src="calcWeekImg(item.days, item.lastDay)" alt="" />
  153. <span class="day-text status">{{ calcWeekImg(item.days, item.lastDay, true) }}</span>
  154. </p>
  155. <p>{{ item.text }}</p>
  156. </div>
  157. </div>
  158. <!-- <div class="mood-list-no-data" v-else>
  159. <div class="no-data">
  160. <img src="../../../../assets/img/no_data_01.png" alt />
  161. <p>暂无数据</p>
  162. </div>
  163. </div>-->
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <div class="main no-data">
  169. <img src="../../assets/today/images/no_data_01.png" alt />
  170. <p>暂无数据</p>
  171. </div>
  172. </div>
  173. </template>
  174. <script>
  175. import { isNotNull } from '@/services/utils-service';
  176. import axios from 'axios';
  177. import APICore from '@/api/core';
  178. import NavBar from '@/components/NavBar';
  179. import EchartBox from '@/components/EchartBox';
  180. export default {
  181. name: '',
  182. components: {
  183. NavBar,
  184. EchartBox
  185. },
  186. data() {
  187. return {
  188. signActive: 0,
  189. emoLegend: {
  190. title: '',
  191. list: [
  192. { name: '无抑郁倾向', color: '#179b3b' },
  193. { name: '轻度抑郁倾向', color: '#8dc21f' },
  194. { name: '中度抑郁倾向', color: '#2ea7e0' },
  195. { name: '重度抑郁倾向', color: '#ff5f8b' }
  196. ]
  197. },
  198. signList: [
  199. {
  200. grid: 'heartRateList',
  201. name: '疲劳'
  202. },
  203. {
  204. grid: 'temperatureList',
  205. name: '压力'
  206. },
  207. {
  208. grid: 'stepList',
  209. name: '焦虑'
  210. }
  211. ],
  212. pieRightList: [
  213. /* {
  214. text: "无情绪倾向",
  215. count: 12,
  216. percentage: "80",
  217. color: "#179b3b"
  218. },
  219. {
  220. text: "轻度情绪倾向",
  221. count: 2,
  222. percentage: "80",
  223. color: "#8dc21f"
  224. },
  225. {
  226. text: "中度情绪倾向",
  227. count: 1,
  228. percentage: "80",
  229. color: "#2ea7e0"
  230. },
  231. {
  232. text: "重度情绪倾向",
  233. count: 1,
  234. percentage: "80",
  235. color: "#ff5f8b"
  236. } */
  237. ],
  238. statisticsList: [
  239. /* { label: '最大值', value: '75', time: '08:15', bgColor: '#ff5f8b' },
  240. { label: '最小值', value: '40', time: '10:15', bgColor: '#189b3b' },
  241. { label: '最近值', value: '50', time: '18:15', bgColor: '#2ea7e0' } */
  242. ],
  243. emotionList: [],
  244. surveyTitle: '本周概况',
  245. echarts: null,
  246. // 路由传过来的情绪参数
  247. emoName: '',
  248. pieData: [],
  249. xAxisData: [],
  250. pieEcharts: null,
  251. monitoringCount: '',
  252. // 7天和30天最大数据列表
  253. weekAndMonData: [],
  254. defaultSeries: null,
  255. defaultLegend: [
  256. {
  257. name: `轻度${this.emoName}倾向`,
  258. icon: 'rect',
  259. itemStyle: {
  260. color: '#8dc21f'
  261. },
  262. textStyle: {
  263. fontSize: 12
  264. }
  265. },
  266. {
  267. name: `中度${this.emoName}倾向`,
  268. itemStyle: {
  269. color: '#2ea7e0'
  270. },
  271. icon: 'rect',
  272. textStyle: {
  273. fontSize: 12
  274. }
  275. },
  276. {
  277. name: `重度${this.emoName}倾向`,
  278. itemStyle: {
  279. color: '#ff5f8b'
  280. },
  281. icon: 'rect',
  282. textStyle: {
  283. fontSize: 12
  284. }
  285. },
  286. {
  287. name: `无${this.emoName}倾向`,
  288. icon: 'rect',
  289. itemStyle: {
  290. color: '#179b3b'
  291. },
  292. textStyle: {
  293. // 项目遗留问题,新项目不需重新转换文字大小
  294. fontSize: 12
  295. }
  296. }
  297. ],
  298. params: {},
  299. weekResult: {},
  300. upImg: require('@/assets/today/icons/up.png'),
  301. downImg: require('@/assets/today/icons/down.png'),
  302. signGrid: [],
  303. chartsScatter: null,
  304. timeList: ['0', '6', '12', '18', '24'],
  305. emotionDataNew: []
  306. };
  307. },
  308. created() {
  309. this.initEchartText();
  310. this.createList();
  311. },
  312. mounted() {
  313. this.loadParams();
  314. this.initEchart();
  315. },
  316. watch: {
  317. // 监听数据发生变化 初始化各项图表
  318. emotionData: {
  319. handler() {
  320. this.initEchart();
  321. },
  322. deep: true
  323. },
  324. xAxisData: {
  325. handler() {
  326. this.initEchart();
  327. },
  328. deep: true
  329. },
  330. pieData: {
  331. handler() {
  332. this.initPieEchart();
  333. },
  334. deep: true
  335. }
  336. },
  337. computed: {
  338. emoOptions() {
  339. return {
  340. grid: {
  341. top: '10%',
  342. left: '10%',
  343. right: '10%',
  344. bottom: '20%'
  345. },
  346. xAxis: {
  347. type: 'category',
  348. axisLine: {
  349. show: false
  350. },
  351. textStyle: {
  352. fontSize: 10
  353. },
  354. axisTick: {
  355. show: false
  356. },
  357. nameLocation: 'left',
  358. axisLabel: {
  359. show: true,
  360. fontSize: 12,
  361. showMinLabel: true, //显示最小值
  362. showMaxLabel: true //显示最大值
  363. },
  364. data: ['6:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00']
  365. },
  366. yAxis: {
  367. type: 'value'
  368. },
  369. series: [
  370. {
  371. type: 'line',
  372. data: this.emotionDataNew,
  373. symbol: 'circle',
  374. symbolSize: 12,
  375. smooth: true,
  376. itemStyle: {
  377. normal: {
  378. color: '#fff',
  379. borderWidth: 2,
  380. lineStyle: {
  381. width: 6,
  382. type: 'solid',
  383. color: '#189b3b'
  384. }
  385. }
  386. }
  387. }
  388. ]
  389. };
  390. },
  391. // 折线图标题
  392. echartsTitle() {
  393. return `${this.emoName}数据图`;
  394. },
  395. defaultOptions() {
  396. return {
  397. time: {
  398. useUTC: false
  399. },
  400. title: {
  401. /* text: this.echartsTitle, */
  402. left: 1,
  403. right: 25,
  404. bottom: 20,
  405. top: '3%',
  406. textStyle: {
  407. fontSize: 18,
  408. fontWeight: 'bold'
  409. }
  410. },
  411. legend: {
  412. width: '65%',
  413. orient: 'horizontal',
  414. right: 'right',
  415. top: '3%',
  416. bottom: '1%',
  417. itemHeight: 12,
  418. itemWidth: 12,
  419. itemGap: 10,
  420. align: 'left',
  421. selectedMode: false,
  422. data: [
  423. {
  424. name: `轻度${this.emoName}倾向`,
  425. icon: 'rect',
  426. itemStyle: {
  427. color: '#8dc21f'
  428. },
  429. textStyle: {
  430. fontSize: 12
  431. }
  432. },
  433. {
  434. name: `中度${this.emoName}倾向`,
  435. itemStyle: {
  436. color: '#2ea7e0'
  437. },
  438. icon: 'rect',
  439. textStyle: {
  440. fontSize: 12
  441. }
  442. },
  443. {
  444. name: `重度${this.emoName}倾向`,
  445. itemStyle: {
  446. color: '#ff5f8b'
  447. },
  448. icon: 'rect',
  449. textStyle: {
  450. fontSize: 12
  451. }
  452. },
  453. {
  454. name: `无${this.emoName}倾向`,
  455. icon: 'rect',
  456. itemStyle: {
  457. color: '#179b3b'
  458. },
  459. textStyle: {
  460. fontSize: 12
  461. }
  462. }
  463. ],
  464. formatter: function (name) {
  465. // 自定义显示内容
  466. if (name.length > 6) {
  467. return name.substring(0, 6) + '\n' + name.substring(6);
  468. } else {
  469. return name;
  470. }
  471. }
  472. },
  473. grid: {
  474. show: true,
  475. borderWidth: 1,
  476. top: '20%',
  477. left: '1%',
  478. right: '5%',
  479. bottom: '5%',
  480. containLabel: true
  481. },
  482. xAxis: {
  483. type: 'category',
  484. axisLine: {
  485. show: false
  486. },
  487. textStyle: {
  488. fontSize: 10
  489. },
  490. axisTick: {
  491. show: false
  492. },
  493. splitLine: {
  494. show: false,
  495. lineStyle: {
  496. color: '#ddd',
  497. width: 2
  498. }
  499. },
  500. nameLocation: 'center',
  501. axisLabel: {
  502. show: true,
  503. fontSize: 12,
  504. showMinLabel: true, //显示最小值
  505. showMaxLabel: true //显示最大值
  506. },
  507. data: this.xAxisData
  508. },
  509. dataZoom: [
  510. {
  511. type: 'inside',
  512. start: 0,
  513. end: 100
  514. },
  515. {
  516. start: 0,
  517. end: 100,
  518. textStyle: {
  519. color: '#FFF',
  520. fontSize: 14
  521. },
  522. show: false,
  523. height: 25,
  524. bottom: '3%',
  525. handleStyle: {
  526. borderWidth: 1,
  527. borderCap: 'square'
  528. }
  529. }
  530. ],
  531. tooltip: {
  532. trigger: 'axis',
  533. textStyle: {
  534. fontSize: 14,
  535. align: 'center'
  536. },
  537. formatter: function (params) {
  538. return params[0].marker + params[0].name + '--' + params[0].value + '</br>';
  539. }
  540. },
  541. yAxis: {
  542. type: 'value',
  543. max: 100,
  544. min: 0,
  545. interval: 20,
  546. splitNumber: 1,
  547. boundaryGap: ['5%', '5%'],
  548. nameTextStyle: {
  549. fontSize: 13
  550. },
  551. alignTicks: true,
  552. axisTick: {
  553. show: true
  554. },
  555. axisLabel: {
  556. show: true,
  557. fontSize: 13
  558. },
  559. splitLine: {
  560. show: true,
  561. lineStyle: {
  562. color: '#ddd',
  563. width: 1
  564. }
  565. }
  566. },
  567. series: [
  568. {
  569. name: `无${this.emoName}倾向`,
  570. type: 'line',
  571. padding: 5,
  572. data: this.emotionData,
  573. symbol: 'circle',
  574. symbolSize: 8
  575. },
  576. {
  577. name: `轻度${this.emoName}倾向`,
  578. type: 'line',
  579. data: ''
  580. },
  581. {
  582. name: `中度${this.emoName}倾向`,
  583. type: 'line',
  584. data: ''
  585. },
  586. {
  587. name: `重度${this.emoName}倾向`,
  588. type: 'line',
  589. data: ''
  590. }
  591. ]
  592. };
  593. },
  594. // 饼状图配置
  595. pieOption() {
  596. return {
  597. tooltip: {
  598. trigger: 'item',
  599. textStyle: {
  600. fontSize: 14
  601. },
  602. position: 'right'
  603. },
  604. legend: {
  605. top: '5%',
  606. left: 'center',
  607. show: false
  608. },
  609. series: [
  610. {
  611. type: 'pie',
  612. radius: ['40%', '80%'],
  613. avoidLabelOverlap: false,
  614. startAngle: 270, // 设置逆时针渲染
  615. itemStyle: {
  616. borderRadius: 5,
  617. borderColor: '#fff',
  618. borderWidth: 2,
  619. fontSize: 16
  620. },
  621. label: {
  622. show: false,
  623. position: 'center',
  624. fontSize: 16
  625. },
  626. emphasis: {
  627. label: {
  628. show: false,
  629. fontSize: 16,
  630. fontWeight: 'bold'
  631. }
  632. },
  633. labelLine: {
  634. show: false
  635. },
  636. data: this.pieData
  637. }
  638. ]
  639. };
  640. },
  641. scatterOptions() {
  642. return {
  643. backgroundColor: 'rgba(255, 255, 255, 1)',
  644. grid: {
  645. top: '1%',
  646. left: '10%',
  647. right: '10%',
  648. bottom: '1%'
  649. },
  650. tooltip: {
  651. trigger: 'axis',
  652. axisPointer: {
  653. // 坐标轴指示器,坐标轴触发有效
  654. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  655. }
  656. },
  657. xAxis: {
  658. type: 'value',
  659. axisLine: {
  660. show: false
  661. },
  662. axisTick: {
  663. show: false
  664. },
  665. axisLabel: {
  666. margin: 15
  667. },
  668. show: false
  669. },
  670. yAxis: {
  671. type: 'category',
  672. data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'].reverse(),
  673. show: true
  674. },
  675. series: [
  676. {
  677. data: [120, 200, 150, 80, 70, 110, 130],
  678. type: 'bar',
  679. stack: 'one',
  680. barWidth: 20,
  681. itemStyle: {
  682. borderWidth: 3,
  683. borderColor: 'rgba(255, 255, 255, 1)', //同背景色一样
  684. barBorderRadius: 120
  685. },
  686. emphasis: {
  687. itemStyle: {
  688. borderColor: 'rgba(255, 255, 255, 1)'
  689. }
  690. }
  691. },
  692. {
  693. data: [120, 30, 150, 80, 70, 110, 130],
  694. type: 'bar',
  695. stack: 'one', //堆叠
  696. barWidth: 20,
  697. itemStyle: {
  698. borderWidth: 3, //用border设置两个柱形图之间的间距
  699. borderColor: 'rgba(255, 255, 255, 1)', //同背景色一样
  700. barBorderRadius: 120
  701. },
  702. emphasis: {
  703. itemStyle: {
  704. borderColor: 'rgba(255, 255, 255, 1)'
  705. }
  706. }
  707. },
  708. {
  709. data: [120, 30, 150, 80, 70, 110, 130],
  710. type: 'bar',
  711. stack: 'one', //堆叠
  712. barWidth: 20,
  713. itemStyle: {
  714. borderWidth: 3, //用border设置两个柱形图之间的间距
  715. borderColor: 'rgba(255, 255, 255, 1)', //同背景色一样
  716. barBorderRadius: 120
  717. },
  718. emphasis: {
  719. itemStyle: {
  720. borderColor: 'rgba(255, 255, 255, 1)'
  721. }
  722. }
  723. },
  724. {
  725. data: [120, 30, 150, 80, 70, 110, 130],
  726. type: 'bar',
  727. stack: 'one', //堆叠
  728. barWidth: 20,
  729. itemStyle: {
  730. borderWidth: 3, //用border设置两个柱形图之间的间距
  731. borderColor: 'rgba(255, 255, 255, 1)', //同背景色一样
  732. barBorderRadius: 120
  733. },
  734. emphasis: {
  735. itemStyle: {
  736. borderColor: 'rgba(255, 255, 255, 1)'
  737. }
  738. }
  739. }
  740. ]
  741. };
  742. }
  743. },
  744. methods: {
  745. createList() {
  746. // 模拟数据
  747. this.emotionDataNew = [];
  748. const colors = ['#189b3b', '#2ea7e0', '#ff5f8b'];
  749. for (let i = 0; i < 7; i++) {
  750. let value = Math.floor(Math.random() * 60) + 80;
  751. let color = colors[Math.floor(Math.random() * colors.length)];
  752. this.emotionDataNew.push({
  753. value,
  754. itemStyle: {
  755. borderColor: color
  756. }
  757. });
  758. }
  759. },
  760. calcWeekImg(cur, last, callBackText) {
  761. let imgurl = '';
  762. let text = '';
  763. if (isNotNull(cur) && isNotNull(last) && this.weekAndMonData.length > 0) {
  764. let curNumber = Number(cur);
  765. let latNumber = Number(last);
  766. if (curNumber - latNumber == 0) {
  767. text = '持平';
  768. } else {
  769. imgurl = curNumber < latNumber ? this.downImg : this.upImg;
  770. text = Math.abs(curNumber - latNumber) + '天';
  771. }
  772. if (callBackText) {
  773. return text;
  774. } else {
  775. return imgurl;
  776. }
  777. }
  778. },
  779. // 计算显示是上升or下降的图片
  780. /**
  781. *
  782. * @param { 本周情绪比例} current
  783. * @param { 上周情绪比例 } last
  784. * @param { 是否返回对比比例 } isCallBackCompare
  785. */
  786. calcImg(current, last, isCallBackCompare) {
  787. let imgUrl = '';
  788. let compare = '';
  789. if (isNotNull(current) && isNotNull(last)) {
  790. compare = Number(current) - Number(last);
  791. imgUrl = compare > 0 ? this.upImg : compare == 0 ? '' : this.downImg;
  792. }
  793. if (isCallBackCompare) {
  794. return compare;
  795. } else {
  796. return imgUrl;
  797. }
  798. },
  799. async loadParams() {
  800. let params = this.$route.query;
  801. if (params) {
  802. this.params = params;
  803. if (!params.accessToken) {
  804. let authToken = await this.getAuth();
  805. this.$store.commit('ssjlToken', authToken);
  806. } else {
  807. this.$store.commit('ssjlToken', params.accessToken);
  808. }
  809. this.getWeekResultDetail();
  810. }
  811. },
  812. // 获取b端token
  813. getAuth() {
  814. let manufactorId = '5bf13062-a41e-4d00-ba14-1101aad12650';
  815. return new Promise((resolve, reject) => {
  816. APICore.getAuth({ manufactorId: manufactorId }).then(res => {
  817. let data = res.data;
  818. if (data.code === 0) {
  819. resolve(res.data.data);
  820. } else {
  821. this.$toast.fail(`${data.message}`);
  822. reject('');
  823. }
  824. });
  825. });
  826. },
  827. initEchartText() {
  828. this.defaultSeries = [
  829. {
  830. name: ``,
  831. type: 'line',
  832. padding: 5,
  833. data: this.emotionData,
  834. symbol: 'circle',
  835. symbolSize: 8, // 拐点圆的大小
  836. areaStyle: {}
  837. },
  838. {
  839. name: `轻度${this.emoName}倾向`,
  840. type: 'line',
  841. padding: 10,
  842. data: '',
  843. symbol: 'circle',
  844. symbolSize: 8 // 拐点圆的大小
  845. },
  846. {
  847. name: `中度${this.emoName}倾向`,
  848. type: 'line',
  849. data: ''
  850. },
  851. {
  852. name: `重度${this.emoName}倾向`,
  853. type: 'line',
  854. data: ''
  855. }
  856. ];
  857. },
  858. calcTitle(type) {
  859. let title = '';
  860. switch (type) {
  861. case 1:
  862. title = '压力';
  863. break;
  864. case 2:
  865. title = '抑郁';
  866. break;
  867. case 3:
  868. title = '疲劳';
  869. break;
  870. default:
  871. break;
  872. }
  873. return title;
  874. },
  875. getWeekResultDetail() {
  876. this.$toast.loading('数据加载中');
  877. let baseUrl =
  878. process.env.NODE_ENV === 'production' ? 'https://dbmq.rzliot.com/auth_heart' : 'https://dbmq.rzliot.com/heart';
  879. let reqUrl = `${baseUrl}/api/Data/GetWeekResultDetail`;
  880. let reqParams = {
  881. recordId: /* this.params.recordId */ '1728096156447281486'
  882. };
  883. axios
  884. .get(reqUrl, {
  885. params: { ...reqParams }
  886. /* headers: { 'AccessToken': this.$store.getters.ssjlToken } */
  887. })
  888. .then(res => {
  889. const data = res.data.response;
  890. let chartData = data.ChartData
  891. ? JSON.parse(data.ChartData).filter(item => {
  892. return item.Key;
  893. })
  894. : [];
  895. if (data) {
  896. this.monitoringCount = data.Total;
  897. this.pieRightList = [];
  898. this.statisticsList = [];
  899. this.emotionList = [];
  900. this.weekResult = data;
  901. this.emoName = this.calcTitle(data.Type);
  902. }
  903. let None = {
  904. count: data.None,
  905. percentage: this.calcPercentage(data.None, data.Total),
  906. text: `无${this.emoName}倾向`,
  907. color: '#179b3b',
  908. scale: data.NoneRatio,
  909. lastPercentage: this.calcPercentage(data.LastNone, data.LastTotal)
  910. };
  911. let Mild = {
  912. count: data.Mild,
  913. percentage: this.calcPercentage(data.Mild, data.Total),
  914. text: `轻度${this.emoName}倾向`,
  915. color: '#8dc21f',
  916. scale: data.MildRatio,
  917. lastPercentage: this.calcPercentage(data.LastMild, data.LastTotal)
  918. };
  919. let Moderate = {
  920. count: data.Moderate,
  921. percentage: this.calcPercentage(data.Moderate, data.Total),
  922. text: `中度${this.emoName}倾向`,
  923. color: '#2ea7e0',
  924. scale: data.ModerateRatio,
  925. lastPercentage: this.calcPercentage(data.LastModerate, data.LastTotal)
  926. };
  927. let Severe = {
  928. count: data.Severe,
  929. percentage: this.calcPercentage(data.Severe, data.Total),
  930. text: `重度${this.emoName}倾向`,
  931. color: '#ff5f8b',
  932. scale: data.SevereRatio,
  933. lastPercentage: this.calcPercentage(data.LastSevere, data.LastTotal)
  934. };
  935. // 饼状图右边数据
  936. this.pieRightList.push(None);
  937. this.pieRightList.push(Mild);
  938. this.pieRightList.push(Moderate);
  939. this.pieRightList.push(Severe);
  940. this.pieData = this.pieRightList.map(item => {
  941. item.value = item.count;
  942. item.itemStyle = {
  943. color: item.color
  944. };
  945. return item;
  946. });
  947. let Max = {
  948. label: '最大值',
  949. value: data.Max,
  950. time: data.MaxDesc
  951. ? this.currentDays === 0
  952. ? this.$dayjs(data.MaxDesc).format('HH:mm')
  953. : this.$dayjs(data.MaxDesc).format('MM/DD HH:mm')
  954. : '',
  955. bgColor: '#ff5f8b'
  956. };
  957. let Min = {
  958. label: '最小值',
  959. value: data.Min,
  960. time: data.MinDesc
  961. ? this.currentDays === 0
  962. ? this.$dayjs(data.MinDesc).format('HH:mm')
  963. : this.$dayjs(data.MinDesc).format('MM/DD HH:mm')
  964. : '',
  965. bgColor: '#189b3b'
  966. };
  967. let Avg = {
  968. label: '平均值',
  969. value: data.Min,
  970. time: data.MinDesc
  971. ? this.currentDays === 0
  972. ? this.$dayjs(data.MinDesc).format('HH:mm')
  973. : this.$dayjs(data.MinDesc).format('MM/DD HH:mm')
  974. : '',
  975. bgColor: '#2ea7e0'
  976. };
  977. /* let Avg = {
  978. label: '最近值',
  979. value: data.Avg,
  980. time: data.AvgDesc
  981. ? this.currentDays === 0
  982. ? this.$dayjs(data.AvgDesc).format('HH:mm')
  983. : this.$dayjs(data.AvgDesc).format('MM/DD HH:mm')
  984. : '',
  985. bgColor: '#2ea7e0'
  986. }; */
  987. this.statisticsList.push(Max);
  988. this.statisticsList.push(Min);
  989. this.statisticsList.push(Avg);
  990. let NoneDay = {
  991. days: data.NoneDay,
  992. text: `无${this.emoName}倾向`,
  993. color: '#179b3b',
  994. lastDay: data.LastNoneDay,
  995. scale: data.NoneDayRatio
  996. };
  997. let MildDay = {
  998. days: data.MildDay,
  999. text: `轻度${this.emoName}倾向`,
  1000. color: '#8dc21f',
  1001. lastDay: data.LastMildDay,
  1002. scale: data.MildDayRatio
  1003. };
  1004. let ModerateDay = {
  1005. days: data.ModerateDay,
  1006. text: `中度${this.emoName}倾向`,
  1007. color: '#2ea7e0',
  1008. lastDay: data.LastModerateDay,
  1009. scale: data.ModerateDayRatio
  1010. };
  1011. let SevereDay = {
  1012. days: data.SevereDay,
  1013. text: `重度${this.emoName}倾向`,
  1014. color: '#ff5f8b',
  1015. lastDay: data.LastSevereDay,
  1016. scale: data.SevereDayRatio
  1017. };
  1018. this.emotionList.push(NoneDay);
  1019. this.emotionList.push(MildDay);
  1020. this.emotionList.push(ModerateDay);
  1021. this.emotionList.push(SevereDay);
  1022. // 图表数据
  1023. this.emotionData = chartData.map(item => {
  1024. return {
  1025. value: item.Value,
  1026. itemStyle: {
  1027. color: this.calcResultColor(item.Level)
  1028. }
  1029. };
  1030. });
  1031. this.weekAndMonData = chartData.map((item, index) => {
  1032. return {
  1033. value: [index, item.MinValue, item.MaxValue]
  1034. };
  1035. });
  1036. this.xAxisData = chartData.map(item => {
  1037. return item.Key ? this.$dayjs(item.Key.replace(/-/g, '/')).format('MM/DD') : item.key;
  1038. });
  1039. let that = this;
  1040. // 7天和30天变成柱状图
  1041. this.weekAndMonthSeries = [
  1042. {
  1043. name: '平均值',
  1044. type: 'scatter',
  1045. symbolSize: 8,
  1046. data: this.emotionData
  1047. },
  1048. {
  1049. name: '',
  1050. type: 'custom',
  1051. data: this.weekAndMonData,
  1052. renderItem: function (params, api) {
  1053. var categoryIndex = api.value(0);
  1054. var end = api.coord([categoryIndex, api.value(1)]);
  1055. var start = api.coord([categoryIndex, api.value(2)]);
  1056. var width = 8;
  1057. var rectShape = that.$echarts.graphic.clipRectByRect(
  1058. {
  1059. x: start[0] - width / 2,
  1060. y: start[1],
  1061. width: 8,
  1062. height: end[1] - start[1]
  1063. },
  1064. {
  1065. x: params.coordSys.x,
  1066. y: params.coordSys.y,
  1067. width: params.coordSys.width,
  1068. height: params.coordSys.height
  1069. }
  1070. );
  1071. if (rectShape) {
  1072. rectShape.r = [10];
  1073. }
  1074. return (
  1075. rectShape && {
  1076. type: 'rect',
  1077. shape: rectShape,
  1078. style: api.style()
  1079. }
  1080. );
  1081. },
  1082. itemStyle: {
  1083. opacity: 0.8
  1084. },
  1085. encode: {
  1086. y: [1, 2],
  1087. x: 0
  1088. }
  1089. },
  1090. {
  1091. name: `轻度${this.emoName}倾向`,
  1092. type: 'scatter',
  1093. symbolSize: 8,
  1094. data: ''
  1095. },
  1096. {
  1097. name: `中度${this.emoName}倾向`,
  1098. type: 'scatter',
  1099. symbolSize: 8,
  1100. data: ''
  1101. },
  1102. {
  1103. name: `重度${this.emoName}倾向`,
  1104. type: 'scatter',
  1105. symbolSize: 8,
  1106. data: ''
  1107. },
  1108. {
  1109. name: `无${this.emoName}倾向`,
  1110. type: 'scatter',
  1111. symbolSize: 8,
  1112. data: ''
  1113. }
  1114. ];
  1115. // 点击提示此时为空
  1116. this.defaultOptions.tooltip = {
  1117. trigger: 'axis',
  1118. formatter: function (params) {
  1119. if (params) {
  1120. return (
  1121. params[0].marker +
  1122. '平均值:' +
  1123. params[0].name +
  1124. '--' +
  1125. params[0].value +
  1126. '</br>' +
  1127. params[1].marker +
  1128. '最大值:' +
  1129. params[1].name +
  1130. '--' +
  1131. params[1].value[2] +
  1132. '</br>' +
  1133. params[1].marker +
  1134. '最小值:' +
  1135. params[1].name +
  1136. '--' +
  1137. params[1].value[1]
  1138. );
  1139. }
  1140. }
  1141. };
  1142. this.defaultOptions.series = this.weekAndMonthSeries;
  1143. this.$toast.success('数据加载完成');
  1144. });
  1145. },
  1146. initEchart() {
  1147. /* if (this.echarts != null && this.echarts != '' && this.echarts != undefined) {
  1148. this.echarts.dispose();
  1149. } */
  1150. /* if (this.chartsScatter != null && this.chartsScatter != '' && this.chartsScatter != undefined) {
  1151. this.chartsScatter.dispose();
  1152. } */
  1153. /* this.echarts = this.$echarts.init(this.$refs.charts);
  1154. this.echarts.setOption(this.defaultOptions); */
  1155. /* this.chartsScatter = this.$echarts.init(this.$refs.chartsScatter);
  1156. this.chartsScatter.setOption(this.scatterOptions); */
  1157. },
  1158. // 初始化饼状图
  1159. initPieEchart() {
  1160. if (this.pieEcharts != null && this.pieEcharts != '' && this.pieEcharts != undefined) {
  1161. this.pieEcharts.dispose();
  1162. }
  1163. this.pieEcharts = this.$echarts.init(this.$refs.pieChart);
  1164. this.pieEcharts.setOption(this.pieOption);
  1165. },
  1166. onNavBack() {
  1167. this.$router.push({
  1168. name: 'Insight'
  1169. });
  1170. },
  1171. // 计算字体显示的颜色
  1172. calcColor(value) {
  1173. let color = '';
  1174. if (value <= 40) {
  1175. color = '#179b3b';
  1176. } else if (value > 40 && value <= 65) {
  1177. color = '#8dc21f';
  1178. } else if (value > 65 && value <= 80) {
  1179. color = '#2ea7e0';
  1180. } else if (value > 80) {
  1181. color = '#ff5f8b';
  1182. } else {
  1183. color = '';
  1184. }
  1185. return color;
  1186. },
  1187. // 计算百分比
  1188. calcPercentage(value, total) {
  1189. if (typeof value !== 'number' || typeof total !== 'number' || total === 0) {
  1190. return 0;
  1191. }
  1192. let milValue = value * 1000;
  1193. let milTotal = total * 1000;
  1194. return Math.round((milValue / milTotal) * 100);
  1195. },
  1196. // 计算结果采用哪种颜色
  1197. calcResultColor(value, isCallBackClass) {
  1198. let color = '';
  1199. let className = '';
  1200. switch (value) {
  1201. case ('0', 0):
  1202. color = '#179b3b';
  1203. className = 'none';
  1204. break;
  1205. case ('1', 1):
  1206. color = '#8dc21f';
  1207. className = 'mild';
  1208. break;
  1209. case ('2', 2):
  1210. color = '#2ea7e0';
  1211. className = 'moderate';
  1212. break;
  1213. case ('3', 3):
  1214. color = '#ff5f8b';
  1215. className = 'severe';
  1216. break;
  1217. }
  1218. return isCallBackClass ? className : color;
  1219. },
  1220. // 重新拼接日期
  1221. resetDate(startDate, endDate) {
  1222. let callBackDate = '';
  1223. if (startDate && endDate) {
  1224. callBackDate = startDate.replace(/-/g, '.') + '-' + endDate.slice(5, endDate.length).replace(/-/g, '.');
  1225. }
  1226. return callBackDate;
  1227. },
  1228. onSignClick(index) {
  1229. this.signActive = index;
  1230. }
  1231. }
  1232. };
  1233. </script>
  1234. <style scoped lang="scss">
  1235. @import './scss/report.scss';
  1236. </style>