add student
This commit is contained in:
parent
99a4466197
commit
36268af5db
|
|
@ -8,6 +8,14 @@ export function scoreList(params) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function subjectScoreList(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/score/subjects',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function scoreInfo(params) {
|
export function scoreInfo(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/score/info',
|
url: '/api/score/info',
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,28 @@ export const constantRoutes = [
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
path: '/student',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/student/query',
|
||||||
|
name: 'Example',
|
||||||
|
meta: { title: '学生', icon: 'el-icon-s-help' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'score',
|
||||||
|
name: 'Score',
|
||||||
|
component: () => import('@/views/query/index'),
|
||||||
|
meta: { title: '成绩查询', icon: 'table' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'class',
|
||||||
|
name: 'Class',
|
||||||
|
component: () => import('@/views/user/index'),
|
||||||
|
meta: { title: '个人信息', icon: 'table' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/form',
|
path: '/form',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
|
|
||||||
142
src/views/query/index.vue
Normal file
142
src/views/query/index.vue
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form label-width="120px">
|
||||||
|
<el-row class="filter-row" type="flex" justify="start">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="年份">
|
||||||
|
<el-input v-model="filter.year" placeholder="请输入年份" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="学期">
|
||||||
|
<el-input v-model="filter.term" placeholder="请输入学期" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="onFilter">成绩查询</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<el-table
|
||||||
|
v-loading="listLoading"
|
||||||
|
:data="list"
|
||||||
|
element-loading-text="Loading"
|
||||||
|
border
|
||||||
|
fit
|
||||||
|
highlight-current-row
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-table-column align="center" label="学生账户">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.studentId }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="学生姓名">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.studentName }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="班级id" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.classId }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="科目" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.subjectName }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="学年" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.year }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="学期" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.term }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="分数" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.score }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getInfo } from '@/api/user'
|
||||||
|
import { getToken } from '@/utils/auth'
|
||||||
|
import { subjectScoreList } from '@/api/score'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
filters: {
|
||||||
|
statusFilter(status) {
|
||||||
|
const statusMap = {
|
||||||
|
published: 'success',
|
||||||
|
draft: 'gray',
|
||||||
|
deleted: 'danger'
|
||||||
|
}
|
||||||
|
return statusMap[status]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
list: null,
|
||||||
|
listLoading: true,
|
||||||
|
filter: {
|
||||||
|
accountId: '',
|
||||||
|
year: '',
|
||||||
|
term: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.fetchData()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchData() {
|
||||||
|
this.listLoading = true
|
||||||
|
const token = getToken()
|
||||||
|
getInfo(token).then(response => {
|
||||||
|
this.accountId = response.userId
|
||||||
|
this.classId = response.classId
|
||||||
|
this.listLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
this.listLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onFilter() {
|
||||||
|
this.listLoading = true
|
||||||
|
subjectScoreList(this.filter).then(response => {
|
||||||
|
this.list = response.result
|
||||||
|
this.listLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
this.listLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.app-container {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.filter-row {
|
||||||
|
margin-bottom: 20px; /* 增加行间距 */
|
||||||
|
}
|
||||||
|
.el-form-item {
|
||||||
|
margin-bottom: 0; /* 移除表单项的底部间距 */
|
||||||
|
}
|
||||||
|
.button-row {
|
||||||
|
margin-top: 10px; /* 增加按钮与筛选区域的间距 */
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.el-button {
|
||||||
|
margin-right: 10px; /* 增加按钮之间的间距 */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
165
src/views/user/index.vue
Normal file
165
src/views/user/index.vue
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-card shadow="hover">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>个人信息</span>
|
||||||
|
<!-- <el-button-->
|
||||||
|
<!-- style="float: right; padding: 3px 0"-->
|
||||||
|
<!-- type="text"-->
|
||||||
|
<!-- @click="handleEdit"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- 编辑-->
|
||||||
|
<!-- </el-button>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-form
|
||||||
|
ref="form"
|
||||||
|
:model="userInfo"
|
||||||
|
label-width="120px"
|
||||||
|
:disabled="!isEditing"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="账号ID">
|
||||||
|
<el-input v-model="userInfo.userId" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户名">
|
||||||
|
<el-input v-model="userInfo.username" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="角色">
|
||||||
|
<el-input v-model="userInfo.role" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="性别">
|
||||||
|
<el-select v-model="userInfo.gender" placeholder="请选择性别">
|
||||||
|
<el-option label="男" value="male" />
|
||||||
|
<el-option label="女" value="female" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="班级ID">
|
||||||
|
<el-input v-model="userInfo.classId" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="手机号">
|
||||||
|
<el-input v-model="userInfo.phone" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="个人简介">
|
||||||
|
<el-input
|
||||||
|
v-model="userInfo.introduction"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row v-if="isEditing">
|
||||||
|
<el-col :span="24" style="text-align: center;">
|
||||||
|
<el-button type="primary" @click="handleSave">保存</el-button>
|
||||||
|
<el-button @click="handleCancel">取消</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getInfo, updateInfo } from '@/api/user'
|
||||||
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
userInfo: {
|
||||||
|
userId: '',
|
||||||
|
username: '',
|
||||||
|
role: '',
|
||||||
|
gender: '',
|
||||||
|
classId: '',
|
||||||
|
className: '',
|
||||||
|
phone: '',
|
||||||
|
email: '',
|
||||||
|
introduction: ''
|
||||||
|
},
|
||||||
|
isEditing: false,
|
||||||
|
originalInfo: {},
|
||||||
|
listLoading: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.fetchData()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchData() {
|
||||||
|
this.listLoading = true
|
||||||
|
const token = getToken()
|
||||||
|
getInfo(token).then(response => {
|
||||||
|
this.userInfo = response.result
|
||||||
|
this.userInfo.role = response.result.roles[0]
|
||||||
|
// 保存原始数据用于取消编辑时恢复
|
||||||
|
this.originalInfo = JSON.parse(JSON.stringify(response))
|
||||||
|
this.listLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
this.listLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleEdit() {
|
||||||
|
this.isEditing = true
|
||||||
|
},
|
||||||
|
handleSave() {
|
||||||
|
this.$refs.form.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.listLoading = true
|
||||||
|
updateInfo(this.userInfo).then(response => {
|
||||||
|
this.$message.success('个人信息更新成功')
|
||||||
|
this.isEditing = false
|
||||||
|
// 更新原始数据
|
||||||
|
this.originalInfo = JSON.parse(JSON.stringify(this.userInfo))
|
||||||
|
this.listLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
this.listLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleCancel() {
|
||||||
|
this.isEditing = false
|
||||||
|
// 恢复原始数据
|
||||||
|
this.userInfo = JSON.parse(JSON.stringify(this.originalInfo))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.app-container {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.el-form-item {
|
||||||
|
margin-bottom: 22px;
|
||||||
|
}
|
||||||
|
.el-card {
|
||||||
|
margin: 20px auto;
|
||||||
|
max-width: 1000px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user