uni-last.tsx 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. import request from '@/helpers/request'
  2. import { state } from '@/state'
  3. import {
  4. Button,
  5. Cell,
  6. Dialog,
  7. Empty,
  8. Field,
  9. Grid,
  10. GridItem,
  11. Icon,
  12. showConfirmDialog,
  13. showToast,
  14. Tab,
  15. Tabs
  16. } from 'vant'
  17. import OSticky from '@/components/o-sticky'
  18. import { defineComponent, onMounted, reactive, onUnmounted, ref } from 'vue'
  19. import iconEdit from '@/views/unit-test/images/icon-edit.png'
  20. import styles from './uni-last.module.less'
  21. import { useRoute, useRouter } from 'vue-router'
  22. import NewspaperItem from './modals/newspaper-item'
  23. import questIcon from '@/school/images/quest-icon.png'
  24. import { postMessage } from '@/helpers/native-message'
  25. // import { browser } from '@/helpers/utils'
  26. export default defineComponent({
  27. name: 'uni-test',
  28. setup() {
  29. const route = useRoute()
  30. const router = useRouter()
  31. // const browserInfo = browser()
  32. const activeName = ref('one')
  33. // const catchList = store
  34. const forms = ref({} as any)
  35. const datas = reactive({
  36. loading: true,
  37. list: [] as any,
  38. uniDetail: {} as any
  39. })
  40. const showTip = ref(false)
  41. // const getList = async () => {
  42. // data.loading = true
  43. // try {
  44. // const res: any = await request.post(
  45. // state.platformApi + '/courseSchedule/queryUnitExamination',
  46. // {
  47. // requestType: 'form',
  48. // data: {
  49. // lessonCoursewareId: route.query.lessonCoursewareId,
  50. // classGroupId: forms.value.classGroupId
  51. // }
  52. // }
  53. // )
  54. // // classGroupId: forms.value.classGroupId
  55. // data.list = res.data || []
  56. // } catch (error) {}
  57. // data.loading = false
  58. // }
  59. const getClassDetail = async () => {
  60. try {
  61. const { data } = await request.get(
  62. state.platformApi + `/classGroup/detail/${forms.value.classGroupId}`
  63. )
  64. forms.value.preStudentNum = data.preStudentNum || 0
  65. } catch (e) {
  66. console.log(e)
  67. }
  68. }
  69. // 获取详情
  70. const getCourseLessonDetail = async () => {
  71. try {
  72. // const query = route.query
  73. // // api-teacher/lessonCoursewareExaminationMapper/detailByCourseId
  74. // // 判断是从课程结束后,还是正常创建
  75. const { data } = await request.post(
  76. state.platformApi + `/lessonCoursewareExaminationMapper/detailByCourseId`,
  77. {
  78. requestType: 'form',
  79. data: {
  80. courseScheduleId: route.query.courseScheduleId
  81. }
  82. }
  83. )
  84. forms.value.classGroupId = data.classGroupId
  85. forms.value.classGroupName = data.classGroupName
  86. forms.value.testName = data.lessonCoursewareExaminationMapperName
  87. forms.value.orchestraName = data.orchestraName
  88. forms.value.coursewareName = data.lessonCoursewareName
  89. forms.value.lessonCoursewareId = data.lessonCoursewareExaminationMapper.lessonCoursewareId
  90. forms.value.preStudentNum = data.studentNum || 0
  91. forms.value.testId = data.lessonCoursewareExaminationMapper.id
  92. const details = data.lessonCoursewareExaminationMapper.details || []
  93. details.forEach((item: any) => {
  94. datas.uniDetail[item.level] = item
  95. })
  96. console.log(forms.value, 'forms')
  97. } catch (e) {
  98. console.log(e)
  99. }
  100. }
  101. onMounted(() => {
  102. forms.value = { ...JSON.parse(sessionStorage.getItem('unit-create') || '{}') } as any
  103. console.log(forms.value)
  104. const query = route.query
  105. // api-teacher/lessonCoursewareExaminationMapper/detailByCourseId
  106. // 判断是从课程结束后,还是正常创建
  107. if (query.courseScheduleId) {
  108. getCourseLessonDetail()
  109. } else {
  110. if (!forms.value.classGroupId) {
  111. showToast('请选择班级')
  112. return
  113. }
  114. getClassDetail()
  115. getStudentUni()
  116. }
  117. })
  118. const getStudentUni = async () => {
  119. try {
  120. const res = await request.post(
  121. state.platformApi + `/lessonCoursewareExaminationMapper/detail`,
  122. {
  123. requestType: 'form',
  124. data: {
  125. lessonCoursewareExaminationMapperId: forms.value.testId
  126. }
  127. }
  128. )
  129. res.data.details.forEach((item: any) => {
  130. datas.uniDetail[item.level] = item
  131. })
  132. } catch (e) {
  133. console.log(e)
  134. }
  135. }
  136. const onSubmit = async () => {
  137. if (!forms.value.expiryDate) {
  138. showToast('请输入截止时间')
  139. return
  140. }
  141. try {
  142. await request.post(
  143. state.platformApi + `/classGroupUnitExamination/publishUnitExamination`,
  144. {
  145. hideLoading: false,
  146. data: {
  147. classGroupId: forms.value.classGroupId,
  148. lessonCoursewareExaminationMapperId: forms.value.testId,
  149. unitExaminationName: `${forms.value?.coursewareName}-${forms.value?.testName}`,
  150. expiryDate: forms.value.expiryDate
  151. }
  152. }
  153. )
  154. showToast('创建成功')
  155. sessionStorage.removeItem('unit-create')
  156. // 如果连接上面有班级编号,说明当前页面是从原生来的
  157. if (route.query.classGroupId) {
  158. postMessage({ api: 'back' })
  159. } else {
  160. router.replace('/unit-list')
  161. }
  162. } catch (e) {
  163. console.log(e)
  164. }
  165. }
  166. return () => (
  167. <>
  168. <div class={styles.lastWrap}>
  169. <h4 class={styles.uniTitle}>
  170. <Icon name={iconEdit} class={styles.editIcon}></Icon>
  171. {forms.value?.coursewareName}-{forms.value?.testName}
  172. </h4>
  173. <div class={styles.infoWrap}>
  174. <Cell
  175. center
  176. valueClass={styles.wrapValue}
  177. value={forms.value?.orchestraName}
  178. title="乐团:"
  179. border={false}
  180. />
  181. <Cell
  182. center
  183. valueClass={styles.wrapValue}
  184. value={forms.value?.classGroupName}
  185. title="班级:"
  186. border={false}
  187. />
  188. <Cell
  189. center
  190. class={styles.heightValue}
  191. valueClass={styles.wrapValue}
  192. value={(forms.value?.preStudentNum || 0) + '人'}
  193. title="学生人数:"
  194. />
  195. <Field
  196. v-model={forms.value.expiryDate}
  197. type="number"
  198. placeholder="请输入截止日期"
  199. input-align="right"
  200. label="截止时间"
  201. >
  202. {{
  203. extra: () => (
  204. <div class={styles.loctionIconWrap}>
  205. <span style={{ color: '#777' }}> 天后截止</span>
  206. </div>
  207. )
  208. }}
  209. </Field>
  210. </div>
  211. <div class={styles.tabsWrap}>
  212. <Icon
  213. class={styles.tabsWrapIcon}
  214. name={questIcon}
  215. size={18}
  216. color="#333"
  217. onClick={() => {
  218. showTip.value = true
  219. }}
  220. />
  221. <Tabs
  222. v-model:active={activeName.value}
  223. class={styles.rankTabs}
  224. background={'#F8F8F8'}
  225. title-active-color={'#333333'}
  226. title-inactive-color={'#777'}
  227. color={'#FF8057'}
  228. shrink
  229. >
  230. <Tab name="one" title="单团学生">
  231. <NewspaperItem item={datas.uniDetail[1]}></NewspaperItem>
  232. </Tab>
  233. <Tab name="two" title="双团学生">
  234. <NewspaperItem item={datas.uniDetail[2]}></NewspaperItem>
  235. </Tab>
  236. <Tab name="three" title="多团学生">
  237. <NewspaperItem item={datas.uniDetail[3]}></NewspaperItem>
  238. </Tab>
  239. </Tabs>
  240. </div>
  241. <OSticky position="bottom">
  242. <div class={'btnGroup'}>
  243. <Button block round type="primary" onClick={onSubmit}>
  244. 创建完成
  245. </Button>
  246. </div>
  247. </OSticky>
  248. <Dialog
  249. class="exercisDetailDialog"
  250. v-model:show={showTip.value}
  251. title="提示框"
  252. confirmButtonText="我知道了"
  253. v-slots={{
  254. title: () => (
  255. <div class={styles.DialogTitle}>
  256. <span></span>
  257. <p>学生分类</p>
  258. </div>
  259. ),
  260. default: () => (
  261. <div class={styles.DialogConent}>
  262. <p>
  263. 根据学生入团的批次对不同训练阶段的学生进行分类,不同训练阶段的学生可布置不同标准的课后作业和阶段自测内容。
  264. </p>
  265. <br />
  266. <p>单团学生:最新进入本乐团的学员</p>
  267. <p>双团学生:较早进入本乐团的学员</p>
  268. <p>多团学生:最早进入本乐团的学员</p>
  269. </div>
  270. )
  271. }}
  272. ></Dialog>
  273. </div>
  274. </>
  275. )
  276. }
  277. })