Bloodoxygen.vue 9.8 KB

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