完善了router表,前端缺席表格单页化

This commit is contained in:
GitHub 2024-12-27 00:03:41 +08:00
parent ba3d2ae9c9
commit 19cb07d9dd
4 changed files with 87 additions and 100 deletions

1
package-lock.json generated
View File

@ -423,6 +423,7 @@
"version": "2.9.1",
"resolved": "https://registry.npmmirror.com/element-plus/-/element-plus-2.9.1.tgz",
"integrity": "sha512-9Agqf/jt4Ugk7EZ6C5LME71sgkvauPCsnvJN12Xid2XVobjufxMGpRE4L7pS4luJMOmFAH3J0NgYEGZT5r+NDg==",
"license": "MIT",
"dependencies": {
"@ctrl/tinycolor": "^3.4.1",
"@element-plus/icons-vue": "^2.3.1",

17
public/index.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -64,6 +64,11 @@ const routes = [
path: '/studentUpdate',
name: '修改学生',
component: StudentUpdate
},
{
path: '/absentRecord',
name: '缺寝记录',
component: AbsentRecord
}/* ,
{
path: '/buildingAdd',

View File

@ -1,16 +1,16 @@
<template>
<div style="margin-top: 60px;margin-left:80px;border: 0px solid red;" >
<div style="margin-top: 60px; margin-left: 80px; border: 0px solid red;">
<el-form style="margin-left: -40px" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="字段:" prop="key">
<el-select v-model="ruleForm.key" style="width: 160px;float: left" placeholder="请选择字段">
<el-select v-model="ruleForm.key" style="width: 160px; float: left" placeholder="请选择字段">
<el-option label="楼宇" value="buildingName"></el-option>
<el-option label="宿舍" value="dormitoryName"></el-option>
</el-select>
</el-form-item>
<div style="border: 0px solid red;width: 400px;height: 60px;position: relative;top: -64px;left: 270px">
<div style="border: 0px solid red; width: 400px; height: 60px; position: relative; top: -64px; left: 270px">
<el-form-item label="值:">
<el-input v-model="ruleForm.value" placeholder="请输入关键字" style="width: 160px;"></el-input>
<el-button type="primary" icon="el-icon-search" style="position: relative;left: 10px;" @click="submitForm('ruleForm')">搜索</el-button>
<el-button type="primary" icon="el-icon-search" style="position: relative; left: 10px;" @click="submitForm('ruleForm')">搜索</el-button>
</el-form-item>
</div>
</el-form>
@ -19,7 +19,7 @@
:data="tableData"
border
stripe
style="width: 1210px;position: relative;top:-30px">
style="width: 1210px; position: relative; top: -30px">
<el-table-column
fixed
prop="id"
@ -27,17 +27,17 @@
width="130">
</el-table-column>
<el-table-column
prop="buildingName"
prop="buildingId"
label="楼宇"
width="180">
</el-table-column>
<el-table-column
prop="dormitoryName"
prop="dormitoryId"
label="宿舍"
width="180">
</el-table-column>
<el-table-column
prop="studentName"
prop="studentId"
label="学生"
width="180">
</el-table-column>
@ -47,7 +47,7 @@
width="180">
</el-table-column>
<el-table-column
prop="dormitoryAdminName"
prop="dormitoryAdminId"
label="宿管"
width="180">
</el-table-column>
@ -57,34 +57,21 @@
width="180">
</el-table-column>
</el-table>
<el-pagination style="margin-top: 20px;float: right"
background
layout="prev, pager, next"
:page-size="pageSize"
:total="total"
:current-page.sync="currentPage"
@current-change="page">
</el-pagination>
</div>
</template>
<script>
import axios from 'axios';
export default {
import axios from 'axios';
export default {
data() {
return {
tableData: null,
currentPage: 1,
pageSize: 3,
total: null,
tableData: [],
key: '',
value: '',
ruleForm: {
key: '',
value: '',
page: '',
size: 3
value: ''
},
rules: {
key: [
@ -93,46 +80,23 @@
}
}
},
methods:{
methods: {
submitForm(formName) {
const _this = this
//
_this.currentPage=1
this.$refs[formName].validate((valid) => {
if (valid) {
const _this = this
_this.ruleForm.page = _this.currentPage
axios.get('http://localhost:8080/absent/search',{params:_this.ruleForm}).then(function (resp) {
_this.tableData = resp.data.data.data
_this.total = resp.data.data.total
axios.get('http://localhost:8080/system/absent/search', { params: this.ruleForm })
.then(resp => {
this.tableData = resp.data.data.data;
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
});
},
page(currentPage){
const _this = this
if(_this.ruleForm.value == ''){
axios.get('http://localhost:8080/absent/list/'+currentPage+'/'+_this.pageSize).then(function (resp) {
_this.tableData = resp.data.data.data
_this.total = resp.data.data.total
})
} else {
_this.ruleForm.page = _this.currentPage
axios.get('http://localhost:8080/absent/search',{params:_this.ruleForm}).then(function (resp) {
_this.tableData = resp.data.data.data
_this.total = resp.data.data.total
})
}
}
},
created() {
const _this = this
axios.get('http://localhost:8080/absent/list/1/'+_this.pageSize).then(function (resp) {
_this.tableData = resp.data.data.data
_this.total = resp.data.data.total
})
}
axios.get('http://localhost:8080/system/absent/list')
}
}
</script>