Temperature.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div>
  3. <div class="box-header">
  4. <div class="box-title boldtext">
  5. 体温 <span style="margin-left: 14px">{{ currentDate }}</span>
  6. </div>
  7. <div>
  8. <!-- <el-button @click="exportData" size="small" style="margin-right: 20px"
  9. >导出</el-button
  10. > -->
  11. <el-date-picker size="small" v-model="currentDatePicker" type="date" placeholder="选择日期"
  12. value-format="yyyy-MM-dd" @change="datePickerchange">
  13. </el-date-picker>
  14. </div>
  15. </div>
  16. <div v-show="!detailsType">
  17. <div style="min-width: 841px; height: 320px; width: 100%;">
  18. <div ref="heartrateChart" style="width: 100%; height: 100%;min-width: 783px;"></div>
  19. </div>
  20. </div>
  21. <!-- 列表展示 -->
  22. <div v-show="detailsType">
  23. <el-table :data="dataList" style="width: 100%">
  24. <el-table-column prop="createTime" label="时间" />
  25. <el-table-column prop="estTemp" label="体温(℃)" />
  26. <el-table-column prop="shellTemp" label="体表温度(℃)" />
  27. </el-table>
  28. <pagination v-show="(total > 0) && detailsType" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getDataPage"/>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import * as echarts from "echarts";
  34. import { queryTemperature ,queryTemperaturePageByDate} from "@/api/watch/deviceInfo";
  35. export default {
  36. props: {
  37. detailsType: {
  38. type: Boolean,
  39. default: false
  40. },
  41. deviceId: {
  42. type: String || Number,
  43. default: "",
  44. },
  45. },
  46. data() {
  47. return {
  48. total:0,
  49. dataList:[],
  50. queryParams:{
  51. pageNum: 1,
  52. pageSize: 10,
  53. deviceId:"",
  54. beginTime:"",
  55. endTime:""
  56. },
  57. currentDate: this.parseTime(new Date(), "{y}-{m}-{d}"),
  58. currentDatePicker: "",
  59. exportLoading: false,
  60. chart: null,
  61. chartOptions: {
  62. tooltip: {
  63. trigger: 'axis'
  64. },
  65. legend: {},
  66. xAxis: {
  67. boundaryGap: false,
  68. type: "time",
  69. splitNumber: 6,
  70. axisLine: {
  71. show: false,
  72. },
  73. axisTick: {
  74. show: false,
  75. },
  76. splitLine: {
  77. show: false,
  78. },
  79. axisLabel: {
  80. color: "#999999",
  81. margin: 20,
  82. // fontSize: 14,
  83. fontWeight: "bold",
  84. formatter: (value) => {
  85. return this.parseTime(value, "{h}:{i}");
  86. },
  87. }
  88. },
  89. yAxis: {
  90. type: 'value',
  91. axisLabel: {
  92. formatter: '{value} °C'
  93. }
  94. },
  95. series: [
  96. {
  97. name: '体温(℃)',
  98. symbol: "none",
  99. type: 'line',
  100. data: [],
  101. markPoint: {
  102. data: [
  103. { type: 'max', name: 'Max' },
  104. { type: 'min', name: 'Min' }
  105. ]
  106. },
  107. },
  108. {
  109. name: '体表温度(℃)',
  110. type: 'line',
  111. symbol: "none",
  112. data: [],
  113. markPoint: {
  114. data: [
  115. { type: 'max', name: 'Max' },
  116. { type: 'min', name: 'Min' }
  117. ]
  118. },
  119. }
  120. ]
  121. }
  122. }
  123. },
  124. methods: {
  125. getDataPage(){
  126. this.loading = true;
  127. this.queryParams.deviceId = this.deviceId;
  128. this.queryParams.beginTime = this.currentDate + " 00:00:00";
  129. this.queryParams.endTime = this.currentDate + " 23:59:59";
  130. queryTemperaturePageByDate(this.queryParams)
  131. .then((response) => {
  132. if (response) {
  133. this.dataList = response.rows;
  134. this.total = response.total;
  135. this.loading = false;
  136. } else {
  137. console.warn("温度分页数据返回为空或格式不正确:", response);
  138. }
  139. })
  140. .catch((error) => {
  141. console.error("获取温度分页数据失败:", error);
  142. });
  143. },
  144. datePickerchange() {
  145. this.currentDate = this.currentDatePicker || this.parseTime(new Date(), "{y}-{m}-{d}");
  146. if(this.detailsType){
  147. this.getDataPage();
  148. } else{
  149. this.getDetailsData();
  150. }
  151. },
  152. initChart() {
  153. const chartElement = this.$refs.heartrateChart;
  154. const sportChartElement = this.$refs.sportHeartrate;
  155. if (chartElement) {
  156. this.chart = echarts.init(chartElement);
  157. this.seChartOptions()
  158. }
  159. if (sportChartElement) {
  160. this.sportChart = echarts.init(sportChartElement);
  161. this.sportChart.setOption(this.sportChartOption);
  162. }
  163. },
  164. seChartOptions() {
  165. this.chartOptions.xAxis.min = this.currentDate + ' 00:00:00'
  166. this.chartOptions.xAxis.max = this.currentDate + ' 23:59:59'
  167. this.chart.setOption(this.chartOptions);
  168. },
  169. // 获取体温折线图
  170. getDetailsData() {
  171. queryTemperature(this.currentDate, this.deviceId)
  172. .then((response) => {
  173. if (response && response.data) {
  174. // console.log("------------------" + JSON.stringify(response.data, null, 2))
  175. const data1 = response.data.map((item) => (
  176. {
  177. value: [
  178. new Date(item.createTime).getTime(),
  179. item.estTemp,
  180. ],
  181. }));
  182. const data2 = response.data.map((item) => (
  183. {
  184. value: [
  185. new Date(item.createTime).getTime(),
  186. item.shellTemp,
  187. ],
  188. }));
  189. // 将数据分别赋值给不同的 series
  190. this.chartOptions.series[0].data = data1;
  191. this.chartOptions.series[1].data = data2;
  192. // 更新图表
  193. if (this.detailsType == false) {
  194. this.initChart();
  195. }
  196. } else {
  197. console.warn("体温数据返回为空或格式不正确:", response);
  198. }
  199. })
  200. .catch((error) => {
  201. console.error("获取体温数据失败:", error);
  202. });
  203. },
  204. // // 导出数据逻辑
  205. // exportData() {
  206. // this.$confirm("是否确认导出所有用户数据项?", "警告", {
  207. // confirmButtonText: "确定",
  208. // cancelButtonText: "取消",
  209. // type: "warning",
  210. // })
  211. // .then(() => {
  212. // this.exportLoading = true;
  213. // return exportHeartDate(this.currentDate, this.deviceId);
  214. // })
  215. // .then((response) => {
  216. // this.download(response.msg);
  217. // this.exportLoading = false;
  218. // })
  219. // .catch(() => {});
  220. // },
  221. },
  222. };
  223. </script>
  224. <style lang="scss" scoped>
  225. @mixin u-flex($flexD, $alignI, $justifyC) {
  226. display: flex;
  227. flex-direction: $flexD;
  228. align-items: $alignI;
  229. justify-content: $justifyC;
  230. }
  231. .fz15 {
  232. font-size: 15px !important;
  233. }
  234. .boldtext {
  235. font-size: 16px;
  236. color: #292929;
  237. line-height: 30px;
  238. font-weight: 700;
  239. }
  240. .box-header {
  241. padding: 0 15px;
  242. @include u-flex(row, center, space-between);
  243. height: 50px;
  244. }
  245. .box-title {
  246. color: #292929;
  247. font-size: 16px;
  248. font-family: PingFang SC-Medium;
  249. padding-left: 10px;
  250. border-left: 4px solid #2284ff;
  251. line-height: 13px;
  252. }
  253. .heartrate-data {
  254. @include u-flex(row, center, space-around);
  255. margin-top: 30px;
  256. &-item {
  257. height: 60px;
  258. width: 196px;
  259. border-radius: 4px;
  260. box-shadow: 0 0 10px rgba(1, 24, 54, 0.1);
  261. overflow: hidden;
  262. @include u-flex(row, center, flex-start);
  263. img {
  264. height: 41px;
  265. width: 41px;
  266. }
  267. }
  268. &-imgbox {
  269. flex-shrink: 0;
  270. height: 60px;
  271. width: 60px;
  272. @include u-flex(row, center, center);
  273. }
  274. &-right {
  275. flex: 1;
  276. text-align: center;
  277. font-size: 13px;
  278. color: #606165;
  279. font-family: PingFang SC-Medium;
  280. background: #fff;
  281. height: 60px;
  282. }
  283. &-num {
  284. font-size: 22px;
  285. color: #2c2c3b;
  286. line-height: 38px;
  287. }
  288. }
  289. .heartrate-sport {
  290. @include u-flex(row, flex-start, flex-start);
  291. margin-top: 20px;
  292. &-l {
  293. width: 490px;
  294. flex-shrink: 0;
  295. }
  296. &-r {
  297. flex: 1;
  298. max-width: 720px;
  299. }
  300. &-lechart {
  301. width: 490px;
  302. height: 300px;
  303. }
  304. &-rechart {
  305. width: 100%;
  306. @include u-flex(row, center, center);
  307. }
  308. }
  309. </style>