import { defineComponent, reactive, onMounted, ref, nextTick } 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, getSubject,addGroup } from './api';
import CreateClass from './modals/createClass';
import RestStudentBox from './modals/restStudentBox';
import TrainDetail from './modals/Gotoclass';
import { getgradeNumList, classArray } from './contants';
import add from '@/views/studentList/images/add.png';
import ClassGuide from '@/custom-plugins/guide-page/class-guide';
import { useRouter } from 'vue-router';
import { rowDark } from 'naive-ui/es/legacy-grid/styles';
import TheEmpty from '/src/components/TheEmpty';
import TheTooltip from '/src/components/TheTooltip';
import PreviewWindow from '../preview-window';
import { state as globalState } from '/src/state';
import { courseSchedulePage } from '../home/api';
import ResetSubject from './modals/resetSubject';
import { fscreen } from '/src/utils';
import UpdateSubject from './modals/updateSubject';
export default defineComponent({
name: 'class-classList',
setup(props, { emit }) {
const state = reactive({
searchForm: {
keyword: null as any,
currentClass: null,
currentGradeNum: null,
subjectId: 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,
removeVisiable: false,
removeRow: {} as any,
previewModal: false,
previewParams: {} as any,
lastCourse: null as any,
subjectList: [] as any,
showResetClass: false,
showSubjectClass: false,
groupVisiable: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 showGuide = ref(false);
state.gradeNumList = getgradeNumList();
const onReset = () => {
state.searchForm = {
keyword: null as any,
currentClass: null,
currentGradeNum: null,
subjectId: null
};
getList();
};
const removeClass = async () => {
try {
await deleteClass({ ids: state.removeRow.id });
getList();
message.success(`删除成功`);
state.removeVisiable = false;
} 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;
setTimeout(() => {
if (state.tableList.length > 0) {
showGuide.value = true;
}
}, 500);
} catch (e) {
state.loading = false;
console.log(e);
}
console.log('getList');
};
const getSubjectList = async () => {
const res = await getSubject({ page: 1, rows: 9999 });
state.subjectList = res.data.rows.map((item: any) => {
return {
value: item.id,
label: item.name
};
});
state.subjectList.unshift({ value: null, label: '选择声部' });
};
const columns = () => {
return [
{
title: '班级名称',
key: 'name',
},
{
title: '班级声部',
key: 'subjectName',
},
{
title: '学生人数',
key: 'preStudentNum',
},
{
title: '上次学习',
key: 'lastStudy',
width: '20%',
render(row: any) {
return row.lastStudy ? (
{ state.removeVisiable = true; state.removeRow = row; }}> 删除
) : null} {row.imGroupId?null:确定要删除班级么? 删除班级信息将会清空。
是否创建班级群聊