<p>&quot;<template>\n    &lt;el-pagination\n            @size-change=&quot;handleSizeChange&quot;\n            @current-change=&quot;handleCurrentChange&quot;\n            :current-page=&quot;currentPage&quot;\n            :page-sizes=&quot;[10, 20, 30, 40]&quot;\n            :page-size=&quot;pageSize&quot;\n            layout=&quot;sizes, prev, pager, next, jumper&quot;\n            :total=&quot;total&quot;\n    /&gt;\n    &lt;el-form ref=&quot;formRef&quot; :inline=&quot;true&quot; :model=&quot;formInline&quot; class=&quot;demo-form-inline&quot;&gt;\n        &lt;el-form-item label=&quot;姓名&quot; &gt;\n            &lt;el-input v-model=&quot;formInline.sname&quot;  style=&quot;border: solid black 1px;&quot; clearable /&gt;\n        </el-form-item>\n        &lt;el-form-item label=&quot;院名&quot;&gt;\n            &lt;el-input v-model=&quot;formInline.departmentName&quot; style=&quot;border: solid black 1px;&quot; clearable /&gt;\n        </el-form-item>\n        &lt;el-form-item label=&quot;班级名称&quot; &gt;\n            &lt;el-input v-model=&quot;formInline.className&quot; style=&quot;border: solid black 1px;&quot; clearable /&gt;\n        </el-form-item>\n        <el-form-item>\n            &lt;el-button type=&quot;primary&quot; @click=&quot;handleClick(formRef)&quot;&gt;Query</el-button>\n        </el-form-item>\n    </el-form>\n    &lt;el-table :data=&quot;Date1&quot; style=&quot;width: 400%&quot; height=&quot;600&quot;&gt;\n        &lt;el-table-column fixed prop=&quot;sid&quot; label=&quot;学号&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;sname&quot; label=&quot;学生姓名&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;spassword&quot; label=&quot;学生密码&quot; width=&quot;150&quot; /&gt;\n        &lt;el-table-column prop=&quot;identification&quot; label=&quot;身份证&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;age&quot; label=&quot;年龄&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;sex&quot; label=&quot;性别&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;departmentName&quot; label=&quot;所属院系&quot; width=&quot;90&quot; /&gt;\n        &lt;el-table-column prop=&quot;className&quot; label=&quot;班级名称&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;address&quot; label=&quot;地址&quot; width=&quot;80&quot; /&gt;\n        &lt;el-table-column prop=&quot;phone&quot; label=&quot;电话号码&quot; width=&quot;150&quot; /&gt;\n        &lt;el-table-column label=&quot;操作&quot; width=&quot;80&quot;&gt;\n            &lt;template #default=&quot;scope&quot;&gt;\n                &lt;el-button style=&quot;font-weight: bold;&quot; size=&quot;small&quot; type=&quot;success&quot; :icon=&quot;'Delete'&quot;\n                 @click=&quot;handleDelete(scope.$index, scope.row)&quot;&gt;删除</el-button>\n            </template>\n        </el-table-column>\n    </el-table>\n\n</template>\n\n&lt;script lang=&quot;ts&quot; setup&gt;\n    import {\n        Delete,\n        Search,\n    } from '@element-plus/icons-vue'\n    import axios from 'axios';\n    import {FormInstance, resultProps} from 'element-plus';\n    import { ElMessageBox } from 'element-plus';\n    import {onMounted, ref} from 'vue';\n    import { useRouter } from 'vue-router'\n    const formRef = ref<FormInstance>()\n    const formInline = ref({\n        sname:'',\n        departmentName:'',\n        className:'',\n    });\n    type student = {\n        sid: number;\n        sname: string;\n        spassword: string;\n        identification:string;\n        age: number;\n        sex:string;\n        phone:string;\n        departmentName:string;\n        address:string;\n        className:string;\n    }\n    let Date1 = ref([]);\n    const router = useRouter();\n    let currentPage = ref(1); // 当前页码\n    let pageSize = ref(4); // 每页显示的条数\n    const total = ref(0); // 总条数\n\n    const initialized = ref(false);// 初始化标志位\n\n    // 监听页码改变事件\n    const handleCurrentChange = (val) =&gt; {\n        currentPage.value = val;\n        fetchData();\n    };\n\n    // 监听每页条数改变事件\n    const handleSizeChange = (val) =&gt; {\n        pageSize.value = val;\n        fetchData();\n    };\n\n    // 根据当前页码和每页显示条数获取数据\n    const fetchData = () =&gt; {\n        axios({\n            method: 'POST',\n            url: '/api/teamSelectAll',\n            data: {\n                ...formInline.value,\n                page: currentPage.value,\n                limit: pageSize.value,\n            },\n        }).then((response) =&gt; {\n            if (response.data.flag) {\n                alert(&quot;查询成功&quot;);\n                Date1.value = response.data.data;\n                total.value = response.data.total;\n            } else {\n                alert(response.data.message);\n            }\n        }).catch((error) =&gt; {\n            console.error('发生错误:', error);\n        });\n    };\n    // 初始化页面数据\n    onMounted(() =&gt; {\n        if (!initialized.value) {\n            fetchData();\n            initialized.value = true;\n            currentPage.value = 1;\n            pageSize.value = 4;\n        }\n    });\n    const handleClick = () =&gt; {\n        currentPage.value = 1; // 重置当前页码为第一页\n        fetchData();\n    };\n\n\n\n\n// axios({\n//     method: 'POST',\n//     url: '/api/teamSelectAll',\n//     data: formInline.value\n// }).then(function (result) {\n//     Date1.value = result.data.data;\n// });\n// const search=()=&gt;{\n//     axios({\n//         method: 'POST',\n//         url: '/api/teamSelectAll',\n//         data: formInline.value\n//     }).then(function(response){\n//         if(response.data.flag){\n//             alert(&quot;查询成功&quot;)\n//             Date1.value=response.data.data;\n//         }else{\n//             alert(response.data.message)\n//         }\n//     }).catch(error =&gt; {\n//         console.error('发生错误:', error);\n//     });\n//     return {\n//         formInline,\n//         search\n//     }\n// }\n\n</script>\n\n\n<style scoped>\n.input {\n  width: 300px;\n  height: 40px;\n  font-size: 18px;\n  border: 1px solid #ccc;\n}\n.auto{\n    width: 100px;\n    height: 40px;\n    font-size: 16px;\n    background-color: #FFA500; /* 橙色 <em>/\n    color: white;\n    border-radius: 20px;\n    font-weight: bold;\n    position: absolute;\n    right: 20%;\n\n}\n.add{\n    width: 120px;\n    height: 40px;\n    font-size: 16px;\n    background-color: #FFA500; /</em> 橙色 <em>/\n    color: white;\n    border-radius: 50px;\n    font-weight: bold;\n    position: absolute;\n    right: 28%;\n\n}\n.input{\n    width: 300px;\n  height: 40px;\n  font-size: 18px;\n  border: 1px solid #ccc;\n  left: 300px;\n}\n.blank{\n    width: 20px;\n}\n.keyword{\n    width: 100px;\n    height: 40px;\n    font-size: 16px;\n    background-color: #FFA500; /</em> 橙色 */\n    color: white;\n    position: absolute;\n    left: 530px;\n    font-weight: bold;\n}\n</style>\n</p>
学生信息管理系统 - 分页查询学生列表