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.
152 lines
3.4 KiB
152 lines
3.4 KiB
<template>
|
|
<view class="pageBgImg">
|
|
<topNavbar title="选择学员"></topNavbar>
|
|
<view class="pad">
|
|
<view class="searchBox" @click.capture="$goPage('/pages/recordEntry/student/addStudent/searchStudent')">
|
|
<searchRow placeholder="搜索学员姓名、学员手机号" :disable="true"></searchRow>
|
|
</view>
|
|
<view class="ul">
|
|
<view class="li" v-for="(item,index) in list" :key="index" @click="chooseSudent(item)">
|
|
<view class="icon">
|
|
<image src="@/static/images/index/radio_cli.png" mode="" v-if="studentIds.indexOf(item.id)!=-1"></image>
|
|
<image src="@/static/images/index/radio_nor.png" mode="" v-else></image>
|
|
</view>
|
|
<view class="name">{{item.name}}</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view style="padding-bottom: 100rpx;" v-if="list.length>6">
|
|
<u-loadmore :status="status" />
|
|
</view>
|
|
<nodata v-if="!list.length&&status=='nomore'"></nodata>
|
|
|
|
<view class="btn_row">
|
|
<view class="btnBorder">已选学员({{studentIds.length}})</view>
|
|
<view class="btnBg" @click="studentBindCoachFn">确认学员</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { studentList, studentBindCoach } from '@/config/api.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
params: {
|
|
pageNo: 1,
|
|
pageSize: 40,
|
|
schoolId: '',
|
|
coachId: '',
|
|
status: 1,
|
|
},
|
|
total: 40,
|
|
list: [],
|
|
status: 'loading',
|
|
studentIds: []
|
|
}
|
|
},
|
|
onLoad() {
|
|
uni.$on('addSearchSudent',(ids)=>{
|
|
console.log(this.studentIds)
|
|
console.log('监听不到?')
|
|
this.studentIds = [...new Set([...this.studentIds,...ids])]
|
|
})
|
|
this.params.schoolId = this.vuex_schoolId
|
|
this.studentListFn()
|
|
},
|
|
onPullDownRefresh() {
|
|
this.initList()
|
|
},
|
|
onReachBottom() {
|
|
if(this.total>this.list.length) {
|
|
this.studentListFn()
|
|
}
|
|
},
|
|
methods: {
|
|
initList() {
|
|
this.params.pageNo = 1
|
|
this.list = []
|
|
this.studentListFn()
|
|
},
|
|
async studentListFn() {
|
|
const {data: res} = await studentList(this.params)
|
|
this.params.pageNo ++
|
|
this.total = res.total
|
|
this.list.push(...res.list)
|
|
if(this.list.length>=this.total) this.status = 'nomore'
|
|
},
|
|
|
|
chooseSudent(item) {
|
|
let index = this.studentIds.indexOf(item.id)
|
|
if(index==-1) {
|
|
this.studentIds.push(item.id)
|
|
}else {
|
|
this.studentIds.splice(index,1)
|
|
}
|
|
},
|
|
async studentBindCoachFn() {
|
|
if(!this.studentIds.length) return this.$u.toast('请搜索并选择学员')
|
|
let obj = {
|
|
"studentIds": this.studentIds,
|
|
"coachId": this.vuex_coachId,
|
|
// "coachName": this.vuex_
|
|
}
|
|
const res = await studentBindCoach(obj)
|
|
if(res.code==0) {
|
|
this.$u.toast('绑定学员成功')
|
|
setTimeout(()=>{
|
|
uni.switchTab({
|
|
url: '/pages/tabbar/student/index'
|
|
})
|
|
},1500)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.btn_row {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
padding: 10rpx 28rpx;
|
|
z-index: 9;
|
|
width: 100%;
|
|
|
|
}
|
|
.searchBox {
|
|
padding: 20rpx 0;
|
|
}
|
|
.ul {
|
|
width: 100%;
|
|
.li {
|
|
display: flex;
|
|
align-items: center;
|
|
height: 108rpx;
|
|
background: #FFFFFF;
|
|
border-radius: 16rpx;
|
|
border: 2rpx solid rgba(25,137,250,0.2);
|
|
margin-bottom: 20rpx;
|
|
padding: 0 20rpx;
|
|
.icon {
|
|
width: 32rpx;
|
|
height: 32rpx;
|
|
}
|
|
.name {
|
|
padding: 0 20rpx;
|
|
}
|
|
}
|
|
}
|
|
.btn_row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
.btnBorder {
|
|
width: 40%;
|
|
}
|
|
.btnBg {
|
|
width: 56%;
|
|
}
|
|
}
|
|
</style>
|