1. 机关教学日志2.新增全局表格横向拖拽滚动指令3.学员模块

This commit is contained in:
2026-08-23 15:10:56 +08:00
parent df7800f001
commit d20c490c74
11 changed files with 1922 additions and 52 deletions
+241 -7
View File
@@ -1,15 +1,249 @@
<template>
<div class="app-container">
<placeholder-page title="学员成绩管理" icon="form"
description="用于管理学员各课程的考核成绩,支持录入、查询、统计与导出。" />
<div class="app-container score-page">
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :model="queryForm" label-width="90px" inline class="search-form">
<el-form-item label="学员编号">
<el-input v-model="queryForm.xybh" placeholder="请输入学员编号" clearable style="width: 200px" />
</el-form-item>
<el-form-item label="年度">
<el-input v-model="queryForm.nd" placeholder="如 2026" clearable style="width: 140px" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">查询</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- ==================== 2. 成绩列表区域 ==================== -->
<div class="toolbar">
<el-button type="primary" :loading="exportLoading" @click="handleExportGrades">导出课程成绩</el-button>
<el-button type="primary" :loading="exportLoading" @click="handleExportProcessGrades">导出课程过程成绩</el-button>
</div>
<el-card shadow="never" class="table-card">
<el-tabs v-model="activeTab">
<!-- 课程成绩 -->
<el-tab-pane label="课程成绩" name="grades">
<el-table v-loading="loading" :data="gradesData" stripe border>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="xybh" label="学员编号" width="110" show-overflow-tooltip />
<el-table-column prop="kmbh" label="科目编号" width="110" show-overflow-tooltip />
<el-table-column prop="klx" label="课类型" width="90" align="center" />
<el-table-column prop="kscj" label="考试成绩" width="90" align="center" />
<el-table-column prop="pscj" label="平时成绩" width="90" align="center" />
<el-table-column prop="zzcj" label="最终成绩" width="90" align="center" />
<el-table-column prop="bkcj" label="补考成绩" width="90" align="center" />
<el-table-column prop="bkcs" label="补考次数" width="90" align="center" />
<el-table-column prop="ksqk" label="考试情况" width="90" align="center" />
<el-table-column prop="qwxf" label="期望学分" width="90" align="center" />
<el-table-column prop="ytg" label="已通过" width="80" align="center" />
<el-table-column prop="nd" label="年度" width="80" align="center" />
</el-table>
<el-empty v-if="!loading && gradesData.length === 0" description="暂无课程成绩数据" :image-size="60" />
</el-tab-pane>
<!-- 课程过程成绩 -->
<el-tab-pane label="课程过程成绩" name="process">
<el-table v-loading="loading" :data="processGradesData" stripe border>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="xybh" label="学员编号" width="110" show-overflow-tooltip />
<el-table-column prop="kmbh" label="科目编号" width="110" show-overflow-tooltip />
<el-table-column prop="klx" label="课类型" width="90" align="center" />
<el-table-column prop="yscj" label="原始成绩" width="90" align="center" />
<el-table-column prop="zzcj" label="最终成绩" width="90" align="center" />
<el-table-column prop="bkcj1" label="补考1" width="80" align="center" />
<el-table-column prop="bkcj2" label="补考2" width="80" align="center" />
<el-table-column prop="bkcj3" label="补考3" width="80" align="center" />
<el-table-column prop="ksqk" label="考试情况" width="90" align="center" />
<el-table-column prop="nd" label="年度" width="80" align="center" />
</el-table>
<el-empty v-if="!loading && processGradesData.length === 0" description="暂无课程过程成绩数据" :image-size="60" />
</el-tab-pane>
</el-tabs>
<div class="pagination">
<el-pagination
:current-page="pagination.pageNum"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
background
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</el-card>
</div>
</template>
<script>
import PlaceholderPage from "@/components/PlaceholderPage"
import {
listStudentGrades,
listStudentProcessGrades,
exportStudentGrades,
exportStudentProcessGrades
} from "@/api/studentRecords/studentRecords"
export default {
name: "Score",
components: { PlaceholderPage }
name: 'ScoreIndex',
data() {
return {
// ==================== 查询条件 ====================
queryForm: {
xybh: '',
nd: ''
},
// ==================== 数据表格 ====================
// 数据来源:grades 课程成绩 / process 课程过程成绩
activeTab: 'grades',
loading: false,
gradesData: [],
processGradesData: [],
pagination: { pageNum: 1, pageSize: 20, total: 0 },
// ==================== 导出 ====================
exportLoading: false
}
},
watch: {
activeTab() {
this.handleSearch()
}
},
mounted() {
this.loadData()
},
methods: {
/** 组装查询参数,仅传非空值 */
buildQueryParams(params) {
const xybh = this.queryForm.xybh && this.queryForm.xybh.trim()
const nd = this.queryForm.nd && this.queryForm.nd.trim()
if (xybh) params.xybh = xybh
if (nd) params.nd = nd
},
loadData() {
this.loading = true
const params = {
pageNum: this.pagination.pageNum,
pageSize: this.pagination.pageSize
}
this.buildQueryParams(params)
const request = this.activeTab === 'grades' ? listStudentGrades(params) : listStudentProcessGrades(params)
request.then(res => {
const data = res.data || {}
const records = data.records || []
if (this.activeTab === 'grades') {
this.gradesData = records
} else {
this.processGradesData = records
}
this.pagination.total = data.total || 0
this.loading = false
}).catch(() => {
if (this.activeTab === 'grades') {
this.gradesData = []
} else {
this.processGradesData = []
}
this.pagination.total = 0
this.loading = false
})
},
handleSearch() {
this.pagination.pageNum = 1
this.loadData()
},
handlePageChange(page) {
this.pagination.pageNum = page
this.loadData()
},
handleSizeChange(size) {
this.pagination.pageSize = size
this.pagination.pageNum = 1
this.loadData()
},
/** 通用 blob 下载 */
downloadBlob(blob, filename) {
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = filename
link.click()
URL.revokeObjectURL(link.href)
},
/** 校验导出所需学员编号 */
requireXybh(exportName) {
const xybh = this.queryForm.xybh && this.queryForm.xybh.trim()
if (!xybh) {
this.$message.warning('导出' + exportName + '前请先输入学员编号')
return null
}
return xybh
},
/** 导出课程成绩 Excel */
handleExportGrades() {
const xybh = this.requireXybh('课程成绩')
if (!xybh) return
this.exportLoading = true
exportStudentGrades(xybh).then(res => {
this.downloadBlob(res, `课程成绩_${xybh}.xls`)
this.$message.success('课程成绩导出成功')
}).catch(() => {}).finally(() => {
this.exportLoading = false
})
},
/** 导出课程过程成绩 Excel */
handleExportProcessGrades() {
const xybh = this.requireXybh('课程过程成绩')
if (!xybh) return
this.exportLoading = true
exportStudentProcessGrades(xybh).then(res => {
this.downloadBlob(res, `课程过程成绩_${xybh}.xls`)
this.$message.success('课程过程成绩导出成功')
}).catch(() => {}).finally(() => {
this.exportLoading = false
})
}
}
}
</script>
</script>
<style scoped lang="scss">
.score-page {
padding: 20px;
.search-card {
margin-bottom: 16px;
.search-form {
.el-form-item {
margin-bottom: 0;
}
}
}
.toolbar {
margin-bottom: 16px;
}
.table-card {
.el-table {
width: 100%;
}
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
}
}
</style>
@@ -300,12 +300,13 @@
</template>
<script>
// 模拟列表数据(后端接口未提供,接口就绪后可删除并改为接口加载)
const mockTableData = [
{ id: 1, bh: 'X101', xh: '2025010101', xm: '张三', xb: '男', nj: '2025级', zy: '炮兵装备运用', db: '54队', bc: '5区队', pxlx: '军官基础教育', pxcc: '本科', zzmm: '党员', mz: '汉族', jg: '江苏', xw: '学士', zczt: '已注册', xjyd: '无异动', ksqk: '正常', bjgm: '0', gljg: '教务处' },
{ id: 2, bh: 'X102', xh: '2025010102', xm: '李四', xb: '男', nj: '2025级', zy: '通信工程', db: '32队', bc: '1区队', pxlx: '军官基础教育', pxcc: '本科', zzmm: '团员', mz: '汉族', jg: '山东', xw: '学士', zczt: '已注册', xjyd: '无异动', ksqk: '正常', bjgm: '1', gljg: '教务处' },
{ id: 3, bh: 'X103', xh: '2024010101', xm: '王五', xb: '男', nj: '2024级', zy: '军事指挥', db: '51队', bc: '2区队', pxlx: '军官基础教育', pxcc: '本科', zzmm: '党员', mz: '汉族', jg: '河南', xw: '学士', zczt: '已注册', xjyd: '异动', ksqk: '正常', bjgm: '2', gljg: '教务处' }
]
import {
listStudentRecord,
getStudentRecord,
addStudentRecord,
updateStudentRecord,
delStudentRecord
} from "@/api/studentRecords/studentRecords"
export default {
name: 'StudentInfoIndex',
@@ -386,21 +387,58 @@ export default {
},
// ==================== 列表加载 ====================
// TODO: 后端接口未提供,暂用模拟数据;接口就绪后替换为 getStudentRecordsList
loadData() {
this.loading = true
setTimeout(() => {
this.tableData = mockTableData.slice()
this.pagination.total = mockTableData.length
const params = {
pageNum: this.pagination.pageNum,
pageSize: this.pagination.pageSize
}
this.buildQueryParams(params)
listStudentRecord(params).then(res => {
const data = res.data || {}
this.tableData = data.records || []
this.pagination.total = data.total || 0
this.loading = false
}, 200)
}).catch(() => {
this.tableData = []
this.pagination.total = 0
this.loading = false
})
},
/** 组装查询参数:文本非空才传,勾选启用的字段才传,门数范围二者其一非空才传 */
buildQueryParams(params) {
const textFields = ['xh', 'xm', 'sfzh', 'zjhm', 'zzmm', 'mz', 'jg', 'xw', 'ybzb', 'bq', 'whcd', 'bkbyyx', 'xylb', 'zdyfl', 'nj', 'zy', 'db', 'bc', 'sszq', 'jcqk']
textFields.forEach(key => {
const v = this.searchForm[key]
if (v !== '' && v !== null && v !== undefined) params[key] = v.trim()
})
if (this.searchForm.pxlxChecked) params.pxlx = this.searchForm.pxlx
if (this.searchForm.pxccChecked) params.pxcc = this.searchForm.pxcc
if (this.searchForm.pxlx2Checked) params.pxlx2 = this.searchForm.pxlx2
if (this.searchForm.xjydEnabled) params.xjyd = this.searchForm.xjyd
if (this.searchForm.ksqkEnabled) params.ksqk = this.searchForm.ksqk
if (this.searchForm.xbEnabled) params.xb = this.searchForm.xb
if (this.searchForm.zcztEnabled) params.zczt = this.searchForm.zczt
if (this.searchForm.txEnabled) params.txzt = this.searchForm.tx
if (this.searchForm.gljgChecked) params.gljg = this.searchForm.gljg
const ranges = [
['bjgmMin', 'bjgmMax'],
['lbjgmMin', 'lbjgmMax'],
['bkcljgmMin', 'bkcljgmMax']
]
ranges.forEach(([minKey, maxKey]) => {
if (this.searchForm[minKey] !== '' || this.searchForm[maxKey] !== '') {
params[minKey] = this.searchForm[minKey]
params[maxKey] = this.searchForm[maxKey]
}
})
},
// ==================== 查询/分页 ====================
handleSearch() {
this.pagination.pageNum = 1
this.loadData()
this.$message.success('查询学员信息(前端模拟)')
},
handlePageChange(page) {
this.pagination.pageNum = page
@@ -428,38 +466,51 @@ export default {
this.dialogVisible = true
},
// TODO: 后端接口未提供,直接使用当前行数据;接口就绪后替换为 getStudentRecordsDetail
handleEdit(row) {
this.dialogTitle = '编辑学员'
this.resetForm()
Object.assign(this.formData, this.createEmptyForm(), row)
this.dialogVisible = true
if (!row.bh) {
Object.assign(this.formData, this.createEmptyForm(), row)
this.dialogVisible = true
return
}
getStudentRecord(row.bh).then(res => {
const data = res.data || {}
Object.assign(this.formData, this.createEmptyForm(), data)
this.dialogVisible = true
}).catch(() => {})
},
// TODO: 后端接口未提供,保存为前端模拟;接口就绪后替换为 addStudentRecords / updateStudentRecords
// ==================== 新增/编辑提交 ====================
handleSubmit() {
this.$refs.formRef.validate((valid) => {
this.$refs.formRef.validate(valid => {
if (!valid) return
this.submitting = true
setTimeout(() => {
this.$message.success(this.dialogTitle === '新增学员' ? '新增成功' : '编辑成功')
const isAdd = this.dialogTitle === '新增学员'
const payload = { ...this.formData }
const request = isAdd ? addStudentRecord(payload) : updateStudentRecord(payload)
request.then(() => {
this.$message.success(isAdd ? '新增成功' : '编辑成功')
this.dialogVisible = false
this.loadData()
}).catch(() => {
}).finally(() => {
this.submitting = false
}, 300)
})
})
},
// TODO: 后端接口未提供,删除为前端模拟;接口就绪后替换为 deleteStudentRecords
// ==================== 删除 ====================
handleDelete(row) {
this.$confirm(`确定要删除"${row.xm}"吗?`, '删除确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.tableData = this.tableData.filter((r) => r.bh !== row.bh)
this.pagination.total = this.tableData.length
return delStudentRecord(row.bh)
}).then(() => {
this.$message.success('删除成功')
this.loadData()
}).catch(() => {})
},
@@ -1,15 +1,544 @@
<template>
<div class="app-container">
<placeholder-page title="学员学籍预警条件管理" icon="tool"
description="用于配置学员学籍预警的触发条件,如成绩、出勤等指标阈值,支持条件的新增与维护。" />
<div class="app-container warning-condition-page">
<!-- ==================== 1. 查询条件 ==================== -->
<el-card shadow="never" class="search-card">
<el-form ref="searchFormRef" :model="searchForm" label-width="90px" class="search-form">
<el-row :gutter="24">
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
<el-form-item label="名称">
<el-input v-model="searchForm.mc" placeholder="请输入名称" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
<el-form-item label="培训类型">
<el-input v-model="searchForm.pxlx" placeholder="请输入培训类型" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
<el-form-item label="培训层次">
<el-input v-model="searchForm.pxcc" placeholder="请输入培训层次" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
<el-form-item label="状态">
<el-select v-model="searchForm.ty" placeholder="请选择状态" clearable style="width: 100%">
<el-option label="启用" :value="0" />
<el-option label="停用" :value="1" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row class="search-actions-row">
<el-col :span="24" class="search-actions">
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- ==================== 2. 列表 ==================== -->
<el-card shadow="never" class="table-card">
<div class="table-header">
<span class="table-title">预警条件列表:</span>
<div class="table-actions">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增预警条件</el-button>
</div>
</div>
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="bh" label="编号" width="100" show-overflow-tooltip />
<el-table-column prop="mc" label="名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="pxlx" label="培训类型" width="120" show-overflow-tooltip />
<el-table-column prop="pxcc" label="培训层次" width="120" show-overflow-tooltip />
<el-table-column prop="bb" label="版本" width="100" show-overflow-tooltip />
<el-table-column prop="xgsj" label="修改时间" width="170" show-overflow-tooltip />
<el-table-column label="停用" width="80" align="center">
<template slot-scope="scope">
<el-tag
:type="scope.row.ty === 1 || scope.row.ty === true ? 'danger' : 'success'"
class="ty-tag"
@click.native="handleToggleDisable(scope.row, scope.row.ty === 1 || scope.row.ty === true ? 0 : 1)"
>
{{ scope.row.ty === 1 || scope.row.ty === true ? '是' : '否' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="150" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="small" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="pageNum"
:page-size="pageSize"
:total="total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
class="pagination-wrapper"
@current-change="handlePageChange"
@size-change="handleSizeChange"
/>
</el-card>
<!-- ==================== 3. 新增/编辑预警条件对话框 ==================== -->
<el-dialog
:title="formTitle"
:visible.sync="formDialogVisible"
width="900px"
:close-on-click-modal="false"
>
<el-form ref="formRef" :model="form" :rules="formRules" label-width="130px" class="form-dialog-form">
<el-divider content-position="left">基本信息</el-divider>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="名称" prop="mc">
<el-input v-model="form.mc" placeholder="请输入名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训类型" prop="pxlx">
<el-input v-model="form.pxlx" placeholder="请输入培训类型" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训层次" prop="pxcc">
<el-input v-model="form.pxcc" placeholder="请输入培训层次" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="版本" prop="bb">
<el-input v-model="form.bb" placeholder="请输入版本" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停用" prop="ty">
<el-switch v-model="form.ty" :active-value="1" :inactive-value="0" active-text="是" inactive-text="否" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="修改时间" prop="xgsj">
<el-date-picker v-model="form.xgsj" type="datetime" placeholder="请选择修改时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">当前学期门数限制</el-divider>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="考试不及格门数下限">
<el-input-number v-model="form.dqxqksbjgmsxx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考试不及格门数下限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试不及格门数上限">
<el-input-number v-model="form.dqxqksbjgmssx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考试不及格门数上限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考查不及格门数下限">
<el-input-number v-model="form.dqxqkcbjgmsxx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考查不及格门数下限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考查不及格门数上限">
<el-input-number v-model="form.dqxqkcbjgmssx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考查不及格门数上限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="不及格门数下限">
<el-input-number v-model="form.dqxqbjgmsxx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入不及格门数下限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="不及格门数上限">
<el-input-number v-model="form.dqxqbjgmssx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入不及格门数上限" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">全部门数限制</el-divider>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="考试不及格门数下限">
<el-input-number v-model="form.qbksbjgmsxx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考试不及格门数下限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试不及格门数上限">
<el-input-number v-model="form.qbksbjgmssx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考试不及格门数上限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考查不及格门数下限">
<el-input-number v-model="form.qbkcbjgmsxx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考查不及格门数下限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考查不及格门数上限">
<el-input-number v-model="form.qbkcbjgmssx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入考查不及格门数上限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="不及格门数下限">
<el-input-number v-model="form.qbbjgmsxx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入不及格门数下限" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="不及格门数上限">
<el-input-number v-model="form.qbbjgmssx" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入不及格门数上限" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="formDialogVisible = false">取 消</el-button>
<el-button type="primary" :loading="formSaving" @click="handleFormSubmit">确 定</el-button>
</div>
</el-dialog>
<!-- ==================== 4. 详情对话框 ==================== -->
<el-dialog title="预警条件详情" :visible.sync="viewDialogVisible" width="800px" :close-on-click-modal="false">
<div v-loading="viewLoading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="编号">{{ viewForm.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="名称">{{ viewForm.mc || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训类型">{{ viewForm.pxlx || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训层次">{{ viewForm.pxcc || '-' }}</el-descriptions-item>
<el-descriptions-item label="版本">{{ viewForm.bb || '-' }}</el-descriptions-item>
<el-descriptions-item label="修改时间">{{ viewForm.xgsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="当前学期考试不及格门数下限">{{ formatValue(viewForm.dqxqksbjgmsxx) }}</el-descriptions-item>
<el-descriptions-item label="当前学期考试不及格门数上限">{{ formatValue(viewForm.dqxqksbjgmssx) }}</el-descriptions-item>
<el-descriptions-item label="当前学期考查不及格门数下限">{{ formatValue(viewForm.dqxqkcbjgmsxx) }}</el-descriptions-item>
<el-descriptions-item label="当前学期考查不及格门数上限">{{ formatValue(viewForm.dqxqkcbjgmssx) }}</el-descriptions-item>
<el-descriptions-item label="当前学期不及格门数下限">{{ formatValue(viewForm.dqxqbjgmsxx) }}</el-descriptions-item>
<el-descriptions-item label="当前学期不及格门数上限">{{ formatValue(viewForm.dqxqbjgmssx) }}</el-descriptions-item>
<el-descriptions-item label="全部考试不及格门数下限">{{ formatValue(viewForm.qbksbjgmsxx) }}</el-descriptions-item>
<el-descriptions-item label="全部考试不及格门数上限">{{ formatValue(viewForm.qbksbjgmssx) }}</el-descriptions-item>
<el-descriptions-item label="全部考查不及格门数下限">{{ formatValue(viewForm.qbkcbjgmsxx) }}</el-descriptions-item>
<el-descriptions-item label="全部考查不及格门数上限">{{ formatValue(viewForm.qbkcbjgmssx) }}</el-descriptions-item>
<el-descriptions-item label="全部不及格门数下限">{{ formatValue(viewForm.qbbjgmsxx) }}</el-descriptions-item>
<el-descriptions-item label="全部不及格门数上限">{{ formatValue(viewForm.qbbjgmssx) }}</el-descriptions-item>
<el-descriptions-item label="停用">
<el-tag :type="viewForm.ty === 1 || viewForm.ty === true ? 'danger' : 'success'" size="mini">
{{ viewForm.ty === 1 || viewForm.ty === true ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="viewDialogVisible = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import PlaceholderPage from "@/components/PlaceholderPage"
import {
listWarningCondition,
getWarningCondition,
addWarningCondition,
updateWarningCondition
} from "@/api/studentRecords/warningCondition"
export default {
name: "WarningCondition",
components: { PlaceholderPage }
data() {
return {
// ==================== 查询条件 ====================
searchForm: {
mc: '',
pxlx: '',
pxcc: '',
ty: ''
},
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// ==================== 新增/编辑 ====================
formDialogVisible: false,
formTitle: '新增预警条件',
isAdd: true,
formSaving: false,
form: this.createEmptyForm(),
formRules: {
mc: [{ required: true, message: "名称不能为空", trigger: "blur" }],
ty: [{ required: true, message: "停用不能为空", trigger: "change" }],
bb: [{ required: true, message: "版本不能为空", trigger: "blur" }],
xgsj: [{ required: true, message: "修改时间不能为空", trigger: "change" }]
},
// ==================== 详情 ====================
viewDialogVisible: false,
viewLoading: false,
viewForm: {}
}
},
created() {
this.fetchList()
},
methods: {
/** 创建空表单 */
createEmptyForm() {
return {
mc: '',
pxlx: '',
pxcc: '',
dqxqksbjgmssx: undefined,
dqxqksbjgmsxx: undefined,
dqxqkcbjgmssx: undefined,
dqxqkcbjgmsxx: undefined,
dqxqbjgmssx: undefined,
dqxqbjgmsxx: undefined,
qbksbjgmssx: undefined,
qbksbjgmsxx: undefined,
qbkcbjgmssx: undefined,
qbkcbjgmsxx: undefined,
qbbjgmssx: undefined,
qbbjgmsxx: undefined,
ty: 0,
bb: '',
xgsj: ''
}
},
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
// 状态:0 启用 / 1 停用(选中时才传)
if (this.searchForm.ty !== '' && this.searchForm.ty !== null && this.searchForm.ty !== undefined) {
params.ty = this.searchForm.ty
}
// 其余文本条件非空时才传
;['mc', 'pxlx', 'pxcc'].forEach(key => {
if (this.searchForm[key] !== '' && this.searchForm[key] !== null && this.searchForm[key] !== undefined) {
params[key] = this.searchForm[key].trim()
}
})
listWarningCondition(params).then(response => {
const data = response.data || {}
this.tableData = data.records || []
this.total = data.total || 0
this.loading = false
}).catch(() => {
this.tableData = []
this.total = 0
this.loading = false
})
},
handleSearch() {
this.pageNum = 1
this.fetchList()
},
handleReset() {
this.searchForm = {
mc: '',
pxlx: '',
pxcc: '',
ty: ''
}
this.pageNum = 1
this.fetchList()
},
handlePageChange(current) {
this.pageNum = current
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
// ==================== 新增/编辑 ====================
handleAdd() {
this.isAdd = true
this.formTitle = '新增预警条件'
this.form = this.createEmptyForm()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleEdit(row) {
this.isAdd = false
this.formTitle = '编辑预警条件'
this.form = this.createEmptyForm()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
getWarningCondition(row.bh).then(response => {
const data = response.data || {}
this.fillFormData(data)
}).catch(() => {})
},
/** 回填表单数据 */
fillFormData(data) {
const fieldKeys = [
'mc', 'pxlx', 'pxcc',
'dqxqksbjgmssx', 'dqxqksbjgmsxx',
'dqxqkcbjgmssx', 'dqxqkcbjgmsxx',
'dqxqbjgmssx', 'dqxqbjgmsxx',
'qbksbjgmssx', 'qbksbjgmsxx',
'qbkcbjgmssx', 'qbkcbjgmsxx',
'qbbjgmssx', 'qbbjgmsxx',
'bb', 'xgsj'
]
const result = this.createEmptyForm()
fieldKeys.forEach(key => {
result[key] = data[key] !== null && data[key] !== undefined ? data[key] : result[key]
})
result.bh = data.bh
result.ty = data.ty === 1 || data.ty === true ? 1 : 0
this.form = result
},
handleFormSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) return
this.formSaving = true
const payload = { ...this.form }
if (!this.isAdd) {
payload.bh = this.form.bh
}
const request = this.isAdd ? addWarningCondition(payload) : updateWarningCondition(payload)
request.then(() => {
this.$message.success(this.isAdd ? '新增成功' : '修改成功')
this.formDialogVisible = false
this.fetchList()
}).catch(() => {
}).finally(() => {
this.formSaving = false
})
})
},
// ==================== 停用/启用切换 ====================
handleToggleDisable(row, val) {
const isDisable = val === 1 || val === true
const prevTy = isDisable ? 0 : 1
const actionName = isDisable ? '停用' : '启用'
this.$confirm(`确定要${actionName}「${row.mc || row.bh || '该预警条件'}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return updateWarningCondition({ ...row, ty: isDisable ? 1 : 0 })
}).then(() => {
this.$message.success(actionName + '成功')
this.fetchList()
}).catch(() => {
// 取消或接口失败时回滚开关状态并刷新
row.ty = prevTy
this.fetchList()
})
},
// ==================== 详情 ====================
handleView(row) {
this.viewDialogVisible = true
this.viewLoading = true
this.viewForm = {}
getWarningCondition(row.bh).then(response => {
this.viewForm = response.data || {}
this.viewLoading = false
}).catch(() => {
this.viewLoading = false
})
},
/** 空值显示占位符 */
formatValue(val) {
return val !== null && val !== undefined ? val : '-'
}
}
}
</script>
</script>
<style scoped lang="scss">
.warning-condition-page {
.search-card {
margin-bottom: 16px;
}
.search-form {
::v-deep .el-form-item {
margin-bottom: 18px;
}
.search-actions-row {
margin-top: 2px;
border-top: 1px dashed #ebeef5;
padding-top: 14px;
}
.search-actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 12px;
}
}
.table-card {
.table-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
.table-title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
.table-actions {
display: flex;
align-items: center;
gap: 10px;
}
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
}
.form-dialog-form {
max-height: 62vh;
overflow-y: auto;
padding-right: 6px;
::v-deep .el-divider--horizontal {
margin: 4px 0 16px;
}
}
.ty-tag {
cursor: pointer;
user-select: none;
}
}
</style>
@@ -12,4 +12,4 @@ export default {
name: "WarningResult",
components: { PlaceholderPage }
}
</script>
</script>