choosePatient.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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">
  17. <u-icon v-show="current == i" 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. methods: {
  36. getPatientList(){
  37. uni.showLoading({
  38. title:"正在加载中"
  39. })
  40. getPatientList().then(
  41. res => {
  42. uni.hideLoading()
  43. if(res.code==200){
  44. this.patientList=res.data;
  45. if(this.patient&&this.patient.patientId) {
  46. const index = this.patientList.findIndex(item=>item.patientId == this.patient.patientId)
  47. this.current = index > -1 ? index : 0
  48. } else {
  49. this.current = 0
  50. }
  51. const patient = this.patientList&&this.patientList.length> 0 ? this.patientList[this.current] : null
  52. this.scrollIntoView = 'patient_'+ this.current
  53. uni.$emit('refreshOrderPatient',patient)
  54. }else{
  55. uni.showToast({
  56. icon:'none',
  57. title: "请求失败",
  58. });
  59. }
  60. },
  61. rej => {}
  62. );
  63. },
  64. addPatient() {
  65. this.$emit('addPatient')
  66. },
  67. handlePatient(item,i) {
  68. const patient = this.patientList&&this.patientList.length> 0 ? this.patientList[i] : null
  69. this.current = i
  70. this.scrollIntoView = 'patient_'+ i
  71. uni.$emit('refreshOrderPatient',patient)
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. @mixin u-flex($flexD, $alignI, $justifyC) {
  78. display: flex;
  79. flex-direction: $flexD;
  80. align-items: $alignI;
  81. justify-content: $justifyC;
  82. }
  83. .patient{
  84. &-container {
  85. padding: 15rpx;
  86. }
  87. &-box {
  88. padding: 30rpx 24rpx;
  89. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  90. background-color: #fff;
  91. border-radius: 15rpx;
  92. }
  93. &-head {
  94. @include u-flex(row, center, space-between);
  95. font-size: 26rpx;
  96. font-family: PingFang SC;
  97. color: #222;
  98. }
  99. &-title {
  100. font-size: 32rpx;
  101. font-weight: bold;
  102. }
  103. &-list {
  104. white-space: nowrap;
  105. width: 100%;
  106. }
  107. &-item {
  108. margin-top: 20rpx;
  109. width: 200rpx;
  110. margin-right: 16rpx;
  111. display: inline-block;
  112. box-sizing: border-box;
  113. padding: 10rpx 16rpx;
  114. border-radius: 12rpx;
  115. border: 1px solid #eee;
  116. font-size: 26rpx;
  117. font-family: PingFang SC;
  118. color: #999;
  119. position: relative;
  120. }
  121. &-active{
  122. border: 1px solid #FF5C03;
  123. &::after {
  124. position: absolute;
  125. bottom: 0;
  126. right: 0;
  127. content: "";
  128. height: 0;
  129. width: 0;
  130. border-top: 24rpx solid transparent;
  131. border-right: 24rpx solid #FF5C03;
  132. border-bottom: 24rpx solid #FF5C03;
  133. border-left: 24rpx solid transparent;
  134. border-radius: 0 0 12rpx 0;
  135. }
  136. }
  137. &-name {
  138. overflow: hidden;
  139. margin-bottom: 10rpx;
  140. font-size: 30rpx;
  141. font-weight: bold;
  142. color: #222;
  143. }
  144. &-info {
  145. @include u-flex(row, center, flex-start);
  146. .text{
  147. margin-right: 19upx;
  148. }
  149. }
  150. }
  151. .checkmarkempty {
  152. position: absolute;
  153. bottom: 0;
  154. right: 0;
  155. z-index: 2;
  156. }
  157. </style>