select-teacher.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import OHeader from '@/components/o-header'
  2. import OPopup from '@/components/o-popup'
  3. import OSticky from '@/components/o-sticky'
  4. import { Button, Cell, CellGroup, Dialog, Field, showDialog, showToast } from 'vant'
  5. import { defineComponent, reactive } from 'vue'
  6. import TeacherList from '../modal/teacher-list'
  7. import styles from './select-teacher.module.less'
  8. import { state as baseState } from '@/state'
  9. import { createState as state, resestState } from './create'
  10. import { useRouter } from 'vue-router'
  11. import request from '@/helpers/request'
  12. export default defineComponent({
  13. name: 'teacher-list',
  14. emits: ['close'],
  15. setup() {
  16. const router = useRouter()
  17. const forms = reactive({
  18. teacherStatus: false,
  19. status: false
  20. })
  21. const onSubmit = async () => {
  22. // forms.status = true
  23. showDialog({
  24. title: '提示',
  25. message: '是否创建乐团?',
  26. showCancelButton: true
  27. }).then(async () => {
  28. try {
  29. const selectSubjects = state.selectLastTeacherSubjects || []
  30. const tempSelects: any = []
  31. selectSubjects.forEach((item: any) => {
  32. tempSelects.push({
  33. teacherId: item.teacher.id,
  34. type: item.type,
  35. subjectId: item.id,
  36. studentIdList: [...item.students]
  37. })
  38. })
  39. console.log(tempSelects, 'tempselects')
  40. // return
  41. await request.post('/api-school/orchestra/addOrchestra', {
  42. data: {
  43. schoolId: baseState.user.data.school.id,
  44. name: state.orchestraName,
  45. classGroupList: [...tempSelects]
  46. }
  47. })
  48. showToast('创建成功')
  49. forms.status = true
  50. } catch {
  51. //
  52. }
  53. })
  54. }
  55. const onConfirm = () => {
  56. resestState()
  57. router.replace('/train-planning')
  58. }
  59. // 取消
  60. const onCancel = () => {
  61. resestState()
  62. router.replace('/my-orchestra')
  63. }
  64. return () => (
  65. <div>
  66. <OHeader title="选择老师" />
  67. <CellGroup inset class={styles.cellGroup}>
  68. {state.selectLastTeacherSubjects.map((subject: any) => (
  69. <Cell
  70. center
  71. onClick={() => {
  72. forms.teacherStatus = true
  73. state.selectTeacher = subject
  74. }}
  75. isLink
  76. >
  77. {{
  78. title: () => <span class={styles.title}>{subject.name}</span>,
  79. value: () => (
  80. <>
  81. {subject.teacher?.nickname ? (
  82. <p class={styles.name}>{subject.teacher?.nickname || ''}</p>
  83. ) : (
  84. <p class={styles.tips}>请选择老师</p>
  85. )}
  86. </>
  87. )
  88. }}
  89. </Cell>
  90. ))}
  91. </CellGroup>
  92. <OSticky position="bottom">
  93. <div class={['btnGroup']}>
  94. <Button type="primary" round block onClick={onSubmit}>
  95. 创建成功
  96. </Button>
  97. </div>
  98. </OSticky>
  99. <OPopup v-model:modelValue={forms.teacherStatus} position="bottom">
  100. <TeacherList
  101. onClose={() => (forms.teacherStatus = false)}
  102. onSelect={(item: any) => {
  103. state.selectTeacher.teacher = item
  104. forms.teacherStatus = false
  105. console.log(state.selectTeacher, 'select')
  106. console.log(state.selectSubjects, 'state.selectSubjects')
  107. }}
  108. />
  109. </OPopup>
  110. <Dialog
  111. v-model:show={forms.status}
  112. message="乐团创建完成,是否需要排课?"
  113. messageAlign="left"
  114. confirmButtonText="去排课"
  115. cancelButtonText="暂不排课"
  116. showCancelButton
  117. onConfirm={onConfirm}
  118. onCancel={onCancel}
  119. >
  120. {{
  121. title: () => (
  122. <div class={styles.dialogTitle}>
  123. <i></i>
  124. 创建成功
  125. </div>
  126. )
  127. }}
  128. </Dialog>
  129. </div>
  130. )
  131. }
  132. })