天波h5前端应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 47KB

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