choosePatient.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="patient-container">
  3. <view class="patient-box">
  4. <view class="patient-head">
  5. <view class="patient-title">选择就诊人</view>
  6. <view class="x-f" @click="addPatient()"><u-icon name="plus-circle" size="36rpx" color="#222"></u-icon>添加</view>
  7. </view>
  8. <scroll-view scroll-x :scroll-into-view="scrollIntoView" :scroll-with-animation="true" class="patient-list" v-if="patientList&&patientList.length>0">
  9. <view :id="'patient_'+i" :class="current == i ? 'patient-item patient-active':'patient-item'" v-for="(item,i) in patientList" :key="item.patientId" @click="handlePatient(item,i)">
  10. <view class="patient-name textOne">{{item.patientName}}</view>
  11. <view class="patient-info">
  12. <text class="text" v-if="item.sex==1">男</text>
  13. <text class="text" v-if="item.sex==2">女</text>
  14. <text class="text">{{$getAge(item.birthday)}}岁</text>
  15. </view>
  16. <view class="checkmarkempty" v-show="current == i">
  17. <u-icon name="checkmark" size="28rpx" color="#fff"></u-icon>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {getPatientList} from '@/api/patient'
  26. export default {
  27. props: ['patient'],
  28. data() {
  29. return {
  30. current: 0,
  31. scrollIntoView: 'patient_0',
  32. patientList: [],
  33. }
  34. },
  35. mounted() {
  36. this.getPatientList()
  37. },
  38. watch: {
  39. patient(newVal) {
  40. const index = this.patientList.findIndex(item=>item.patientId == newVal.patientId)
  41. this.current = index > -1 ? index : 0
  42. setTimeout(()=>{
  43. this.scrollIntoView = `patient_${this.current}`
  44. },100)
  45. }
  46. },
  47. methods: {
  48. getPatientList(){
  49. uni.showLoading({
  50. title:"正在加载中"
  51. })
  52. getPatientList().then(
  53. res => {
  54. uni.hideLoading()
  55. if(res.code==200){
  56. this.patientList=res.data;
  57. const patient = this.patientList&&this.patientList.length> 0 ? this.patientList[this.current] : null
  58. uni.$emit('refreshOrderPatient',patient)
  59. }else{
  60. uni.showToast({
  61. icon:'none',
  62. title: "请求失败",
  63. });
  64. }
  65. },
  66. rej => {}
  67. );
  68. },
  69. addPatient() {
  70. this.$emit('addPatient')
  71. },
  72. handlePatient(item,i) {
  73. const patient = this.patientList&&this.patientList.length> 0 ? this.patientList[i] : null
  74. uni.$emit('refreshOrderPatient',patient)
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. @mixin u-flex($flexD, $alignI, $justifyC) {
  81. display: flex;
  82. flex-direction: $flexD;
  83. align-items: $alignI;
  84. justify-content: $justifyC;
  85. }
  86. .patient{
  87. &-container {
  88. padding: 15rpx;
  89. }
  90. &-box {
  91. padding: 30rpx 24rpx;
  92. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  93. background-color: #fff;
  94. border-radius: 15rpx;
  95. }
  96. &-head {
  97. @include u-flex(row, center, space-between);
  98. font-size: 26rpx;
  99. font-family: PingFang SC;
  100. color: #222;
  101. }
  102. &-title {
  103. font-size: 32rpx;
  104. font-weight: bold;
  105. }
  106. &-list {
  107. white-space: nowrap;
  108. width: 100%;
  109. }
  110. &-item {
  111. margin-top: 20rpx;
  112. width: 200rpx;
  113. margin-right: 16rpx;
  114. display: inline-block;
  115. box-sizing: border-box;
  116. padding: 10rpx 16rpx;
  117. border-radius: 12rpx;
  118. border: 1px solid #eee;
  119. font-size: 26rpx;
  120. font-family: PingFang SC;
  121. color: #999;
  122. position: relative;
  123. }
  124. &-active{
  125. border: 1px solid #FF5C03;
  126. &::after {
  127. position: absolute;
  128. bottom: 0;
  129. right: 0;
  130. content: "";
  131. height: 0;
  132. width: 0;
  133. border-top: 24rpx solid transparent;
  134. border-right: 24rpx solid #FF5C03;
  135. border-bottom: 24rpx solid #FF5C03;
  136. border-left: 24rpx solid transparent;
  137. border-radius: 0 0 12rpx 0;
  138. }
  139. }
  140. &-name {
  141. overflow: hidden;
  142. margin-bottom: 10rpx;
  143. font-size: 30rpx;
  144. font-weight: bold;
  145. color: #222;
  146. }
  147. &-info {
  148. @include u-flex(row, center, flex-start);
  149. .text{
  150. margin-right: 19upx;
  151. }
  152. }
  153. }
  154. .checkmarkempty {
  155. position: absolute;
  156. bottom: 0;
  157. right: 0;
  158. z-index: 2;
  159. }
  160. </style>