bloodPressureDetail.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="container">
  3. <view class="datebox">
  4. <picker mode="date" fields="day" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
  5. <view class="datebox-item border-line flex-bt">
  6. <view>日期</view>
  7. <view class="datebox-item-right">
  8. <text :class="date ? '':'default'">{{date ? date : "请选择日期"}}</text>
  9. <image src="@/static/images/health/right_arrow_right_icon24.png"></image>
  10. </view>
  11. </view>
  12. </picker>
  13. <picker mode="time" :value="time" @change="bindTimeChange">
  14. <view class="datebox-item flex-bt">
  15. <view>测量时间</view>
  16. <view class="datebox-item-right">
  17. <text :class="time ? '':'default'">{{time ? time : "请选择测量时间"}}</text>
  18. <image src="@/static/images/health/right_arrow_right_icon24.png"></image>
  19. </view>
  20. </view>
  21. </picker>
  22. </view>
  23. <view class="datebox-detail">
  24. <view class="datebox-detail-header flex-bt">
  25. <view>收缩压</view>
  26. <view class="datebox-detail-header-right">
  27. <text class="num">{{sbp}}</text>
  28. <text>mmHg</text>
  29. </view>
  30. </view>
  31. <view class="scale">
  32. <simpleScale ref="simpleSBPScale" :minVal="0" :maxVal="300" :int="true" :single="10" :h="h" :active="sbp" :style="style"
  33. @value="getSBPScroll" />
  34. </view>
  35. <view class="datebox-detail-header flex-bt" style="margin-top: 48rpx;">
  36. <view>舒张压</view>
  37. <view class="datebox-detail-header-right">
  38. <text class="num">{{dbp}}</text>
  39. <text>mmHg</text>
  40. </view>
  41. </view>
  42. <view class="scale">
  43. <simpleScale ref="simpleDBPScale" :minVal="0" :maxVal="300" :int="true" :single="10" :h="h" :active="dbp" :style="style"
  44. @value="getDBPScroll" />
  45. </view>
  46. </view>
  47. <view class="h40"></view>
  48. <view class="btn-box">
  49. <view class="sub-btn" @click="submit()">记录</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {addData,getDataById,getLatest,updateData} from '@/api/healthUser.js'
  55. import simpleScale from "@/pages_echarts/components/simpleScale/simpleScale.vue"
  56. // import { bpInfo } from "@/api/pages_watch/healthMonitoring.js"
  57. export default {
  58. components: {
  59. simpleScale
  60. },
  61. data() {
  62. return {
  63. // 表示有效日期范围的开始,字符串格式为"YYYY-MM-DD"
  64. startDate:this.utils.timeFormat(new Date()) ,
  65. // 表示有效日期范围的结束,字符串格式为"YYYY-MM-DD"
  66. endDate: this.utils.timeFormat(new Date()),
  67. date: this.utils.timeFormat(new Date(),'yyyy-mm-dd'),
  68. time: this.utils.timeFormat(new Date(),'hh:MM:ss'),
  69. // 收缩压
  70. sbp: "0",
  71. // 舒张压
  72. dbp: "0",
  73. loading: false,
  74. style: {
  75. line: '#ccc',
  76. bginner: '#fbfbfb',
  77. bgoutside: '#ffffff',
  78. fontColor: '#333',
  79. fontSize: 16
  80. },
  81. h: uni.upx2px(88)
  82. }
  83. },
  84. onLoad(options) {
  85. console.log(options)
  86. this.type=options.type;
  87. this.userId=options.userId
  88. if(this.type=='edit'){
  89. this.id=options.id;
  90. this.getDataById();
  91. // this.listByIndicator()
  92. }
  93. // const param = JSON.parse(option.param)
  94. // this.date = param.createTime && param.createTime.split(' ')[0]
  95. // this.time = param.createTime && param.createTime.substring(11, 16)
  96. // this.active = String(param.num || 0)
  97. this.$nextTick(()=>{
  98. this.$refs.simpleSBPScale.init()
  99. this.$refs.simpleDBPScale.init()
  100. })
  101. },
  102. methods: {
  103. bindDateChange(e) {
  104. this.date = e.detail.value
  105. this.getList()
  106. },
  107. bindTimeChange(e) {
  108. this.time = e.detail.value
  109. this.getList()
  110. },
  111. getSBPScroll(e) {
  112. this.sbp = e
  113. },
  114. getDBPScroll(e) {
  115. this.dbp = e
  116. },
  117. getDataById(){
  118. getDataById({id:this.id}).then(
  119. res => {
  120. if(res.code==200){
  121. this.date=res.data.measurementDate
  122. this.time=res.data.measurementTime
  123. this.sbp= res.data.value1?String(res.data.value1):'0'
  124. this.dbp= res.data.value1?String(res.data.value2):'0'
  125. }else{
  126. uni.showToast({
  127. icon:'none',
  128. title: res.msg,
  129. });
  130. }
  131. },
  132. rej => {}
  133. );
  134. },
  135. submit(){
  136. var data={
  137. userId:this.userId,
  138. "measurementType": 3, //测量类型(0-腰围,1-臀围,2-血糖,3-血压,4-尿酸 5-BMI)
  139. "value1": this.sbp, //数值1(测量值1 测量值只有一个时默认填写/身高cm/舒张压)
  140. "value2": this.dbp,
  141. "measurementDate": this.date, //测量日期 yyyy-MM-dd
  142. "measurementTime":this.time//测量时间 HH:mm:ss
  143. }
  144. if(this.type=="add"){
  145. this.addData(data)
  146. }
  147. else if(this.type=="edit"){
  148. data.id=this.id
  149. this.updateData(data)
  150. }
  151. },
  152. addData(data){
  153. addData(data).then(
  154. res => {
  155. if(res.code==200){
  156. uni.showToast({
  157. icon:'success',
  158. title: "操作成功",
  159. });
  160. setTimeout(function() {
  161. uni.$emit('refreshBloodPressureList');
  162. // uni.$emit('refreshBloodPressure');
  163. uni.navigateBack({
  164. delta: 1
  165. })
  166. }, 500);
  167. }else{
  168. uni.showToast({
  169. icon:'none',
  170. title: res.msg,
  171. });
  172. }
  173. },
  174. rej => {}
  175. );
  176. },
  177. updateData(data){
  178. updateData(data).then(
  179. res => {
  180. if(res.code==200){
  181. uni.showToast({
  182. icon:'success',
  183. title: "更新成功",
  184. });
  185. setTimeout(function() {
  186. uni.$emit('refreshBloodPressureList');
  187. // uni.$emit('refreshBloodPressure');
  188. uni.navigateBack({
  189. delta: 1
  190. })
  191. }, 500);
  192. }else{
  193. uni.showToast({
  194. icon:'none',
  195. title: res.msg,
  196. });
  197. }
  198. },
  199. rej => {}
  200. );
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. @mixin u-flex($flexD, $alignI, $justifyC) {
  207. display: flex;
  208. flex-direction: $flexD;
  209. align-items: $alignI;
  210. justify-content: $justifyC;
  211. }
  212. .flex-bt {
  213. @include u-flex(row, center, space-between);
  214. }
  215. .default {
  216. font-weight: 400;
  217. font-size: 28rpx;
  218. color: #999999;
  219. }
  220. .container {
  221. padding: 20rpx 24rpx;
  222. font-family: PingFang SC, PingFang SC;
  223. font-weight: 500;
  224. font-size: 32rpx;
  225. color: #333333;
  226. }
  227. .btn-box {
  228. height: 120upx;
  229. padding: 0 30upx;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. .sub-btn {
  234. width: 388rpx;
  235. height: 72rpx;
  236. line-height: 72upx;
  237. text-align: center;
  238. font-size: 32upx;
  239. font-family: PingFang SC;
  240. font-weight: bold;
  241. color: #FFFFFF;
  242. background: #FF5039;
  243. border-radius: 44upx;
  244. margin-bottom: 40upx;
  245. }
  246. }
  247. .datebox {
  248. padding: 0 32rpx;
  249. margin-bottom: 20rpx;
  250. background: #FFFFFF;
  251. border-radius: 16rpx 16rpx 16rpx 16rpx;
  252. &-item {
  253. height: 120rpx;
  254. &-right {
  255. font-weight: 400;
  256. font-size: 32rpx;
  257. @include u-flex(row, center, flex-start);
  258. image {
  259. width: 48rpx;
  260. height: 48rpx;
  261. }
  262. }
  263. }
  264. }
  265. .datebox-detail {
  266. background: #FFFFFF;
  267. border-radius: 16rpx 16rpx 16rpx 16rpx;
  268. padding: 40rpx 32rpx;
  269. &-header-right {
  270. flex-shrink: 0;
  271. font-weight: 400;
  272. font-size: 28rpx;
  273. color: #999999;
  274. .num {
  275. font-size: 48rpx;
  276. color: #333333;
  277. margin-right: 14rpx;
  278. }
  279. }
  280. }
  281. .scale {
  282. height: 176rpx;
  283. margin-top: 36rpx;
  284. overflow: hidden;
  285. background: #FFFFFF;
  286. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(170,170,170,0.1);
  287. border-radius: 0rpx 0rpx 0rpx 0rpx;
  288. border: 2rpx solid #ECECEC;
  289. // width: 200rpx;
  290. // height: 600rpx;
  291. }
  292. </style>