index.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="wrap">
  3. <view class="selectbox">
  4. <view class="example-body">
  5. <view class="">
  6. <uni-datetime-picker type="date" v-model='start_time' :clear-icon='false' placeholder='请选择开始日期' @change='startchang'></uni-datetime-picker>
  7. </view>
  8. <view class="">
  9. <uni-datetime-picker type="date" v-model='end_time' :clear-icon='false' placeholder='请选择结束日期' @chang='endchang'></uni-datetime-picker>
  10. </view>
  11. </view>
  12. <view class="dropdown">
  13. <uni-data-select :localdata="Trend" v-model="value" :clear='false'></uni-data-select>
  14. </view>
  15. </view>
  16. <view class="main_cnt">
  17. <view class="typeselect">
  18. <button type="default" @click="wei_btn" :class="table_show=='血压'?'btn_show':''">体重</button>
  19. <button type="default" @click="blo_btn" :class="table_show=='体重'?'btn_show':''">血压</button>
  20. </view>
  21. <view class="Chart">
  22. <weightTable :record="weiData" v-if="table_show=='体重' && value==1" ></weightTable>
  23. <weightLine :record="weiData" v-if="table_show=='体重' && value==0"></weightLine>
  24. <bloodpressTable :record="bloodData" v-if="table_show=='血压' && value==1"></bloodpressTable>
  25. <bloodpressLine :record="bloodData" v-if="table_show=='血压' && value==0"></bloodpressLine>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import bloodpressLine from "./component/bloodpressLine.vue";
  32. import bloodpressTable from "./component/bloodpressTable.vue";
  33. import weightLine from "./component/weightLine.vue";
  34. import weightTable from "./component/weightTable.vue";
  35. import { getweight,getbloods } from '@/api/api.js';
  36. import moment from 'moment'
  37. export default {
  38. data() {
  39. return {
  40. table_show:"体重",
  41. weiData:[],
  42. bloodData:[],
  43. value: 1,
  44. Trend:[{
  45. value: 0,
  46. text: "趋势图",
  47. },{
  48. value: 1,
  49. text: "列表图",
  50. }
  51. ],
  52. start_time:moment().subtract(7, 'days').format("YYYY-MM-DD"),
  53. end_time:moment(new Date()).format('YYYY-MM-DD'),
  54. patient_id: 0,
  55. org_id:0,
  56. currentDate:'2023-01-01',
  57. // start_time:'',
  58. // end_time:'',
  59. }
  60. },
  61. components: {
  62. bloodpressLine,
  63. bloodpressTable,
  64. weightLine,
  65. weightTable
  66. },
  67. onLoad(){
  68. this.org_id = this.$store.state.data.userInfo.user_org_id
  69. this.patient_id = this.$store.state.data.userInfo.id
  70. console.log('dddddd',this.end_time,this.start_time);
  71. this.getweightInfo(this.start_time,this.end_time,this.patient_id,this.org_id)
  72. this.getbloodInfo(this.start_time,this.end_time,this.patient_id,this.org_id)
  73. },
  74. methods: {
  75. wei_btn() {
  76. console.log('体重')
  77. this.table_show = "体重"
  78. },
  79. blo_btn(){
  80. console.log('血压')
  81. this.table_show = "血压"
  82. },
  83. async getweightInfo(start,end,patient_id,org_id) {
  84. let params = {
  85. start:start,
  86. end:end,
  87. patient_id: patient_id,
  88. org_id:org_id
  89. }
  90. let res = await getweight(params)
  91. console.log('kkkkk',res.data)
  92. // this.patient = res.data.data.patient
  93. // let arr = []
  94. let arr_mid = []
  95. let dryarr = []
  96. let arr = res.data.data.after_eweight
  97. arr_mid = res.data.data.before_eweight
  98. dryarr = res.data.data.dry_eweight
  99. // console.log(arr,'ooo')
  100. arr.forEach(el => {
  101. arr_mid.forEach(i => {
  102. // console.log(el,'el')
  103. if(el.assessment_date == i.assessment_date){
  104. this.$set(el,'weight_before',i.weight_before)
  105. }
  106. })
  107. })
  108. let newarr = arr
  109. newarr.forEach(el => {
  110. dryarr.forEach(i => {
  111. if(el.assessment_date == i.assessment_date){
  112. this.$set(el,'dry_weight',i.dry_weight)
  113. el.assessment_date = this.timestampToTime(el.assessment_date)
  114. }
  115. })
  116. })
  117. this.weiData = arr
  118. },
  119. // 获取血压
  120. async getbloodInfo(start,end,patient_id,org_id) {
  121. let params = {
  122. start:start,
  123. end:end,
  124. patient_id: patient_id,
  125. org_id:org_id
  126. }
  127. // console.log(params,'params')
  128. let res = await getbloods(params)
  129. let arr_mid = []
  130. // 透前
  131. let arr = res.data.data.before_blood
  132. // 透后
  133. arr_mid = res.data.data.after_blood
  134. arr.forEach(el => {
  135. arr_mid.forEach(i => {
  136. // console.log(el,'el')
  137. if(el.assessment_date == i.assessment_date){
  138. this.$set(el,'diastolic_blood_pressure_before',el.diastolic_blood_pressure)
  139. this.$set(el,'diastolic_blood_pressure_after',i.diastolic_blood_pressure)
  140. this.$set(el,'systolic_blood_pressure_before',el.systolic_blood_pressure)
  141. this.$set(el,'systolic_blood_pressure_after',i.systolic_blood_pressure)
  142. el.assessment_date = this.timestampToTime(el.assessment_date)
  143. }
  144. })
  145. })
  146. console.log(res.data.data,'params33333')
  147. this.bloodData = arr
  148. },
  149. timestampToTime(timestamp) {
  150. // 时间戳为10位需*1000,时间戳为13位不需乘1000
  151. var date = new Date(timestamp * 1000);
  152. var Y = date.getFullYear() + "-";
  153. var M =
  154. (date.getMonth() + 1 < 10
  155. ? "0" + (date.getMonth() + 1)
  156. : date.getMonth() + 1) + "-";
  157. var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
  158. return Y + M + D;
  159. },
  160. dateChange(d) {
  161. uni.showToast({
  162. icon: 'none',
  163. title: d
  164. })
  165. },
  166. ed(res) {
  167. // console.log(res)
  168. },
  169. datetime_click(){
  170. this.$refs.datetimepocker.show()
  171. },
  172. startchang(val){
  173. console.log('cccc',val);
  174. this.start_time = val
  175. },
  176. endchang(val){
  177. this.end_time = val
  178. }
  179. },
  180. }
  181. </script>
  182. <style lang="scss" >
  183. page {
  184. height: 100%;
  185. background-color: #f3f3f9;
  186. }
  187. .wrap {
  188. height: 100vh;
  189. /* padding: 0 30rpx; */
  190. }
  191. .example-body {
  192. display: flex;
  193. // width: 500rpx;
  194. flex: 1;
  195. }
  196. .main_cnt{
  197. padding: 0 20rpx;
  198. }
  199. .text {
  200. font-size: 12px;
  201. color: #666;
  202. margin-top: 5px;
  203. }
  204. .uni-px-5 {
  205. padding-left: 10px;
  206. padding-right: 10px;
  207. }
  208. .uni-pb-5 {
  209. padding-bottom: 10px;
  210. }
  211. .selectbox {
  212. /* margin-top: 15px; */
  213. display: flex;
  214. justify-content: space-between;
  215. // box-sizing: border-box;
  216. height: 80rpx;
  217. padding: 10rpx;
  218. background: gainsboro;
  219. }
  220. .typeselect {
  221. margin-top: 15px;
  222. display: flex;
  223. justify-content: left;
  224. }
  225. .typeselect button {
  226. margin: 0 10rpx 0 0;
  227. width: 160rpx;
  228. font-size: 33rpx;
  229. background: #00c4b3;
  230. color: #fff;
  231. }
  232. </style>
  233. <style lang="scss" scoped>
  234. /deep/ .uni-select {
  235. background: #fff;
  236. }
  237. .btn_show{
  238. background: #fff;
  239. color: #00c4b3;
  240. }
  241. </style>