You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.4 KiB

9 months ago
6 months ago
9 months ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="选择学员"></topNavbar>
  4. <view class="pad">
  5. <view class="searchBox" @click.capture="$goPage('/pages/recordEntry/student/addStudent/searchStudent')">
  6. <searchRow placeholder="搜索学员姓名、学员手机号" :disable="true"></searchRow>
  7. </view>
  8. <view class="ul">
  9. <view class="li" v-for="(item,index) in list" :key="index" @click="chooseSudent(item)">
  10. <view class="icon">
  11. <image src="@/static/images/index/radio_cli.png" mode="" v-if="studentIds.indexOf(item.id)!=-1"></image>
  12. <image src="@/static/images/index/radio_nor.png" mode="" v-else></image>
  13. </view>
  14. <view class="name">{{item.name}}</view>
  15. </view>
  16. </view>
  17. <view style="padding-bottom: 100rpx;" v-if="list.length>6">
  18. <u-loadmore :status="status" />
  19. </view>
  20. <nodata v-if="!list.length&&status=='nomore'"></nodata>
  21. <view class="btn_row">
  22. <view class="btnBorder">已选学员{{studentIds.length}}</view>
  23. <view class="btnBg" @click="studentBindCoachFn">确认学员</view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { studentList, studentBindCoach } from '@/config/api.js'
  30. export default {
  31. data() {
  32. return {
  33. params: {
  34. pageNo: 1,
  35. pageSize: 40,
  36. schoolId: '',
  37. coachId: '',
  38. status: 1,
  39. },
  40. total: 40,
  41. list: [],
  42. status: 'loading',
  43. studentIds: []
  44. }
  45. },
  46. onLoad() {
  47. uni.$on('addSearchSudent',(ids)=>{
  48. console.log(this.studentIds)
  49. console.log('监听不到?')
  50. this.studentIds = [...new Set([...this.studentIds,...ids])]
  51. })
  52. this.params.schoolId = this.vuex_schoolId
  53. this.studentListFn()
  54. },
  55. onPullDownRefresh() {
  56. this.initList()
  57. },
  58. onReachBottom() {
  59. if(this.total>this.list.length) {
  60. this.studentListFn()
  61. }
  62. },
  63. methods: {
  64. initList() {
  65. this.params.pageNo = 1
  66. this.list = []
  67. this.studentListFn()
  68. },
  69. async studentListFn() {
  70. const {data: res} = await studentList(this.params)
  71. this.params.pageNo ++
  72. this.total = res.total
  73. this.list.push(...res.list)
  74. if(this.list.length>=this.total) this.status = 'nomore'
  75. },
  76. chooseSudent(item) {
  77. let index = this.studentIds.indexOf(item.id)
  78. if(index==-1) {
  79. this.studentIds.push(item.id)
  80. }else {
  81. this.studentIds.splice(index,1)
  82. }
  83. },
  84. async studentBindCoachFn() {
  85. if(!this.studentIds.length) return this.$u.toast('请搜索并选择学员')
  86. let obj = {
  87. "studentIds": this.studentIds,
  88. "coachId": this.vuex_coachId,
  89. // "coachName": this.vuex_
  90. }
  91. const res = await studentBindCoach(obj)
  92. if(res.code==0) {
  93. this.$u.toast('绑定学员成功')
  94. setTimeout(()=>{
  95. uni.switchTab({
  96. url: '/pages/tabbar/student/index'
  97. })
  98. },1500)
  99. }
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .btn_row {
  106. position: fixed;
  107. bottom: 0;
  108. left: 0;
  109. padding: 10rpx 28rpx;
  110. z-index: 9;
  111. width: 100%;
  112. }
  113. .searchBox {
  114. padding: 20rpx 0;
  115. }
  116. .ul {
  117. width: 100%;
  118. .li {
  119. display: flex;
  120. align-items: center;
  121. height: 108rpx;
  122. background: #FFFFFF;
  123. border-radius: 16rpx;
  124. border: 2rpx solid rgba(25,137,250,0.2);
  125. margin-bottom: 20rpx;
  126. padding: 0 20rpx;
  127. .icon {
  128. width: 32rpx;
  129. height: 32rpx;
  130. }
  131. .name {
  132. padding: 0 20rpx;
  133. }
  134. }
  135. }
  136. .btn_row {
  137. display: flex;
  138. justify-content: space-between;
  139. .btnBorder {
  140. width: 40%;
  141. }
  142. .btnBg {
  143. width: 56%;
  144. }
  145. }
  146. </style>