index.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import OEmpty from '@/components/o-empty'
  2. import OHeader from '@/components/o-header'
  3. import OSticky from '@/components/o-sticky'
  4. import { trainCourseEmnu } from '@/constant'
  5. import request from '@/helpers/request'
  6. import { state } from '@/state'
  7. import dayjs from 'dayjs'
  8. import { Button, Cell, CellGroup, Tag } from 'vant'
  9. import { defineComponent, onMounted, reactive } from 'vue'
  10. import { useRouter } from 'vue-router'
  11. import { forms, weekFormat } from '../../create'
  12. import styles from './index.module.less'
  13. export default defineComponent({
  14. name: 'train-content',
  15. setup() {
  16. // SINGLE_DELIVERY("单交付团"),
  17. // MULTIPLE_DELIVERY("多交付常规团"),
  18. // MULTIPLE_DELIVERY_SCHOOL("多交付合并团"),
  19. // SINGLE("单技"),
  20. // MUSIC_THEORY("乐理"),
  21. // INSTRUMENTAL_ENSEMBLE("合奏");
  22. /**
  23. * 1、单交付团,所在课程时间为120分钟
  24. * 2、多交付团,乐理45分钟,其它60分钟
  25. * 3、多交付合并团,单技60分钟,合奏60分钟
  26. * */
  27. const router = useRouter()
  28. const base = reactive({
  29. contentList: [] as any,
  30. SINGLE_DELIVERY: {
  31. SINGLE: 120,
  32. MUSIC_THEORY: 120
  33. },
  34. MULTIPLE_DELIVERY: {
  35. SINGLE: 45,
  36. MUSIC_THEORY: 60,
  37. INSTRUMENTAL_ENSEMBLE: 60
  38. },
  39. MULTIPLE_DELIVERY_SCHOOL: {
  40. SINGLE: 60,
  41. MUSIC_THEORY: 60,
  42. INSTRUMENTAL_ENSEMBLE: 60
  43. },
  44. disabled: false // 判断是否有班级
  45. })
  46. const getClasses = async () => {
  47. try {
  48. const { data } = await request.get(
  49. '/api-school/orchestra/trainingContent/' + state.user.data.school.id
  50. )
  51. base.contentList = data || []
  52. } catch {
  53. //
  54. }
  55. }
  56. const onSubmit = async () => {
  57. try {
  58. const list = base.contentList
  59. const trainingPlanClassList: any = []
  60. console.log(forms, 'forms')
  61. list.forEach((item: any) => {
  62. trainingPlanClassList.push({
  63. orchestraId: item.orchestraId,
  64. classGroupIdList: item.classGroupIdList,
  65. courseNum: forms.times,
  66. startTime: dayjs(forms.trainStartTime).format('HH:mm:ss'),
  67. endTime: dayjs(forms.trainStartTime).add(120, 'minute').format('HH:mm:ss'),
  68. singleCourseTime: base[item.deliveryType][item.classType]
  69. })
  70. })
  71. const params = {
  72. week: forms.week,
  73. schoolId: state.user.data.school.id,
  74. skipHoliday: forms.skipHoliday ? true : false,
  75. type: 'STANDARD',
  76. startDate: dayjs(forms.trainStartDate).format('YYYY-MM-DD'),
  77. trainingPlanClassList
  78. }
  79. const { data } = await request.post('/api-school/orchestra/trainingPlanList', {
  80. data: {
  81. ...params
  82. }
  83. })
  84. // 初始化 课程预览时选中的乐团编号 课程预览时选中的课程组编号
  85. forms.selectOrchestraId = null
  86. forms.selectClassGroupId = null
  87. console.log(data, 'date')
  88. router.push({
  89. path: '/course-preview',
  90. query: {
  91. cacheId: data
  92. }
  93. })
  94. } catch {
  95. //
  96. }
  97. }
  98. onMounted(() => {
  99. getClasses()
  100. })
  101. return () => (
  102. <div class={base.contentList.length <= 0 && 'emptyRootContainer'}>
  103. <OHeader />
  104. {/* 训练内容 */}
  105. {base.contentList.map((item: any) => (
  106. <CellGroup inset class={styles.cellGroup}>
  107. <Cell center>
  108. {{
  109. title: () => (
  110. <div class={styles.classType}>
  111. {trainCourseEmnu[item.classType]}
  112. <Tag round type="primary" size="medium" class={styles.classNum}>
  113. {forms.times}课时
  114. </Tag>
  115. </div>
  116. ),
  117. value: () => (
  118. <span class={styles.classTime}>
  119. 每{weekFormat(forms.week)} {dayjs(forms.trainStartTime || '').format('HH:mm')}-
  120. {dayjs(forms.trainStartTime || '')
  121. .add(base[item.deliveryType][item.classType], 'minute')
  122. .format('HH:mm')}
  123. </span>
  124. )
  125. }}
  126. </Cell>
  127. <Cell center>
  128. {{
  129. title: () => (
  130. <div class={styles.orchestra}>
  131. <p class={styles.name}>{item.orchestraName}</p>
  132. <p class={styles.class}>
  133. 共<span>{item.classGroupIdList && item.classGroupIdList.length}</span>个班级
  134. </p>
  135. </div>
  136. )
  137. }}
  138. </Cell>
  139. </CellGroup>
  140. ))}
  141. {base.contentList && base.contentList.length <= 0 && (
  142. <OEmpty btnStatus={false} tips="暂无训练内容" />
  143. )}
  144. <OSticky position="bottom">
  145. <div class={'btnGroup'}>
  146. <Button round type="primary" block onClick={onSubmit}>
  147. 下一步
  148. </Button>
  149. </div>
  150. </OSticky>
  151. </div>
  152. )
  153. }
  154. })