天波h5前端应用
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

1706 líneas
53KB

  1. <template>
  2. <div class="psychological-container">
  3. <van-nav-bar :title="emoName + '监测'" :border="true" :left-arrow="true" @click-left="onNavBack">
  4. <template #left>
  5. <van-icon name="arrow-left" size="24" style="padding: 0" />
  6. <span>返回</span>
  7. </template>
  8. </van-nav-bar>
  9. <div class="tab-bar">
  10. <div class="date-tab-con">
  11. <div class="date-tab-list">
  12. <div :class="[
  13. 'date-tab-item',
  14. { active: current === index, notClick: false },
  15. ]" @click="onTabClick(item.value, index)" v-for="(item, index) in dateList" :key="index">
  16. <img :src="tabImgUrl" alt v-if="index == 3" />
  17. <span>{{ item.text }}</span>
  18. <img class="more" :src="selectDownImg" alt v-if="index == 3" />
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <!-- 情绪切换 -->
  24. <div class="psy-tab-bar" v-if="pageType !== 1">
  25. <div class="psy-tab-con">
  26. <div class="psy-tab-list">
  27. <div :class="[
  28. 'psy-tab-item',
  29. { active: psyCurrent === index, notClick: false },
  30. ]" @click="onPsyTabClick(item.name, index)" v-for="(item, index) in psyList" :key="index">
  31. <span>{{ item.text }}</span>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="main" v-show="current !== 3">
  37. <div class="top">
  38. <!-- 日期选择 -->
  39. <!-- 标题 -->
  40. <div class="title">
  41. <div class="title-left">
  42. {{ titleLeft }}<van-icon name="question-o" @click="onHelp" />
  43. </div>
  44. <div class="title-right" v-show="currentDays === 0">
  45. <div class="title-right-button" @click="onPsychologicalScale">量表记录</div>
  46. <div class="title-right-button" @click="onHistory">历史监测</div>
  47. </div>
  48. </div>
  49. <!-- 日历 -->
  50. <van-dialog class="calenddar-dialog" v-model="calendarDialogShow" :show-confirm-button="false"
  51. :show-cancle-button="false" :close-on-click-overlay="true" ref="calenddarDialog">
  52. <template #default>
  53. <div class="calendar" ref="calendarCon">
  54. <van-calendar v-model="calendarShow" :min-date="minDate" :max-date="maxDate" :default-date="defaultDate"
  55. :round="false" :poppable="false" color="#62BD48" :show-confirm="false" :show-title="false"
  56. :show-subtitle="false" :formatter="formatter" @select="onSelect" />
  57. </div>
  58. </template>
  59. </van-dialog>
  60. <!-- 监测次数 -->
  61. <div class="monitoring-count">
  62. <p>监测次数:{{ monitoringCount || "0" }}次</p>
  63. </div>
  64. <!-- 折线图-非日报 -->
  65. <div class="pie-chart-con">
  66. <div class="pie-chart-left">
  67. <div id="pieChart" ref="pieChart"></div>
  68. </div>
  69. <div class="pie-chart-right">
  70. <div class="list">
  71. <div class="item" v-for="(item, index) in pieRightList" :key="index">
  72. <div class="item-left">
  73. <div class="circle" :style="{ backgroundColor: item.color }"></div>
  74. <span class="text">{{ item.text || "--" }}</span>
  75. </div>
  76. <div class="item-right">
  77. <span :style="{ color: item.color }">{{
  78. item.count ? item.count + "次" : "0次"
  79. }}</span>
  80. <label :style="{ color: item.color }">{{
  81. item.percentage ? "(" + item.percentage + "%" + ")" : "(0%)"
  82. }}</label>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- 统计 -->
  89. <div class="statistics">
  90. <div class="list">
  91. <div class="item" v-for="(item, index) in statisticsList" :key="index">
  92. <div class="top">
  93. <span>{{ item.label || "--" }}</span>
  94. </div>
  95. <div class="middle">
  96. <span :style="{ color: calcResultColor(item.level) }">{{
  97. item.value || "--"
  98. }}</span>
  99. </div>
  100. <div class="bottom">
  101. <span>{{ item.time || "--" }}</span>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <!-- 分割线 -->
  108. <div class="line"></div>
  109. <!-- 底部 -->
  110. <div class="bottom">
  111. <div class="echart-container">
  112. <div class="echart" ref="charts"></div>
  113. </div>
  114. <div class="line-gray"></div>
  115. <div class="result" v-if="monitoringCount == ''">
  116. <div class="result-con">
  117. <div class="title">
  118. <span class="title-no-data">结果解读</span>
  119. <div class="no-data">
  120. <img src="../../../assets/img/no_data_01.png" alt />
  121. <p>暂无数据</p>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="result" v-else>
  127. <div class="result-con reminder" v-show="current === 0">
  128. <div class="title">
  129. <span class="title-reminder">结果解读</span>
  130. <p class="title-emo" :style="{ color: currentColor }">
  131. {{ this.$replaceAll(result, '抑郁', '忧郁') }}
  132. </p>
  133. <span class="font-28"><!-- 继续保持积极乐观,培养健康的生活习惯,预防消极事件对情绪带来的不良影响。 -->{{
  134. advice
  135. }}</span>
  136. </div>
  137. <div class="friendly-reminder" v-if="emoType === 2">
  138. <p :style="{ color: currentColor }">友情提示:</p>
  139. <span>如果您发现{{ anxietyText }}倾向分值升高或处于轻度水平,不需要过度紧张,这可能是由正常的情绪波动或者生活习惯(睡眠时间、运动量等)的改变造成的。如果您发现{{ anxietyText
  140. }}倾向分值连续7天及以上处于中度或重度水平,建议您寻求家人朋友或心理咨询师的帮助,及早进行干预。</span>
  141. </div>
  142. <div class="warm-reminder">
  143. <p :style="{ color: currentColor }">温馨提示:</p>
  144. <span>{{ warmTips }}</span>
  145. </div>
  146. </div>
  147. <div class="result-con" v-show="current > 0">
  148. <div class="title">
  149. <span class="title-text">{{ surveyTitle }}</span>
  150. <div class="mood-list" v-if="emotionList.length > 0">
  151. <div class="item" v-for="(item, index) in emotionList" :key="index">
  152. <p>
  153. <span :style="{ color: item.color }" class="day">{{
  154. item.days
  155. }}</span>
  156. <span class="day-text">天</span>
  157. </p>
  158. <p>{{ item.text }}</p>
  159. </div>
  160. </div>
  161. <div class="mood-list-no-data" v-else>
  162. <div class="no-data">
  163. <img src="../../../assets/img/no_data_01.png" alt />
  164. <p>暂无数据</p>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. <!-- -->
  171. </div>
  172. </div>
  173. <!-- 周报菜单 -->
  174. <div class="main report" v-show="current == 3">
  175. <div class="content">
  176. <div class="list" v-if="pageType === 0 && weekList.length > 0">
  177. <div class="item" v-for="(item, index) in weekList" :key="index" @click="onClickItem(item)">
  178. <div class="left">
  179. <img :src="weekImg" alt />
  180. <div class="middle">
  181. <div class="title">
  182. <span>周报</span>
  183. <p>{{ item.name }}</p>
  184. </div>
  185. <div class="overall">
  186. <span>总评</span>
  187. <div class="left">
  188. <p :style="{ color: calcResultColor(item.summaryLevel) }">
  189. {{ item.summary }}
  190. </p>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. <div class="right">
  196. <img :src="moreImg" alt />
  197. </div>
  198. </div>
  199. </div>
  200. <div class="list" v-if="pageType === 1 && weekResultList.length > 0">
  201. <div class="item" v-for="(item, index) in weekResultList" :key="index" @click="onClickItem(item[1])">
  202. <div class="left">
  203. <img :src="weekImg" alt />
  204. <div class="middle">
  205. <div class="title">
  206. <span>周报</span>
  207. <p>{{ item[1].name }}</p>
  208. </div>
  209. <div class="overall">
  210. <span>总评</span>
  211. <div class="left">
  212. <p v-for="(su, index) in item[1].summaryDetails" :key="index" :style="{ color: calcResultColor(su.summaryLevel) }">
  213. {{ su.summary }}
  214. </p>
  215. <!-- <p :style="{ color: calcResultColor(item.summaryLevel) }">
  216. {{ item.summary }}
  217. </p>
  218. <p :style="{ color: calcResultColor(item.summaryLevel) }">
  219. {{ item.summary }}
  220. </p>
  221. <p :style="{ color: calcResultColor(item.summaryLevel) }">
  222. {{ item.summary }}
  223. </p> -->
  224. </div>
  225. </div>
  226. <!-- <div class="trend">
  227. <p>( <span>无抑郁倾向</span><span>5%</span>,<span>轻度抑郁倾向</span> <span>5%</span> )</p>
  228. </div>-->
  229. </div>
  230. </div>
  231. <div class="right">
  232. <img :src="moreImg" alt />
  233. </div>
  234. </div>
  235. </div>
  236. <div class="list no-data" v-if="weekList.length < 1 && weekResultList.length < 1 ">
  237. <img :src="noDataImg" alt />
  238. <p>连续佩戴两周产生对比数据</p>
  239. </div>
  240. </div>
  241. </div>
  242. <!-- 弹出层 -->
  243. <van-popup v-model="isPopup">
  244. <div class="popup">
  245. <div class="item science-tips first" v-if="emoType === 2">
  246. <div class="tips">
  247. <h5>小科普</h5>
  248. </div>
  249. <p>
  250. {{ anxietyText }}症是一种心理疾病,严重时可发展为精神障碍。然而当我们体会到了痛苦、悲伤、和郁闷等负面情绪,并不意味着我们就是{{ anxietyText
  251. }}症。日常的短时的喜、怒、哀、乐,都是正常的情绪变化,然而长期的低落情绪、兴趣缺失等可能会让我们有{{ anxietyText }}的风险。
  252. </p>
  253. </div>
  254. <div class="item">
  255. <h5 v-html="title1"></h5>
  256. <div v-html="article1"></div>
  257. </div>
  258. <div class="item">
  259. <h5 v-html="title2"></h5>
  260. <div v-html="article2"></div>
  261. </div>
  262. <van-button size="large" @click="onClose">返回</van-button>
  263. </div>
  264. </van-popup>
  265. </div>
  266. </template>
  267. <script>
  268. import { EmotionModel, PsyBaseUrl, } from "@/config/models";
  269. import axios from "axios";
  270. export default {
  271. name: "psychological-monitor",
  272. data() {
  273. return {
  274. // 日期选择标签
  275. dateList: [
  276. { name: "today", text: "今天", value: 0 },
  277. { name: "week", text: "前7天", value: 7 },
  278. { name: "month", text: "前30天", value: 30 },
  279. { name: "weekReport", text: "周报", value: 49 },
  280. ],
  281. // 情绪tab
  282. psyList: [
  283. { name: "tiredness", text: "疲劳", value: 0 },
  284. { name: "stress", text: "压力", value: 1 },
  285. { name: "depression", text: this.$replaceAll('抑郁', '抑郁', '忧郁'), value: 2 },
  286. ],
  287. // 当前情绪下标
  288. psyCurrent: 0,
  289. current: 0, // 日期选择标签-当前选中的标签
  290. currentDays: 0, //日期选择标签-日期参数
  291. emotionData: [], //情绪数据,TODO 接口对接
  292. echarts: null, //折线图
  293. itemHeight: Number(((document.body.clientWidth / 750) * 95).toFixed()), // 日历组件item高度
  294. xAxisData: [], //图表x轴展示的数据
  295. monitoringCount: "", //监测次数
  296. pieEcharts: null, //饼状图
  297. pieData: [], //饼状图数据
  298. //饼状图右边数据,TODO 根据接口数据和 模块 重新封装数组
  299. pieRightList: [
  300. /* {
  301. text: "无情绪倾向",
  302. count: 12,
  303. percentage: "80",
  304. color: "#62BD48"
  305. },
  306. {
  307. text: "轻度情绪倾向",
  308. count: 2,
  309. percentage: "80",
  310. color: "#ffde00"
  311. },
  312. {
  313. text: "中度情绪倾向",
  314. count: 1,
  315. percentage: "80",
  316. color: "#ff8a00"
  317. },
  318. {
  319. text: "重度情绪倾向",
  320. count: 1,
  321. percentage: "80",
  322. color: "#d70d0d"
  323. } */
  324. ],
  325. // 情绪状态列表
  326. statisticsList: [
  327. /* { label: "最大值", value: "75", time: "08:15" },
  328. { label: "最小值", value: "40", time: "10:15" },
  329. { label: "最近值", value: "50", time: "18:15" } */
  330. ],
  331. // 周报-情绪计算
  332. emotionList: [
  333. /* { days: "5", text: "无情绪倾向", color: "#62BD48" },
  334. { days: "4", text: "轻度情绪倾向", color: "#ffde00" },
  335. { days: "3", text: "中度情绪倾向", color: "#ff8a00" },
  336. { days: "2", text: "重度情绪倾向", color: "#ACACAC" } */
  337. ],
  338. // 弹窗-日历是否显示
  339. calendarDialogShow: false,
  340. // 日历是否显示,默认为true
  341. calendarShow: true,
  342. // 日历 默认最小可选择日期,默认为最近1个月
  343. minDate: new Date(
  344. this.$dayjs()
  345. .month(this.$dayjs().month() - 1)
  346. .hour(0)
  347. .minute(0)
  348. .second(0)
  349. .format()
  350. ),
  351. // 日历 默认最小可选择日期,默认为当前时间
  352. maxDate: new Date(this.$dayjs().hour(0).minute(0).second(0).format()),
  353. // 默认日历日期时间
  354. defaultDate: new Date(this.$dayjs().hour(0).minute(0).second(0).format()),
  355. // 路由传过来的情绪参数
  356. emoName: "",
  357. // 默认折线图 Series 配置
  358. defaultSeries: null,
  359. // 非日报折线图 Series 配置
  360. weekAndMonthSeries: null,
  361. // 当前情绪类型
  362. emoType: "",
  363. // 结果解读
  364. result: "",
  365. // 需要高亮的日期数组
  366. highlightDates: [],
  367. // 选中的日历日期
  368. selectDate: "",
  369. uid: "",
  370. // 建议
  371. advice: "",
  372. // 底部天数标题
  373. surveyTitle: "" || "7天概览",
  374. // 路由中的日期
  375. routeDate: "",
  376. // 路由参数
  377. params: {},
  378. // 是否显示帮助
  379. isPopup: false,
  380. // 结果等级
  381. resultLevel: "",
  382. // 轻度级别颜色
  383. mildColor: "#ffde00",
  384. // 中度级别颜色
  385. severeColor: "#ff8a00",
  386. // 重度级别颜色
  387. moderateColor: "#d70d0d",
  388. // 7天和30天最大数据列表
  389. weekAndMonData: [],
  390. tabImgUrl: require("@/assets/img/psychological/statistical_form.png"),
  391. selectDownImg: require("@/assets/img/psychological/select_down.png"),
  392. weekImg: require("@/assets/img/psychological/week_report.png"),
  393. moreImg: require("@/assets/img/psychological/more.png"),
  394. noDataImg: require("@/assets/img/no_data_01.png"),
  395. weekList: [],
  396. startDate: "", //接口需要的开始时间
  397. endDate: "", //接口需要的结束时间
  398. currentEmoName: "", //当前情绪名称
  399. weekResultList: [], //周报新详情周报列表
  400. };
  401. },
  402. computed: {
  403. // 页面类型,0 保持不动,1显示方式为新页面显示方式
  404. pageType() {
  405. return Number(this.$route.query.pageType) || 0
  406. },
  407. anxietyText() {
  408. const appTypeList = ['1'];
  409. return appTypeList.indexOf(this.$store.getters.appType) > -1 ? `忧郁` : `抑郁`
  410. },
  411. // 默认折线图配置,echarts 具体配置 见 https://echarts.apache.org/zh/option.html#title
  412. defaultOptions() {
  413. return {
  414. time: {
  415. useUTC: false,
  416. },
  417. title: {
  418. text: this.echartsTitle,
  419. left: 1,
  420. right: 25,
  421. bottom: 20,
  422. top: "3%",
  423. textStyle: {
  424. fontSize: 16,
  425. fontWeight: "bold",
  426. },
  427. },
  428. legend: {
  429. width: "65%",
  430. orient: "horizontal",
  431. right: "5%",
  432. top: 1,
  433. bottom: "1%",
  434. itemHeight: 12,
  435. itemWidth: 12,
  436. itemGap: 10,
  437. align: "left",
  438. selectedMode: false,
  439. data: [
  440. {
  441. name: `无${this.emoName}倾向`,
  442. icon: "rect",
  443. itemStyle: {
  444. color: "#62BD48",
  445. },
  446. textStyle: {
  447. fontSize: 12,
  448. },
  449. },
  450. {
  451. name: `轻度${this.emoName}倾向`,
  452. icon: "rect",
  453. itemStyle: {
  454. color: "#ffde00",
  455. },
  456. textStyle: {
  457. fontSize: 12,
  458. },
  459. },
  460. {
  461. name: `中度${this.emoName}倾向`,
  462. itemStyle: {
  463. color: "#ff8a00",
  464. },
  465. icon: "rect",
  466. textStyle: {
  467. fontSize: 12,
  468. },
  469. },
  470. {
  471. name: `重度${this.emoName}倾向`,
  472. itemStyle: {
  473. color: "#d70d0d",
  474. },
  475. icon: "rect",
  476. textStyle: {
  477. fontSize: 12,
  478. },
  479. },
  480. ],
  481. formatter: function (name) {
  482. // 自定义显示内容
  483. if (name.length > 6) {
  484. return name.substring(0, 6) + "\n" + name.substring(6);
  485. } else {
  486. return name;
  487. }
  488. },
  489. },
  490. grid: {
  491. show: true,
  492. borderWidth: 1,
  493. top: "20%",
  494. left: "1%",
  495. right: "5%",
  496. bottom: "10%",
  497. containLabel: true,
  498. },
  499. xAxis: {
  500. type: "category",
  501. axisLine: {
  502. show: false,
  503. },
  504. textStyle: {
  505. fontSize: 10,
  506. },
  507. axisTick: {
  508. show: false,
  509. },
  510. splitLine: {
  511. show: false,
  512. lineStyle: {
  513. color: "#ddd",
  514. width: 2,
  515. },
  516. },
  517. nameLocation: "center",
  518. axisLabel: {
  519. show: true,
  520. fontSize: 12,
  521. showMinLabel: true, //显示最小值
  522. showMaxLabel: true, //显示最大值
  523. },
  524. data: this.xAxisData,
  525. },
  526. dataZoom: [
  527. /* {
  528. type: "inside",
  529. start: 0,
  530. end: 100,
  531. }, */
  532. {
  533. start: 0,
  534. end: 100,
  535. textStyle: {
  536. color: "#FFF",
  537. fontSize: 14,
  538. },
  539. show: true,
  540. height: 15,
  541. bottom: 5,
  542. handleStyle: {
  543. borderWidth: 1,
  544. borderCap: "square",
  545. },
  546. },
  547. ],
  548. tooltip: {
  549. trigger: "axis",
  550. textStyle: {
  551. fontSize: 14,
  552. align: "center",
  553. },
  554. formatter: function (params) {
  555. return (
  556. params[0].marker +
  557. params[0].name +
  558. "--" +
  559. params[0].value +
  560. "</br>"
  561. );
  562. },
  563. },
  564. yAxis: {
  565. type: "value",
  566. max: 100,
  567. min: 0,
  568. interval: 20,
  569. splitNumber: 1,
  570. boundaryGap: ["5%", "5%"],
  571. nameTextStyle: {
  572. fontSize: 13,
  573. },
  574. alignTicks: true,
  575. axisTick: {
  576. show: true,
  577. },
  578. axisLabel: {
  579. show: true,
  580. fontSize: 13,
  581. },
  582. splitLine: {
  583. show: true,
  584. lineStyle: {
  585. color: "#ddd",
  586. width: 1,
  587. },
  588. },
  589. },
  590. series: [
  591. {
  592. name: `无${this.emoName}倾向`,
  593. type: "line",
  594. padding: 5,
  595. data: this.emotionData,
  596. symbol: "circle",
  597. symbolSize: 8,
  598. },
  599. {
  600. name: `轻度${this.emoName}倾向`,
  601. type: "line",
  602. data: "",
  603. },
  604. {
  605. name: `中度${this.emoName}倾向`,
  606. type: "line",
  607. data: "",
  608. },
  609. {
  610. name: `重度${this.emoName}倾向`,
  611. type: "line",
  612. data: "",
  613. },
  614. ],
  615. };
  616. },
  617. imei() {
  618. return this.$store.getters.serialNo;
  619. },
  620. // 饼状图配置
  621. pieOption() {
  622. return {
  623. tooltip: {
  624. trigger: "item",
  625. textStyle: {
  626. fontSize: 14,
  627. },
  628. position: "right",
  629. },
  630. legend: {
  631. top: "5%",
  632. left: "center",
  633. show: false,
  634. },
  635. series: [
  636. {
  637. type: "pie",
  638. radius: ["40%", "80%"],
  639. avoidLabelOverlap: false,
  640. startAngle: 270, // 设置逆时针渲染
  641. itemStyle: {
  642. borderRadius: 5,
  643. borderColor: "#fff",
  644. borderWidth: 2,
  645. fontSize: 16,
  646. },
  647. label: {
  648. show: false,
  649. position: "center",
  650. fontSize: 16,
  651. },
  652. emphasis: {
  653. label: {
  654. show: false,
  655. fontSize: 16,
  656. fontWeight: "bold",
  657. },
  658. },
  659. labelLine: {
  660. show: false,
  661. },
  662. data: this.pieData,
  663. },
  664. ],
  665. };
  666. },
  667. titleLeft() {
  668. let text = this.emoName === "depression" ? "趋势" : "";
  669. let today = "";
  670. if (this.currentDays !== 0) {
  671. today = "";
  672. } else {
  673. today =
  674. this.$dayjs(this.selectDate || this.defaultDate).format(
  675. "YYYY-MM-DD"
  676. ) === this.$dayjs(new Date()).format("YYYY-MM-DD")
  677. ? "今天"
  678. : "";
  679. }
  680. return `${today}${this.emoName}倾向${text}`;
  681. },
  682. // 折线图标题
  683. echartsTitle() {
  684. let today = "";
  685. if (this.currentDays !== 0) {
  686. today = "";
  687. } else {
  688. today =
  689. this.$dayjs(this.selectDate || this.defaultDate).format(
  690. "YYYY-MM-DD"
  691. ) === this.$dayjs(new Date()).format("YYYY-MM-DD")
  692. ? "今天"
  693. : "";
  694. }
  695. return `${today}${this.emoName}数据图`;
  696. },
  697. warmTips() {
  698. return `正常连续佩戴腕表,每${this.emoType == 2 ? "一" : "半"
  699. }小时计算一个${this.emoName}分值。`;
  700. /* return `正常连续佩戴手表,每半小时计算一个${this.emoName}分值,睡眠期间不进行计算。` */
  701. },
  702. title1() {
  703. return this.params.name ? this.$replaceAll(EmotionModel[this.params.name].title1, '抑郁', '忧郁') : ''
  704. },
  705. article1() {
  706. return this.params.name ? this.$replaceAll(EmotionModel[this.params.name].article1, '抑郁', '忧郁') : ''
  707. },
  708. title2() {
  709. return this.params.name ? this.$replaceAll(EmotionModel[this.params.name].title2, '抑郁', '忧郁') : ''
  710. },
  711. article2() {
  712. return this.params.name ? this.$replaceAll(EmotionModel[this.params.name].article2, '抑郁', '忧郁') : ''
  713. },
  714. // 当前情绪颜色
  715. currentColor() {
  716. return this.calcResultColor(this.resultLevel) || "#62BD48";
  717. },
  718. },
  719. watch: {
  720. // 监听数据发生变化 初始化各项图表
  721. emotionData: {
  722. handler(n, o) {
  723. this.initEchart();
  724. },
  725. deep: true,
  726. },
  727. xAxisData: {
  728. handler(n, o) {
  729. this.initEchart();
  730. },
  731. deep: true,
  732. },
  733. pieData: {
  734. handler(n, o) {
  735. this.initPieEchart();
  736. },
  737. deep: true,
  738. },
  739. },
  740. created() {
  741. // 读取路由传过来的参数,根据路由传过来的参数判断是哪种情绪
  742. this.loadParams();
  743. this.initEchartText();
  744. /* this.getPieData(); */
  745. this.getCalendarData();
  746. this.getPsychologiclData();
  747. this.getWeekResult();
  748. },
  749. mounted() {
  750. this.initEchart();
  751. if(this.params.current) {
  752. this.current = Number(this.params.current);
  753. } else {
  754. this.current = Number(this.$store.getters.tabClick) || 0;
  755. }
  756. this.currentDays = this.calcDaysByTabClick(
  757. Number(this.$store.getters.tabClick)
  758. );
  759. this.psyCurrent = this.calcPsyTabindex(EmotionModel[this.params.name].type);
  760. window.document.title = "心理监测";
  761. if(this.pageType === 1) {
  762. this.getWeekResultAny();
  763. }
  764. },
  765. methods: {
  766. loadParams() {
  767. let params = this.$route.query;
  768. if (params) {
  769. this.emoName = this.$replaceAll(EmotionModel[params.name].name, '抑郁', '忧郁');
  770. this.emoType = EmotionModel[params.name].type;
  771. this.uid = params.uid;
  772. this.routeDate = params.date;
  773. this.params = params;
  774. this.currentEmoName = params.name;
  775. if (params.date) {
  776. this.dateList[0].text =
  777. this.$dayjs(params.date).format("YYYY-MM-DD") ===
  778. this.$dayjs(new Date()).format("YYYY-MM-DD")
  779. ? "今天"
  780. : this.$dayjs(params.date).format("MM-DD");
  781. this.defaultDate = new Date(
  782. this.$dayjs(params.date).hour(0).minute(0).second(0).format()
  783. );
  784. }
  785. }
  786. },
  787. // 计算点击的天数
  788. calcDaysByTabClick(value) {
  789. let days = "";
  790. console.log("value", value);
  791. switch (value) {
  792. case 0:
  793. days = 0;
  794. break;
  795. case 1:
  796. days = 7;
  797. break;
  798. case 2:
  799. days = 30;
  800. break;
  801. case 3:
  802. days = 49;
  803. break;
  804. default:
  805. break;
  806. }
  807. return days;
  808. },
  809. // 计算psyTab的下标值
  810. calcPsyTabindex(type) {
  811. let psyIndex = "";
  812. switch (type) {
  813. case 1:
  814. psyIndex = 1;
  815. break;
  816. case 2:
  817. psyIndex = 2;
  818. break;
  819. case 3:
  820. psyIndex = 0;
  821. break;
  822. default:
  823. break;
  824. }
  825. return psyIndex;
  826. },
  827. // 获取这个月中有数据的日期,控制日历组件的日期样式
  828. getCalendarData() {
  829. let currentDate = new Date();
  830. // 获取最近30天的心情等级日历数据
  831. let dateList = this.getPostDate(currentDate, 30, true);
  832. let reqUrl = `${PsyBaseUrl}/api/Data/GetCalendarData`;
  833. let reqParams = {
  834. uid: this.uid,
  835. startDate: dateList[0],
  836. endDate: dateList[1],
  837. };
  838. axios
  839. .get(reqUrl, {
  840. params: { ...reqParams },
  841. headers: { AccessToken: this.$store.getters.ssjlToken },
  842. })
  843. .then((res) => {
  844. if (res.data) {
  845. let data = res.data.response;
  846. // const mergedArr = [...new Set([...arr1, ...arr2, ...arr3])];
  847. /* let name = this.params.name.charAt(0).toUpperCase()+ this.params.name.slice(1); */
  848. let currentName = this.currentEmoName;
  849. let list = [];
  850. if (currentName === "stress") {
  851. list = data.Stress;
  852. } else if (currentName === "depression") {
  853. list = data.Depression;
  854. } else {
  855. list = data.Tiredness;
  856. }
  857. list = list.map((item) => {
  858. item.Date = this.$dayjs(item.Date.replace(/-/g, "/")).format(
  859. "YYYY/MM/DD"
  860. );
  861. return item;
  862. });
  863. this.highlightDates = [...list];
  864. }
  865. });
  866. },
  867. // 获取饼状图数据,TODO 对接接口数据
  868. getPieData() {
  869. this.pieData = [
  870. { value: 12, name: "", itemStyle: { color: "green" } },
  871. { value: 2, name: "", itemStyle: { color: "orange" } },
  872. { value: 1, name: "", itemStyle: { color: "#FFC0CB" } },
  873. { value: 1, name: "", itemStyle: { color: "red" } },
  874. ];
  875. },
  876. // 获取情绪数据
  877. getPsychologiclData(date, startDate, endDate) {
  878. this.$toast.loading({
  879. message: "数据加载中",
  880. });
  881. let reqDate = date
  882. ? this.$dayjs(date).format("YYYY-MM-DD")
  883. : this.routeDate ||
  884. this.$dayjs(this.defaultDate).format("YYYY-MM-DD"); /* "2023-05-23" */
  885. let reqParams = {
  886. uid: this.uid,
  887. startDate: startDate || reqDate,
  888. endDate: endDate || reqDate,
  889. type: this.emoType,
  890. };
  891. console.log("请求参数", reqParams);
  892. let reqUrl = `${PsyBaseUrl}/api/Data/GetHisData`;
  893. axios
  894. .get(reqUrl, {
  895. params: { ...reqParams },
  896. headers: { AccessToken: this.$store.getters.ssjlToken },
  897. })
  898. .then((res) => {
  899. if (res.data) {
  900. let data = res.data.response;
  901. // 监测次数
  902. this.monitoringCount = data.Count;
  903. this.pieRightList = [];
  904. this.statisticsList = [];
  905. this.emotionList = [];
  906. let None = {
  907. count: data.None,
  908. percentage: this.calcPercentage(data.None, data.Count),
  909. text: `无${this.emoName}倾向`,
  910. color: "#62BD48",
  911. };
  912. let Mild = {
  913. count: data.Mild,
  914. percentage: this.calcPercentage(data.Mild, data.Count),
  915. text: `轻度${this.emoName}倾向`,
  916. color: "#ffde00",
  917. };
  918. let Moderate = {
  919. count: data.Moderate,
  920. percentage: this.calcPercentage(data.Moderate, data.Count),
  921. text: `中度${this.emoName}倾向`,
  922. color: "#ff8a00",
  923. };
  924. let Severe = {
  925. count: data.Severe,
  926. percentage: this.calcPercentage(data.Severe, data.Count),
  927. text: `重度${this.emoName}倾向`,
  928. color: "#d70d0d",
  929. };
  930. // 饼状图右边数据
  931. this.pieRightList.push(None);
  932. this.pieRightList.push(Mild);
  933. this.pieRightList.push(Moderate);
  934. this.pieRightList.push(Severe);
  935. this.pieData = this.pieRightList.map((item) => {
  936. item.value = item.count;
  937. item.itemStyle = {
  938. color: item.color,
  939. };
  940. return item;
  941. });
  942. // 最大,最小和最近值
  943. let Max = {
  944. label: "最大值",
  945. value: data.Max,
  946. time: data.MaxDesc
  947. ? this.currentDays === 0
  948. ? this.$dayjs(data.MaxDesc).format("HH:mm")
  949. : this.$dayjs(data.MaxDesc).format("MM/DD HH:mm")
  950. : "",
  951. level: data.MaxLevel
  952. };
  953. let Min = {
  954. label: "最小值",
  955. value: data.Min,
  956. time: data.MinDesc
  957. ? this.currentDays === 0
  958. ? this.$dayjs(data.MinDesc).format("HH:mm")
  959. : this.$dayjs(data.MinDesc).format("MM/DD HH:mm")
  960. : "",
  961. level: data.MinLevel
  962. };
  963. let Avg = {
  964. label: "平均值",
  965. value: data.Avg,
  966. time: data.AvgDesc
  967. ? this.currentDays === 0
  968. ? this.$dayjs(data.AvgDesc).format("HH:mm")
  969. : this.$dayjs(data.AvgDesc).format("MM/DD HH:mm")
  970. : "",
  971. level: data.AvgLevel
  972. };
  973. let Current = {
  974. label: "最近值",
  975. value: data.Current,
  976. time: data.CurrentDesc
  977. ? this.currentDays === 0
  978. ? this.$dayjs(data.CurrentDesc).format("HH:mm")
  979. : this.$dayjs(data.CurrentDesc).format("MM/DD HH:mm")
  980. : "",
  981. level: data.CurrentLevel
  982. };
  983. this.statisticsList.push(Max);
  984. this.statisticsList.push(Min);
  985. this.statisticsList.push(Avg);
  986. this.statisticsList.push(Current);
  987. // 周报月报底部显示数据
  988. let NoneDay = {
  989. days: data.NoneDay,
  990. text: `无${this.emoName}倾向`,
  991. color: "#62BD48",
  992. };
  993. let MildDay = {
  994. days: data.MildDay,
  995. text: `轻度${this.emoName}倾向`,
  996. color: "#ffde00",
  997. };
  998. let ModerateDay = {
  999. days: data.ModerateDay,
  1000. text: `中度${this.emoName}倾向`,
  1001. color: "#ff8a00",
  1002. };
  1003. let SevereDay = {
  1004. days: data.SevereDay,
  1005. text: `重度${this.emoName}倾向`,
  1006. color: "#d70d0d",
  1007. };
  1008. this.emotionList.push(NoneDay);
  1009. this.emotionList.push(MildDay);
  1010. this.emotionList.push(ModerateDay);
  1011. this.emotionList.push(SevereDay);
  1012. // 图表数据
  1013. this.emotionData = data.ChartDatas.map((item) => {
  1014. return {
  1015. value: item.Value,
  1016. itemStyle: {
  1017. color: this.calcResultColor(item.Level),
  1018. },
  1019. };
  1020. });
  1021. // 7天 和 30天柱形图显示
  1022. this.weekAndMonData = data.ChartDatas.map((item, index) => {
  1023. return {
  1024. value: [index, item.MinValue, item.MaxValue],
  1025. };
  1026. });
  1027. // x轴显示数据
  1028. if (this.currentDays === 0) {
  1029. // 显示今天数据
  1030. this.xAxisData = data.ChartDatas.map((item) => {
  1031. return this.$dayjs(item.Key.replace(/-/g, "/")).format("HH:mm");
  1032. });
  1033. } else {
  1034. this.xAxisData = data.ChartDatas.map((item) => {
  1035. return this.$dayjs(item.Key.replace(/-/g, "/")).format("MM/DD");
  1036. });
  1037. let emphasisStyle = {
  1038. itemStyle: {
  1039. shadowBlur: 10,
  1040. shadowColor: "rgba(0,0,0,0.3)",
  1041. },
  1042. };
  1043. let that = this;
  1044. // 7天和30天变成柱状图
  1045. this.weekAndMonthSeries = [
  1046. {
  1047. name: "平均值",
  1048. type: "scatter",
  1049. symbolSize: 8,
  1050. data: this.emotionData,
  1051. },
  1052. {
  1053. name: "",
  1054. type: "custom",
  1055. data: this.weekAndMonData,
  1056. renderItem: function (params, api) {
  1057. var categoryIndex = api.value(0);
  1058. var end = api.coord([categoryIndex, api.value(1)]);
  1059. var start = api.coord([categoryIndex, api.value(2)]);
  1060. var width = 8;
  1061. var rectShape = that.$echarts.graphic.clipRectByRect(
  1062. {
  1063. x: start[0] - width / 2,
  1064. y: start[1],
  1065. width: 8,
  1066. height: end[1] - start[1],
  1067. },
  1068. {
  1069. x: params.coordSys.x,
  1070. y: params.coordSys.y,
  1071. width: params.coordSys.width,
  1072. height: params.coordSys.height,
  1073. }
  1074. );
  1075. if (rectShape) {
  1076. rectShape.r = [10];
  1077. }
  1078. return (
  1079. rectShape && {
  1080. type: "rect",
  1081. shape: rectShape,
  1082. style: api.style(),
  1083. }
  1084. );
  1085. },
  1086. itemStyle: {
  1087. opacity: 0.8,
  1088. },
  1089. encode: {
  1090. y: [1, 2],
  1091. x: 0,
  1092. },
  1093. },
  1094. {
  1095. name: `轻度${this.emoName}倾向`,
  1096. type: "scatter",
  1097. symbolSize: 8,
  1098. data: "",
  1099. },
  1100. {
  1101. name: `中度${this.emoName}倾向`,
  1102. type: "scatter",
  1103. symbolSize: 8,
  1104. data: "",
  1105. },
  1106. {
  1107. name: `重度${this.emoName}倾向`,
  1108. type: "scatter",
  1109. symbolSize: 8,
  1110. data: "",
  1111. },
  1112. {
  1113. name: `无${this.emoName}倾向`,
  1114. type: "scatter",
  1115. symbolSize: 8,
  1116. data: "",
  1117. },
  1118. ];
  1119. // 点击提示此时为空
  1120. this.defaultOptions.tooltip = {
  1121. trigger: "axis",
  1122. formatter: function (params) {
  1123. return (
  1124. params[0].marker +
  1125. "平均值:" +
  1126. params[0].name +
  1127. "--" +
  1128. params[0].value +
  1129. "</br>" +
  1130. params[1].marker +
  1131. "最大值:" +
  1132. params[1].name +
  1133. "--" +
  1134. params[1].value[2] +
  1135. "</br>" +
  1136. params[1].marker +
  1137. "最小值:" +
  1138. params[1].name +
  1139. "--" +
  1140. params[1].value[1]
  1141. );
  1142. },
  1143. };
  1144. this.defaultOptions.series = this.weekAndMonthSeries;
  1145. }
  1146. // 结果解读
  1147. this.result = data.Result;
  1148. this.resultLevel = data.ResultLevel;
  1149. this.advice = data.Advice;
  1150. this.$toast.success({
  1151. message: "数据加载完成",
  1152. });
  1153. }
  1154. })
  1155. .catch(() => {
  1156. this.$dialog({
  1157. message: "登录过期,请重新进入",
  1158. });
  1159. })
  1160. .finally(() => { });
  1161. },
  1162. // 计算百分比
  1163. calcPercentage(value, total) {
  1164. if (
  1165. typeof value !== "number" ||
  1166. typeof total !== "number" ||
  1167. total === 0
  1168. ) {
  1169. return 0;
  1170. }
  1171. let milValue = value * 1000;
  1172. let milTotal = total * 1000;
  1173. return Math.round((milValue / milTotal) * 100);
  1174. },
  1175. // 初始化图表的文字内容
  1176. initEchartText() {
  1177. let text = this.emoName === "depression" ? "趋势" : "";
  1178. let today =
  1179. this.$dayjs(this.defaultDate).format("YYYY-MM-DD") ===
  1180. this.$dayjs(new Date()).format("YYYY-MM-DD")
  1181. ? "今天"
  1182. : "";
  1183. this.result = `无${this.emoName}倾向`;
  1184. this.defaultSeries = [
  1185. {
  1186. name: ``,
  1187. type: "line",
  1188. padding: 5,
  1189. data: this.emotionData,
  1190. symbol: "circle",
  1191. symbolSize: 8, // 拐点圆的大小
  1192. areaStyle: {},
  1193. },
  1194. {
  1195. name: `轻度${this.emoName}倾向`,
  1196. type: "line",
  1197. padding: 10,
  1198. data: "",
  1199. symbol: "circle",
  1200. symbolSize: 8, // 拐点圆的大小
  1201. },
  1202. {
  1203. name: `中度${this.emoName}倾向`,
  1204. type: "line",
  1205. data: "",
  1206. },
  1207. {
  1208. name: `重度${this.emoName}倾向`,
  1209. type: "line",
  1210. data: "",
  1211. },
  1212. ];
  1213. this.pieRightList = this.pieRightList.map((item) => {
  1214. item.text = item.text.replace("情绪", this.emoName);
  1215. return item;
  1216. });
  1217. },
  1218. // 初始化饼状图
  1219. initPieEchart() {
  1220. if (
  1221. this.pieEcharts != null &&
  1222. this.pieEcharts != "" &&
  1223. this.pieEcharts != undefined
  1224. ) {
  1225. this.pieEcharts.dispose();
  1226. }
  1227. this.pieEcharts = this.$echarts.init(this.$refs.pieChart);
  1228. this.pieEcharts.setOption(this.pieOption);
  1229. },
  1230. // 格式化日期显示参数
  1231. formatter(day) {
  1232. const month = day.date.getMonth() + 1;
  1233. const date = day.date.getDate();
  1234. const formatDate = this.$dayjs(day.date).format("YYYY/MM/DD");
  1235. const currentDate = this.$dayjs(new Date()).format("YYYY/MM/DD");
  1236. day.className = "custom-calendar";
  1237. for (let h = 0; h < this.highlightDates.length; h++) {
  1238. if (this.highlightDates[h].Date === formatDate) {
  1239. day.className = `highlight-border ${this.calcResultColor(
  1240. this.highlightDates[h].SummaryLevel,
  1241. true
  1242. )}`;
  1243. } else if (formatDate === currentDate) {
  1244. day.text = "今天";
  1245. }
  1246. }
  1247. return day;
  1248. },
  1249. // 返回
  1250. onNavBack() {
  1251. this.params.name = "";
  1252. this.$router.replace({
  1253. name: "psychologicalMain",
  1254. query: {
  1255. ...this.params,
  1256. },
  1257. });
  1258. },
  1259. // 点击日期选择
  1260. onTabClick(value, index) {
  1261. this.current = index;
  1262. this.currentDays = value;
  1263. this.$store.commit("tabClick", index);
  1264. let currentDate = value === 0 ? new Date() : new Date(this.$dayjs().subtract(1, 'days'))
  1265. this.surveyTitle = value === 7 ? "7天概览" : "30天概览";
  1266. if (value === 7) {
  1267. let dateList = this.getPostDate(currentDate, 6, true);
  1268. this.getPsychologiclData("", dateList[0], dateList[1]);
  1269. this.startDate = dateList[0];
  1270. this.endDate = dateList[1];
  1271. } else if (value === 0) {
  1272. // 今天
  1273. this.defaultOptions.xAxis.data = this.xAxisData;
  1274. this.defaultOptions.series = this.defaultSeries;
  1275. this.defaultOptions.series[0].data = this.emotionData;
  1276. this.getPsychologiclData(
  1277. this.selectDate
  1278. ? this.selectDate
  1279. : this.$dayjs(currentDate).format("YYYY-MM-DD")
  1280. );
  1281. this.startDate =
  1282. this.selectDate || this.$dayjs(currentDate).format("YYYY-MM-DD");
  1283. this.endDate =
  1284. this.selectDate || this.$dayjs(currentDate).format("YYYY-MM-DD");
  1285. } else if (value === 30) {
  1286. // 30天
  1287. this.defaultOptions.xAxis.data = this.xAxisData;
  1288. this.defaultOptions.series = this.defaultSeries;
  1289. this.defaultOptions.series[0].data = this.emotionData;
  1290. let dateList = this.getPostDate(currentDate, 30, true);
  1291. this.getPsychologiclData("", dateList[0], dateList[1]);
  1292. this.startDate = dateList[0];
  1293. this.endDate = dateList[1];
  1294. } else {
  1295. // 周报菜单
  1296. if(this.pageType !== 1) {
  1297. this.getWeekResult();
  1298. } else {
  1299. this.getWeekResultAny();
  1300. }
  1301. }
  1302. },
  1303. // 点击情绪tab
  1304. onPsyTabClick(name, index) {
  1305. this.psyCurrent = index;
  1306. this.emoName = this.$replaceAll(EmotionModel[name].name, '抑郁', '忧郁');
  1307. this.currentEmoName = name;
  1308. this.emoType = EmotionModel[name].type;
  1309. console.log("this.currentDays", this.currentDays);
  1310. if (this.currentDays === 49) {
  1311. // 即点击了周报,此时调用获取周报接口
  1312. this.getWeekResult();
  1313. } else {
  1314. this.getPsychologiclData(this.selectDate, this.startDate, this.endDate);
  1315. }
  1316. this.getCalendarData();
  1317. },
  1318. getCurrentMonthStaAndEnd(currentDate) {
  1319. let list = [];
  1320. let monthStart = new Date(
  1321. currentDate.getFullYear(),
  1322. currentDate.getMonth(),
  1323. 1
  1324. ); // 获取本月第一天的日期时间
  1325. let monthEnd = new Date(
  1326. currentDate.getFullYear(),
  1327. currentDate.getMonth() + 1,
  1328. 0,
  1329. 23,
  1330. 59,
  1331. 59
  1332. ); // 获取本月最后一天的日期时间(时间为23:59:59)
  1333. list.push(this.$dayjs(monthStart).format("YYYY-MM-DD"));
  1334. list.push(this.$dayjs(monthEnd).format("YYYY-MM-DD"));
  1335. return list;
  1336. },
  1337. // 获取指定天数的起始日期
  1338. /**
  1339. *
  1340. * @param dateNow :Date类
  1341. * @param intervalDays :间隔天数
  1342. * @param bolPastTime :Boolean,判断在参数date之前,还是之后,
  1343. */
  1344. getPostDate(dateNow, intervalDays, bolPastTime) {
  1345. let oneDayTime = 24 * 60 * 60 * 1000;
  1346. let list = [];
  1347. let lastDay;
  1348. if (bolPastTime == true) {
  1349. lastDay = new Date(dateNow.getTime() - intervalDays * oneDayTime);
  1350. list.push(this.formateDate(lastDay));
  1351. list.push(this.formateDate(dateNow));
  1352. } else {
  1353. lastDay = new Date(dateNow.getTime() + intervalDays * oneDayTime);
  1354. list.push(this.formateDate(dateNow));
  1355. list.push(this.formateDate(lastDay));
  1356. }
  1357. return list;
  1358. },
  1359. formateDate(time) {
  1360. let year = time.getFullYear();
  1361. let month = time.getMonth() + 1;
  1362. let day = time.getDate();
  1363. if (month < 10) {
  1364. month = "0" + month;
  1365. }
  1366. if (day < 10) {
  1367. day = "0" + day;
  1368. }
  1369. return year + "-" + month + "-" + day + "";
  1370. },
  1371. // 字体大小转化
  1372. fontChar(res) {
  1373. const clientWidth =
  1374. window.innerWidth ||
  1375. document.documentElement.clientWidth ||
  1376. document.body.clientWidth;
  1377. if (!clientWidth) return;
  1378. let fontSize = clientWidth / 750;
  1379. return res * fontSize;
  1380. },
  1381. // 初始化折线图表
  1382. initEchart() {
  1383. if (
  1384. this.echarts != null &&
  1385. this.echarts != "" &&
  1386. this.echarts != undefined
  1387. ) {
  1388. this.echarts.dispose();
  1389. }
  1390. this.echarts = this.$echarts.init(this.$refs.charts);
  1391. this.echarts.setOption(this.defaultOptions);
  1392. },
  1393. // 点击心理量表记录
  1394. onPsychologicalScale(){
  1395. this.$router.push({
  1396. name: "PsychologicalScaleList",
  1397. query: {
  1398. uid: this.uid,
  1399. accessToken: this.$store.getters.ssjlToken,
  1400. showLeftArrow:1,
  1401. },
  1402. });
  1403. },
  1404. // 点击历史监测,打开日历
  1405. onHistory() {
  1406. this.calendarDialogShow = true;
  1407. },
  1408. // 选择日历具体某一个日期
  1409. onSelect(value) {
  1410. const selectDate = this.$dayjs(value).format("YYYY-MM-DD");
  1411. this.dateList[0].text =
  1412. this.$dayjs(value).format("YYYY-MM-DD") ===
  1413. this.$dayjs(new Date()).format("YYYY-MM-DD")
  1414. ? "今天"
  1415. : this.$dayjs(value).format("MM-DD");
  1416. this.calendarDialogShow = false;
  1417. this.selectDate = selectDate;
  1418. this.startDate = selectDate;
  1419. this.endDate = selectDate;
  1420. this.current = 0;
  1421. this.getPsychologiclData(selectDate);
  1422. },
  1423. // 计算字体显示的颜色
  1424. calcColor(value) {
  1425. let color = "";
  1426. if (value <= 40) {
  1427. color = "#62BD48";
  1428. } else if (value > 40 && value <= 65) {
  1429. color = "#ffde00";
  1430. } else if (value > 65 && value <= 80) {
  1431. color = "#ff8a00";
  1432. } else if (value > 80) {
  1433. color = "#d70d0d";
  1434. } else {
  1435. color = "";
  1436. }
  1437. return color;
  1438. },
  1439. // 计算结果采用哪种颜色
  1440. calcResultColor(value, isCallBackClass) {
  1441. let color = "";
  1442. let className = "";
  1443. switch (Number(value)) {
  1444. case 0:
  1445. color = "#62BD48";
  1446. className = "none";
  1447. break;
  1448. case 1:
  1449. color = "#ffde00";
  1450. className = "mild";
  1451. break;
  1452. case 2:
  1453. color = "#ff8a00";
  1454. className = "moderate";
  1455. break;
  1456. case 3:
  1457. color = "#d70d0d";
  1458. className = "severe";
  1459. break;
  1460. }
  1461. return isCallBackClass ? className : color;
  1462. },
  1463. // 点击帮助
  1464. onHelp() {
  1465. this.isPopup = true;
  1466. },
  1467. // 关闭poup
  1468. onClose() {
  1469. this.isPopup = false;
  1470. },
  1471. //循环调用3次 GetWeekResult 接口
  1472. async getWeekResultAny() {
  1473. Promise.all([
  1474. await this.getWeekResultPro(1),
  1475. await this.getWeekResultPro(2),
  1476. await this.getWeekResultPro(3),
  1477. ]).then(res =>{
  1478. let weekResultLists = res.reduce((accumulator, currentValue) => accumulator.concat(currentValue), [])
  1479. let typeMap = {};
  1480. weekResultLists.forEach(item => {
  1481. if (!typeMap[item.name]) {
  1482. typeMap[item.name] = {
  1483. name: item.name,
  1484. recordId: [],
  1485. summary: [],
  1486. summaryLevel: [],
  1487. summaryDetails: [],
  1488. type: item.type,
  1489. };
  1490. weekResultLists.push(typeMap[item.name]);
  1491. }
  1492. typeMap[item.name].recordId.push(item.recordId);
  1493. typeMap[item.name].summary.push(item.summary);
  1494. typeMap[item.name].summaryLevel.push(item.summaryLevel);
  1495. let combinedArray = typeMap[item.name].summary.map((sum, index) => ({summary: sum, summaryLevel: typeMap[item.name].summaryLevel[index]}));
  1496. console.log(combinedArray);
  1497. typeMap[item.name].summaryDetails = combinedArray
  1498. });
  1499. let array = Object.entries(typeMap);
  1500. this.weekResultList = array.reverse();
  1501. console.log("weekResultLists", this.weekResultList);
  1502. console.log("typeMap", typeMap);
  1503. });
  1504. },
  1505. getWeekResultPro(type) {
  1506. let baseUrl =
  1507. process.env.NODE_ENV === "production"
  1508. ? "https://dbmq.rzliot.com/auth_heart"
  1509. : "https://dbmq.rzliot.com/heart";
  1510. let reqUrl = `${baseUrl}/api/Data/GetWeekResult`;
  1511. let reqParams = {
  1512. uid: this.uid /* '1929285069986332672' */,
  1513. type: type || this.emoType,
  1514. };
  1515. return new Promise(resolve => {
  1516. axios
  1517. .get(reqUrl, {
  1518. params: { ...reqParams },
  1519. /* headers: { 'AccessToken': this.$store.getters.ssjlToken } */
  1520. }).then(res => {
  1521. const data = res.data.response;
  1522. let summaryList = data.map(item => {
  1523. return {
  1524. name: item.Name.replace("周报", "")
  1525. .replace(/-/g, ".")
  1526. .replace(/~/g, "-"),
  1527. recordId: item.RecordId,
  1528. summary: this.$replaceAll(item.Summary, '抑郁', '忧郁'),
  1529. summaryLevel: item.SummaryLevel,
  1530. type: item.Type,
  1531. };
  1532. });
  1533. resolve(summaryList)
  1534. })
  1535. })
  1536. },
  1537. getWeekResult(type) {
  1538. this.$toast.loading("数据加载中");
  1539. let baseUrl =
  1540. process.env.NODE_ENV === "production"
  1541. ? "https://dbmq.rzliot.com/auth_heart"
  1542. : "https://dbmq.rzliot.com/heart";
  1543. let reqUrl = `${baseUrl}/api/Data/GetWeekResult`;
  1544. let reqParams = {
  1545. uid: this.uid /* '1929285069986332672' */,
  1546. type: this.emoType,
  1547. };
  1548. axios
  1549. .get(reqUrl, {
  1550. params: { ...reqParams },
  1551. /* headers: { 'AccessToken': this.$store.getters.ssjlToken } */
  1552. })
  1553. .then((res) => {
  1554. console.log("res", res);
  1555. const data = res.data.response;
  1556. this.weekList = data
  1557. .map((item) => {
  1558. return {
  1559. name: item.Name.replace("周报", "")
  1560. .replace(/-/g, ".")
  1561. .replace(/~/g, "-"),
  1562. recordId: item.RecordId,
  1563. summary: this.$replaceAll(item.Summary, '抑郁', '忧郁'),
  1564. summaryLevel: item.SummaryLevel,
  1565. type: this.emoType,
  1566. };
  1567. })
  1568. .reverse();
  1569. this.$toast.success("数据加载完成");
  1570. });
  1571. },
  1572. onClickItem(item) {
  1573. if(this.pageType === 1) {
  1574. // 跳转去新的周报详情页
  1575. this.$router.push({
  1576. name: "reportDetails",
  1577. query: {
  1578. recordId: item.recordId[Number(this.psyCurrent) - 1],
  1579. name: this.currentEmoName,
  1580. isShowLeft: true,
  1581. uid: this.uid,
  1582. time: item.name,
  1583. current: 3,
  1584. },
  1585. });
  1586. } else {
  1587. this.$router.push({
  1588. name: "psychologicalReport",
  1589. query: {
  1590. recordId: item.recordId,
  1591. name: this.currentEmoName,
  1592. isShowLeft: true,
  1593. uid: this.uid,
  1594. },
  1595. });
  1596. }
  1597. },
  1598. },
  1599. };
  1600. </script>
  1601. <style lang="scss">
  1602. .van-nav-bar .van-icon {
  1603. padding-left: 10px;
  1604. }
  1605. .calenddar-dialog {
  1606. overflow: scroll;
  1607. }
  1608. .calendar {
  1609. overflow: scroll;
  1610. .van-calendar {
  1611. height: 350px;
  1612. .van-calendar__header {
  1613. display: none;
  1614. }
  1615. .van-calendar__days .van-calendar__day {
  1616. width: 27px;
  1617. height: 27px;
  1618. margin: 5px;
  1619. font-size: 12px;
  1620. &.custom-calendar {
  1621. width: 27px;
  1622. height: 27px;
  1623. }
  1624. &.highlight-border {
  1625. border: 1px solid #62bd48;
  1626. width: 27px;
  1627. height: 27px;
  1628. border-radius: 50%;
  1629. &.none {
  1630. border: 1px solid #62bd48;
  1631. }
  1632. &.mild {
  1633. border: 1px solid #ffde00;
  1634. }
  1635. &.moderate {
  1636. border: 1px solid #ff8a00;
  1637. }
  1638. &.severe {
  1639. border: 1px solid #d70d0d;
  1640. }
  1641. }
  1642. }
  1643. .van-calendar__selected-day {
  1644. width: 27px;
  1645. height: 27px;
  1646. border-radius: 50%;
  1647. font-size: 12px;
  1648. }
  1649. }
  1650. }
  1651. </style>
  1652. <style scoped lang="scss">
  1653. @import "./index.scss";
  1654. </style>