Cert.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink" :headerStyle="'background-color:'+statusTitleColor"></top-header>
  5. <div class="mui-content vongi-jkz-content">
  6. <div class="vongi-jkz-content mui-content-padded mui-clearfix">
  7. <div class="vongi-jkz-left mui-col-xs-5">
  8. <div class="mui-content-padded faceaifyy-content">
  9. <div class="faceaifyy-content-region">
  10. <img :src="detail.faceImageUrl">
  11. </div>
  12. <div class="mui-media-body" style="width: 100%;">最近体温测量<span :style="'color:'+statusTitleColor" v-text="detail.lastTemperature+'℃'"></span></div>
  13. </div>
  14. </div>
  15. <div class="vongi-jkz-right mui-col-xs-7">
  16. <ul class="mui-table-view mui-grid-view mui-grid-9 fyy-statistics">
  17. <li class="mui-table-view-cell mui-media mui-col-xs-12">
  18. <div class="vongi-jkz-list">
  19. <div class="fyy-statistics-body">
  20. <h2>{{detail.name}}<span :style="'color:'+statusTitleColor">{{statusName}}</span></h2>
  21. <a class="mui-navigate-right">
  22. <span class="mui-icon iconfont icon-erweima1"></span>
  23. </a>
  24. </div>
  25. <div class="mui-ellipsis mui-h5">湖北荆鹏软件集团有限公司</div>
  26. <div class="mui-ellipsis mui-h5">信息工程部</div>
  27. </div>
  28. </li>
  29. <li class="mui-table-view-cell mui-media mui-col-xs-6">
  30. <div class="vongi-jkz-list">
  31. <div class="fyy-statistics-body">
  32. <h3><span class="color55f868 mui-h1" v-text="detail.totalDays"></span>天</h3>
  33. </div>
  34. <div class="mui-media-body">已连续正常天数</div>
  35. </div>
  36. </li>
  37. <li class="mui-table-view-cell mui-media mui-col-xs-6">
  38. <div class="vongi-jkz-list">
  39. <div class="fyy-statistics-body">
  40. <h3><span class="colorfe616c mui-h1" v-text="detail.undetectedCount"></span>次</h3>
  41. </div>
  42. <div class="mui-media-body">漏测记录</div>
  43. </div>
  44. </li>
  45. </ul>
  46. </div>
  47. </div>
  48. <div class="mui-content-padded fyy-echarts">
  49. <div class="fyy-echarts-inter" v-for="(item,index) in chartsList">
  50. <h4 class="colorf6f448">{{item.startDate}}~{{item.endDate}}</h4>
  51. <div :id="'linePicture'+index" style="width:100%;"></div>
  52. </div>
  53. <!-- <div class="fyy-annotation" @click="doChartTips">
  54. <div class="fyy-annotation-color">
  55. <span class="color09ae47"></span><span>14天连续测温正常</span>
  56. </div>
  57. <div class="fyy-annotation-color">
  58. <span class="colorfe616c"></span><span>7天内有一次以上异常</span>
  59. </div>
  60. <div class="fyy-annotation-color">
  61. <span class="colord39d33"></span><span>14天内有一次以上异常</span>
  62. </div>
  63. </div> -->
  64. </div>
  65. </div>
  66. <loading :visible="isLoading"></loading>
  67. </div>
  68. </template>
  69. <script>
  70. import * as API_Health from '@/apis/Common/health'
  71. import echarts from 'echarts/lib/echarts'
  72. import 'echarts/lib/chart/line'
  73. import 'echarts/lib/component/legend'
  74. import 'echarts/lib/component/title'
  75. import Common from '$project/components/Common.vue'
  76. import Loading from '$project/components/Loading.vue'
  77. import TopHeader from '$project/components/TopHeader.vue'
  78. import {
  79. mapGetters,
  80. mapMutations
  81. } from 'vuex'
  82. export default {
  83. name: 'CommonHealthTemperatureInfo',
  84. components: {
  85. Common,
  86. Loading,
  87. TopHeader
  88. },
  89. data() {
  90. return {
  91. pageTitle: '健康证',
  92. isLoading: false,
  93. rightLink: {
  94. show: true,
  95. icon: 'icon-shijian',
  96. style: 'font-size:14px;color:#000;',
  97. title: '测温记录'
  98. },
  99. detail: {},
  100. subForm: {
  101. personId: ''
  102. },
  103. chartsList: [],
  104. maxTemparture: 37,
  105. //和下面的对应默认值
  106. lineColor: '#e5aa37',
  107. statusColor: '#e5aa37',
  108. statusTitleColor: '#d39d33',
  109. statusName: '异常',
  110. }
  111. },
  112. created() {
  113. this.subForm.personId = this.person_data.id;
  114. },
  115. methods: {
  116. //获取详情
  117. getDetail() {
  118. this.isLoading = true;
  119. API_Health.getCertDetail(this.subForm).then(response => {
  120. this.detail = response;
  121. this.maxTemparture = response.temperatureMax;
  122. this.isLoading = false;
  123. }).catch(error => {
  124. this.isLoading = false;
  125. mui.toast(error);
  126. })
  127. },
  128. //获取统计图表数据
  129. getEcharts() {
  130. this.isLoading = true;
  131. API_Health.getCertList(this.subForm).then(response => {
  132. this.chartsList = response;
  133. if (response.length > 0) {
  134. this.maxTemparture = response[0]['temperatureMax'];
  135. this.detail.totalDays = response[0]['totalDays'];
  136. this.detail.undetectedCount = response[0]['undetectedCount'];
  137. this.getStatus()
  138. this.echarts();
  139. }
  140. this.isLoading = false;
  141. }).catch(error => {
  142. this.isLoading = false;
  143. mui.toast(error);
  144. })
  145. },
  146. //计算显示颜色
  147. getStatus() {
  148. if (this.chartsList.length) {
  149. var chartList = this.chartsList[0]['list'].slice();
  150. chartList.reverse();
  151. //console.log(chartList)
  152. for (var index in chartList) {
  153. if (chartList[index]['value'] >= this.maxTemparture && index < 7) {
  154. this.statusColor = '#fe616c';
  155. this.statusTitleColor = '#ed5b65';
  156. this.statusName = '异常';
  157. break;
  158. } else if (chartList[index]['value'] >= this.maxTemparture && index < 14) {
  159. this.statusColor = '#e5aa37';
  160. this.statusTitleColor = '#d39d33';
  161. this.statusName = '异常';
  162. break;
  163. } else {
  164. this.statusColor = '#0bcf54';
  165. this.statusTitleColor = '#09ae47';
  166. this.statusName = '正常';
  167. }
  168. }
  169. //如果全为0则显示默认值
  170. var allzero = true;
  171. for (var index in chartList) {
  172. if (chartList[index]['value'] > 0) {
  173. allzero = false;
  174. break;
  175. }
  176. }
  177. if (allzero) {
  178. this.statusColor = '#e5aa37';
  179. this.statusTitleColor = '#d39d33';
  180. this.statusName = '异常';
  181. }
  182. }
  183. },
  184. echarts() {
  185. this.$nextTick(() => {
  186. var _titleData = [];
  187. var _listData = [];
  188. for (var index in this.chartsList) {
  189. for (var k in this.chartsList[index]['list']) {
  190. _titleData.push(this.chartsList[index]['list'][k]['name']);
  191. _listData.push(this.chartsList[index]['list'][k]['value']);
  192. }
  193. }
  194. console.log(_titleData);
  195. console.log(_listData);
  196. for (var index in this.chartsList) {
  197. var _this = this;
  198. //是否有异常数据
  199. for (var k in this.chartsList[index]['list']) {
  200. if (this.chartsList[index]['list'][k]['value'] >= this.maxTemparture) {
  201. this.lineColor = 'yellow';
  202. break;
  203. }
  204. }
  205. var wheight = window.screen.height;
  206. if (wheight < 480) {
  207. var rHeight = '180';
  208. var gHeight = '130';
  209. } else if (wheight >= 480 && wheight <= 568) {
  210. var rHeight = '190';
  211. var gHeight = '130';
  212. } else if (wheight > 568 && wheight <= 736) {
  213. var rHeight = '200';
  214. var gHeight = '130';
  215. } else {
  216. var rHeight = '230';
  217. var gHeight = '180';
  218. }
  219. // 基于准备好的dom,初始化echarts实例
  220. var myChart = echarts.init(document.getElementById('linePicture' + index));
  221. // 指定图表的配置项和数据
  222. var option = {
  223. xAxis: {
  224. type: 'category',
  225. boundaryGap: false,
  226. data: _titleData,
  227. axisLabel: {
  228. textStyle: {
  229. color: '#fff',
  230. fontSize: '12'
  231. },
  232. showMinLabel: true,
  233. showMaxLabel: true,
  234. },
  235. axisLine: {
  236. lineStyle: {
  237. type: 'solid',
  238. color: '#fff',
  239. //width: '2'
  240. }
  241. },
  242. },
  243. yAxis: {
  244. type: 'value',
  245. axisLabel: {
  246. textStyle: {
  247. color: '#fff',
  248. //fontSize: '12'
  249. },
  250. },
  251. min: 30,
  252. max: 40,
  253. splitNumber: 6,
  254. axisLine: {
  255. lineStyle: {
  256. type: 'solid',
  257. color: '#fff',
  258. //width: '2'
  259. }
  260. },
  261. splitLine: {
  262. lineStyle: {
  263. type: 'dashed',
  264. color: '#404978',
  265. }
  266. }
  267. },
  268. series: [{
  269. data: _listData,
  270. type: 'line',
  271. //smooth: true,
  272. markLine: { //添加警戒线
  273. symbol: "none", //去掉警戒线最后面的箭头
  274. name: "",
  275. silent: true,
  276. precision: 2,
  277. data: [{
  278. silent: true, //鼠标悬停事件 true没有,false有
  279. lineStyle: { //警戒线的样式 ,虚实 颜色
  280. type: "solid",
  281. color: "red"
  282. },
  283. label: {
  284. position: 'start'
  285. },
  286. yAxis: _this.maxTemparture
  287. }]
  288. },
  289. lineStyle: {
  290. normal: {
  291. color: _this.statusColor //改变区域颜色
  292. }
  293. },
  294. areaStyle: {
  295. color: _this.statusColor,
  296. }
  297. }],
  298. visualMap: {
  299. show: false,
  300. //dimension: 0,
  301. seriesIndex: 0,
  302. pieces: [{
  303. gt: _this.maxTemparture,
  304. lt: 40,
  305. color: 'red'
  306. }, {
  307. gt: 0,
  308. lt: _this.maxTemparture,
  309. color: 'green'
  310. }],
  311. },
  312. grid: {
  313. show: true,
  314. x: 40,
  315. x2: 30,
  316. y: 20,
  317. height: gHeight
  318. },
  319. };
  320. // 使用刚指定的配置项和数据显示图表。
  321. myChart.setOption(option);
  322. myChart.resize({
  323. height: rHeight + 'px'
  324. })
  325. }
  326. });
  327. },
  328. //右上角点击事件
  329. doRightLink() {
  330. this.$router.push({
  331. name: 'CommonHealthTemperatureRecord',
  332. query: {}
  333. })
  334. },
  335. asynCallBack() {},
  336. },
  337. mounted() {
  338. //获取详情
  339. this.getDetail();
  340. //获取统计图表
  341. this.getEcharts();
  342. },
  343. destroyed() {},
  344. computed: {
  345. ...mapGetters({
  346. openId: 'wx_openid',
  347. token: 'token',
  348. person_data: 'person_data',
  349. company_data: 'company_data',
  350. })
  351. }
  352. }
  353. </script>
  354. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  355. <style scoped src="$project/assets/css/sczpfyy.css"></style>
  356. <style scoped src="$project/assets/css/iconfont.css"></style>
  357. <style scoped>
  358. </style>