import { defineComponent, reactive, onMounted, ref } from 'vue'; import styles from './index.module.less'; import { NButton, NDataTable, NForm, NFormItem, NImage, NModal, NSelect, NSpace, useDialog, useMessage } from 'naive-ui'; import SearchInput from '@/components/searchInput'; import CSelect from '@/components/CSelect'; import Pagination from '@/components/pagination'; import { classGroupList, deleteClass } from './api'; import { useUserStore } from '/src/store/modules/users'; import CreateClass from './modals/createClass'; import RestStudentBox from './modals/restStudentBox'; import TrainDetail from './modals/Gotoclass'; import { sixYearSystem, fiveYearSystem, threeYearSystem, foreYearSystem, nineYearSystem, classArray } from './contants'; import add from '@/views/studentList/images/add.png'; import { useRouter } from 'vue-router'; import { rowDark } from 'naive-ui/es/legacy-grid/styles'; export default defineComponent({ name: 'class-classList', setup(props, { emit }) { const state = reactive({ searchForm: { keyword: null as any, currentClass: null, currentGradeNum: null }, orchestraType: null, courseTypeCode: null, loading: false, pagination: { page: 1, rows: 10, pageTotal: 6 }, gradeNumList: [] as any, tableList: [] as any, studentVisible: false, activeRow: null as any, showaddClass: false, goCourseVisiable: false }); const formRef = ref(); const dialog = useDialog(); const message = useMessage(); const router = useRouter(); const search = () => { state.pagination.page = 1; getList(); console.log('search', state); }; const userInfo = useUserStore(); if (userInfo.getUserInfo.schoolInfos[0].gradeYear == 'THREE_YEAR_SYSTEM') { state.gradeNumList = threeYearSystem; } else if ( userInfo.getUserInfo.schoolInfos[0].gradeYear == 'FORE_YEAR_SYSTEM' ) { state.gradeNumList = foreYearSystem; } else if ( userInfo.getUserInfo.schoolInfos[0].gradeYear == 'FIVE_YEAR_SYSTEM' ) { state.gradeNumList = fiveYearSystem; } else if ( userInfo.getUserInfo.schoolInfos[0].gradeYear == 'SIX_YEAR_SYSTEM' ) { state.gradeNumList = sixYearSystem; } else { state.gradeNumList = nineYearSystem; } const onReset = () => { state.searchForm = { keyword: null as any, currentClass: null, currentGradeNum: null }; getList(); }; const removeClass = async (row: any) => { dialog.warning({ title: '警告', content: `是否删除班级“${row.name}”?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await deleteClass({ ids: row.id }); getList(); message.success(`删除成功`); } catch (e) { console.log(e); } } }); }; const getList = async () => { // classGroupList state.loading = true; try { const res = await classGroupList({ ...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); } console.log('getList'); }; const columns = () => { return [ { title: '班级名称', key: 'name' }, { title: '学生人数', key: 'preStudentNum' }, { title: '上次学习', key: 'lastStudy', render(row: any) { return

{row.lastStudy ? row.lastStudy : '--'}

; } }, { title: '操作', key: 'id', render(row: any) { return (
{ router.push({ path: '/classDetail', query: { name: row.name, id: row.id } }); }}> 详情 { startResetStudent(row); }}> 学生调整 classesBegin(row)}> 开始上课 {!(row.preStudentNum > 0) ? (

removeClass(row)}> 删除

) : null}
); } } ]; }; const startResetStudent = (row: any) => { state.activeRow = row; state.studentVisible = true; }; const classesBegin = (row: any) => { state.activeRow = row; state.goCourseVisiable = true; console.log('classesBegin'); }; onMounted(() => { getList(); }); return () => (
(state.searchForm.keyword = val) }> 搜索 重置
(state.showaddClass = true)} v-slots={{ icon: () => ( <> ) }}> 创建班级
(state.studentVisible = false)} onGetList={() => getList()}> getList()} onClose={() => (state.showaddClass = false)} /> (state.goCourseVisiable = false)}>
); } });