index.tsx 9.2 KB

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