index.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. import { defineComponent, onMounted, reactive, ref } from 'vue';
  2. import styles from './index.module.less';
  3. import {
  4. NButton,
  5. NDataTable,
  6. NForm,
  7. NFormItem,
  8. NImage,
  9. NModal,
  10. NProgress,
  11. NSpace
  12. } from 'naive-ui';
  13. import SearchInput from '@/components/searchInput';
  14. import CSelect from '@/components/CSelect';
  15. import Pagination from '@/components/pagination';
  16. import { api_trainingDetail, api_trainingStudentList } from '../api';
  17. import { useRoute } from 'vue-router';
  18. import CBreadcrumb from '/src/components/CBreadcrumb';
  19. import defultHeade from '@/components/layout/images/teacherIcon.png';
  20. import { trainingStatusArray } from '@/utils/searchArray';
  21. import dayjs from 'dayjs';
  22. import TheEmpty from '/src/components/TheEmpty';
  23. import TrainingDetails from '../../classList/modals/TrainingDetails';
  24. export default defineComponent({
  25. name: 'homewrok-record-detail',
  26. setup() {
  27. const route = useRoute();
  28. const state = reactive({
  29. searchForm: { keyword: '', trainingStatus: '' as any },
  30. loading: false,
  31. pagination: {
  32. page: 1,
  33. rows: 10,
  34. pageTotal: 4
  35. },
  36. tableList: [] as any,
  37. workInfo: {} as any,
  38. detailVisiable: false,
  39. activeRow: null as any,
  40. index: 0
  41. });
  42. const TrainingDetailsRef = ref();
  43. const routerList = ref([
  44. { name: '作业', path: '/homework-record' },
  45. { name: route.query.name, path: '/homework-record-detail' }
  46. ] as any);
  47. const search = () => {
  48. state.pagination.page = 1;
  49. getList();
  50. };
  51. const onReset = () => {
  52. state.searchForm = { keyword: '', trainingStatus: '' as any };
  53. search();
  54. };
  55. const getList = async () => {
  56. state.loading = true;
  57. try {
  58. const res = await api_trainingStudentList({
  59. trainingId: route.query.id,
  60. ...state.searchForm,
  61. ...state.pagination
  62. });
  63. state.tableList = res.data.rows;
  64. state.pagination.pageTotal = res.data.total;
  65. state.loading = false;
  66. } catch (e) {
  67. state.loading = false;
  68. console.log(e);
  69. }
  70. };
  71. const getWorkInfo = async () => {
  72. try {
  73. const res = await api_trainingDetail({ id: route.query.id });
  74. const result = res.data || {};
  75. // state.workInfo
  76. let pTitle = '';
  77. let eTitle = '';
  78. if (
  79. result.studentLessonTrainingDetails &&
  80. result.studentLessonTrainingDetails.length > 0
  81. ) {
  82. result.studentLessonTrainingDetails.forEach((child: any) => {
  83. // if (child.trainingType === 'PRACTICE' && child.musicName) {
  84. // pTitle += pTitle ? '、' + child.musicName : child.musicName;
  85. // }
  86. // if (child.trainingType === 'EVALUATION' && child.musicName) {
  87. // eTitle += eTitle ? '、' + child.musicName : child.musicName;
  88. // }
  89. if (child.trainingType === 'PRACTICE' && child.musicName) {
  90. pTitle += pTitle
  91. ? '、《' + child.musicName + '》'
  92. : '练习曲目《' + child.musicName + '》';
  93. }
  94. if (child.trainingType === 'EVALUATION' && child.musicName) {
  95. eTitle += eTitle
  96. ? '、《' + child.musicName + '》'
  97. : '评测曲目《' + child.musicName + '》';
  98. }
  99. });
  100. }
  101. result.pTitle = pTitle;
  102. result.eTitle = eTitle;
  103. state.workInfo = result;
  104. } catch (e) {
  105. console.log(e);
  106. }
  107. };
  108. const lookDetail = (row: any, index: number) => {
  109. console.log(index, 'index');
  110. state.index = index + 1;
  111. state.activeRow = row;
  112. state.detailVisiable = true;
  113. };
  114. onMounted(() => {
  115. getWorkInfo();
  116. getList();
  117. });
  118. const columns = () => {
  119. return [
  120. {
  121. title: '学生姓名',
  122. key: 'studentName'
  123. },
  124. {
  125. title: '最后提交时间',
  126. key: 'submitTime',
  127. render(row: any) {
  128. return row.submitTime
  129. ? dayjs(row.submitTime).format('YYYY-MM-DD')
  130. : '--';
  131. }
  132. },
  133. {
  134. title: '作业状态',
  135. key: 'sex',
  136. render(row: any) {
  137. return (
  138. <div>
  139. {row.trainingStatus == 'UNSUBMITTED' ? (
  140. <p class={styles.nosub}>未提交</p>
  141. ) : null}
  142. {row.trainingStatus == 'SUBMITTED' ? (
  143. <p class={styles.ison}>不合格</p>
  144. ) : null}
  145. {row.trainingStatus == 'TARGET' ? (
  146. <p class={styles.isok}>合格</p>
  147. ) : null}
  148. </div>
  149. );
  150. }
  151. },
  152. {
  153. title: '操作',
  154. key: 'id',
  155. render(row: any, index: number) {
  156. return (
  157. <NButton
  158. text
  159. type="primary"
  160. onClick={() => {
  161. lookDetail(row, index);
  162. }}>
  163. 详情
  164. </NButton>
  165. );
  166. }
  167. }
  168. ];
  169. };
  170. const goToNext = () => {
  171. ++state.index;
  172. state.activeRow = state.tableList[state.index - 1];
  173. TrainingDetailsRef.value.getTrainingDetail(
  174. state.activeRow.studentLessonTrainingId
  175. );
  176. };
  177. const gotoPre = () => {
  178. --state.index;
  179. state.activeRow = state.tableList[state.index - 1];
  180. TrainingDetailsRef.value.getTrainingDetail(
  181. state.activeRow.studentLessonTrainingId
  182. );
  183. };
  184. return () => (
  185. <div>
  186. <CBreadcrumb list={routerList.value}></CBreadcrumb>
  187. <div class={styles.listWrap}>
  188. <div class={styles.teacherSection}>
  189. <div class={styles.teacherList}>
  190. <div class={styles.tTemp}>
  191. <div class={styles.teacherHeader}>
  192. <div class={styles.teacherHeaderBorder}>
  193. <NImage
  194. class={styles.teacherHeaderImg}
  195. src={state.workInfo.teacherAvatar || defultHeade}
  196. previewDisabled></NImage>
  197. </div>
  198. </div>
  199. <div class={styles.workafterInfo}>
  200. <h4>{state.workInfo.teacherName}</h4>
  201. {state.workInfo.createTime && (
  202. <p>
  203. 布置时间:
  204. {state.workInfo.createTime &&
  205. dayjs(state.workInfo.createTime).format(
  206. 'YYYY-MM-DD HH:mm'
  207. )}{' '}
  208. |{' '}
  209. <span>
  210. 截止时间:
  211. {state.workInfo.expireDate &&
  212. dayjs(state.workInfo.expireDate).format(
  213. 'YYYY-MM-DD HH:mm'
  214. )}
  215. </span>
  216. </p>
  217. )}
  218. </div>
  219. </div>
  220. <div class={styles.infos}>
  221. <div class={styles.homeTitle}>{state.workInfo.name}</div>
  222. <div class={[styles.homeContent, styles.homeworkText]}>
  223. <div class={styles.pSection}>
  224. {state.workInfo.pTitle && (
  225. <p class={[styles.text, styles.p1]}>
  226. {state.workInfo.pTitle}
  227. </p>
  228. )}
  229. {state.workInfo.eTitle && (
  230. <p class={[styles.text, styles.p2]}>
  231. {state.workInfo.eTitle}
  232. </p>
  233. )}
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <div>
  239. <div class={styles.stitcTitle}>作业完成情况</div>
  240. <div class={styles.stitcConent}>
  241. <NSpace size={[38, 0]}>
  242. <NProgress
  243. percentage={state.workInfo.trainingRate || 0}
  244. // percentage={20}
  245. offset-degree={180}
  246. type="circle"
  247. strokeWidth={6}
  248. rail-color={'EDEFFA'}
  249. color={'#64A5FF'}>
  250. <div class={styles.contentRect}>
  251. <div class={styles.nums}>
  252. {state.workInfo.trainingNum || 0}
  253. <i>/</i>
  254. {state.workInfo.expectNum || 0}
  255. <span>人</span>
  256. </div>
  257. <div class={styles.text}>已提交</div>
  258. </div>
  259. </NProgress>
  260. <NProgress
  261. percentage={state.workInfo.trainingRate || 0}
  262. offset-degree={180}
  263. strokeWidth={6}
  264. type="circle"
  265. rail-color={'EDEFFA'}
  266. color={'#64A5FF'}>
  267. <div class={styles.contentRect}>
  268. <div class={styles.nums}>
  269. {state.workInfo.trainingRate || 0}%
  270. </div>
  271. <div class={styles.text}>提交率</div>
  272. </div>
  273. </NProgress>
  274. <NProgress
  275. percentage={state.workInfo.standardNum || 0}
  276. offset-degree={180}
  277. strokeWidth={6}
  278. type="circle"
  279. rail-color={'EDEFFA'}
  280. color={'#40CEAE'}>
  281. <div class={styles.contentRect}>
  282. <div class={styles.nums}>
  283. {state.workInfo.standardNum || 0}
  284. <span>人</span>
  285. </div>
  286. <div class={styles.text}>合格人数</div>
  287. </div>
  288. </NProgress>
  289. <NProgress
  290. percentage={state.workInfo.qualifiedRate || 0}
  291. offset-degree={180}
  292. strokeWidth={6}
  293. type="circle"
  294. rail-color={'EDEFFA'}
  295. color={'#40CEAE'}>
  296. <div class={styles.contentRect}>
  297. <div class={styles.nums}>
  298. {state.workInfo.qualifiedRate || 0}%
  299. </div>
  300. <div class={styles.text}>合格率</div>
  301. </div>
  302. </NProgress>
  303. </NSpace>
  304. </div>
  305. </div>
  306. </div>
  307. <div class={styles.searchList}>
  308. <NForm label-placement="left" inline>
  309. <NFormItem>
  310. <SearchInput
  311. {...{ placeholder: '请输入学生姓名' }}
  312. class={styles.searchInput}
  313. searchWord={state.searchForm.keyword}
  314. onChangeValue={(val: string) =>
  315. (state.searchForm.keyword = val)
  316. }></SearchInput>
  317. </NFormItem>
  318. <NFormItem>
  319. <CSelect
  320. {...({
  321. options: [
  322. {
  323. label: '全部状态',
  324. value: ''
  325. },
  326. ...trainingStatusArray
  327. ],
  328. placeholder: '作业状态',
  329. clearable: true,
  330. inline: true
  331. } as any)}
  332. v-model:value={state.searchForm.trainingStatus}></CSelect>
  333. </NFormItem>
  334. <NFormItem>
  335. <NSpace justify="end">
  336. <NButton type="primary" class="searchBtn" onClick={search}>
  337. 搜索
  338. </NButton>
  339. <NButton
  340. type="primary"
  341. ghost
  342. class="resetBtn"
  343. onClick={onReset}>
  344. 重置
  345. </NButton>
  346. </NSpace>
  347. </NFormItem>
  348. </NForm>
  349. </div>
  350. <div class={styles.tableWrap}>
  351. <NDataTable
  352. v-slots={{
  353. empty: () => <TheEmpty></TheEmpty>
  354. }}
  355. class={styles.classTable}
  356. loading={state.loading}
  357. columns={columns()}
  358. data={state.tableList}></NDataTable>
  359. <Pagination
  360. v-model:page={state.pagination.page}
  361. v-model:pageSize={state.pagination.rows}
  362. v-model:pageTotal={state.pagination.pageTotal}
  363. onList={getList}
  364. // sync
  365. />
  366. </div>
  367. </div>
  368. <NModal
  369. v-model:show={state.detailVisiable}
  370. preset="card"
  371. class={['modalTitle background', styles.wordDetailModel]}
  372. title={'作业详情'}>
  373. <TrainingDetails
  374. onNext={() => goToNext()}
  375. onPre={() => gotoPre()}
  376. ref={TrainingDetailsRef}
  377. onClose={() => (state.detailVisiable = false)}
  378. total={state.tableList.length}
  379. current={state.index}
  380. activeRow={state.activeRow}></TrainingDetails>
  381. </NModal>
  382. </div>
  383. );
  384. }
  385. });