天波h5前端应用
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

919 rindas
34KB

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