index.tsx 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. import {
  2. Button,
  3. Cell,
  4. CellGroup,
  5. Checkbox,
  6. CheckboxGroup,
  7. DatePicker,
  8. Dialog,
  9. Field,
  10. Icon,
  11. Picker,
  12. Popup,
  13. Radio,
  14. RadioGroup,
  15. showToast,
  16. Sticky,
  17. Tag
  18. } from 'vant'
  19. import { defineComponent, onMounted, reactive } from 'vue'
  20. import { weekdays, weekFormat } from '../../create'
  21. import styles from './index.module.less'
  22. import { forms } from '../../create'
  23. import dayjs from 'dayjs'
  24. import { useRouter } from 'vue-router'
  25. import OPopup from '@/components/o-popup'
  26. import ClassList from '../../modal/class-list'
  27. import request from '@/helpers/request'
  28. import { state } from '@/state'
  29. import OSticky from '@/components/o-sticky'
  30. export default defineComponent({
  31. name: 'practice',
  32. props: {
  33. address: {
  34. type: String,
  35. default: ''
  36. }
  37. },
  38. setup(props) {
  39. const router = useRouter()
  40. // 查询没有设置指导老师的班级
  41. // const getClasses = async (show = true) => {
  42. // try {
  43. // const { data } = await request.post('/api-school/classGroup/page', {
  44. // data: {
  45. // page: 1,
  46. // rows: 200,
  47. // schoolId: state.user.data.school.id,
  48. // hasTeacher: false,
  49. // orchestraType: 'DELIVERY'
  50. // }
  51. // })
  52. // // 班级数据
  53. // forms.classList = data.rows || []
  54. // // 判断没有设置伴学指导的班级
  55. // if (forms.classList.length > 0 && show) {
  56. // forms.status = true
  57. // }
  58. // } catch {
  59. // //
  60. // }
  61. // }
  62. const onSubmit = () => {
  63. // showToast('请选择课程类型')
  64. // return
  65. // 判断是否有班级没有设置伴学指导
  66. if (forms.classList.length > 0) {
  67. forms.status = true
  68. return
  69. }
  70. if (forms.classType.length <= 0) {
  71. showToast('请选择课程类型')
  72. return
  73. }
  74. if (!forms.trainStartDate) {
  75. showToast('请选择课程开始日期')
  76. return
  77. }
  78. if (!forms.week) {
  79. showToast('请选择周次')
  80. return
  81. }
  82. if (!props.address) {
  83. showToast('您所在的学校暂未设置地址')
  84. return
  85. }
  86. // 初始化 训练详情
  87. const classPracticeList: any = []
  88. forms.classType.forEach((item: any) => {
  89. classPracticeList.push({
  90. classType: item,
  91. startTime: null as any,
  92. endTime: null as any,
  93. trainTimer: null as any,
  94. times: null as any,
  95. classIdList: [] as any
  96. })
  97. })
  98. forms.classPracticeList = classPracticeList
  99. router.push('/practice-detail')
  100. }
  101. onMounted(() => {
  102. // getClasses()
  103. })
  104. return () => (
  105. <div class={styles.practice}>
  106. <div class={styles.tips}>
  107. <Icon name="warning" class={styles.icon} />
  108. 乐团加练可对任意班级进行排课
  109. </div>
  110. <CellGroup inset class={styles.cellGroup}>
  111. <Cell title="课程类型" titleClass={styles.classType}>
  112. {{
  113. value: () => (
  114. <CheckboxGroup
  115. checked-color="#FF8057"
  116. v-model={forms.classType}
  117. direction="horizontal"
  118. >
  119. <Tag
  120. size="large"
  121. type="primary"
  122. color={!forms.classType.includes('SINGLE') ? '#EAEAEA' : '#FF8057'}
  123. textColor={!forms.classType.includes('SINGLE') ? '#AAA' : '#FFF'}
  124. class={styles.radioSection}
  125. >
  126. <Checkbox class={styles.radioItem} name={'SINGLE'}></Checkbox>声部课
  127. </Tag>
  128. <Tag
  129. size="large"
  130. type="primary"
  131. color={!forms.classType.includes('MUSIC_THEORY') ? '#EAEAEA' : '#FF8057'}
  132. textColor={!forms.classType.includes('MUSIC_THEORY') ? '#AAA' : '#FFF'}
  133. class={styles.radioSection}
  134. >
  135. <Checkbox class={styles.radioItem} name={'MUSIC_THEORY'}></Checkbox>乐理课
  136. </Tag>
  137. <Tag
  138. size="large"
  139. type="primary"
  140. color={
  141. !forms.classType.includes('INSTRUMENTAL_ENSEMBLE') ? '#EAEAEA' : '#FF8057'
  142. }
  143. textColor={!forms.classType.includes('INSTRUMENTAL_ENSEMBLE') ? '#AAA' : '#FFF'}
  144. class={styles.radioSection}
  145. >
  146. <Checkbox class={styles.radioItem} name={'INSTRUMENTAL_ENSEMBLE'}></Checkbox>
  147. 合奏课
  148. </Tag>
  149. </CheckboxGroup>
  150. )
  151. }}
  152. </Cell>
  153. <Field
  154. label="课程开始日期"
  155. inputAlign="right"
  156. placeholder="请选择课程开始日期"
  157. readonly
  158. isLink
  159. modelValue={
  160. forms.trainStartDate ? dayjs(forms.trainStartDate).format('YYYY年MM月DD日') : ''
  161. }
  162. onClick={() => (forms.calendarStatus = true)}
  163. />
  164. <Field
  165. label="课程周次"
  166. inputAlign="right"
  167. placeholder="请选择课程周次"
  168. readonly
  169. modelValue={weekFormat(forms.week)}
  170. // isLink
  171. onClick={() => {
  172. // forms.weekStatus = true
  173. if (!forms.trainStartDate) {
  174. showToast('请选择课程开始日期')
  175. return
  176. }
  177. }}
  178. />
  179. <Cell title="跳过节假日">
  180. {{
  181. value: () => (
  182. <RadioGroup
  183. checked-color="#FF8057"
  184. v-model={forms.skipHoliday}
  185. direction="horizontal"
  186. >
  187. <Tag
  188. size="large"
  189. type="primary"
  190. color={!(forms.skipHoliday === 1) ? '#EAEAEA' : '#FF8057'}
  191. textColor={!(forms.skipHoliday === 1) ? '#AAA' : '#FFF'}
  192. class={styles.radioSection}
  193. round
  194. >
  195. <Radio class={styles.radioItem} name={1}></Radio>是
  196. </Tag>
  197. <Tag
  198. size="large"
  199. type="primary"
  200. color={!(forms.skipHoliday === 0) ? '#EAEAEA' : '#FF8057'}
  201. textColor={!(forms.skipHoliday === 0) ? '#AAA' : '#FFF'}
  202. class={styles.radioSection}
  203. round
  204. >
  205. <Radio class={styles.radioItem} name={0}></Radio>否
  206. </Tag>
  207. </RadioGroup>
  208. )
  209. }}
  210. </Cell>
  211. </CellGroup>
  212. <OSticky position="bottom">
  213. <div class={'btnGroup'} style={{ marginTop: '24px' }}>
  214. <Button type="primary" block round onClick={onSubmit}>
  215. 下一步
  216. </Button>
  217. </div>
  218. </OSticky>
  219. {/* 训练周次 */}
  220. <Popup v-model:show={forms.weekStatus} position="bottom" round>
  221. <Picker
  222. columns={weekdays}
  223. onCancel={() => (forms.weekStatus = false)}
  224. onConfirm={(val: any) => {
  225. forms.week = val.selectedValues[0]
  226. forms.weekStatus = false
  227. }}
  228. />
  229. </Popup>
  230. {/* 训练开始日期 */}
  231. <Popup v-model:show={forms.calendarStatus} position="bottom" round>
  232. <DatePicker
  233. minDate={new Date()}
  234. v-model={forms.classDate}
  235. onCancel={() => (forms.calendarStatus = false)}
  236. onConfirm={(date: any) => {
  237. forms.calendarStatus = false
  238. forms.trainStartDate = date.selectedValues.join('-')
  239. const days = dayjs(forms.trainStartDate).day()
  240. const selectDays = weekdays[days === 0 ? 6 : days - 1]
  241. forms.week = selectDays.value
  242. }}
  243. />
  244. </Popup>
  245. {/* <Dialog
  246. v-model:show={forms.status}
  247. message={`您有${forms.classList.length}个班级尚未指定伴学指导,请完成指定后再进行训练规划。`}
  248. messageAlign="left"
  249. confirmButtonText="去设置"
  250. cancelButtonText="暂不设置"
  251. showCancelButton
  252. onConfirm={() => {
  253. forms.classStatus = true
  254. }}
  255. >
  256. {{
  257. title: () => (
  258. <div class={styles.dialogTitle}>
  259. <i></i>
  260. 指定伴学指导
  261. </div>
  262. )
  263. }}
  264. </Dialog>
  265. <OPopup
  266. v-model:modelValue={forms.classStatus}
  267. position="bottom"
  268. style={{ background: '#F6F6F6' }}
  269. destroy
  270. >
  271. <ClassList
  272. classList={forms.classList}
  273. onClose={() => (forms.classStatus = false)}
  274. onConfirm={() => {
  275. getClasses(false)
  276. }}
  277. />
  278. </OPopup> */}
  279. </div>
  280. )
  281. }
  282. })