import { defineComponent, onMounted, reactive, watch } from 'vue'; import styles from '../index.module.less'; import { NButton, NDataTable, NForm, NFormItem, NImage, NSelect, NSpace, useMessage } from 'naive-ui'; import SearchInput from '@/components/searchInput'; import CSelect from '@/components/CSelect'; import Pagination from '@/components/pagination'; import { classGroupDetail, getStudentList } from '../api'; import add from './images/add.png'; import { useRoute, useRouter } from 'vue-router'; import TheEmpty from '/src/components/TheEmpty'; export default defineComponent({ name: 'student-studentList', props: { upgradeFlag: { type: Number } }, setup(props, { emit }) { const message = useMessage(); const route = useRoute(); const router = useRouter(); const state = reactive({ upgradeFlag: props.upgradeFlag == 0 ? true : false, // 是否为历史班 searchForm: { keyword: '', gender: null as any }, loading: false, pagination: { page: 1, rows: 10, pageTotal: 4 }, tableList: [] as any }); watch( () => props.upgradeFlag, () => { state.upgradeFlag = props.upgradeFlag == 0 ? true : false; } ); const search = () => { state.pagination.page = 1; getList(); console.log('search', state); }; const onReset = () => { state.searchForm = { keyword: '', gender: null as any }; search(); }; const getList = async () => { state.loading = true; try { const res = await getStudentList({ classGroupId: 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); } }; onMounted(() => { getList(); }); const copyTo = (text: string) => { const input = document.createElement('input'); input.value = text; document.body.appendChild(input); input.select(); input.setSelectionRange(0, input.value.length); document.execCommand('Copy'); document.body.removeChild(input); message.success('复制成功'); }; const gotoDetail = (row: any) => { router.push({ path: '/classStudentDetail', query: { ...route.query, studentId: row.id, studentName: row.nickname, upgradeFlag: state.upgradeFlag ? 0 : 1 } }); }; const columns = () => { return [ { title: '学生姓名', key: 'nickname', render: (row: any) => { return (