123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- import { defineComponent, onMounted, reactive, ref } from 'vue';
- import styles from './index.module.less';
- import {
- NButton,
- NDataTable,
- NForm,
- NFormItem,
- NImage,
- NModal,
- NProgress,
- NSpace
- } from 'naive-ui';
- import SearchInput from '@/components/searchInput';
- import CSelect from '@/components/CSelect';
- import Pagination from '@/components/pagination';
- import { api_trainingDetail, api_trainingStudentList } from '../api';
- import { useRoute } from 'vue-router';
- import CBreadcrumb from '/src/components/CBreadcrumb';
- import defultHeade from '@/components/layout/images/teacherIcon.png';
- import { trainingStatusArray } from '@/utils/searchArray';
- import dayjs from 'dayjs';
- import TheEmpty from '/src/components/TheEmpty';
- import TrainingDetails from '../../classList/modals/TrainingDetails';
- export default defineComponent({
- name: 'homewrok-record-detail',
- setup() {
- const route = useRoute();
- const state = reactive({
- searchForm: { keyword: '', trainingStatus: '' as any },
- loading: false,
- pagination: {
- page: 1,
- rows: 10,
- pageTotal: 4
- },
- tableList: [] as any,
- workInfo: {} as any,
- detailVisiable: false,
- activeRow: null as any,
- index: 0
- });
- const TrainingDetailsRef = ref();
- const routerList = ref([
- { name: '作业', path: '/homework-record' },
- { name: route.query.name, path: '/homework-record-detail' }
- ] as any);
- const search = () => {
- state.pagination.page = 1;
- getList();
- };
- const onReset = () => {
- state.searchForm = { keyword: '', trainingStatus: '' as any };
- search();
- };
- const getList = async () => {
- state.loading = true;
- try {
- const res = await api_trainingStudentList({
- trainingId: route.query.id,
- ...state.searchForm,
- ...state.pagination
- });
- state.tableList = res.data.rows;
- state.pagination.pageTotal = res.data.total;
- state.loading = false;
- } catch (e) {
- state.loading = false;
- console.log(e);
- }
- };
- const getWorkInfo = async () => {
- try {
- const res = await api_trainingDetail({ id: route.query.id });
- const result = res.data || {};
- // state.workInfo
- let pTitle = '';
- let eTitle = '';
- if (
- result.studentLessonTrainingDetails &&
- result.studentLessonTrainingDetails.length > 0
- ) {
- result.studentLessonTrainingDetails.forEach((child: any) => {
- // if (child.trainingType === 'PRACTICE' && child.musicName) {
- // pTitle += pTitle ? '、' + child.musicName : child.musicName;
- // }
- // if (child.trainingType === 'EVALUATION' && child.musicName) {
- // eTitle += eTitle ? '、' + child.musicName : child.musicName;
- // }
- if (child.trainingType === 'PRACTICE' && child.musicName) {
- pTitle += pTitle
- ? '、《' + child.musicName + '》'
- : '练习曲目《' + child.musicName + '》';
- }
- if (child.trainingType === 'EVALUATION' && child.musicName) {
- eTitle += eTitle
- ? '、《' + child.musicName + '》'
- : '评测曲目《' + child.musicName + '》';
- }
- });
- }
- result.pTitle = pTitle;
- result.eTitle = eTitle;
- state.workInfo = result;
- } catch (e) {
- console.log(e);
- }
- };
- const lookDetail = (row: any, index: number) => {
- console.log(index, 'index');
- state.index = index + 1;
- state.activeRow = row;
- state.detailVisiable = true;
- };
- onMounted(() => {
- getWorkInfo();
- getList();
- });
- const columns = () => {
- return [
- {
- title: '学生姓名',
- key: 'studentName'
- },
- {
- title: '最后提交时间',
- key: 'submitTime',
- render(row: any) {
- return row.submitTime
- ? dayjs(row.submitTime).format('YYYY-MM-DD')
- : '--';
- }
- },
- {
- title: '作业状态',
- key: 'sex',
- render(row: any) {
- return (
- <div>
- {row.trainingStatus == 'UNSUBMITTED' ? (
- <p class={styles.nosub}>未提交</p>
- ) : null}
- {row.trainingStatus == 'SUBMITTED' ? (
- <p class={styles.ison}>不合格</p>
- ) : null}
- {row.trainingStatus == 'TARGET' ? (
- <p class={styles.isok}>合格</p>
- ) : null}
- </div>
- );
- }
- },
- {
- title: '操作',
- key: 'id',
- render(row: any, index: number) {
- return (
- <NButton
- text
- type="primary"
- onClick={() => {
- lookDetail(row, index);
- }}>
- 详情
- </NButton>
- );
- }
- }
- ];
- };
- const goToNext = () => {
- ++state.index;
- state.activeRow = state.tableList[state.index - 1];
- TrainingDetailsRef.value.getTrainingDetail(
- state.activeRow.studentLessonTrainingId
- );
- };
- const gotoPre = () => {
- --state.index;
- state.activeRow = state.tableList[state.index - 1];
- TrainingDetailsRef.value.getTrainingDetail(
- state.activeRow.studentLessonTrainingId
- );
- };
- return () => (
- <div>
- <CBreadcrumb list={routerList.value}></CBreadcrumb>
- <div class={styles.listWrap}>
- <div class={styles.teacherSection}>
- <div class={styles.teacherList}>
- <div class={styles.tTemp}>
- <div class={styles.teacherHeader}>
- <div class={styles.teacherHeaderBorder}>
- <NImage
- class={styles.teacherHeaderImg}
- src={state.workInfo.teacherAvatar || defultHeade}
- previewDisabled></NImage>
- </div>
- </div>
- <div class={styles.workafterInfo}>
- <h4>{state.workInfo.teacherName}</h4>
- {state.workInfo.createTime && (
- <p>
- 布置时间:
- {state.workInfo.createTime &&
- dayjs(state.workInfo.createTime).format(
- 'YYYY-MM-DD HH:mm'
- )}{' '}
- |{' '}
- <span>
- 截止时间:
- {state.workInfo.expireDate &&
- dayjs(state.workInfo.expireDate).format(
- 'YYYY-MM-DD HH:mm'
- )}
- </span>
- </p>
- )}
- </div>
- </div>
- <div class={styles.infos}>
- <div class={styles.homeTitle}>{state.workInfo.name}</div>
- <div class={[styles.homeContent, styles.homeworkText]}>
- <div class={styles.pSection}>
- {state.workInfo.pTitle && (
- <p class={[styles.text, styles.p1]}>
- {state.workInfo.pTitle}
- </p>
- )}
- {state.workInfo.eTitle && (
- <p class={[styles.text, styles.p2]}>
- {state.workInfo.eTitle}
- </p>
- )}
- </div>
- </div>
- </div>
- </div>
- <div>
- <div class={styles.stitcTitle}>作业完成情况</div>
- <div class={styles.stitcConent}>
- <NSpace size={[38, 0]}>
- <NProgress
- percentage={state.workInfo.trainingRate || 0}
- // percentage={20}
- offset-degree={180}
- type="circle"
- strokeWidth={6}
- rail-color={'EDEFFA'}
- color={'#64A5FF'}>
- <div class={styles.contentRect}>
- <div class={styles.nums}>
- {state.workInfo.trainingNum || 0}
- <i>/</i>
- {state.workInfo.expectNum || 0}
- <span>人</span>
- </div>
- <div class={styles.text}>已提交</div>
- </div>
- </NProgress>
- <NProgress
- percentage={state.workInfo.trainingRate || 0}
- offset-degree={180}
- strokeWidth={6}
- type="circle"
- rail-color={'EDEFFA'}
- color={'#64A5FF'}>
- <div class={styles.contentRect}>
- <div class={styles.nums}>
- {state.workInfo.trainingRate || 0}%
- </div>
- <div class={styles.text}>提交率</div>
- </div>
- </NProgress>
- <NProgress
- percentage={state.workInfo.standardNum || 0}
- offset-degree={180}
- strokeWidth={6}
- type="circle"
- rail-color={'EDEFFA'}
- color={'#40CEAE'}>
- <div class={styles.contentRect}>
- <div class={styles.nums}>
- {state.workInfo.standardNum || 0}
- <span>人</span>
- </div>
- <div class={styles.text}>合格人数</div>
- </div>
- </NProgress>
- <NProgress
- percentage={state.workInfo.qualifiedRate || 0}
- offset-degree={180}
- strokeWidth={6}
- type="circle"
- rail-color={'EDEFFA'}
- color={'#40CEAE'}>
- <div class={styles.contentRect}>
- <div class={styles.nums}>
- {state.workInfo.qualifiedRate || 0}%
- </div>
- <div class={styles.text}>合格率</div>
- </div>
- </NProgress>
- </NSpace>
- </div>
- </div>
- </div>
- <div class={styles.searchList}>
- <NForm label-placement="left" inline>
- <NFormItem>
- <SearchInput
- {...{ placeholder: '请输入学生姓名' }}
- class={styles.searchInput}
- searchWord={state.searchForm.keyword}
- onChangeValue={(val: string) =>
- (state.searchForm.keyword = val)
- }></SearchInput>
- </NFormItem>
- <NFormItem>
- <CSelect
- {...({
- options: [
- {
- label: '全部状态',
- value: ''
- },
- ...trainingStatusArray
- ],
- placeholder: '作业状态',
- clearable: true,
- inline: true
- } as any)}
- v-model:value={state.searchForm.trainingStatus}></CSelect>
- </NFormItem>
- <NFormItem>
- <NSpace justify="end">
- <NButton type="primary" class="searchBtn" onClick={search}>
- 搜索
- </NButton>
- <NButton
- type="primary"
- ghost
- class="resetBtn"
- onClick={onReset}>
- 重置
- </NButton>
- </NSpace>
- </NFormItem>
- </NForm>
- </div>
- <div class={styles.tableWrap}>
- <NDataTable
- v-slots={{
- empty: () => <TheEmpty></TheEmpty>
- }}
- class={styles.classTable}
- loading={state.loading}
- columns={columns()}
- data={state.tableList}></NDataTable>
- <Pagination
- v-model:page={state.pagination.page}
- v-model:pageSize={state.pagination.rows}
- v-model:pageTotal={state.pagination.pageTotal}
- onList={getList}
- // sync
- />
- </div>
- </div>
- <NModal
- v-model:show={state.detailVisiable}
- preset="card"
- class={['modalTitle background', styles.wordDetailModel]}
- title={'作业详情'}>
- <TrainingDetails
- onNext={() => goToNext()}
- onPre={() => gotoPre()}
- ref={TrainingDetailsRef}
- onClose={() => (state.detailVisiable = false)}
- total={state.tableList.length}
- current={state.index}
- activeRow={state.activeRow}></TrainingDetails>
- </NModal>
- </div>
- );
- }
- });
|