index.tsx 9.7 KB

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