index.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import {
  2. Button,
  3. Cell,
  4. CellGroup,
  5. Checkbox,
  6. CheckboxGroup,
  7. DatePicker,
  8. Field,
  9. Icon,
  10. Picker,
  11. Popup,
  12. Radio,
  13. RadioGroup,
  14. showToast,
  15. Sticky,
  16. Tag
  17. } from 'vant'
  18. import { defineComponent, reactive } from 'vue'
  19. import { weekdays, weekFormat } from '../../create'
  20. import styles from './index.module.less'
  21. import { forms } from '../../create'
  22. import dayjs from 'dayjs'
  23. import { useRouter } from 'vue-router'
  24. export default defineComponent({
  25. name: 'practice',
  26. setup() {
  27. const router = useRouter()
  28. const onSubmit = () => {
  29. if (forms.classType.length <= 0) {
  30. showToast('请选择课程类型')
  31. return
  32. }
  33. if (!forms.trainStartDate) {
  34. showToast('请选择课程开始日期')
  35. return
  36. }
  37. if (!forms.week) {
  38. showToast('请选择周次')
  39. return
  40. }
  41. // 初始化 训练详情
  42. const classPracticeList: any = []
  43. forms.classType.forEach((item: any) => {
  44. classPracticeList.push({
  45. classType: item,
  46. startTime: null as any,
  47. endTime: null as any,
  48. trainTimer: null as any,
  49. times: null as any,
  50. classIdList: [] as any
  51. })
  52. })
  53. forms.classPracticeList = classPracticeList
  54. router.push('/practice-detail')
  55. }
  56. return () => (
  57. <div class={styles.practice}>
  58. <div class={styles.tips}>
  59. <Icon name="warning" class={styles.icon} />
  60. 乐团加练可对任意班级进行排课
  61. </div>
  62. <CellGroup inset class={styles.cellGroup}>
  63. <Cell title="课程类型" titleClass={styles.classType}>
  64. {{
  65. value: () => (
  66. <CheckboxGroup
  67. checked-color="#FF8057"
  68. v-model={forms.classType}
  69. direction="horizontal"
  70. >
  71. <Tag
  72. size="large"
  73. type="primary"
  74. plain={!forms.classType.includes('SINGLE')}
  75. color="#FF8057"
  76. class={styles.radioSection}
  77. >
  78. <Checkbox class={styles.radioItem} name={'SINGLE'}></Checkbox>声部课
  79. </Tag>
  80. <Tag
  81. size="large"
  82. type="primary"
  83. plain={!forms.classType.includes('MUSIC_THEORY')}
  84. color="#FF8057"
  85. class={styles.radioSection}
  86. >
  87. <Checkbox class={styles.radioItem} name={'MUSIC_THEORY'}></Checkbox>乐理课
  88. </Tag>
  89. <Tag
  90. size="large"
  91. type="primary"
  92. plain={!forms.classType.includes('INSTRUMENTAL_ENSEMBLE')}
  93. color="#FF8057"
  94. class={styles.radioSection}
  95. >
  96. <Checkbox class={styles.radioItem} name={'INSTRUMENTAL_ENSEMBLE'}></Checkbox>
  97. 合奏课
  98. </Tag>
  99. </CheckboxGroup>
  100. )
  101. }}
  102. </Cell>
  103. <Field
  104. label="课程开始日期"
  105. inputAlign="right"
  106. placeholder="请选择课程开始日期"
  107. readonly
  108. isLink
  109. modelValue={
  110. forms.trainStartDate ? dayjs(forms.trainStartDate).format('YYYY年MM月DD日') : ''
  111. }
  112. onClick={() => (forms.calendarStatus = true)}
  113. />
  114. <Field
  115. label="课程周次"
  116. inputAlign="right"
  117. placeholder="请选择课程周次"
  118. readonly
  119. modelValue={weekFormat(forms.week)}
  120. isLink
  121. onClick={() => {
  122. forms.weekStatus = true
  123. // if (!forms.trainStartDate) {
  124. // showToast('请选择课程开始日期')
  125. // return
  126. // }
  127. }}
  128. />
  129. <Cell title="跳过节假日">
  130. {{
  131. value: () => (
  132. <RadioGroup
  133. checked-color="#FF8057"
  134. v-model={forms.skipHoliday}
  135. direction="horizontal"
  136. >
  137. <Tag
  138. size="large"
  139. type="primary"
  140. plain={!(forms.skipHoliday === 1)}
  141. color="#FF8057"
  142. class={styles.radioSection}
  143. >
  144. <Radio class={styles.radioItem} name={1}></Radio>是
  145. </Tag>
  146. <Tag
  147. size="large"
  148. type="primary"
  149. plain={!(forms.skipHoliday === 0)}
  150. color="#FF8057"
  151. class={styles.radioSection}
  152. >
  153. <Radio class={styles.radioItem} name={0}></Radio>否
  154. </Tag>
  155. </RadioGroup>
  156. )
  157. }}
  158. </Cell>
  159. </CellGroup>
  160. <Sticky position="bottom">
  161. <div class={'btnGroup'} style={{ marginTop: '24px' }}>
  162. <Button type="primary" block round size="large" onClick={onSubmit}>
  163. 下一步
  164. </Button>
  165. </div>
  166. </Sticky>
  167. {/* 训练周次 */}
  168. <Popup v-model:show={forms.weekStatus} position="bottom" round>
  169. <Picker
  170. columns={weekdays}
  171. onCancel={() => (forms.weekStatus = false)}
  172. onConfirm={(val: any) => {
  173. forms.week = val.selectedValues[0]
  174. forms.weekStatus = false
  175. }}
  176. />
  177. </Popup>
  178. {/* 训练开始日期 */}
  179. <Popup v-model:show={forms.calendarStatus} position="bottom" round>
  180. <DatePicker
  181. minDate={new Date()}
  182. v-model={forms.classDate}
  183. onCancel={() => (forms.calendarStatus = false)}
  184. onConfirm={(date: any) => {
  185. forms.calendarStatus = false
  186. forms.trainStartDate = date.selectedValues.join('-')
  187. // const days = dayjs(forms.trainStartDate).day()
  188. // const selectDays = weekdays[days === 0 ? 6 : days - 1]
  189. // forms.week = selectDays.value
  190. }}
  191. />
  192. </Popup>
  193. </div>
  194. )
  195. }
  196. })