index.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. });
  90. }
  91. result.pTitle = pTitle;
  92. result.eTitle = eTitle;
  93. state.workInfo = result;
  94. } catch (e) {
  95. console.log(e);
  96. }
  97. };
  98. const lookDetail = (row: any, index: number) => {
  99. console.log(index, 'index');
  100. state.index = index + 1;
  101. state.activeRow = row;
  102. state.detailVisiable = true;
  103. };
  104. onMounted(() => {
  105. getWorkInfo();
  106. getList();
  107. });
  108. const columns = () => {
  109. return [
  110. {
  111. title: '学生姓名',
  112. key: 'studentName'
  113. },
  114. {
  115. title: '最后提交时间',
  116. key: 'submitTime',
  117. render(row: any) {
  118. return row.submitTime
  119. ? dayjs(row.submitTime).format('YYYY-MM-DD')
  120. : '--';
  121. }
  122. },
  123. {
  124. title: '作业状态',
  125. key: 'sex',
  126. render(row: any) {
  127. return (
  128. <div>
  129. {row.trainingStatus == 'UNSUBMITTED' ? (
  130. <p class={styles.nosub}>未提交</p>
  131. ) : null}
  132. {row.trainingStatus == 'SUBMITTED' ? (
  133. <p class={styles.ison}>不合格</p>
  134. ) : null}
  135. {row.trainingStatus == 'TARGET' ? (
  136. <p class={styles.isok}>合格</p>
  137. ) : null}
  138. </div>
  139. );
  140. }
  141. },
  142. {
  143. title: '操作',
  144. key: 'id',
  145. render(row: any, index: number) {
  146. return (
  147. <NButton
  148. text
  149. type="primary"
  150. onClick={() => {
  151. lookDetail(row, index);
  152. }}>
  153. 详情
  154. </NButton>
  155. );
  156. }
  157. }
  158. ];
  159. };
  160. const goToNext = () => {
  161. ++state.index;
  162. state.activeRow = state.tableList[state.index - 1];
  163. TrainingDetailsRef.value.getTrainingDetail(
  164. state.activeRow.studentLessonTrainingId
  165. );
  166. };
  167. const gotoPre = () => {
  168. --state.index;
  169. state.activeRow = state.tableList[state.index - 1];
  170. TrainingDetailsRef.value.getTrainingDetail(
  171. state.activeRow.studentLessonTrainingId
  172. );
  173. };
  174. return () => (
  175. <div>
  176. <CBreadcrumb list={routerList.value}></CBreadcrumb>
  177. <div class={styles.listWrap}>
  178. <div class={styles.teacherSection}>
  179. <div class={styles.teacherList}>
  180. <div class={styles.tTemp}>
  181. <div class={styles.teacherHeader}>
  182. <div class={styles.teacherHeaderBorder}>
  183. <NImage
  184. class={styles.teacherHeaderImg}
  185. src={state.workInfo.teacherAvatar || defultHeade}
  186. previewDisabled></NImage>
  187. </div>
  188. </div>
  189. <div class={styles.workafterInfo}>
  190. <h4>{state.workInfo.teacherName}</h4>
  191. {state.workInfo.createTime && (
  192. <p>
  193. 布置时间:
  194. {state.workInfo.createTime &&
  195. dayjs(state.workInfo.createTime).format(
  196. 'YYYY-MM-DD'
  197. )}{' '}
  198. |{' '}
  199. <span>
  200. 截止时间:
  201. {state.workInfo.expireDate &&
  202. dayjs(state.workInfo.expireDate).format('YYYY-MM-DD')}
  203. </span>
  204. </p>
  205. )}
  206. </div>
  207. </div>
  208. <div class={styles.infos}>
  209. <div class={styles.homeTitle}>{state.workInfo.name}</div>
  210. <div class={[styles.homeContent, styles.homeworkText]}>
  211. <div class={styles.pSection}>
  212. {state.workInfo.pTitle && (
  213. <p class={[styles.text, styles.p1]}>
  214. {state.workInfo.pTitle}
  215. </p>
  216. )}
  217. {state.workInfo.eTitle && (
  218. <p class={[styles.text, styles.p2]}>
  219. {state.workInfo.eTitle}
  220. </p>
  221. )}
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. <div>
  227. <div class={styles.stitcTitle}>作业完成情况</div>
  228. <div class={styles.stitcConent}>
  229. <NSpace size={[38, 0]}>
  230. <NProgress
  231. percentage={state.workInfo.trainingRate || 0}
  232. // percentage={20}
  233. offset-degree={180}
  234. type="circle"
  235. rail-color={'EDEFFA'}
  236. color={'#64A5FF'}>
  237. <div class={styles.contentRect}>
  238. <div class={styles.nums}>
  239. {state.workInfo.trainingNum || 0}
  240. <i>/</i>
  241. {state.workInfo.expectNum || 0}
  242. <span>人</span>
  243. </div>
  244. <div class={styles.text}>已提交</div>
  245. </div>
  246. </NProgress>
  247. <NProgress
  248. percentage={state.workInfo.trainingRate || 0}
  249. offset-degree={180}
  250. type="circle"
  251. rail-color={'EDEFFA'}
  252. color={'#64A5FF'}>
  253. <div class={styles.contentRect}>
  254. <div class={styles.nums}>
  255. {state.workInfo.trainingRate || 0}%
  256. </div>
  257. <div class={styles.text}>提交率</div>
  258. </div>
  259. </NProgress>
  260. <NProgress
  261. percentage={state.workInfo.standardNum || 0}
  262. offset-degree={180}
  263. type="circle"
  264. rail-color={'EDEFFA'}
  265. color={'#40CEAE'}>
  266. <div class={styles.contentRect}>
  267. <div class={styles.nums}>
  268. {state.workInfo.standardNum || 0}
  269. <span>人</span>
  270. </div>
  271. <div class={styles.text}>合格人数</div>
  272. </div>
  273. </NProgress>
  274. <NProgress
  275. percentage={state.workInfo.qualifiedRate || 0}
  276. offset-degree={180}
  277. type="circle"
  278. rail-color={'EDEFFA'}
  279. color={'#40CEAE'}>
  280. <div class={styles.contentRect}>
  281. <div class={styles.nums}>
  282. {state.workInfo.qualifiedRate || 0}%
  283. </div>
  284. <div class={styles.text}>合格率</div>
  285. </div>
  286. </NProgress>
  287. </NSpace>
  288. </div>
  289. </div>
  290. </div>
  291. <div class={styles.searchList}>
  292. <NForm label-placement="left" inline>
  293. <NFormItem>
  294. <SearchInput
  295. {...{ placeholder: '请输入学生姓名' }}
  296. class={styles.searchInput}
  297. searchWord={state.searchForm.keyword}
  298. onChangeValue={(val: string) =>
  299. (state.searchForm.keyword = val)
  300. }></SearchInput>
  301. </NFormItem>
  302. <NFormItem>
  303. <CSelect
  304. {...({
  305. options: [
  306. {
  307. label: '全部状态',
  308. value: ''
  309. },
  310. ...trainingStatusArray
  311. ],
  312. placeholder: '作业状态',
  313. clearable: true,
  314. inline: true
  315. } as any)}
  316. v-model:value={state.searchForm.trainingStatus}></CSelect>
  317. </NFormItem>
  318. <NFormItem>
  319. <NSpace justify="end">
  320. <NButton type="primary" class="searchBtn" onClick={search}>
  321. 搜索
  322. </NButton>
  323. <NButton
  324. type="primary"
  325. ghost
  326. class="resetBtn"
  327. onClick={onReset}>
  328. 重置
  329. </NButton>
  330. </NSpace>
  331. </NFormItem>
  332. </NForm>
  333. </div>
  334. <div class={styles.tableWrap}>
  335. <NDataTable
  336. v-slots={{
  337. empty: () => <TheEmpty></TheEmpty>
  338. }}
  339. class={styles.classTable}
  340. loading={state.loading}
  341. columns={columns()}
  342. data={state.tableList}></NDataTable>
  343. <Pagination
  344. v-model:page={state.pagination.page}
  345. v-model:pageSize={state.pagination.rows}
  346. v-model:pageTotal={state.pagination.pageTotal}
  347. onList={getList}
  348. // sync
  349. />
  350. </div>
  351. </div>
  352. <NModal
  353. v-model:show={state.detailVisiable}
  354. preset="card"
  355. class={['modalTitle background', styles.wordDetailModel]}
  356. title={'作业详情'}>
  357. <TrainingDetails
  358. onNext={() => goToNext()}
  359. onPre={() => gotoPre()}
  360. ref={TrainingDetailsRef}
  361. onClose={() => (state.detailVisiable = false)}
  362. total={state.tableList.length}
  363. current={state.index}
  364. activeRow={state.activeRow}></TrainingDetails>
  365. </NModal>
  366. </div>
  367. );
  368. }
  369. });