健康同学微信公众号h5项目
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

990 lines
28KB

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