import dayjs from 'dayjs' import { Button } from 'vant' import { defineComponent } from 'vue' import Student from '../../components/student' import styles from './student-confirm.module.less' export default defineComponent({ name: 'studentConfirm', props: { courseInfo: { type: Object, default: {} }, studentObject: { type: Object, default: {} }, onSubmit: { type: Function, default: (item: any) => {} } }, computed: { timer() { const item: any = this.courseInfo return ( dayjs(item.startTime).format('YYYY/MM/DD HH:mm') + ' ~ ' + dayjs(item.endTime).format('HH:mm') ) }, addStudents() { const { addStudents } = this.studentObject return addStudents || [] }, removeStudents() { const { removeStudents } = this.studentObject return removeStudents || [] }, calcTimer() { const { addStudents, removeStudents } = this.studentObject const { singleCourseTime } = this.courseInfo const suffix: number = addStudents.length - removeStudents.length console.log(suffix, singleCourseTime) const type = suffix >= 0 ? 'add' : 'remove' // n * (n -1) * 分钟数 * 课次数 return { type, mins: Math.abs((Math.abs(suffix) + 1) * suffix * singleCourseTime) } } }, render() { return (

您将为{this.courseInfo.groupName}

{this.timer}

{this.addStudents.length > 0 && ( <>

添加学员 {this.addStudents.length}

{this.addStudents.map((item: any) => ( ))} )} {this.removeStudents.length > 0 && ( <>

移除学员 {this.removeStudents.length}

{this.removeStudents.map((item: any) => ( ))} )}

调整后将{this.calcTimer.type === 'remove' ? '释放' : '冻结'}{' '} {this.calcTimer.mins} 分钟

) } })