import { defineComponent, onMounted, reactive, ref } from 'vue'; import styles from '../index.module.less'; import { NButton, NDataTable, NForm, NFormItem, NImage, NModal, NSelect, NSpace } from 'naive-ui'; import SearchInput from '@/components/searchInput'; import CSelect from '@/components/CSelect'; import Pagination from '@/components/pagination'; import { getTrainingList } from '../api'; import add from './images/add.png'; import { useRoute, useRouter } from 'vue-router'; import CDatePicker from '/src/components/CDatePicker'; import { getNowDateAndMonday, getNowDateAndSunday, getTimes } from '@/utils/dateFormat'; import dayjs from 'dayjs'; import TrainSettings from '../../attend-class/model/train-settings'; import { use } from 'echarts'; export default defineComponent({ name: 'afterWork', setup(props, { emit }) { const timer = ref<[number, number]>([ getNowDateAndMonday(new Date().getTime()), getNowDateAndSunday(new Date().getTime()) ]); const state = reactive({ searchForm: { status: null as any }, loading: false, pagination: { page: 1, rows: 10, pageTotal: 4 }, tableList: [] as any, addWorkVisible: false }); const router = useRouter(); const route = useRoute(); const search = () => { state.pagination.page = 1; getList(); }; const onReset = () => { timer.value = [ getNowDateAndMonday(new Date().getTime()), getNowDateAndSunday(new Date().getTime()) ]; state.searchForm = { status: null as any }; search(); }; const getList = async () => { state.loading = true; try { const res = await getTrainingList({ classGroupId: route.query.id, ...state.searchForm, ...state.pagination, ...getTimes(timer.value, ['startTime', 'endTime'], 'YYYY-MM-DD') }); state.tableList = res.data.rows; state.pagination.pageTotal = res.data.total; state.loading = false; } catch (e) { state.loading = false; console.log(e); } }; onMounted(() => { getList(); }); const columns = () => { return [ { title: '布置老师', key: 'teacherName' }, { title: '布置时间', key: 'createTime', render(row: any) { return <>{dayjs(row.createTime).format('YYYY-MM-DD')}; } }, { title: '截止时间', key: 'expireDate', render(row: any) { return <>{dayjs(row.expireDate).format('YYYY-MM-DD')}; } }, { title: '训练状态', key: 'status', render(row: any) { return row.status == 0 ? (
{' '} 进行中
) : (
已结束
); } }, { title: '布置人数', key: 'expectNum' }, { title: '提交人数', key: 'trainingNum' }, { title: '合格人数', key: 'standardNum' }, { title: '提交率', key: 'trainingRate', render(row: any) { return <>{row.trainingRate}%; } }, { title: '合格率', key: 'qualifiedRate', render(row: any) { return <>{row.qualifiedRate}%; } }, // { // title: '', // key: 'sex', // render(row: any) { // return <>{row.sex == '0' ? '女' : '男'}; // } // }, { title: '操作', key: 'id', render(row: any) { return ( gotoWorkDetail(row)}> 详情 ); } } ]; }; const gotoWorkDetail = (row: any) => { console.log(row); router.push({ path: '/afterWorkDetail', query: { ...route.query, teacherName: row.teacherName, trainingId: row.id } }); }; return () => (
搜索 重置
(state.addWorkVisible = true)}> 布置训练
{ getList(); state.addWorkVisible = false; }} />
); } });