Pressure.vue 9.4 KB

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