choosePatient.vue 4.5 KB

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