Pressure.vue 9.3 KB

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