Temperature.vue 10 KB

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