import OHeader from '@/components/o-header'
import {
Button,
Cell,
CellGroup,
Grid,
GridItem,
Icon,
Image,
Popup,
showDialog,
showToast,
Tag
} from 'vant'
import { defineComponent, onMounted, reactive } from 'vue'
import styles from './companion-detail.module.less'
import { postMessage } from '@/helpers/native-message'
import iconTeacher from '@common/images/icon_teacher.png'
import iconMessage from '@common/images/icon-message.png'
import iconCallPhone from '@common/images/icon-call-phone.png'
import iconCallMessage from '@common/images/icon-call-message.png'
import OSticky from '@/components/o-sticky'
import request from '@/helpers/request'
import { state as baseState } from '@/state'
import { useRoute, useRouter } from 'vue-router'
import OEmpty from '@/components/o-empty'
export default defineComponent({
name: 'companion-detail',
setup(props, { slots, attrs, emit }) {
const route = useRoute()
const router = useRouter()
const state = reactive({
showMessage: false,
detail: {} as any,
classList: [] as any
})
const getDetail = async () => {
try {
const query = route.query
const { data } = await request.post('/api-school/teacher/detail', {
data: {
teacherId: query.id,
schoolId: baseState.user.data.school.id
}
})
state.detail = data
const subjects = data.subjectName ? data.subjectName.split(',') : []
state.detail.subjectNames = subjects
} catch {
//
}
}
const getClassDetail = async () => {
try {
const query = route.query
const { data } = await request.post('/api-school/classGroup/page', {
data: {
teacherId: query.id,
schoolId: baseState.user.data.school.id,
page: 1,
rows: 100
}
})
state.classList = data.rows || []
} catch {
//
}
}
const onDetail = async () => {
if (state.classList.length > 0) {
router.push({
path: '/companion-unbind',
query: { id: route.query.id }
})
return
}
try {
showDialog({
title: '提示',
message: '是否解除绑定',
showCancelButton: true
}).then(async () => {
await request.post('/api-school/classGroup/handoverTeacher', {
data: {
teacherId: route.query.id
}
})
setTimeout(() => {
showToast('解绑成功')
}, 100)
setTimeout(() => {
router.back()
}, 1000)
})
} catch {
//
}
}
onMounted(() => {
getDetail()
getClassDetail()
})
return () => (
<>
{state.detail.nickname}
{state.detail.subjectNames.map((subject: any) => (
{state.detail.completedCourseScheduleNum || 0}/
{state.detail.totalCourseScheduleNum || 0}
课时
{item.name}
{item.orchestraName}
{item.completeCourseScheduleNum}/{item.courseScheduleNum}
总课时