123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- 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, studentCount } = this.courseInfo
- const suffix: number = addStudents.length - removeStudents.length
- console.log(suffix, singleCourseTime, this.courseInfo)
- const type = suffix >= 0 ? 'add' : 'remove'
- // n * (n -1) * 分钟数 * 课次数
- // 总分钟数
- const allMinutes = (studentCount + 1) * studentCount * singleCourseTime
- //
- const reTime = Math.abs(
- (Math.abs(suffix) + 1) * suffix * singleCourseTime
- )
- return {
- type,
- mins: Math.abs(allMinutes - reTime)
- }
- }
- },
- render() {
- return (
- <div class={styles.studentConfirm}>
- <div class={[styles.confirmTitle, 'van-hairline--bottom']}>
- <p>您将为{this.courseInfo.groupName}</p>
- <p class={styles.timer}>{this.timer}</p>
- </div>
- <div class={styles.studentList}>
- {this.addStudents.length > 0 && (
- <>
- <p class={styles.addTitle}>
- 添加学员 <span>{this.addStudents.length}</span> 名
- </p>
- {this.addStudents.map((item: any) => (
- <Student border={false} item={item} />
- ))}
- </>
- )}
- {this.removeStudents.length > 0 && (
- <>
- <p class={styles.addTitle}>
- 移除学员 <span>{this.removeStudents.length}</span> 名
- </p>
- {this.removeStudents.map((item: any) => (
- <Student border={false} item={item} />
- ))}
- </>
- )}
- </div>
- <p class={styles.calc}>
- 调整后将{this.calcTimer.type === 'remove' ? '释放' : '冻结'}{' '}
- <span>{this.calcTimer.mins}</span> 分钟
- </p>
- <div class={styles.btnGroup}>
- <Button
- type="primary"
- round
- block
- onClick={() => {
- const { userIdList } = this.studentObject
- this.onSubmit(userIdList)
- }}
- >
- 确认调整
- </Button>
- </div>
- </div>
- )
- }
- })
|