choosePatient.vue 3.8 KB

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