考生管理
This commit is contained in:
parent
7a82c98d00
commit
96476e6127
@ -1,6 +1,7 @@
|
||||
const { executeWithRetry } = require('./utils.js');
|
||||
// 修复导入方式
|
||||
const { getDbConnection } = require('./index.js');
|
||||
const { getSystemDbPath } = require('./index.js');
|
||||
const { getSystemDbPath } = require('./path.js'); // 从 path.js 导入
|
||||
const { executeWithRetry } = require('./utils.js'); // 从 utils.js 导入
|
||||
|
||||
/**
|
||||
* 查询所有考生列表
|
||||
|
@ -35,6 +35,7 @@ async function createWindow() {
|
||||
width: 800, // 默认宽度(实际会被最大化覆盖)
|
||||
height: 600, // 默认高度(实际会被最大化覆盖)
|
||||
show: false, // 先隐藏窗口,避免闪烁
|
||||
frame: false, // 无边框窗口(可选,根据需求决定是否保留)
|
||||
webPreferences: {
|
||||
// 改为使用绝对路径解析
|
||||
preload: require('path').join(process.cwd(), 'src/preload.js'),
|
||||
@ -43,6 +44,9 @@ async function createWindow() {
|
||||
}
|
||||
})
|
||||
|
||||
// 设置隐藏菜单栏
|
||||
win.setMenu(null);
|
||||
|
||||
// 在窗口显示前设置最大化
|
||||
win.maximize();
|
||||
// 然后显示窗口
|
||||
|
@ -20,26 +20,18 @@
|
||||
<i class="el-icon-menu"></i>
|
||||
<span slot="title">后台首页</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/examinee">
|
||||
<i class="el-icon-user-solid"></i>
|
||||
<span slot="title">考生管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/question">
|
||||
<i class="el-icon-document-checked"></i>
|
||||
<span slot="title">试题管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/examinee">
|
||||
<i class="el-icon-user-solid"></i>
|
||||
<span slot="title">考生管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/exam">
|
||||
<i class="el-icon-date"></i>
|
||||
<span slot="title">考试管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/statistics">
|
||||
<i class="el-icon-data-analysis"></i>
|
||||
<span slot="title">数据统计</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/settings">
|
||||
<i class="el-icon-setting"></i>
|
||||
<span slot="title">系统设置</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="logout">
|
||||
<i class="el-icon-switch-button"></i>
|
||||
<span slot="title">退出登录</span>
|
||||
|
@ -4,6 +4,7 @@ import WelcomeView from '../views/WelcomeView.vue'
|
||||
import AdminLayout from '../components/admin/AdminLayout.vue'
|
||||
import AdminHomeView from '../views/admin/AdminHomeView.vue'
|
||||
import QuestionManagementView from '../views/admin/QuestionManagementView.vue'
|
||||
import ExamineeManagementView from '../views/admin/ExamineeManagementView.vue' // 添加这行
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
@ -30,6 +31,11 @@ const routes = [
|
||||
path: 'question',
|
||||
name: 'QuestionManagement',
|
||||
component: QuestionManagementView
|
||||
},
|
||||
{
|
||||
path: 'examinee', // 添加考生管理路由
|
||||
name: 'ExamineeManagement',
|
||||
component: ExamineeManagementView
|
||||
}
|
||||
// 可以在这里添加更多子路由
|
||||
]
|
||||
@ -37,7 +43,7 @@ const routes = [
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
mode: 'hash', // 将history改为hash
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
})
|
||||
|
234
src/views/admin/ExamineeManagementView.vue
Normal file
234
src/views/admin/ExamineeManagementView.vue
Normal file
@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<div class="examinee-management-container">
|
||||
<div class="examinee-header">
|
||||
<h1>考生管理</h1>
|
||||
<el-button type="primary" @click="handleAddExaminee">+ 添加考生</el-button>
|
||||
</div>
|
||||
<div class="examinee-content">
|
||||
<el-table :data="examineeList" style="width: 100%" v-loading="loading">
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column prop="examinee_name" label="姓名" width="120" />
|
||||
<el-table-column prop="examinee_id_card" label="身份证号" width="180" />
|
||||
<el-table-column prop="examinee_admission_ticket" label="准考证号" width="180" />
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleEditExaminee(scope.row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="handleDeleteExaminee(scope.row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<!-- 添加/编辑考生弹窗 -->
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="dialogVisible"
|
||||
append-to-body
|
||||
show-close
|
||||
width="600px"
|
||||
>
|
||||
<el-form :model="formData" label-width="120px" ref="formRef">
|
||||
<el-form-item label="考生姓名" prop="examinee_name" :rules="[{ required: true, message: '请输入考生姓名', trigger: 'blur' }]">
|
||||
<el-input v-model="formData.examinee_name" placeholder="请输入考生姓名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="性别" prop="examinee_gender">
|
||||
<el-select v-model="formData.examinee_gender" placeholder="请选择性别">
|
||||
<el-option label="男" value="男" />
|
||||
<el-option label="女" value="女" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单位" prop="examinee_unit">
|
||||
<el-input v-model="formData.examinee_unit" placeholder="请输入单位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="笔试考场" prop="written_exam_room">
|
||||
<el-input v-model="formData.written_exam_room" placeholder="请输入笔试考场" />
|
||||
</el-form-item>
|
||||
<el-form-item label="笔试座位号" prop="written_exam_seat">
|
||||
<el-input v-model="formData.written_exam_seat" placeholder="请输入笔试座位号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="机试考场" prop="computer_exam_room">
|
||||
<el-input v-model="formData.computer_exam_room" placeholder="请输入机试考场" />
|
||||
</el-form-item>
|
||||
<el-form-item label="机试座位号" prop="computer_exam_seat">
|
||||
<el-input v-model="formData.computer_exam_seat" placeholder="请输入机试座位号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="身份证号" prop="examinee_id_card" :rules="[{ required: true, message: '请输入身份证号', trigger: 'blur' }]">
|
||||
<el-input v-model="formData.examinee_id_card" placeholder="请输入身份证号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="准考证号" prop="examinee_admission_ticket" :rules="[{ required: true, message: '请输入准考证号', trigger: 'blur' }]">
|
||||
<el-input v-model="formData.examinee_admission_ticket" placeholder="请输入准考证号" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleSaveExaminee">保存</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'ExamineeManagementView',
|
||||
data() {
|
||||
return {
|
||||
examineeList: [],
|
||||
loading: false,
|
||||
dialogVisible: false,
|
||||
dialogTitle: '添加考生',
|
||||
isEdit: false,
|
||||
formData: {
|
||||
id: null,
|
||||
examinee_name: '',
|
||||
examinee_gender: '',
|
||||
examinee_unit: '',
|
||||
written_exam_room: '',
|
||||
written_exam_seat: '',
|
||||
computer_exam_room: '',
|
||||
computer_exam_seat: '',
|
||||
examinee_id_card: '',
|
||||
examinee_admission_ticket: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchExaminees()
|
||||
},
|
||||
methods: {
|
||||
// 获取考生列表
|
||||
async fetchExaminees() {
|
||||
this.loading = true
|
||||
try {
|
||||
const result = await window.electronAPI.examineeFetchAll() // 修改方法名
|
||||
this.examineeList = result
|
||||
} catch (error) {
|
||||
this.$message.error('获取考生列表失败: ' + error.message)
|
||||
console.error('获取考生列表失败', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 简化handleAddExaminee方法
|
||||
// 处理添加考生
|
||||
handleAddExaminee() {
|
||||
console.log('点击了添加考生按钮');
|
||||
this.isEdit = false;
|
||||
this.dialogTitle = '添加考生';
|
||||
this.formData = {
|
||||
id: null,
|
||||
examinee_name: '',
|
||||
examinee_gender: '',
|
||||
examinee_unit: '',
|
||||
written_exam_room: '',
|
||||
written_exam_seat: '',
|
||||
computer_exam_room: '',
|
||||
computer_exam_seat: '',
|
||||
examinee_id_card: '',
|
||||
examinee_admission_ticket: ''
|
||||
};
|
||||
|
||||
// 直接设置对话框状态为显示
|
||||
this.dialogVisible = true;
|
||||
console.log('对话框状态:', this.dialogVisible);
|
||||
},
|
||||
|
||||
// 处理编辑考生
|
||||
handleEditExaminee(row) {
|
||||
this.isEdit = true
|
||||
this.dialogTitle = '编辑考生'
|
||||
this.formData = { ...row }
|
||||
this.dialogVisible = true
|
||||
},
|
||||
|
||||
// 处理保存考生
|
||||
async handleSaveExaminee() {
|
||||
this.$refs.formRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
// 将数据转换为普通对象
|
||||
const examineeData = { ...this.formData }
|
||||
|
||||
if (this.isEdit) {
|
||||
console.log(examineeData)
|
||||
await window.electronAPI.examineeUpdate(examineeData.id, examineeData) // 修改方法名
|
||||
this.$message.success('考生更新成功')
|
||||
} else {
|
||||
await window.electronAPI.examineeCreate(examineeData) // 修改方法名
|
||||
this.$message.success('考生添加成功')
|
||||
}
|
||||
this.dialogVisible = false
|
||||
this.fetchExaminees() // 重新加载列表
|
||||
} catch (error) {
|
||||
this.$message.error('保存考生失败: ' + error.message)
|
||||
console.error('保存考生失败', error)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 处理删除考生
|
||||
handleDeleteExaminee(id) {
|
||||
this.$confirm(
|
||||
'确定要删除该考生吗?',
|
||||
'确认删除',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
.then(async () => {
|
||||
try {
|
||||
await window.electronAPI.examineeDelete(id) // 修改方法名
|
||||
this.$message.success('考生删除成功')
|
||||
this.fetchExaminees() // 重新加载列表
|
||||
} catch (error) {
|
||||
this.$message.error('删除考生失败: ' + error.message)
|
||||
console.error('删除考生失败', error)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// 取消删除
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.examinee-management-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.examinee-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.examinee-content {
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* 确保表格单元格内容不换行 */
|
||||
.el-table__cell {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user