前端文件

This commit is contained in:
2026-09-10 17:42:46 +08:00
parent 255a0e56a5
commit 345f425a1d
361 changed files with 73359 additions and 0 deletions
@@ -0,0 +1,534 @@
<template>
<div class="app-container joint-training-page">
<div class="list-title">联教联训管理</div>
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="40px" class="search-form">
<el-row :gutter="6">
<el-col :span="4">
<el-form-item label="名称">
<el-input v-model="searchForm.mc" placeholder="请输入名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="2">
<div class="search-actions">
<el-button type="primary" @click="handleQuery">查询</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- ==================== 2. 操作区域 ==================== -->
<el-card shadow="never" class="upload-card">
<div class="upload-row">
<div class="upload-left">
<el-button type="primary" @click="handleAdd">新增联教联训</el-button>
<el-button icon="el-icon-download" @click="handleExport">导出 Excel</el-button>
<el-button icon="el-icon-download" @click="handleDownloadTemplate">【联教联训数据文件模板】下载</el-button>
<el-button icon="el-icon-folder-opened" @click="handleChooseFile">选择文件</el-button>
<span class="file-name" :class="{ 'has-file': selectedFile }">{{ fileName }}</span>
<input ref="fileInputRef" type="file" accept=".xls,.xlsx" style="display: none" @change="handleFileChange" />
<el-button type="primary" icon="el-icon-upload2" :loading="uploading" @click="handleUpload">上传数据</el-button>
</div>
</div>
</el-card>
<!-- ==================== 3. 数据表格 ==================== -->
<el-card shadow="never" class="table-card">
<div class="table-title">联教联训记录列表</div>
<el-table v-loading="tableLoading" :data="tableData" border stripe style="width: 100%">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="bh" label="编号" width="150" align="center" show-overflow-tooltip />
<el-table-column prop="mc" label="名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="xz" label="性质" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="yj" label="依据" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="ksrq" label="开始日期" width="110" align="center" :formatter="fmtDateTime" />
<el-table-column prop="jsrq" label="结束日期" width="110" align="center" :formatter="fmtDateTime" />
<el-table-column prop="ts" label="天数" width="70" align="center" />
<el-table-column prop="jbksl" label="基本课时量" width="90" align="center" />
<el-table-column prop="kslx" label="课时类型" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="xmlx" label="项目类型" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="sm" label="说明" min-width="120" show-overflow-tooltip />
<el-table-column prop="bz" label="备注" min-width="120" show-overflow-tooltip />
<el-table-column label="操作" width="230" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" @click="handleEdit(row)">修改</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(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"
@current-change="handlePageChange"
@size-change="handleSizeChange"
/>
</el-card>
<!-- ==================== 4. 新增/修改对话框 ==================== -->
<el-dialog
:visible="dialogVisible"
:title="dialogTitle"
width="720px"
:close-on-click-modal="false"
@update:visible="val => dialogVisible = val"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px" class="add-form">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="编号">
<el-input v-model="form.bh" placeholder="留空则自动生成" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称" prop="mc">
<el-input v-model="form.mc" placeholder="请输入名称" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="性质">
<el-input v-model="form.xz" placeholder="请输入性质" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="依据">
<el-input v-model="form.yj" placeholder="请输入依据" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="开始日期">
<el-date-picker v-model="form.ksrq" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择开始日期" clearable class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期">
<el-date-picker v-model="form.jsrq" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择结束日期" clearable class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="天数">
<el-input-number v-model="form.ts" :min="0" :precision="1" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="基本课时量">
<el-input-number v-model="form.jbksl" :min="0" :precision="1" :step="0.5" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="课时类型">
<el-input v-model="form.kslx" placeholder="请输入课时类型" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="项目类型">
<el-input v-model="form.xmlx" placeholder="请输入项目类型" clearable />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="说明">
<el-input v-model="form.sm" type="textarea" :rows="2" placeholder="请输入说明" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.bz" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 5. 详情对话框 ==================== -->
<el-dialog :visible="detailVisible" title="联教联训详情" width="640px" @update:visible="val => detailVisible = val">
<el-descriptions :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh }}</el-descriptions-item>
<el-descriptions-item label="名称">{{ detailData.mc }}</el-descriptions-item>
<el-descriptions-item label="性质">{{ fmtEmpty(detailData.xz) }}</el-descriptions-item>
<el-descriptions-item label="依据">{{ fmtEmpty(detailData.yj) }}</el-descriptions-item>
<el-descriptions-item label="开始日期">{{ fmtDateTime(null, null, detailData.ksrq) }}</el-descriptions-item>
<el-descriptions-item label="结束日期">{{ fmtDateTime(null, null, detailData.jsrq) }}</el-descriptions-item>
<el-descriptions-item label="天数">{{ fmtValue(detailData.ts) }}</el-descriptions-item>
<el-descriptions-item label="基本课时量">{{ fmtValue(detailData.jbksl) }}</el-descriptions-item>
<el-descriptions-item label="课时类型">{{ fmtEmpty(detailData.kslx) }}</el-descriptions-item>
<el-descriptions-item label="项目类型">{{ fmtEmpty(detailData.xmlx) }}</el-descriptions-item>
<el-descriptions-item label="说明" :span="2">{{ fmtEmpty(detailData.sm) }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ fmtEmpty(detailData.bz) }}</el-descriptions-item>
</el-descriptions>
<div slot="footer">
<el-button @click="detailVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import {
listJointTraining,
addJointTraining,
updateJointTraining,
deleteJointTraining,
getJointTraining,
importJointTraining,
exportJointTraining,
downloadJointTrainingTemplate
} from '@/api/classHour/jointTraining'
export default {
name: 'JointTrainingIndex',
data() {
return {
// ==================== 1. 查询条件 ====================
searchForm: {
mc: ''
},
// ==================== 2. 文件操作 ====================
selectedFile: null,
uploading: false,
// ==================== 3. 表格数据 ====================
tableLoading: false,
tableData: [],
pageNum: 1,
pageSize: 10,
total: 0,
// ==================== 4. 新增/修改表单 ====================
dialogVisible: false,
dialogTitle: '新增联教联训',
saving: false,
form: this.createEmptyForm(),
rules: {
mc: [{ required: true, message: '请输入名称', trigger: 'blur' }]
},
// ==================== 5. 详情 ====================
detailVisible: false,
detailData: {}
}
},
computed: {
fileName() {
return (this.selectedFile && this.selectedFile.name) || '未选择任何文件'
}
},
mounted() {
this.fetchList()
},
methods: {
createEmptyForm() {
return {
bh: '',
mc: '',
xz: '',
yj: '',
ksrq: '',
jsrq: '',
ts: null,
jbksl: null,
kslx: '',
xmlx: '',
sm: '',
bz: ''
}
},
/** 把后端 LocalDateTime(含 T/毫秒)规范为表单可回显的格式 */
normalizeDateTime(val) {
if (!val) return ''
return String(val).replace('T', ' ').replace(/\.\d+$/, '').slice(0, 19)
},
// ==================== 查询 ====================
fetchList() {
this.tableLoading = true
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (this.searchForm.mc && this.searchForm.mc.trim()) params.mc = this.searchForm.mc.trim()
listJointTraining(params).then(res => {
const data = (res && res.data) || {}
this.tableData = data.records || []
this.total = data.total || 0
this.tableLoading = false
}).catch(() => {
this.tableData = []
this.total = 0
this.tableLoading = false
})
},
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
/** 日期时间显示(去掉 T、截断到分钟) */
fmtDateTime(row, column, cellValue) {
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
return String(cellValue).replace('T', ' ').slice(0, 16)
},
/** 空值显示为 '-' */
fmtEmpty(val) {
return val === null || val === undefined || val === '' ? '-' : val
},
/** 数值空值显示为 '-'(保留 0) */
fmtValue(val) {
return val === null || val === undefined ? '-' : val
},
// ==================== 新增 / 修改 ====================
handleAdd() {
this.form = this.createEmptyForm()
this.dialogTitle = '新增联教联训'
this.dialogVisible = true
},
handleEdit(row) {
getJointTraining(row.bh).then(res => {
const d = (res && res.data) || {}
this.form = {
bh: d.bh || '',
mc: d.mc || '',
xz: d.xz || '',
yj: d.yj || '',
ksrq: this.normalizeDateTime(d.ksrq),
jsrq: this.normalizeDateTime(d.jsrq),
ts: d.ts === null || d.ts === undefined ? null : d.ts,
jbksl: d.jbksl === null || d.jbksl === undefined ? null : d.jbksl,
kslx: d.kslx || '',
xmlx: d.xmlx || '',
sm: d.sm || '',
bz: d.bz || ''
}
this.dialogTitle = '修改联教联训'
this.dialogVisible = true
}).catch(() => {})
},
handleSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) {
this.$message.warning('请完善必填项后再提交')
return
}
const payload = this.buildPayload()
this.saving = true
const req = payload.bh ? updateJointTraining(payload) : addJointTraining(payload)
req.then(() => {
this.$message.success(this.dialogTitle === '修改联教联训' ? '修改成功' : '新增成功')
this.dialogVisible = false
this.fetchList()
}).catch(() => {}).finally(() => {
this.saving = false
})
})
},
/** 构建请求体,仅含实体非空字段(创建/修改时间为后端自动维护,不传) */
buildPayload() {
const f = this.form
const payload = {}
if (f.bh && f.bh.trim()) payload.bh = f.bh.trim()
if (f.mc && f.mc.trim()) payload.mc = f.mc.trim()
if (f.xz && f.xz.trim()) payload.xz = f.xz.trim()
if (f.yj && f.yj.trim()) payload.yj = f.yj.trim()
if (f.ksrq) payload.ksrq = f.ksrq
if (f.jsrq) payload.jsrq = f.jsrq
if (f.ts !== null && f.ts !== undefined) payload.ts = f.ts
if (f.jbksl !== null && f.jbksl !== undefined) payload.jbksl = f.jbksl
if (f.kslx && f.kslx.trim()) payload.kslx = f.kslx.trim()
if (f.xmlx && f.xmlx.trim()) payload.xmlx = f.xmlx.trim()
if (f.sm && f.sm.trim()) payload.sm = f.sm.trim()
if (f.bz && f.bz.trim()) payload.bz = f.bz.trim()
return payload
},
// ==================== 删除 ====================
handleDelete(row) {
this.$confirm(`确定要删除「${row.mc || row.bh || '该记录'}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => deleteJointTraining(row.bh)).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
// ==================== 详情 ====================
handleDetail(row) {
getJointTraining(row.bh).then(res => {
this.detailData = (res && res.data) || {}
this.detailVisible = true
}).catch(() => {})
},
// ==================== 导出 ====================
handleExport() {
exportJointTraining().then(blob => {
saveAs(blob, '联教联训管理.xlsx')
this.$message.success('导出成功')
}).catch(() => {})
},
// ==================== 文件选择与导入 ====================
handleChooseFile() {
this.$refs.fileInputRef && this.$refs.fileInputRef.click()
},
handleFileChange(e) {
const input = e.target
this.selectedFile = (input.files && input.files[0]) || null
},
handleUpload() {
if (!this.selectedFile) {
this.$message.warning('请先选择文件')
return
}
this.uploading = true
importJointTraining(this.selectedFile).then(res => {
const count = res && res.data
if (count !== null && count !== undefined) {
this.$message.success(`导入成功,共 ${count} 条记录`)
} else {
this.$message.success((res && res.msg) || '导入成功')
}
this.selectedFile = null
this.$refs.fileInputRef && (this.$refs.fileInputRef.value = '')
this.pageNum = 1
this.fetchList()
}).catch(() => {}).finally(() => {
this.uploading = false
})
},
handleDownloadTemplate() {
downloadJointTrainingTemplate().then(blob => {
saveAs(blob, '联教连训管理.xls')
this.$message.success('模板下载成功')
}).catch(() => {})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.joint-training-page {
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
}
// ==================== 1. 查询条件区域 ====================
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
.search-actions {
display: flex;
justify-content: flex-end;
align-items: center;
height: 40px;
}
}
}
// ==================== 2. 操作区域 ====================
.upload-card {
margin-bottom: 16px;
.upload-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
.upload-left {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
.file-name {
font-size: 12px;
color: #909399;
&.has-file {
color: #303133;
}
}
}
}
}
// ==================== 3. 数据表格 ====================
.table-card {
margin-bottom: 16px;
.table-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
}
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
.text-danger {
color: #f56c6c;
}
}
// ==================== 4. 新增/修改表单 ====================
.add-form {
max-height: 62vh;
overflow-y: auto;
padding-right: 4px;
}
}
</style>
+706
View File
@@ -0,0 +1,706 @@
<template>
<div class="app-container plan-page">
<!-- ==================== Tab 切换 ==================== -->
<el-tabs v-model="activeTab" @tab-click="handleTabClick">
<el-tab-pane label="课时费方案" name="fee" />
<el-tab-pane label="课时方案" name="coeff" />
</el-tabs>
<!-- ==================== 1. 查询与新增 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :inline="true" class="search-form" @submit.native.prevent>
<el-form-item label="名称">
<el-input v-model="currentForm.mc" placeholder="请输入名称" clearable style="width: 220px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button type="primary" plain @click="handleAdd">新增{{ currentTitle }}</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- ==================== 2. 数据表格 ==================== -->
<el-card shadow="never" class="table-card">
<!-- 课时费方案 -->
<el-table
v-if="activeTab === 'fee'"
v-loading="feeState.loading"
:data="feeState.list"
border
stripe
class="plan-data-table"
style="width: 100%"
>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="bh" label="编号" width="150" align="center" show-overflow-tooltip />
<el-table-column prop="mc" label="名称" min-width="130" show-overflow-tooltip />
<el-table-column prop="mrbzksl" label="默认标准课时量" width="120" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.mrbzksl) }}</template>
</el-table-column>
<el-table-column prop="mrksfbz" label="默认课时费标准" width="120" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.mrksfbz) }}</template>
</el-table-column>
<el-table-column prop="mrclksfbz" label="默认超量课时费标准" width="150" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.mrclksfbz) }}</template>
</el-table-column>
<el-table-column prop="xgjxbzksfbz" label="相关教学补助课时费标准" width="180" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.xgjxbzksfbz) }}</template>
</el-table-column>
<el-table-column prop="jxyxbz" label="绩效优秀补助" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.jxyxbz) }}</template>
</el-table-column>
<el-table-column prop="jxlhbz" label="绩效良好补助" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.jxlhbz) }}</template>
</el-table-column>
<el-table-column prop="jxzdbz" label="绩效中等补助" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.jxzdbz) }}</template>
</el-table-column>
<el-table-column prop="jxjgbz" label="绩效及格补助" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.jxjgbz) }}</template>
</el-table-column>
<el-table-column prop="jxbjgbz" label="绩效不及格补助" width="120" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.jxbjgbz) }}</template>
</el-table-column>
<el-table-column prop="sm" label="说明" min-width="120" show-overflow-tooltip />
<el-table-column label="操作" width="180" align="center" fixed="right">
<template slot-scope="{ row }">
<div class="table-actions">
<el-button type="text" size="small" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" @click="handleEdit(row)">修改</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(row)">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
<!-- 课时方案 -->
<el-table
v-else
v-loading="coeffState.loading"
:data="coeffState.list"
border
stripe
class="plan-data-table"
style="width: 100%"
>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="bh" label="编号" width="150" align="center" show-overflow-tooltip />
<el-table-column prop="mc" label="名称" min-width="130" show-overflow-tooltip />
<el-table-column prop="zjksxs" label="主讲课时系数" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.zjksxs) }}</template>
</el-table-column>
<el-table-column prop="fjksxs" label="辅讲课时系数" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.fjksxs) }}</template>
</el-table-column>
<el-table-column prop="mbxyrs" label="满班学员人数" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.mbxyrs) }}</template>
</el-table-column>
<el-table-column prop="dz10xybjxs" label="递增10学员班级系数" width="150" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.dz10xybjxs) }}</template>
</el-table-column>
<el-table-column prop="bjxssx" label="班级系数上限" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.bjxssx) }}</template>
</el-table-column>
<el-table-column prop="d78jksl" label="第78节课时量" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.d78jksl) }}</template>
</el-table-column>
<el-table-column prop="yjksl" label="夜间课时量" width="100" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.yjksl) }}</template>
</el-table-column>
<el-table-column prop="mrktjxffxs" label="默认课堂教法系数" width="130" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.mrktjxffxs) }}</template>
</el-table-column>
<el-table-column prop="hbxszl" label="合班系数增量" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.hbxszl) }}</template>
</el-table-column>
<el-table-column prop="hbxssx" label="合班系数上限" width="110" align="right">
<template slot-scope="{ row }">{{ fmtValue(row.hbxssx) }}</template>
</el-table-column>
<el-table-column prop="sm" label="说明" min-width="120" show-overflow-tooltip />
<el-table-column label="操作" width="140" align="center" fixed="right">
<template slot-scope="{ row }">
<div class="table-actions">
<el-button type="text" size="small" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" @click="handleEdit(row)">修改</el-button>
</div>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="currentState.pageNum"
:page-size="currentState.pageSize"
:total="currentState.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
class="pagination"
@current-change="handlePageChange"
@size-change="handleSizeChange"
/>
</el-card>
<!-- ==================== 3. 新增/修改对话框 ==================== -->
<el-dialog
:visible="dialogVisible"
:title="dialogTitle"
width="760px"
:close-on-click-modal="false"
@update:visible="val => dialogVisible = val"
>
<!-- 课时费方案表单 -->
<el-form v-if="activeTab === 'fee'" ref="feeFormRef" :model="feeForm" :rules="feeRules" label-width="160px" class="add-form">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="编号">
<el-input v-model="feeForm.bh" placeholder="留空则自动生成" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称" prop="mc">
<el-input v-model="feeForm.mc" placeholder="请输入名称" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="默认标准课时量" prop="mrbzksl">
<el-input-number v-model="feeForm.mrbzksl" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="默认课时费标准" prop="mrksfbz">
<el-input-number v-model="feeForm.mrksfbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="默认超量课时费标准" prop="mrclksfbz">
<el-input-number v-model="feeForm.mrclksfbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="相关教学补助课时费标准" prop="xgjxbzksfbz">
<el-input-number v-model="feeForm.xgjxbzksfbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="绩效优秀补助" prop="jxyxbz">
<el-input-number v-model="feeForm.jxyxbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="绩效良好补助" prop="jxlhbz">
<el-input-number v-model="feeForm.jxlhbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="绩效中等补助" prop="jxzdbz">
<el-input-number v-model="feeForm.jxzdbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="绩效及格补助" prop="jxjgbz">
<el-input-number v-model="feeForm.jxjgbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="绩效不及格补助" prop="jxbjgbz">
<el-input-number v-model="feeForm.jxbjgbz" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="说明">
<el-input v-model="feeForm.sm" type="textarea" :rows="2" placeholder="请输入说明" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="feeForm.bz" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-form>
<!-- 课时方案表单 -->
<el-form v-else ref="coeffFormRef" :model="coeffForm" :rules="coeffRules" label-width="160px" class="add-form">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="编号">
<el-input v-model="coeffForm.bh" placeholder="留空则自动生成" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称" prop="mc">
<el-input v-model="coeffForm.mc" placeholder="请输入名称" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="主讲课时系数">
<el-input-number v-model="coeffForm.zjksxs" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="辅讲课时系数">
<el-input-number v-model="coeffForm.fjksxs" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="满班学员人数">
<el-input-number v-model="coeffForm.mbxyrs" :min="0" :precision="0" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="递增10学员班级系数">
<el-input-number v-model="coeffForm.dz10xybjxs" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="班级系数上限">
<el-input-number v-model="coeffForm.bjxssx" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="第78节课时量">
<el-input-number v-model="coeffForm.d78jksl" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="夜间课时量">
<el-input-number v-model="coeffForm.yjksl" :min="0" :precision="2" :step="1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="默认课堂教学方法系数">
<el-input-number v-model="coeffForm.mrktjxffxs" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="合班系数增量">
<el-input-number v-model="coeffForm.hbxszl" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="合班系数上限">
<el-input-number v-model="coeffForm.hbxssx" :min="0" :precision="2" :step="0.1" class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="说明">
<el-input v-model="coeffForm.sm" type="textarea" :rows="2" placeholder="请输入说明" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="coeffForm.bz" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 4. 详情对话框 ==================== -->
<el-dialog :visible="detailVisible" :title="`${currentTitle}详情`" width="680px" @update:visible="val => detailVisible = val">
<el-descriptions v-if="activeTab === 'fee'" :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh }}</el-descriptions-item>
<el-descriptions-item label="名称">{{ detailData.mc }}</el-descriptions-item>
<el-descriptions-item label="默认标准课时量">{{ fmtValue(detailData.mrbzksl) }}</el-descriptions-item>
<el-descriptions-item label="默认课时费标准">{{ fmtValue(detailData.mrksfbz) }}</el-descriptions-item>
<el-descriptions-item label="默认超量课时费标准">{{ fmtValue(detailData.mrclksfbz) }}</el-descriptions-item>
<el-descriptions-item label="相关教学补助课时费标准">{{ fmtValue(detailData.xgjxbzksfbz) }}</el-descriptions-item>
<el-descriptions-item label="绩效优秀补助">{{ fmtValue(detailData.jxyxbz) }}</el-descriptions-item>
<el-descriptions-item label="绩效良好补助">{{ fmtValue(detailData.jxlhbz) }}</el-descriptions-item>
<el-descriptions-item label="绩效中等补助">{{ fmtValue(detailData.jxzdbz) }}</el-descriptions-item>
<el-descriptions-item label="绩效及格补助">{{ fmtValue(detailData.jxjgbz) }}</el-descriptions-item>
<el-descriptions-item label="绩效不及格补助">{{ fmtValue(detailData.jxbjgbz) }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ fmtEmpty(detailData.cjsj) }}</el-descriptions-item>
<el-descriptions-item label="说明" :span="2">{{ fmtEmpty(detailData.sm) }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ fmtEmpty(detailData.bz) }}</el-descriptions-item>
</el-descriptions>
<el-descriptions v-else :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh }}</el-descriptions-item>
<el-descriptions-item label="名称">{{ detailData.mc }}</el-descriptions-item>
<el-descriptions-item label="主讲课时系数">{{ fmtValue(detailData.zjksxs) }}</el-descriptions-item>
<el-descriptions-item label="辅讲课时系数">{{ fmtValue(detailData.fjksxs) }}</el-descriptions-item>
<el-descriptions-item label="满班学员人数">{{ fmtValue(detailData.mbxyrs) }}</el-descriptions-item>
<el-descriptions-item label="递增10学员班级系数">{{ fmtValue(detailData.dz10xybjxs) }}</el-descriptions-item>
<el-descriptions-item label="班级系数上限">{{ fmtValue(detailData.bjxssx) }}</el-descriptions-item>
<el-descriptions-item label="第78节课时量">{{ fmtValue(detailData.d78jksl) }}</el-descriptions-item>
<el-descriptions-item label="夜间课时量">{{ fmtValue(detailData.yjksl) }}</el-descriptions-item>
<el-descriptions-item label="默认课堂教学方法系数">{{ fmtValue(detailData.mrktjxffxs) }}</el-descriptions-item>
<el-descriptions-item label="合班系数增量">{{ fmtValue(detailData.hbxszl) }}</el-descriptions-item>
<el-descriptions-item label="合班系数上限">{{ fmtValue(detailData.hbxssx) }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ fmtEmpty(detailData.cjsj) }}</el-descriptions-item>
<el-descriptions-item label="说明" :span="2">{{ fmtEmpty(detailData.sm) }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ fmtEmpty(detailData.bz) }}</el-descriptions-item>
</el-descriptions>
<div slot="footer">
<el-button @click="detailVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listFeeStandard,
getFeeStandard,
addFeeStandard,
updateFeeStandard,
deleteFeeStandard,
listCoefficientPlan,
getCoefficientPlan,
addCoefficientPlan,
updateCoefficientPlan
} from '@/api/classHour/plan'
export default {
name: 'ClassHourPlan',
data() {
return {
// ==================== Tab ====================
activeTab: 'fee',
// ==================== 查询条件 ====================
feeSearch: { mc: '' },
coeffSearch: { mc: '' },
// ==================== 列表状态 ====================
feeState: this.createEmptyState(),
coeffState: this.createEmptyState(),
// ==================== 新增/修改 ====================
dialogVisible: false,
dialogTitle: '',
saving: false,
feeForm: this.createEmptyFeeForm(),
coeffForm: this.createEmptyCoeffForm(),
feeRules: {
mc: [{ required: true, message: '请输入名称', trigger: 'blur' }],
mrbzksl: [{ required: true, message: '请输入默认标准课时量', trigger: 'blur' }],
mrksfbz: [{ required: true, message: '请输入默认课时费标准', trigger: 'blur' }],
mrclksfbz: [{ required: true, message: '请输入默认超量课时费标准', trigger: 'blur' }],
xgjxbzksfbz: [{ required: true, message: '请输入相关教学补助课时费标准', trigger: 'blur' }],
jxyxbz: [{ required: true, message: '请输入绩效优秀补助', trigger: 'blur' }],
jxlhbz: [{ required: true, message: '请输入绩效良好补助', trigger: 'blur' }],
jxzdbz: [{ required: true, message: '请输入绩效中等补助', trigger: 'blur' }],
jxjgbz: [{ required: true, message: '请输入绩效及格补助', trigger: 'blur' }],
jxbjgbz: [{ required: true, message: '请输入绩效不及格补助', trigger: 'blur' }]
},
coeffRules: {
mc: [{ required: true, message: '请输入名称', trigger: 'blur' }]
},
// ==================== 详情 ====================
detailVisible: false,
detailData: {}
}
},
computed: {
currentForm() {
return this.activeTab === 'fee' ? this.feeSearch : this.coeffSearch
},
currentState() {
return this.activeTab === 'fee' ? this.feeState : this.coeffState
},
currentTitle() {
return this.activeTab === 'fee' ? '课时费方案' : '课时方案'
}
},
mounted() {
this.fetchList()
},
methods: {
createEmptyState() {
return { list: [], loading: false, pageNum: 1, pageSize: 10, total: 0 }
},
createEmptyFeeForm() {
return {
bh: '',
mc: '',
mrbzksl: null,
mrksfbz: null,
mrclksfbz: null,
xgjxbzksfbz: null,
jxyxbz: null,
jxlhbz: null,
jxzdbz: null,
jxjgbz: null,
jxbjgbz: null,
sm: '',
bz: ''
}
},
createEmptyCoeffForm() {
return {
bh: '',
mc: '',
zjksxs: null,
fjksxs: null,
mbxyrs: null,
dz10xybjxs: null,
bjxssx: null,
d78jksl: null,
yjksl: null,
mrktjxffxs: null,
hbxszl: null,
hbxssx: null,
sm: '',
bz: ''
}
},
// ==================== 查询 ====================
fetchList() {
const state = this.currentState
const params = { pageNum: state.pageNum, pageSize: state.pageSize }
if (this.currentForm.mc && this.currentForm.mc.trim()) params.mc = this.currentForm.mc.trim()
state.loading = true
const req = this.activeTab === 'fee' ? listFeeStandard(params) : listCoefficientPlan(params)
req.then(res => {
const data = (res && res.data) || {}
state.list = data.records || []
state.total = data.total || 0
}).catch(() => {
state.list = []
state.total = 0
}).finally(() => {
state.loading = false
})
},
handleTabClick() {
this.currentState.pageNum = 1
this.fetchList()
},
handleQuery() {
this.currentState.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.currentState.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.currentState.pageSize = size
this.currentState.pageNum = 1
this.fetchList()
},
// ==================== 新增 / 修改 ====================
handleAdd() {
this.feeForm = this.createEmptyFeeForm()
this.coeffForm = this.createEmptyCoeffForm()
this.dialogTitle = `新增${this.currentTitle}`
this.dialogVisible = true
},
handleEdit(row) {
const req = this.activeTab === 'fee' ? getFeeStandard(row.bh) : getCoefficientPlan(row.bh)
req.then(res => {
const d = (res && res.data) || {}
if (this.activeTab === 'fee') {
this.feeForm = {
bh: d.bh || '',
mc: d.mc || '',
mrbzksl: this.toNull(d.mrbzksl),
mrksfbz: this.toNull(d.mrksfbz),
mrclksfbz: this.toNull(d.mrclksfbz),
xgjxbzksfbz: this.toNull(d.xgjxbzksfbz),
jxyxbz: this.toNull(d.jxyxbz),
jxlhbz: this.toNull(d.jxlhbz),
jxzdbz: this.toNull(d.jxzdbz),
jxjgbz: this.toNull(d.jxjgbz),
jxbjgbz: this.toNull(d.jxbjgbz),
sm: d.sm || '',
bz: d.bz || ''
}
} else {
this.coeffForm = {
bh: d.bh || '',
mc: d.mc || '',
zjksxs: this.toNull(d.zjksxs),
fjksxs: this.toNull(d.fjksxs),
mbxyrs: this.toNull(d.mbxyrs),
dz10xybjxs: this.toNull(d.dz10xybjxs),
bjxssx: this.toNull(d.bjxssx),
d78jksl: this.toNull(d.d78jksl),
yjksl: this.toNull(d.yjksl),
mrktjxffxs: this.toNull(d.mrktjxffxs),
hbxszl: this.toNull(d.hbxszl),
hbxssx: this.toNull(d.hbxssx),
sm: d.sm || '',
bz: d.bz || ''
}
}
this.dialogTitle = `修改${this.currentTitle}`
this.dialogVisible = true
}).catch(() => {})
},
handleSubmit() {
const isFee = this.activeTab === 'fee'
const formRef = isFee ? this.$refs.feeFormRef : this.$refs.coeffFormRef
formRef.validate(valid => {
if (!valid) {
this.$message.warning('请完善必填项后再提交')
return
}
const payload = isFee ? this.buildFeePayload() : this.buildCoeffPayload()
this.saving = true
const req = payload.bh
? (isFee ? updateFeeStandard(payload) : updateCoefficientPlan(payload))
: (isFee ? addFeeStandard(payload) : addCoefficientPlan(payload))
req.then(() => {
this.$message.success(this.dialogTitle.indexOf('修改') === 0 ? '修改成功' : '新增成功')
this.dialogVisible = false
this.fetchList()
}).catch(() => {}).finally(() => {
this.saving = false
})
})
},
toNull(val) {
return val === null || val === undefined ? null : val
},
/** 课时费方案请求体:仅含实体非空字段(创建/修改时间后端自动维护) */
buildFeePayload() {
const f = this.feeForm
const p = {}
if (f.bh && f.bh.trim()) p.bh = f.bh.trim()
if (f.mc && f.mc.trim()) p.mc = f.mc.trim()
;['mrbzksl', 'mrksfbz', 'mrclksfbz', 'xgjxbzksfbz', 'jxyxbz', 'jxlhbz', 'jxzdbz', 'jxjgbz', 'jxbjgbz'].forEach(k => {
if (f[k] !== null && f[k] !== undefined) p[k] = f[k]
})
if (f.sm && f.sm.trim()) p.sm = f.sm.trim()
if (f.bz && f.bz.trim()) p.bz = f.bz.trim()
return p
},
/** 课时方案请求体:仅含实体非空字段 */
buildCoeffPayload() {
const f = this.coeffForm
const p = {}
if (f.bh && f.bh.trim()) p.bh = f.bh.trim()
if (f.mc && f.mc.trim()) p.mc = f.mc.trim()
;['zjksxs', 'fjksxs', 'mbxyrs', 'dz10xybjxs', 'bjxssx', 'd78jksl', 'yjksl', 'mrktjxffxs', 'hbxszl', 'hbxssx'].forEach(k => {
if (f[k] !== null && f[k] !== undefined) p[k] = f[k]
})
if (f.sm && f.sm.trim()) p.sm = f.sm.trim()
if (f.bz && f.bz.trim()) p.bz = f.bz.trim()
return p
},
// ==================== 删除(仅课时费方案有删除接口) ====================
handleDelete(row) {
this.$confirm(`确定要删除「${row.mc || row.bh || '该方案'}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => deleteFeeStandard(row.bh)).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
// ==================== 详情 ====================
handleDetail(row) {
const req = this.activeTab === 'fee' ? getFeeStandard(row.bh) : getCoefficientPlan(row.bh)
req.then(res => {
this.detailData = (res && res.data) || {}
this.detailVisible = true
}).catch(() => {})
},
/** 数值空值显示为 '-'(保留 0) */
fmtValue(val) {
return val === null || val === undefined ? '-' : val
},
/** 空值显示为 '-' */
fmtEmpty(val) {
return val === null || val === undefined || val === '' ? '-' : val
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.plan-page {
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
}
// ==================== 1. 查询区域 ====================
.search-card {
margin-bottom: 16px;
.search-form {
.el-form-item {
margin-bottom: 0;
}
}
}
// ==================== 2. 数据表格 ====================
.table-card {
.table-actions {
display: flex;
align-items: center;
justify-content: center;
white-space: nowrap;
}
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
.text-danger {
color: #f56c6c;
}
}
// ==================== 3. 新增/修改表单 ====================
.add-form {
max-height: 62vh;
overflow-y: auto;
padding-right: 4px;
.w-full {
width: 100%;
}
}
}
</style>
@@ -0,0 +1,299 @@
<template>
<div class="app-container subsidy-page">
<div class="list-title">课时补助核算</div>
<!-- ==================== Tab 切换 ==================== -->
<el-tabs v-model="activeTab" @tab-click="handleTabClick">
<el-tab-pane label="课时统计" name="hour" />
<el-tab-pane label="课时费统计" name="fee" />
</el-tabs>
<!-- ==================== 1. 查询条件 ==================== -->
<!-- 课时统计 -->
<el-card v-if="activeTab === 'hour'" shadow="never" class="search-card">
<el-form :model="hourForm" label-width="100px" class="search-form" @submit.native.prevent>
<el-row :gutter="24">
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="学期年度">
<el-input v-model="hourForm.nd" placeholder="如 2026" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="学期序号">
<el-input v-model="hourForm.xq" placeholder="如 1" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="教员姓名">
<el-input v-model="hourForm.jyxm" placeholder="请输入教员姓名" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="6" class="search-actions-col">
<div class="search-actions">
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button type="primary" plain @click="handleExport">导出 Excel</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- 课时费统计 -->
<el-card v-else shadow="never" class="search-card">
<el-form :model="feeForm" label-width="100px" class="search-form" @submit.native.prevent>
<el-row :gutter="24">
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="学期年度">
<el-input v-model="feeForm.nd" placeholder="如 2026" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="学期序号">
<el-input v-model="feeForm.xq" placeholder="如 1" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="教员姓名">
<el-input v-model="feeForm.jyxm" placeholder="请输入教员姓名" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="6">
<el-form-item label="标准编号">
<el-input v-model="feeForm.ksfbzbh" placeholder="课时费标准编号" clearable />
</el-form-item>
</el-col>
<el-col :span="24" class="search-actions-col">
<div class="search-actions">
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button type="primary" plain @click="handleExport">导出 Excel</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- ==================== 2. 数据表格 ==================== -->
<el-card shadow="never" class="table-card">
<div class="table-title">{{ activeTab === 'hour' ? '课时统计列表' : '课时费统计列表' }}</div>
<el-table v-loading="currentState.loading" :data="currentState.list" border stripe style="width: 100%">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="jysdh" label="教研室代号" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="jysmc" label="教研室名称" width="120" show-overflow-tooltip />
<el-table-column prop="jybh" label="教员编号" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="jyxm" label="教员姓名" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="zc" label="职称" width="90" align="center" show-overflow-tooltip />
<el-table-column prop="nf" label="年份" width="70" align="center" />
<el-table-column prop="sbn" label="上半年" width="90" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.sbn) }}</template>
</el-table-column>
<el-table-column prop="xbn" label="下半年" width="90" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.xbn) }}</template>
</el-table-column>
<el-table-column prop="zj" label="总计" width="90" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.zj) }}</template>
</el-table-column>
<el-table-column prop="bzksl" label="标准课时量" width="100" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.bzksl) }}</template>
</el-table-column>
<el-table-column prop="cks" label="超课时" width="90" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.cks) }}</template>
</el-table-column>
<el-table-column prop="jsgs" label="计算过程" min-width="140" show-overflow-tooltip />
<el-table-column prop="jg" label="结果" width="90" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.jg) }}</template>
</el-table-column>
<el-table-column prop="ksfbzmc" label="课时费标准" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="ksfbz" label="课时费单价" width="100" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.ksfbz) }}</template>
</el-table-column>
<el-table-column prop="clksfbz" label="超量课时费单价" width="120" align="right" header-align="center">
<template slot-scope="{ row }">{{ fmtValue(row.clksfbz) }}</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="currentState.pageNum"
:page-size="currentState.pageSize"
:total="currentState.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
class="pagination"
@current-change="handlePageChange"
@size-change="handleSizeChange"
/>
</el-card>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import {
listHourStatistics,
exportHourStatistics,
listFeeStatistics,
exportFeeStatistics
} from '@/api/classHour/hourStat'
export default {
name: 'SubsidyIndex',
data() {
return {
// ==================== Tab ====================
activeTab: 'hour',
// ==================== 课时统计查询条件 ====================
hourForm: {
nd: '',
xq: '',
jyxm: ''
},
// ==================== 课时费统计查询条件 ====================
feeForm: {
nd: '',
xq: '',
jyxm: '',
ksfbzbh: ''
},
// ==================== 各 Tab 列表状态 ====================
hourState: this.createEmptyState(),
feeState: this.createEmptyState()
}
},
computed: {
currentForm() {
return this.activeTab === 'hour' ? this.hourForm : this.feeForm
},
currentState() {
return this.activeTab === 'hour' ? this.hourState : this.feeState
}
},
mounted() {
this.fetchList()
},
methods: {
createEmptyState() {
return { list: [], loading: false, pageNum: 1, pageSize: 20, total: 0 }
},
/** 构建查询参数,仅传非空字段(与后端 Query 字段一致) */
buildParams(form) {
const params = {}
if (form.nd && form.nd.trim()) params.nd = form.nd.trim()
if (form.xq && form.xq.trim()) params.xq = form.xq.trim()
if (form.jyxm && form.jyxm.trim()) params.jyxm = form.jyxm.trim()
if (form.ksfbzbh && form.ksfbzbh.trim()) params.ksfbzbh = form.ksfbzbh.trim()
return params
},
// ==================== 查询 ====================
fetchList() {
const state = this.currentState
const form = this.currentForm
const params = Object.assign(
{ pageNum: state.pageNum, pageSize: state.pageSize },
this.buildParams(form)
)
state.loading = true
const req = this.activeTab === 'hour' ? listHourStatistics(params) : listFeeStatistics(params)
req.then(res => {
const data = (res && res.data) || {}
state.list = data.records || []
state.total = data.total || 0
}).catch(() => {
state.list = []
state.total = 0
}).finally(() => {
state.loading = false
})
},
handleTabClick() {
this.currentState.pageNum = 1
this.fetchList()
},
handleQuery() {
this.currentState.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.currentState.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.currentState.pageSize = size
this.currentState.pageNum = 1
this.fetchList()
},
// ==================== 导出 ====================
handleExport() {
const clean = this.buildParams(this.currentForm)
const isHour = this.activeTab === 'hour'
const req = isHour ? exportHourStatistics(clean) : exportFeeStatistics(clean)
const fileName = isHour ? '课时统计.xlsx' : '课时费统计.xlsx'
req.then(blob => {
saveAs(blob, fileName)
this.$message.success('导出成功')
}).catch(() => {})
},
/** 数值空值显示为 '-'(保留 0) */
fmtValue(val) {
return val === null || val === undefined ? '-' : val
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.subsidy-page {
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
}
// ==================== 1. 查询条件区域 ====================
.search-card {
margin-bottom: 16px;
.search-form {
.search-actions-col {
display: flex;
align-items: center;
}
.search-actions {
display: flex;
gap: 12px;
}
}
}
// ==================== 2. 数据表格 ====================
.table-card {
.table-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
}
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
}
}
</style>
+102
View File
@@ -0,0 +1,102 @@
<template>
<div :class="className" :style="{height:height,width:width}" />
</template>
<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
const animationDuration = 6000
export default {
mixins: [resize],
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '300px'
}
},
data() {
return {
chart: null
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
top: 10,
left: '2%',
right: '2%',
bottom: '3%',
containLabel: true
},
xAxis: [{
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}],
yAxis: [{
type: 'value',
axisTick: {
show: false
}
}],
series: [{
name: 'pageA',
type: 'bar',
stack: 'vistors',
barWidth: '60%',
data: [79, 52, 200, 334, 390, 330, 220],
animationDuration
}, {
name: 'pageB',
type: 'bar',
stack: 'vistors',
barWidth: '60%',
data: [80, 52, 200, 334, 390, 330, 220],
animationDuration
}, {
name: 'pageC',
type: 'bar',
stack: 'vistors',
barWidth: '60%',
data: [30, 52, 200, 334, 390, 330, 220],
animationDuration
}]
})
}
}
}
</script>
+135
View File
@@ -0,0 +1,135 @@
<template>
<div :class="className" :style="{height:height,width:width}" />
</template>
<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
export default {
mixins: [resize],
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '350px'
},
autoResize: {
type: Boolean,
default: true
},
chartData: {
type: Object,
required: true
}
},
data() {
return {
chart: null
}
},
watch: {
chartData: {
deep: true,
handler(val) {
this.setOptions(val)
}
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
this.setOptions(this.chartData)
},
setOptions({ expectedData, actualData } = {}) {
this.chart.setOption({
xAxis: {
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
boundaryGap: false,
axisTick: {
show: false
}
},
grid: {
left: 10,
right: 10,
bottom: 20,
top: 30,
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
padding: [5, 10]
},
yAxis: {
axisTick: {
show: false
}
},
legend: {
data: ['expected', 'actual']
},
series: [{
name: 'expected', itemStyle: {
normal: {
color: '#FF005A',
lineStyle: {
color: '#FF005A',
width: 2
}
}
},
smooth: true,
type: 'line',
data: expectedData,
animationDuration: 2800,
animationEasing: 'cubicInOut'
},
{
name: 'actual',
smooth: true,
type: 'line',
itemStyle: {
normal: {
color: '#3888fa',
lineStyle: {
color: '#3888fa',
width: 2
},
areaStyle: {
color: '#f3f8ff'
}
}
},
data: actualData,
animationDuration: 2800,
animationEasing: 'quadraticOut'
}]
})
}
}
}
</script>
+181
View File
@@ -0,0 +1,181 @@
<template>
<el-row :gutter="40" class="panel-group">
<el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
<div class="card-panel" @click="handleSetLineChartData('newVisitis')">
<div class="card-panel-icon-wrapper icon-people">
<svg-icon icon-class="peoples" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">
访客
</div>
<count-to :start-val="0" :end-val="102400" :duration="2600" class="card-panel-num" />
</div>
</div>
</el-col>
<el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
<div class="card-panel" @click="handleSetLineChartData('messages')">
<div class="card-panel-icon-wrapper icon-message">
<svg-icon icon-class="message" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">
消息
</div>
<count-to :start-val="0" :end-val="81212" :duration="3000" class="card-panel-num" />
</div>
</div>
</el-col>
<el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
<div class="card-panel" @click="handleSetLineChartData('purchases')">
<div class="card-panel-icon-wrapper icon-money">
<svg-icon icon-class="money" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">
金额
</div>
<count-to :start-val="0" :end-val="9280" :duration="3200" class="card-panel-num" />
</div>
</div>
</el-col>
<el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
<div class="card-panel" @click="handleSetLineChartData('shoppings')">
<div class="card-panel-icon-wrapper icon-shopping">
<svg-icon icon-class="shopping" class-name="card-panel-icon" />
</div>
<div class="card-panel-description">
<div class="card-panel-text">
订单
</div>
<count-to :start-val="0" :end-val="13600" :duration="3600" class="card-panel-num" />
</div>
</div>
</el-col>
</el-row>
</template>
<script>
import CountTo from 'vue-count-to'
export default {
components: {
CountTo
},
methods: {
handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type)
}
}
}
</script>
<style lang="scss" scoped>
.panel-group {
margin-top: 18px;
.card-panel-col {
margin-bottom: 32px;
}
.card-panel {
height: 108px;
cursor: pointer;
font-size: 12px;
position: relative;
overflow: hidden;
color: #666;
background: #fff;
box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
border-color: rgba(0, 0, 0, .05);
&:hover {
.card-panel-icon-wrapper {
color: #fff;
}
.icon-people {
background: #40c9c6;
}
.icon-message {
background: #36a3f7;
}
.icon-money {
background: #f4516c;
}
.icon-shopping {
background: #34bfa3
}
}
.icon-people {
color: #40c9c6;
}
.icon-message {
color: #36a3f7;
}
.icon-money {
color: #f4516c;
}
.icon-shopping {
color: #34bfa3
}
.card-panel-icon-wrapper {
float: left;
margin: 14px 0 0 14px;
padding: 16px;
transition: all 0.38s ease-out;
border-radius: 6px;
}
.card-panel-icon {
float: left;
font-size: 48px;
}
.card-panel-description {
float: right;
font-weight: bold;
margin: 26px;
margin-left: 0px;
.card-panel-text {
line-height: 18px;
color: rgba(0, 0, 0, 0.45);
font-size: 16px;
margin-bottom: 12px;
}
.card-panel-num {
font-size: 20px;
}
}
}
}
@media (max-width:550px) {
.card-panel-description {
display: none;
}
.card-panel-icon-wrapper {
float: none !important;
width: 100%;
height: 100%;
margin: 0 !important;
.svg-icon {
display: block;
margin: 14px auto !important;
float: none !important;
}
}
}
</style>
+79
View File
@@ -0,0 +1,79 @@
<template>
<div :class="className" :style="{height:height,width:width}" />
</template>
<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
export default {
mixins: [resize],
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '300px'
}
},
data() {
return {
chart: null
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
legend: {
left: 'center',
bottom: '10',
data: ['Industries', 'Technology', 'Forex', 'Gold', 'Forecasts']
},
series: [
{
name: 'WEEKLY WRITE ARTICLES',
type: 'pie',
roseType: 'radius',
radius: [15, 95],
center: ['50%', '38%'],
data: [
{ value: 320, name: 'Industries' },
{ value: 240, name: 'Technology' },
{ value: 149, name: 'Forex' },
{ value: 100, name: 'Gold' },
{ value: 59, name: 'Forecasts' }
],
animationEasing: 'cubicInOut',
animationDuration: 2600
}
]
})
}
}
}
</script>
@@ -0,0 +1,116 @@
<template>
<div :class="className" :style="{height:height,width:width}" />
</template>
<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
const animationDuration = 3000
export default {
mixins: [resize],
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '300px'
}
},
data() {
return {
chart: null
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
radar: {
radius: '66%',
center: ['50%', '42%'],
splitNumber: 8,
splitArea: {
areaStyle: {
color: 'rgba(127,95,132,.3)',
opacity: 1,
shadowBlur: 45,
shadowColor: 'rgba(0,0,0,.5)',
shadowOffsetX: 0,
shadowOffsetY: 15
}
},
indicator: [
{ name: 'Sales', max: 10000 },
{ name: 'Administration', max: 20000 },
{ name: 'Information Techology', max: 20000 },
{ name: 'Customer Support', max: 20000 },
{ name: 'Development', max: 20000 },
{ name: 'Marketing', max: 20000 }
]
},
legend: {
left: 'center',
bottom: '10',
data: ['Allocated Budget', 'Expected Spending', 'Actual Spending']
},
series: [{
type: 'radar',
symbolSize: 0,
areaStyle: {
normal: {
shadowBlur: 13,
shadowColor: 'rgba(0,0,0,.2)',
shadowOffsetX: 0,
shadowOffsetY: 10,
opacity: 1
}
},
data: [
{
value: [5000, 7000, 12000, 11000, 15000, 14000],
name: 'Allocated Budget'
},
{
value: [4000, 9000, 15000, 15000, 13000, 11000],
name: 'Expected Spending'
},
{
value: [5500, 11000, 12000, 15000, 12000, 12000],
name: 'Actual Spending'
}
],
animationDuration: animationDuration
}]
})
}
}
}
</script>
@@ -0,0 +1,56 @@
import { debounce } from '@/utils'
export default {
data() {
return {
$_sidebarElm: null,
$_resizeHandler: null
}
},
mounted() {
this.initListener()
},
activated() {
if (!this.$_resizeHandler) {
// avoid duplication init
this.initListener()
}
// when keep-alive chart activated, auto resize
this.resize()
},
beforeDestroy() {
this.destroyListener()
},
deactivated() {
this.destroyListener()
},
methods: {
// use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_sidebarResizeHandler(e) {
if (e.propertyName === 'width') {
this.$_resizeHandler()
}
},
initListener() {
this.$_resizeHandler = debounce(() => {
this.resize()
}, 100)
window.addEventListener('resize', this.$_resizeHandler)
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
},
destroyListener() {
window.removeEventListener('resize', this.$_resizeHandler)
this.$_resizeHandler = null
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
},
resize() {
const { chart } = this
chart && chart.resize()
}
}
}
+88
View File
@@ -0,0 +1,88 @@
<template>
<div class="errPage-container">
<el-button icon="arrow-left" class="pan-back-btn" @click="back">
返回
</el-button>
<el-row>
<el-col :span="12">
<h1 class="text-jumbo text-ginormous">
401错误!
</h1>
<h2>您没有访问权限!</h2>
<h6>对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面</h6>
<ul class="list-unstyled">
<li class="link-type">
<router-link to="/">
回首页
</router-link>
</li>
</ul>
</el-col>
<el-col :span="12">
<img :src="errGif" width="313" height="428" alt="Girl has dropped her ice cream.">
</el-col>
</el-row>
</div>
</template>
<script>
import errGif from '@/assets/401_images/401.gif'
export default {
name: 'Page401',
data() {
return {
errGif: errGif + '?' + +new Date()
}
},
methods: {
back() {
if (this.$route.query.noGoBack) {
this.$router.push({ path: '/' })
} else {
this.$router.go(-1)
}
}
}
}
</script>
<style lang="scss" scoped>
.errPage-container {
width: 800px;
max-width: 100%;
margin: 100px auto;
.pan-back-btn {
background: #008489;
color: #fff;
border: none!important;
}
.pan-gif {
margin: 0 auto;
display: block;
}
.pan-img {
display: block;
margin: 0 auto;
width: 100%;
}
.text-jumbo {
font-size: 60px;
font-weight: 700;
color: #484848;
}
.list-unstyled {
font-size: 14px;
li {
padding-bottom: 5px;
}
a {
color: #008489;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
}
</style>
+233
View File
@@ -0,0 +1,233 @@
<template>
<div class="wscn-http404-container">
<div class="wscn-http404">
<div class="pic-404">
<img class="pic-404__parent" src="@/assets/404_images/404.png" alt="404">
<img class="pic-404__child left" src="@/assets/404_images/404_cloud.png" alt="404">
<img class="pic-404__child mid" src="@/assets/404_images/404_cloud.png" alt="404">
<img class="pic-404__child right" src="@/assets/404_images/404_cloud.png" alt="404">
</div>
<div class="bullshit">
<div class="bullshit__oops">
404错误!
</div>
<div class="bullshit__headline">
{{ message }}
</div>
<div class="bullshit__info">
对不起,您正在寻找的页面不存在。尝试检查URL的错误,然后按浏览器上的刷新按钮或尝试在我们的应用程序中找到其他内容。
</div>
<router-link to="/" class="bullshit__return-home">
返回首页
</router-link>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Page404',
computed: {
message() {
return '找不到网页!'
}
}
}
</script>
<style lang="scss" scoped>
.wscn-http404-container{
transform: translate(-50%,-50%);
position: absolute;
top: 40%;
left: 50%;
}
.wscn-http404 {
position: relative;
width: 1200px;
padding: 0 50px;
overflow: hidden;
.pic-404 {
position: relative;
float: left;
width: 600px;
overflow: hidden;
&__parent {
width: 100%;
}
&__child {
position: absolute;
&.left {
width: 80px;
top: 17px;
left: 220px;
opacity: 0;
animation-name: cloudLeft;
animation-duration: 2s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 1s;
}
&.mid {
width: 46px;
top: 10px;
left: 420px;
opacity: 0;
animation-name: cloudMid;
animation-duration: 2s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 1.2s;
}
&.right {
width: 62px;
top: 100px;
left: 500px;
opacity: 0;
animation-name: cloudRight;
animation-duration: 2s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-delay: 1s;
}
@keyframes cloudLeft {
0% {
top: 17px;
left: 220px;
opacity: 0;
}
20% {
top: 33px;
left: 188px;
opacity: 1;
}
80% {
top: 81px;
left: 92px;
opacity: 1;
}
100% {
top: 97px;
left: 60px;
opacity: 0;
}
}
@keyframes cloudMid {
0% {
top: 10px;
left: 420px;
opacity: 0;
}
20% {
top: 40px;
left: 360px;
opacity: 1;
}
70% {
top: 130px;
left: 180px;
opacity: 1;
}
100% {
top: 160px;
left: 120px;
opacity: 0;
}
}
@keyframes cloudRight {
0% {
top: 100px;
left: 500px;
opacity: 0;
}
20% {
top: 120px;
left: 460px;
opacity: 1;
}
80% {
top: 180px;
left: 340px;
opacity: 1;
}
100% {
top: 200px;
left: 300px;
opacity: 0;
}
}
}
}
.bullshit {
position: relative;
float: left;
width: 300px;
padding: 30px 0;
overflow: hidden;
&__oops {
font-size: 32px;
font-weight: bold;
line-height: 40px;
color: #1482f0;
opacity: 0;
margin-bottom: 20px;
animation-name: slideUp;
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
&__headline {
font-size: 20px;
line-height: 24px;
color: #222;
font-weight: bold;
opacity: 0;
margin-bottom: 10px;
animation-name: slideUp;
animation-duration: 0.5s;
animation-delay: 0.1s;
animation-fill-mode: forwards;
}
&__info {
font-size: 13px;
line-height: 21px;
color: grey;
opacity: 0;
margin-bottom: 30px;
animation-name: slideUp;
animation-duration: 0.5s;
animation-delay: 0.2s;
animation-fill-mode: forwards;
}
&__return-home {
display: block;
float: left;
width: 110px;
height: 36px;
background: #1482f0;
border-radius: 100px;
text-align: center;
color: #ffffff;
opacity: 0;
font-size: 14px;
line-height: 36px;
cursor: pointer;
animation-name: slideUp;
animation-duration: 0.5s;
animation-delay: 0.3s;
animation-fill-mode: forwards;
}
@keyframes slideUp {
0% {
transform: translateY(60px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
}
}
</style>
+296
View File
@@ -0,0 +1,296 @@
<template>
<div class="app-container home">
<!-- 通知公告 -->
<el-row :gutter="20" class="bottom-row">
<el-col :xs="24" :sm="24" :md="24" :lg="24">
<el-card class="module-card notice-card" shadow="hover">
<div slot="header" class="card-header">
<span><i class="el-icon-bell card-icon"></i> 通知公告</span>
<el-button v-show="false" type="text" class="more-btn" @click="handleMore('notice')">更多 <i class="el-icon-arrow-right"></i></el-button>
</div>
<div class="card-body notice-body" v-loading="noticeLoading">
<div v-if="noticeList.length === 0" class="empty-state mini-empty">
<i class="el-icon-inbox empty-icon"></i>
<p>暂无公告</p>
</div>
<div v-else class="notice-list">
<div v-for="item in noticeList" :key="item.noticeId" class="notice-item" @click="handleViewNotice(item)">
<div class="notice-main">
<el-tag size="mini" :type="item.noticeType === '1' ? 'warning' : 'success'" class="notice-tag">
{{ item.noticeType === '1' ? '通知' : '公告' }}
</el-tag>
<span class="notice-title">{{ item.noticeTitle }}</span>
</div>
<div class="notice-meta">
<span>{{ item.createBy || '系统' }}</span>
<span>{{ item.createTime }}</span>
</div>
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<notice-detail-view ref="noticeViewRef" />
</div>
</template>
<script>
import { listNoticeTop } from "@/api/system/notice"
import NoticeDetailView from "@/layout/components/HeaderNotice/DetailView"
export default {
name: "Index",
components: { NoticeDetailView },
data() {
return {
version: "3.9.2",
noticeList: [],
noticeLoading: false
}
},
mounted() {
this.loadNoticeList()
},
methods: {
goTarget(href) {
window.open(href, "_blank")
},
handleMore(type) {
const titleMap = {
notice: '通知公告'
}
const targetTitle = titleMap[type]
if (targetTitle) {
const routes = this.$store.getters.sidebarRouters || []
const findRouteByTitle = (routeList, parentPath = '') => {
for (const route of routeList) {
const fullPath = parentPath ? parentPath + '/' + route.path : route.path
if (route.meta && route.meta.title === targetTitle) {
return fullPath
}
if (route.children && route.children.length) {
const found = findRouteByTitle(route.children, fullPath)
if (found) return found
}
}
return null
}
const targetPath = findRouteByTitle(routes)
if (targetPath) {
this.$router.push(targetPath)
return
}
}
this.$message.info("更多功能暂未开放")
},
loadNoticeList() {
this.noticeLoading = true
listNoticeTop().then(response => {
this.noticeList = response.data || []
this.noticeLoading = false
}).catch(() => {
this.noticeLoading = false
})
},
handleViewNotice(item) {
this.$refs.noticeViewRef.open(item)
}
}
}
</script>
<style scoped lang="scss">
.home {
background: linear-gradient(135deg, #f5f7fa 0%, #eef0f8 50%, #f5f7fa 100%);
min-height: calc(100vh - 84px);
padding: 20px;
position: relative;
.bottom-row {
margin-bottom: 20px;
}
.module-card {
height: 420px;
width: 100%;
display: flex;
flex-direction: column;
border-radius: 10px;
border: none;
transition: all 0.3s ease;
background: linear-gradient(180deg, #ffffff 0%, #f8f9fd 100%);
box-shadow: 0 4px 20px rgba(0, 135, 90, 0.06);
&:hover {
box-shadow: 0 8px 30px rgba(0, 135, 90, 0.12);
}
::v-deep .el-card__header {
padding: 14px 20px;
border-bottom: 1px solid rgba(0, 135, 90, 0.08);
background: linear-gradient(135deg, var(--edu-green-dark) 0%, var(--edu-green-primary) 100%);
border-radius: 10px 10px 0 0;
flex-shrink: 0;
}
::v-deep .el-card__body {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
padding: 0;
}
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
font-weight: 600;
font-size: 15px;
color: #ffffff;
.card-icon {
margin-right: 6px;
color: var(--edu-green-light);
font-size: 16px;
}
.more-btn {
padding: 0;
font-size: 13px;
color: rgba(255, 255, 255, 0.75);
&:hover {
color: #ffffff;
}
i {
font-size: 12px;
}
}
}
.card-body {
flex: 1;
display: flex;
flex-direction: column;
overflow-x: hidden;
overflow-y: auto;
padding: 15px 20px;
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
}
.card-footer {
flex-shrink: 0;
padding: 10px 20px 15px;
text-align: right;
border-top: 1px solid rgba(0, 135, 90, 0.06);
background: linear-gradient(180deg, #ffffff 0%, #f4f6fb 100%);
overflow-x: auto;
::v-deep .el-pagination__total,
::v-deep .el-pagination__jump,
::v-deep .el-pager li {
color: #5a5f7a;
}
::v-deep .el-pager li.active,
::v-deep .el-pager li:hover {
color: var(--edu-green-dark);
}
}
.empty-state {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 160px;
color: #8a90ad;
.empty-icon {
font-size: 48px;
margin-bottom: 12px;
color: #b8bed8;
}
p {
margin: 0;
font-size: 14px;
}
}
.notice-list {
.notice-item {
padding: 14px 0;
border-bottom: 1px solid #f5f5f5;
cursor: pointer;
transition: all 0.2s;
&:last-child {
border-bottom: none;
}
&:hover {
background: rgba(0, 135, 90, 0.03);
margin: 0 -20px;
padding-left: 20px;
padding-right: 20px;
}
.notice-main {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
.notice-tag {
flex-shrink: 0;
&.el-tag--warning {
background-color: rgba(0, 135, 90, 0.08);
border-color: rgba(0, 135, 90, 0.15);
color: var(--edu-green-dark);
}
&.el-tag--success {
background-color: rgba(0, 135, 90, 0.06);
border-color: rgba(0, 135, 90, 0.12);
color: var(--edu-green-primary);
}
}
.notice-title {
flex: 1;
font-size: 13px;
color: #303133;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
&:hover {
color: var(--edu-green-dark);
}
}
}
.notice-meta {
display: flex;
justify-content: space-between;
font-size: 12px;
color: #909399;
padding-left: 42px;
}
}
}
}
</style>
+449
View File
@@ -0,0 +1,449 @@
<template>
<div class="login">
<div class="login-card">
<aside class="brand-panel">
<div class="brand-main">
<div class="brand-mark" aria-hidden="true">教</div>
<h1 class="brand-title">{{ title }}</h1>
<p class="brand-tagline">开课计划 · 课表编排 · 成绩管理 · 教学分析</p>
<div class="brand-illustration" aria-hidden="true">
<svg-icon icon-class="education" />
</div>
</div>
<p class="brand-footnote">仅限授权单位内部使用</p>
</aside>
<section class="form-panel">
<div class="form-heading">
<h2>用户登录</h2>
<p>请使用内网账号进入系统</p>
</div>
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" label-position="top" @submit.native.prevent>
<el-form-item label="用户名" prop="username">
<el-input
v-model="loginForm.username"
type="text"
auto-complete="off"
placeholder="请输入用户名"
/>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input
v-model="loginForm.password"
type="password"
auto-complete="off"
placeholder="请输入密码"
show-password
@keyup.enter.native="handleLogin"
/>
</el-form-item>
<div class="form-extra">
<el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>
<router-link v-if="register" class="register-link" to="/register">立即注册</router-link>
</div>
<el-form-item class="login-action">
<el-button
:loading="loading"
type="primary"
class="login-btn"
native-type="submit"
@click.native.prevent="handleLogin"
>
<span v-if="!loading">登 录</span>
<span v-else>登 录 中...</span>
</el-button>
</el-form-item>
</el-form>
<p class="access-hint">登录后按账号权限进入对应业务,请妥善保管账号与口令。</p>
<div class="role-tags" aria-label="系统角色">
<span v-for="role in roles" :key="role.name" class="role-tag" :class="role.tone">{{ role.name }}</span>
</div>
<p class="form-footer">{{ footerContent }}</p>
</section>
</div>
</div>
</template>
<script>
import Cookies from "js-cookie"
import { encrypt, decrypt } from '@/utils/jsencrypt'
export default {
name: "Login",
data() {
return {
title: process.env.VUE_APP_TITLE,
footerContent: "Copyright © 2018-2026 教学管理信息系统 内部使用",
roles: [
{ name: "系统管理员", tone: "admin" },
{ name: "教务人员", tone: "affairs" },
{ name: "教研室", tone: "office" },
{ name: "教员", tone: "teacher" },
{ name: "学员", tone: "student" }
],
loginForm: {
username: "admin",
password: "admin123",
rememberMe: false
},
loginRules: {
username: [
{ required: true, trigger: "blur", message: "请输入您的账号" }
],
password: [
{ required: true, trigger: "blur", message: "请输入您的密码" }
]
},
loading: false,
register: false,
redirect: undefined
}
},
watch: {
$route: {
handler: function(route) {
this.redirect = route.query && route.query.redirect
},
immediate: true
}
},
created() {
this.getCookie()
},
methods: {
getCookie() {
const username = Cookies.get("username")
const password = Cookies.get("password")
const rememberMe = Cookies.get('rememberMe')
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
password: password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
}
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
if (this.loginForm.rememberMe) {
Cookies.set("username", this.loginForm.username, { expires: 30 })
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 })
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
} else {
Cookies.remove("username")
Cookies.remove("password")
Cookies.remove('rememberMe')
}
const loginData = {
username: this.loginForm.username,
password: this.loginForm.password
}
this.$store.dispatch("Login", loginData).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{})
}).catch(() => {
this.loading = false
})
}
})
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.login {
display: flex;
justify-content: center;
align-items: center;
min-height: 100%;
padding: 28px 20px;
background:
radial-gradient(circle at 18% 16%, rgba(11, 107, 85, 0.28), transparent 42%),
radial-gradient(circle at 86% 82%, rgba(198, 155, 60, 0.10), transparent 36%),
#10241f;
}
.login-card {
display: flex;
width: min(1080px, 100%);
overflow: hidden;
background: linear-gradient(160deg, #0c7a62 0%, #0b6b55 46%, #084c3f 100%);
border-radius: 18px;
box-shadow: 0 22px 56px rgba(8, 36, 30, 0.32);
}
.brand-panel {
display: flex;
flex-direction: column;
position: relative;
width: 42%;
padding: 48px 40px 24px;
color: #ffffff;
background: transparent;
overflow: hidden;
}
.brand-main {
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
min-height: 0;
padding-bottom: 12px;
}
.brand-mark {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 48px;
left: 40px;
width: 48px;
height: 48px;
color: #7a5410;
font-size: 26px;
font-weight: 700;
background: #e4c56a;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(16, 36, 28, 0.18);
}
.brand-title {
margin: 0 0 10px;
font-size: 32px;
font-weight: 700;
line-height: 1.25;
letter-spacing: 1px;
}
.brand-tagline {
margin: 0;
color: rgba(255, 255, 255, 0.78);
font-size: 13px;
letter-spacing: 0.4px;
}
.brand-illustration {
width: 116px;
height: 116px;
margin-top: 44px;
color: rgba(255, 255, 255, 0.12);
font-size: 116px;
line-height: 1;
transform: rotate(-6deg);
}
.brand-illustration .svg-icon {
display: block;
width: 100%;
height: 100%;
}
.brand-footnote {
margin: 16px 0 0;
color: rgba(255, 255, 255, 0.52);
font-size: 12px;
}
.form-panel {
display: flex;
flex-direction: column;
flex: 1;
padding: 56px 56px 28px;
background: #ffffff;
}
.form-heading {
margin-bottom: 32px;
}
.form-heading h2 {
margin: 0 0 8px;
color: #172b25;
font-size: 28px;
font-weight: 700;
letter-spacing: 0.5px;
}
.form-heading p {
margin: 0;
color: #7a8a85;
font-size: 14px;
}
.login-form {
::v-deep .el-form-item {
margin-bottom: 22px;
}
::v-deep .el-form-item__label {
float: none;
display: block;
padding: 0 0 8px;
line-height: 1.2;
color: #172b25;
font-size: 14px;
font-weight: 600;
}
::v-deep .el-form-item__content {
margin-left: 0 !important;
line-height: normal;
}
::v-deep .el-input__inner {
height: 48px;
padding: 0 16px;
color: #172b25;
background: #f3f6f5;
border: 1px solid transparent;
border-radius: 10px;
box-shadow: none;
}
::v-deep .el-input__inner:hover {
border-color: #c8d8d2;
}
::v-deep .el-input__inner:focus {
background: #ffffff;
border-color: #0b6b55;
box-shadow: 0 0 0 3px rgba(11, 107, 85, 0.10);
}
::v-deep .el-input__suffix {
right: 10px;
}
::v-deep .el-form-item__error {
padding-top: 4px;
}
}
.form-extra {
display: flex;
align-items: center;
justify-content: space-between;
margin: -6px 0 18px;
::v-deep .el-checkbox__label {
color: #52645f;
font-size: 13px;
font-weight: 400;
}
}
.register-link {
color: #0b6b55;
font-size: 13px;
}
.login-action {
margin-bottom: 0;
}
.login-btn {
width: 100%;
height: 48px;
font-size: 16px;
font-weight: 600;
letter-spacing: 6px;
border-radius: 10px;
}
.access-hint {
margin: 18px 0 16px;
color: #7a8a85;
font-size: 12px;
line-height: 1.6;
}
.role-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.role-tag {
padding: 4px 10px;
font-size: 12px;
font-weight: 600;
line-height: 1.6;
border-radius: 999px;
}
.role-tag.admin {
color: #3d6ea8;
background: #e8f1fb;
}
.role-tag.affairs {
color: #0b6b55;
background: #e8f3ef;
}
.role-tag.office {
color: #b77a17;
background: #f8f1e4;
}
.role-tag.teacher {
color: #6b5b93;
background: #f0eaf6;
}
.role-tag.student {
color: #9a7424;
background: #f7f0de;
}
.form-footer {
margin-top: auto;
padding-top: 28px;
color: #9aa7a3;
font-size: 12px;
text-align: center;
}
@media (max-width: 900px) {
.login {
align-items: flex-start;
padding: 16px;
}
.login-card {
flex-direction: column;
}
.brand-panel {
width: 100%;
padding: 28px 24px 20px;
}
.brand-mark {
position: static;
margin-bottom: 22px;
}
.brand-title {
font-size: 26px;
}
.brand-illustration {
display: none;
}
.form-panel {
padding: 32px 24px 20px;
}
}
@media (max-width: 640px) {
.form-heading h2 {
font-size: 24px;
}
}
</style>
+148
View File
@@ -0,0 +1,148 @@
<template>
<div class="app-container">
<el-row :gutter="10">
<el-col :span="24" class="card-box">
<el-card>
<div slot="header"><span><i class="el-icon-monitor"></i> 基本信息</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%">
<tbody>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">Redis版本</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.redis_version }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">运行模式</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.redis_mode == "standalone" ? "单机" : "集群" }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">端口</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.tcp_port }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">客户端数</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.connected_clients }}</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">运行时间(天)</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.uptime_in_days }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">使用内存</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.used_memory_human }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">使用CPU</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ parseFloat(cache.info.used_cpu_user_children).toFixed(2) }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">内存配置</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.maxmemory_human }}</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">AOF是否开启</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.aof_enabled == "0" ? "否" : "是" }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">RDB是否成功</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.rdb_last_bgsave_status }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">Key数量</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.dbSize">{{ cache.dbSize }} </div></td>
<td class="el-table__cell is-leaf"><div class="cell">网络入口/出口</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="cache.info">{{ cache.info.instantaneous_input_kbps }}kps/{{cache.info.instantaneous_output_kbps}}kps</div></td>
</tr>
</tbody>
</table>
</div>
</el-card>
</el-col>
<el-col :span="12" class="card-box">
<el-card>
<div slot="header"><span><i class="el-icon-pie-chart"></i> 命令统计</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<div ref="commandstats" style="height: 420px" />
</div>
</el-card>
</el-col>
<el-col :span="12" class="card-box">
<el-card>
<div slot="header"><span><i class="el-icon-odometer"></i> 内存信息</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<div ref="usedmemory" style="height: 420px" />
</div>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import { getCache } from "@/api/monitor/cache"
import * as echarts from "echarts"
export default {
name: "Cache",
data() {
return {
// 统计命令信息
commandstats: null,
// 使用内存
usedmemory: null,
// cache信息
cache: []
}
},
created() {
this.getList()
this.openLoading()
},
methods: {
/** 查缓存询信息 */
getList() {
getCache().then((response) => {
this.cache = response.data
this.$modal.closeLoading()
this.commandstats = echarts.init(this.$refs.commandstats, "macarons")
this.commandstats.setOption({
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)",
},
series: [
{
name: "命令",
type: "pie",
roseType: "radius",
radius: [15, 95],
center: ["50%", "38%"],
data: response.data.commandStats,
animationEasing: "cubicInOut",
animationDuration: 1000,
}
]
})
this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons")
this.usedmemory.setOption({
tooltip: {
formatter: "{b} <br/>{a} : " + this.cache.info.used_memory_human,
},
series: [
{
name: "峰值",
type: "gauge",
min: 0,
max: 1000,
detail: {
formatter: this.cache.info.used_memory_human,
},
data: [
{
value: parseFloat(this.cache.info.used_memory_human),
name: "内存消耗",
}
]
}
]
})
window.addEventListener("resize", () => {
this.commandstats.resize()
this.usedmemory.resize()
})
})
},
// 打开加载层
openLoading() {
this.$modal.loading("正在加载缓存监控数据,请稍候!")
}
}
}
</script>
+241
View File
@@ -0,0 +1,241 @@
<template>
<div class="app-container">
<el-row :gutter="10">
<el-col :span="8">
<el-card style="height: calc(100vh - 125px)">
<div slot="header">
<span><i class="el-icon-collection"></i> 缓存列表</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh-right"
@click="refreshCacheNames()"
></el-button>
</div>
<el-table
v-loading="loading"
:data="cacheNames"
:height="tableHeight"
highlight-current-row
@row-click="getCacheKeys"
style="width: 100%"
>
<el-table-column
label="序号"
width="60"
type="index"
></el-table-column>
<el-table-column
label="缓存名称"
align="center"
prop="cacheName"
:show-overflow-tooltip="true"
:formatter="nameFormatter"
></el-table-column>
<el-table-column
label="备注"
align="center"
prop="remark"
:show-overflow-tooltip="true"
/>
<el-table-column
label="操作"
width="60"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleClearCacheName(scope.row)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="8">
<el-card style="height: calc(100vh - 125px)">
<div slot="header">
<span><i class="el-icon-key"></i> 键名列表</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh-right"
@click="refreshCacheKeys()"
></el-button>
</div>
<el-table
v-loading="subLoading"
:data="cacheKeys"
:height="tableHeight"
highlight-current-row
@row-click="handleCacheValue"
style="width: 100%"
>
<el-table-column
label="序号"
width="60"
type="index"
></el-table-column>
<el-table-column
label="缓存键名"
align="center"
:show-overflow-tooltip="true"
:formatter="keyFormatter"
>
</el-table-column>
<el-table-column
label="操作"
width="60"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleClearCacheKey(scope.row)"
></el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="8">
<el-card :bordered="false" style="height: calc(100vh - 125px)">
<div slot="header">
<span><i class="el-icon-document"></i> 缓存内容</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh-right"
@click="handleClearCacheAll()"
>清理全部</el-button
>
</div>
<el-form :model="cacheForm">
<el-row :gutter="32">
<el-col :offset="1" :span="22">
<el-form-item label="缓存名称:" prop="cacheName">
<el-input v-model="cacheForm.cacheName" :readOnly="true" />
</el-form-item>
</el-col>
<el-col :offset="1" :span="22">
<el-form-item label="缓存键名:" prop="cacheKey">
<el-input v-model="cacheForm.cacheKey" :readOnly="true" />
</el-form-item>
</el-col>
<el-col :offset="1" :span="22">
<el-form-item label="缓存内容:" prop="cacheValue">
<el-input
v-model="cacheForm.cacheValue"
type="textarea"
:rows="8"
:readOnly="true"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import { listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from "@/api/monitor/cache"
export default {
name: "CacheList",
data() {
return {
cacheNames: [],
cacheKeys: [],
cacheForm: {},
loading: true,
subLoading: false,
nowCacheName: "",
tableHeight: window.innerHeight - 200
}
},
created() {
this.getCacheNames()
},
methods: {
/** 查询缓存名称列表 */
getCacheNames() {
this.loading = true
listCacheName().then(response => {
this.cacheNames = response.data
this.loading = false
})
},
/** 刷新缓存名称列表 */
refreshCacheNames() {
this.getCacheNames()
this.$modal.msgSuccess("刷新缓存列表成功")
},
/** 清理指定名称缓存 */
handleClearCacheName(row) {
clearCacheName(row.cacheName).then(response => {
this.$modal.msgSuccess("清理缓存名称[" + row.cacheName + "]成功")
this.getCacheKeys()
})
},
/** 查询缓存键名列表 */
getCacheKeys(row) {
const cacheName = row !== undefined ? row.cacheName : this.nowCacheName
if (cacheName === "") {
return
}
this.subLoading = true
listCacheKey(cacheName).then(response => {
this.cacheKeys = response.data
this.subLoading = false
this.nowCacheName = cacheName
})
},
/** 刷新缓存键名列表 */
refreshCacheKeys() {
this.getCacheKeys()
this.$modal.msgSuccess("刷新键名列表成功")
},
/** 清理指定键名缓存 */
handleClearCacheKey(cacheKey) {
clearCacheKey(cacheKey).then(response => {
this.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功")
this.getCacheKeys()
})
},
/** 列表前缀去除 */
nameFormatter(row) {
return row.cacheName.replace(":", "")
},
/** 键名前缀去除 */
keyFormatter(cacheKey) {
return cacheKey.replace(this.nowCacheName, "")
},
/** 查询缓存内容详细 */
handleCacheValue(cacheKey) {
getCacheValue(this.nowCacheName, cacheKey).then(response => {
this.cacheForm = response.data
})
},
/** 清理全部缓存 */
handleClearCacheAll() {
clearCacheAll().then(response => {
this.$modal.msgSuccess("清理全部缓存成功")
})
}
}
}
</script>
@@ -0,0 +1,15 @@
<template>
<i-frame :src="url" />
</template>
<script>
import iFrame from "@/components/iFrame/index"
export default {
name: "Druid",
components: { iFrame },
data() {
return {
url: process.env.VUE_APP_BASE_API + "/druid/login.html"
}
}
}
</script>
+197
View File
@@ -0,0 +1,197 @@
<template>
<el-dialog :title="type === 'log' ? '调度日志详细' : '任务详细'" :visible.sync="visible" width="780px" append-to-body @close="$emit('update:visible', false)">
<div class="detail-wrap">
<template v-if="type === 'log'">
<!-- 基本信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-info"></i> 基本信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">日志编号</span><span class="detail-value">{{ form.jobLogId }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行状态</span>
<el-tag v-if="form.status == 0" type="success" size="small">正常</el-tag>
<el-tag v-else type="danger" size="small">失败</el-tag>
</div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">开始时间</span><span class="detail-value">{{ form.startTime }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">结束时间</span><span class="detail-value">{{ form.endTime }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">记录时间</span><span class="detail-value">{{ form.createTime }}</span></div>
</el-col>
<el-col :span="12" v-if="form.status == 0 && form.startTime && form.endTime">
<div class="detail-item"><span class="detail-label">执行耗时</span><span class="detail-value">{{ costTime }} 毫秒</span></div>
</el-col>
</el-row>
</div>
<!-- 任务信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-time"></i> 任务信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">任务名称</span><span class="detail-value">{{ form.jobName }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">任务分组</span>
<dict-tag :options="dict.type.sys_job_group" :value="form.jobGroup" />
</div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="24">
<div class="detail-item"><span class="detail-label">日志信息</span><span class="detail-value">{{ form.jobMessage }}</span></div>
</el-col>
</el-row>
</div>
<!-- 调用目标 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-s-operation"></i> 调用目标</div>
<div class="code-body">
<div class="code-wrap"><pre class="code-pre">{{ form.invokeTarget || '(无)' }}</pre></div>
</div>
</div>
<!-- 异常信息 -->
<div class="detail-card" v-if="form.status == 1">
<div class="detail-card-title error-title"><i class="el-icon-warning"></i> 异常信息</div>
<div class="error-body"><div class="error-msg">{{ form.exceptionInfo }}</div></div>
</div>
</template>
<template v-else>
<!-- 任务配置 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-setting"></i> 任务配置</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">任务编号</span><span class="detail-value">{{ form.jobId }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">任务名称</span><span class="detail-value">{{ form.jobName }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">任务分组</span>
<dict-tag :options="dict.type.sys_job_group" :value="form.jobGroup" />
</div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行状态</span>
<el-tag v-if="form.status == 0" type="success" size="small">正常</el-tag>
<el-tag v-else type="info" size="small">暂停</el-tag>
</div>
</el-col>
</el-row>
</div>
<!-- 调度信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-date"></i> 调度信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">cron 表达式</span><span class="detail-value mono">{{ form.cronExpression }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">下次执行时间</span><span class="detail-value">{{ parseTime(form.nextValidTime) }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行策略</span>
<el-tag v-if="form.misfirePolicy == 0" type="info" size="small">默认策略</el-tag>
<el-tag v-else-if="form.misfirePolicy == 1" type="warning" size="small">立即执行</el-tag>
<el-tag v-else-if="form.misfirePolicy == 2" type="primary" size="small">执行一次</el-tag>
<el-tag v-else-if="form.misfirePolicy == 3" type="danger" size="small">放弃执行</el-tag>
</div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">并发执行</span>
<el-tag v-if="form.concurrent == 0" type="success" size="small">允许</el-tag>
<el-tag v-else type="danger" size="small">禁止</el-tag>
</div>
</el-col>
</el-row>
</div>
<!-- 执行方法 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-s-operation"></i> 执行方法</div>
<div class="code-body">
<div class="code-wrap"><pre class="code-pre">{{ form.invokeTarget || '(无)' }}</pre></div>
</div>
</div>
<!-- 元信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-document"></i> 元信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">创建人</span><span class="detail-value">{{ form.createBy || '-' }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">创建时间</span><span class="detail-value">{{ form.createTime }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">更新人</span><span class="detail-value">{{ form.updateBy || '-' }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">更新时间</span><span class="detail-value">{{ form.updateTime || '-' }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row" v-if="form.remark">
<el-col :span="24">
<div class="detail-item"><span class="detail-label">备注</span><span class="detail-value">{{ form.remark }}</span></div>
</el-col>
</el-row>
</div>
</template>
</div>
</el-dialog>
</template>
<script>
export default {
dicts: ['sys_job_group'],
props: {
visible: { type: Boolean, default: false },
row: { type: Object, default: () => ({}) },
// 'job' 任务详细 | 'log' 调度日志详细
type: { type: String, default: 'job' }
},
computed: {
form() { return this.row || {} },
costTime() {
if (!this.form.startTime || !this.form.endTime) return 0
return new Date(this.form.endTime).getTime() - new Date(this.form.startTime).getTime()
}
}
}
</script>
<style scoped>
.detail-label {
width: 80px;
}
</style>
+508
View File
@@ -0,0 +1,508 @@
<template>
<div class="app-container monitor-job">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="任务名称" prop="jobName">
<el-input
v-model="queryParams.jobName"
placeholder="请输入任务名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="任务组名" prop="jobGroup">
<el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable>
<el-option
v-for="dict in dict.type.sys_job_group"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="任务状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable>
<el-option
v-for="dict in dict.type.sys_job_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['monitor:job:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['monitor:job:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['monitor:job:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['monitor:job:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-s-operation"
size="mini"
@click="handleJobLog"
v-hasPermi="['monitor:job:query']"
>日志</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="任务编号" width="100" align="center" prop="jobId" />
<el-table-column label="任务名称" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<a class="link-type" style="cursor:pointer" @click="handleView(scope.row)">{{ scope.row.jobName }}</a>
</template>
</el-table-column>
<el-table-column label="任务组名" align="center" prop="jobGroup">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_job_group" :value="scope.row.jobGroup"/>
</template>
</el-table-column>
<el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" />
<el-table-column label="cron执行表达式" align="center" prop="cronExpression" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['monitor:job:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['monitor:job:remove']"
>删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['monitor:job:changeStatus', 'monitor:job:query']">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleRun" icon="el-icon-caret-right"
v-hasPermi="['monitor:job:changeStatus']">执行一次</el-dropdown-item>
<el-dropdown-item command="handleJobLog" icon="el-icon-s-operation"
v-hasPermi="['monitor:job:query']">调度日志</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改定时任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="任务名称" prop="jobName">
<el-input v-model="form.jobName" placeholder="请输入任务名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务分组" prop="jobGroup">
<el-select v-model="form.jobGroup" placeholder="请选择任务分组">
<el-option
v-for="dict in dict.type.sys_job_group"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item prop="invokeTarget">
<span slot="label">
调用方法
<el-tooltip placement="top">
<div slot="content">
Bean调用示例:ryTask.ryParams('ry')
<br />Class类调用示例:com.roomroot.quartz.task.RyTask.ryParams('ry')
<br />参数说明:支持字符串,布尔类型,长整型,浮点型,整型
</div>
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-input v-model="form.invokeTarget" placeholder="请输入调用目标字符串" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="cron表达式" prop="cronExpression">
<el-input v-model="form.cronExpression" placeholder="请输入cron执行表达式">
<template slot="append">
<el-button type="primary" @click="handleShowCron">
生成表达式
<i class="el-icon-time el-icon--right"></i>
</el-button>
</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.jobId !== undefined">
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_job_status"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="执行策略" prop="misfirePolicy">
<el-radio-group v-model="form.misfirePolicy" size="small">
<el-radio-button label="1">立即执行</el-radio-button>
<el-radio-button label="2">执行一次</el-radio-button>
<el-radio-button label="3">放弃执行</el-radio-button>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否并发" prop="concurrent">
<el-radio-group v-model="form.concurrent" size="small">
<el-radio-button label="0">允许</el-radio-button>
<el-radio-button label="1">禁止</el-radio-button>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<el-dialog title="Cron表达式生成器" :visible.sync="openCron" append-to-body destroy-on-close class="scrollbar">
<crontab @hide="openCron=false" @fill="crontabFill" :expression="expression"></crontab>
</el-dialog>
<!-- 任务日志详细 -->
<job-detail :visible.sync="openView" :row="form" type="job" />
</div>
</template>
<script>
import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job"
import JobDetail from './detail'
import Crontab from '@/components/Crontab'
export default {
components: { Crontab, JobDetail },
name: "Job",
dicts: ['sys_job_group', 'sys_job_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 定时任务表格数据
jobList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否显示详细弹出层
openView: false,
// 是否显示Cron表达式弹出层
openCron: false,
// 传入的表达式
expression: "",
// 表格高度
tableHeight: window.innerHeight - 240,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
jobName: undefined,
jobGroup: undefined,
status: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
jobName: [
{ required: true, message: "任务名称不能为空", trigger: "blur" }
],
invokeTarget: [
{ required: true, message: "调用目标字符串不能为空", trigger: "blur" }
],
cronExpression: [
{ required: true, message: "cron执行表达式不能为空", trigger: "blur" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询定时任务列表 */
getList() {
this.loading = true
listJob(this.queryParams).then(response => {
this.jobList = response.rows
this.total = response.total
this.loading = false
})
},
// 任务组名字典翻译
jobGroupFormat(row, column) {
return this.selectDictLabel(this.dict.type.sys_job_group, row.jobGroup)
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
jobId: undefined,
jobName: undefined,
jobGroup: undefined,
invokeTarget: undefined,
cronExpression: undefined,
misfirePolicy: 1,
concurrent: 1,
status: "0"
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.jobId)
this.single = selection.length != 1
this.multiple = !selection.length
},
// 更多操作触发
handleCommand(command, row) {
switch (command) {
case "handleRun":
this.handleRun(row)
break
case "handleView":
this.handleView(row)
break
case "handleJobLog":
this.handleJobLog(row)
break
default:
break
}
},
// 任务状态修改
handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"
this.$modal.confirm('确认要"' + text + '""' + row.jobName + '"任务吗?').then(function() {
return changeJobStatus(row.jobId, row.status)
}).then(() => {
this.$modal.msgSuccess(text + "成功")
}).catch(function() {
row.status = row.status === "0" ? "1" : "0"
})
},
/* 立即执行一次 */
handleRun(row) {
this.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function() {
return runJob(row.jobId, row.jobGroup)
}).then(() => {
this.$modal.msgSuccess("执行成功")
}).catch(() => {})
},
/** 任务详细信息 */
handleView(row) {
getJob(row.jobId).then(response => {
this.form = response.data
this.openView = true
})
},
/** cron表达式按钮操作 */
handleShowCron() {
this.expression = this.form.cronExpression
this.openCron = true
},
/** 确定后回传值 */
crontabFill(value) {
this.form.cronExpression = value
},
/** 任务日志列表查询 */
handleJobLog(row) {
const jobId = row.jobId || 0
this.$router.push('/monitor/job-log/index/' + jobId)
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加任务"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const jobId = row.jobId || this.ids
getJob(jobId).then(response => {
this.form = response.data
this.open = true
this.title = "修改任务"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.jobId != undefined) {
updateJob(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addJob(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const jobIds = row.jobId || this.ids
this.$modal.confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?').then(function() {
return delJob(jobIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('monitor/job/export', {
...this.queryParams
}, `job_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.monitor-job ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.monitor-job ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.monitor-job ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.monitor-job ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+300
View File
@@ -0,0 +1,300 @@
<template>
<div class="app-container monitor-job-log">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="任务名称" prop="jobName">
<el-input
v-model="queryParams.jobName"
placeholder="请输入任务名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="任务组名" prop="jobGroup">
<el-select
v-model="queryParams.jobGroup"
placeholder="请选择任务组名"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.sys_job_group"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="执行状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="请选择执行状态"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.sys_common_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="执行时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['monitor:job:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
@click="handleClean"
v-hasPermi="['monitor:job:remove']"
>清空</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['monitor:job:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
icon="el-icon-close"
size="mini"
@click="handleClose"
>关闭</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="jobLogList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="日志编号" width="80" align="center" prop="jobLogId" />
<el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" />
<el-table-column label="任务组名" align="center" prop="jobGroup" :show-overflow-tooltip="true">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_job_group" :value="scope.row.jobGroup"/>
</template>
</el-table-column>
<el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" />
<el-table-column label="日志信息" align="center" prop="jobMessage" :show-overflow-tooltip="true" />
<el-table-column label="执行状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="执行时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleView(scope.row)"
v-hasPermi="['monitor:job:query']"
>详细</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<job-log-detail :visible.sync="open" :row="form" type="log" />
</div>
</template>
<script>
import { getJob} from "@/api/monitor/job"
import { listJobLog, delJobLog, cleanJobLog } from "@/api/monitor/jobLog"
import JobLogDetail from './detail'
export default {
name: "JobLog",
components: { JobLogDetail },
dicts: ['sys_common_status', 'sys_job_group'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 调度日志表格数据
jobLogList: [],
// 是否显示弹出层
open: false,
// 日期范围
dateRange: [],
// 表单参数
form: {},
// 表格高度
tableHeight: window.innerHeight - 240,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
jobName: undefined,
jobGroup: undefined,
status: undefined
}
}
},
created() {
const jobId = this.$route.params && this.$route.params.jobId
if (jobId !== undefined && jobId != 0) {
getJob(jobId).then(response => {
this.queryParams.jobName = response.data.jobName
this.queryParams.jobGroup = response.data.jobGroup
this.getList()
})
} else {
this.getList()
}
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询调度日志列表 */
getList() {
this.loading = true
listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.jobLogList = response.rows
this.total = response.total
this.loading = false
}
)
},
// 返回按钮
handleClose() {
const obj = { path: "/monitor/job" }
this.$tab.closeOpenPage(obj)
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.jobLogId)
this.multiple = !selection.length
},
/** 详细按钮操作 */
handleView(row) {
this.open = true
this.form = row
},
/** 删除按钮操作 */
handleDelete(row) {
const jobLogIds = this.ids
this.$modal.confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?').then(function() {
return delJobLog(jobLogIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 清空按钮操作 */
handleClean() {
this.$modal.confirm('是否确认清空所有调度日志数据项?').then(function() {
return cleanJobLog()
}).then(() => {
this.getList()
this.$modal.msgSuccess("清空成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('/monitor/jobLog/export', {
...this.queryParams
}, `log_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.monitor-job-log ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.monitor-job-log ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.monitor-job-log ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.monitor-job-log ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
@@ -0,0 +1,274 @@
<template>
<div class="app-container monitor-logininfor">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="登录地址" prop="ipaddr">
<el-input
v-model="queryParams.ipaddr"
placeholder="请输入登录地址"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="登录状态"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.sys_common_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="登录时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['monitor:logininfor:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
@click="handleClean"
v-hasPermi="['monitor:logininfor:remove']"
>清空</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-unlock"
size="mini"
:disabled="single"
@click="handleUnlock"
v-hasPermi="['monitor:logininfor:unlock']"
>解锁</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['monitor:logininfor:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<div class="table-wrapper">
<el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange" height="100%">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="访问编号" align="center" prop="infoId" />
<el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
<el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
<el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
<el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" />
<el-table-column label="操作系统" align="center" prop="os" />
<el-table-column label="登录状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="操作信息" align="center" prop="msg" :show-overflow-tooltip="true" />
<el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.loginTime) }}</span>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/monitor/logininfor"
export default {
name: "Logininfor",
dicts: ['sys_common_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 选择用户名
selectName: "",
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 表格数据
list: [],
// 日期范围
dateRange: [],
// 默认排序
defaultSort: { prop: "loginTime", order: "descending" },
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
ipaddr: undefined,
userName: undefined,
status: undefined
}
}
},
created() {
this.getList()
},
methods: {
/** 查询登录日志列表 */
getList() {
this.loading = true
list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.list = response.rows
this.total = response.total
this.loading = false
}
)
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.queryParams.pageNum = 1
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
},
/** 多选框选中数据 */
handleSelectionChange(selection) {
this.ids = selection.map(item => item.infoId)
this.single = selection.length!=1
this.multiple = !selection.length
this.selectName = selection.map(item => item.userName)
},
/** 排序触发事件 */
handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop
this.queryParams.isAsc = column.order
this.getList()
},
/** 删除按钮操作 */
handleDelete(row) {
const infoIds = row.infoId || this.ids
this.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function() {
return delLogininfor(infoIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 清空按钮操作 */
handleClean() {
this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function() {
return cleanLogininfor()
}).then(() => {
this.getList()
this.$modal.msgSuccess("清空成功")
}).catch(() => {})
},
/** 解锁按钮操作 */
handleUnlock() {
const username = this.selectName
this.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function() {
return unlockLogininfor(username)
}).then(() => {
this.$modal.msgSuccess("用户" + username + "解锁成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('monitor/logininfor/export', {
...this.queryParams
}, `logininfor_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.monitor-logininfor {
display: flex;
flex-direction: column;
height: calc(100vh - 124px);
}
.table-wrapper {
flex: 1;
overflow: hidden;
}
.monitor-logininfor ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.monitor-logininfor ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.monitor-logininfor ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.monitor-logininfor ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+152
View File
@@ -0,0 +1,152 @@
<template>
<div class="app-container monitor-online">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="登录地址" prop="ipaddr">
<el-input
v-model="queryParams.ipaddr"
placeholder="请输入登录地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table
v-loading="loading"
:data="list.slice((pageNum-1)*pageSize,pageNum*pageSize)"
style="width: 100%;"
:height="tableHeight"
>
<el-table-column label="序号" type="index" align="center">
<template slot-scope="scope">
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column label="会话编号" align="center" prop="tokenId" :show-overflow-tooltip="true" />
<el-table-column label="登录名称" align="center" prop="userName" :show-overflow-tooltip="true" />
<el-table-column label="部门名称" align="center" prop="deptName" />
<el-table-column label="主机" align="center" prop="ipaddr" :show-overflow-tooltip="true" />
<el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
<el-table-column label="浏览器" align="center" prop="browser" />
<el-table-column label="操作系统" align="center" prop="os" />
<el-table-column label="登录时间" align="center" prop="loginTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.loginTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleForceLogout(scope.row)"
v-hasPermi="['monitor:online:forceLogout']"
>强退</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />
</div>
</template>
<script>
import { list, forceLogout } from "@/api/monitor/online"
export default {
name: "Online",
data() {
return {
// 遮罩层
loading: true,
// 总条数
total: 0,
// 表格数据
list: [],
pageNum: 1,
pageSize: 10,
// 表格高度
tableHeight: window.innerHeight - 240,
// 查询参数
queryParams: {
ipaddr: undefined,
userName: undefined
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
methods: {
getTableHeight() {
this.tableHeight = window.innerHeight - 240
},
/** 查询登录日志列表 */
getList() {
this.loading = true
list(this.queryParams).then(response => {
this.list = response.rows
this.total = response.total
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 强退按钮操作 */
handleForceLogout(row) {
this.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?').then(function() {
return forceLogout(row.tokenId)
}).then(() => {
this.getList()
this.$modal.msgSuccess("强退成功")
}).catch(() => {})
}
}
}
</script>
<style scoped>
.monitor-online ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.monitor-online ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.monitor-online ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.monitor-online ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
@@ -0,0 +1,147 @@
<template>
<el-dialog title="操作日志详细" :visible.sync="visible" width="780px" append-to-body @close="$emit('update:visible', false)">
<div class="detail-wrap">
<!-- 基本信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-info"></i> 基本信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">操作模块</span><span class="detail-value">{{ form.title }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">业务类型</span><span class="detail-value">{{ typeLabel }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">操作时间</span><span class="detail-value">{{ form.operTime }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行状态</span>
<el-tag v-if="form.status === 0" type="success" size="small"><i class="el-icon-check"></i> 正常</el-tag>
<el-tag v-else type="danger" size="small"><i class="el-icon-close"></i> 异常</el-tag>
</div>
</el-col>
</el-row>
</div>
<!-- 操作人员 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-user"></i> 操作人员</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">操作人员</span><span class="detail-value">{{ form.operName }}</span></div>
</el-col>
<el-col :span="12" v-if="form.deptName">
<div class="detail-item"><span class="detail-label">所属部门</span><span class="detail-value">{{ form.deptName }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="24">
<div class="detail-item">
<span class="detail-label">操作地址</span>
<span class="detail-value">{{ form.operIp }}&nbsp;&nbsp;<span class="detail-location">{{ form.operLocation }}</span></span>
</div>
</el-col>
</el-row>
</div>
<!-- 请求信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-sort"></i> 请求信息</div>
<el-row class="detail-row">
<el-col :span="24">
<div class="detail-item">
<span class="detail-label">请求地址</span>
<span class="detail-value">
<span :class="'method-tag method-' + form.requestMethod">{{ form.requestMethod }}</span>
{{ form.operUrl }}
</span>
</div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="24">
<div class="detail-item"><span class="detail-label">操作方法</span><span class="detail-value mono">{{ form.method }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">消耗时间</span><span class="detail-value">{{ form.costTime }} 毫秒</span></div>
</el-col>
</el-row>
</div>
<!-- 请求参数 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-upload2"></i> 请求参数</div>
<div class="code-body">
<div class="code-wrap">
<div class="code-action">
<el-button size="mini" icon="el-icon-copy-document" @click="copyText(form.operParam)">复制</el-button>
</div>
<pre class="code-pre">{{ formatJson(form.operParam) }}</pre>
</div>
</div>
</div>
<!-- 返回参数 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-download"></i> 返回参数</div>
<div class="code-body">
<div class="code-wrap">
<div class="code-action">
<el-button size="mini" icon="el-icon-copy-document" @click="copyText(form.jsonResult)">复制</el-button>
</div>
<pre class="code-pre">{{ formatJson(form.jsonResult) }}</pre>
</div>
</div>
</div>
<!-- 异常信息 -->
<div class="detail-card" v-if="form.status !== 0">
<div class="detail-card-title error-title"><i class="el-icon-warning"></i> 异常信息</div>
<div class="error-body">
<div class="error-msg">{{ form.errorMsg }}</div>
</div>
</div>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'OperlogDetail',
dicts: ['sys_oper_type'],
props: {
visible: { type: Boolean, default: false },
row: { type: Object, default: () => ({}) }
},
computed: {
form() { return this.row || {} },
typeLabel() { return this.selectDictLabel(this.dict.type.sys_oper_type, this.form.businessType) || '-' }
},
methods: {
formatJson(str) {
if (!str) return '(无数据)'
try { return JSON.stringify(JSON.parse(str), null, 2) } catch { return str }
},
copyText(str) {
const text = this.formatJson(str)
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => this.$message({ message: '已复制', type: 'success', duration: 1500 }))
} else {
const ta = document.createElement('textarea')
ta.value = text
document.body.appendChild(ta)
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
this.$message({ message: '已复制', type: 'success', duration: 1500 })
}
}
}
}
</script>
@@ -0,0 +1,306 @@
<template>
<div class="app-container monitor-operlog">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="操作地址" prop="operIp">
<el-input
v-model="queryParams.operIp"
placeholder="请输入操作地址"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="系统模块" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入系统模块"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="操作人员" prop="operName">
<el-input
v-model="queryParams.operName"
placeholder="请输入操作人员"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="businessType">
<el-select
v-model="queryParams.businessType"
placeholder="操作类型"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.sys_oper_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="操作状态"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.sys_common_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="操作时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['monitor:operlog:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
@click="handleClean"
v-hasPermi="['monitor:operlog:remove']"
>清空</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['monitor:operlog:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<div class="table-wrapper">
<el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange" height="100%">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="日志编号" align="center" prop="operId" />
<el-table-column label="系统模块" align="center" prop="title" :show-overflow-tooltip="true" />
<el-table-column label="操作类型" align="center" prop="businessType">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_oper_type" :value="scope.row.businessType"/>
</template>
</el-table-column>
<el-table-column label="操作人员" align="center" prop="operName" width="110" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
<el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
<el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" />
<el-table-column label="操作状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="操作日期" align="center" prop="operTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.operTime) }}</span>
</template>
</el-table-column>
<el-table-column label="消耗时间" align="center" prop="costTime" width="110" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']">
<template slot-scope="scope">
<span>{{ scope.row.costTime }}毫秒</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleDetail(scope.row,scope.index)"
v-hasPermi="['monitor:operlog:query']"
>详细</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<operlog-detail :visible.sync="detailVisible" :row="detailRow" />
</div>
</template>
<script>
import OperlogDetail from './detail'
import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog"
export default {
name: "Operlog",
components: { OperlogDetail },
dicts: ['sys_oper_type', 'sys_common_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 表格数据
list: [],
// 是否显示弹出层
detailVisible: false,
detailRow: {},
// 日期范围
dateRange: [],
// 默认排序
defaultSort: { prop: "operTime", order: "descending" },
// 表单参数
form: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
operIp: undefined,
title: undefined,
operName: undefined,
businessType: undefined,
status: undefined
}
}
},
created() {
this.getList()
},
methods: {
/** 查询登录日志 */
getList() {
this.loading = true
list(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
this.list = response.rows
this.total = response.total
this.loading = false
}
)
},
// 详细按钮操作
handleDetail(row) {
this.detailRow = row
this.detailVisible = true
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.queryParams.pageNum = 1
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
},
/** 多选框选中数据 */
handleSelectionChange(selection) {
this.ids = selection.map(item => item.operId)
this.multiple = !selection.length
},
/** 排序触发事件 */
handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop
this.queryParams.isAsc = column.order
this.getList()
},
/** 删除按钮操作 */
handleDelete(row) {
const operIds = row.operId || this.ids
this.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function() {
return delOperlog(operIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 清空按钮操作 */
handleClean() {
this.$modal.confirm('是否确认清空所有操作日志数据项?').then(function() {
return cleanOperlog()
}).then(() => {
this.getList()
this.$modal.msgSuccess("清空成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('monitor/operlog/export', {
...this.queryParams
}, `operlog_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.monitor-operlog {
display: flex;
flex-direction: column;
height: calc(100vh - 124px);
}
.table-wrapper {
flex: 1;
overflow: hidden;
}
.monitor-operlog ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.monitor-operlog ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.monitor-operlog ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.monitor-operlog ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+207
View File
@@ -0,0 +1,207 @@
<template>
<div class="app-container">
<el-row :gutter="10">
<el-col :span="12" class="card-box">
<el-card>
<div slot="header"><span><i class="el-icon-cpu"></i> CPU</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%;">
<thead>
<tr>
<th class="el-table__cell is-leaf"><div class="cell">属性</div></th>
<th class="el-table__cell is-leaf"><div class="cell">值</div></th>
</tr>
</thead>
<tbody>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">核心数</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.cpuNum }}</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">用户使用率</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.used }}%</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">系统使用率</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.sys }}%</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">当前空闲率</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.free }}%</div></td>
</tr>
</tbody>
</table>
</div>
</el-card>
</el-col>
<el-col :span="12" class="card-box">
<el-card>
<div slot="header"><span><i class="el-icon-tickets"></i> 内存</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%;">
<thead>
<tr>
<th class="el-table__cell is-leaf"><div class="cell">属性</div></th>
<th class="el-table__cell is-leaf"><div class="cell">内存</div></th>
<th class="el-table__cell is-leaf"><div class="cell">JVM</div></th>
</tr>
</thead>
<tbody>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">总内存</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem">{{ server.mem.total }}G</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.total }}M</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">已用内存</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem">{{ server.mem.used}}G</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.used}}M</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">剩余内存</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem">{{ server.mem.free }}G</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.free }}M</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">使用率</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem" :class="{'text-danger': server.mem.usage > 80}">{{ server.mem.usage }}%</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm" :class="{'text-danger': server.jvm.usage > 80}">{{ server.jvm.usage }}%</div></td>
</tr>
</tbody>
</table>
</div>
</el-card>
</el-col>
<el-col :span="24" class="card-box">
<el-card>
<div slot="header">
<span><i class="el-icon-monitor"></i> 服务器信息</span>
</div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%;">
<tbody>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">服务器名称</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.computerName }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">操作系统</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.osName }}</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">服务器IP</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.computerIp }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">系统架构</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.osArch }}</div></td>
</tr>
</tbody>
</table>
</div>
</el-card>
</el-col>
<el-col :span="24" class="card-box">
<el-card>
<div slot="header">
<span><i class="el-icon-coffee-cup"></i> Java虚拟机信息</span>
</div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%;table-layout:fixed;">
<tbody>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">Java名称</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.name }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">Java版本</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.version }}</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">启动时间</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.startTime }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">运行时长</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.runTime }}</div></td>
</tr>
<tr>
<td colspan="1" class="el-table__cell is-leaf"><div class="cell">安装路径</div></td>
<td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.home }}</div></td>
</tr>
<tr>
<td colspan="1" class="el-table__cell is-leaf"><div class="cell">项目路径</div></td>
<td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
</tr>
<tr>
<td colspan="1" class="el-table__cell is-leaf"><div class="cell">运行参数</div></td>
<td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.inputArgs }}</div></td>
</tr>
</tbody>
</table>
</div>
</el-card>
</el-col>
<el-col :span="24" class="card-box">
<el-card>
<div slot="header">
<span><i class="el-icon-receiving"></i> 磁盘状态</span>
</div>
<div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%;">
<thead>
<tr>
<th class="el-table__cell el-table__cell is-leaf"><div class="cell">盘符路径</div></th>
<th class="el-table__cell is-leaf"><div class="cell">文件系统</div></th>
<th class="el-table__cell is-leaf"><div class="cell">盘符类型</div></th>
<th class="el-table__cell is-leaf"><div class="cell">总大小</div></th>
<th class="el-table__cell is-leaf"><div class="cell">可用大小</div></th>
<th class="el-table__cell is-leaf"><div class="cell">已用大小</div></th>
<th class="el-table__cell is-leaf"><div class="cell">已用百分比</div></th>
</tr>
</thead>
<tbody v-if="server.sysFiles">
<tr v-for="(sysFile, index) in server.sysFiles" :key="index">
<td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.dirName }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.sysTypeName }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.typeName }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.total }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.free }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.used }}</div></td>
<td class="el-table__cell is-leaf"><div class="cell" :class="{'text-danger': sysFile.usage > 80}">{{ sysFile.usage }}%</div></td>
</tr>
</tbody>
</table>
</div>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import { getServer } from "@/api/monitor/server"
export default {
name: "Server",
data() {
return {
// 服务器信息
server: []
}
},
created() {
this.getList()
this.openLoading()
},
methods: {
/** 查询服务器信息 */
getList() {
getServer().then(response => {
this.server = response.data
this.$modal.closeLoading()
})
},
// 打开加载层
openLoading() {
this.$modal.loading("正在加载服务监控数据,请稍候!")
}
}
}
</script>
+12
View File
@@ -0,0 +1,12 @@
<script>
export default {
created() {
const { params, query } = this.$route
const { path } = params
this.$router.replace({ path: '/' + path, query })
},
render: function(h) {
return h() // avoid warning message
}
}
</script>
+167
View File
@@ -0,0 +1,167 @@
<template>
<div class="register">
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
<h3 class="title">{{title}}</h3>
<el-form-item prop="username">
<el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="password" :rules="registerPwdValidator">
<el-input
v-model="registerForm.password"
type="password"
auto-complete="off"
placeholder="密码"
@keyup.enter.native="handleRegister"
>
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item prop="confirmPassword">
<el-input
v-model="registerForm.confirmPassword"
type="password"
auto-complete="off"
placeholder="确认密码"
@keyup.enter.native="handleRegister"
>
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
</el-input>
</el-form-item>
<el-form-item style="width:100%;">
<el-button
:loading="loading"
size="medium"
type="primary"
style="width:100%;"
@click.native.prevent="handleRegister"
>
<span v-if="!loading">注 册</span>
<span v-else>注 册 中...</span>
</el-button>
<div style="float: right;">
<router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
</div>
</el-form-item>
</el-form>
<!-- 底部 -->
<div class="el-register-footer">
<span>{{ footerContent }}</span>
</div>
</div>
</template>
<script>
import { register } from "@/api/login"
import passwordRule from "@/utils/passwordRule"
export default {
mixins: [passwordRule],
data() {
return {
title: process.env.VUE_APP_TITLE,
footerContent: "Copyright © 2018-2026 roomroot. All Rights Reserved.",
registerForm: {
username: "",
password: "",
confirmPassword: ""
},
loading: false
}
},
computed: {
registerRules() {
return {
username: [
{ required: true, trigger: "blur", message: "请输入您的账号" },
{ min: 2, max: 20, message: '用户账号长度必须介于 2 和 20 之间', trigger: 'blur' }
],
confirmPassword: [
{ required: true, message: "请再次输入您的密码", trigger: "blur" },
{
validator: (rule, value, callback) => {
if (this.registerForm.password !== value) {
callback(new Error("两次输入的密码不一致"))
} else {
callback()
}
}, trigger: "blur"
}
]
}
}
},
methods: {
handleRegister() {
this.$refs.registerForm.validate(valid => {
if (valid) {
this.loading = true
register(this.registerForm).then(() => {
const username = this.registerForm.username
this.$alert("<font color='red'>恭喜你,您的账号 " + username + " 注册成功!</font>", '系统提示', {
dangerouslyUseHTMLString: true,
type: 'success'
}).then(() => {
this.$router.push("/login")
}).catch(() => {})
}).catch(() => {
this.loading = false
})
}
})
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.register {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
background-image: url("../assets/images/login-background.jpg");
background-size: cover;
}
.title {
margin: 0px auto 30px auto;
text-align: center;
color: #707070;
}
.register-form {
border-radius: 6px;
background: #ffffff;
width: 400px;
padding: 25px 25px 5px 25px;
.el-input {
height: 38px;
input {
height: 38px;
}
}
.input-icon {
height: 39px;
width: 14px;
margin-left: 2px;
}
}
.register-tip {
font-size: 13px;
text-align: center;
color: #bfbfbf;
}
.el-register-footer {
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #fff;
font-family: Arial;
font-size: 12px;
letter-spacing: 1px;
}
</style>
@@ -0,0 +1,371 @@
<template>
<div class="app-container plan-import-page">
<!-- ==================== 1. 查询条件 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="100px" class="search-form">
<!-- 第一行:课程时间独占整行 -->
<el-row :gutter="24">
<el-col :span="24">
<el-form-item label="课程时间">
<div class="date-range">
<span>从</span>
<el-date-picker
v-model="searchForm.kssj"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="开始时间"
clearable
class="date-input"
/>
<span>到</span>
<el-date-picker
v-model="searchForm.jssj"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="结束时间"
clearable
class="date-input"
/>
</div>
</el-form-item>
</el-col>
</el-row>
<!-- 下面分左右两栏 -->
<el-row :gutter="24">
<el-col :xs="24" :md="12">
<el-form-item label="检查状态">
<div class="checkbox-group">
<el-checkbox v-model="searchForm.jcztYtg">已通过</el-checkbox>
<el-checkbox v-model="searchForm.jcztWtg">未通过</el-checkbox>
</div>
</el-form-item>
<el-form-item label="教员姓名">
<el-input v-model="searchForm.jyxm" placeholder="请输入教员姓名" clearable />
</el-form-item>
<el-form-item label="教学场地名称">
<el-input v-model="searchForm.jxcdmc" placeholder="请输入教学场地名称" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="12">
<el-form-item label="忽略状态">
<div class="checkbox-group">
<el-checkbox v-model="searchForm.hlztYc">有用</el-checkbox>
<el-checkbox v-model="searchForm.hlztYbl">已被忽略</el-checkbox>
</div>
</el-form-item>
<el-form-item label="班次名称">
<el-input v-model="searchForm.bcmc" placeholder="请输入班次名称" clearable />
</el-form-item>
<el-form-item label="科目名称">
<el-input v-model="searchForm.kmmc" placeholder="请输入科目名称" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" class="search-actions">
<el-button type="primary" @click="handleSearch">查询</el-button>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- ==================== 2. 操作按钮区 ==================== -->
<el-card shadow="never" class="action-card">
<div class="action-bar">
<div class="bar-center">
<div class="file-area">
<input ref="fileInputRef" type="file" accept=".xlsx,.xls" style="display: none" @change="handleFileChange" />
<el-button icon="el-icon-folder-opened" @click="handleChooseFile">选择文件</el-button>
<span class="file-name">{{ selectedFileName }}</span>
</div>
</div>
<div class="bar-right">
<el-button type="primary" icon="el-icon-upload2" @click="handleImport" :loading="importing">导入到系统</el-button>
</div>
</div>
</el-card>
<!-- ==================== 3. 数据表格 ==================== -->
<el-card shadow="never" class="table-card">
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row class="import-table">
<el-table-column prop="nd" label="年度" width="60" align="center" />
<el-table-column prop="xh" label="序号" width="53" align="center" />
<el-table-column prop="yxh" label="原序号" width="67" align="center" />
<el-table-column prop="rq" label="日期" width="120" align="center" :formatter="formatDate" />
<el-table-column prop="yjc" label="原节次" width="67" align="center" />
<el-table-column prop="jc" label="节次" width="53" align="center" />
<el-table-column prop="kcmc" label="课程名称" width="85" show-overflow-tooltip />
<el-table-column prop="bc" label="班次" width="53" show-overflow-tooltip />
<el-table-column prop="zrdw" label="责任单位" width="81" show-overflow-tooltip />
<el-table-column prop="skjy" label="授课教员" width="81" align="center" />
<el-table-column prop="jxcd" label="教学场地" width="81" align="center" />
<el-table-column prop="jxnr" label="教学内容" width="81" show-overflow-tooltip />
<el-table-column prop="jxff" label="教学方法" width="81" align="center" />
<el-table-column prop="jybz" label="教员备注" width="81" show-overflow-tooltip />
<el-table-column prop="jwbz" label="教务备注" width="81" show-overflow-tooltip />
<el-table-column prop="jcjg" label="检查结果" width="81" align="center" />
<el-table-column prop="ytgjc" label="已通过检查" width="95" align="center">
<template slot-scope="{ row }">
<span>{{ row.ytgjc ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column prop="ybhl" label="已被忽略" width="81" align="center">
<template slot-scope="{ row }">
<span>{{ row.ybhl ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column prop="ybcl" label="已被处理" width="81" align="center">
<template slot-scope="{ row }">
<span>{{ row.ybcl ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column prop="ybdr" label="已被导入" align="center">
<template slot-scope="{ row }">
<span>{{ row.ybdr ? '是' : '否' }}</span>
</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>
</div>
</template>
<script>
import { listTeachingPlan, importTeachingPlan } from '@/api/schedule/teachingPlan'
export default {
name: 'PlanImportIndex',
data() {
return {
// ==================== 查询表单 ====================
searchForm: {
kssj: '',
jssj: '',
jcztYtg: false,
jcztWtg: true,
hlztYc: false,
hlztYbl: true,
jyxm: '',
bcmc: '',
jxcdmc: '',
kmmc: ''
},
// ==================== 文件上传与导入 ====================
selectedFileName: '未选择任何文件',
selectedFile: null,
importing: false,
// ==================== 表格数据 ====================
tableData: [],
loading: false,
pageNum: 1,
pageSize: 20,
total: 0
}
},
mounted() {
this.fetchList()
},
methods: {
// ==================== 查询 ====================
// 仅传后端 Mapper 支持的字段:skjy(授课教员) bc(班次) kcmc(课程名称) ytgjc(已通过检查)
// 课程时间、忽略状态、教学场地名称后端列表查询不支持,不传
buildSearchParams() {
const f = this.searchForm
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (f.jyxm && f.jyxm.trim()) params.skjy = f.jyxm.trim()
if (f.bcmc && f.bcmc.trim()) params.bc = f.bcmc.trim()
if (f.kmmc && f.kmmc.trim()) params.kcmc = f.kmmc.trim()
// 检查状态:仅勾选「已通过」或「未通过」其中之一时才按该条件过滤
if (f.jcztYtg && !f.jcztWtg) params.ytgjc = true
else if (!f.jcztYtg && f.jcztWtg) params.ytgjc = false
return params
},
fetchList() {
this.loading = true
listTeachingPlan(this.buildSearchParams()).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()
},
handlePageChange(current) {
this.pageNum = current
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
/** 日期格式化 */
formatDate(row, column, cellValue) {
return cellValue ? String(cellValue).substring(0, 10) : ''
},
// ==================== 文件选择 ====================
handleChooseFile() {
this.$refs.fileInputRef && this.$refs.fileInputRef.click()
},
handleFileChange(event) {
const target = event.target
const file = target.files && target.files[0]
if (file) {
this.selectedFile = file
this.selectedFileName = file.name
} else {
this.selectedFile = null
this.selectedFileName = '未选择任何文件'
}
},
// ==================== 通用 Blob 下载 ====================
downloadBlob(blob, fileName) {
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
},
// ==================== 导入到系统 ====================
handleImport() {
if (!this.selectedFile) {
this.$message.warning('请先选择文件')
return
}
this.importing = true
importTeachingPlan(this.selectedFile).then(res => {
const count = res && res.data
if (count !== null && count !== undefined) {
this.$message.success(`导入成功,共 ${count} 条记录`)
} else {
this.$message.success((res && res.msg) || '导入成功')
}
this.selectedFile = null
this.selectedFileName = '未选择任何文件'
this.$refs.fileInputRef && (this.$refs.fileInputRef.value = '')
this.pageNum = 1
this.fetchList()
}).catch(() => {}).finally(() => {
this.importing = false
})
},
}
}
</script>
<style scoped lang="scss">
.plan-import-page {
.search-card {
margin-bottom: 16px;
.search-form {
.date-range {
display: flex;
align-items: center;
gap: 8px;
.date-input {
width: 180px;
flex-shrink: 0;
}
}
.checkbox-group {
display: flex;
align-items: center;
gap: 16px;
}
.form-tip {
color: #f56c6c;
font-size: 12px;
margin-bottom: 12px;
padding-left: 100px;
}
.search-actions {
display: flex;
justify-content: flex-end;
padding-top: 8px;
}
}
}
.action-card {
margin-bottom: 16px;
.action-bar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 16px;
.bar-left,
.bar-center,
.bar-right {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
}
.bar-right {
margin-left: auto;
}
.file-area {
display: flex;
align-items: center;
gap: 8px;
.file-name {
color: #606266;
font-size: 14px;
}
}
}
}
.table-card {
.import-table {
width: 100%;
}
}
}
</style>
+293
View File
@@ -0,0 +1,293 @@
<template>
<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 v-if="!isStudentRole" label="学号">
<el-input v-model="queryForm.xh" placeholder="请输入学号" clearable style="width: 180px" />
</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 label="课程名称">
<el-select v-model="queryForm.kcbh" placeholder="请选择课程名称" clearable filterable style="width: 200px">
<el-option v-for="item in kbOptions" :key="item.kbh" :label="item.kmc" :value="item.kbh" />
</el-select>
</el-form-item>
<el-form-item v-if="!isStudentRole" label="班次">
<el-select v-model="queryForm.xydbh" placeholder="请选择班次" clearable filterable style="width: 200px">
<el-option v-for="item in teamOptions" :key="item.xydbh" :label="item.xydmc" :value="item.xydbh" />
</el-select>
</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 style="width: 100%">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="kmbh" label="科目编号" min-width="110" show-overflow-tooltip />
<el-table-column prop="klx" label="课类型" min-width="90" align="center" />
<el-table-column prop="kscj" label="考试成绩" min-width="90" align="center" />
<el-table-column prop="pscj" label="平时成绩" min-width="90" align="center" />
<el-table-column prop="zzcj" label="最终成绩" min-width="90" align="center" />
<el-table-column prop="bkcj" label="补考成绩" min-width="90" align="center" />
<el-table-column prop="bkcs" label="补考次数" min-width="90" align="center" />
<el-table-column prop="ksqk" label="考试情况" min-width="90" align="center" />
<el-table-column prop="qwxf" label="期望学分" min-width="90" align="center" />
<el-table-column prop="ytg" label="考试结果" min-width="90" align="center" :formatter="formatExamResult" />
<el-table-column prop="nd" label="年度" min-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 style="width: 100%">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="kmbh" label="科目编号" min-width="110" show-overflow-tooltip />
<el-table-column prop="klx" label="课类型" min-width="90" align="center" />
<el-table-column prop="yscj" label="原始成绩" min-width="90" align="center" />
<el-table-column prop="zzcj" label="最终成绩" min-width="90" align="center" />
<el-table-column prop="bkcj1" label="补考1" min-width="80" align="center" />
<el-table-column prop="bkcj2" label="补考2" min-width="80" align="center" />
<el-table-column prop="bkcj3" label="补考3" min-width="80" align="center" />
<el-table-column prop="ksqk" label="考试情况" min-width="90" align="center" />
<el-table-column prop="nd" label="年度" min-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 {
listStudentGrades,
listStudentProcessGrades,
exportStudentGrades,
exportStudentProcessGrades
} from "@/api/studentRecords/studentRecords"
import { listKb } from "@/api/teachOffice/kb"
import { listTeam } from "@/api/studentRecords/team"
export default {
name: 'ScoreIndex',
data() {
return {
// ==================== 查询条件 ====================
queryForm: {
xh: '',
nd: '',
kcbh: '',
xydbh: ''
},
// ==================== 下拉选项 ====================
kbOptions: [],
teamOptions: [],
// ==================== 数据表格 ====================
// 数据来源:grades 课程成绩 / process 课程过程成绩
activeTab: 'grades',
loading: false,
gradesData: [],
processGradesData: [],
pagination: { pageNum: 1, pageSize: 20, total: 0 },
// ==================== 导出 ====================
exportLoading: false
}
},
watch: {
activeTab() {
this.handleSearch()
}
},
computed: {
/** 学员角色(后端角色键 STUDENT)隐藏学号/班次查询,仅查看本人成绩 */
isStudentRole() {
const roles = this.$store.getters.roles
return Array.isArray(roles) && roles.includes('STUDENT')
}
},
mounted() {
this.loadKbOptions()
this.loadTeamOptions()
this.loadData()
},
methods: {
/** 格式化考试结果:1 已通过,0 不通过 */
formatExamResult(row, column, cellValue) {
if (cellValue === 1 || cellValue === '1') return '已通过'
if (cellValue === 0 || cellValue === '0') return '不通过'
return ''
},
/** 加载课程名称下拉选项 */
loadKbOptions() {
listKb({ pageNum: 1, pageSize: 1000 }).then(res => {
const data = res.data || {}
this.kbOptions = data.records || []
}).catch(() => {
this.kbOptions = []
})
},
/** 加载班次下拉选项 */
loadTeamOptions() {
listTeam({ pageNum: 1, pageSize: 1000 }).then(res => {
const data = res.data || {}
this.teamOptions = data.records || []
}).catch(() => {
this.teamOptions = []
})
},
/** 组装查询参数,仅传非空值 */
buildQueryParams(params) {
const xh = this.queryForm.xh && this.queryForm.xh.trim()
const nd = this.queryForm.nd && this.queryForm.nd.trim()
const kcbh = this.queryForm.kcbh && this.queryForm.kcbh.trim()
const xydbh = this.queryForm.xydbh && this.queryForm.xydbh.trim()
if (xh) params.xh = xh
if (nd) params.nd = nd
if (kcbh) params.kcbh = kcbh
if (xydbh) params.xydbh = xydbh
},
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)
},
/** 构建导出查询参数 */
buildExportQuery() {
const query = {}
this.buildQueryParams(query)
return query
},
/** 导出课程成绩 Excel */
handleExportGrades() {
const query = this.buildExportQuery()
this.exportLoading = true
exportStudentGrades(query).then(res => {
this.downloadBlob(res, `课程成绩_${Date.now()}.xls`)
this.$message.success('课程成绩导出成功')
}).catch(() => { }).finally(() => {
this.exportLoading = false
})
},
/** 导出课程过程成绩 Excel */
handleExportProcessGrades() {
const query = this.buildExportQuery()
this.exportLoading = true
exportStudentProcessGrades(query).then(res => {
this.downloadBlob(res, `课程过程成绩_${Date.now()}.xls`)
this.$message.success('课程过程成绩导出成功')
}).catch(() => { }).finally(() => {
this.exportLoading = false
})
}
}
}
</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>
@@ -0,0 +1,871 @@
<template>
<div class="app-container shift-team-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.xydmc" 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.nj" 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.zydh" 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.xydlx" placeholder="请选择学员队类型" clearable filterable class="w-full">
<el-option
v-for="item in teamTypeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</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.rwlb" 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.xslx" placeholder="请选择虚实类型" clearable class="w-full">
<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. 工具栏:新增 / 导入 / 导出 ==================== -->
<div class="toolbar">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增学员队</el-button>
<el-button icon="el-icon-download" @click="handleExport">导出 Excel</el-button>
<el-button icon="el-icon-download" @click="handleDownloadTemplate">模板下载</el-button>
<div class="file-input">
<input ref="fileInputRef" type="file" accept=".xls,.xlsx" style="display: none" @change="handleFileChange" />
<el-button icon="el-icon-folder-opened" @click="handleChooseFile">选择文件</el-button>
<span class="file-name">{{ fileName }}</span>
<el-button type="primary" icon="el-icon-upload2" :loading="uploading" @click="handleUpload">上传数据</el-button>
</div>
</div>
<!-- ==================== 3. 列表 ==================== -->
<el-card shadow="never" class="table-card">
<div class="table-header">
<span class="table-title">教学班次列表:</span>
</div>
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row>
<el-table-column prop="xydbh" label="学员队编号" min-width="120" show-overflow-tooltip />
<el-table-column prop="xydmc" label="学员队名称" min-width="130" show-overflow-tooltip />
<el-table-column prop="nj" label="年级" width="90" align="center" />
<el-table-column prop="zydh" label="专业代号" min-width="110" show-overflow-tooltip />
<el-table-column prop="rwlb" label="任务类别" width="100" align="center" />
<el-table-column label="虚实类型" width="90" align="center">
<template slot-scope="{ row }">
<el-tag :type="Number(row.xslx) === 1 ? 'success' : 'info'" size="mini">
{{ Number(row.xslx) === 1 ? '是' : '否' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="在校状态" width="90" align="center">
<template slot-scope="{ row }">
<el-tag :type="Number(row.zxzt) === 1 ? 'success' : 'danger'" size="mini">
{{ Number(row.zxzt) === 1 ? '在校' : '毕业' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="xydrs" label="人数" width="80" align="center" />
<el-table-column label="入学日期" width="110" align="center">
<template slot-scope="{ row }">{{ formatDate(row.rxrq) }}</template>
</el-table-column>
<el-table-column label="毕业日期" width="110" align="center">
<template slot-scope="{ row }">{{ formatDate(row.byrq) }}</template>
</el-table-column>
<el-table-column label="操作" width="190" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" icon="el-icon-view" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(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>
<!-- ==================== 4. 新增/编辑对话框 ==================== -->
<el-dialog
:visible="formDialogVisible"
:title="dialogTitle"
width="760px"
:close-on-click-modal="false"
@update:visible="val => formDialogVisible = val"
>
<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="xydbh">
<el-input v-model="form.xydbh" placeholder="请输入学员队编号" :disabled="!isAdd" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员队名称" prop="xydmc">
<el-input v-model="form.xydmc" placeholder="请输入学员队名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员队人数" prop="xydrs">
<el-input-number v-model="form.xydrs" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="年级">
<el-input v-model="form.nj" placeholder="请输入年级" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业代号" prop="zydh">
<el-select
v-model="form.zydh"
:loading="majorOptionsLoading"
placeholder="请选择专业"
clearable
filterable
class="w-full"
>
<el-option
v-for="item in majorOptions"
:key="item.zydh"
:label="formatMajorLabel(item)"
:value="item.zydh"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业教室编号">
<el-input v-model="form.zyjsbh" placeholder="请输入专业教室编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员队类型" prop="xydlx">
<el-select v-model="form.xydlx" placeholder="请选择学员队类型" filterable class="w-full">
<el-option
v-for="item in teamTypeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="节次类别" prop="jclb">
<el-select v-model="form.jclb" placeholder="请选择节次类别" filterable class="w-full">
<el-option
v-for="item in sessionCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="系统模式" prop="xtms">
<el-select v-model="form.xtms" placeholder="请选择系统模式" filterable class="w-full">
<el-option
v-for="item in systemModeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="简称">
<el-input v-model="form.jc" placeholder="请输入简称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="所属单位">
<el-select v-model="form.ssdw" placeholder="请选择所属单位" clearable filterable class="w-full">
<el-option
v-for="item in unitCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</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="任务类别" prop="rwlb">
<el-input v-model="form.rwlb" placeholder="请输入任务类别" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="虚实类型" prop="xslx">
<el-select v-model="form.xslx" class="w-full">
<el-option label="否" :value="0" />
<el-option label="是" :value="1" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="主体培训任务" prop="ztpxrw">
<el-select v-model="form.ztpxrw" class="w-full" @change="handlePrimaryTrainingTaskChange">
<el-option label="是" :value="1" />
<el-option label="否" :value="0" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训任务标识号">
<el-select
v-model="form.pxrwbsh"
:loading="trainingTaskLoading"
placeholder="请选择培训任务"
clearable
filterable
class="w-full"
>
<el-option
v-for="item in trainingTaskOptions"
:key="item.bsh"
:label="formatTrainingTaskLabel(item)"
:value="item.bsh"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="在校状态">
<el-select v-model="form.zxzt" placeholder="请选择在校状态" clearable class="w-full">
<el-option label="在校" :value="1" />
<el-option label="毕业" :value="0" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="入学日期" prop="rxrq">
<el-date-picker v-model="form.rxrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择入学日期" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="毕业日期" prop="byrq">
<el-date-picker v-model="form.byrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择毕业日期" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注">
<el-input v-model="form.bz" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="formDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="formSaving" @click="handleFormSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 5. 详情对话框 ==================== -->
<el-dialog title="学员队详情" :visible="detailDialogVisible" width="720px" :close-on-click-modal="false"
@update:visible="val => detailDialogVisible = val">
<div v-loading="detailLoading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="学员队编号">{{ detailForm.xydbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员队名称">{{ detailForm.xydmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员队人数">{{ fmtValue(detailForm.xydrs) }}</el-descriptions-item>
<el-descriptions-item label="年级">{{ detailForm.nj || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业代号">{{ detailForm.zydh || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业教室编号">{{ detailForm.zyjsbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员队类型">{{ detailForm.xydlx || '-' }}</el-descriptions-item>
<el-descriptions-item label="节次类别">{{ detailForm.jclb || '-' }}</el-descriptions-item>
<el-descriptions-item label="系统模式">{{ detailForm.xtms || '-' }}</el-descriptions-item>
<el-descriptions-item label="简称">{{ detailForm.jc || '-' }}</el-descriptions-item>
<el-descriptions-item label="所属单位">{{ detailForm.ssdw || '-' }}</el-descriptions-item>
<el-descriptions-item label="任务类别">{{ detailForm.rwlb || '-' }}</el-descriptions-item>
<el-descriptions-item label="虚实类型">
<el-tag :type="Number(detailForm.xslx) === 1 ? 'success' : 'info'" size="mini">
{{ Number(detailForm.xslx) === 1 ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="主体培训任务">
<el-tag :type="Number(detailForm.ztpxrw) === 1 ? 'success' : 'info'" size="mini">
{{ Number(detailForm.ztpxrw) === 1 ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="培训任务标识号">{{ detailForm.pxrwbsh || '-' }}</el-descriptions-item>
<el-descriptions-item label="在校状态">
<el-tag :type="Number(detailForm.zxzt) === 1 ? 'success' : 'danger'" size="mini">
{{ Number(detailForm.zxzt) === 1 ? '在校' : '毕业' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="入学日期">{{ detailForm.rxrq || '-' }}</el-descriptions-item>
<el-descriptions-item label="毕业日期">{{ detailForm.byrq || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ detailForm.bz || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import {
listTeam,
getTeam,
addTeam,
updateTeam,
delTeam,
listTrainingTasks,
importTeam,
exportTeam,
downloadTeamTemplate
} from '@/api/studentRecords/team'
import { getDicts } from '@/api/system/dict/data'
import { listMajor } from '@/api/subjectMajor/major'
const TEAM_TYPE_DICT_CODE = 'stu_type'
const SESSION_CATEGORY_DICT_CODE = 'session_category'
const SYSTEM_MODE_DICT_CODE = 'system_mode'
const UNIT_CATEGORY_DICT_CODE = 'sys_unit_category'
const MAJOR_OPTION_PAGE_SIZE = 10000
export default {
name: 'ShiftTeamIndex',
data() {
return {
// ==================== 查询条件 ====================
searchForm: {
xydmc: '',
nj: '',
zydh: '',
xydlx: '',
rwlb: '',
xslx: undefined
},
teamTypeOptions: [],
sessionCategoryOptions: [],
systemModeOptions: [],
unitCategoryOptions: [],
majorOptions: [],
majorOptionsLoading: false,
trainingTaskOptions: [],
trainingTaskLoading: false,
// ==================== 文件导入 ====================
selectedFile: null,
uploading: false,
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// ==================== 新增/编辑 ====================
formDialogVisible: false,
dialogTitle: '新增学员队',
isAdd: true,
formSaving: false,
form: this.createEmptyForm(),
formRules: {
xydbh: [{ required: true, message: '请输入学员队编号', trigger: 'blur' }],
xydmc: [{ required: true, message: '请输入学员队名称', trigger: 'blur' }],
xydrs: [{ required: true, message: '请输入学员队人数', trigger: 'change' }],
zydh: [{ required: true, message: '请选择专业', trigger: 'change' }],
rwlb: [{ required: true, message: '请输入任务类别', trigger: 'blur' }],
xslx: [{ required: true, message: '请选择虚实类型', trigger: 'change' }],
rxrq: [{ required: true, message: '请选择入学日期', trigger: 'change' }],
byrq: [{ required: true, message: '请选择毕业日期', trigger: 'change' }],
xydlx: [{ required: true, message: '请选择学员队类型', trigger: 'change' }],
jclb: [{ required: true, message: '请选择节次类别', trigger: 'change' }],
xtms: [{ required: true, message: '请选择系统模式', trigger: 'change' }],
ztpxrw: [{ required: true, message: '请选择主体培训任务', trigger: 'change' }]
},
// ==================== 详情 ====================
detailDialogVisible: false,
detailLoading: false,
detailForm: {}
}
},
computed: {
fileName() {
return (this.selectedFile && this.selectedFile.name) || '未选择任何文件'
}
},
mounted() {
this.loadTeamDictionaries()
this.loadMajorOptions()
this.fetchList()
},
methods: {
/** 加载学员队相关字典。 */
async loadTeamDictionaries() {
const emptyResponse = { data: [] }
const [teamTypeResponse, sessionCategoryResponse, systemModeResponse, unitCategoryResponse] = await Promise.all([
getDicts(TEAM_TYPE_DICT_CODE).catch(() => emptyResponse),
getDicts(SESSION_CATEGORY_DICT_CODE).catch(() => emptyResponse),
getDicts(SYSTEM_MODE_DICT_CODE).catch(() => emptyResponse),
getDicts(UNIT_CATEGORY_DICT_CODE).catch(() => emptyResponse)
])
this.teamTypeOptions = teamTypeResponse.data || []
this.sessionCategoryOptions = sessionCategoryResponse.data || []
this.systemModeOptions = systemModeResponse.data || []
this.unitCategoryOptions = unitCategoryResponse.data || []
},
/** 加载专业下拉选项,标签同时包含名称、代码和代号,便于直接模糊搜索。 */
async loadMajorOptions() {
this.majorOptionsLoading = true
try {
const response = await listMajor({
pageNum: 1,
pageSize: MAJOR_OPTION_PAGE_SIZE,
ty: false
})
const data = response.data || {}
this.majorOptions = Array.isArray(data.records) ? data.records : []
} catch (error) {
this.majorOptions = []
} finally {
this.majorOptionsLoading = false
}
},
formatMajorLabel(item) {
const identifiers = [item.zydm, item.zydh].filter(Boolean).join(' / ')
if (!item.zymc) {
return identifiers
}
return identifiers ? `${item.zymc}(${identifiers})` : item.zymc
},
createEmptyForm() {
return {
xydbh: '',
xydmc: '',
xydrs: undefined,
nj: '',
zydh: '',
zyjsbh: '',
bz: '',
zxzt: undefined,
rwlb: '',
xslx: 1,
rxrq: '',
byrq: '',
xydlx: '',
pxrwbsh: '',
jclb: '',
xtms: '',
jsonzd: '',
jc: '',
ssdw: '',
ztpxrw: 1
}
},
// ==================== 日期/数值展示 ====================
formatDate(val) {
if (!val) return ''
return String(val).substring(0, 10)
},
fmtValue(val) {
return val === null || val === undefined || val === '' ? '-' : val
},
normalizeSchoolStatus(value) {
if (value === 1 || value === '1' || value === '在校') {
return 1
}
if (value === 0 || value === '0' || value === '毕业') {
return 0
}
return undefined
},
/** 构建查询条件(不含分页),供列表查询与导出共用 */
buildQuery() {
const params = {}
;['xydmc', 'nj', 'zydh', 'xydlx', 'rwlb'].forEach(key => {
const value = this.searchForm[key]
if (value !== '' && value !== null && value !== undefined) {
params[key] = String(value).trim()
}
})
if (this.searchForm.xslx !== undefined && this.searchForm.xslx !== '' && this.searchForm.xslx !== null) {
params.xslx = this.searchForm.xslx
}
return params
},
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize,
...this.buildQuery()
}
listTeam(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.$refs.searchFormRef.resetFields()
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.dialogTitle = '新增学员队'
this.form = this.createEmptyForm()
this.loadTrainingTaskOptions(this.form.ztpxrw)
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleEdit(row) {
this.isAdd = false
this.dialogTitle = '编辑学员队'
this.form = this.createEmptyForm()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
getTeam(row.xydbh).then(response => {
const d = response.data || {}
this.form = {
xydbh: d.xydbh || '',
xydmc: d.xydmc || '',
xydrs: d.xydrs !== null && d.xydrs !== undefined ? d.xydrs : undefined,
nj: d.nj || '',
zydh: d.zydh || '',
zyjsbh: d.zyjsbh || '',
bz: d.bz || '',
zxzt: this.normalizeSchoolStatus(d.zxzt),
rwlb: d.rwlb || '',
xslx: d.xslx !== null && d.xslx !== undefined ? Number(d.xslx) : 1,
rxrq: this.formatDate(d.rxrq),
byrq: this.formatDate(d.byrq),
xydlx: d.xydlx || '',
pxrwbsh: d.pxrwbsh || '',
jclb: d.jclb || '',
xtms: d.xtms || '',
jsonzd: d.jsonzd || '',
jc: d.jc || '',
ssdw: d.ssdw || '',
ztpxrw: d.ztpxrw !== null && d.ztpxrw !== undefined ? Number(d.ztpxrw) : 1
}
this.loadTrainingTaskOptions(this.form.ztpxrw)
}).catch(() => {})
},
/** 按主体培训任务标志加载后端培训任务选项。 */
async loadTrainingTaskOptions(ztpxrw) {
this.trainingTaskLoading = true
try {
const response = await listTrainingTasks(ztpxrw)
this.trainingTaskOptions = Array.isArray(response.data) ? response.data : []
} catch (error) {
this.trainingTaskOptions = []
} finally {
this.trainingTaskLoading = false
}
},
handlePrimaryTrainingTaskChange(ztpxrw) {
this.form.pxrwbsh = ''
this.loadTrainingTaskOptions(ztpxrw)
},
formatTrainingTaskLabel(item) {
if (!item.mc) {
return item.bsh
}
return `${item.mc}(${item.bsh})`
},
buildPayload() {
const f = this.form
const payload = {
xydbh: f.xydbh,
xydmc: f.xydmc,
zydh: f.zydh,
rwlb: f.rwlb,
xydlx: f.xydlx,
jclb: f.jclb,
xtms: f.xtms,
xslx: Number(f.xslx),
ztpxrw: Number(f.ztpxrw)
}
// 数值字段
if (f.xydrs !== '' && f.xydrs !== null && f.xydrs !== undefined) payload.xydrs = Number(f.xydrs)
// 字符串字段
if (f.zxzt !== '' && f.zxzt !== null && f.zxzt !== undefined) payload.zxzt = String(f.zxzt)
// 后端字段为 LocalDateTime,日期选择器值统一补齐当天零点。
if (f.rxrq) payload.rxrq = `${this.formatDate(f.rxrq)}T00:00:00`
if (f.byrq) payload.byrq = `${this.formatDate(f.byrq)}T00:00:00`
// 其余文本字段非空才传
;['nj', 'zyjsbh', 'pxrwbsh', 'jsonzd', 'jc', 'ssdw', 'bz'].forEach(key => {
if (f[key] !== '' && f[key] !== null && f[key] !== undefined) {
payload[key] = String(f[key]).trim()
}
})
return payload
},
handleFormSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) return
this.formSaving = true
const payload = this.buildPayload()
const request = this.isAdd ? addTeam(payload) : updateTeam(payload)
request.then(() => {
this.$message.success(this.isAdd ? '新增成功' : '修改成功')
this.formDialogVisible = false
this.fetchList()
}).catch(() => {
}).finally(() => {
this.formSaving = false
})
})
},
// ==================== 删除 ====================
handleDelete(row) {
this.$confirm(`确定要删除「${row.xydmc || row.xydbh}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return delTeam(row.xydbh)
}).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
// ==================== 详情 ====================
handleDetail(row) {
this.detailDialogVisible = true
this.detailLoading = true
this.detailForm = {}
getTeam(row.xydbh).then(response => {
this.detailForm = response.data || {}
this.detailLoading = false
}).catch(() => {
this.detailLoading = false
})
},
// ==================== 导出 ====================
handleExport() {
exportTeam(this.buildQuery()).then(blob => {
saveAs(blob, '班次(学员队)管理.xlsx')
this.$message.success('导出成功')
}).catch(() => {})
},
// ==================== 模板下载 / 导入 ====================
handleDownloadTemplate() {
downloadTeamTemplate().then(blob => {
saveAs(blob, '学员队导入模板.xlsx')
this.$message.success('模板下载成功')
}).catch(() => {})
},
handleChooseFile() {
this.$refs.fileInputRef && this.$refs.fileInputRef.click()
},
handleFileChange(e) {
const input = e.target
this.selectedFile = (input.files && input.files[0]) || null
},
handleUpload() {
if (!this.selectedFile) {
this.$message.warning('请先选择文件')
return
}
this.uploading = true
importTeam(this.selectedFile).then(res => {
const count = res && res.data
if (count !== null && count !== undefined) {
this.$message.success(`导入成功,共 ${count} 条记录`)
} else {
this.$message.success((res && res.msg) || '导入成功')
}
this.selectedFile = null
this.$refs.fileInputRef && (this.$refs.fileInputRef.value = '')
this.pageNum = 1
this.fetchList()
}).catch(() => {}).finally(() => {
this.uploading = false
})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.shift-team-page {
.w-full {
width: 100%;
}
.search-card {
margin-bottom: 16px;
.search-form {
.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;
}
}
}
.toolbar {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
margin-bottom: 16px;
.file-input {
display: flex;
align-items: center;
gap: 8px;
.file-name {
font-size: 12px;
color: #909399;
max-width: 180px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.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;
}
}
.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;
}
}
.text-danger {
color: #f56c6c;
padding: 0;
}
}
</style>
@@ -0,0 +1,730 @@
<template>
<div class="app-container status-change-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="12" :xl="12">
<el-form-item label="编号">
<el-input v-model="searchForm.bh" placeholder="请输入编号" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="学员编号">
<el-input v-model="searchForm.xybh" placeholder="请输入学员编号" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="申请类型">
<el-select v-model="searchForm.sqlx" placeholder="请选择申请类型" clearable class="w-full">
<el-option v-for="item in applyTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="状态">
<el-select v-model="searchForm.zt" placeholder="请选择状态" clearable class="w-full">
<el-option v-for="(item, key) in statusMap" :key="key" :label="item.label" :value="Number(key)" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" class="search-actions">
<div class="search-buttons">
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button @click="handleReset">重置</el-button>
</div>
</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>
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增学籍异动申请</el-button>
</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="编号" min-width="140" show-overflow-tooltip />
<el-table-column prop="xybh" label="学员编号" min-width="120" show-overflow-tooltip />
<el-table-column prop="sqlx" label="申请类型" width="100" align="center" />
<el-table-column prop="sy" label="事由" min-width="140" show-overflow-tooltip />
<el-table-column prop="bz" label="备注" min-width="140" show-overflow-tooltip />
<el-table-column label="状态" width="90" align="center">
<template slot-scope="{ row }">
<el-tag :type="statusTagType(row.zt)" size="mini" effect="light">{{ statusLabel(row.zt) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="提交时间" width="160" align="center">
<template slot-scope="{ row }">{{ row.tjsj ? fmtDateTime(row.tjsj) : '-' }}</template>
</el-table-column>
<el-table-column label="创建时间" width="160" align="center">
<template slot-scope="{ row }">{{ row.cjsj ? fmtDateTime(row.cjsj) : '-' }}</template>
</el-table-column>
<el-table-column label="修改时间" width="160" align="center">
<template slot-scope="{ row }">{{ row.xgsj ? fmtDateTime(row.xgsj) : '-' }}</template>
</el-table-column>
<el-table-column label="操作" width="230" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button
v-if="!row.tjsj"
type="text"
size="small"
icon="el-icon-upload2"
@click="handleSubmit(row)"
>提交</el-button>
<el-button v-else type="text" size="small" icon="el-icon-check" disabled>已提交</el-button>
<el-button type="text" size="small" icon="el-icon-view" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-empty v-if="!loading && tableData.length === 0" description="暂无学籍异动申请数据" :image-size="60" />
<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
:visible="formDialogVisible"
:title="dialogTitle"
width="600px"
:close-on-click-modal="false"
@update:visible="val => formDialogVisible = val"
>
<el-form ref="formRef" :model="form" :rules="formRules" label-width="110px" class="add-form">
<el-form-item label="学号" prop="xh">
<el-input
ref="studentNoInput"
v-model.trim="form.xh"
placeholder="请输入学号"
:disabled="studentVerifying"
@input="handleStudentNoInput"
@change="handleStudentNoComplete"
/>
<div v-if="isStudentVerified" class="student-verified-tip">
<i class="el-icon-circle-check" />
已核验:{{ verifiedStudent.xm || verifiedStudent.xh || form.xh }}
</div>
</el-form-item>
<el-form-item label="申请类型" prop="sqlx">
<el-select v-model="form.sqlx" placeholder="请选择申请类型" class="w-full">
<el-option v-for="item in applyTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="事由" prop="sy">
<el-input v-model="form.sy" type="textarea" :rows="3" placeholder="请输入事由" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.bz" type="textarea" :rows="3" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="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="studentConfirmVisible"
width="560px"
append-to-body
:close-on-click-modal="false"
@update:visible="val => studentConfirmVisible = val"
>
<el-alert
title="请核对以下信息,确认无误后再提交申请。"
type="info"
:closable="false"
show-icon
class="student-confirm-alert"
/>
<el-descriptions :column="2" border>
<el-descriptions-item label="学号">{{ pendingStudent.xh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员编号">{{ pendingStudent.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="姓名">{{ pendingStudent.xm || '-' }}</el-descriptions-item>
<el-descriptions-item label="性别">{{ studentSexLabel(pendingStudent.xb) }}</el-descriptions-item>
<el-descriptions-item label="学员队期编号">{{ pendingStudent.xydqbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="当前班次编号">{{ pendingStudent.dqbzbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员类别">{{ pendingStudent.xylb || '-' }}</el-descriptions-item>
<el-descriptions-item label="政治面貌">{{ pendingStudent.zzmm || '-' }}</el-descriptions-item>
</el-descriptions>
<div slot="footer">
<el-button @click="handleStudentReenter">重新输入</el-button>
<el-button type="primary" @click="handleStudentConfirm">确认无误</el-button>
</div>
</el-dialog>
<!-- ==================== 5. 详情对话框 ==================== -->
<el-dialog title="学籍异动申请详情" :visible="detailDialogVisible" width="760px" :close-on-click-modal="false"
@update:visible="val => detailDialogVisible = val">
<div v-loading="detailLoading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="编号">{{ detailForm.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员编号">{{ detailForm.xybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="申请类型">{{ detailForm.sqlx || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag :type="statusTagType(detailForm.zt)" size="mini">{{ statusLabel(detailForm.zt) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="事由" :span="2">{{ detailForm.sy || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ detailForm.bz || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detailForm.cjsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="修改时间">{{ detailForm.xgsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="提交时间">{{ detailForm.tjsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员队审核意见">{{ detailForm.xydshyj || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员队干部编号">{{ detailForm.xydgbbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员队干部审核时间">{{ detailForm.xydshsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="管理员账户编号">{{ detailForm.glyzhbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="管理员审核意见">{{ detailForm.glyshyj || '-' }}</el-descriptions-item>
<el-descriptions-item label="管理员审核时间">{{ detailForm.glyshsj || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listApplication,
getApplication,
addApplication,
updateApplication,
delApplication
} from '@/api/studentRecords/application'
import { getStudentRecord, listStudentRecord } from '@/api/studentRecords/studentRecords'
export default {
name: 'StatusChangeIndex',
computed: {
isStudentVerified() {
const studentNo = this.normalizeStudentNo(this.form.xh)
return Boolean(
studentNo &&
studentNo === this.verifiedStudentNo &&
this.form.xybh === this.verifiedStudent.bh
)
}
},
data() {
return {
// ==================== 申请类型选项(学籍异动) ====================
applyTypeOptions: ['休学', '复学', '退学', '转学', '留级', '转专业'],
// ==================== 状态映射:0-待审核 1-已审核 2-驳回等 ====================
statusMap: {
0: { label: '待审核', type: 'warning' },
1: { label: '已审核', type: 'success' },
2: { label: '驳回', type: 'danger' }
},
// ==================== 查询条件 ====================
searchForm: {
bh: '',
xybh: '',
sqlx: '',
zt: undefined
},
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// ==================== 新增/编辑 ====================
formDialogVisible: false,
dialogTitle: '新增学籍异动申请',
isAdd: true,
formSaving: false,
studentVerifying: false,
studentConfirmVisible: false,
pendingStudent: {},
verifiedStudent: {},
verifiedStudentNo: '',
form: this.createEmptyForm(),
formRules: {
xh: [
{ required: true, message: '请输入学号', trigger: 'blur' },
{ max: 50, message: '学号不能超过50个字符', trigger: 'blur' },
{ pattern: /^[A-Za-z0-9]+$/, message: '学号只能包含字母和数字', trigger: 'blur' }
],
sqlx: [{ required: true, message: '请选择申请类型', trigger: 'change' }],
sy: [{ required: true, message: '请输入事由', trigger: 'blur' }]
},
// ==================== 详情 ====================
detailDialogVisible: false,
detailLoading: false,
detailForm: {}
}
},
mounted() {
this.fetchList()
},
methods: {
createEmptyForm() {
return {
bh: '',
xh: '',
xybh: '',
sqlx: '',
sy: '',
bz: '',
zt: 0
}
},
// ==================== 状态展示 ====================
// 统一格式化后端 LocalDateTime(去除 T、截断到秒)
fmtDateTime(val) {
if (val === null || val === undefined || val === '') return ''
return String(val).replace('T', ' ').slice(0, 19)
},
statusLabel(zt) {
const item = this.statusMap[zt]
return item ? item.label : (zt !== null && zt !== undefined ? String(zt) : '-')
},
statusTagType(zt) {
const item = this.statusMap[zt]
return item ? item.type : 'info'
},
studentSexLabel(value) {
if (value === '' || value === null || value === undefined) {
return '-'
}
if (String(value) === '1') {
return '男'
}
if (String(value) === '0') {
return '女'
}
return String(value)
},
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
// 等值筛选,留空不传
;['bh', 'xybh', 'sqlx'].forEach(key => {
const value = this.searchForm[key]
if (value !== '' && value !== null && value !== undefined) {
params[key] = String(value).trim()
}
})
if (this.searchForm.zt !== undefined && this.searchForm.zt !== '' && this.searchForm.zt !== null) {
params.zt = this.searchForm.zt
}
listApplication(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.$refs.searchFormRef.resetFields()
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.dialogTitle = '新增学籍异动申请'
this.form = this.createEmptyForm()
this.resetStudentVerification()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleEdit(row) {
this.isAdd = false
this.dialogTitle = '编辑学籍异动申请'
this.form = this.createEmptyForm()
this.resetStudentVerification()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
getApplication(row.bh).then(response => {
const data = response.data || {}
this.form = {
bh: data.bh || '',
xh: '',
xybh: data.xybh || '',
sqlx: data.sqlx || '',
sy: data.sy || '',
bz: data.bz || '',
zt: data.zt !== null && data.zt !== undefined ? Number(data.zt) : 0
}
this.loadExistingStudent(data.xybh)
}).catch(() => {})
},
normalizeStudentNo(value) {
return value === null || value === undefined ? '' : String(value).trim()
},
resetStudentVerification() {
this.studentVerifying = false
this.studentConfirmVisible = false
this.pendingStudent = {}
this.verifiedStudent = {}
this.verifiedStudentNo = ''
},
handleStudentNoInput() {
const studentNo = this.normalizeStudentNo(this.form.xh)
if (studentNo !== this.verifiedStudentNo) {
this.verifiedStudent = {}
this.verifiedStudentNo = ''
this.form.xybh = ''
}
this.pendingStudent = {}
},
handleStudentNoComplete() {
if (this.normalizeStudentNo(this.form.xh)) {
this.loadStudentForConfirmation()
}
},
async loadStudentForConfirmation() {
if (this.studentVerifying) {
return false
}
const studentNo = this.normalizeStudentNo(this.form.xh)
if (!studentNo) {
this.$refs.formRef && this.$refs.formRef.validateField('xh')
return false
}
if (studentNo === this.verifiedStudentNo && this.verifiedStudent.bh) {
this.pendingStudent = { ...this.verifiedStudent }
this.studentConfirmVisible = true
return true
}
this.studentVerifying = true
try {
const response = await listStudentRecord({ pageNum: 1, pageSize: 2, xh: studentNo })
const records = response.data && Array.isArray(response.data.records) ? response.data.records : []
// 请求返回前用户可能已经修改了学号,旧结果不能覆盖当前输入。
if (studentNo !== this.normalizeStudentNo(this.form.xh)) {
return false
}
if (records.length === 0) {
this.$message.warning('未查询到该学号对应的学员,请核对学号')
this.resetStudentVerification()
return false
}
if (records.length > 1) {
this.$message.warning('该学号匹配到多名学员,请联系管理员检查学员数据')
this.resetStudentVerification()
return false
}
this.pendingStudent = records[0]
this.studentConfirmVisible = true
return true
} catch (error) {
if (studentNo === this.normalizeStudentNo(this.form.xh)) {
this.resetStudentVerification()
}
return false
} finally {
this.studentVerifying = false
}
},
handleStudentConfirm() {
const studentNo = this.normalizeStudentNo(this.form.xh)
if (!this.pendingStudent.bh || this.normalizeStudentNo(this.pendingStudent.xh) !== studentNo) {
this.$message.warning('学号已变化,请重新核验')
this.studentConfirmVisible = false
return
}
this.verifiedStudent = { ...this.pendingStudent }
this.verifiedStudentNo = studentNo
this.form.xybh = this.pendingStudent.bh
this.studentConfirmVisible = false
this.$refs.formRef && this.$refs.formRef.clearValidate('xh')
this.$message.success('学员信息核验成功')
},
handleStudentReenter() {
this.studentConfirmVisible = false
this.pendingStudent = {}
this.verifiedStudent = {}
this.verifiedStudentNo = ''
this.form.xybh = ''
this.$nextTick(() => {
const input = this.$refs.studentNoInput
input && input.focus()
})
},
async loadExistingStudent(studentId) {
const normalizedStudentId = this.normalizeStudentNo(studentId)
if (!normalizedStudentId) {
return
}
this.studentVerifying = true
try {
const response = await getStudentRecord(normalizedStudentId)
const student = response.data || {}
if (this.form.xybh !== normalizedStudentId || !student.bh) {
return
}
this.form.xh = student.xh || ''
this.verifiedStudentNo = this.normalizeStudentNo(student.xh)
this.verifiedStudent = student
} catch (error) {
this.$message.warning('未能加载原申请的学员信息,请重新输入学号核验')
} finally {
this.studentVerifying = false
}
},
buildPayload() {
const f = this.form
const payload = {
xybh: f.xybh,
sqlx: f.sqlx,
sy: f.sy
}
// 新增编号和状态由后端生成;编辑时仅回传记录定位编号和原状态。
if (!this.isAdd) {
payload.bh = f.bh
if (f.zt !== null && f.zt !== undefined && f.zt !== '') {
payload.zt = Number(f.zt)
}
}
// 备注留空则移除
if (f.bz !== '' && f.bz !== null && f.bz !== undefined) {
payload.bz = f.bz
}
return payload
},
async handleFormSubmit() {
const isValid = await new Promise(resolve => {
this.$refs.formRef.validate(valid => resolve(valid))
})
if (!isValid) {
return
}
if (!this.isStudentVerified) {
const isFound = await this.loadStudentForConfirmation()
if (isFound) {
this.$message.warning('请先确认学员信息,再提交申请')
}
return
}
this.formSaving = true
const payload = this.buildPayload()
const request = this.isAdd ? addApplication(payload) : updateApplication(payload)
request.then(() => {
this.$message.success(this.isAdd ? '新增成功' : '修改成功')
this.formDialogVisible = false
this.fetchList()
}).catch(() => {
}).finally(() => {
this.formSaving = false
})
},
// ==================== 提交 ====================
// 无独立提交接口,通过编辑接口写入提交时间 tjsj(zt 保持原值不变)
formatNow() {
const d = new Date()
const pad = n => String(n).padStart(2, '0')
const date = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
return `${date} ${time}`
},
handleSubmit(row) {
this.$confirm(`确定要提交编号为「${row.bh}」的学籍异动申请吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const payload = {
bh: row.bh,
xybh: row.xybh,
sqlx: row.sqlx,
sy: row.sy,
zt: row.zt !== null && row.zt !== undefined ? Number(row.zt) : 0,
tjsj: this.formatNow()
}
if (row.bz) {
payload.bz = row.bz
}
return updateApplication(payload)
}).then(() => {
this.$message.success('提交成功')
this.fetchList()
}).catch(() => {})
},
// ==================== 删除 ====================
handleDelete(row) {
this.$confirm(`确定要删除编号为「${row.bh}」的学籍异动申请吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return delApplication(row.bh)
}).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
// ==================== 详情 ====================
handleDetail(row) {
this.detailDialogVisible = true
this.detailLoading = true
this.detailForm = {}
getApplication(row.bh).then(response => {
this.detailForm = response.data || {}
this.detailLoading = false
}).catch(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.status-change-page {
.search-card {
margin-bottom: 16px;
}
.search-form {
.w-full {
width: 100%;
}
.search-actions {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 8px;
.search-tip {
font-size: 12px;
color: #909399;
}
.search-buttons {
display: flex;
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;
}
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
}
.add-form {
max-height: 60vh;
overflow-y: auto;
padding-right: 4px;
}
.student-verified-tip {
margin-top: 4px;
color: #078267;
font-size: 12px;
line-height: 20px;
i {
margin-right: 4px;
}
}
.text-danger {
color: #f56c6c;
padding: 0;
}
}
.student-confirm-alert {
margin-bottom: 16px;
}
</style>
@@ -0,0 +1,876 @@
<template>
<div class="app-container student-info-page">
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card v-if="!isStudentRole" shadow="never" class="search-card">
<el-form :model="searchForm" label-width="110px" class="search-form">
<el-row :gutter="24">
<!-- 左栏 -->
<el-col :xs="24" :md="12">
<el-form-item label="学号">
<el-input v-model="searchForm.xh" placeholder="请输入学号" clearable />
</el-form-item>
<el-form-item label="姓名">
<el-input v-model="searchForm.xm" placeholder="请输入姓名" clearable />
</el-form-item>
<el-form-item label="性别">
<el-select v-model="searchForm.xb" placeholder="请选择性别" clearable class="full-width">
<el-option label="男" value="男" />
<el-option label="女" value="女" />
</el-select>
</el-form-item>
<el-form-item label="证件号码">
<el-input v-model="searchForm.zjhm" placeholder="请输入证件号码" clearable />
</el-form-item>
<el-form-item label="政治面貌">
<el-select v-model="searchForm.zzmm" placeholder="请选择政治面貌" clearable filterable class="full-width">
<el-option
v-for="item in politicalStatusOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
<el-form-item label="民族">
<el-select v-model="searchForm.mz" placeholder="请选择民族" clearable filterable class="full-width">
<el-option
v-for="item in nationOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
<el-form-item label="籍贯">
<el-input v-model="searchForm.jg" placeholder="请输入籍贯" clearable />
</el-form-item>
<el-form-item label="学位">
<el-select v-model="searchForm.xw" placeholder="请选择学位" clearable filterable class="full-width">
<el-option
v-for="item in degreeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<!-- 右栏 -->
<el-col :xs="24" :md="12">
<el-form-item label="原部职别">
<el-input v-model="searchForm.ybzb" placeholder="请输入原部职别" clearable />
</el-form-item>
<el-form-item label="身份证号">
<el-input v-model="searchForm.sfzh" placeholder="请输入身份证号" clearable />
</el-form-item>
<el-form-item label="文化程度">
<el-select v-model="searchForm.whcd" placeholder="请选择文化程度" clearable filterable class="full-width">
<el-option
v-for="item in educationLevelOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
<el-form-item label="本科毕业院校">
<el-input v-model="searchForm.bkbyyx" placeholder="请输入本科毕业院校" clearable />
</el-form-item>
<el-form-item label="学员类别">
<el-select v-model="searchForm.xylb" placeholder="请选择学员类别" clearable filterable class="full-width">
<el-option
v-for="item in studentCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
<el-form-item label="联系电话">
<el-input v-model="searchForm.lxdh" placeholder="请输入联系电话" clearable />
</el-form-item>
<el-form-item label="通信地址">
<el-input v-model="searchForm.txdz" placeholder="请输入通信地址" clearable />
</el-form-item>
</el-col>
</el-row>
<div class="search-actions">
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
</div>
</el-form>
</el-card>
<!-- ==================== 2. 数据表格区域 ==================== -->
<el-card shadow="never" class="table-card">
<div class="list-header">
<div class="list-title">学员信息列表</div>
<el-button v-if="!isStudentRole" type="primary" icon="el-icon-plus" @click="handleAdd">新增学员</el-button>
</div>
<el-table v-loading="loading" :data="tableData" class="student-info-table" stripe border>
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="xh" label="学号" width="130" align="center" show-overflow-tooltip />
<el-table-column prop="xm" label="姓名" width="90" align="center" show-overflow-tooltip />
<el-table-column prop="xb" label="性别" width="70" align="center" />
<el-table-column prop="nj" label="年级" width="80" align="center" />
<el-table-column prop="zy" label="专业" width="160" align="center" show-overflow-tooltip />
<el-table-column prop="xylb" label="学员类别" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="bc" label="班次" width="180" align="center" show-overflow-tooltip />
<el-table-column prop="zzmm" label="政治面貌" width="110" align="center" />
<el-table-column prop="mz" label="民族" width="80" align="center" />
<el-table-column prop="jg" label="籍贯" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="xw" label="学位" width="90" align="center" />
<el-table-column prop="zczt" label="注册状态" width="110" align="center" />
<el-table-column prop="xjyd" label="学籍异动状态" width="130" align="center" />
<el-table-column prop="ksqk" label="考试情况" width="100" align="center" />
<el-table-column prop="bjgm" label="不及格门数" width="110" align="center" />
<el-table-column prop="gljg" label="管理机构" width="150" align="center" show-overflow-tooltip />
<el-table-column label="操作" width="190" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" class="text-primary" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" class="text-success" @click="handleGrades(row)">成绩</el-button>
<el-button type="text" class="danger-text" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<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>
<!-- 新增/编辑弹窗 -->
<el-dialog
:visible="dialogVisible"
:title="dialogTitle"
width="780px"
:close-on-click-modal="false"
@update:visible="val => dialogVisible = val"
>
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px">
<el-row v-if="dialogTitle !== '新增学员'" :gutter="20">
<el-col :span="12"><el-form-item label="编号" prop="bh"><el-input v-model="formData.bh" placeholder="请输入编号" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="学号" prop="xh"><el-input v-model="formData.xh" placeholder="请输入学号" /></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="姓名" prop="xm"><el-input v-model="formData.xm" placeholder="请输入姓名" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="性别" prop="xb"><el-select v-model="formData.xb" placeholder="请选择" class="full-width"><el-option label="男" value="1" /><el-option label="女" value="0" /></el-select></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="出生日期" prop="csrq"><el-date-picker v-model="formData.csrq" type="date" placeholder="请选择" value-format="yyyy-MM-dd" class="full-width" /></el-form-item></el-col>
<el-col :span="12">
<el-form-item label="民族" prop="mz">
<el-select v-model="formData.mz" placeholder="请选择民族" filterable class="full-width">
<el-option
v-for="item in nationOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="籍贯" prop="jg"><el-input v-model="formData.jg" placeholder="请输入籍贯" /></el-form-item></el-col>
<el-col :span="12">
<el-form-item label="政治面貌" prop="zzmm">
<el-select v-model="formData.zzmm" placeholder="请选择政治面貌" filterable class="full-width">
<el-option
v-for="item in politicalStatusOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="文化程度" prop="whcd">
<el-select v-model="formData.whcd" placeholder="请选择文化程度" filterable class="full-width">
<el-option
v-for="item in educationLevelOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员类别" prop="xylb">
<el-select v-model="formData.xylb" placeholder="请选择学员类别" filterable class="full-width">
<el-option
v-for="item in studentCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="学员队期编号" prop="xydqbh"><el-input v-model="formData.xydqbh" placeholder="请输入学员队期编号" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="证件号码" prop="zjhm"><el-input v-model="formData.zjhm" placeholder="请输入证件号码" /></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="所属军区" prop="ssjq"><el-input v-model="formData.ssjq" placeholder="请输入所属军区" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="当前班次编号" prop="dqbzbh"><el-input v-model="formData.dqbzbh" placeholder="请输入当前班次编号" /></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="军人证件类型" prop="jrzjlx"><el-input v-model="formData.jrzjlx" placeholder="请输入军人证件类型" /></el-form-item></el-col>
<el-col v-if="dialogTitle !== '新增学员'" :span="12"><el-form-item label="退学状态" prop="txzt"><el-input v-model="formData.txzt" placeholder="请输入退学状态" /></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="8"><el-form-item label="国防生" prop="gfs"><el-select v-model="formData.gfs" placeholder="请选择" class="full-width"><el-option label="是" value="1" /><el-option label="否" value="0" /></el-select></el-form-item></el-col>
<el-col v-if="dialogTitle !== '新增学员'" :span="8"><el-form-item label="留级状态" prop="ljzt"><el-input v-model="formData.ljzt" placeholder="请输入" /></el-form-item></el-col>
<el-col v-if="dialogTitle !== '新增学员'" :span="8"><el-form-item label="分班状态" prop="fbzt"><el-input v-model="formData.fbzt" placeholder="请输入" /></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="8"><el-form-item label="允许查看成绩" prop="yxckcj"><el-select v-model="formData.yxckcj" placeholder="请选择" class="full-width"><el-option label="是" value="1" /><el-option label="否" value="0" /></el-select></el-form-item></el-col>
<el-col :span="8"><el-form-item label="已注册" prop="yzc"><el-select v-model="formData.yzc" placeholder="请选择" class="full-width"><el-option label="是" value="1" /><el-option label="否" value="0" /></el-select></el-form-item></el-col>
<el-col :span="8" />
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="联系电话" prop="lxdh"><el-input v-model="formData.lxdh" placeholder="请输入联系电话" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="通讯地址" prop="txdz"><el-input v-model="formData.txdz" placeholder="请输入通讯地址" /></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24"><el-form-item label="备注" prop="bz"><el-input v-model="formData.bz" type="textarea" :rows="2" placeholder="请输入备注" /></el-form-item></el-col>
</el-row>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="submitting" @click="handleSubmit">确定</el-button>
</div>
</el-dialog>
<!-- 成绩弹窗 -->
<el-dialog
:visible="gradesVisible"
title="学员成绩"
width="80%"
:close-on-click-modal="false"
@update:visible="val => gradesVisible = val"
>
<div class="student-summary">
<span><strong>学员:</strong>{{ gradesStudent || '-' }}</span>
<span><strong>学号:</strong>{{ gradesStudentNo || '-' }}</span>
<div class="grades-year-filter">
<span class="filter-label">年度:</span>
<el-select v-model="gradesYear" size="small" clearable placeholder="全部年度">
<el-option
v-for="year in gradeYearOptions"
:key="year"
:label="year"
:value="year"
/>
</el-select>
</div>
</div>
<el-tabs v-model="gradesTab">
<el-tab-pane label="成绩" name="grades">
<el-table v-loading="gradesLoading" :data="filteredGradesData" stripe border max-height="420">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="nd" label="年度" width="85" align="center" />
<el-table-column prop="kmbh" label="科目编号" min-width="120" align="center" 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="qwxf" 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="100" align="center" />
<el-table-column label="考试结果" width="90" align="center">
<template slot-scope="{ row }">{{ formatPassStatus(row.ytg) }}</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="进程成绩" name="process">
<el-table v-loading="gradesLoading" :data="filteredProcessGradesData" stripe border max-height="420">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="nd" label="年度" width="85" align="center" />
<el-table-column prop="kmbh" label="科目编号" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="klx" label="课类型" width="90" align="center" />
<el-table-column prop="yscj" label="原始成绩" width="100" align="center" />
<el-table-column prop="zzcj" label="最终成绩" width="90" align="center" />
<el-table-column prop="bkcj1" label="补考成绩1" width="100" align="center" />
<el-table-column prop="bkcj2" label="补考成绩2" width="100" align="center" />
<el-table-column prop="bkcj3" label="补考成绩3" width="100" align="center" />
<el-table-column prop="bkcs" label="补考次数" width="90" align="center" />
<el-table-column prop="ksqk" label="考试情况" width="100" align="center" />
</el-table>
</el-tab-pane>
</el-tabs>
<div slot="footer">
<el-button type="primary" :loading="gradesExporting" @click="handleExportGrades">
{{ gradesTab === 'grades' ? '导出成绩' : '导出进程成绩' }}
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listStudentRecord,
getStudentRecord,
addStudentRecord,
updateStudentRecord,
delStudentRecord,
listStudentGrades,
listStudentProcessGrades,
exportStudentGrades,
exportStudentProcessGrades
} from "@/api/studentRecords/studentRecords"
import { getDicts } from '@/api/system/dict/data'
import { optionselect } from '@/api/system/dict/type'
const POLITICAL_STATUS_DICT_CODE = 'sys_political_status'
const NATION_DICT_CODE = 'nation_type'
const DEGREE_DICT_CODE = 'sys_degree_type'
const EDUCATION_LEVEL_DICT_CODE = 'sys_edu_level'
const GRADES_VIEW_DISABLED_VALUES = new Set(['0', 'false', '否', '不允许'])
const RESIDENT_IDENTITY_CARD_TYPES = new Set(['居民身份证', '身份证'])
const IDENTITY_CARD_CHECK_CODES = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
const IDENTITY_CARD_WEIGHTS = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
const PHONE_NUMBER_PATTERN = /^(1[3-9]\d{9}|0\d{2,3}-?\d{7,8})$/
function isResidentIdentityCardType(certificateType) {
return RESIDENT_IDENTITY_CARD_TYPES.has(String(certificateType || '').trim())
}
function isValidIdentityCard(identityCard) {
const normalizedValue = String(identityCard || '').trim().toUpperCase()
if (!/^\d{17}[\dX]$/.test(normalizedValue)) {
return false
}
const year = Number(normalizedValue.slice(6, 10))
const month = Number(normalizedValue.slice(10, 12))
const day = Number(normalizedValue.slice(12, 14))
const birthDate = new Date(year, month - 1, day)
const isValidDate = birthDate.getFullYear() === year &&
birthDate.getMonth() === month - 1 && birthDate.getDate() === day
if (!isValidDate || birthDate > new Date()) {
return false
}
const checksum = IDENTITY_CARD_WEIGHTS.reduce((total, weight, index) => {
return total + Number(normalizedValue[index]) * weight
}, 0)
return IDENTITY_CARD_CHECK_CODES[checksum % 11] === normalizedValue[17]
}
export default {
name: 'StudentInfoIndex',
data() {
const validateCertificateNumber = (rule, value, callback) => {
if (value && isResidentIdentityCardType(this.formData.jrzjlx) && !isValidIdentityCard(value)) {
callback(new Error('请输入合法的18位居民身份证号码'))
return
}
callback()
}
const validateBirthDate = (rule, value, callback) => {
if (value && new Date(`${value}T00:00:00`) > new Date()) {
callback(new Error('出生日期不能晚于今天'))
return
}
callback()
}
const validatePhoneNumber = (rule, value, callback) => {
if (value && !PHONE_NUMBER_PATTERN.test(String(value).trim())) {
callback(new Error('请输入正确的手机号码或固定电话号码'))
return
}
callback()
}
return {
// ==================== 查询条件 ====================
// 仅保留后端 XYXX 实体支持的字段:/student-records/list 会按实体字段动态构建查询条件
searchForm: {
xh: '', xm: '', xb: '', zjhm: '', zzmm: '', mz: '', jg: '', xw: '',
ybzb: '', sfzh: '', whcd: '', bkbyyx: '', xylb: '', lxdh: '', txdz: ''
},
politicalStatusOptions: [],
nationOptions: [],
degreeOptions: [],
educationLevelOptions: [],
studentCategoryOptions: [],
// ==================== 数据表格 ====================
loading: false,
tableData: [],
pagination: { pageNum: 1, pageSize: 20, total: 0 },
// ==================== 新增/编辑弹窗 ====================
dialogVisible: false,
dialogTitle: '新增学员',
submitting: false,
formData: this.createEmptyForm(),
formRules: {
xm: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
xydqbh: [{ required: true, message: '请输入学员队期编号', trigger: 'blur' }],
zjhm: [
{ required: true, message: '请输入证件号码', trigger: 'blur' },
{ validator: validateCertificateNumber, trigger: 'blur' }
],
zzmm: [{ required: true, message: '请选择政治面貌', trigger: 'change' }],
xb: [{ required: true, message: '请选择性别', trigger: 'change' }],
csrq: [
{ required: true, message: '请选择出生日期', trigger: 'change' },
{ validator: validateBirthDate, trigger: 'change' }
],
mz: [{ required: true, message: '请选择民族', trigger: 'change' }],
jg: [{ required: true, message: '请输入籍贯', trigger: 'blur' }],
whcd: [{ required: true, message: '请选择文化程度', trigger: 'change' }],
xylb: [{ required: true, message: '请选择学员类别', trigger: 'change' }],
ssjq: [{ required: true, message: '请输入所属军区', trigger: 'blur' }],
gfs: [{ required: true, message: '请选择国防生', trigger: 'change' }],
yxckcj: [{ required: true, message: '请选择允许查看成绩', trigger: 'change' }],
dqbzbh: [{ required: true, message: '请输入当前班次编号', trigger: 'blur' }],
yzc: [{ required: true, message: '请选择已注册', trigger: 'change' }],
jrzjlx: [{ required: true, message: '请输入军人证件类型', trigger: 'blur' }],
lxdh: [{ validator: validatePhoneNumber, trigger: 'blur' }]
},
// ==================== 成绩弹窗 ====================
gradesVisible: false,
gradesTab: 'grades',
gradesData: [],
processGradesData: [],
gradesYear: '',
gradesStudent: '',
gradesStudentNo: '',
currentBh: '',
gradesLoading: false,
gradesExporting: false
}
},
computed: {
gradeYearOptions() {
const years = [...this.gradesData, ...this.processGradesData]
.map(item => item.nd)
.filter(year => year !== '' && year !== null && year !== undefined)
.map(String)
return [...new Set(years)].sort((firstYear, secondYear) => secondYear.localeCompare(firstYear))
},
/** 学员角色(后端角色键 STUDENT)隐藏条件查询栏与新增学员按钮 */
isStudentRole() {
const roles = this.$store.getters.roles
return Array.isArray(roles) && roles.includes('STUDENT')
},
filteredGradesData() {
return this.filterGradesByYear(this.gradesData)
},
filteredProcessGradesData() {
return this.filterGradesByYear(this.processGradesData)
}
},
created() {
this.loadStudentDictionaries()
},
mounted() {
this.loadData()
},
methods: {
/** 加载学员基础信息字典,业务字段按字典标签查询和提交。 */
async loadStudentDictionaries() {
const emptyResponse = { data: [] }
const [politicalStatusResponse, nationResponse, degreeResponse, educationLevelResponse, dictTypeResponse] =
await Promise.all([
getDicts(POLITICAL_STATUS_DICT_CODE).catch(() => emptyResponse),
getDicts(NATION_DICT_CODE).catch(() => emptyResponse),
getDicts(DEGREE_DICT_CODE).catch(() => emptyResponse),
getDicts(EDUCATION_LEVEL_DICT_CODE).catch(() => emptyResponse),
optionselect().catch(() => emptyResponse)
])
this.politicalStatusOptions = politicalStatusResponse.data || []
this.nationOptions = nationResponse.data || []
this.degreeOptions = degreeResponse.data || []
this.educationLevelOptions = educationLevelResponse.data || []
this.studentCategoryOptions = await this.loadNamedDictionary(dictTypeResponse.data || [], '学员类别')
this.mergeExistingDictionaryOptions()
},
/** 根据字典名称匹配类型编码,避免业务页面硬编码数据库配置。 */
async loadNamedDictionary(dictTypes, dictName) {
const dictType = dictTypes.find(item => item.dictName === dictName) ||
dictTypes.find(item => String(item.dictName || '').includes(dictName))
if (!dictType || !dictType.dictType) {
return []
}
try {
const response = await getDicts(dictType.dictType)
return response.data || []
} catch (error) {
return []
}
},
/** 字典缺项时保留列表已有值,避免历史数据无法作为查询条件。 */
mergeExistingDictionaryOptions() {
this.politicalStatusOptions = this.mergeFieldOptions(this.politicalStatusOptions, 'zzmm')
this.nationOptions = this.mergeFieldOptions(this.nationOptions, 'mz')
this.degreeOptions = this.mergeFieldOptions(this.degreeOptions, 'xw')
this.educationLevelOptions = this.mergeFieldOptions(this.educationLevelOptions, 'whcd')
this.studentCategoryOptions = this.mergeFieldOptions(this.studentCategoryOptions, 'xylb')
},
mergeFieldOptions(dictionaryOptions, fieldName) {
const options = dictionaryOptions.slice()
const existingLabels = new Set(options.map(item => String(item.dictLabel)))
this.tableData.forEach(row => {
const value = row[fieldName]
if (value === '' || value === null || value === undefined || existingLabels.has(String(value))) {
return
}
options.push({
dictLabel: String(value),
dictValue: String(value)
})
existingLabels.add(String(value))
})
return options
},
/** 创建空白表单 */
createEmptyForm() {
return {
bh: '', xh: '', xm: '', xydqbh: '', zjhm: '', zzmm: '', xb: '', csrq: '', mz: '', jg: '',
whcd: '', xylb: '', ssjq: '', gfs: '', txzt: '', ljzt: '', fbzt: '', yxckcj: '', dqbzbh: '', yzc: '',
jrzjlx: '', sfzh: '', lxdh: '', txdz: '', bz: '', dtsj: ''
}
},
// ==================== 列表加载 ====================
loadData() {
this.loading = true
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.mergeExistingDictionaryOptions()
this.loading = false
}).catch(() => {
this.tableData = []
this.pagination.total = 0
this.loading = false
})
},
/** 组装查询参数:仅传后端 XYXX 实体支持的字符串字段,空值忽略 */
buildQueryParams(params) {
const textFields = [
'xh', 'xm', 'zjhm', 'zzmm', 'mz', 'jg', 'xw', 'ybzb', 'sfzh', 'whcd', 'bkbyyx', 'xylb', 'lxdh', 'txdz'
]
textFields.forEach(key => {
const v = this.searchForm[key]
if (v !== '' && v !== null && v !== undefined) params[key] = v.trim()
})
if (this.searchForm.xb) params.xb = this.searchForm.xb
},
// ==================== 查询/分页 ====================
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()
},
// ==================== 新增/编辑弹窗 ====================
resetForm() {
Object.assign(this.formData, this.createEmptyForm())
this.$nextTick(() => {
if (this.$refs.formRef) {
this.$refs.formRef.clearValidate()
}
})
},
handleAdd() {
this.dialogTitle = '新增学员'
this.resetForm()
this.dialogVisible = true
},
handleEdit(row) {
this.dialogTitle = '编辑学员'
this.resetForm()
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(() => {})
},
// ==================== 新增/编辑提交 ====================
handleSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) return
this.submitting = true
const isAdd = this.dialogTitle === '新增学员'
const payload = { ...this.formData }
if (isAdd) {
delete payload.bh
delete payload.xh
delete payload.txzt
delete payload.ljzt
delete payload.fbzt
}
const request = isAdd ? addStudentRecord(payload) : updateStudentRecord(payload)
request.then(() => {
this.$message.success(isAdd ? '新增成功' : '编辑成功')
this.dialogVisible = false
this.loadData()
}).catch(() => {
}).finally(() => {
this.submitting = false
})
})
},
// ==================== 删除 ====================
handleDelete(row) {
this.$confirm(`确定要删除"${row.xm}"吗?`, '删除确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return delStudentRecord(row.bh)
}).then(() => {
this.$message.success('删除成功')
this.loadData()
}).catch(() => {})
},
// ==================== 成绩弹窗 ====================
async handleGrades(row) {
if (this.isGradesViewDisabled(row.yxckcj)) {
this.$alert('不允许查看该学员成绩', '提示', {
confirmButtonText: '确定',
type: 'warning'
}).catch(() => {})
return
}
this.gradesStudent = row.xm || ''
this.gradesStudentNo = row.xh || ''
this.currentBh = row.bh || ''
this.gradesData = []
this.processGradesData = []
this.gradesYear = ''
this.gradesTab = 'grades'
this.gradesVisible = true
this.gradesLoading = true
const emptyResponse = { data: { records: [] } }
const query = { pageNum: 1, pageSize: 1000, xybh: this.currentBh }
try {
const [gradesResponse, processGradesResponse] = await Promise.all([
listStudentGrades(query).catch(() => emptyResponse),
listStudentProcessGrades(query).catch(() => emptyResponse)
])
this.gradesData = gradesResponse.data.records || []
this.processGradesData = processGradesResponse.data.records || []
} finally {
this.gradesLoading = false
}
},
formatPassStatus(value) {
if (value === 1 || value === '1') {
return '已通过'
}
if (value === 0 || value === '0') {
return '未通过'
}
return '-'
},
isGradesViewDisabled(value) {
return GRADES_VIEW_DISABLED_VALUES.has(String(value).trim().toLowerCase())
},
filterGradesByYear(grades) {
if (!this.gradesYear) {
return grades
}
return grades.filter(item => String(item.nd) === this.gradesYear)
},
downloadGradesFile(blob, fileName) {
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = fileName
link.click()
URL.revokeObjectURL(link.href)
},
async handleExportGrades() {
if (!this.currentBh) {
this.$message.warning('缺少学员编号,无法导出成绩')
return
}
this.gradesExporting = true
try {
const isProcessGrades = this.gradesTab === 'process'
const request = isProcessGrades ? exportStudentProcessGrades : exportStudentGrades
const blob = await request({ xybh: this.currentBh })
const suffix = isProcessGrades ? '课程过程成绩' : '课程成绩'
this.downloadGradesFile(blob, `${this.gradesStudent || '学员'}_${suffix}.xlsx`)
this.$message.success(`${suffix}导出成功`)
} finally {
this.gradesExporting = false
}
}
}
}
</script>
<style scoped lang="scss">
.student-info-page {
.search-card {
.search-form {
.range-control {
display: flex;
align-items: center;
gap: 6px;
width: 100%;
.el-input {
flex: 1;
}
.range-sep {
flex-shrink: 0;
font-size: 12px;
color: #606266;
}
}
.search-tip {
font-size: 12px;
color: #f56c6c;
margin-top: 8px;
margin-bottom: 8px;
}
.search-actions {
display: flex;
justify-content: flex-end;
padding-top: 12px;
border-top: 1px solid #ebeef5;
}
}
}
.table-card {
.list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
}
.el-table {
width: 100%;
}
.student-info-table ::v-deep .cell {
white-space: nowrap;
word-break: keep-all;
}
}
.text-primary {
color: #409eff;
padding: 0;
}
.text-success {
color: #67c23a;
padding: 0;
}
.danger-text {
color: #f56c6c;
padding: 0;
}
.full-width {
width: 100%;
}
.student-summary {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 32px;
margin-bottom: 8px;
color: #303133;
line-height: 24px;
.grades-year-filter {
display: flex;
align-items: center;
margin-left: auto;
.filter-label {
flex-shrink: 0;
margin-right: 8px;
}
.el-select {
width: 160px;
}
}
}
}
</style>
@@ -0,0 +1,583 @@
<template>
<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-select v-model="searchForm.pxlx" placeholder="请选择培训类型" clearable filterable style="width: 100%">
<el-option
v-for="item in trainingTypeOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</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.pxcc" placeholder="请选择培训层次" clearable filterable style="width: 100%">
<el-option
v-for="item in trainingLevelOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
<el-form-item label="停用">
<el-radio-group v-model="searchForm.ty">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</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-select v-model="form.pxlx" placeholder="请选择培训类型" filterable style="width: 100%">
<el-option
v-for="item in trainingTypeOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训层次" prop="pxcc">
<el-select v-model="form.pxcc" placeholder="请选择培训层次" filterable style="width: 100%">
<el-option
v-for="item in trainingLevelOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</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-radio-group v-model="form.ty">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</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 {
listWarningCondition,
getWarningCondition,
addWarningCondition,
updateWarningCondition
} from "@/api/studentRecords/warningCondition"
import { getDicts } from '@/api/system/dict/data'
const TRAINING_TYPE_DICT_CODE = 'train_type'
const TRAINING_LEVEL_DICT_CODE = 'train_level'
export default {
name: "WarningCondition",
data() {
return {
// ==================== 查询条件 ====================
searchForm: {
mc: '',
pxlx: '',
pxcc: '',
ty: 0
},
trainingTypeOptions: [],
trainingLevelOptions: [],
// ==================== 列表数据 ====================
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" }]
},
// ==================== 详情 ====================
viewDialogVisible: false,
viewLoading: false,
viewForm: {}
}
},
created() {
this.loadTrainingDictionaries()
this.fetchList()
},
methods: {
/** 加载培训类型、培训层次字典。 */
async loadTrainingDictionaries() {
const emptyResponse = { data: [] }
const [typeResponse, levelResponse] = await Promise.all([
getDicts(TRAINING_TYPE_DICT_CODE).catch(() => emptyResponse),
getDicts(TRAINING_LEVEL_DICT_CODE).catch(() => emptyResponse)
])
this.trainingTypeOptions = typeResponse.data || []
this.trainingLevelOptions = levelResponse.data || []
},
/** 创建空表单 */
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: ''
}
},
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
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: 0
}
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'
]
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>
<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>
@@ -0,0 +1,256 @@
<template>
<div class="app-container warning-result-page">
<!-- ==================== 1. 查询条件 ==================== -->
<el-card shadow="never" class="search-card">
<el-form ref="searchFormRef" :model="searchForm" label-width="110px" 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.nd" 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.yjtjbh" 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.xybh" 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.fb" placeholder="请选择发布状态" clearable class="w-full">
<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>
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row>
<el-table-column prop="bh" label="编号" min-width="140" show-overflow-tooltip />
<el-table-column prop="nd" label="年度" width="90" align="center" />
<el-table-column prop="yjtjbh" label="预警条件编号" min-width="140" show-overflow-tooltip />
<el-table-column prop="xybh" label="学员编号" min-width="120" show-overflow-tooltip />
<el-table-column prop="cjsj" label="创建时间" width="160" show-overflow-tooltip />
<el-table-column label="发布" width="90" align="center">
<template slot-scope="{ row }">
<el-tag :type="Number(row.fb) === 1 ? 'success' : 'info'" size="mini">
{{ Number(row.fb) === 1 ? '是' : '否' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="fbsj" label="发布时间" width="160" show-overflow-tooltip />
<el-table-column label="操作" width="100" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" icon="el-icon-view" @click="handleDetail(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="预警结果详情" :visible="detailDialogVisible" width="560px" :close-on-click-modal="false"
@update:visible="val => detailDialogVisible = val">
<div v-loading="detailLoading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="编号">{{ detailForm.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="年度">{{ detailForm.nd || '-' }}</el-descriptions-item>
<el-descriptions-item label="预警条件编号">{{ detailForm.yjtjbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员编号">{{ detailForm.xybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detailForm.cjsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="发布时间">{{ detailForm.fbsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="发布">
<el-tag :type="Number(detailForm.fb) === 1 ? 'success' : 'info'" size="mini">
{{ Number(detailForm.fb) === 1 ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listWarningResult,
getWarningResult
} from '@/api/studentRecords/warningResult'
export default {
name: 'WarningResult',
data() {
return {
// ==================== 查询条件 ====================
searchForm: {
nd: '',
yjtjbh: '',
xybh: '',
fb: undefined
},
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// ==================== 详情 ====================
detailDialogVisible: false,
detailLoading: false,
detailForm: {}
}
},
created() {
this.fetchList()
},
methods: {
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
// 文本条件非空时才传
;['nd', 'yjtjbh', 'xybh'].forEach(key => {
const value = this.searchForm[key]
if (value !== '' && value !== null && value !== undefined) {
params[key] = String(value).trim()
}
})
// 发布:等值筛选(选中时才传)
if (this.searchForm.fb !== undefined && this.searchForm.fb !== '' && this.searchForm.fb !== null) {
params.fb = this.searchForm.fb
}
listWarningResult(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.$refs.searchFormRef.resetFields()
this.pageNum = 1
this.fetchList()
},
handlePageChange(current) {
this.pageNum = current
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
// ==================== 详情 ====================
handleDetail(row) {
this.detailDialogVisible = true
this.detailLoading = true
this.detailForm = {}
getWarningResult(row.bh).then(response => {
this.detailForm = response.data || {}
this.detailLoading = false
}).catch(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.warning-result-page {
.search-card {
margin-bottom: 16px;
}
.search-form {
.w-full {
width: 100%;
}
.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;
}
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
}
}
</style>
@@ -0,0 +1,626 @@
<template>
<div class="app-container discipline-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="12" :xl="12">
<el-form-item label="专业名称">
<el-input v-model="searchForm.zymc" placeholder="请输入专业名称" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="专业代码">
<el-input v-model="searchForm.zydm" placeholder="请输入专业代码" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="专业方向">
<el-input v-model="searchForm.zyfx" placeholder="请输入专业方向" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="学年制">
<el-input v-model="searchForm.xnz" placeholder="请输入学年制" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="停用" class="checkbox-form-item">
<el-radio-group v-model="searchForm.ty">
<el-radio :label="false">否</el-radio>
<el-radio :label="true">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="培训类型2">
<el-select v-model="searchForm.pxlx2" placeholder="请选择" clearable class="w-full">
<el-option label="类型1" value="1" />
<el-option label="类型2" value="2" />
<el-option label="其他" value="3" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" class="search-actions">
<div class="search-buttons">
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button @click="handleReset">重置</el-button>
</div>
</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>
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建学科专业</el-button>
</div>
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" width="60" align="center">
<template slot-scope="scope">{{ fmtXh(scope.$index) }}</template>
</el-table-column>
<el-table-column prop="jxgljgbh" label="教学管理机构" width="200" show-overflow-tooltip />
<el-table-column prop="zydm" label="专业代码" width="200" />
<el-table-column prop="zymc" label="专业名称" width="200" show-overflow-tooltip />
<el-table-column prop="xylb" label="学员类别" width="150" align="center" />
<el-table-column prop="xnz" label="学年制" width="120" align="center" />
<el-table-column prop="xqs" label="学期数" width="120" align="center" />
<el-table-column prop="zgzy" label="主干专业" align="center" />
<el-table-column label="停用" width="100" align="center">
<template slot-scope="{ row }">
<el-tag :type="row.ty === 1 ? 'danger' : 'success'" size="mini">
{{ row.ty === 1 ? '是' : '否' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="230" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" icon="el-icon-view" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button v-if="row.ty === 1" type="text" size="small" class="text-success" @click="handleEnable(row)">
启用
</el-button>
<el-button v-else type="text" size="small" class="text-danger" @click="handleDisable(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
:visible="formDialogVisible"
:title="dialogTitle"
width="750px"
:close-on-click-modal="false"
@update:visible="val => formDialogVisible = val"
>
<el-form ref="formRef" :model="form" :rules="formRules" label-width="130px" class="add-form">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="规范名称" prop="gfmc">
<el-input v-model="form.gfmc" placeholder="请输入规范名称" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="专业代码" prop="zydm">
<el-input v-model="form.zydm" placeholder="请输入专业代码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业名称" prop="zymc">
<el-input v-model="form.zymc" placeholder="请输入专业名称" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="专业方向" prop="zyfx">
<el-input v-model="form.zyfx" placeholder="请输入专业方向" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学年制" prop="xnz">
<el-input v-model="form.xnz" placeholder="请输入学年制" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="学期数" prop="xqs">
<el-input-number v-model="form.xqs" :min="0" controls-position="right" style="width: 100%" placeholder="请输入学期数" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训层次" prop="pxcc">
<el-select v-model="form.pxcc" placeholder="请选择培训层次" filterable class="w-full">
<el-option
v-for="item in trainingLevelOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="培训类型" prop="pxlx">
<el-select v-model="form.pxlx" placeholder="请选择培训类型" filterable class="w-full">
<el-option
v-for="item in trainingTypeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训类型2" prop="pxlx2">
<el-input v-model="form.pxlx2" placeholder="请输入培训类型2" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="教学管理机构编号" prop="jxgljgbh">
<el-input v-model="form.jxgljgbh" placeholder="请输入教学管理机构编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员类别" prop="xylb">
<el-select v-model="form.xylb" placeholder="请选择学员类别" filterable class="w-full">
<el-option
v-for="item in studentCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="自定义分类" prop="zdyfl">
<el-input v-model="form.zdyfl" placeholder="请输入自定义分类" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="主干专业" prop="zgzy">
<el-input v-model="form.zgzy" placeholder="请输入主干专业" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注">
<el-input v-model="form.bz" type="textarea" :rows="3" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="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="detailDialogVisible" width="700px" :close-on-click-modal="false"
@update:visible="val => detailDialogVisible = val">
<div v-loading="detailLoading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="规范名称">{{ detailForm.gfmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业代码">{{ detailForm.zydm || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业名称">{{ detailForm.zymc || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业方向">{{ detailForm.zyfx || '-' }}</el-descriptions-item>
<el-descriptions-item label="学年制">{{ detailForm.xnz || '-' }}</el-descriptions-item>
<el-descriptions-item label="学期数">{{ fmtValue(detailForm.xqs) }}</el-descriptions-item>
<el-descriptions-item label="培训层次">{{ detailForm.pxcc || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训类型">{{ detailForm.pxlx || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训类型2">{{ detailForm.pxlx2 || '-' }}</el-descriptions-item>
<el-descriptions-item label="教学管理机构编号">{{ detailForm.jxgljgbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员类别">{{ detailForm.xylb || '-' }}</el-descriptions-item>
<el-descriptions-item label="自定义分类">{{ detailForm.zdyfl || '-' }}</el-descriptions-item>
<el-descriptions-item label="主干专业">{{ detailForm.zgzy || '-' }}</el-descriptions-item>
<el-descriptions-item label="停用">
<el-tag :type="detailForm.ty === 1 ? 'danger' : 'success'" size="mini">
{{ detailForm.ty === 1 ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="停用时间">{{ detailForm.tysj || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ detailForm.bz || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listDiscipline,
getDiscipline,
addDiscipline,
updateDiscipline,
disableDiscipline
} from '@/api/subjectMajor/discipline'
import { getDicts } from '@/api/system/dict/data'
import { optionselect } from '@/api/system/dict/type'
const TRAINING_TYPE_DICT_CODE = 'train_type'
const TRAINING_LEVEL_DICT_CODE = 'train_level'
export default {
name: 'DisciplineIndex',
data() {
return {
// ==================== 查询条件 ====================
searchForm: {
zymc: '',
zydm: '',
zyfx: '',
xnz: '',
ty: false,
pxlx2: ''
},
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// ==================== 新增/编辑 ====================
formDialogVisible: false,
dialogTitle: '新增学科专业',
isAdd: true,
formSaving: false,
form: this.createEmptyForm(),
formRules: {
gfmc: [{ required: true, message: '请输入规范名称', trigger: 'blur' }],
zydm: [{ required: true, message: '请输入专业代码', trigger: 'blur' }],
zymc: [{ required: true, message: '请输入专业名称', trigger: 'blur' }],
zyfx: [{ required: true, message: '请输入专业方向', trigger: 'blur' }],
xnz: [{ required: true, message: '请输入学年制', trigger: 'blur' }],
xqs: [{ required: true, message: '请输入学期数', trigger: 'change' }],
pxcc: [{ required: true, message: '请选择培训层次', trigger: 'change' }],
pxlx: [{ required: true, message: '请选择培训类型', trigger: 'change' }],
pxlx2: [{ required: true, message: '请输入培训类型2', trigger: 'blur' }],
jxgljgbh: [{ required: true, message: '请输入教学管理机构编号', trigger: 'blur' }],
xylb: [{ required: true, message: '请选择学员类别', trigger: 'change' }],
zdyfl: [{ required: true, message: '请输入自定义分类', trigger: 'blur' }],
zgzy: [{ required: true, message: '请输入主干专业', trigger: 'blur' }]
},
trainingTypeOptions: [],
trainingLevelOptions: [],
studentCategoryOptions: [],
// ==================== 详情 ====================
detailDialogVisible: false,
detailLoading: false,
detailForm: {}
}
},
mounted() {
this.loadDisciplineDictionaries()
this.fetchList()
},
methods: {
/** 加载学科专业表单字典,业务字段统一提交字典标签。 */
async loadDisciplineDictionaries() {
const emptyResponse = { data: [] }
const [typeResponse, levelResponse, dictTypeResponse] = await Promise.all([
getDicts(TRAINING_TYPE_DICT_CODE).catch(() => emptyResponse),
getDicts(TRAINING_LEVEL_DICT_CODE).catch(() => emptyResponse),
optionselect().catch(() => emptyResponse)
])
this.trainingTypeOptions = typeResponse.data || []
this.trainingLevelOptions = levelResponse.data || []
this.studentCategoryOptions = await this.loadNamedDictionary(dictTypeResponse.data || [], '学员类别')
},
async loadNamedDictionary(dictTypes, dictName) {
const dictType = dictTypes.find(item => item.dictName === dictName) ||
dictTypes.find(item => String(item.dictName || '').includes(dictName))
if (!dictType || !dictType.dictType) {
return []
}
try {
const response = await getDicts(dictType.dictType)
return response.data || []
} catch (error) {
return []
}
},
/** 序号:按当前页数据索引生成跨页连续的序号 */
fmtXh(index) {
return (this.pageNum - 1) * this.pageSize + index + 1
},
createEmptyForm() {
return {
bsh: '',
gfmc: '',
zydm: '',
zymc: '',
zyfx: '',
xnz: '',
xqs: undefined,
pxcc: '',
pxlx: '',
pxlx2: '',
jxgljgbh: '',
xylb: '',
zdyfl: '',
jsonzd: '',
zgzy: '',
bz: ''
}
},
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
params.ty = this.searchForm.ty ? 1 : 0
// 其余文本条件非空时才传
;['zymc', 'zydm', 'zyfx', 'xnz', 'pxlx2'].forEach(key => {
const value = this.searchForm[key]
if (value !== '' && value !== null && value !== undefined) {
params[key] = String(value).trim()
}
})
listDiscipline(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.$refs.searchFormRef.resetFields()
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.dialogTitle = '新增学科专业'
this.form = this.createEmptyForm()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleEdit(row) {
this.isAdd = false
this.dialogTitle = '编辑学科专业'
this.form = this.createEmptyForm()
this.formDialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
getDiscipline(row.bsh).then(response => {
const data = response.data || {}
this.form = {
bsh: data.bsh || '',
gfmc: data.gfmc || '',
zydm: data.zydm || '',
zymc: data.zymc || '',
zyfx: data.zyfx || '',
xnz: data.xnz || '',
xqs: data.xqs !== null && data.xqs !== undefined ? data.xqs : undefined,
pxcc: data.pxcc || '',
pxlx: data.pxlx || '',
pxlx2: data.pxlx2 || '',
jxgljgbh: data.jxgljgbh || '',
xylb: data.xylb || '',
zdyfl: data.zdyfl || '',
jsonzd: data.jsonzd || '',
zgzy: data.zgzy || '',
bz: data.bz || ''
}
}).catch(() => {})
},
buildPayload() {
const f = this.form
const payload = {
bsh: f.bsh || undefined,
gfmc: f.gfmc,
zydm: f.zydm,
zymc: f.zymc,
zyfx: f.zyfx,
xnz: f.xnz,
pxcc: f.pxcc,
pxlx: f.pxlx,
pxlx2: f.pxlx2,
jxgljgbh: f.jxgljgbh,
xylb: f.xylb,
zdyfl: f.zdyfl,
zgzy: f.zgzy,
jsonzd: f.jsonzd,
bz: f.bz
}
// 学期数为数值字段,转为数字后再提交。
if (f.xqs !== '' && f.xqs !== null && f.xqs !== undefined) {
payload.xqs = Number(f.xqs)
}
return payload
},
handleFormSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) {
return
}
this.formSaving = true
const payload = this.buildPayload()
const request = this.isAdd ? addDiscipline(payload) : updateDiscipline(payload)
request.then(() => {
this.$message.success(this.isAdd ? '新增成功' : '修改成功')
this.formDialogVisible = false
this.fetchList()
}).catch(() => {
}).finally(() => {
this.formSaving = false
})
})
},
// ==================== 停用/启用 ====================
handleDisable(row) {
this.$confirm(`确定要停用「${row.zymc || row.zydm || '该专业'}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return disableDiscipline(row.bsh)
}).then(() => {
this.$message.success('停用成功')
this.fetchList()
}).catch(() => {})
},
// 后端暂未提供启用接口,仅作提示
handleEnable(row) {
this.$message.info('后端暂未提供该接口')
},
// ==================== 详情 ====================
// 数值字段空值显示为 '-'(保留 0)
fmtValue(val) {
return val === null || val === undefined || val === '' ? '-' : val
},
handleDetail(row) {
this.detailDialogVisible = true
this.detailLoading = true
this.detailForm = {}
getDiscipline(row.bsh).then(response => {
this.detailForm = response.data || {}
this.detailLoading = false
}).catch(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.discipline-page {
.search-form {
.w-full {
width: 100%;
}
.checkbox-form-item {
::v-deep(.el-form-item__content) {
display: flex;
align-items: center;
gap: 16px;
}
}
.search-actions {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 8px;
.search-tip {
font-size: 12px;
color: #f56c6c;
}
.search-buttons {
display: flex;
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;
}
}
}
.add-form {
max-height: 60vh;
overflow-y: auto;
padding-right: 4px;
}
.text-success {
color: #67c23a;
padding: 0;
}
.text-danger {
color: #f56c6c;
padding: 0;
}
}
</style>
@@ -0,0 +1,843 @@
<template>
<div class="app-container major-page">
<!-- ==================== 1. 查询条件 ==================== -->
<el-card shadow="never" class="search-card">
<el-form ref="searchFormRef" :model="searchForm" label-width="140px" 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.zymc" 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.zyfx" 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.zydm" 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.xnz" 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="培训类型2">
<el-input v-model="searchForm.pxlx2" placeholder="请输入培训类型2" 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-input v-model="searchForm.xkzyxxbsh" 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-radio-group v-model="searchForm.ty">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</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-download" @click="handleDownloadTemplate">下载模板</el-button>
<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 label="序号" width="60" align="center">
<template slot-scope="scope">{{ fmtXh(scope.$index) }}</template>
</el-table-column>
<el-table-column prop="zydh" label="专业代号" width="120" show-overflow-tooltip />
<el-table-column prop="zymc" label="专业名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="zyfx" label="专业方向" min-width="120" show-overflow-tooltip />
<el-table-column prop="zydm" label="专业代码" width="110" show-overflow-tooltip />
<el-table-column prop="xnz" label="学年制" width="80" align="center" />
<el-table-column prop="xqs" label="学期数" width="80" align="center" />
<el-table-column prop="pxcc" label="培训层次" width="100" align="center" />
<el-table-column prop="pxlx" label="培训类型" width="100" align="center" />
<el-table-column prop="pxlx2" label="培训类型2" width="100" align="center" />
<el-table-column prop="xylb" label="学员类别" width="100" align="center" />
<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="240" 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>
<el-button type="text" size="small" icon="el-icon-delete" class="text-danger" @click="handleDelete(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="160px" class="form-dialog-form">
<el-divider content-position="left">基本信息</el-divider>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="专业代号" prop="zydh">
<el-input v-model="form.zydh" :disabled="!isAdd" placeholder="请输入专业代号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业名称" prop="zymc">
<el-input v-model="form.zymc" placeholder="请输入专业名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业方向" prop="zyfx">
<el-input v-model="form.zyfx" placeholder="请输入专业方向" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业代码" prop="zydm">
<el-input v-model="form.zydm" placeholder="请输入专业代码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业版本" prop="zybb">
<el-input v-model="form.zybb" placeholder="请输入专业版本" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学年制" prop="xnz">
<el-input v-model="form.xnz" placeholder="请输入学年制" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学期数" prop="xqs">
<el-input-number v-model="form.xqs" :min="0" :max="999" controls-position="right" style="width: 100%" placeholder="请输入学期数" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业标识号" prop="zybsh">
<el-input v-model="form.zybsh" placeholder="请输入专业标识号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学科专业信息标识号" prop="xkzyxxbsh">
<el-select
v-model="form.xkzyxxbsh"
:loading="disciplineOptionsLoading"
placeholder="请选择学科专业"
clearable
filterable
class="w-full"
>
<el-option
v-for="item in disciplineOptions"
:key="item.bsh"
:label="formatDisciplineLabel(item)"
:value="item.bsh"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教学管理机构">
<el-input v-model="form.jxgljgbh" placeholder="请输入教学管理机构" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规范名称">
<el-input v-model="form.gfmc" placeholder="请输入规范名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="简称">
<el-input v-model="form.jc" 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="培训层次" prop="pxcc">
<el-select v-model="form.pxcc" placeholder="请选择培训层次" filterable class="w-full">
<el-option
v-for="item in trainingLevelOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训类型" prop="pxlx">
<el-select v-model="form.pxlx" placeholder="请选择培训类型" filterable class="w-full">
<el-option
v-for="item in trainingTypeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训类型2" prop="pxlx2">
<el-input v-model="form.pxlx2" placeholder="请输入培训类型2" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员类别" prop="xylb">
<el-select v-model="form.xylb" placeholder="请选择学员类别" filterable class="w-full">
<el-option
v-for="item in studentCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="主干专业" prop="zgzy">
<el-select v-model="form.zgzy" placeholder="请选择" clearable style="width: 100%">
<el-option label="是" value="是" />
<el-option label="否" value="否" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="自定义分类" prop="zdyfl">
<el-input v-model="form.zdyfl" placeholder="请输入自定义分类" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="节次类别" prop="jclb">
<el-select v-model="form.jclb" placeholder="请选择节次类别" filterable class="w-full">
<el-option
v-for="item in sessionCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="系统模式" prop="xtms">
<el-select v-model="form.xtms" placeholder="请选择系统模式" filterable class="w-full">
<el-option
v-for="item in systemModeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</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 v-model="form.jxdgbh" placeholder="请输入教学大纲编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="人培编号">
<el-input v-model="form.rpbh" placeholder="请输入人培编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="序号标识">
<el-input-number v-model="form.xhbs" :min="0" controls-position="right" style="width: 100%" 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="启用时间">
<el-date-picker v-model="form.qysj" type="datetime" placeholder="请选择启用时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停用时间">
<el-date-picker v-model="form.tysj" type="datetime" placeholder="请选择停用时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培养目标">
<el-input v-model="form.pymb" placeholder="请输入培养目标" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="专业备注">
<el-input v-model="form.zybz" type="textarea" :rows="3" placeholder="请输入专业备注" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="专业规范">
<el-input v-model="form.zygf" type="textarea" :rows="3" 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="700px" :close-on-click-modal="false">
<div v-loading="viewLoading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="专业代号">{{ viewForm.zydh || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业名称">{{ viewForm.zymc || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业方向">{{ viewForm.zyfx || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业代码">{{ viewForm.zydm || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业版本">{{ viewForm.zybb || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业标识号">{{ viewForm.zybsh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学年制">{{ viewForm.xnz || '-' }}</el-descriptions-item>
<el-descriptions-item label="学期数">{{ viewForm.xqs || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训层次">{{ viewForm.pxcc || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训类型">{{ viewForm.pxlx || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训类型2">{{ viewForm.pxlx2 || '-' }}</el-descriptions-item>
<el-descriptions-item label="学员类别">{{ viewForm.xylb || '-' }}</el-descriptions-item>
<el-descriptions-item label="主干专业">{{ viewForm.zgzy || '-' }}</el-descriptions-item>
<el-descriptions-item label="自定义分类">{{ viewForm.zdyfl || '-' }}</el-descriptions-item>
<el-descriptions-item label="教学管理机构编号">{{ viewForm.jxgljgbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="学科专业信息标识号">{{ viewForm.xkzyxxbsh || '-' }}</el-descriptions-item>
<el-descriptions-item label="简称">{{ viewForm.jc || '-' }}</el-descriptions-item>
<el-descriptions-item label="规范名称">{{ viewForm.gfmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="节次类别">{{ viewForm.jclb || '-' }}</el-descriptions-item>
<el-descriptions-item label="系统模式">{{ viewForm.xtms || '-' }}</el-descriptions-item>
<el-descriptions-item label="序号标识">{{ viewForm.xhbs || '-' }}</el-descriptions-item>
<el-descriptions-item label="教学大纲编号">{{ viewForm.jxdgbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="人培编号">{{ viewForm.rpbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="启用时间">{{ viewForm.qysj || '-' }}</el-descriptions-item>
<el-descriptions-item label="停用时间">{{ viewForm.tysj || '-' }}</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-item label="培养目标" :span="2">{{ viewForm.pymb || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业备注" :span="2">{{ viewForm.zybz || '-' }}</el-descriptions-item>
<el-descriptions-item label="专业规范" :span="2">{{ viewForm.zygf || '-' }}</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 {
listMajor,
getMajor,
addMajor,
updateMajor,
delMajor,
downloadMajorTemplate
} from "@/api/subjectMajor/major"
import { listDiscipline } from '@/api/subjectMajor/discipline'
import { getDicts } from '@/api/system/dict/data'
import { optionselect } from '@/api/system/dict/type'
const TRAINING_TYPE_DICT_CODE = 'train_type'
const TRAINING_LEVEL_DICT_CODE = 'train_level'
const SESSION_CATEGORY_DICT_CODE = 'session_category'
const SYSTEM_MODE_DICT_CODE = 'system_mode'
const DISCIPLINE_OPTION_PAGE_SIZE = 10000
export default {
name: "Major",
data() {
return {
// ==================== 查询条件 ====================
searchForm: {
zymc: '',
zyfx: '',
zydm: '',
xnz: '',
pxlx: '',
pxlx2: '',
pxcc: '',
xkzyxxbsh: '',
ty: 0
},
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// ==================== 新增/编辑 ====================
formDialogVisible: false,
formTitle: '新增专业',
isAdd: true,
formSaving: false,
form: this.createEmptyForm(),
trainingTypeOptions: [],
trainingLevelOptions: [],
studentCategoryOptions: [],
sessionCategoryOptions: [],
systemModeOptions: [],
disciplineOptions: [],
disciplineOptionsLoading: false,
formRules: {
zydh: [{ required: true, message: "专业代号不能为空", trigger: "blur" }],
zymc: [{ required: true, message: "专业名称不能为空", trigger: "blur" }],
zyfx: [{ required: true, message: "专业方向不能为空", trigger: "blur" }],
zydm: [{ required: true, message: "专业代码不能为空", trigger: "blur" }],
zybb: [{ required: true, message: "专业版本不能为空", trigger: "blur" }],
xnz: [{ required: true, message: "学年制不能为空", trigger: "blur" }],
xqs: [{ required: true, message: "学期数不能为空", trigger: "change" }],
zybsh: [{ required: true, message: "专业标识号不能为空", trigger: "blur" }],
pxcc: [{ required: true, message: "请选择培训层次", trigger: "change" }],
pxlx: [{ required: true, message: "请选择培训类型", trigger: "change" }],
pxlx2: [{ required: true, message: "培训类型2不能为空", trigger: "blur" }],
xylb: [{ required: true, message: "请选择学员类别", trigger: "change" }],
zdyfl: [{ required: true, message: "自定义分类不能为空", trigger: "blur" }],
zgzy: [{ required: true, message: "主干专业不能为空", trigger: "change" }],
jclb: [{ required: true, message: "请选择节次类别", trigger: "change" }],
xtms: [{ required: true, message: "请选择系统模式", trigger: "change" }]
},
// ==================== 详情 ====================
viewDialogVisible: false,
viewLoading: false,
viewForm: {}
}
},
created() {
this.loadMajorDictionaries()
this.loadDisciplineOptions()
this.fetchList()
},
methods: {
/** 加载专业表单中已配置的字典项,文本业务字段统一提交字典标签。 */
async loadMajorDictionaries() {
const emptyResponse = { data: [] }
const [typeResponse, levelResponse, sessionResponse, modeResponse, dictTypeResponse] = await Promise.all([
getDicts(TRAINING_TYPE_DICT_CODE).catch(() => emptyResponse),
getDicts(TRAINING_LEVEL_DICT_CODE).catch(() => emptyResponse),
getDicts(SESSION_CATEGORY_DICT_CODE).catch(() => emptyResponse),
getDicts(SYSTEM_MODE_DICT_CODE).catch(() => emptyResponse),
optionselect().catch(() => emptyResponse)
])
this.trainingTypeOptions = typeResponse.data || []
this.trainingLevelOptions = levelResponse.data || []
this.sessionCategoryOptions = sessionResponse.data || []
this.systemModeOptions = modeResponse.data || []
const dictTypes = dictTypeResponse.data || []
this.studentCategoryOptions = await this.loadNamedDictionary(dictTypes, '学员类别')
},
async loadNamedDictionary(dictTypes, dictName) {
const dictType = dictTypes.find(item => item.dictName === dictName) ||
dictTypes.find(item => String(item.dictName || '').includes(dictName))
if (!dictType || !dictType.dictType) {
return []
}
try {
const response = await getDicts(dictType.dictType)
return response.data || []
} catch (error) {
return []
}
},
/** 复用学科专业分页接口加载启用数据,作为全量下拉选项。 */
async loadDisciplineOptions() {
this.disciplineOptionsLoading = true
try {
const response = await listDiscipline({
pageNum: 1,
pageSize: DISCIPLINE_OPTION_PAGE_SIZE,
ty: 0
})
const data = response.data || {}
this.disciplineOptions = Array.isArray(data.records) ? data.records : []
} catch (error) {
this.disciplineOptions = []
} finally {
this.disciplineOptionsLoading = false
}
},
formatDisciplineLabel(item) {
const name = item.zymc || item.gfmc || item.zydm || item.bsh
const identifiers = [item.zydm, item.bsh].filter(Boolean).join(' / ')
return identifiers && identifiers !== name ? `${name}(${identifiers})` : name
},
/** 表格序号(跨页连续) */
fmtXh(index) {
return (this.pageNum - 1) * this.pageSize + index + 1
},
/** 创建空表单 */
createEmptyForm() {
return {
zydh: '',
zymc: '',
zyfx: '',
xnz: '',
xqs: undefined,
zybz: '',
zygf: '',
zydm: '',
zybb: '',
ty: 0,
qysj: null,
tysj: null,
jxgljgbh: '',
pxcc: '',
pxlx: '',
xkzyxxbsh: '',
pxlx2: '',
xylb: '',
zdyfl: '',
zybsh: '',
xhbs: undefined,
jc: '',
jclb: '',
xtms: '',
jsonzd: '',
zgzy: '',
gfmc: '',
jxdgbh: '',
rpbh: '',
pymb: ''
}
},
// ==================== 查询列表 ====================
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
params.ty = this.searchForm.ty
// 其余文本条件非空时才传
;['zymc', 'zyfx', 'zydm', 'xnz', 'pxlx', 'pxlx2', 'pxcc', 'xkzyxxbsh'].forEach(key => {
if (this.searchForm[key] !== '' && this.searchForm[key] !== null && this.searchForm[key] !== undefined) {
params[key] = this.searchForm[key].trim()
}
})
listMajor(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 = {
zymc: '',
zyfx: '',
zydm: '',
xnz: '',
pxlx: '',
pxlx2: '',
pxcc: '',
xkzyxxbsh: '',
ty: 0
}
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()
})
getMajor(row.zydh).then(response => {
const data = response.data || {}
this.form = {
zydh: data.zydh,
zymc: data.zymc,
zyfx: data.zyfx,
xnz: data.xnz,
xqs: data.xqs !== null && data.xqs !== undefined ? data.xqs : undefined,
zybz: data.zybz,
zygf: data.zygf,
zydm: data.zydm,
zybb: data.zybb,
ty: data.ty === 1 || data.ty === true ? 1 : 0,
qysj: data.qysj,
tysj: data.tysj,
jxgljgbh: data.jxgljgbh,
pxcc: data.pxcc,
pxlx: data.pxlx,
xkzyxxbsh: data.xkzyxxbsh,
pxlx2: data.pxlx2,
xylb: data.xylb,
zdyfl: data.zdyfl,
zybsh: data.zybsh,
xhbs: data.xhbs,
jc: data.jc,
jclb: data.jclb,
xtms: data.xtms,
jsonzd: data.jsonzd,
zgzy: data.zgzy,
gfmc: data.gfmc,
jxdgbh: data.jxdgbh,
rpbh: data.rpbh,
pymb: data.pymb
}
}).catch(() => {})
},
handleFormSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) return
this.formSaving = true
const payload = { ...this.form }
const request = this.isAdd ? addMajor(payload) : updateMajor(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.zymc || row.zydh || '该专业'}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return updateMajor({ ...row, ty: isDisable ? 1 : 0 })
}).then(() => {
this.$message.success(actionName + '成功')
this.fetchList()
}).catch(() => {
// 取消或接口失败时回滚开关状态并刷新
row.ty = prevTy
this.fetchList()
})
},
// ==================== 删除 ====================
handleDelete(row) {
this.$confirm(`确定要删除「${row.zymc || row.zydh || '该专业'}」吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return delMajor(row.zydh)
}).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
// ==================== 下载模板 ====================
handleDownloadTemplate() {
downloadMajorTemplate().then(res => {
const blob = new Blob([res], { type: 'application/vnd.ms-excel;charset=utf-8' })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = '人才培养方案课程数据文件模板.xls'
link.click()
URL.revokeObjectURL(link.href)
this.$message.success('模板下载成功')
}).catch(() => {})
},
// ==================== 详情 ====================
handleView(row) {
this.viewDialogVisible = true
this.viewLoading = true
this.viewForm = {}
getMajor(row.zydh).then(response => {
this.viewForm = response.data || {}
this.viewLoading = false
}).catch(() => {
this.viewLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.major-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;
}
}
.text-danger {
color: #f56c6c;
padding: 0;
}
.ty-tag {
cursor: pointer;
user-select: none;
}
}
</style>
+380
View File
@@ -0,0 +1,380 @@
<template>
<div class="app-container system-config">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="参数名称" prop="configName">
<el-input
v-model="queryParams.configName"
placeholder="请输入参数名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="参数键名" prop="configKey">
<el-input
v-model="queryParams.configKey"
placeholder="请输入参数键名"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="系统内置" prop="configType">
<el-select v-model="queryParams.configType" placeholder="系统内置" clearable>
<el-option
v-for="dict in dict.type.sys_yes_no"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:config:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:config:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:config:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:config:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-refresh"
size="mini"
@click="handleRefreshCache"
v-hasPermi="['system:config:remove']"
>刷新缓存</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="configList" :height="tableHeight" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="参数主键" align="center" prop="configId" />
<el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" />
<el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" />
<el-table-column label="参数键值" align="center" prop="configValue" :show-overflow-tooltip="true" />
<el-table-column label="系统内置" align="center" prop="configType">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.configType"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:config:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:config:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="参数名称" prop="configName">
<el-input v-model="form.configName" placeholder="请输入参数名称" />
</el-form-item>
<el-form-item label="参数键名" prop="configKey">
<el-input v-model="form.configKey" placeholder="请输入参数键名" />
</el-form-item>
<el-form-item label="参数键值" prop="configValue">
<el-input v-model="form.configValue" type="textarea" placeholder="请输入参数键值" />
</el-form-item>
<el-form-item label="系统内置" prop="configType">
<el-radio-group v-model="form.configType">
<el-radio
v-for="dict in dict.type.sys_yes_no"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config"
export default {
name: "Config",
dicts: ['sys_yes_no'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 总条数
total: 0,
// 参数表格数据
configList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
configName: undefined,
configKey: undefined,
configType: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
configName: [
{ required: true, message: "参数名称不能为空", trigger: "blur" }
],
configKey: [
{ required: true, message: "参数键名不能为空", trigger: "blur" }
],
configValue: [
{ required: true, message: "参数键值不能为空", trigger: "blur" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询参数列表 */
getList() {
this.loading = true
listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.configList = response.rows
this.total = response.total
this.loading = false
}
)
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
configId: undefined,
configName: undefined,
configKey: undefined,
configValue: undefined,
configType: "Y",
remark: undefined
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加参数"
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.configId)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const configId = row.configId || this.ids
getConfig(configId).then(response => {
this.form = response.data
this.open = true
this.title = "修改参数"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.configId != undefined) {
updateConfig(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addConfig(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const configIds = row.configId || this.ids
this.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function() {
return delConfig(configIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/config/export', {
...this.queryParams
}, `config_${new Date().getTime()}.xlsx`)
},
/** 刷新缓存按钮操作 */
handleRefreshCache() {
refreshCache().then(() => {
this.$modal.msgSuccess("刷新成功")
})
}
}
}
</script>
<style scoped>
.system-config ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-config ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-config ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-config ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+426
View File
@@ -0,0 +1,426 @@
<template>
<div class="app-container system-dept">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="部门名称" prop="deptName">
<el-input
v-model="queryParams.deptName"
placeholder="请输入部门名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:dept:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-check"
size="mini"
@click="handleSaveSort"
v-hasPermi="['system:dept:edit']"
>保存排序</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="deptList"
:height="tableHeight"
row-key="deptId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="orderNum" label="排序" width="200">
<template slot-scope="scope">
<el-input-number v-model="scope.row.orderNum" controls-position="right" :min="0" size="mini" style="width: 88px" />
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:dept:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['system:dept:add']"
>新增</el-button>
<el-button
v-if="scope.row.parentId != 0"
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:dept:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改部门对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="24" v-if="form.parentId !== 0">
<el-form-item label="上级部门" prop="parentId">
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="部门名称" prop="deptName">
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="显示排序" prop="orderNum">
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="负责人" prop="leader">
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="部门状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listDept, getDept, delDept, addDept, updateDept, updateDeptSort, listDeptExcludeChild } from "@/api/system/dept"
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
export default {
name: "Dept",
dicts: ['sys_normal_disable'],
components: { Treeselect },
data() {
return {
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 表格树数据
deptList: [],
// 部门树选项
deptOptions: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否展开,默认全部展开
isExpandAll: true,
// 重新渲染表格状态
refreshTable: true,
// 记录原始排序,用于对比变更
originalOrders: {},
// 查询参数
queryParams: {
deptName: undefined,
status: '0'
},
// 表单参数
form: {},
// 表单校验
rules: {
parentId: [
{ required: true, message: "上级部门不能为空", trigger: "blur" }
],
deptName: [
{ required: true, message: "部门名称不能为空", trigger: "blur" }
],
orderNum: [
{ required: true, message: "显示排序不能为空", trigger: "blur" }
],
email: [
{
type: "email",
message: "请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
],
phone: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询部门列表 */
getList() {
this.loading = true
listDept(this.queryParams).then(response => {
this.deptList = this.handleTree(response.data, "deptId")
// 记录原始排序值
this.recordOriginalOrders(this.deptList)
this.loading = false
})
},
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children
}
return {
id: node.deptId,
label: node.deptName,
children: node.children
}
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
deptId: undefined,
parentId: undefined,
deptName: undefined,
orderNum: undefined,
leader: undefined,
phone: undefined,
email: undefined,
status: "0"
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset()
if (row != undefined) {
this.form.parentId = row.deptId
}
this.open = true
this.title = "添加部门"
listDept().then(response => {
this.deptOptions = this.handleTree(response.data, "deptId")
})
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false
this.isExpandAll = !this.isExpandAll
this.$nextTick(() => {
this.refreshTable = true
})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
getDept(row.deptId).then(response => {
this.form = response.data
this.open = true
this.title = "修改部门"
listDeptExcludeChild(row.deptId).then(response => {
this.deptOptions = this.handleTree(response.data, "deptId")
if (this.deptOptions.length == 0) {
const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] }
this.deptOptions.push(noResultsOptions)
}
})
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deptId != undefined) {
updateDept(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addDept(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 递归记录原始排序 */
recordOriginalOrders(list) {
list.forEach(item => {
this.originalOrders[item.deptId] = item.orderNum
if (item.children && item.children.length) {
this.recordOriginalOrders(item.children)
}
})
},
/** 保存排序 */
handleSaveSort() {
const changedDeptIds = []
const changedOrderNums = []
const collectChanged = (list) => {
list.forEach(item => {
if (String(this.originalOrders[item.deptId]) !== String(item.orderNum)) {
changedDeptIds.push(item.deptId)
changedOrderNums.push(item.orderNum)
}
if (item.children && item.children.length) {
collectChanged(item.children)
}
})
}
collectChanged(this.deptList)
if (changedDeptIds.length === 0) {
this.$modal.msgWarning("未检测到排序修改")
return
}
updateDeptSort({ deptIds: changedDeptIds.join(","), orderNums: changedOrderNums.join(",") }).then(() => {
this.$modal.msgSuccess("排序保存成功")
this.recordOriginalOrders(this.deptList)
})
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() {
return delDept(row.deptId)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
}
}
</script>
<style scoped>
.system-dept ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-dept ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-dept ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-dept ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+433
View File
@@ -0,0 +1,433 @@
<template>
<div class="app-container system-dict-data">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="字典名称" prop="dictType">
<el-select v-model="queryParams.dictType" filterable>
<el-option
v-for="item in typeOptions"
:key="item.dictId"
:label="item.dictName"
:value="item.dictType"
/>
</el-select>
</el-form-item>
<el-form-item label="字典标签" prop="dictLabel">
<el-input
v-model="queryParams.dictLabel"
placeholder="请输入字典标签"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:dict:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:dict:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:dict:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:dict:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
icon="el-icon-close"
size="mini"
@click="handleClose"
>关闭</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="dataList" :height="tableHeight" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="字典编码" align="center" prop="dictCode" />
<el-table-column label="字典标签" align="center" prop="dictLabel">
<template slot-scope="scope">
<span v-if="(scope.row.listClass == '' || scope.row.listClass == 'default') && (scope.row.cssClass == '' || scope.row.cssClass == null)">{{ scope.row.dictLabel }}</span>
<el-tag v-else :type="scope.row.listClass == 'primary' ? '' : scope.row.listClass" :class="scope.row.cssClass">{{ scope.row.dictLabel }}</el-tag>
</template>
</el-table-column>
<el-table-column label="字典键值" align="center" prop="dictValue" />
<el-table-column label="字典排序" align="center" prop="dictSort" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:dict:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:dict:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="字典类型">
<el-input v-model="form.dictType" :disabled="true" />
</el-form-item>
<el-form-item label="数据标签" prop="dictLabel">
<el-input v-model="form.dictLabel" placeholder="请输入数据标签" />
</el-form-item>
<el-form-item label="数据键值" prop="dictValue">
<el-input v-model="form.dictValue" placeholder="请输入数据键值" />
</el-form-item>
<el-form-item label="样式属性" prop="cssClass">
<el-input v-model="form.cssClass" placeholder="请输入样式属性" />
</el-form-item>
<el-form-item label="显示排序" prop="dictSort">
<el-input-number v-model="form.dictSort" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="回显样式" prop="listClass">
<el-select v-model="form.listClass">
<el-option
v-for="item in listClassOptions"
:key="item.value"
:label="item.label + '(' + item.value + ')'"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data"
import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type"
export default {
name: "Data",
dicts: ['sys_normal_disable'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 总条数
total: 0,
// 字典表格数据
dataList: [],
// 默认字典类型
defaultDictType: "",
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 数据标签回显样式
listClassOptions: [
{
value: "default",
label: "默认"
},
{
value: "primary",
label: "主要"
},
{
value: "success",
label: "成功"
},
{
value: "info",
label: "信息"
},
{
value: "warning",
label: "警告"
},
{
value: "danger",
label: "危险"
}
],
// 类型数据字典
typeOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
dictType: undefined,
dictLabel: undefined,
status: '0'
},
// 表单参数
form: {},
// 表单校验
rules: {
dictLabel: [
{ required: true, message: "数据标签不能为空", trigger: "blur" }
],
dictValue: [
{ required: true, message: "数据键值不能为空", trigger: "blur" }
],
dictSort: [
{ required: true, message: "数据顺序不能为空", trigger: "blur" }
]
}
}
},
created() {
const dictId = this.$route.params && this.$route.params.dictId
this.getType(dictId)
this.getTypeList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询字典类型详细 */
getType(dictId) {
getType(dictId).then(response => {
this.queryParams.dictType = response.data.dictType
this.defaultDictType = response.data.dictType
this.getList()
})
},
/** 查询字典类型列表 */
getTypeList() {
getDictOptionselect().then(response => {
this.typeOptions = response.data
})
},
/** 查询字典数据列表 */
getList() {
this.loading = true
listData(this.queryParams).then(response => {
this.dataList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
dictCode: undefined,
dictLabel: undefined,
dictValue: undefined,
cssClass: undefined,
listClass: 'default',
dictSort: 0,
status: "0",
remark: undefined
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 返回按钮操作 */
handleClose() {
const obj = { path: "/system/dict" }
this.$tab.closeOpenPage(obj)
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.queryParams.dictType = this.defaultDictType
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加字典数据"
this.form.dictType = this.queryParams.dictType
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictCode)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const dictCode = row.dictCode || this.ids
getData(dictCode).then(response => {
this.form = response.data
this.open = true
this.title = "修改字典数据"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.dictCode != undefined) {
updateData(this.form).then(() => {
this.$store.dispatch('dict/removeDict', this.queryParams.dictType)
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addData(this.form).then(() => {
this.$store.dispatch('dict/removeDict', this.queryParams.dictType)
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const dictCodes = row.dictCode || this.ids
this.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?').then(function() {
return delData(dictCodes)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
this.$store.dispatch('dict/removeDict', this.queryParams.dictType)
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/dict/data/export', {
...this.queryParams
}, `data_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.system-dict-data ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-dict-data ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-dict-data ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-dict-data ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+203
View File
@@ -0,0 +1,203 @@
<template>
<el-drawer :title="drawerTitle" :visible.sync="localVisible" direction="rtl" size="700px" append-to-body>
<div class="drawer-wrap">
<div v-if="loading" class="drawer-loading">
<i class="el-icon-loading"></i>
<span>加载中...</span>
</div>
<div v-else-if="!dataList.length" class="drawer-empty">
<i class="el-icon-document"></i>
<div>暂无字典数据</div>
</div>
<template v-else>
<el-row :gutter="12" class="stat-row">
<el-col :span="disabledCount > 0 ? 8 : 12">
<div class="stat-card">
<div class="stat-num">{{ dataList.length }}</div>
<div class="stat-label">共计条目</div>
</div>
</el-col>
<el-col :span="disabledCount > 0 ? 8 : 12">
<div class="stat-card">
<div class="stat-num success">{{ normalCount }}</div>
<div class="stat-label">正常</div>
</div>
</el-col>
<el-col :span="8" v-if="disabledCount > 0">
<div class="stat-card">
<div class="stat-num danger">{{ disabledCount }}</div>
<div class="stat-label">停用</div>
</div>
</el-col>
</el-row>
<div v-for="item in dataList" :key="item.dictCode" class="dict-item">
<div class="dict-cell">
<div class="dict-cell-key">标签</div>
<div class="dict-cell-val">
<el-tag v-if="item.listClass && item.listClass !== 'default'" :type="item.listClass === 'primary' ? '' : item.listClass" size="small">{{ item.dictLabel }}</el-tag>
<span v-else>{{ item.dictLabel }}</span>
</div>
</div>
<div class="dict-cell">
<div class="dict-cell-key">键值</div>
<div class="dict-cell-val">{{ item.dictValue }}</div>
</div>
<div class="dict-cell">
<div class="dict-cell-key">状态</div>
<div class="dict-cell-val">
<el-tag :type="item.status === '0' ? 'success' : 'danger'" size="small">
{{ item.status === '0' ? '正常' : '停用' }}
</el-tag>
</div>
</div>
</div>
</template>
</div>
</el-drawer>
</template>
<script>
import { listData } from '@/api/system/dict/data'
export default {
props: {
visible: { type: Boolean, default: false },
row: { type: Object, default: () => ({}) }
},
data() {
return {
localVisible: false,
loading: false,
dataList: []
}
},
computed: {
drawerTitle() {
return this.row.dictName + ' ' + (this.row.dictType || '')
},
normalCount() {
return this.dataList.filter(r => r.status === '0').length
},
disabledCount() {
return this.dataList.filter(r => r.status !== '0').length
}
},
watch: {
visible(val) {
this.localVisible = val
},
localVisible(val) {
this.$emit('update:visible', val)
if (val) {
this.loadData()
} else {
this.dataList = []
}
}
},
methods: {
loadData() {
if (!this.row || !this.row.dictType) return
this.loading = true
this.dataList = []
listData({ dictType: this.row.dictType, pageSize: 100, pageNum: 1 }).then(response => {
this.dataList = response.rows || []
}).catch(() => {}).finally(() => {
this.loading = false
})
}
}
}
</script>
<style scoped>
.drawer-wrap {
padding: 0 20px 20px;
}
.drawer-loading {
display: flex;
align-items: center;
justify-content: center;
height: 120px;
color: #aaa;
font-size: 13px;
gap: 8px;
}
.drawer-empty {
text-align: center;
color: #bbb;
padding: 60px 0;
font-size: 13px;
}
.drawer-empty i {
font-size: 36px;
display: block;
margin-bottom: 8px;
}
.stat-row {
margin-bottom: 16px;
}
.stat-card {
background: #f7f9fb;
border: 1px solid #e8ecf0;
border-radius: 6px;
padding: 10px 14px;
text-align: center;
}
.stat-num {
font-size: 22px;
font-weight: 700;
color: #2c3e50;
}
.stat-num.success { color: #27ae60; }
.stat-num.danger { color: #e74c3c; }
.stat-label {
font-size: 11px;
color: #95a5a6;
margin-top: 4px;
}
.dict-item {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
border: 1px solid #e8ecf0;
border-radius: 6px;
overflow: hidden;
margin-bottom: 8px;
}
.dict-cell {
display: grid;
grid-template-columns: 70px 1fr;
border-right: 1px solid #f0f4f8;
}
.dict-cell:last-child {
border-right: 0;
}
.dict-cell-key {
padding: 9px 14px;
font-size: 12px;
color: #888;
background: #f7f9fb;
border-right: 1px solid #f0f4f8;
}
.dict-cell-val {
padding: 9px 14px;
font-size: 13px;
color: #2c3e50;
word-break: break-all;
display: flex;
align-items: center;
}
</style>
+403
View File
@@ -0,0 +1,403 @@
<template>
<div class="app-container system-dict">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="字典名称" prop="dictName">
<el-input
v-model="queryParams.dictName"
placeholder="请输入字典名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="字典类型" prop="dictType">
<el-input
v-model="queryParams.dictType"
placeholder="请输入字典类型"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:dict:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:dict:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:dict:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:dict:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-refresh"
size="mini"
@click="handleRefreshCache"
v-hasPermi="['system:dict:remove']"
>刷新缓存</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="typeList" :height="tableHeight" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="字典编号" align="center" prop="dictId" />
<el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true" />
<el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<a class="link-type" style="cursor:pointer" @click="handleViewData(scope.row)">{{ scope.row.dictType }}</a>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:dict:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-s-operation"
@click="handleDataList(scope.row)"
v-hasPermi="['system:dict:edit']"
>列表</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:dict:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="字典名称" prop="dictName">
<el-input v-model="form.dictName" placeholder="请输入字典名称" />
</el-form-item>
<el-form-item prop="dictType">
<el-input v-model="form.dictType" placeholder="请输入字典类型" maxlength="100" />
<span slot="label">
<el-tooltip content="数据存储中的Key值,如:sys_user_sex" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
字典类型
</span>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<dict-data-drawer :visible.sync="drawerVisible" :row="drawerRow" />
</div>
</template>
<script>
import DictDataDrawer from './detail'
import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type"
export default {
name: "Dict",
components: { DictDataDrawer },
dicts: ['sys_normal_disable'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 总条数
total: 0,
// 字典表格数据
typeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 字典数据抽屉状态
drawerVisible: false,
// 字典数据信息
drawerRow: {},
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
dictName: undefined,
dictType: undefined,
status: '0'
},
// 表单参数
form: {},
// 表单校验
rules: {
dictName: [
{ required: true, message: "字典名称不能为空", trigger: "blur" }
],
dictType: [
{ required: true, message: "字典类型不能为空", trigger: "blur" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询字典类型列表 */
getList() {
this.loading = true
listType(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.typeList = response.rows
this.total = response.total
this.loading = false
}
)
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
dictId: undefined,
dictName: undefined,
dictType: undefined,
status: "0",
remark: undefined
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加字典类型"
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictId)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 字典数据抽屉显示信息 */
handleViewData(row) {
this.drawerRow = row
this.drawerVisible = true
},
/** 字典数据列表页面 */
handleDataList(row) {
this.$tab.openPage("字典数据", '/system/dict-data/index/' + row.dictId)
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const dictId = row.dictId || this.ids
getType(dictId).then(response => {
this.form = response.data
this.open = true
this.title = "修改字典类型"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.dictId != undefined) {
updateType(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addType(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const dictIds = row.dictId || this.ids
this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function() {
return delType(dictIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/dict/type/export', {
...this.queryParams
}, `type_${new Date().getTime()}.xlsx`)
},
/** 刷新缓存按钮操作 */
handleRefreshCache() {
refreshCache().then(() => {
this.$modal.msgSuccess("刷新成功")
this.$store.dispatch('dict/cleanDict')
})
}
}
}
</script>
<style scoped>
.system-dict ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-dict ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-dict ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-dict ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+568
View File
@@ -0,0 +1,568 @@
<template>
<div class="app-container system-menu">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="菜单名称" prop="menuName">
<el-input
v-model="queryParams.menuName"
placeholder="请输入菜单名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:menu:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-check"
size="mini"
@click="handleSaveSort"
v-hasPermi="['system:menu:edit']"
>保存排序</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="menuList"
:height="tableHeight"
row-key="menuId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="220">
<template slot-scope="scope">
<svg-icon :icon-class="scope.row.icon" />
<span class="ml5">{{ scope.row.menuName }}</span>
</template>
</el-table-column>
<el-table-column prop="menuName" label="类型" :show-overflow-tooltip="true" width="100">
<template slot-scope="scope">
<el-tag v-if="scope.row.menuType === 'M' && scope.row.isFrame === '0'" type="danger" size="small">外链</el-tag>
<el-tag v-else-if="scope.row.menuType === 'M'" type="primary" size="small">目录</el-tag>
<el-tag v-else-if="scope.row.menuType === 'C' && scope.row.isFrame === '0'" type="danger" size="small">外链</el-tag>
<el-tag v-else-if="scope.row.menuType === 'C'" type="success" size="small">菜单</el-tag>
<el-tag v-else-if="scope.row.menuType === 'F'" type="warning" size="small">按钮</el-tag>
</template>
</el-table-column>
<el-table-column prop="orderNum" label="排序" width="200">
<template slot-scope="scope">
<el-input-number v-model="scope.row.orderNum" controls-position="right" :min="0" size="mini" style="width: 88px" />
</template>
</el-table-column>
<el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true" />
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true" />
<el-table-column prop="status" label="状态" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:menu:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['system:menu:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:menu:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改菜单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="680px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="24">
<el-form-item label="上级菜单" prop="parentId">
<treeselect
v-model="form.parentId"
:options="menuOptions"
:normalizer="normalizer"
:show-count="true"
placeholder="选择上级菜单"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="菜单类型" prop="menuType">
<el-radio-group v-model="form.menuType">
<el-radio label="M">目录</el-radio>
<el-radio label="C">菜单</el-radio>
<el-radio label="F">按钮</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item label="菜单图标" prop="icon">
<el-popover
placement="bottom-start"
width="460"
trigger="click"
@show="$refs['iconSelect'].reset()"
>
<IconSelect ref="iconSelect" @selected="selected" :active-icon="form.icon" />
<el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly>
<svg-icon
v-if="form.icon"
slot="prefix"
:icon-class="form.icon"
style="width: 25px;"
/>
<i v-else slot="prefix" class="el-icon-search el-input__icon" />
</el-input>
</el-popover>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="显示排序" prop="orderNum">
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="菜单名称" prop="menuName">
<el-input v-model="form.menuName" placeholder="请输入菜单名称" />
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType == 'C'">
<el-form-item prop="routeName">
<el-input v-model="form.routeName" placeholder="请输入路由名称" />
<span slot="label">
<el-tooltip content="默认不填则和路由地址相同:如地址为:`user`,则名称为`User`(注意:为避免名字的冲突,特殊情况下请自定义,保证唯一性)" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
路由名称
</span>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item prop="isFrame">
<span slot="label">
<el-tooltip content="选择是外链则路由地址需要以`http(s)://`开头" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
是否外链
</span>
<el-radio-group v-model="form.isFrame">
<el-radio label="0">是</el-radio>
<el-radio label="1">否</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item prop="path">
<span slot="label">
<el-tooltip content="访问的路由地址,如:`user`,如外网地址需内链访问则以`http(s)://`开头" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
路由地址
</span>
<el-input v-model="form.path" placeholder="请输入路由地址" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12" v-if="form.menuType == 'C'">
<el-form-item prop="component">
<span slot="label">
<el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
组件路径
</span>
<el-input v-model="form.component" placeholder="请输入组件路径" />
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType != 'M'">
<el-form-item prop="perms">
<el-input v-model="form.perms" placeholder="请输入权限标识" maxlength="100" />
<span slot="label">
<el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
权限字符
</span>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12" v-if="form.menuType == 'C'">
<el-form-item prop="query">
<el-input v-model="form.query" placeholder="请输入路由参数" maxlength="255" />
<span slot="label">
<el-tooltip content='访问路由的默认传递参数,如:`{"id": 1, "name": "ry"}`' placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
路由参数
</span>
</el-form-item>
</el-col>
<el-col :span="12" v-if="form.menuType == 'C'">
<el-form-item prop="isCache">
<span slot="label">
<el-tooltip content="选择是则会被`keep-alive`缓存,需要匹配组件的`name`和地址保持一致" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
是否缓存
</span>
<el-radio-group v-model="form.isCache">
<el-radio label="0">缓存</el-radio>
<el-radio label="1">不缓存</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12" v-if="form.menuType != 'F'">
<el-form-item prop="visible">
<span slot="label">
<el-tooltip content="选择隐藏则路由将不会出现在侧边栏,但仍然可以访问" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
显示状态
</span>
<el-radio-group v-model="form.visible">
<el-radio
v-for="dict in dict.type.sys_show_hide"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="status">
<span slot="label">
<el-tooltip content="选择停用则路由将不会出现在侧边栏,也不能被访问" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
菜单状态
</span>
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listMenu, getMenu, delMenu, addMenu, updateMenu, updateMenuSort } from "@/api/system/menu"
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
import IconSelect from "@/components/IconSelect"
export default {
name: "Menu",
dicts: ['sys_show_hide', 'sys_normal_disable'],
components: { Treeselect, IconSelect },
data() {
return {
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 菜单表格树数据
menuList: [],
// 菜单树选项
menuOptions: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否展开,默认全部折叠
isExpandAll: false,
// 重新渲染表格状态
refreshTable: true,
// 记录原始排序,用于对比变更
originalOrders: {},
// 查询参数
queryParams: {
menuName: undefined,
visible: undefined,
status: '0'
},
// 表单参数
form: {},
// 表单校验
rules: {
menuName: [
{ required: true, message: "菜单名称不能为空", trigger: "blur" }
],
orderNum: [
{ required: true, message: "菜单顺序不能为空", trigger: "blur" }
],
path: [
{ required: true, message: "路由地址不能为空", trigger: "blur" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
// 选择图标
selected(name) {
this.form.icon = name
},
/** 查询菜单列表 */
getList() {
this.loading = true
listMenu(this.queryParams).then(response => {
this.menuList = this.handleTree(response.data, "menuId")
// 记录原始排序值
this.recordOriginalOrders(this.menuList)
this.loading = false
})
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children
}
return {
id: node.menuId,
label: node.menuName,
children: node.children
}
},
/** 查询菜单下拉树结构 */
getTreeselect() {
listMenu().then(response => {
this.menuOptions = []
const menu = { menuId: 0, menuName: '主类目', children: [] }
menu.children = this.handleTree(response.data, "menuId")
this.menuOptions.push(menu)
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
menuId: undefined,
parentId: 0,
menuName: undefined,
icon: undefined,
menuType: "M",
orderNum: undefined,
isFrame: "1",
isCache: "0",
visible: "0",
status: "0"
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset()
this.getTreeselect()
if (row != null && row.menuId) {
this.form.parentId = row.menuId
} else {
this.form.parentId = 0
}
this.open = true
this.title = "添加菜单"
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false
this.isExpandAll = !this.isExpandAll
this.$nextTick(() => {
this.refreshTable = true
})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
this.getTreeselect()
getMenu(row.menuId).then(response => {
this.form = response.data
this.open = true
this.title = "修改菜单"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.menuId != undefined) {
updateMenu(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addMenu(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 递归记录原始排序 */
recordOriginalOrders(list) {
list.forEach(item => {
this.originalOrders[item.menuId] = item.orderNum
if (item.children && item.children.length) {
this.recordOriginalOrders(item.children)
}
})
},
/** 保存排序 */
handleSaveSort() {
const changedMenuIds = []
const changedOrderNums = []
const collectChanged = (list) => {
list.forEach(item => {
if (String(this.originalOrders[item.menuId]) !== String(item.orderNum)) {
changedMenuIds.push(item.menuId)
changedOrderNums.push(item.orderNum)
}
if (item.children && item.children.length) {
collectChanged(item.children)
}
})
}
collectChanged(this.menuList)
if (changedMenuIds.length === 0) {
this.$modal.msgWarning("未检测到排序修改")
return
}
updateMenuSort({ menuIds: changedMenuIds.join(","), orderNums: changedOrderNums.join(",") }).then(() => {
this.$modal.msgSuccess("排序保存成功")
this.recordOriginalOrders(this.menuList)
})
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?').then(function() {
return delMenu(row.menuId)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
}
}
</script>
<style scoped>
.system-menu ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-menu ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-menu ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-menu ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
@@ -0,0 +1,109 @@
<template>
<el-dialog :title="`「${noticeTitle}」已读用户`" :visible.sync="visible" width="760px" top="6vh" append-to-body @close="handleClose">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" style="margin-bottom: 4px;">
<el-form-item prop="searchValue">
<el-input
v-model="queryParams.searchValue"
placeholder="登录名称 / 用户名称"
clearable
prefix-icon="el-icon-search"
style="width: 220px;"
@keyup.enter.native="handleQuery"
@clear="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item style="float: right; margin-right: 0;">
<span class="read-stat">
共 <strong>{{ total }}</strong> 人已读
</span>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="userList" size="small" stripe height="340px">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column label="登录名称" prop="userName" align="center" :show-overflow-tooltip="true" />
<el-table-column label="用户名称" prop="nickName" align="center" :show-overflow-tooltip="true" />
<el-table-column label="所属部门" prop="deptName" align="center" :show-overflow-tooltip="true" />
<el-table-column label="手机号码" prop="phonenumber" align="center" width="120" />
<el-table-column label="阅读时间" prop="readTime" align="center" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.readTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" style="padding: 6px 0px;"/>
</el-dialog>
</template>
<script>
import { listNoticeReadUsers } from "@/api/system/notice"
export default {
name: "ReadUsers",
data() {
return {
visible: false,
loading: false,
noticeId: undefined,
noticeTitle: "",
total: 0,
userList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
noticeId: undefined,
searchValue: undefined
}
}
},
methods: {
open(row) {
this.noticeId = row.noticeId
this.noticeTitle = row.noticeTitle
this.queryParams.noticeId = row.noticeId
this.queryParams.searchValue = undefined
this.queryParams.pageNum = 1
this.visible = true
this.getList()
},
getList() {
this.loading = true
listNoticeReadUsers(this.queryParams).then(res => {
this.userList = res.rows
this.total = res.total
}).finally(() => {
this.loading = false
})
},
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
handleClose() {
this.userList = []
this.total = 0
this.queryParams.searchValue = undefined
}
}
}
</script>
<style scoped>
.read-stat {
font-size: 13px;
color: #606266;
line-height: 28px;
}
.read-stat strong {
color: #00875A;
font-size: 15px;
margin: 0 2px;
}
</style>
+369
View File
@@ -0,0 +1,369 @@
<template>
<div class="app-container system-notice">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input
v-model="queryParams.noticeTitle"
placeholder="请输入公告标题"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="操作人员" prop="createBy">
<el-input
v-model="queryParams.createBy"
placeholder="请输入操作人员"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="noticeType">
<el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable>
<el-option
v-for="dict in dict.type.sys_notice_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:notice:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:notice:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:notice:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" prop="noticeId" width="100" />
<el-table-column label="公告标题" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<a class="link-type" style="cursor:pointer" @click="handleViewData(scope.row)">{{ scope.row.noticeTitle }}</a>
</template>
</el-table-column>
<el-table-column label="公告类型" align="center" prop="noticeType" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_notice_type" :value="scope.row.noticeType"/>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_notice_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-user"
@click="handleReadUsers(scope.row)"
v-hasPermi="['system:notice:list']"
>阅读用户</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:notice:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:notice:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改公告对话框 -->
<el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="公告标题" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入公告标题" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公告类型" prop="noticeType">
<el-select v-model="form.noticeType" placeholder="请选择公告类型">
<el-option
v-for="dict in dict.type.sys_notice_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_notice_status"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="内容">
<editor v-model="form.noticeContent" :min-height="192"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<notice-detail-view ref="noticeViewRef" />
<read-users-dialog ref="readUsersRef" />
</div>
</template>
<script>
import NoticeDetailView from "@/layout/components/HeaderNotice/DetailView"
import ReadUsersDialog from "./ReadUsers"
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"
export default {
name: "Notice",
components: { NoticeDetailView, ReadUsersDialog },
dicts: ['sys_notice_status', 'sys_notice_type'],
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 公告表格数据
noticeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
noticeTitle: undefined,
createBy: undefined,
status: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
noticeTitle: [
{ required: true, message: "公告标题不能为空", trigger: "blur" }
],
noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "change" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
/** 获取表格高度 */
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询公告列表 */
getList() {
this.loading = true
listNotice(this.queryParams).then(response => {
this.noticeList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
noticeId: undefined,
noticeTitle: undefined,
noticeType: undefined,
noticeContent: undefined,
status: "0"
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.noticeId)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加公告"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => {
this.form = response.data
this.open = true
this.title = "修改公告"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.noticeId != undefined) {
updateNotice(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addNotice(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 查看公告详情 */
handleViewData(row) {
this.$refs.noticeViewRef.open(row)
},
/** 查看已读用户 */
handleReadUsers(row) {
this.$refs.readUsersRef.open(row)
},
/** 删除按钮操作 */
handleDelete(row) {
const noticeIds = row.noticeId || this.ids
this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() {
return delNotice(noticeIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
}
}
</script>
<style scoped>
.system-notice ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-notice ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-notice ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-notice ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+342
View File
@@ -0,0 +1,342 @@
<template>
<div class="app-container system-post">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="岗位编码" prop="postCode">
<el-input
v-model="queryParams.postCode"
placeholder="请输入岗位编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="岗位名称" prop="postName">
<el-input
v-model="queryParams.postName"
placeholder="请输入岗位名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:post:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:post:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:post:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:post:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="岗位编号" align="center" prop="postId" />
<el-table-column label="岗位编码" align="center" prop="postCode" />
<el-table-column label="岗位名称" align="center" prop="postName" />
<el-table-column label="岗位排序" align="center" prop="postSort" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:post:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:post:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改岗位对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="岗位名称" prop="postName">
<el-input v-model="form.postName" placeholder="请输入岗位名称" />
</el-form-item>
<el-form-item label="岗位编码" prop="postCode">
<el-input v-model="form.postCode" placeholder="请输入编码名称" />
</el-form-item>
<el-form-item label="岗位顺序" prop="postSort">
<el-input-number v-model="form.postSort" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="岗位状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post"
export default {
name: "Post",
dicts: ['sys_normal_disable'],
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 岗位表格数据
postList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
postCode: undefined,
postName: undefined,
status: '0'
},
// 表单参数
form: {},
// 表单校验
rules: {
postName: [
{ required: true, message: "岗位名称不能为空", trigger: "blur" }
],
postCode: [
{ required: true, message: "岗位编码不能为空", trigger: "blur" }
],
postSort: [
{ required: true, message: "岗位顺序不能为空", trigger: "blur" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
/** 获取表格高度 */
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询岗位列表 */
getList() {
this.loading = true
listPost(this.queryParams).then(response => {
this.postList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
postId: undefined,
postCode: undefined,
postName: undefined,
postSort: 0,
status: "0",
remark: undefined
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.postId)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加岗位"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const postId = row.postId || this.ids
getPost(postId).then(response => {
this.form = response.data
this.open = true
this.title = "修改岗位"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.postId != undefined) {
updatePost(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addPost(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const postIds = row.postId || this.ids
this.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?').then(function() {
return delPost(postIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/post/export', {
...this.queryParams
}, `post_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.system-post ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-post ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-post ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-post ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+234
View File
@@ -0,0 +1,234 @@
<template>
<div class="app-container system-role-auth-user">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="手机号码" prop="phonenumber">
<el-input
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="openSelectUser"
v-hasPermi="['system:role:add']"
>添加用户</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-circle-close"
size="mini"
:disabled="multiple"
@click="cancelAuthUserAll"
v-hasPermi="['system:role:remove']"
>批量取消授权</el-button>
</el-col>
<el-col :span="1.5">
<el-button
icon="el-icon-close"
size="mini"
@click="handleClose"
>关闭</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-circle-close"
@click="cancelAuthUser(scope.row)"
v-hasPermi="['system:role:remove']"
>取消授权</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<select-user ref="select" :roleId="queryParams.roleId" @ok="handleQuery" />
</div>
</template>
<script>
import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role"
import selectUser from "./selectUser"
export default {
name: "AuthUser",
dicts: ['sys_normal_disable'],
components: { selectUser },
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 选中用户组
userIds: [],
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 用户表格数据
userList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
roleId: undefined,
userName: undefined,
phonenumber: undefined
}
}
},
created() {
const roleId = this.$route.params && this.$route.params.roleId
if (roleId) {
this.queryParams.roleId = roleId
this.getList()
}
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
/** 获取表格高度 */
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询授权用户列表 */
getList() {
this.loading = true
allocatedUserList(this.queryParams).then(response => {
this.userList = response.rows
this.total = response.total
this.loading = false
}
)
},
// 返回按钮
handleClose() {
const obj = { path: "/system/role" }
this.$tab.closeOpenPage(obj)
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.userIds = selection.map(item => item.userId)
this.multiple = !selection.length
},
/** 打开授权用户表弹窗 */
openSelectUser() {
this.$refs.select.show()
},
/** 取消授权按钮操作 */
cancelAuthUser(row) {
const roleId = this.queryParams.roleId
this.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?').then(function() {
return authUserCancel({ userId: row.userId, roleId: roleId })
}).then(() => {
this.getList()
this.$modal.msgSuccess("取消授权成功")
}).catch(() => {})
},
/** 批量取消授权按钮操作 */
cancelAuthUserAll() {
const roleId = this.queryParams.roleId
const userIds = this.userIds.join(",")
this.$modal.confirm('是否取消选中用户授权数据项?').then(function() {
return authUserCancelAll({ roleId: roleId, userIds: userIds })
}).then(() => {
this.getList()
this.$modal.msgSuccess("取消授权成功")
}).catch(() => {})
}
}
}
</script>
<style scoped>
.system-role-auth-user ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-role-auth-user ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-role-auth-user ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-role-auth-user ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+633
View File
@@ -0,0 +1,633 @@
<template>
<div class="app-container system-role">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="角色名称" prop="roleName">
<el-input
v-model="queryParams.roleName"
placeholder="请输入角色名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="权限字符" prop="roleKey">
<el-input
v-model="queryParams.roleKey"
placeholder="请输入权限字符"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:role:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:role:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:role:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:role:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="角色编号" prop="roleId" width="120" />
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" />
<el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" />
<el-table-column label="显示顺序" prop="roleSort" width="100" />
<el-table-column label="状态" align="center" width="100">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:role:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:role:remove']"
>删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleDataScope" icon="el-icon-circle-check"
v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item>
<el-dropdown-item command="handleAuthUser" icon="el-icon-user"
v-hasPermi="['system:role:edit']">分配用户</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改角色配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="角色名称" prop="roleName">
<el-input v-model="form.roleName" placeholder="请输入角色名称" />
</el-form-item>
<el-form-item prop="roleKey">
<span slot="label">
<el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
权限字符
</span>
<el-input v-model="form.roleKey" placeholder="请输入权限字符" />
</el-form-item>
<el-form-item label="角色顺序" prop="roleSort">
<el-input-number v-model="form.roleSort" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="菜单权限">
<el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>
<el-tree
class="tree-border"
:data="menuOptions"
show-checkbox
ref="menu"
node-key="id"
:check-strictly="!form.menuCheckStrictly"
empty-text="加载中,请稍候"
:props="defaultProps"
></el-tree>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!-- 分配角色数据权限对话框 -->
<el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body>
<el-form :model="form" label-width="80px">
<el-form-item label="角色名称">
<el-input v-model="form.roleName" :disabled="true" />
</el-form-item>
<el-form-item label="权限字符">
<el-input v-model="form.roleKey" :disabled="true" />
</el-form-item>
<el-form-item label="权限范围">
<el-select v-model="form.dataScope" @change="dataScopeSelectChange">
<el-option
v-for="item in dataScopeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数据权限" v-show="form.dataScope == 2">
<el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox>
<el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox>
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox>
<el-tree
class="tree-border"
:data="deptOptions"
show-checkbox
default-expand-all
ref="dept"
node-key="id"
:check-strictly="!form.deptCheckStrictly"
empty-text="加载中,请稍候"
:props="defaultProps"
></el-tree>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitDataScope">确 定</el-button>
<el-button @click="cancelDataScope">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role"
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"
export default {
name: "Role",
dicts: ['sys_normal_disable'],
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 角色表格数据
roleList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否显示弹出层(数据权限)
openDataScope: false,
menuExpand: false,
menuNodeAll: false,
deptExpand: true,
deptNodeAll: false,
// 日期范围
dateRange: [],
// 数据范围选项
dataScopeOptions: [
{
value: "1",
label: "全部数据权限"
},
{
value: "2",
label: "自定数据权限"
},
{
value: "3",
label: "本部门数据权限"
},
{
value: "4",
label: "本部门及以下数据权限"
},
{
value: "5",
label: "仅本人数据权限"
}
],
// 菜单列表
menuOptions: [],
// 部门列表
deptOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
roleName: undefined,
roleKey: undefined,
status: '0'
},
// 表单参数
form: {},
defaultProps: {
children: "children",
label: "label"
},
// 表单校验
rules: {
roleName: [
{ required: true, message: "角色名称不能为空", trigger: "blur" }
],
roleKey: [
{ required: true, message: "权限字符不能为空", trigger: "blur" }
],
roleSort: [
{ required: true, message: "角色顺序不能为空", trigger: "blur" }
]
}
}
},
created() {
this.getList()
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
/** 获取表格高度 */
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询角色列表 */
getList() {
this.loading = true
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.roleList = response.rows
this.total = response.total
this.loading = false
}
)
},
/** 查询菜单树结构 */
getMenuTreeselect() {
menuTreeselect().then(response => {
this.menuOptions = response.data
})
},
// 所有菜单节点数据
getMenuAllCheckedKeys() {
// 目前被选中的菜单节点
let checkedKeys = this.$refs.menu.getCheckedKeys()
// 半选中的菜单节点
let halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys()
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
return checkedKeys
},
// 所有部门节点数据
getDeptAllCheckedKeys() {
// 目前被选中的部门节点
let checkedKeys = this.$refs.dept.getCheckedKeys()
// 半选中的部门节点
let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys()
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
return checkedKeys
},
/** 根据角色ID查询菜单树结构 */
getRoleMenuTreeselect(roleId) {
return roleMenuTreeselect(roleId).then(response => {
this.menuOptions = response.menus
return response
})
},
/** 根据角色ID查询部门树结构 */
getDeptTree(roleId) {
return deptTreeSelect(roleId).then(response => {
this.deptOptions = response.depts
return response
})
},
// 角色状态修改
handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"
this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function() {
return changeRoleStatus(row.roleId, row.status)
}).then(() => {
this.$modal.msgSuccess(text + "成功")
}).catch(function() {
row.status = row.status === "0" ? "1" : "0"
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 取消按钮(数据权限)
cancelDataScope() {
this.openDataScope = false
this.reset()
},
// 表单重置
reset() {
if (this.$refs.menu != undefined) {
this.$refs.menu.setCheckedKeys([])
}
this.menuExpand = false,
this.menuNodeAll = false,
this.deptExpand = true,
this.deptNodeAll = false,
this.form = {
roleId: undefined,
roleName: undefined,
roleKey: undefined,
roleSort: 0,
status: "0",
menuIds: [],
deptIds: [],
menuCheckStrictly: true,
deptCheckStrictly: true,
remark: undefined
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.roleId)
this.single = selection.length != 1
this.multiple = !selection.length
},
// 更多操作触发
handleCommand(command, row) {
switch (command) {
case "handleDataScope":
this.handleDataScope(row)
break
case "handleAuthUser":
this.handleAuthUser(row)
break
default:
break
}
},
// 树权限(展开/折叠)
handleCheckedTreeExpand(value, type) {
if (type == 'menu') {
let treeList = this.menuOptions
for (let i = 0; i < treeList.length; i++) {
this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value
}
} else if (type == 'dept') {
let treeList = this.deptOptions
for (let i = 0; i < treeList.length; i++) {
this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value
}
}
},
// 树权限(全选/全不选)
handleCheckedTreeNodeAll(value, type) {
if (type == 'menu') {
this.$refs.menu.setCheckedNodes(value ? this.menuOptions: [])
} else if (type == 'dept') {
this.$refs.dept.setCheckedNodes(value ? this.deptOptions: [])
}
},
// 树权限(父子联动)
handleCheckedTreeConnect(value, type) {
if (type == 'menu') {
this.form.menuCheckStrictly = value ? true: false
} else if (type == 'dept') {
this.form.deptCheckStrictly = value ? true: false
}
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.getMenuTreeselect()
this.open = true
this.title = "添加角色"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const roleId = row.roleId || this.ids
const roleMenu = this.getRoleMenuTreeselect(roleId)
getRole(roleId).then(response => {
this.form = response.data
this.open = true
this.$nextTick(() => {
roleMenu.then(res => {
let checkedKeys = res.checkedKeys
checkedKeys.forEach((v) => {
this.$nextTick(()=>{
this.$refs.menu.setChecked(v, true ,false)
})
})
})
})
})
this.title = "修改角色"
},
/** 选择角色权限范围触发 */
dataScopeSelectChange(value) {
if (value !== '2') {
this.$refs.dept.setCheckedKeys([])
}
},
/** 分配数据权限操作 */
handleDataScope(row) {
this.reset()
const deptTreeSelect = this.getDeptTree(row.roleId)
getRole(row.roleId).then(response => {
this.form = response.data
this.openDataScope = true
this.$nextTick(() => {
deptTreeSelect.then(res => {
this.$refs.dept.setCheckedKeys(res.checkedKeys)
})
})
})
this.title = "分配数据权限"
},
/** 分配用户操作 */
handleAuthUser(row) {
const roleId = row.roleId
this.$router.push("/system/role-auth/user/" + roleId)
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.roleId != undefined) {
this.form.menuIds = this.getMenuAllCheckedKeys()
updateRole(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
this.form.menuIds = this.getMenuAllCheckedKeys()
addRole(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 提交按钮(数据权限) */
submitDataScope() {
if (this.form.roleId != undefined) {
this.form.deptIds = this.getDeptAllCheckedKeys()
dataScope(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.openDataScope = false
this.getList()
})
}
},
/** 删除按钮操作 */
handleDelete(row) {
const roleIds = row.roleId || this.ids
this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() {
return delRole(roleIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/role/export', {
...this.queryParams
}, `role_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.system-role ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-role ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-role ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-role ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
@@ -0,0 +1,136 @@
<template>
<!-- 授权用户 -->
<el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="手机号码" prop="phonenumber">
<el-input
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row>
<el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSelectUser">确 定</el-button>
<el-button @click="visible = false">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import { unallocatedUserList, authUserSelectAll } from "@/api/system/role"
export default {
dicts: ['sys_normal_disable'],
props: {
// 角色编号
roleId: {
type: [Number, String]
}
},
data() {
return {
// 遮罩层
visible: false,
// 选中数组值
userIds: [],
// 总条数
total: 0,
// 未授权用户数据
userList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
roleId: undefined,
userName: undefined,
phonenumber: undefined
}
}
},
methods: {
// 显示弹框
show() {
this.queryParams.roleId = this.roleId
this.getList()
this.visible = true
},
clickRow(row) {
this.$refs.table.toggleRowSelection(row)
},
// 多选框选中数据
handleSelectionChange(selection) {
this.userIds = selection.map(item => item.userId)
},
// 查询表数据
getList() {
unallocatedUserList(this.queryParams).then(res => {
this.userList = res.rows
this.total = res.total
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 选择授权用户操作 */
handleSelectUser() {
const roleId = this.queryParams.roleId
const userIds = this.userIds.join(",")
if (userIds == "") {
this.$modal.msgError("请选择要分配的用户")
return
}
authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => {
this.$modal.msgSuccess(res.msg)
this.visible = false
this.$emit("ok")
})
}
}
}
</script>
+152
View File
@@ -0,0 +1,152 @@
<template>
<div class="app-container system-user-auth-role">
<h4 class="form-header h4">基本信息</h4>
<el-form ref="form" :model="form" label-width="80px">
<el-row>
<el-col :span="8" :offset="2">
<el-form-item label="用户昵称" prop="nickName">
<el-input v-model="form.nickName" disabled />
</el-form-item>
</el-col>
<el-col :span="8" :offset="2">
<el-form-item label="登录账号" prop="userName">
<el-input v-model="form.userName" disabled />
</el-form-item>
</el-col>
</el-row>
</el-form>
<h4 class="form-header h4">角色信息</h4>
<el-table v-loading="loading" :row-key="getRowKey" @row-click="clickRow" ref="table" @selection-change="handleSelectionChange" :data="roles.slice((pageNum-1)*pageSize,pageNum*pageSize)" :height="tableHeight">
<el-table-column label="序号" type="index" align="center">
<template slot-scope="scope">
<span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column type="selection" :reserve-selection="true" :selectable="checkSelectable" width="55" />
<el-table-column label="角色编号" align="center" prop="roleId" />
<el-table-column label="角色名称" align="center" prop="roleName" />
<el-table-column label="权限字符" align="center" prop="roleKey" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-120px;margin-top:30px;">
<el-button type="primary" @click="submitForm()">提交</el-button>
<el-button @click="close()">返回</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { getAuthRole, updateAuthRole } from "@/api/system/user"
export default {
name: "AuthRole",
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 分页信息
total: 0,
pageNum: 1,
pageSize: 10,
// 选中角色编号
roleIds: [],
// 角色信息
roles: [],
// 用户信息
form: {}
}
},
created() {
const userId = this.$route.params && this.$route.params.userId
if (userId) {
this.loading = true
getAuthRole(userId).then((response) => {
this.form = response.user
this.roles = response.roles
this.total = this.roles.length
this.$nextTick(() => {
this.roles.forEach((row) => {
if (row.flag) {
this.$refs.table.toggleRowSelection(row)
}
})
})
this.loading = false
})
}
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
methods: {
/** 获取表格高度 */
getTableHeight() {
this.tableHeight = window.innerHeight - 240
},
/** 单击选中行数据 */
clickRow(row) {
if (this.checkSelectable(row)) {
this.$refs.table.toggleRowSelection(row)
}
},
// 多选框选中数据
handleSelectionChange(selection) {
this.roleIds = selection.map((item) => item.roleId)
},
// 保存选中的数据编号
getRowKey(row) {
return row.roleId
},
// 检查角色状态
checkSelectable(row) {
return row.status === "0" ? true : false
},
/** 提交按钮 */
submitForm() {
const userId = this.form.userId
const roleIds = this.roleIds.join(",")
updateAuthRole({ userId: userId, roleIds: roleIds }).then(() => {
this.$modal.msgSuccess("授权成功")
this.close()
})
},
/** 关闭按钮 */
close() {
const obj = { path: "/system/user" }
this.$tab.closeOpenPage(obj)
}
}
}
</script>
<style scoped>
.system-user-auth-role ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-user-auth-role ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-user-auth-role ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-user-auth-role ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+510
View File
@@ -0,0 +1,510 @@
<template>
<div class="app-container tree-sidebar-manage-wrap system-user">
<tree-panel title="组织机构" :tree-data="deptOptions" search-placeholder="请输入部门名称" storage-key="dept-sidebar-width" :defaultExpandAll="true" @node-click="handleNodeClick" @refresh="getDeptTree" ref="deptTreeRef" />
<div class="tree-sidebar-content">
<div class="content-inner">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用户名称" prop="userName">
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="停用" prop="status">
<el-radio-group v-model="queryParams.status">
<el-radio label="0">否</el-radio>
<el-radio label="1">是</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:user:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:user:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:user:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange" :height="tableHeight">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns.userId.visible" />
<el-table-column label="用户名称" align="center" key="userName" v-if="columns.userName.visible" :show-overflow-tooltip="true">
<template slot-scope="scope">
<a class="link-type" style="cursor:pointer" @click="handleViewData(scope.row)">{{ scope.row.userName }}</a>
</template>
</el-table-column>
<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns.nickName.visible" :show-overflow-tooltip="true" />
<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns.deptName.visible" :show-overflow-tooltip="true" />
<el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns.phonenumber.visible" width="120" />
<el-table-column label="状态" align="center" key="status" v-if="columns.status.visible">
<template slot-scope="scope">
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" v-if="columns.createTime.visible" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
<template slot-scope="scope" v-if="scope.row.userId !== 1">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleResetPwd" icon="el-icon-key" v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
<el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check" v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
</div>
</div>
<!-- 添加或修改用户配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="用户昵称" prop="nickName">
<el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="deptId">
<treeselect v-model="form.deptId" :options="enabledDeptOptions" :show-count="true" placeholder="请选择归属部门" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
<el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password" :rules="pwdValidator">
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="用户性别">
<el-select v-model="form.sex" placeholder="请选择性别">
<el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="岗位">
<el-select v-model="form.postIds" multiple filterable placeholder="请选择岗位">
<el-option v-for="item in postOptions" :key="item.postId" :label="item.postName" :value="item.postId" :disabled="item.status == 1" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="角色">
<el-select v-model="form.roleIds" multiple filterable placeholder="请选择角色">
<el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId" :disabled="item.status == 1"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="备注">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!-- 用户详情抽屉 -->
<user-view-drawer ref="userViewRef" />
<!-- 用户导入对话框 -->
<excel-import-dialog ref="importUserRef" title="用户导入" action="/system/user/importData" template-action="/system/user/importTemplate" template-file-name="user_template" update-support-label="是否更新已经存在的用户数据" @success="getList" />
</div>
</template>
<script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user"
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
import TreePanel from "@/components/TreePanel"
import ExcelImportDialog from "@/components/ExcelImportDialog"
import UserViewDrawer from "./view"
import passwordRule from "@/utils/passwordRule"
export default {
name: "User",
mixins: [passwordRule],
dicts: ['sys_normal_disable', 'sys_user_sex'],
components: { Treeselect, TreePanel, ExcelImportDialog, UserViewDrawer },
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 240,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 用户表格数据
userList: null,
// 弹出层标题
title: "",
// 所有部门树选项
deptOptions: undefined,
// 过滤掉已禁用部门树选项
enabledDeptOptions: undefined,
// 是否显示弹出层
open: false,
// 默认密码
initPassword: undefined,
// 日期范围
dateRange: [],
// 岗位选项
postOptions: [],
// 角色选项
roleOptions: [],
// 表单参数
form: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
userName: undefined,
phonenumber: undefined,
status: '0',
deptId: undefined
},
// 列信息
columns: {
userId: { label: '用户编号', visible: true },
userName: { label: '用户名称', visible: true },
nickName: { label: '用户昵称', visible: true },
deptName: { label: '部门', visible: true },
phonenumber: { label: '手机号码', visible: true },
status: { label: '状态', visible: true },
createTime: { label: '创建时间', visible: true }
},
// 表单校验
rules: {
userName: [
{ required: true, message: "用户名称不能为空", trigger: "blur" },
{ min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' }
],
nickName: [
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
],
email: [
{
type: "email",
message: "请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
],
phonenumber: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
}
}
},
created() {
this.getList()
this.getDeptTree()
this.getConfigKey("sys.user.initPassword").then(response => {
this.initPassword = response.msg
})
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
/** 获取表格高度 */
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询用户列表 */
getList() {
this.loading = true
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.rows
this.total = response.total
this.loading = false
}).catch(() => {
this.loading = false
})
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data
this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)))
}).catch(() => {
this.deptOptions = []
this.enabledDeptOptions = []
})
},
// 过滤禁用的部门
filterDisabledDept(deptList) {
return deptList.filter(dept => {
if (dept.disabled) {
return false
}
if (dept.children && dept.children.length) {
dept.children = this.filterDisabledDept(dept.children)
}
return true
})
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.deptId = data.id
this.handleQuery()
},
// 用户状态修改
handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"
this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
return changeUserStatus(row.userId, row.status)
}).then(() => {
this.$modal.msgSuccess(text + "成功")
}).catch(function() {
row.status = row.status === "0" ? "1" : "0"
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
userId: undefined,
deptId: undefined,
userName: undefined,
nickName: undefined,
password: undefined,
phonenumber: undefined,
email: undefined,
sex: undefined,
status: "0",
remark: undefined,
postIds: [],
roleIds: []
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.queryParams.deptId = undefined
this.$refs.deptTreeRef.setCurrentKey(null)
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.userId)
this.single = selection.length != 1
this.multiple = !selection.length
},
// 更多操作触发
handleCommand(command, row) {
switch (command) {
case "handleResetPwd":
this.handleResetPwd(row)
break
case "handleAuthRole":
this.handleAuthRole(row)
break
default:
break
}
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
getUser().then(response => {
this.postOptions = response.posts
this.roleOptions = response.roles
this.open = true
this.title = "添加用户"
this.form.password = this.initPassword
})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const userId = row.userId || this.ids
getUser(userId).then(response => {
this.form = response.data
this.postOptions = response.posts
this.roleOptions = response.roles
this.$set(this.form, "postIds", response.postIds)
this.$set(this.form, "roleIds", response.roleIds)
this.open = true
this.title = "修改用户"
this.form.password = ""
})
},
/** 重置密码按钮操作 */
handleResetPwd(row) {
this.$prompt(`请输入「${row.userName}」的新密码`, "重置密码", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
inputValidator: this.pwdPromptValidator
}).then(({ value }) => {
resetUserPwd(row.userId, value).then(() => {
this.$modal.msgSuccess("修改成功,新密码是:" + value)
})
}).catch(() => {})
},
/** 分配角色操作 */
handleAuthRole(row) {
const userId = row.userId
this.$router.push("/system/user-auth/role/" + userId)
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.userId != undefined) {
updateUser(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addUser(this.form).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const userIds = row.userId || this.ids
this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function() {
return delUser(userIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/user/export', {
...this.queryParams
}, `user_${new Date().getTime()}.xlsx`)
},
/** 详情按钮操作 */
handleViewData(row) {
this.$refs.userViewRef.open(row.userId)
},
/** 导入按钮操作 */
handleImport() {
this.$refs.importUserRef.open()
}
}
}
</script>
<style scoped>
.system-user ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.system-user ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.system-user ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.system-user ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
@@ -0,0 +1,109 @@
<template>
<div class="app-container">
<el-row :gutter="20">
<el-col :span="6" :xs="24">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>个人信息</span>
</div>
<div>
<div class="text-center">
<userAvatar />
</div>
<ul class="list-group list-group-striped">
<li class="list-group-item">
<svg-icon icon-class="user" />用户名称
<div class="pull-right">{{ user.userName }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="phone" />手机号码
<div class="pull-right">{{ user.phonenumber }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="email" />用户邮箱
<div class="pull-right">{{ user.email }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="tree" />所属部门
<div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="peoples" />所属角色
<div class="pull-right">{{ roleGroup }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="date" />创建日期
<div class="pull-right">{{ user.createTime }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="login" />上次登录时间
<div class="pull-right">{{ loginStats.LAST_LOGIN_TIME || '首次登录' }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="online" />登录次数
<div class="pull-right">{{ loginStats.LOGIN_COUNT || 0 }}次</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="ip" />最后登录IP
<div class="pull-right">{{ loginStats.LAST_LOGIN_IP || '-' }}</div>
</li>
</ul>
</div>
</el-card>
</el-col>
<el-col :span="18" :xs="24">
<el-card>
<div slot="header" class="clearfix">
<span>基本资料</span>
</div>
<el-tabs v-model="selectedTab">
<el-tab-pane label="基本资料" name="userinfo">
<userInfo :user="user" />
</el-tab-pane>
<el-tab-pane label="修改密码" name="resetPwd">
<resetPwd />
</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import userAvatar from "./userAvatar"
import userInfo from "./userInfo"
import resetPwd from "./resetPwd"
import { getUserProfile } from "@/api/system/user"
export default {
name: "Profile",
components: { userAvatar, userInfo, resetPwd },
data() {
return {
user: {},
roleGroup: {},
postGroup: {},
loginStats: {},
selectedTab: "userinfo"
}
},
created() {
const activeTab = this.$route.params && this.$route.params.activeTab
if (activeTab) {
this.selectedTab = activeTab
}
this.getUser()
},
methods: {
getUser() {
getUserProfile().then(response => {
this.user = response.data
this.roleGroup = response.roleGroup
this.postGroup = response.postGroup
this.loginStats = response.loginStats || {}
})
}
}
}
</script>
@@ -0,0 +1,70 @@
<template>
<el-form ref="form" :model="user" :rules="formRules" label-width="80px">
<el-form-item label="旧密码" prop="oldPassword">
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password/>
</el-form-item>
<el-form-item label="新密码" prop="newPassword" :rules="infoPwdValidator">
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password/>
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="user.confirmPassword" placeholder="请确认新密码" type="password" show-password/>
</el-form-item>
<el-form-item>
<el-button type="primary" size="mini" @click="submit">保存</el-button>
<el-button size="mini" @click="close">关闭</el-button>
</el-form-item>
</el-form>
</template>
<script>
import { updateUserPwd } from "@/api/system/user"
import passwordRule from "@/utils/passwordRule"
export default {
mixins: [passwordRule],
data() {
return {
user: {
oldPassword: undefined,
newPassword: undefined,
confirmPassword: undefined
}
}
},
computed: {
formRules() {
return {
oldPassword: [
{ required: true, message: "旧密码不能为空", trigger: "blur" }
],
confirmPassword: [
{ required: true, message: "确认密码不能为空", trigger: "blur" },
{
validator: (rule, value, callback) => {
if (this.user.newPassword !== value) {
callback(new Error("两次输入的密码不一致"))
} else {
callback()
}
}, trigger: "blur"
}
]
}
}
},
methods: {
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(() => {
this.$modal.msgSuccess("修改成功")
})
}
})
},
close() {
this.$tab.closePage()
}
}
}
</script>
@@ -0,0 +1,184 @@
<template>
<div>
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div>
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
<el-row>
<el-col :xs="24" :md="12" :style="{height: '350px'}">
<vue-cropper
ref="cropper"
:img="options.img"
:info="true"
:autoCrop="options.autoCrop"
:autoCropWidth="options.autoCropWidth"
:autoCropHeight="options.autoCropHeight"
:fixedBox="options.fixedBox"
:outputType="options.outputType"
@realTime="realTime"
v-if="visible"
/>
</el-col>
<el-col :xs="24" :md="12" :style="{height: '350px'}">
<div class="avatar-upload-preview">
<img :src="previews.url" :style="previews.img" />
</div>
</el-col>
</el-row>
<br />
<el-row>
<el-col :lg="2" :sm="3" :xs="3">
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
<el-button size="small">
选择
<i class="el-icon-upload el-icon--right"></i>
</el-button>
</el-upload>
</el-col>
<el-col :lg="{span: 1, offset: 2}" :sm="2" :xs="2">
<el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button>
</el-col>
<el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2">
<el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button>
</el-col>
<el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2">
<el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button>
</el-col>
<el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2">
<el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button>
</el-col>
<el-col :lg="{span: 2, offset: 6}" :sm="2" :xs="2">
<el-button type="primary" size="small" @click="uploadImg()">提 交</el-button>
</el-col>
</el-row>
</el-dialog>
</div>
</template>
<script>
import store from "@/store"
import { VueCropper } from "vue-cropper"
import { uploadAvatar } from "@/api/system/user"
import { debounce } from '@/utils'
export default {
components: { VueCropper },
data() {
return {
// 是否显示弹出层
open: false,
// 是否显示cropper
visible: false,
// 弹出层标题
title: "修改头像",
options: {
img: store.getters.avatar, //裁剪图片的地址
autoCrop: true, // 是否默认生成截图框
autoCropWidth: 200, // 默认生成截图框宽度
autoCropHeight: 200, // 默认生成截图框高度
fixedBox: true, // 固定截图框大小 不允许改变
outputType:"png", // 默认生成截图为PNG格式
filename: 'avatar' // 文件名称
},
previews: {},
resizeHandler: null
}
},
methods: {
// 编辑头像
editCropper() {
this.open = true
},
// 打开弹出层结束时的回调
modalOpened() {
this.visible = true
if (!this.resizeHandler) {
this.resizeHandler = debounce(() => {
this.refresh()
}, 100)
}
window.addEventListener("resize", this.resizeHandler)
},
// 刷新组件
refresh() {
this.$refs.cropper.refresh()
},
// 覆盖默认的上传行为
requestUpload() {
},
// 向左旋转
rotateLeft() {
this.$refs.cropper.rotateLeft()
},
// 向右旋转
rotateRight() {
this.$refs.cropper.rotateRight()
},
// 图片缩放
changeScale(num) {
num = num || 1
this.$refs.cropper.changeScale(num)
},
// 上传预处理
beforeUpload(file) {
if (file.type.indexOf("image/") == -1) {
this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。")
} else {
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => {
this.options.img = reader.result
this.options.filename = file.name
}
}
},
// 上传图片
uploadImg() {
this.$refs.cropper.getCropBlob(data => {
let formData = new FormData()
formData.append("avatarfile", data, this.options.filename)
uploadAvatar(formData).then(response => {
this.open = false
this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl
store.commit('SET_AVATAR', this.options.img)
this.$modal.msgSuccess("修改成功")
this.visible = false
})
})
},
// 实时预览
realTime(data) {
this.previews = data
},
// 关闭窗口
closeDialog() {
this.options.img = store.getters.avatar
this.visible = false
window.removeEventListener("resize", this.resizeHandler)
}
}
}
</script>
<style scoped lang="scss">
.user-info-head {
position: relative;
display: inline-block;
height: 120px;
}
.user-info-head:hover:after {
content: '+';
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
color: #eee;
background: rgba(0, 0, 0, 0.5);
font-size: 24px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
cursor: pointer;
line-height: 110px;
border-radius: 50%;
}
</style>
@@ -0,0 +1,88 @@
<template>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="用户昵称" prop="nickName">
<el-input v-model="form.nickName" maxlength="30" />
</el-form-item>
<el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="form.phonenumber" maxlength="11" />
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" maxlength="50" />
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.sex">
<el-radio label="0">男</el-radio>
<el-radio label="1">女</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" size="mini" @click="submit">保存</el-button>
<el-button size="mini" @click="close">关闭</el-button>
</el-form-item>
</el-form>
</template>
<script>
import { updateUserProfile } from "@/api/system/user"
export default {
props: {
user: {
type: Object
}
},
data() {
return {
form: {},
// 表单校验
rules: {
nickName: [
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
],
email: [
{ required: true, message: "邮箱地址不能为空", trigger: "blur" },
{
type: "email",
message: "请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
],
phonenumber: [
{ required: true, message: "手机号码不能为空", trigger: "blur" },
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
}
}
},
watch: {
user: {
handler(user) {
if (user) {
this.form = { nickName: user.nickName, phonenumber: user.phonenumber, email: user.email, sex: user.sex }
}
},
immediate: true
}
},
methods: {
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
updateUserProfile(this.form).then(() => {
this.$modal.msgSuccess("修改成功")
this.user.phonenumber = this.form.phonenumber
this.user.email = this.form.email
})
}
})
},
close() {
this.$tab.closePage()
}
}
}
</script>
+177
View File
@@ -0,0 +1,177 @@
<template>
<el-drawer title="用户信息详情" :visible.sync="visible" direction="rtl" size="68%" append-to-body :before-close="handleClose" custom-class="detail-drawer">
<div v-loading="loading" class="drawer-content">
<!-- 基本信息 -->
<h4 class="section-header">基本信息</h4>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">用户名称:</label>
<span class="info-value plaintext">{{ info.nickName }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">归属部门:</label>
<span class="info-value plaintext">{{ (info.dept && info.dept.deptName) }}</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">手机号码:</label>
<span class="info-value plaintext">{{ info.phonenumber }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">邮箱:</label>
<span class="info-value plaintext">{{ info.email }}</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">登录账号:</label>
<span class="info-value plaintext">{{ info.userName }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">用户状态:</label>
<span class="info-value plaintext">
<el-tag size="small" :type="info.status === '0' ? 'success' : 'danger'">{{ info.status === '0' ? '正常' : '停用' }}</el-tag>
</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">岗位:</label>
<span class="info-value plaintext">{{ postNames || '无岗位' }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">用户性别:</label>
<span class="info-value plaintext">{{ sexLabel }}</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="24">
<div class="info-item full-width">
<label class="info-label">角色:</label>
<span class="info-value plaintext">{{ roleNames || '无角色' }}</span>
</div>
</el-col>
</el-row>
<!-- 其他信息 -->
<h4 class="section-header">其他信息</h4>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">创建者:</label>
<span class="info-value plaintext">{{ info.createBy }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">创建时间:</label>
<span class="info-value plaintext">{{ info.createTime }}</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">更新者:</label>
<span class="info-value plaintext">{{ info.updateBy }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">更新时间:</label>
<span class="info-value plaintext">{{ info.updateTime }}</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="12">
<div class="info-item">
<label class="info-label">最后登录IP:</label>
<span class="info-value plaintext">{{ info.loginIp }}</span>
</div>
</el-col>
<el-col :span="12">
<div class="info-item">
<label class="info-label">最后登录时间:</label>
<span class="info-value plaintext">{{ info.loginDate }}</span>
</div>
</el-col>
</el-row>
<el-row :gutter="20" class="mb8">
<el-col :span="24">
<div class="info-item full-width">
<label class="info-label">备注:</label>
<span class="info-value plaintext">{{ info.remark }}</span>
</div>
</el-col>
</el-row>
</div>
</el-drawer>
</template>
<script>
import { getUser } from '@/api/system/user'
export default {
name: 'UserViewDrawer',
dicts: ['sys_user_sex'],
data() {
return {
visible: false,
loading: false,
info: {},
postOptions: [],
roleOptions: []
}
},
computed: {
sexLabel() {
return this.selectDictLabel(this.dict.type.sys_user_sex, this.info.sex) || '-'
},
postNames() {
if (!this.postOptions.length) return ''
const ids = this.info.postIds || []
return this.postOptions.filter(p => ids.includes(p.postId)).map(p => p.postName).join('、') || ''
},
roleNames() {
if (!this.roleOptions.length) return ''
const ids = this.info.roleIds || []
return this.roleOptions.filter(r => ids.includes(r.roleId)).map(r => r.roleName).join('、') || ''
}
},
methods: {
open(userId) {
this.visible = true
this.loading = true
getUser(userId).then(res => {
this.info = res.data || {}
this.postOptions = res.posts || []
this.roleOptions = res.roles || []
this.info.postIds = res.postIds || []
this.info.roleIds = res.roleIds || []
}).finally(() => {
this.loading = false
})
},
handleClose() {
this.visible = false
}
}
}
</script>
@@ -0,0 +1,860 @@
<template>
<div class="school-calendar-editor">
<!-- 标题栏 -->
<div class="sce-titlebar">
<div class="sce-title-left">
<span class="sce-semester-name">{{ semesterName }}</span>
</div>
<div class="sce-title-center">
<span class="sce-date-range">从 {{ dateRangeText }} ,共 {{ totalWeeks }} 周</span>
</div>
<div class="sce-title-right">
<i class="el-icon-close" title="关闭" @click="handleClose" />
</div>
</div>
<!-- 设置面板 -->
<div class="sce-panel">
<div class="sce-panel-row">
<span class="sce-label">事件名称:</span>
<el-input v-model="toolbar.eventName" size="small" class="sce-event-input" placeholder="请输入校历事件名称" />
<el-checkbox v-model="toolbar.bold" class="sce-cb">加粗显示</el-checkbox>
<el-checkbox v-model="toolbar.schedulable" class="sce-cb">可排课</el-checkbox>
<el-checkbox v-model="toolbar.mainCourse" class="sce-cb">正课</el-checkbox>
<el-checkbox v-model="toolbar.remarkShow" class="sce-cb">备注显示</el-checkbox>
<span class="sce-label">备注:</span>
<el-input
v-model="toolbar.remark"
size="small"
type="textarea"
:rows="1"
class="sce-remark-input"
resize="none"
placeholder="备注信息"
/>
</div>
<div class="sce-panel-row">
<el-button type="primary" size="small" icon="el-icon-check" @click="applyEvent">设定</el-button>
<el-button type="danger" size="small" icon="el-icon-delete" @click="deleteEvent">删除</el-button>
<el-button size="small" icon="el-icon-brush" @click="absorbEvent">吸取</el-button>
<el-button size="small" icon="el-icon-refresh" @click="refreshGrid">刷新</el-button>
<span class="sce-divider" />
<el-checkbox v-model="show78" class="sce-cb">显示78节</el-checkbox>
<el-checkbox v-model="showNight" class="sce-cb">显示晚上</el-checkbox>
<el-checkbox v-model="showLateNight" class="sce-cb">显示夜间</el-checkbox>
</div>
</div>
<!-- 时间编排区域 -->
<div ref="gridWrap" class="sce-grid-wrap" @mousedown="onGridMouseDown">
<table class="sce-grid" :class="{ 'is-selecting': selecting }">
<thead>
<tr>
<th class="sce-corner sce-th-weekno" :rowspan="2">周次</th>
<th class="sce-corner sce-th-weekrange" :rowspan="2">日期段</th>
<th v-for="col in visibleColumns" :key="'h1-' + col.colIndex" :colspan="1" class="sce-th-day">
{{ weekDayLabel(col.dayIndex) }}
</th>
</tr>
<tr>
<th v-for="col in visibleColumns" :key="'h2-' + col.colIndex" class="sce-th-slot">
{{ col.slotLabel }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="(week, wIdx) in weeks" :key="'w-' + wIdx">
<td class="sce-week-cell sce-weekno-cell">{{ wIdx + 1 }}</td>
<td class="sce-week-cell sce-weekrange-cell">{{ week.rangeText }}</td>
<td
v-for="col in visibleColumns"
:key="'c-' + wIdx + '-' + col.colIndex"
class="sce-cell"
:class="cellClass(wIdx, col)"
:data-key="cellKey(wIdx, col.colIndex)"
@dblclick="onCellDblClick(wIdx, col)"
>
<span v-if="getEvent(wIdx, col.colIndex) && getEvent(wIdx, col.colIndex).name" class="sce-event-name" :class="{ 'is-bold': getEvent(wIdx, col.colIndex).bold }">{{ getEvent(wIdx, col.colIndex).name }}</span>
<span v-else class="sce-date-num">{{ dateNumberOf(wIdx, col.dayIndex) }}</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="sce-status">
已选 {{ selectedKeys.length }} 个时间格
<span v-if="absorbPreview" class="sce-absorb-tip">已吸取:{{ absorbPreview }}</span>
</div>
</div>
</template>
<script>
import { getSemester } from '@/api/teachBusiness/semester'
import { listXqxlb, addXqxlb, updateXqxlb } from '@/api/teachBusiness/xqxlb'
// 节次定义:12/34/56 常显,78/晚上/夜间由开关控制可见
const SLOT_DEFS = [
{ key: '12', label: '1-2', ctrl: null },
{ key: '34', label: '3-4', ctrl: null },
{ key: '56', label: '5-6', ctrl: null },
{ key: '78', label: '7-8', ctrl: 'show78' },
{ key: 'night', label: '晚上', ctrl: 'showNight' },
{ key: 'late', label: '夜间', ctrl: 'showLateNight' }
]
// 前端节次 key -> 后端 xqxlb.courseClass 节次范围(如 12 节 -> "1-2"、夜间 -> "11-12")
const SLOT_COURSE_MAP = {
'12': '1-2',
'34': '3-4',
'56': '5-6',
'78': '7-8',
night: '9-10',
late: '11-12'
}
const WEEK_DAYS = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
function pad2(n) {
return n < 10 ? '0' + n : '' + n
}
function fmtDate(d) {
return d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate())
}
// 生成 32 位小写 UUID(去横线),与后端 UuidUtil.getUUID 一致,用于 bh 缺失时兜底
function genUUID() {
let s = ''
const chars = '0123456789abcdef'
for (let i = 0; i < 32; i++) {
s += chars[Math.floor(Math.random() * 16)]
}
return s
}
export default {
name: 'SchoolCalendarEditor',
props: {
nd: { type: [String, Number], default: '' },
semesterName: { type: String, default: '' }
},
data() {
return {
// 学期日期范围
startDate: null,
endDate: null,
// 日历渲染起点(学期当周周一)
calendarStart: null,
totalWeeks: 0,
dateRangeText: '',
weeks: [],
// 显示开关(默认不勾选,每天仅显示 1-2/3-4/5-6 三个节次)
show78: false,
showNight: false,
showLateNight: false,
// 工具栏表单
toolbar: {
eventName: '',
bold: false,
schedulable: false,
mainCourse: false,
remarkShow: false,
remark: ''
},
// 事件存储:key = cellKey -> event
events: {},
// 暂存被隐藏节次列上的事件:key = 周-星期-节次 -> event,列再次显示时恢复
hiddenEvents: {},
// 选择集(用数组以保证 Vue2 响应式)
selectedKeys: [],
// 拖拽状态
selecting: false,
dragStart: null,
dragStartSelected: false, // 按下起点在按下前是否已选中
moved: false, // 是否发生移动(区分点击与拖拽)
dragAddMode: false, // ctrl 拖拽为追加
// 窗口控制
absorbPreview: ''
}
},
computed: {
// 当前可见列(由开关过滤,默认每天三个节次)
visibleColumns() {
const cols = []
let colIndex = 0
WEEK_DAYS.forEach((dayLabel, dayIndex) => {
SLOT_DEFS.forEach(slot => {
if (slot.ctrl && !this[slot.ctrl]) return
cols.push({ colIndex: colIndex, dayIndex: dayIndex, slotKey: slot.key, slotLabel: slot.label, dayLabel: dayLabel })
colIndex++
})
})
return cols
},
// xqxlb 的 nd 后端已统一为「6 位学期代号」(如 202701),与 this.nd 一致。
// 不再按日历起点/季度取年份,避免跨年度学期解析出错。
xqxlbNd() {
return Number(String(this.nd).slice(0, 6)) || Number(this.nd) || 0
}
},
watch: {
nd: {
immediate: true,
handler(val) {
if (val) this.loadSemester()
}
},
visibleColumns(newCols, oldCols) {
// 节次列显隐会改变列索引,按「周期-星期-节次」重定位事件,避免事件随时间格列偏移
if (oldCols && oldCols.length) {
const oldPosOf = index => (oldCols[index] || null)
const newIndex = (dayIndex, slotKey) => {
const c = newCols.find(x => x.dayIndex === dayIndex && x.slotKey === slotKey)
return c ? c.colIndex : -1
}
const next = {}
Object.keys(this.events).forEach(key => {
const m = key.match(/^w(\d+)-c(\d+)$/)
if (!m) return
const wIdx = +m[1]
const old = oldPosOf(+m[2])
if (!old) return
const newC = newIndex(old.dayIndex, old.slotKey)
if (newC < 0) {
// 该节次列被隐藏:事件暂存,待列再次显示时恢复
this.hiddenEvents[this.cellStableKey(wIdx, old.dayIndex, old.slotKey)] = this.events[key]
return
}
next['w' + wIdx + '-c' + newC] = this.events[key]
})
// 恢复重新显示的隐藏节次事件
Object.keys(this.hiddenEvents).forEach(stable => {
const p = stable.split('-')
const wIdx = +p[0]
const dayIndex = +p[1]
const slotKey = p[2]
const newC = newIndex(dayIndex, slotKey)
if (newC >= 0) {
next['w' + wIdx + '-c' + newC] = this.hiddenEvents[stable]
delete this.hiddenEvents[stable]
}
})
this.events = next
}
// 列变化后清空无效选择(列索引含义会变)
this.selectedKeys = []
}
},
beforeDestroy() {
this.removeGlobalListeners()
},
methods: {
/* ---------- 数据加载 ---------- */
loadSemester() {
if (!this.nd) return
getSemester(this.nd)
.then(res => {
const data = res.data || res || {}
const kx = (data.kxrq || '').toString().slice(0, 10)
const jx = (data.jsrq || '').toString().slice(0, 10)
if (kx && jx) {
this.startDate = new Date(kx.replace(/-/g, '/'))
this.endDate = new Date(jx.replace(/-/g, '/'))
this.calendarStart = null
this.buildWeeks()
}
this.loadXqxlbEvents()
})
.catch(() => {
this.$message.warning('学期详情获取失败,请确认学期数据')
})
},
// 从后端拉取本学期校历事件,渲染到对应时间格(年度由 6 位学期代号截取前 4 位)
// XQXLB 的 nd 存的是「年份」(如 2026),春/夏/秋三学期共用同一批年度记录;
// 后端 updateById 只能改已存在的 bh,所以每个格子必须有预生成的记录才能存。
// 若本学期日期区间 [kxrq, jsrq] 内还没有任何占位记录(首次进入该学期),
// 调用 /xqxlb/add 只按本学期 kxrq/jsrq 预生成这一张网格,再重新拉取,
// 这样后续 /xqxlb/update 的 updateById 才能命中每一格。(区间有覆盖则跳过,幂等)
loadXqxlbEvents() {
const fetchList = () => listXqxlb({ nd: this.xqxlbNd }).then(res => {
const data = res.data
return Array.isArray(data) ? data : (data && data.records) || []
})
const render = (list) => {
// 后端 add() 的按「月日」去重对已存的全量日期不生效,同一年度多次打开/刷新会
// 积累同一格的重复占位记录(各带不同 bh)。updateById 只改其中一行,其余空记录
// 会在重新拉取时把刚保存的事件名覆盖掉。故这里按「周-星期-节次」先去重:
// 同一格保留有事件名(jqmc非空)的一条;都没有则保留最后一条兜底(保证有 bh)。
const unique = {}
list.forEach(item => {
const pos = this.locateXqxlb(item)
if (!pos) return
const stable = this.cellStableKey(pos.wIdx, pos.dayIndex, pos.slotKey)
const prev = unique[stable]
if (!prev || (item.jqmc && !prev.item.jqmc)) {
unique[stable] = { item: item, pos: pos }
}
})
const loaded = {}
Object.keys(unique).forEach(stable => {
const { item, pos } = unique[stable]
const ev = {
bh: item.bh,
name: item.jqmc || '',
bold: !!item.jc,
schedulable: !!item.kpk,
mainCourse: !!item.zdpk,
remarkShow: !!item.bzxs,
remark: item.bz || ''
}
const colIndex = this.colIndexOf(pos.dayIndex, pos.slotKey)
if (colIndex >= 0) {
loaded[this.cellKey(pos.wIdx, colIndex)] = ev
} else {
// 该节次列当前隐藏:暂存(含 bh),待列显示时由 visibleColumns 监听恢复
this.hiddenEvents[this.cellStableKey(pos.wIdx, pos.dayIndex, pos.slotKey)] = ev
}
})
// 合并到现有格子(后端数据覆盖已有状态)
this.events = Object.assign({}, this.events, loaded)
}
fetchList().then(list => {
const hasCoverage = list.some(item => this.isInRange(item.jqsj))
if (!hasCoverage && this.startDate && this.endDate) {
// 本学期区间尚无占位记录:仅用本期 kxrq/jsrq 预生成整张网格
const startStr = fmtDate(this.startDate)
const endStr = fmtDate(this.endDate)
return addXqxlb(startStr, endStr).then(() => fetchList())
}
return list
}).then(render).catch(() => {
this.$message.warning('校历事件加载失败')
})
},
// 判断某条记录(jqsj 日期)是否落在本学期 [startDate, endDate] 区间内
isInRange(jqsj) {
if (!this.startDate || !this.endDate || !jqsj) return false
const d = new Date(String(jqsj).slice(0, 10).replace(/-/g, '/'))
if (isNaN(d.getTime())) return false
return d >= this.startDate && d <= this.endDate
},
// 根据假期记录反推时间格位置(jqsj 日期 + courseClass 节次),与列是否可见无关
locateXqxlb(item) {
if (!this.calendarStart || !item.jqsj) return null
const d = new Date(String(item.jqsj).slice(0, 10).replace(/-/g, '/'))
if (isNaN(d.getTime())) return null
const offset = Math.round((d - this.calendarStart) / (24 * 3600 * 1000))
if (offset < 0) return null
const wIdx = Math.floor(offset / 7)
const dayIndex = offset % 7
const slotKey = this.courseClassToSlotKey(item.courseClass)
if (slotKey === null) return null
return { wIdx, dayIndex, slotKey }
},
// 后端 courseClass 节次范围 -> 前端节次 key
courseClassToSlotKey(courseClass) {
if (!courseClass) return null
const s = String(courseClass).trim()
for (const key in SLOT_COURSE_MAP) {
if (s === SLOT_COURSE_MAP[key]) return key
}
// 兼容 "910"/"1112" 等紧凑写法
if (s === '910') return 'night'
if (s === '1112') return 'late'
return null
},
// 获取日期所在周的周一(周一为一周起点)
getMonday(d) {
const date = new Date(d)
const day = date.getDay() // 0=周日,1=周一,...,6=周六
const diff = date.getDate() - day + (day === 0 ? -6 : 1)
date.setDate(diff)
return date
},
buildWeeks() {
if (!this.startDate || !this.endDate) return
const start = this.getMonday(new Date(this.startDate))
const end = new Date(this.endDate)
this.calendarStart = start
const days = Math.round((end - start) / (24 * 3600 * 1000)) + 1
this.totalWeeks = Math.ceil(days / 7)
this.dateRangeText = fmtDate(new Date(this.startDate)) + ' 到 ' + fmtDate(new Date(this.endDate))
const weeks = []
for (let w = 0; w < this.totalWeeks; w++) {
const wkStart = new Date(start)
wkStart.setDate(start.getDate() + w * 7)
const wkEnd = new Date(wkStart)
wkEnd.setDate(wkStart.getDate() + 6)
weeks.push({
rangeText: pad2(wkStart.getMonth() + 1) + '-' + pad2(wkStart.getDate()) +
'至' + pad2(wkEnd.getMonth() + 1) + '-' + pad2(wkEnd.getDate())
})
}
this.weeks = weeks
},
colIndexOf(dayIndex, slotKey) {
const col = this.visibleColumns.find(c => c.dayIndex === dayIndex && c.slotKey === slotKey)
return col ? col.colIndex : -1
},
/* ---------- 单元格工具 ---------- */
cellKey(wIdx, colIndex) {
return 'w' + wIdx + '-c' + colIndex
},
// 稳定的单元格身份:不随列显隐变化的周-星期-节次
cellStableKey(wIdx, dayIndex, slotKey) {
return wIdx + '-' + dayIndex + '-' + slotKey
},
getEvent(wIdx, colIndex) {
return this.events[this.cellKey(wIdx, colIndex)] || null
},
weekDayLabel(dayIndex) {
return WEEK_DAYS[dayIndex]
},
// 单元格内显示的日期数字(如 0703)
dateNumberOf(wIdx, dayIndex) {
if (!this.calendarStart) return ''
const d = new Date(this.calendarStart)
d.setDate(this.calendarStart.getDate() + wIdx * 7 + dayIndex)
return pad2(d.getMonth() + 1) + pad2(d.getDate())
},
cellClass(wIdx, col) {
const classes = []
if (this.selectedKeys.includes(this.cellKey(wIdx, col.colIndex))) classes.push('is-selected')
const ev = this.getEvent(wIdx, col.colIndex)
// 可排课的全部白色;不可排课且事件名非空才标红
if (ev && ev.name && !ev.schedulable) {
classes.push('no-schedule')
}
return classes
},
/* ---------- 点击 / 拖拽多选 ---------- */
onGridMouseDown(e) {
const cell = e.target.closest('.sce-cell')
if (!cell) {
// 点击空白区(非单元格,含表头、周次列等)取消所有选中
if (this.selectedKeys.length) this.selectedKeys = []
return
}
e.preventDefault()
const key = cell.getAttribute('data-key')
this.dragStart = key
this.dragAddMode = e.ctrlKey || e.metaKey
// 记录起点格在按下时的选中状态,用于松手时判定"纯点击"的切换行为
this.dragStartSelected = this.selectedKeys.includes(key)
this.moved = false
this.selecting = true
// 非 ctrl 模式下,若起点本身已选中(可能准备拖拽扩展),先不清除,避免误清空
if (!this.dragAddMode && !this.dragStartSelected) this.selectedKeys = []
this.addGlobalListeners()
},
addGlobalListeners() {
document.addEventListener('mousemove', this.onGridMouseMove)
document.addEventListener('mouseup', this.onGridMouseUp)
},
removeGlobalListeners() {
document.removeEventListener('mousemove', this.onGridMouseMove)
document.removeEventListener('mouseup', this.onGridMouseUp)
},
onGridMouseMove(e) {
if (!this.selecting || !this.dragStart) return
if (!this.moved) this.moved = true
const el = document.elementFromPoint(e.clientX, e.clientY)
const cell = el && el.closest ? el.closest('.sce-cell') : null
if (!cell) return
const curKey = cell.getAttribute('data-key')
this.selectRectangle(this.dragStart, curKey, this.dragAddMode)
},
onGridMouseUp() {
if (!this.selecting) {
this.removeGlobalListeners()
return
}
// 纯点击(未移动)时,做单选 / 切换
if (!this.moved) {
const key = this.dragStart
if (this.dragAddMode) {
// Ctrl + 单击:切换该格选中
if (this.selectedKeys.includes(key)) {
this.selectedKeys = this.selectedKeys.filter(k => k !== key)
} else {
this.selectedKeys.push(key)
}
} else {
// 普通单击:已选中则取消该格,未选中则仅选中该格
if (this.dragStartSelected) {
this.selectedKeys = this.selectedKeys.filter(k => k !== key)
} else {
this.selectedKeys = [key]
}
}
}
this.selecting = false
this.dragStart = null
this.dragStartSelected = false
this.removeGlobalListeners()
},
// 根据起点终点 key 选中矩形范围内所有格
selectRectangle(startKey, endKey, addMode) {
const parse = k => {
const m = k.match(/^w(\d+)-c(\d+)$/)
return m ? { w: +m[1], c: +m[2] } : null
}
const s = parse(startKey)
const t = parse(endKey)
if (!s || !t) return
if (!addMode) this.selectedKeys = []
const minW = Math.min(s.w, t.w)
const maxW = Math.max(s.w, t.w)
const minC = Math.min(s.c, t.c)
const maxC = Math.max(s.c, t.c)
for (let w = minW; w <= maxW; w++) {
for (let c = minC; c <= maxC; c++) {
const key = this.cellKey(w, c)
if (this.selectedKeys.indexOf(key) === -1) this.selectedKeys.push(key)
}
}
},
/* ---------- 事件操作 ---------- */
applyEvent() {
if (!this.selectedKeys.length) {
this.$message.warning('请先选择时间格')
return
}
const name = this.toolbar.eventName.trim()
// 设定时未填写事件名:提示,不触发清除
if (!name) {
this.$message.warning('请输入事件名')
return
}
const keys = [...this.selectedKeys]
keys.forEach(key => {
const prev = this.events[key]
this.$set(this.events, key, {
// 编辑已有事件:沿用后端返回的 bh;新增事件:bh 由 loadXqxlbEvents
// 通过 /xqxlb/add 预生成的占位行提供(首次进入学期时已落库)
bh: prev && prev.bh ? prev.bh : undefined,
name: name,
bold: this.toolbar.bold,
schedulable: this.toolbar.schedulable,
mainCourse: this.toolbar.mainCourse,
remarkShow: this.toolbar.remarkShow,
remark: this.toolbar.remark
})
})
this.persistEvents(keys)
},
deleteEvent() {
if (!this.selectedKeys.length) {
this.$message.warning('请先选择时间格')
return
}
this.$confirm('确认删除选中单元格的事件吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const keys = [...this.selectedKeys]
this.persistDeleteEvents(keys).then(({ ok, fail }) => {
if (fail === 0) {
keys.forEach(key => {
this.$delete(this.events, key)
})
this.selectedKeys = []
}
})
}).catch(() => {})
},
absorbEvent() {
// 吸取:取选择中第一个事件名非空的格
let target = null
for (const key of this.selectedKeys) {
if (this.events[key] && this.events[key].name) { target = this.events[key]; break }
}
if (!target) {
this.$message.warning('所选时间格中无事件可吸取')
return
}
this.toolbar.eventName = target.name
this.toolbar.bold = !!target.bold
this.toolbar.schedulable = !!target.schedulable
this.toolbar.mainCourse = !!target.mainCourse
this.toolbar.remarkShow = !!target.remarkShow
this.toolbar.remark = target.remark || ''
this.absorbPreview = target.name
},
onCellDblClick(wIdx, col) {
const ev = this.getEvent(wIdx, col.colIndex)
if (ev && ev.name) {
this.toolbar.eventName = ev.name
this.toolbar.bold = !!ev.bold
this.toolbar.schedulable = !!ev.schedulable
this.toolbar.mainCourse = !!ev.mainCourse
this.toolbar.remarkShow = !!ev.remarkShow
this.toolbar.remark = ev.remark || ''
this.absorbPreview = ev.name
this.$message.info('已吸取事件:' + ev.name)
}
},
refreshGrid() {
this.selectedKeys = []
this.absorbPreview = ''
this.events = {}
this.hiddenEvents = {}
this.loadXqxlbEvents()
this.$message.info('已刷新')
},
/* ---------- 后端持久化(xqxlb 接口) ---------- */
// 批量保存选中格事件,返回各格子保存成功/失败的个数
persistEvents(keys) {
const tasks = keys
.filter(key => this.events[key])
.map(key => {
const payload = this.buildXqxlbPayload(key, this.events[key])
if (!payload) return Promise.resolve(false)
return updateXqxlb(payload)
.then(() => {
console.warn('[设定] key=', key, 'bh来源=', this.events[key] && this.events[key].bh ? '已有' : '生成', 'bh=', payload.bh, 'nd=', payload.nd, 'name=', payload.jqmc)
return true
})
.catch(err => {
console.warn('[设定] key=', key, '保存失败', err && (err.message || err))
return false
})
})
return Promise.all(tasks).then(results => {
const ok = results.filter(r => r === true).length
const fail = results.length - ok
if (fail > 0) {
this.$message.error(fail + ' 个事件保存失败,请检查后端接口')
} else if (ok > 0) {
this.$message.success('已设定 ' + ok + ' 个时间格')
}
// 保存成功后重新拉取,回写各记录主键,避免重复新增
this.loadXqxlbEvents()
return { ok: ok, fail: fail }
})
},
// 批量删除选中格事件:调用 update 接口并将 jqmc 置空完成删除
persistDeleteEvents(keys) {
const tasks = keys
.filter(key => this.events[key])
.map(key => {
const payload = this.buildXqxlbPayload(key, this.events[key])
if (!payload) return Promise.resolve(false)
payload.jqmc = ''
return updateXqxlb(payload)
.then(() => true)
.catch(() => false)
})
return Promise.all(tasks).then(results => {
const ok = results.filter(r => r === true).length
const fail = results.length - ok
if (fail > 0) {
this.$message.error(fail + ' 个事件删除失败,请检查后端接口')
} else if (ok > 0) {
this.$message.success('已删除 ' + ok + ' 个时间格事件')
}
// 删除成功后重新拉取,同步后端状态
this.loadXqxlbEvents()
return { ok: ok, fail: fail }
})
},
// 构造 xqxlb 提交数据
buildXqxlbPayload(key, ev) {
const pos = this.parseCellKey(key)
if (!pos) return null
const d = new Date(this.calendarStart)
d.setDate(this.calendarStart.getDate() + pos.wIdx * 7 + pos.dayIndex)
return {
delFlag: 0,
// bh 编号必须传:有后端记录则沿用其 bh,否则前端生成 UUID 兜底(避免 payload 缺主键导致 updateById 失效)
bh: ev.bh || genUUID(),
// nd 后端已统一为 6 位学期代号(如 202701),与查询口径一致,不再取记录日期的年份
nd: this.xqxlbNd,
jqsj: fmtDate(d),
jqmc: ev.name || '',
jc: !!ev.bold,
bz: ev.remark || null,
kpk: !!ev.schedulable,
bzxs: !!ev.remarkShow,
zdpk: !!ev.mainCourse,
courseClass: SLOT_COURSE_MAP[pos.slotKey] || null
}
},
// 时间格 key -> { wIdx, dayIndex, slotKey }
parseCellKey(key) {
const m = key.match(/^w(\d+)-c(\d+)$/)
if (!m) return null
const colIndex = +m[2]
const col = this.visibleColumns.find(c => c.colIndex === colIndex)
if (!col) return null
return { wIdx: +m[1], dayIndex: col.dayIndex, slotKey: col.slotKey }
},
/* ---------- 返回学期管理 ---------- */
handleClose() {
this.$emit('close')
this.$router.replace({ path: '/teachBusiness/semester' })
}
}
}
</script>
<style scoped lang="scss">
.school-calendar-editor {
display: flex;
flex-direction: column;
height: 100%;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 6px;
overflow: hidden;
/* 标题栏 */
.sce-titlebar {
display: flex;
align-items: center;
height: 44px;
padding: 0 14px;
background: var(--edu-green-primary, #00875a);
color: #fff;
.sce-title-left { flex: 1; font-size: 15px; font-weight: 600; }
.sce-title-center { flex: 1; text-align: center; font-size: 13px; opacity: 0.9; }
.sce-title-right { flex: 0 0 auto; text-align: right; }
.sce-title-right i {
margin-left: 14px;
cursor: pointer;
font-size: 18px;
opacity: 0.85;
&:hover { opacity: 1; }
}
}
/* 设置面板 */
.sce-panel {
padding: 10px 14px;
border-bottom: 1px solid #ebeef5;
background: #fafafa;
.sce-panel-row {
display: flex;
align-items: center;
flex-wrap: wrap;
margin-bottom: 8px;
&:last-child { margin-bottom: 0; }
}
.sce-label { font-size: 13px; color: #606266; margin-right: 6px; white-space: nowrap; }
.sce-event-input { width: 200px; margin-right: 12px; }
.sce-remark-input { width: 240px; margin-left: 6px; }
.sce-cb { margin-right: 14px; }
.sce-divider { width: 1px; height: 18px; background: #dcdfe6; margin: 0 14px; }
}
/* 时间编排区 */
.sce-grid-wrap {
flex: 1;
overflow: auto;
padding: 8px 10px;
background: #fff;
}
.sce-grid {
border-collapse: collapse;
table-layout: fixed;
width: 100%;
font-size: 12px;
user-select: none;
th, td {
border: 1px solid #e4e7ed;
text-align: center;
padding: 0;
}
.sce-corner {
background: #f5f7fa;
font-weight: 600;
color: #303133;
vertical-align: middle;
}
.sce-th-weekno { width: 52px; }
.sce-th-weekrange { width: 110px; }
.sce-th-day {
background: var(--edu-green-primary, #00875a);
color: #fff;
font-weight: 600;
height: 26px;
}
.sce-th-slot {
background: #ecf5f0;
color: #00875a;
height: 22px;
font-weight: 500;
}
.sce-week-cell {
background: #f5f7fa;
vertical-align: middle;
white-space: nowrap;
}
.sce-weekno-cell {
font-weight: 600;
color: #303133;
font-size: 13px;
}
.sce-weekrange-cell {
font-size: 11px;
color: #909399;
}
.sce-cell {
height: 30px;
position: relative;
cursor: pointer;
background: #fff;
transition: background 0.15s;
.sce-event-name {
display: block;
line-height: 1;
padding: 2px 0;
}
.sce-date-num {
display: block;
font-size: 10px;
color: #c0c4cc;
line-height: 1;
}
// 可排课白色,不可排课且有事件标红
&.no-schedule { background: #fde2e2; }
&.is-selected {
outline: 2px solid var(--edu-green-primary, #00875a);
outline-offset: -2px;
background: #d4ecdf !important;
}
}
}
.sce-status {
padding: 6px 14px;
font-size: 12px;
color: #909399;
border-top: 1px solid #ebeef5;
background: #fafafa;
.sce-absorb-tip { margin-left: 12px; color: #00875a; }
}
}
</style>
@@ -0,0 +1,517 @@
<template>
<div class="teach-calendar app-container">
<!-- 顶部标题:学期名称-校历 -->
<div class="cal-titlebar">
<span class="cal-title">{{ titleText }}</span>
</div>
<!-- 显示控制栏 -->
<div class="cal-panel">
<el-checkbox v-model="showDate" class="cal-cb">显示日期</el-checkbox>
<div class="cal-panel-right">
<el-button size="mini" type="primary" icon="el-icon-download" @click="exportExcel">另存为Excel</el-button>
</div>
</div>
<!-- 学期校历表格 -->
<div class="cal-grid-wrap">
<table class="cal-grid">
<thead>
<tr>
<th class="cal-corner cal-th-weekno" :rowspan="2">周次</th>
<th class="cal-corner cal-th-weekrange" :rowspan="2">日期段</th>
<th v-for="day in weekDayHeaders" :key="'h1-' + day.dayIndex" :colspan="day.colCount" class="cal-th-day">
{{ day.label }}
</th>
</tr>
<tr>
<th v-for="col in visibleColumns" :key="'h2-' + col.colIndex" class="cal-th-slot">
{{ col.slotLabel }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="(week, wIdx) in weeks" :key="'w-' + wIdx">
<td class="cal-week-cell cal-weekno-cell">{{ wIdx + 1 }}</td>
<td class="cal-week-cell cal-weekrange-cell">{{ week.rangeText }}</td>
<td
v-for="col in visibleColumns"
:key="'c-' + wIdx + '-' + col.colIndex"
class="cal-cell"
:class="cellClass(wIdx, col)"
>
<template v-if="getEvent(wIdx, col.colIndex) && getEvent(wIdx, col.colIndex).name">
<span class="cal-event-name">{{ getEvent(wIdx, col.colIndex).name }}</span>
</template>
<span v-else-if="showDate" class="cal-date-num">{{ dateNumberOf(wIdx, col.dayIndex) }}</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- 底部状态栏 -->
<div class="cal-status">
<span v-if="nd">从 {{ dateRangeText }} ,共 {{ totalWeeks }} 周</span>
<span v-else>请选择学期</span>
</div>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import { listSemester, getSemester } from '@/api/teachBusiness/semester'
import { listXqxlb } from '@/api/teachBusiness/xqxlb'
// 节次定义:全部常显
const SLOT_DEFS = [
{ key: '12', label: '1-2' },
{ key: '34', label: '3-4' },
{ key: '56', label: '5-6' },
{ key: '78', label: '7-8' },
{ key: 'night', label: '晚上' },
{ key: 'late', label: '夜间' }
]
// 前端节次 key -> 后端 xqxlb.courseClass 节次范围
const SLOT_COURSE_MAP = {
'12': '1-2',
'34': '3-4',
'56': '5-6',
'78': '7-8',
night: '9-10',
late: '11-12'
}
const WEEK_DAYS = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
function pad2(n) {
return n < 10 ? '0' + n : '' + n
}
function fmtDate(d) {
return d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate())
}
export default {
name: 'SemesterCalendar',
data() {
return {
// 当前学期代号(跟随顶栏切换学期,自动更新为当前学期)
nd: '',
// 学期日期范围
startDate: null,
endDate: null,
// 日历渲染起点(学期当周周一)
calendarStart: null,
totalWeeks: 0,
dateRangeText: '',
weeks: [],
// 显示控制:默认不勾选显示日期;节次全部展示
showDate: false,
// 事件存储:key = cellKey -> event
events: {},
loading: false
}
},
computed: {
// 页面标题:学期名称-校历
titleText() {
if (!this.nd) return '学期校历'
return this.getSemesterName(this.nd) + '-校历'
},
// 当前可见列(全部节次常显)
visibleColumns() {
const cols = []
let colIndex = 0
WEEK_DAYS.forEach((dayLabel, dayIndex) => {
SLOT_DEFS.forEach(slot => {
cols.push({ colIndex: colIndex, dayIndex: dayIndex, slotKey: slot.key, slotLabel: slot.label, dayLabel: dayLabel })
colIndex++
})
})
return cols
},
// 表头第一行星期:每个星期合并其下全部节次列
weekDayHeaders() {
return WEEK_DAYS.map((label, dayIndex) => ({
dayIndex: dayIndex,
label: label,
colCount: SLOT_DEFS.length
}))
}
},
created() {
// 初始加载当前学期
this.loadCurrentSemester()
// 顶栏切换学期后自动刷新为当前学期的校历
this.$root.$on('semester-current-changed', this.loadCurrentSemester)
},
beforeDestroy() {
this.$root.$off('semester-current-changed', this.loadCurrentSemester)
},
methods: {
/* ---------- 加载当前学期 ---------- */
loadCurrentSemester() {
this.loading = true
listSemester({ pageNum: 1, pageSize: 100 }).then(response => {
const data = response.data || {}
const list = data.records || []
// 跟随顶栏当前学期(dqxq=true),无则取第一条
const current = list.find(i => i.dqxq) || list[0]
this.loading = false
if (current) {
if (String(this.nd) !== String(current.nd)) {
this.nd = current.nd
this.loadSemester()
}
}
}).catch(() => {
this.loading = false
})
},
/* ---------- 数据加载 ---------- */
loadSemester() {
if (!this.nd) return
this.startDate = null
this.endDate = null
this.calendarStart = null
getSemester(this.nd)
.then(res => {
const data = res.data || res || {}
const kx = (data.kxrq || '').toString().slice(0, 10)
const jx = (data.jsrq || '').toString().slice(0, 10)
if (kx && jx) {
this.startDate = new Date(kx.replace(/-/g, '/'))
this.endDate = new Date(jx.replace(/-/g, '/'))
this.buildWeeks()
}
this.loadXqxlbEvents()
})
.catch(() => {
this.$message.warning('学期详情获取失败,请确认学期数据')
})
},
// 从后端拉取校历事件,渲染到对应时间格
// xqxlb.nd 后端已统一为 6 位学期代号(如 202701),与 this.nd 一致,一次查询即可
loadXqxlbEvents() {
if (!this.calendarStart || !this.nd) return
listXqxlb({ nd: Number(String(this.nd).slice(0, 6)) || Number(this.nd) }).then(res => {
const data = res.data
const list = Array.isArray(data) ? data : (data && data.records) || []
const loaded = {}
// 同一格可能有多条(后端 add() 去重失效累积的重复占位)。
// 按格子去重:同一格优先保留「有事件名(jqmc非空)」的那条,避免空占位把事件盖成空白。
const unique = {}
list.forEach(item => {
const pos = this.locateXqxlb(item)
if (!pos) return
const prev = unique[pos.key]
const has = !!item.jqmc
if (!prev || (has && !prev.has)) {
unique[pos.key] = { has: has, item: item }
}
})
Object.keys(unique).forEach(key => {
const { item } = unique[key]
loaded[key] = {
bh: item.bh,
name: item.jqmc || '',
schedulable: !!item.kpk,
mainCourse: !!item.zdpk,
remarkShow: !!item.bzxs,
remark: item.bz || ''
}
})
this.events = loaded
}).catch(() => {
this.$message.warning('校历事件加载失败')
})
},
// 根据假期记录反推时间格 key(jqsj 日期 + courseClass 节次)
locateXqxlb(item) {
if (!this.calendarStart || !item.jqsj) return null
const d = new Date(String(item.jqsj).slice(0, 10).replace(/-/g, '/'))
if (isNaN(d.getTime())) return null
const offset = Math.round((d - this.calendarStart) / (24 * 3600 * 1000))
if (offset < 0) return null
const wIdx = Math.floor(offset / 7)
const dayIndex = offset % 7
const slotKey = this.courseClassToSlotKey(item.courseClass)
if (slotKey === null) return null
const colIndex = this.colIndexOf(dayIndex, slotKey)
if (colIndex < 0) return null
return { key: this.cellKey(wIdx, colIndex) }
},
// 后端 courseClass 节次范围 -> 前端节次 key
courseClassToSlotKey(courseClass) {
if (!courseClass) return null
const s = String(courseClass).trim()
for (const key in SLOT_COURSE_MAP) {
if (s === SLOT_COURSE_MAP[key]) return key
}
// 兼容 "910"/"1112" 等紧凑写法
if (s === '910') return 'night'
if (s === '1112') return 'late'
return null
},
// 获取日期所在周的周一(周一为一周起点)
getMonday(d) {
const date = new Date(d)
const day = date.getDay() // 0=周日,1=周一,...,6=周六
const diff = date.getDate() - day + (day === 0 ? -6 : 1)
date.setDate(diff)
return date
},
buildWeeks() {
if (!this.startDate || !this.endDate) return
const start = this.getMonday(new Date(this.startDate))
const end = new Date(this.endDate)
this.calendarStart = start
const days = Math.round((end - start) / (24 * 3600 * 1000)) + 1
this.totalWeeks = Math.ceil(days / 7)
this.dateRangeText = fmtDate(new Date(this.startDate)) + ' 到 ' + fmtDate(new Date(this.endDate))
const weeks = []
for (let w = 0; w < this.totalWeeks; w++) {
const wkStart = new Date(start)
wkStart.setDate(start.getDate() + w * 7)
const wkEnd = new Date(wkStart)
wkEnd.setDate(wkStart.getDate() + 6)
weeks.push({
rangeText: pad2(wkStart.getMonth() + 1) + '-' + pad2(wkStart.getDate()) +
'至' + pad2(wkEnd.getMonth() + 1) + '-' + pad2(wkEnd.getDate())
})
}
this.weeks = weeks
},
colIndexOf(dayIndex, slotKey) {
const col = this.visibleColumns.find(c => c.dayIndex === dayIndex && c.slotKey === slotKey)
return col ? col.colIndex : -1
},
/* ---------- 单元格工具 ---------- */
cellKey(wIdx, colIndex) {
return 'w' + wIdx + '-c' + colIndex
},
getEvent(wIdx, colIndex) {
return this.events[this.cellKey(wIdx, colIndex)] || null
},
weekDayLabel(dayIndex) {
return WEEK_DAYS[dayIndex]
},
// 单元格内显示的日期数字(如 0703)
dateNumberOf(wIdx, dayIndex) {
if (!this.calendarStart) return ''
const d = new Date(this.calendarStart)
d.setDate(this.calendarStart.getDate() + wIdx * 7 + dayIndex)
return pad2(d.getMonth() + 1) + pad2(d.getDate())
},
cellClass(wIdx, col) {
const classes = []
const ev = this.getEvent(wIdx, col.colIndex)
// 可排课的全部白色;不可排课且事件名非空才标红
if (ev && ev.name && !ev.schedulable) {
classes.push('no-schedule')
}
return classes
},
/** 学期代号 -> 学期名称(如 202601 -> 2026年春季学期) */
getSemesterName(nd) {
if (!nd) return ''
const s = String(nd)
const xn = s.slice(0, 4)
const xq = s.slice(4)
const map = { '01': '春季学期', '02': '夏季学期', '03': '秋季学期' }
return xn + '年' + (map[xq] || '第' + xq + '学期')
},
/* ---------- 另存为Excel ---------- */
exportExcel() {
if (!this.weeks.length) {
this.$message.warning('暂无校历数据可导出')
return
}
// 按星期分组节次列,用于表头合并
const dayCols = []
this.visibleColumns.forEach(col => {
if (!dayCols[col.dayIndex]) dayCols[col.dayIndex] = []
dayCols[col.dayIndex].push(col)
})
let html = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">'
html += '<head><meta charset="utf-8"></head><body>'
html += '<table border="1" cellspacing="0" cellpadding="4" style="border-collapse:collapse;">'
// 标题行
html += '<tr><td colspan="' + (this.visibleColumns.length + 2) + '" style="font-size:15px;font-weight:bold;text-align:center;">' + this.titleText + '</td></tr>'
// 表头第一行:星期(合并同类天)
html += '<tr><th rowspan="2">周次</th><th rowspan="2">日期段</th>'
WEEK_DAYS.forEach((dayLabel, dayIndex) => {
const cols = dayCols[dayIndex] || []
if (cols.length) html += '<th colspan="' + cols.length + '">' + dayLabel + '</th>'
})
html += '</tr>'
// 表头第二行:节次
html += '<tr>'
this.visibleColumns.forEach(col => {
html += '<th>' + col.slotLabel + '</th>'
})
html += '</tr>'
// 数据行
this.weeks.forEach((week, wIdx) => {
html += '<tr>'
html += '<td>' + (wIdx + 1) + '</td>'
html += '<td>' + week.rangeText + '</td>'
this.visibleColumns.forEach(col => {
const ev = this.getEvent(wIdx, col.colIndex)
if (ev && ev.name) {
const remark = ev.remark && ev.remarkShow ? '(' + ev.remark + ')' : ''
html += '<td>' + ev.name + remark + '</td>'
} else if (this.showDate) {
html += '<td>' + this.dateNumberOf(wIdx, col.dayIndex) + '</td>'
} else {
html += '<td></td>'
}
})
html += '</tr>'
})
html += '</table></body></html>'
const blob = new Blob(['\ufeff' + html], { type: 'application/vnd.ms-excel;charset=utf-8' })
saveAs(blob, (this.titleText || '学期校历') + '.xls')
this.$message.success('已导出Excel')
}
}
}
</script>
<style scoped lang="scss">
.teach-calendar {
height: 100%;
display: flex;
flex-direction: column;
padding: 12px;
box-sizing: border-box;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 6px;
overflow: hidden;
/* 顶部标题栏 */
.cal-titlebar {
display: flex;
align-items: center;
justify-content: center;
height: 44px;
background: var(--edu-green-primary, #00875a);
color: #fff;
border-radius: 4px 4px 0 0;
.cal-title {
font-size: 15px;
font-weight: 600;
}
}
/* 显示控制栏 */
.cal-panel {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 8px 14px;
border-bottom: 1px solid #ebeef5;
background: #fafafa;
.cal-cb { margin-right: 14px; }
.cal-panel-right { margin-left: auto; }
}
/* 表格区域 */
.cal-grid-wrap {
flex: 1;
overflow: auto;
padding: 8px 10px;
background: #fff;
}
.cal-grid {
border-collapse: collapse;
table-layout: fixed;
width: 100%;
font-size: 12px;
th, td {
border: 1px solid #e4e7ed;
text-align: center;
padding: 0;
}
.cal-corner {
background: #f5f7fa;
font-weight: 600;
color: #303133;
vertical-align: middle;
}
.cal-th-weekno { width: 52px; }
.cal-th-weekrange { width: 110px; }
.cal-th-day {
background: var(--edu-green-primary, #00875a);
color: #fff;
font-weight: 600;
height: 26px;
}
.cal-th-slot {
background: #ecf5f0;
color: #00875a;
height: 22px;
font-weight: 500;
}
.cal-week-cell {
background: #f5f7fa;
vertical-align: middle;
white-space: nowrap;
}
.cal-weekno-cell {
font-weight: 600;
color: #303133;
font-size: 13px;
}
.cal-weekrange-cell {
font-size: 11px;
color: #909399;
}
.cal-cell {
height: 30px;
position: relative;
background: #fff;
.cal-event-name {
display: block;
line-height: 1;
padding: 2px 0;
}
.cal-date-num {
display: block;
font-size: 10px;
color: #c0c4cc;
line-height: 1;
}
// 可排课白色,不可排课且有事件标红
&.no-schedule { background: #fde2e2; }
}
}
/* 底部状态栏 */
.cal-status {
padding: 6px 14px;
font-size: 12px;
color: #909399;
border-top: 1px solid #ebeef5;
background: #fafafa;
}
}
</style>
@@ -0,0 +1,64 @@
<template>
<div class="teach-calendar app-container">
<school-calendar-editor
v-if="nd"
:key="nd"
:nd="nd"
:semester-name="semesterName"
@close="handleClose"
/>
<div v-else class="calendar-empty">未指定学期,请从学期管理页面进入。</div>
</div>
</template>
<script>
import SchoolCalendarEditor from '@/views/teachBusiness/calendar/components/SchoolCalendarEditor'
export default {
name: 'SemesterCalendarEdit',
components: { SchoolCalendarEditor },
data() {
return {
nd: '',
semesterName: ''
}
},
created() {
this.nd = this.$route.query.nd || ''
this.semesterName = this.$route.query.name || ''
},
watch: {
// 编辑校历页被 keep-alive 缓存复用:同路径下 query.nd 变化时不会重新走 created(),
// 需在此同步到 nd,并通过 :key="nd" 让编辑器随学期切换全新挂载,读取正确学期数据。
'$route.query.nd'(val) {
if (val && String(val) !== String(this.nd)) {
this.nd = val
this.semesterName = this.$route.query.name || ''
}
}
},
methods: {
handleClose() {
this.$router.replace({ path: '/teachBusiness/semester' })
}
}
}
</script>
<style scoped>
.teach-calendar {
height: 100%;
display: flex;
flex-direction: column;
padding: 12px;
box-sizing: border-box;
}
.calendar-empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
font-size: 14px;
}
</style>
@@ -0,0 +1,647 @@
<template>
<div class="app-container teach-semester">
<!-- 工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新添</el-button>
</el-col>
<el-col :span="1.8">
<el-button type="success" plain icon="el-icon-date" size="mini"
@click="handleEditCalendar">
编辑校历
</el-button>
</el-col>
</el-row>
<!-- 数据表格 -->
<el-table v-loading="loading" :data="semesterList" border :height="tableHeight" highlight-current-row
@current-change="handleCurrentChange">
<el-table-column label="学期名称" align="center" width="250">
<template slot-scope="scope">
<span>{{ getSemesterName(scope.row.nd) }}</span>
</template>
</el-table-column>
<el-table-column label="当前" align="center" width="100">
<template slot-scope="scope">
<el-tag v-if="scope.row.dqxq" type="success" size="mini">当前</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="开学日期" align="center" prop="kxrq" width="160">
<template slot-scope="scope">
<span>{{ formatDate(scope.row.kxrq) }}</span>
</template>
</el-table-column>
<el-table-column label="结束日期" align="center" prop="jsrq" width="160">
<template slot-scope="scope">
<span>{{ formatDate(scope.row.jsrq) }}</span>
</template>
</el-table-column>
<el-table-column label="周数" align="center" prop="sdzs" width="55" />
<el-table-column label="调课不审批" align="center" width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.tkbsp ? 'primary' : 'info'" size="mini">{{ scope.row.tkbsp ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="禁止调课" align="center" width="80">
<template slot-scope="scope">
<el-tag :type="scope.row.jztk ? 'danger' : 'info'" size="mini">{{ scope.row.jztk ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="终结成绩定及格" align="center" width="130">
<template slot-scope="scope">
<el-tag :type="scope.row.zjcjdjg ? 'primary' : 'info'" size="mini">{{ scope.row.zjcjdjg ? '是' : '否'
}}</el-tag>
</template>
</el-table-column>
<el-table-column label="课时系数方案" align="center" width="160">
<template slot-scope="scope">
<span>{{ getCoefficientLabel(scope.row.ksxsfabh) }}</span>
</template>
</el-table-column>
<el-table-column label="锁定时长" align="center" width="100">
<template slot-scope="scope">
<span>{{ scope.row.sdjldw || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="table-action-column">
<template slot-scope="scope">
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="text" size="mini" icon="el-icon-delete" class="text-danger"
@click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 学期信息弹窗 -->
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body class="semester-dialog">
<el-alert v-if="isSemesterNameDuplicated()" class="semester-dup-alert" type="warning" show-icon
title="该学期已存在,不能重复添加" :closable="false" />
<el-form ref="form" class="semester-dialog-form" :model="form" :rules="rules" label-width="96px"
label-position="right">
<el-row :gutter="20" class="semester-dialog-body">
<!-- 左侧表单区 -->
<el-col :span="15" class="semester-form-col">
<el-form-item label="学期名称">
<el-input :value="getSemesterName(buildNd(form.xn, form.xq))" readonly placeholder="请在下方选择年份和学期类型"
prefix-icon="el-icon-office-building" />
</el-form-item>
<el-row :gutter="14">
<el-col :span="12">
<el-form-item label="年份" prop="xn">
<el-select v-model="form.xn" placeholder="请选择年份" :disabled="!isAdd" style="width: 100%"
@change="checkSemesterNameUnique">
<el-option v-for="item in yearOptions" :key="item" :label="item + '年'" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学期类型" prop="xq">
<el-select v-model="form.xq" placeholder="请选择学期类型" :disabled="!isAdd" style="width: 100%"
@change="checkSemesterNameUnique">
<el-option v-for="item in semesterOptions" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="14">
<el-col :span="12">
<el-form-item label="开学日期" prop="kxrq">
<el-date-picker v-model="form.kxrq" type="date" placeholder="开学日期" value-format="yyyy-MM-dd"
style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期" prop="jsrq">
<el-date-picker v-model="form.jsrq" type="date" placeholder="结束日期" value-format="yyyy-MM-dd"
style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="14">
<el-col :span="12">
<el-form-item label="学期周数" prop="sdzs">
<el-input-number v-model="form.sdzs" :min="1" :max="60" controls-position="right"
style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="课时系数方案" prop="ksxsfabh">
<el-select v-model="form.ksxsfabh" placeholder="请选择" clearable style="width: 100%">
<el-option v-for="item in coefficientOptions" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="锁定时长">
<div class="lock-group">
<el-input-number v-model="form.lockValue" :min="0" :max="99" controls-position="right"
style="width: 120px" />
<el-radio-group v-model="form.lockUnit" class="lock-unit" style="margin-left: 28px">
<el-radio label="周">周</el-radio>
<el-radio label="月">月</el-radio>
</el-radio-group>
</div>
</el-form-item>
<div class="form-tip">以当前周星期四中午12点为界限,锁定【锁定周数】周的教学实施计划,被锁定的教学实施计划不允许教员自行调整。</div>
</el-col>
<!-- 右侧业务开关区 -->
<el-col :span="9" class="semester-switch-col">
<div class="switch-panel-title">业务开关</div>
<div class="switch-panel">
<div class="switch-item">
<el-checkbox v-model="form.dqxq">当前学期</el-checkbox>
<div class="switch-tip">设定当前学期后,系统启动时会自动将该学期设置为默认学期。</div>
</div>
<div class="switch-item">
<el-checkbox v-model="form.jztk">禁止调课</el-checkbox>
<div class="switch-tip">设定【禁止调课】后,教学信息系统中就无法对课程信息进行调整。</div>
</div>
<div class="switch-item">
<el-checkbox v-model="form.tkbsp">调课不审批</el-checkbox>
<div class="switch-tip">
设定【调课不审批】后,在教学信息系统中调课时,如果只是更改教员,或更改授课地点,调课申请会立即生效。而对于改变授课地点,调课申请会立即生效。而对于改变授课时间、增加或减少授课教员的调课申请依然不受该设置影响,依然需要逐级审批后才能生效。
</div>
</div>
<div class="switch-item">
<el-checkbox v-model="form.zjcjdjg">终结成绩定及格</el-checkbox>
<div class="switch-tip">设定【终结成绩定及格】后,学员终结性成绩不及格的,最终成绩即为不及格。</div>
</div>
<div class="switch-item">
<el-checkbox v-model="form.jwldshtk">教务机关审核教学计划调整</el-checkbox>
<div class="switch-tip">勾选:教务机关需要从行政入口对每个教学计划调整申请进行审批,同时再由管理员身份教务参谋进行最后的把关;不勾选:仅由管理员身份教务参谋进行最后的把关。</div>
</div>
</div>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listSemester, getSemester, addSemester, updateSemester, delSemester } from "@/api/teachBusiness/semester"
export default {
name: "Semester",
data() {
return {
// 遮罩层
loading: true,
// 表格高度
tableHeight: window.innerHeight - 280,
// 总条数
total: 0,
// 学期列表数据
semesterList: [],
// 当前点击选中的学期
currentSemester: null,
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否新增
isAdd: true,
// 学年选项(当前年份 ± 10 年)
yearOptions: [],
// 学期选项:01 春季、02 夏季、03 秋季
semesterOptions: [
{ value: '01', label: '春季学期' },
{ value: '02', label: '夏季学期' },
{ value: '03', label: '秋季学期' }
],
// 课时系数方案选项(引用基础数据表,暂以静态占位)
coefficientOptions: [
{ value: '1', label: '标准系数方案' },
{ value: '2', label: '综合系数方案' },
{ value: '3', label: '实训系数方案' }
],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10
},
// 表单参数
form: {},
// 表单校验
rules: {
xn: [
{ required: true, message: "请选择年份", trigger: "change" }
],
xq: [
{ required: true, message: "请选择学期类型", trigger: "change" }
],
kxrq: [
{ required: true, message: "请选择开学日期", trigger: "change" }
],
jsrq: [
{ required: true, message: "请选择结束日期", trigger: "change" }
]
}
}
},
created() {
this.initYearOptions()
this.getList()
// 顶栏切换当前学期后,自动刷新本页数据
this.$root.$on('semester-current-changed', this.handleCurrentChanged)
},
beforeDestroy() {
this.$root.$off('semester-current-changed', this.handleCurrentChanged)
},
watch: {
'form.kxrq': 'calculateWeeks',
'form.jsrq': 'calculateWeeks',
// 新增时选择学期类型后,自动带出开学/结束日期
'form.xq'(val) {
if (this.isAdd) this.autoFillDatesForXq()
},
'form.xn'(val) {
if (this.isAdd) this.autoFillDatesForXq()
}
},
methods: {
/** 顶栏切换当前学期后自动刷新 */
handleCurrentChanged() {
this.getList()
},
/** 初始化学年选项(新增时只能从当前年份往后选择) */
initYearOptions() {
const current = new Date().getFullYear()
const list = []
for (let i = current; i <= current + 10; i++) {
list.push(i)
}
this.yearOptions = list
},
/** 学年+学期 -> 学期代号(如 2026 + 01 = 202601) */
buildNd(xn, xq) {
if (xn === undefined || xn === null || xn === '' || !xq) return ''
return String(xn) + String(xq)
},
/** 根据学年+学期类型自动带出开学/结束日期(春季01:2-5月,夏季02:6-8月,秋季03:9-12月) */
autoFillDatesForXq() {
const xn = this.form.xn
const xq = this.form.xq
if (xn === undefined || xn === null || xn === '') return
const year = Number(xn)
const pad = m => `${year}-${String(m).padStart(2, '0')}`
const rules = {
'01': { start: pad(2) + '-01', end: pad(5) + '-31' },
'02': { start: pad(6) + '-01', end: pad(8) + '-31' },
'03': { start: pad(9) + '-01', end: pad(12) + '-31' }
}
const rule = rules[xq]
if (!rule) return
this.form.kxrq = rule.start
this.form.jsrq = rule.end
},
/** 学期代号 -> 学期名称(如 202601 -> 2026年春季学期) */
getSemesterName(nd) {
if (!nd) return ''
const s = String(nd)
const xn = s.slice(0, 4)
const xq = s.slice(4)
const map = { '01': '春季学期', '02': '夏季学期', '03': '秋季学期' }
return xn + '年' + (map[xq] || '第' + xq + '学期')
},
/** 学期代号 -> {xn, xq} */
parseNd(nd) {
if (!nd) return { xn: undefined, xq: undefined }
const s = String(nd)
return { xn: s.slice(0, 4), xq: s.slice(4) }
},
/** 新增时校验学期名称(年份+学期类型拼接)是否已存在于表格 */
isSemesterNameDuplicated() {
if (!this.isAdd) return false
const nd = this.buildNd(this.form.xn, this.form.xq)
if (!nd) return false
return this.semesterList.some(item => String(item.nd) === String(nd))
},
/** 年份/学期类型切换时实时刷新顶部重复提示 */
checkSemesterNameUnique() {
this.$forceUpdate()
},
/** 课时系数方案编号 -> 名称 */
getCoefficientLabel(value) {
if (!value && value !== 0) return '-'
const found = this.coefficientOptions.find(o => String(o.value) === String(value))
return found ? found.label : value
},
/** 格式化后端 LocalDateTime(2026-02-23T00:00:00 -> 2026-02-23) */
formatDate(value) {
if (!value) return ''
return String(value).slice(0, 10)
},
/** 根据开学日期和结束日期自动计算学期周数 */
calculateWeeks() {
const kxrq = this.form.kxrq
const jsrq = this.form.jsrq
if (!kxrq || !jsrq) return
const start = new Date(String(kxrq).slice(0, 10).replace(/-/g, '/'))
const end = new Date(String(jsrq).slice(0, 10).replace(/-/g, '/'))
if (isNaN(start.getTime()) || isNaN(end.getTime())) return
if (end < start) return
// 以开学当周周一为起点,向上取整到周
const day = start.getDay()
const monday = new Date(start)
monday.setDate(start.getDate() - (day === 0 ? 6 : day - 1))
const days = Math.round((end - monday) / (24 * 3600 * 1000)) + 1
this.$set(this.form, 'sdzs', Math.max(1, Math.ceil(days / 7)))
},
/** 查询学期列表 */
getList() {
this.loading = true
listSemester(this.queryParams).then(response => {
const data = response.data || {}
this.semesterList = data.records || []
this.total = data.total || 0
this.loading = false
}).catch(() => {
this.semesterList = []
this.total = 0
this.loading = false
})
},
/** 单击行选中变化:记录当前选中的学期,用于启用「编辑校历」 */
handleCurrentChange(currentRow) {
this.currentSemester = currentRow || null
},
/** 组装提交数据 */
buildPayload(form) {
const lockValue = form.lockValue !== undefined && form.lockValue !== null ? form.lockValue : ''
return {
delFlag: 0,
nd: this.buildNd(form.xn, form.xq),
dqxq: !!form.dqxq,
kxrq: form.kxrq ? form.kxrq + 'T00:00:00' : null,
jsrq: form.jsrq ? form.jsrq + 'T00:00:00' : null,
tkbsp: !!form.tkbsp,
jztk: !!form.jztk,
zjcjdjg: !!form.zjcjdjg,
jwldshtk: !!form.jwldshtk,
ksxsfabh: form.ksxsfabh || null,
sdzs: form.sdzs,
sdjldw: lockValue === '' ? '' : lockValue + form.lockUnit,
xh: form.xh,
jsonzd: "{'1':1}",
kstjsj: null
}
},
/** 新增按钮 */
handleAdd() {
this.reset()
this.isAdd = true
this.open = true
this.title = "学期信息 - 新增"
},
/** 编辑按钮 */
handleUpdate(row) {
const semesterId = row && row.nd ? row.nd : ''
if (!semesterId) return
this.reset()
this.isAdd = false
getSemester(semesterId).then(response => {
const data = response.data || {}
const { xn, xq } = this.parseNd(data.nd)
// 解析锁定时长(如 "2周" / "1月" / "1")
let lockValue = data.sdjldw
let lockUnit = '周'
if (lockValue) {
const s = String(lockValue)
if (s.endsWith('周')) { lockValue = s.slice(0, -1); lockUnit = '周' }
else if (s.endsWith('月')) { lockValue = s.slice(0, -1); lockUnit = '月' }
}
this.form = {
xn: xn,
xq: xq,
dqxq: !!data.dqxq,
jztk: !!data.jztk,
tkbsp: !!data.tkbsp,
zjcjdjg: !!data.zjcjdjg,
jwldshtk: !!data.jwldshtk,
ksxsfabh: data.ksxsfabh,
kxrq: this.formatDate(data.kxrq),
jsrq: this.formatDate(data.jsrq),
sdzs: data.sdzs,
lockValue: lockValue,
lockUnit: lockUnit,
xh: data.xh
}
this.open = true
this.title = "学期信息 - 编辑"
}).catch(() => { })
},
/** 编辑校历按钮:对当前选中的学期编辑校历 */
handleEditCalendar() {
const row = this.currentSemester
if (!row || !row.nd) {
this.$modal.msgWarning('请选择学期')
return
}
this.$router.push({
path: '/teachBusiness/semester/semesterCalendar',
query: { nd: row.nd, name: this.getSemesterName(row.nd) }
})
},
/** 删除按钮:单行删除 */
handleDelete(row) {
if (!row || !row.nd) return
const name = this.getSemesterName(row.nd)
this.$modal.confirm('确认删除学期【' + name + '】吗?').then(() => {
return delSemester(row.nd)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => { })
},
/** 提交表单 */
submitForm() {
if (this.isSemesterNameDuplicated()) {
this.$modal.msgWarning("该学期已存在,不能重复添加")
return
}
this.$refs["form"].validate(valid => {
if (valid) {
const payload = this.buildPayload(this.form)
const selfNd = payload.nd
// 当前学期全局只能有一个:若本次设为当前,先把其他 dqxq=true 的取消
const cancelOthers = payload.dqxq
? this.cancelOtherCurrent(selfNd)
: Promise.resolve()
cancelOthers.then(() => {
if (this.isAdd) {
return addSemester(payload)
}
return updateSemester(payload)
}).then(() => {
this.$modal.msgSuccess(this.isAdd ? "新增成功" : "修改成功")
this.open = false
this.getList()
}).catch(() => { })
}
})
},
/** 取消其它“当前学期”,保证全局唯一 */
cancelOtherCurrent(selfNd) {
return listSemester({ pageNum: 1, pageSize: 100 }).then(response => {
const data = response.data || {}
const list = data.records || []
const others = list.filter(i => i.dqxq && String(i.nd) !== String(selfNd))
if (!others.length) return Promise.resolve()
return Promise.all(others.map(o => updateSemester({ ...o, dqxq: false })))
})
},
/** 重置表单 */
reset() {
this.form = {
xn: undefined,
xq: undefined,
dqxq: false,
jztk: false,
tkbsp: false,
zjcjdjg: false,
jwldshtk: false,
ksxsfabh: undefined,
kxrq: undefined,
jsrq: undefined,
sdzs: 20,
lockValue: 1,
lockUnit: '周',
xh: 1
}
this.resetForm("form")
},
/** 取消按钮 */
cancel() {
this.open = false
this.reset()
}
}
}
</script>
<style scoped lang="scss">
.teach-semester {
.mb8 {
margin-bottom: 8px;
}
/* 弹窗内表单:防止 label 文字换行、字段拥挤换行 */
::v-deep .el-dialog__body {
padding-top: 16px;
padding-bottom: 16px;
}
/* 对话框整体两栏布局 */
.semester-dialog-body {
display: block;
}
/* 顶部学期重复提示与表单间距 */
.semester-dup-alert {
margin-bottom: 16px;
}
.semester-form-col {
padding-right: 4px;
}
.semester-switch-col {
padding-left: 24px;
border-left: 1px solid #ebeef5;
}
.semester-dialog-form {
::v-deep .el-form-item {
margin-bottom: 18px;
}
::v-deep .el-form-item__label {
white-space: nowrap;
line-height: 32px;
padding-right: 10px;
color: #606266;
}
::v-deep .el-form-item__content {
line-height: 32px;
}
.el-input,
.el-select,
.el-date-editor {
width: 100%;
}
}
.form-tip {
font-size: 12px;
color: #909399;
line-height: 1.5;
margin-top: 4px;
white-space: normal;
padding-left: 2px;
}
.lock-group {
display: flex;
align-items: center;
}
.switch-panel-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 14px;
padding-left: 2px;
}
.switch-panel {
display: flex;
flex-direction: column;
gap: 12px;
}
.switch-item {
padding: 11px 13px;
background: #fafafa;
border: 1px solid #ebeef5;
border-radius: 6px;
transition: border-color 0.2s, background 0.2s;
&:hover {
border-color: var(--edu-green-primary);
background: #fff;
}
.el-checkbox {
height: 26px;
font-weight: 600;
color: #303133;
}
.switch-tip {
font-size: 12px;
line-height: 1.6;
color: #909399;
text-align: justify;
margin: 2px 0 0 2px;
}
}
}
</style>
@@ -0,0 +1,600 @@
<template>
<div class="app-container syllabus-page">
<!-- 查询条件 -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="100px" class="search-form" @submit.native.prevent>
<el-row :gutter="32">
<el-col :xs="24" :md="8">
<el-form-item label="专业代号">
<el-input v-model="searchForm.zydh" placeholder="请输入专业代号" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="停用">
<el-radio-group v-model="searchForm.ty">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<div class="search-actions">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- 数据列表 -->
<el-card shadow="never" class="table-card">
<div class="list-header">
<div class="list-title">教学大纲列表</div>
<div class="list-actions">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
<el-button
type="danger"
plain
icon="el-icon-delete"
:disabled="!selection.length"
@click="handleBatchDelete"
>删除所选</el-button>
<el-button icon="el-icon-download" @click="handleDownload">下载</el-button>
</div>
</div>
<el-table v-loading="loading" :data="pagedData" border stripe highlight-current-row
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column prop="zydh" label="专业代号" width="150" align="center" />
<el-table-column prop="kbh" label="课编号" width="110" show-overflow-tooltip align="center" />
<el-table-column prop="jc" label="简称" width="100" show-overflow-tooltip align="center" />
<el-table-column prop="kcdw" label="课程定位" width="120" show-overflow-tooltip align="center" />
<el-table-column prop="mk" label="模块" width="100" show-overflow-tooltip align="center" />
<el-table-column prop="jysdh" label="教研室" width="100" show-overflow-tooltip align="center" />
<el-table-column prop="klx" label="课类型" width="80" align="center" />
<el-table-column prop="xqdc" label="学期第次" width="80" align="center" />
<el-table-column prop="xs" label="学时" width="70" align="center" />
<el-table-column prop="xf" label="学分" width="70" align="center" />
<el-table-column prop="llxs" label="理论学时" width="80" align="center" />
<el-table-column prop="sjxs" label="实践学时" width="80" align="center" />
<el-table-column prop="zks" label="周课时" width="70" align="center" />
<el-table-column prop="ksks" label="考试课时" width="80" align="center" />
<el-table-column prop="cjfz" label="成绩分制" width="90" align="center" />
<el-table-column label="不计入平均分" width="110" align="center">
<template slot-scope="scope">{{ fmtYesNo(scope.row.bjrxypjf) }}</template>
</el-table-column>
<el-table-column label="考试课时不显示" width="130" align="center">
<template slot-scope="scope">{{ fmtYesNo(scope.row.ksksbxs) }}</template>
</el-table-column>
<el-table-column label="大纲课程" width="90" align="center">
<template slot-scope="scope">{{ fmtYesNo(scope.row.dgkc) }}</template>
</el-table-column>
<el-table-column label="停用" width="80" align="center">
<template slot-scope="scope">
<el-tag :type="Number(scope.row.ty) === 1 ? 'danger' : 'success'" size="mini">
{{ Number(scope.row.ty) === 1 ? '停用' : '正常' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="启用时间" width="150" align="center">
<template slot-scope="scope">{{ fmtDateTime(scope.row.qysj) }}</template>
</el-table-column>
<el-table-column label="停用时间" width="150" align="center">
<template slot-scope="scope">{{ fmtDateTime(scope.row.tysj) }}</template>
</el-table-column>
<el-table-column label="操作" width="160" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="text" size="mini" icon="el-icon-delete" class="danger-text-btn" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagination"
background
layout="total, sizes, prev, pager, next"
:current-page="pageNum"
:page-size="pageSize"
:total="total"
:page-sizes="[10, 20, 50, 100]"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</el-card>
<!-- 新增/编辑弹窗 -->
<el-dialog :title="dialog.title" :visible.sync="dialog.visible" width="720px" append-to-body
:close-on-click-modal="false">
<el-form ref="syllabusForm" :model="dialog.form" :rules="rules" label-width="130px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="专业" prop="zydh">
<el-select
v-model="dialog.form.zydh"
filterable
clearable
placeholder="请选择专业"
class="w-full"
:loading="referenceDataLoading"
>
<el-option
v-for="item in majorOptions"
:key="item.zydh"
:label="item.zymc"
:value="item.zydh"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="课程" prop="kbh">
<el-select
v-model="dialog.form.kbh"
filterable
clearable
placeholder="请选择课程"
class="w-full"
:loading="referenceDataLoading"
>
<el-option
v-for="item in subjectOptions"
:key="item.kbh"
:label="item.kmc"
:value="item.kbh"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学期第次" prop="xqdc">
<el-input-number v-model="dialog.form.xqdc" :min="1" :max="20" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="课类型" prop="klx">
<el-select
v-model="dialog.form.klx"
filterable
clearable
placeholder="请选择课类型"
class="w-full"
:loading="referenceDataLoading"
>
<el-option
v-for="item in courseTypeOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学时" prop="xs">
<el-input-number v-model="dialog.form.xs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停用" prop="ty">
<el-radio-group v-model="dialog.form.ty">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="简称">
<el-input v-model="dialog.form.jc" placeholder="请输入课程简称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学分">
<el-input-number v-model="dialog.form.xf" :min="0" :step="0.5" :precision="1" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="课程定位">
<el-input v-model="dialog.form.kcdw" placeholder="请输入课程定位" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="模块">
<el-input v-model="dialog.form.mk" placeholder="请输入模块" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="成绩分制">
<el-input v-model="dialog.form.cjfz" placeholder="请输入成绩分制" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教研室">
<el-select
v-model="dialog.form.jysdh"
filterable
clearable
placeholder="请选择教研室"
class="w-full"
:loading="referenceDataLoading"
>
<el-option
v-for="item in officeOptions"
:key="item.jysdh"
:label="item.jysmc"
:value="item.jysdh"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试课时">
<el-input-number v-model="dialog.form.ksks" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="理论学时">
<el-input-number v-model="dialog.form.llxs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="实践学时">
<el-input-number v-model="dialog.form.sjxs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="周课时">
<el-input-number v-model="dialog.form.zks" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="不计入平均分">
<el-radio-group v-model="dialog.form.bjrxypjf">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试课时不显示">
<el-radio-group v-model="dialog.form.ksksbxs">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="大纲课程">
<el-radio-group v-model="dialog.form.dgkc">
<el-radio :label="0">否</el-radio>
<el-radio :label="1">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialog.visible = false">取 消</el-button>
<el-button type="primary" :loading="dialog.submitting" @click="submitDialog">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
addSyllabus,
deleteSyllabus,
batchDeleteSyllabus,
updateSyllabus,
listByZydhAndTy
} from '@/api/teachBusiness/syllabus'
import { listMajor } from '@/api/subjectMajor/major'
import { listKb } from '@/api/teachOffice/kb'
import { listOffice } from '@/api/teachOffice/office'
import { getDicts } from '@/api/system/dict/data'
const REFERENCE_DATA_PAGE_SIZE = 10000
const COURSE_TYPE_DICT_CODE = 'course_type'
export default {
name: 'SyllabusIndex',
data() {
return {
loading: false,
searchForm: {
zydh: '',
ty: 0
},
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
localPaging: false,
selection: [],
referenceDataLoading: false,
majorOptions: [],
subjectOptions: [],
courseTypeOptions: [],
officeOptions: [],
dialog: {
visible: false,
title: '',
submitting: false,
form: this.createEmptyForm()
},
rules: {
zydh: [{ required: true, message: '请选择专业', trigger: 'change' }],
kbh: [{ required: true, message: '请选择课程', trigger: 'change' }],
xqdc: [{ required: true, message: '请输入学期第次', trigger: 'blur' }],
klx: [{ required: true, message: '请选择课类型', trigger: 'change' }],
xs: [{ required: true, message: '请输入学时', trigger: 'blur' }],
ty: [{ required: true, message: '请选择停用标识', trigger: 'change' }]
}
}
},
computed: {
pagedData() {
if (!this.localPaging) {
return this.tableData
}
const start = (this.pageNum - 1) * this.pageSize
return this.tableData.slice(start, start + this.pageSize)
}
},
created() {
this.fetchList()
this.loadReferenceData()
},
methods: {
loadReferenceData() {
this.referenceDataLoading = true
const query = { pageNum: 1, pageSize: REFERENCE_DATA_PAGE_SIZE }
const requests = [
listMajor(query),
listKb(query),
listOffice(query),
getDicts(COURSE_TYPE_DICT_CODE)
].map(request => {
return request
.then(response => this.getResponseRecords(response))
.catch(() => [])
})
Promise.all(requests).then(([majors, subjects, offices, courseTypes]) => {
this.majorOptions = this.getUniqueOptions(majors, 'zydh', 'zymc')
this.subjectOptions = this.getUniqueOptions(subjects, 'kbh', 'kmc')
this.officeOptions = this.getUniqueOptions(offices, 'jysdh', 'jysmc')
this.courseTypeOptions = this.getUniqueOptions(courseTypes, 'dictValue', 'dictLabel')
}).finally(() => {
this.referenceDataLoading = false
})
},
getResponseRecords(response) {
const data = response.data || {}
return Array.isArray(data) ? data : data.records || []
},
getUniqueOptions(items, valueKey, labelKey) {
const values = new Set()
return items.filter(item => {
const value = item[valueKey]
const label = item[labelKey]
if (!value || !label || values.has(value)) {
return false
}
values.add(value)
return true
})
},
/* ---------- 列表加载 ---------- */
fetchList() {
this.loading = true
listByZydhAndTy({ zydh: this.searchForm.zydh, ty: this.searchForm.ty }).then(response => {
const data = response.data || []
this.tableData = Array.isArray(data) ? data : (data.records || [])
this.total = this.tableData.length
this.localPaging = true
}).catch(() => {
this.tableData = []
this.total = 0
}).finally(() => {
this.loading = false
})
},
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handleReset() {
this.searchForm = { zydh: '', ty: 0 }
this.pageNum = 1
this.fetchList()
},
handleSelectionChange(val) {
this.selection = val
},
/* ---------- 新增 / 编辑 ---------- */
handleAdd() {
this.dialog.title = '新增教学大纲'
this.dialog.form = this.createEmptyForm()
this.dialog.visible = true
this.$nextTick(() => {
if (this.$refs.syllabusForm) this.$refs.syllabusForm.clearValidate()
})
},
handleEdit(row) {
this.dialog.title = '编辑教学大纲'
this.dialog.form = Object.assign({}, this.createEmptyForm(), row)
this.dialog.visible = true
this.$nextTick(() => {
if (this.$refs.syllabusForm) this.$refs.syllabusForm.clearValidate()
})
},
submitDialog() {
this.$refs.syllabusForm.validate(valid => {
if (!valid) return
this.dialog.submitting = true
const payload = this.cleanPayload(this.dialog.form)
const isEdit = !!payload.bh
const req = isEdit ? updateSyllabus(payload) : addSyllabus(payload)
req.then(() => {
this.$message.success(isEdit ? '修改成功' : '新增成功')
this.dialog.visible = false
this.fetchList()
}).finally(() => {
this.dialog.submitting = false
})
})
},
/* ---------- 删除 / 批量删除 ---------- */
handleDelete(row) {
this.$confirm('删除后该条记录将置为「停用」,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return deleteSyllabus(row.bh)
}).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
handleBatchDelete() {
if (!this.selection.length) {
this.$message.warning('请先勾选要删除的记录')
return
}
const bhList = this.selection.map(row => row.bh)
this.$confirm('确定删除所选 ' + bhList.length + ' 条记录吗?(将置为「停用」)', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return batchDeleteSyllabus(bhList)
}).then(() => {
this.$message.success('批量删除成功')
this.fetchList()
}).catch(() => {})
},
/* ---------- 下载(无后端接口) ---------- */
handleDownload() {
this.$message.warning('后端暂未提供该接口')
},
/* ---------- 分页 ---------- */
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
if (!this.localPaging) {
this.fetchList()
}
},
handlePageChange(page) {
this.pageNum = page
if (!this.localPaging) {
this.fetchList()
}
},
/* ---------- 工具 ---------- */
createEmptyForm() {
return {
bh: '',
zydh: '',
kbh: '',
xqdc: 1,
klx: '',
xs: 0,
ty: 0,
jc: '',
xf: null,
kcdw: '',
ksks: 0,
mk: '',
cjfz: '',
bjrxypjf: 0,
llxs: 0,
sjxs: 0,
zks: 0,
ksksbxs: 0,
dgkc: 0,
jysdh: ''
}
},
/** 移除空值(''/null/undefined),保留 0 等有效值 */
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
fmtYesNo(val) {
return Number(val) === 1 ? '是' : '否'
},
fmtDateTime(val) {
return (val || '').substring(0, 16) || '-'
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.syllabus-page {
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
.search-actions {
padding-top: 4px;
}
}
}
.table-card {
.list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
}
.pagination {
margin-top: 16px;
text-align: right;
}
}
}
.danger-text-btn {
color: #f56c6c;
&:hover {
color: #f78989;
}
}
</style>
@@ -0,0 +1,297 @@
<template>
<div class="app-container teaching-task-page">
<!-- ==================== 页面标题 ==================== -->
<div class="page-title">教学任务列表</div>
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="80px" class="search-form">
<el-row :gutter="24">
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="任务名称">
<el-input
v-model="searchForm.rwmc"
placeholder="请输入任务名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="年度">
<el-select
v-model="searchForm.nd"
placeholder="请选择年度"
clearable
filterable
style="width: 100%"
>
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="状态">
<el-select
v-model="searchForm.zt"
placeholder="请选择状态"
clearable
style="width: 100%"
>
<el-option
v-for="opt in statusOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<div class="search-actions">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
</div>
</el-form>
</el-card>
<!-- ==================== 2. 数据表格 ==================== -->
<el-card shadow="never" class="table-card">
<el-table v-loading="loading" :data="tableData" border stripe>
<template slot="empty">
<span>无数据!</span>
</template>
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="bh" label="编号" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="rwmc" label="任务名称" width="250" align="center" show-overflow-tooltip />
<el-table-column prop="nd" label="年度" width="150" align="center" />
<el-table-column label="状态" width="100" align="center">
<template slot-scope="{ row }">
<el-tag :type="row.zt === '已发布' ? 'success' : 'info'" size="small">
{{ row.zt || '-' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="fbsj" label="发布时间" width="200" align="center" :formatter="fmtDateTime" />
<el-table-column prop="jssj" label="结束时间" width="200" align="center" :formatter="fmtDateTime" />
<el-table-column prop="cjsj" label="创建时间" width="200" align="center" :formatter="fmtDateTime" />
<el-table-column prop="jcxqscsj" label="教材需求生成时间" width="200" align="center" :formatter="fmtDateTime" />
<el-table-column label="操作" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleDetail(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"
@current-change="handlePageChange"
@size-change="handleSizeChange"
/>
</el-card>
<!-- ==================== 3. 详情对话框 ==================== -->
<el-dialog
:visible="detailVisible"
title="教学任务详情"
width="620px"
:close-on-click-modal="false"
@update:visible="val => detailVisible = val"
>
<el-descriptions v-if="detailData.bh" :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="任务名称">{{ detailData.rwmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="年度">{{ fmtVal(detailData.nd) }}</el-descriptions-item>
<el-descriptions-item label="状态">{{ detailData.zt || '-' }}</el-descriptions-item>
<el-descriptions-item label="发布时间">{{ fmtVal(detailData.fbsj) }}</el-descriptions-item>
<el-descriptions-item label="结束时间">{{ fmtVal(detailData.jssj) }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ fmtVal(detailData.cjsj) }}</el-descriptions-item>
<el-descriptions-item label="教材需求生成时间">{{ fmtVal(detailData.jcxqscsj) }}</el-descriptions-item>
</el-descriptions>
<div v-else v-loading="detailLoading" class="detail-empty">加载中...</div>
<div slot="footer">
<el-button @click="detailVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
/**
* 教学任务列表(只读查询页)
* 对应菜单:teachBusiness/teachingTask(原「分组课列表」页,下载类功能后端无接口已移除)
* 仅提供 分页查询 list + 详情 get?bh=,不做增删改发(避免与教学任务计划管理页重复操作同一实体)
* 增删改发统一在 src/views/teachOffice/taskPlan/index.vue(教学任务计划管理)完成
*/
import { listTeachingTask, getTeachingTask } from '@/api/teachBusiness/teachingTask'
import { listAllSemester } from '@/api/teachBusiness/semester'
export default {
name: 'TeachingTask',
data() {
return {
// ==================== 1. 查询条件 ====================
searchForm: {
rwmc: '',
nd: undefined,
zt: ''
},
yearOptions: [],
statusOptions: [
{ label: '未发布', value: '未发布' },
{ label: '已发布', value: '已发布' }
],
// ==================== 2. 表格数据 ====================
loading: false,
tableData: [],
pageNum: 1,
pageSize: 10,
total: 0,
// ==================== 3. 详情 ====================
detailVisible: false,
detailLoading: false,
detailData: {}
}
},
created() {
this.loadYearOptions().then(() => this.fetchList())
},
methods: {
/* ---------- 年度下拉(数据来自 /semester/all,禁止硬编码) ---------- */
loadYearOptions() {
return listAllSemester().then(response => {
const list = response.data || []
const map = {}
list.forEach(item => {
if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item
})
const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a)))
this.yearOptions = arr
// 默认年度:优先当前学期(dqxq=true),否则取最新年度
const current = list.find(item => item.dqxq === true)
const defaultNd = (current && current.nd) || arr[0]
if (!this.searchForm.nd) this.searchForm.nd = defaultNd
return arr
}).catch(() => {
this.yearOptions = []
return []
})
},
/* ---------- 通用格式化 ---------- */
fmtDateTime(row, column, cellValue) {
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
return String(cellValue).replace('T', ' ').slice(0, 16)
},
fmtVal(val) {
if (val === null || val === undefined || val === '') return '-'
return String(val).replace('T', ' ').slice(0, 16)
},
/* ---------- 列表加载 ---------- */
fetchList() {
this.loading = true
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (this.searchForm.rwmc && this.searchForm.rwmc.trim()) params.rwmc = this.searchForm.rwmc.trim()
if (this.searchForm.nd !== undefined && this.searchForm.nd !== null && this.searchForm.nd !== '') {
params.nd = this.searchForm.nd
}
if (this.searchForm.zt && this.searchForm.zt.trim()) params.zt = this.searchForm.zt.trim()
listTeachingTask(params).then(res => {
const data = (res && res.data) || {}
this.tableData = data.records || []
this.total = data.total || 0
this.loading = false
}).catch(() => {
this.tableData = []
this.total = 0
this.loading = false
})
},
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
/* ---------- 详情(只读,走真实 get?bh= 接口) ---------- */
handleDetail(row) {
this.detailVisible = true
this.detailLoading = true
this.detailData = {}
getTeachingTask(row.bh).then(res => {
this.detailData = (res && res.data) || {}
this.detailLoading = false
}).catch(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.teaching-task-page {
.page-title {
text-align: center;
font-size: 20px;
font-weight: 600;
color: #303133;
margin-bottom: 20px;
}
// ==================== 1. 查询条件区域 ====================
.search-card {
margin-bottom: 16px;
.search-form {
.search-actions {
display: flex;
justify-content: flex-end;
padding-top: 12px;
border-top: 1px solid #ebeef5;
}
}
}
// ==================== 2. 数据表格 ====================
.table-card {
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
}
// ==================== 3. 详情 ====================
.detail-empty {
min-height: 120px;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
}
}
</style>
@@ -0,0 +1,466 @@
<template>
<div class="app-container timetable-page">
<el-tabs v-model="activeTab" class="timetable-tabs">
<!-- ==================== 今日教学实施计划 ==================== -->
<el-tab-pane label="今日教学实施计划" name="today">
<div class="tab-body">
<div class="date-header">
<el-link type="primary" :underline="false" class="nav-link" @click="handlePrevDay">前一天</el-link>
<div class="date-title">{{ dateTitle }}</div>
<el-link type="primary" :underline="false" class="nav-link" @click="handleNextDay">后一天</el-link>
</div>
<div class="table-card">
<el-table :data="todayData" row-key="bh" v-loading="loading" stripe border>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column label="上课时间" width="130" align="center">
<template #default="{ row }">{{ row.sjsj || '-' }}</template>
</el-table-column>
<el-table-column prop="kcmc" label="课程" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="zrdw" label="责任单位" width="110" align="center" />
<el-table-column prop="bc" label="班次" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="skjy" label="教员" width="90" align="center" />
<el-table-column label="场地" width="140" align="center" show-overflow-tooltip>
<template #default="{ row }">{{ row.jxcd || '-' }}</template>
</el-table-column>
<el-table-column label="教学内容方法" min-width="160" show-overflow-tooltip header-align="center">
<template #default="{ row }">{{ row.jxnrff || '-' }}</template>
</el-table-column>
<el-table-column prop="jybz" label="备注" width="100" show-overflow-tooltip header-align="center">
<template #default="{ row }">{{ row.jybz || '-' }}</template>
</el-table-column>
</el-table>
<el-empty v-show="!loading && !todayData.length" description="暂无教学计划数据" />
</div>
</div>
</el-tab-pane>
<!-- ==================== 本周教学实施计划 ==================== -->
<el-tab-pane label="本周教学实施计划" name="week">
<div class="tab-body">
<div class="week-header">
<el-link type="primary" :underline="false" class="nav-link" @click="handlePrevWeek">上一周</el-link>
<div class="week-title">{{ weekRangeText }}</div>
<el-link type="primary" :underline="false" class="nav-link" @click="handleNextWeek">下一周</el-link>
</div>
<div class="table-card">
<el-table :data="weekData" row-key="bh" v-loading="loading" stripe border>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column label="上课时间" width="170" align="center" show-overflow-tooltip>
<template #default="{ row }">{{ row.sjsj || '-' }}</template>
</el-table-column>
<el-table-column prop="kcmc" label="课程" min-width="130" align="center" show-overflow-tooltip />
<el-table-column prop="zrdw" label="责任单位" width="100" align="center" />
<el-table-column prop="bc" label="班次" width="130" align="center" show-overflow-tooltip />
<el-table-column prop="skjy" label="教员" width="90" align="center" />
<el-table-column label="场地" width="140" align="center" show-overflow-tooltip>
<template #default="{ row }">{{ row.jxcd || '-' }}</template>
</el-table-column>
<el-table-column label="教学内容方法" min-width="150" show-overflow-tooltip header-align="center">
<template #default="{ row }">{{ row.jxnrff || '-' }}</template>
</el-table-column>
<el-table-column prop="jybz" label="备注" width="100" show-overflow-tooltip header-align="center">
<template #default="{ row }">{{ row.jybz || '-' }}</template>
</el-table-column>
</el-table>
<el-empty v-show="!loading && !weekData.length" description="本周暂无教学计划数据" />
</div>
</div>
</el-tab-pane>
<!-- ==================== 教学班次教学实施计划 ==================== -->
<el-tab-pane label="教学班次教学实施计划" name="shift">
<div class="tab-body">
<!-- 选择条件 -->
<div class="search-card">
<el-form :model="searchForm" inline class="search-form">
<el-form-item label="队别班次">
<el-select v-model="searchForm.teamClass" placeholder="请选择队别班次" clearable filterable class="shift-select">
<el-option v-for="item in teamClassOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
</el-form-item>
</el-form>
</div>
<!-- 标题 -->
<div class="page-title">{{ pageTitle }}</div>
<!-- 下载操作按钮 -->
<el-card shadow="never" class="action-card">
<div class="button-row">
<el-button type="primary" plain size="mini" @click="handleExportPlan">学期教学实施计划</el-button>
<el-button type="primary" plain size="mini" @click="handleExportGrades">学期成绩表</el-button>
<el-button type="primary" plain size="mini" @click="handleExportCourses">课程列表另存Excel</el-button>
</div>
</el-card>
<!-- 数据表格 -->
<div class="table-card">
<el-table :data="shiftData" v-loading="loading" border stripe style="width: 100%">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column label="课程名称/课时系数" min-width="220" align="center">
<template #default="{ row }">
<div>{{ row.kcmc || '-' }}</div>
<div class="sub-text">{{ row.kssk || '-' }}</div>
</template>
</el-table-column>
<el-table-column prop="zrjs" label="责任教员/课次" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="bc" label="班次" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="nj" label="年级" width="80" align="center" />
<el-table-column prop="zy" label="专业" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="jhxs" label="计划学时" width="90" align="center" />
<el-table-column prop="yxxs" label="运行学时" width="90" align="center" />
<el-table-column prop="khlxfs" label="考核类型方式" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="ssjs" label="实施教员" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="rscd" label="人数/场地" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="kcjd" label="课程进度" width="120" align="center" />
<el-table-column prop="ssjhbg" label="实施计划变更" min-width="120" align="center" show-overflow-tooltip />
</el-table>
<el-empty v-show="!loading && !shiftData.length" description="请选择队别班次后查询" />
</div>
</div>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { listToday, listWeek, listClass, exportClassPlan, exportClassGrades, exportClassCourses } from '@/api/teachBusiness/timetable'
import { listTeam } from '@/api/studentRecords/team'
const WEEK_DAY_NAMES = ['日', '一', '二', '三', '四', '五', '六']
function pad2(n) {
return n < 10 ? '0' + n : '' + n
}
function formatDate(d) {
return d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate())
}
function getMonday(d) {
const day = d.getDay() || 7
const monday = new Date(d)
monday.setDate(d.getDate() - day + 1)
return monday
}
export default {
name: 'Timetable',
data() {
return {
activeTab: 'today',
loading: false,
// 今日
todayDate: new Date(),
dayOffset: 0,
todayData: [],
// 本周
weekStart: getMonday(new Date()),
weekOffset: 0,
weekData: [],
// 班次
searchForm: { teamClass: '' },
teamClassOptions: [],
teamMap: {},
shiftData: []
}
},
computed: {
selectedTodayDate() {
const date = new Date(this.todayDate)
date.setDate(date.getDate() + this.dayOffset)
return date
},
selectedWeekStart() {
const date = new Date(this.weekStart)
date.setDate(date.getDate() + this.weekOffset * 7)
return date
},
dateTitle() {
return formatDate(this.selectedTodayDate) + ' 今日教学实施计划'
},
weekRangeText() {
const end = new Date(this.selectedWeekStart)
end.setDate(end.getDate() + 6)
return formatDate(this.selectedWeekStart) + '(' + this.weekDayName(this.selectedWeekStart) + ') 至 ' +
formatDate(end) + '(' + this.weekDayName(end) + ') 本周教学实施计划'
},
pageTitle() {
const name = this.searchForm.teamClass || ''
return (name ? name + ' ' : '') + '教学班次教学实施计划'
}
},
created() {
this.loadTeamOptions()
this.getTodayList()
this.getWeekList()
},
methods: {
weekDayName(d) {
return WEEK_DAY_NAMES[d.getDay()]
},
/* ---------- 今日:日期导航 ---------- */
handlePrevDay() {
this.dayOffset -= 1
this.getTodayList()
},
handleNextDay() {
this.dayOffset += 1
this.getTodayList()
},
/* ---------- 本周:周次导航 ---------- */
handlePrevWeek() {
this.weekOffset -= 1
this.getWeekList()
},
handleNextWeek() {
this.weekOffset += 1
this.getWeekList()
},
/* ---------- 队别班次下拉(真实接口) ---------- */
loadTeamOptions() {
listTeam({ pageNum: 1, pageSize: 1000 }).then(response => {
const data = response.data || {}
const list = data.records || []
const map = {}
;(list || []).forEach(item => {
if (item.xydmc) map[item.xydmc] = item.xydbh
})
this.teamMap = map
this.teamClassOptions = list.map(item => item.xydmc).filter(Boolean)
}).catch(() => {
this.teamMap = {}
this.teamClassOptions = []
})
},
/* ---------- 数据字段映射(接口字段 -> 页面字段) ---------- */
mapLessonRow(apiRow) {
// 接口今日/本周实体:bh sksj kc zrdw bc jy cd jxnrxff bz
const row = Object.assign({}, apiRow)
row.kcmc = apiRow.kc
row.skjy = apiRow.jy
row.jxcd = apiRow.cd
row.jxnrff = apiRow.jxnrxff
row.jybz = apiRow.bz
row.sjsj = apiRow.sksj
return row
},
extractLessonRows(response) {
const data = response && response.data
if (Array.isArray(data)) {
return data
}
if (!data) {
return []
}
// 新接口返回 DailyWeeklyTimetableRangeVO,列表位于 data.list;
// records 分支用于兼容旧分页结构,避免后端版本切换时页面再次无数据。
if (Array.isArray(data.list)) {
return data.list
}
if (Array.isArray(data.records)) {
return data.records
}
return []
},
mapClassRow(apiRow) {
// 接口班次实体:sskcbh kcmcksxs zrjykc jhxs yxxs khlxfs ssjy rscd ssjhbg
const row = Object.assign({}, apiRow)
const parts = String(apiRow.kcmcksxs || '').split(' / ')
row.kcmc = parts[0] || '-'
row.kssk = parts[1] || '-'
row.zrjs = apiRow.zrjykc
row.ssjs = apiRow.ssjy
return row
},
/* ---------- 今日:拉取数据 ---------- */
getTodayList() {
const params = {
offset: this.dayOffset,
rq: formatDate(this.todayDate)
}
this.loading = true
listToday(params).then(response => {
this.todayData = this.extractLessonRows(response).map(item => this.mapLessonRow(item))
this.loading = false
}).catch(() => {
this.todayData = []
this.loading = false
})
},
/* ---------- 本周:拉取数据 ---------- */
getWeekList() {
const params = {
offset: this.weekOffset,
rq: formatDate(this.weekStart)
}
this.loading = true
listWeek(params).then(response => {
this.weekData = this.extractLessonRows(response).map(item => this.mapLessonRow(item))
this.loading = false
}).catch(() => {
this.weekData = []
this.loading = false
})
},
/* ---------- 班次:拉取数据 ---------- */
getShiftList() {
if (!this.searchForm.teamClass) return
const xydbh = this.teamMap[this.searchForm.teamClass] || this.searchForm.teamClass
const params = { xydbh: xydbh, pageNum: 1, pageSize: 1000 }
this.loading = true
listClass(params).then(response => {
const data = response.data || {}
this.shiftData = (data.records || []).map(item => this.mapClassRow(item))
this.loading = false
}).catch(() => {
this.shiftData = []
this.loading = false
})
},
/* ---------- 班次:查询 ---------- */
handleQuery() {
if (!this.searchForm.teamClass) {
this.$message.warning('请先选择队别班次')
return
}
this.getShiftList()
},
/* ---------- 下载 ---------- */
downloadBlob(blob, filename) {
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = filename
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(link.href)
},
shiftQueryParams() {
if (!this.searchForm.teamClass) return null
const xydbh = this.teamMap[this.searchForm.teamClass] || this.searchForm.teamClass
return { xydbh: xydbh }
},
/** 下载学期教学实施计划 Excel(GET /kcb/class/export-plan) */
handleExportPlan() {
const params = this.shiftQueryParams()
if (!params) {
this.$message.warning('请先选择队别班次')
return
}
exportClassPlan(params).then(blob => {
this.downloadBlob(blob, '学期教学实施计划.xlsx')
this.$message.success('学期教学实施计划导出成功')
}).catch(() => {})
},
/** 下载学期成绩表 Excel(GET /kcb/class/export-grades) */
handleExportGrades() {
const params = this.shiftQueryParams()
if (!params) {
this.$message.warning('请先选择队别班次')
return
}
exportClassGrades(params).then(blob => {
this.downloadBlob(blob, '学期成绩表.xlsx')
this.$message.success('学期成绩表导出成功')
}).catch(() => {})
},
/** 班次课程列表另存 Excel(GET /kcb/class/export-courses) */
handleExportCourses() {
const params = this.shiftQueryParams()
if (!params) {
this.$message.warning('请先选择队别班次')
return
}
exportClassCourses(params).then(blob => {
this.downloadBlob(blob, '班次课程列表.xlsx')
this.$message.success('班次课程列表导出成功')
}).catch(() => {})
}
}
}
</script>
<style scoped lang="scss">
.timetable-page {
.timetable-tabs {
background: #fff;
padding: 0 16px;
border: 1px solid #ebeef5;
border-radius: 6px;
}
.tab-body {
padding-bottom: 16px;
}
.sub-text {
font-size: 12px;
color: #909399;
margin-top: 2px;
}
/* 日期/周次导航 */
.date-header,
.week-header {
display: flex;
align-items: center;
justify-content: center;
gap: 24px;
margin-bottom: 12px;
padding: 14px 16px;
background: #fafafa;
border: 1px solid #ebeef5;
border-radius: 4px;
.nav-link {
font-size: 14px;
}
.date-title,
.week-title {
font-size: 16px;
font-weight: 700;
color: #303133;
}
}
/* 班次 */
.search-card {
margin-bottom: 12px;
.search-form {
margin-bottom: 0;
}
.shift-select {
width: 240px;
}
}
.page-title {
font-size: 17px;
font-weight: 700;
color: #303133;
text-align: center;
margin-bottom: 12px;
}
.action-card {
margin-bottom: 12px;
.button-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
}
}
</style>
@@ -0,0 +1,951 @@
<template>
<div class="page-container">
<!-- 统计卡片 -->
<div class="section-card">
<div class="stat-grid">
<div
v-for="card in statCards"
:key="card.title"
class="stat-card"
:style="{ background: card.gradient }"
tabindex="0"
role="button"
@click="handleStatClick(card)"
@keydown.enter="handleStatClick(card)"
>
<span class="stat-text">{{ card.title }}</span>
<span class="stat-value">{{ card.value }}</span>
</div>
</div>
</div>
<!-- 查询条件 -->
<div class="section-card">
<el-form :model="queryParams" :inline="true" size="small" class="search-form" @submit.native.prevent>
<el-form-item label="年度">
<el-select
v-model="queryParams.nd"
placeholder="请选择年度"
clearable
filterable
style="width: 140px"
>
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</el-form-item>
<el-form-item label="申请教员编号">
<el-input v-model="queryParams.sqjybh" placeholder="请输入申请教员编号" clearable style="width: 180px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="教研室审批状态">
<el-select v-model="queryParams.jyspzzt" placeholder="请选择" clearable style="width: 150px">
<el-option v-for="item in auditStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 调课调整申请列表 -->
<div class="section-card">
<div class="section-header">
<div class="section-title">调停补课申请列表</div>
<div class="header-actions">
<el-button type="primary" plain icon="el-icon-plus" size="small" @click="openAdd">新增申请</el-button>
</div>
</div>
<el-table :data="tableData" v-loading="loading" size="small" border stripe class="compact-table" max-height="520">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="kcmc" label="课程名称" width="200" align="center" show-overflow-tooltip />
<el-table-column label="申请教员" width="150" align="center" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.sqjyxm || scope.row.sqjybh || '-' }}</template>
</el-table-column>
<el-table-column prop="sy" label="调课事由" width="230" show-overflow-tooltip header-align="center" />
<el-table-column label="拟调整时间" width="200" align="center" show-overflow-tooltip>
<template slot-scope="scope">{{ fmtRqJc(scope.row.rq, scope.row.jc) }}</template>
</el-table-column>
<el-table-column prop="nd" label="年度" width="150" align="center" />
<el-table-column label="教研室审批状态" width="150" align="center">
<template slot-scope="scope">
<el-tag :type="auditStatusTag(scope.row.jyspzzt).type" size="mini">{{ auditStatusTag(scope.row.jyspzzt).label }}</el-tag>
</template>
</el-table-column>
<el-table-column label="教研室查收状态" width="150" align="center">
<template slot-scope="scope">
<el-tag :type="receiveStatusTag(scope.row.jyscszt).type" size="mini">{{ receiveStatusTag(scope.row.jyscszt).label }}</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" width="150" align="center">
<template slot-scope="scope">{{ fmtDateTime(scope.row.cjsj) }}</template>
</el-table-column>
<el-table-column label="操作" width="180" align="center" fixed="right">
<template slot-scope="scope">
<div class="ops-cell">
<el-button type="text" size="mini" icon="el-icon-view" @click="openDetail(scope.row)">详情</el-button>
<el-button v-if="showAuditMenu(scope.row)" type="text" size="mini" @click="openAudit(scope.row)">审批</el-button>
<el-button v-if="scope.row.sczt === 0 && scope.row.jyspzzt !== 1 && scope.row.jyspzzt !== 3" type="text" size="mini" class="danger-btn" @click="handleCancel(scope.row)">撤销</el-button>
</div>
</template>
</el-table-column>
</el-table>
<el-empty v-show="!loading && tableData.length === 0" description="暂无调整申请" />
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="loadList"
/>
</div>
<!-- 新增申请弹窗 -->
<el-dialog title="新增课表调整申请" :visible.sync="addVisible" width="640px" append-to-body>
<el-form ref="addForm" :model="addForm" :rules="addRules" label-width="110px">
<el-form-item label="年度" prop="nd">
<el-select
v-model="addForm.nd"
placeholder="请选择年度"
filterable
style="width: 100%"
@change="handleAddYearChange"
>
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</el-form-item>
<el-form-item label="课次编号" prop="sskcbbh">
<el-input v-model="addForm.sskcbbh" placeholder="请从可供调课课次中选择" disabled />
<el-button type="primary" plain size="mini" class="pick-lesson-btn" :loading="lessonLoading" @click="loadAdjustableLessons">选择可供调课课次</el-button>
</el-form-item>
<el-form-item label="调课事由" prop="sy">
<el-input
v-model="addForm.sy"
type="textarea"
:rows="2"
maxlength="200"
show-word-limit
placeholder="请输入调课事由"
/>
</el-form-item>
<el-form-item label="拟调整日期" prop="rq">
<el-date-picker v-model="addForm.rq" type="date" value-format="yyyy-MM-dd" placeholder="请选择日期" style="width: 100%" />
</el-form-item>
<el-form-item label="拟调整节次" prop="jc">
<el-select v-model="addForm.jc" placeholder="请选择节次" style="width: 100%">
<el-option v-for="n in jcOptions" :key="n" :label="jcLabel(n)" :value="n" />
</el-select>
</el-form-item>
<el-form-item label="申请教员">
<el-input v-model="addForm.sqjybh" placeholder="由服务端根据当前登录人写入" disabled />
</el-form-item>
<el-form-item label="学员队名称">
<el-input v-model="addForm.xydmc" placeholder="选择可供调课课次后自动带出" disabled />
</el-form-item>
<el-form-item label="原教室编号">
<el-input v-model="addForm.yjsbh" placeholder="选择可供调课课次后自动带出" disabled />
</el-form-item>
<el-form-item label="拟调整教室编号">
<el-select
v-model="addForm.xjsbh"
placeholder="请选择拟调整教室"
clearable
filterable
:loading="classroomLoading"
style="width: 100%"
>
<el-option
v-for="room in classroomOptions"
:key="room.jsbh"
:label="classroomOptionLabel(room)"
:value="room.jsbh"
/>
</el-select>
</el-form-item>
<el-form-item label="原上课时间">
<el-input v-model="addForm.ydsjap" placeholder="选择可供调课课次后自动带出" disabled />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="addLoading" @click="submitAdd">提交申请</el-button>
<el-button @click="addVisible = false">取消</el-button>
</div>
</el-dialog>
<!-- 可供调课课次选择弹窗 -->
<el-dialog title="选择可供调课课次" :visible.sync="lessonDialogVisible" width="760px" append-to-body>
<el-table :data="lessonOptions" v-loading="lessonLoading" size="small" border stripe max-height="420">
<el-table-column prop="kcmc" label="课程名称" min-width="140" align="center" show-overflow-tooltip />
<el-table-column label="原上课时间" width="160" align="center">
<template slot-scope="scope">{{ fmtRqJc(scope.row.rq, scope.row.jc) }}</template>
</el-table-column>
<el-table-column prop="xydmc" label="学员队" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="kcxh" label="课次序号" width="90" align="center" />
<el-table-column prop="jsbh" label="教室编号" width="110" align="center" show-overflow-tooltip />
<el-table-column label="操作" width="90" align="center">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="pickLesson(scope.row)">选择</el-button>
</template>
</el-table-column>
</el-table>
<el-empty v-show="!lessonLoading && lessonOptions.length === 0" description="暂无可供调课课次" />
</el-dialog>
<!-- 审批弹窗 -->
<el-dialog title="教研室审批" :visible.sync="auditVisible" width="520px" append-to-body>
<el-form ref="auditForm" :model="auditForm" label-width="100px">
<el-form-item label="审批结果" required>
<el-radio-group v-model="auditForm.spzt">
<el-radio :label="1">同意</el-radio>
<el-radio :label="2">发回</el-radio>
<el-radio :label="3">拒绝</el-radio>
</el-radio-group>
<div class="form-tip">点审批即已查收</div>
</el-form-item>
<el-form-item label="审批意见">
<el-input v-model="auditForm.fhyj" type="textarea" :rows="3" placeholder="请输入审批意见(发回/拒绝时必填)" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="auditLoading" @click="submitAudit">确定</el-button>
<el-button @click="auditVisible = false">取消</el-button>
</div>
</el-dialog>
<!-- 查看详情弹窗 -->
<el-dialog title="申请详情" :visible.sync="detailVisible" width="760px" append-to-body>
<div v-loading="detailLoading">
<el-descriptions v-if="detailData" :column="2" border size="small">
<el-descriptions-item label="课程名称">{{ detailData.kcmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="申请教员">{{ detailData.sqjyxm || detailData.sqjybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="调课事由" :span="2">{{ detailData.sy || '-' }}</el-descriptions-item>
<el-descriptions-item label="原上课时间">{{ detailData.ydsjap || '-' }}</el-descriptions-item>
<el-descriptions-item label="拟调整时间">{{ fmtRqJc(detailData.rq, detailData.jc) }}</el-descriptions-item>
<el-descriptions-item label="年度">{{ detailData.nd || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ fmtDateTime(detailData.cjsj) }}</el-descriptions-item>
<el-descriptions-item label="教研室审批状态">
<el-tag :type="auditStatusTag(detailData.jyspzzt).type" size="mini">{{ auditStatusTag(detailData.jyspzzt).label }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="教研室查收状态">
<el-tag :type="receiveStatusTag(detailData.jyscszt).type" size="mini">{{ receiveStatusTag(detailData.jyscszt).label }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="教研室审批人">{{ detailData.jyspzrbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教研室审批时间">{{ fmtDateTime(detailData.jyspzsj) }}</el-descriptions-item>
<el-descriptions-item label="审批意见" :span="2">{{ detailData.fhyj || '-' }}</el-descriptions-item>
<el-descriptions-item label="教研室查收人">{{ detailData.jyscsrbh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教研室查收时间">{{ fmtDateTime(detailData.jyscssj) }}</el-descriptions-item>
<el-descriptions-item label="教学内容" :span="2">{{ detailData.jxnr || '-' }}</el-descriptions-item>
<el-descriptions-item label="教学要点" :span="2">{{ detailData.jxyd || '-' }}</el-descriptions-item>
<el-descriptions-item label="教学方法" :span="2">{{ detailData.jxff || '-' }}</el-descriptions-item>
<el-descriptions-item label="教学保障备注" :span="2">{{ detailData.jxbzbz || '-' }}</el-descriptions-item>
<el-descriptions-item label="用车信息" :span="2">{{ detailData.ycxx || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ detailData.bz || '-' }}</el-descriptions-item>
</el-descriptions>
<!-- 新教室 -->
<div v-if="detailData && detailData.roomList && detailData.roomList.length" class="sub-section">
<div class="sub-title">新教室</div>
<el-table :data="detailData.roomList" size="small" border stripe>
<el-table-column prop="jsbh" label="教室编号" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="jsmc" label="教室名称" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="bz" label="备注" min-width="160" show-overflow-tooltip header-align="center" />
</el-table>
</div>
<!-- 新辅助教员 -->
<div v-if="detailData && detailData.teacherList && detailData.teacherList.length" class="sub-section">
<div class="sub-title">新辅助教员</div>
<el-table :data="detailData.teacherList" size="small" border stripe>
<el-table-column prop="fzjybh" label="教员编号" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="fzjyxm" label="教员姓名" min-width="120" align="center" show-overflow-tooltip />
<el-table-column label="是否主教员" width="100" align="center">
<template slot-scope="scope">{{ scope.row.zjy === 1 ? '是' : '否' }}</template>
</el-table-column>
<el-table-column prop="bz" label="备注" min-width="140" show-overflow-tooltip header-align="center" />
</el-table>
</div>
<!-- 新学员队 -->
<div v-if="detailData && detailData.teamList && detailData.teamList.length" class="sub-section">
<div class="sub-title">新学员队</div>
<el-table :data="detailData.teamList" size="small" border stripe>
<el-table-column prop="xydbh" label="学员队编号" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="xydmc" label="学员队名称" min-width="140" align="center" show-overflow-tooltip />
</el-table>
</div>
<!-- 新保障明细 -->
<div v-if="detailData && detailData.supportList && detailData.supportList.length" class="sub-section">
<div class="sub-title">新保障明细</div>
<el-table :data="detailData.supportList" size="small" border stripe>
<el-table-column prop="bztgmxbh" label="保障编号" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="bztgmxmc" label="保障名称" min-width="160" align="center" show-overflow-tooltip />
<el-table-column prop="sl" label="数量" width="80" align="center" />
<el-table-column prop="bz" label="备注" min-width="140" show-overflow-tooltip header-align="center" />
</el-table>
</div>
<!-- 机关审批记录 -->
<div v-if="detailData && detailData.auditList && detailData.auditList.length" class="sub-section">
<div class="sub-title">机关审批记录</div>
<el-table :data="detailData.auditList" size="small" border stripe>
<el-table-column prop="jgmc" label="机关" min-width="140" align="center" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.jgmc || scope.row.jgbh || '-' }}</template>
</el-table-column>
<el-table-column label="审批状态" width="100" align="center">
<template slot-scope="scope">
<el-tag :type="auditStatusTag(scope.row.spzt).type" size="mini">{{ auditStatusTag(scope.row.spzt).label }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="sprxm" label="审批人" min-width="110" align="center" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.sprxm || scope.row.sprbh || '-' }}</template>
</el-table-column>
<el-table-column label="审批时间" width="150" align="center">
<template slot-scope="scope">{{ fmtDateTime(scope.row.spsj) }}</template>
</el-table-column>
<el-table-column prop="fhyj" label="发回意见" min-width="140" show-overflow-tooltip header-align="center" />
</el-table>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="detailVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listScheduleAdjust,
listAdjustableLessons,
getScheduleAdjustDetail,
submitScheduleAdjust,
auditByTeachingOffice,
cancelScheduleAdjust
} from '@/api/teachBusiness/courseRunning'
import { listAllSemester } from '@/api/teachBusiness/semester'
import { listAllClassroom } from '@/api/teachBusiness/classroom'
import { mapGetters } from 'vuex'
// 节次 -> 节次区间映射
const JC_SECTION = {
1: '1-2节', 2: '3-4节', 3: '5-6节', 4: '7-8节', 5: '9-10节', 6: '11-12节'
}
// 审批状态:0-未审批,1-已同意,2-已发回,3-已拒绝
const AUDIT_STATUS = {
0: { label: '未审批', type: 'info' },
1: { label: '已同意', type: 'success' },
2: { label: '已发回', type: 'warning' },
3: { label: '已拒绝', type: 'danger' }
}
// 查收状态:0-未查收,1-已查收
const RECEIVE_STATUS = {
0: { label: '未查收', type: 'info' },
1: { label: '已查收', type: 'success' }
}
export default {
name: 'TimetableAdjust',
data() {
return {
loading: false,
tableData: [],
total: 0,
queryParams: {
nd: undefined,
sqjybh: undefined,
jyspzzt: undefined,
pageNum: 1,
pageSize: 20
},
// 年度下拉数据来自 /semester/all(真实后端数据)
yearOptions: [],
defaultNd: undefined,
jcOptions: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
auditStatusOptions: [
{ label: '未审批', value: 0 },
{ label: '已同意', value: 1 },
{ label: '已发回', value: 2 },
{ label: '已拒绝', value: 3 }
],
statCards: this.createStatCards([0, 0, 0, 0]),
// 新增申请
addVisible: false,
addLoading: false,
addForm: {},
addRules: {
nd: [{ required: true, message: '请选择年度', trigger: 'change' }],
sskcbbh: [{ required: true, message: '请选择可供调课课次', trigger: 'change' }],
sy: [{ required: true, message: '请输入调课事由', trigger: 'blur' }],
rq: [{ required: true, message: '请选择拟调整日期', trigger: 'change' }],
jc: [{ required: true, message: '请选择拟调整节次', trigger: 'change' }]
},
// 可供调课课次
lessonDialogVisible: false,
lessonLoading: false,
lessonOptions: [],
classroomLoading: false,
classroomOptions: [],
// 审批
auditVisible: false,
auditLoading: false,
auditForm: { ssdksqbh: '', spzt: 1, fhyj: '' },
// 详情
detailVisible: false,
detailLoading: false,
detailData: null
}
},
computed: {
...mapGetters(['roles']),
isTeacher() {
const r = this.roles || []
const hasTeacher = r.includes('TEACHER') || r.includes('teacher') || r.includes('ROLE_TEACHER')
const hasAdmin = r.includes('admin') || r.includes('ROLE_ADMIN')
return hasTeacher && !hasAdmin
}
},
created() {
this.loadYearOptions().then(() => {
this.loadStatistics()
this.loadList()
})
},
methods: {
/* ---------- 年度下拉(数据来自 /semester/all) ---------- */
loadYearOptions() {
return listAllSemester().then(response => {
const list = response.data || []
// 去重并按年度倒序
const map = {}
list.forEach(item => {
if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item
})
const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a)))
this.yearOptions = arr
// 默认年度:优先当前学期(dqxq=true),否则取最新年度
const current = list.find(item => item.dqxq === true)
this.defaultNd = (current && current.nd) || arr[0]
if (!this.queryParams.nd) this.queryParams.nd = this.defaultNd
return arr
}).catch(() => {
this.yearOptions = []
this.defaultNd = undefined
return []
})
},
/* ---------- 通用格式化 ---------- */
fmtDateTime(v) {
if (!v) return '-'
return String(v).replace('T', ' ').substring(0, 16)
},
fmtRqJc(rq, jc) {
if (!rq) return '-'
const date = String(rq).substring(0, 10)
const sec = jc === null || jc === undefined || jc === '' ? '第?节' : (JC_SECTION[jc] || '第' + jc + '节')
return date + ' ' + sec
},
jcLabel(n) {
return JC_SECTION[n] || ('第' + n + '节')
},
auditStatusTag(v) {
return AUDIT_STATUS[v] || { label: '-', type: 'info' }
},
receiveStatusTag(v) {
return RECEIVE_STATUS[v] || { label: '-', type: 'info' }
},
/* ---------- 列表查询 ---------- */
loadList() {
const params = {
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize
}
if (this.queryParams.nd) params.nd = this.queryParams.nd
if (this.queryParams.sqjybh) params.sqjybh = this.queryParams.sqjybh
if (this.queryParams.jyspzzt !== undefined && this.queryParams.jyspzzt !== '') {
params.jyspzzt = this.queryParams.jyspzzt
}
this.loading = true
listScheduleAdjust(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
})
},
handleQuery() {
this.queryParams.pageNum = 1
this.loadList()
},
resetQuery() {
this.queryParams = {
nd: this.defaultNd,
sqjybh: undefined,
jyspzzt: undefined,
pageNum: 1,
pageSize: 20
}
this.loadList()
},
loadStatistics() {
const baseParams = {
nd: this.defaultNd,
pageNum: 1,
pageSize: 1
}
const statusFilters = [undefined, 0, 1, 3]
const requests = statusFilters.map(status => {
const params = Object.assign({}, baseParams)
if (status !== undefined) {
params.jyspzzt = status
}
return listScheduleAdjust(params)
.then(response => Number((response.data && response.data.total) || 0))
.catch(() => 0)
})
return Promise.all(requests).then(counts => {
this.statCards = this.createStatCards(counts)
})
},
createStatCards(counts) {
return [
{
title: '本页申请',
value: counts[0],
gradient: 'linear-gradient(135deg, #00875a 0%, #00b877 100%)',
filter: undefined
},
{
title: '教研室待审批',
value: counts[1],
gradient: 'linear-gradient(135deg, #e6a23c 0%, #f8b04c 100%)',
filter: 0
},
{
title: '教研室已同意',
value: counts[2],
gradient: 'linear-gradient(135deg, #409eff 0%, #66b1ff 100%)',
filter: 1
},
{
title: '教研室已拒绝',
value: counts[3],
gradient: 'linear-gradient(135deg, #f56c6c 0%, #f78989 100%)',
filter: 3
}
]
},
handleStatClick(card) {
this.queryParams.jyspzzt = card.filter
this.handleQuery()
},
/* ---------- 新增申请 ---------- */
openAdd() {
this.addForm = {
nd: this.defaultNd || this.yearOptions[0],
sskcbbh: '',
sy: '',
rq: '',
jc: 1,
sqjybh: '',
xydrwbh: '',
kbh: '',
kcbbh: '',
xydmc: '',
yjsbh: '',
xjsbh: '',
ydsjap: '',
jxnr: '',
jxyd: '',
jxff: '',
jxbzbz: '',
ycxx: '',
bz: '',
roomList: [],
teacherList: [],
teamList: [],
supportList: []
}
this.lessonOptions = []
this.loadClassroomOptions()
this.$nextTick(() => this.$refs.addForm && this.$refs.addForm.clearValidate())
this.addVisible = true
},
handleAddYearChange() {
Object.assign(this.addForm, {
sskcbbh: '',
rq: '',
jc: 1,
sqjybh: '',
xydrwbh: '',
kbh: '',
kcbbh: '',
xydmc: '',
yjsbh: '',
xjsbh: '',
ydsjap: '',
jxnr: '',
jxyd: '',
jxff: '',
jxbzbz: '',
ycxx: '',
bz: '',
roomList: [],
teacherList: [],
teamList: [],
supportList: []
})
this.lessonOptions = []
},
loadClassroomOptions() {
this.classroomLoading = true
return listAllClassroom().then(response => {
const classrooms = Array.isArray(response.data) ? response.data : []
this.classroomOptions = classrooms
.filter(room => room.jsbh && !this.isDisabledValue(room.ty))
.sort((first, second) => String(first.jsbh).localeCompare(String(second.jsbh), 'zh-CN'))
}).catch(() => {
this.classroomOptions = []
this.$message.warning('教室列表加载失败,请稍后重试')
}).finally(() => {
this.classroomLoading = false
})
},
classroomOptionLabel(room) {
return room.jsmc ? room.jsbh + ' · ' + room.jsmc : room.jsbh
},
isDisabledValue(value) {
return value === true || value === 1 || value === '1' || value === 'true'
},
loadAdjustableLessons() {
if (!this.addForm.nd) {
this.$message.warning('请先选择年度')
return
}
this.lessonLoading = true
listAdjustableLessons({ nd: this.addForm.nd }).then(response => {
const data = response.data || []
this.lessonOptions = Array.isArray(data) ? data : (data.records || [])
this.lessonLoading = false
this.lessonDialogVisible = true
}).catch(() => {
this.lessonLoading = false
this.$message.warning('加载可供调课课次失败,请稍后重试')
})
},
pickLesson(row) {
const lessonNumber = row.sskcbbh || row.bh || ''
if (!lessonNumber) {
this.$message.warning('当前课次缺少课次编号,无法选择')
return
}
const currentRoomNumber = row.jsbh || row.yjsbh || row.xjsbh || ''
const roomList = this.normalizeRoomList(row.roomList, currentRoomNumber)
const teamList = this.normalizeTeamList(row.teamList, row.xydbh)
Object.assign(this.addForm, {
sskcbbh: lessonNumber,
rq: row.rq ? String(row.rq).substring(0, 10) : '',
jc: row.jc === null || row.jc === undefined ? 1 : Number(row.jc),
nd: row.nd || this.addForm.nd,
sqjybh: row.sqjybh || '',
xydrwbh: row.xydrwbh || '',
kbh: row.kbh || '',
kcbbh: row.kcbbh || '',
xydmc: row.xydmc || '',
yjsbh: row.yjsbh || currentRoomNumber,
xjsbh: row.xjsbh || currentRoomNumber,
ydsjap: row.rq ? this.fmtRqJc(row.rq, row.jc) : (row.ydsjap || ''),
jxnr: row.jxnr || '',
jxyd: row.jxyd || '',
jxff: row.jxff || '',
jxbzbz: row.jxbzbz || '',
ycxx: row.ycxx || '',
bz: row.bz || '',
roomList: roomList,
teacherList: this.normalizeTeacherList(row.teacherList),
teamList: teamList,
supportList: this.normalizeSupportList(row.supportList)
})
;['jysdh', 'kcmc', 'sqjyxm'].forEach(key => {
if (row[key] !== undefined && row[key] !== null) this.addForm[key] = row[key]
})
this.lessonDialogVisible = false
this.$nextTick(() => this.$refs.addForm && this.$refs.addForm.validateField('sskcbbh'))
this.$message.success('已选择课次:' + (row.kcmc || lessonNumber))
},
submitAdd() {
this.$refs.addForm.validate(valid => {
if (!valid) return
const payload = {
sskcbbh: this.addForm.sskcbbh,
sy: this.addForm.sy,
rq: this.addForm.rq + 'T00:00:00',
jc: this.addForm.jc,
nd: this.addForm.nd,
roomList: this.buildSubmitRoomList(),
teacherList: this.normalizeTeacherList(this.addForm.teacherList),
teamList: this.normalizeTeamList(this.addForm.teamList),
supportList: this.normalizeSupportList(this.addForm.supportList)
}
const optionalFields = [
'sqjybh', 'xydrwbh', 'kbh', 'kcbbh', 'xjsbh', 'jxnr', 'jxyd',
'jxff', 'jxbzbz', 'ycxx', 'bz'
]
optionalFields.forEach(key => {
if (this.addForm[key]) payload[key] = this.addForm[key]
})
this.addLoading = true
submitScheduleAdjust(payload).then(() => {
this.addLoading = false
this.addVisible = false
this.$message.success('申请提交成功')
this.loadList()
}).catch(() => {
this.addLoading = false
})
})
},
normalizeRoomList(roomList, fallbackRoomNumber) {
const normalizedList = (Array.isArray(roomList) ? roomList : [])
.filter(item => item && item.jsbh)
.map(item => ({
jsbh: item.jsbh,
bz: item.bz || ''
}))
if (normalizedList.length === 0 && fallbackRoomNumber) {
normalizedList.push({ jsbh: fallbackRoomNumber, bz: '' })
}
return normalizedList
},
normalizeTeacherList(teacherList) {
return (Array.isArray(teacherList) ? teacherList : [])
.filter(item => item && item.fzjybh)
.map(item => ({ fzjybh: item.fzjybh }))
},
normalizeTeamList(teamList, fallbackTeamNumber) {
const normalizedList = (Array.isArray(teamList) ? teamList : [])
.filter(item => item && item.xydbh)
.map(item => ({ xydbh: item.xydbh }))
if (normalizedList.length === 0 && fallbackTeamNumber) {
normalizedList.push({ xydbh: fallbackTeamNumber })
}
return normalizedList
},
normalizeSupportList(supportList) {
return (Array.isArray(supportList) ? supportList : [])
.filter(item => item && item.bztgmxbh)
.map(item => ({
bztgmxbh: item.bztgmxbh,
sl: item.sl === null || item.sl === undefined ? undefined : Number(item.sl)
}))
},
buildSubmitRoomList() {
if (!this.addForm.xjsbh) return []
const currentRoomList = this.normalizeRoomList(this.addForm.roomList)
if (this.addForm.xjsbh === this.addForm.yjsbh && currentRoomList.length > 0) {
return currentRoomList
}
const currentRoom = currentRoomList.find(item => item.jsbh === this.addForm.xjsbh)
return [{
jsbh: this.addForm.xjsbh,
bz: currentRoom ? currentRoom.bz : ''
}]
},
/* ---------- 审批 ---------- */
showAuditMenu(row) {
// 教员角色不展示审批入口;已拒绝状态不展示审批
if (this.isTeacher) return false
return row.sczt === 0 && (row.jyspzzt === 0 || row.jyspzzt === 2)
},
openAudit(row) {
this.auditForm = {
ssdksqbh: row.ssdksqbh,
spzt: 1,
fhyj: ''
}
this.auditVisible = true
},
submitAudit() {
const f = this.auditForm
if (f.spzt !== 1 && !f.fhyj) {
this.$message.warning('发回/拒绝时请填写审批意见')
return
}
const payload = {
ssdksqbh: f.ssdksqbh,
spzt: f.spzt,
fhyj: f.fhyj
}
this.auditLoading = true
auditByTeachingOffice(payload).then(() => {
this.auditLoading = false
this.auditVisible = false
this.$message.success('审批成功')
this.loadList()
}).catch(() => {
this.auditLoading = false
})
},
/* ---------- 撤销 ---------- */
handleCancel(row) {
this.$confirm('确认撤销该调课申请?', '提示', { type: 'warning' })
.then(() => {
cancelScheduleAdjust({ ssdksqbh: row.ssdksqbh }).then(() => {
this.$message.success('撤销成功')
this.loadList()
}).catch(() => {})
})
.catch(() => {})
},
/* ---------- 详情 ---------- */
openDetail(row) {
this.detailVisible = true
this.detailLoading = true
this.detailData = null
getScheduleAdjustDetail(row.ssdksqbh).then(response => {
this.detailData = response.data || {}
this.detailLoading = false
}).catch(() => {
this.detailData = null
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.page-container {
padding: 16px;
.section-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 16px 20px;
margin-bottom: 16px;
.section-title {
font-size: 16px;
font-weight: 700;
color: #303133;
}
.section-header {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
.header-actions {
display: flex;
align-items: center;
gap: 12px;
}
}
}
/* 统计卡片 */
.stat-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
margin-top: 14px;
}
.stat-card {
display: flex;
flex-direction: column;
justify-content: center;
padding: 16px 20px;
border-radius: 6px;
color: #fff;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease;
&:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}
.stat-text {
font-size: 13px;
opacity: 0.92;
}
.stat-value {
margin-top: 8px;
font-size: 26px;
font-weight: 700;
line-height: 1;
}
}
/* 查询区域 */
.search-form {
margin-bottom: -16px;
::v-deep .el-form-item {
margin-bottom: 16px;
}
}
.compact-table {
width: 100%;
}
.danger-btn {
color: #f56c6c;
&:hover {
color: #f78989;
}
}
.ops-cell {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 0 4px;
}
.form-tip {
font-size: 12px;
color: #909399;
line-height: 1.4;
margin-top: 4px;
}
.pick-lesson-btn {
margin-top: 6px;
width: 100%;
}
.sub-section {
margin-top: 16px;
.sub-title {
font-size: 14px;
font-weight: 700;
color: #303133;
margin-bottom: 8px;
}
}
}
@media (max-width: 992px) {
.page-container .stat-grid {
grid-template-columns: repeat(2, 1fr);
}
}
</style>
@@ -0,0 +1,423 @@
<template>
<div class="app-container conflict-page">
<!-- 冲突检查区域 -->
<div class="section-card">
<div class="section-header">
<div>
<div class="section-title">教学资源冲突检查</div>
<div class="section-desc">当前检查年度:{{ nd ? nd + ' 年' : '未选择' }},可单独检查或执行全部检查</div>
</div>
<div class="header-actions">
<el-form inline class="toolbar-form" @submit.native.prevent>
<el-form-item label="年度" class="year-item">
<el-select
v-model="nd"
placeholder="请选择年度"
filterable
style="width: 130px"
@change="handleNdChange"
>
<el-option v-for="y in yearOptions" :key="y" :label="y + ' 年'" :value="y" />
</el-select>
</el-form-item>
</el-form>
<el-button size="mini" :disabled="loading" @click="handleReset">重置</el-button>
<el-button type="primary" size="mini" :loading="loading" @click="handleCheckAll">执行全部检查</el-button>
</div>
</div>
<!-- 检查项卡片网格 -->
<div class="check-grid">
<div
v-for="item in conflictItems"
:key="item.key"
class="check-item-card"
:class="{ active: activeKey === item.key }"
@click="selectCard(item)"
>
<div class="check-item-header">
<span class="check-item-name">{{ item.label }}</span>
<el-tag :type="getStatus(item).type" size="mini">{{ getStatus(item).text }}</el-tag>
</div>
<div class="check-item-desc">{{ item.desc }}</div>
<div class="check-item-footer">
<span class="conflict-count">
冲突数:
<b :class="item.count > 0 ? 'danger-text' : 'normal-text'">{{ item.count }}</b>
</span>
<el-button type="primary" plain size="mini" :disabled="loading" @click.stop="handleCheck(item)">检查</el-button>
</div>
</div>
</div>
</div>
<!-- 冲突明细区域 -->
<div class="section-card">
<div class="section-header detail-header">
<div class="section-title">
冲突明细
<span v-if="activeKey" class="active-label">— {{ activeLabel }}</span>
</div>
<span v-if="activeKey" class="detail-count">共 {{ detailTotal }} 条记录</span>
</div>
<template v-if="activeKey">
<el-table v-loading="detailLoading" :data="activeDetails" border stripe size="mini" max-height="500">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column label="冲突号" width="90" align="center" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.conflictNo || '-' }}</template>
</el-table-column>
<el-table-column prop="courseNames" label="课程" min-width="150" align="center" show-overflow-tooltip />
<el-table-column label="日期" width="100" align="center">
<template slot-scope="scope">{{ fmtDate(scope.row.rq) }}</template>
</el-table-column>
<el-table-column prop="jc" label="节次" width="70" align="center" />
<el-table-column prop="xydNames" label="班次" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="teacherNames" label="教员" min-width="120" align="center" show-overflow-tooltip />
<el-table-column prop="classroomNames" label="场地" min-width="140" align="center" show-overflow-tooltip />
<el-table-column prop="responsibleDept" label="责任单位" min-width="110" align="center" show-overflow-tooltip />
</el-table>
<el-pagination
v-if="detailTotal > 0"
class="detail-pagination"
background
layout="total, prev, pager, next"
:current-page="detailQuery.pageNum"
:page-size="detailQuery.pageSize"
:total="detailTotal"
@current-change="handlePageChange"
/>
<el-empty v-if="detailTotal === 0 && !detailLoading" description="暂无冲突明细" />
</template>
<el-empty v-else v-show="!loading" description="点击上方卡片「检查」按钮,在此查看冲突明细" />
</div>
</div>
</template>
<script>
import { checkConflict, checkAllConflict, resetConflict, getConflictDetails } from '@/api/teachBusiness/timetableConflict'
import { listAllSemester } from '@/api/teachBusiness/semester'
// 四类检查卡片定义(标题/描述与后端 TimetableConflictDimension 枚举一致,作为页面布局常量;
// 检查状态与冲突数完全来自后端接口)
const CARD_DEFS = [
{ key: 'TEAM_CONFLICT', label: '教学班时间冲突检查', desc: '同一教学班次在同一时间段被安排多门课程' },
{ key: 'ELECTIVE_REQUIRED_CONFLICT', label: '教学班必修与选修时间冲突检查', desc: '教学班次必修课与选修课时间重叠' },
{ key: 'TEACHER_CONFLICT', label: '教员时间冲突检查', desc: '同一教员在同一时间段被安排多门课程' },
{ key: 'CLASSROOM_CONFLICT', label: '教室时间冲突检查', desc: '同一教室在同一时间段被多门课程占用' }
]
export default {
name: 'TimetableConflict',
data() {
return {
loading: false,
detailLoading: false,
// 年度(数据来自 /semester/all,真实后端数据)
nd: undefined,
yearOptions: [],
conflictItems: CARD_DEFS.map(c => ({ ...c, count: 0, checked: false })),
activeKey: '',
activeDetails: [],
detailTotal: 0,
detailQuery: { pageNum: 1, pageSize: 20 }
}
},
computed: {
activeLabel() {
const item = this.conflictItems.find(i => i.key === this.activeKey)
return item ? item.label : ''
}
},
created() {
this.loadYearOptions()
},
methods: {
/* ---------- 年度下拉(数据来自 /semester/all) ---------- */
loadYearOptions() {
return listAllSemester().then(response => {
const list = response.data || []
// 去重并按年度倒序
const map = {}
list.forEach(item => {
if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item
})
const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a)))
this.yearOptions = arr
// 默认年度:优先当前学期(dqxq=true),否则取最新年度
const current = list.find(item => item.dqxq === true)
this.nd = (current && current.nd) || arr[0]
return arr
}).catch(() => {
this.yearOptions = []
this.nd = undefined
return []
})
},
fmtDate(rq) {
return (rq || '').substring(0, 10)
},
getStatus(item) {
if (!item.checked) return { type: 'info', text: '未检查' }
return item.count > 0
? { type: 'danger', text: '存在 ' + item.count + ' 处冲突' }
: { type: 'success', text: '无冲突' }
},
/* 用后端返回的单卡片结果同步对应卡片状态 */
applyCard(card) {
if (!card) return
const item = this.conflictItems.find(i => i.key === card.dimensionCode)
if (!item) return
item.checked = card.checked
item.count = card.conflictCount
},
applySummary(summary) {
if (!summary || !summary.cards) return
summary.cards.forEach(card => this.applyCard(card))
},
/* ---------- 单个检查 ---------- */
handleCheck(item) {
if (!this.nd) {
this.$message.warning('请先选择年度')
return
}
this.loading = true
checkConflict({ nd: this.nd, dimensionCode: item.key }).then(response => {
this.applyCard(response.data)
this.activeKey = item.key
this.detailQuery.pageNum = 1
this.loadDetails()
if (item.count > 0) {
this.$message.warning('「' + item.label + '」检查完成,发现 ' + item.count + ' 处冲突')
} else {
this.$message.success('「' + item.label + '」检查完成,未发现冲突')
}
}).finally(() => {
this.loading = false
})
},
/* ---------- 全部检查 ---------- */
handleCheckAll() {
if (!this.nd) {
this.$message.warning('请先选择年度')
return
}
this.loading = true
checkAllConflict({ nd: this.nd }).then(response => {
const summary = response.data
this.applySummary(summary)
const total = summary ? summary.totalConflictCount : 0
this.$message.success('全部检查完成,共发现 ' + total + ' 处冲突')
const firstConflict = this.conflictItems.find(i => i.checked && i.count > 0)
const firstChecked = this.conflictItems.find(i => i.checked)
this.activeKey = firstConflict ? firstConflict.key : (firstChecked ? firstChecked.key : '')
this.detailQuery.pageNum = 1
if (this.activeKey) {
this.loadDetails()
} else {
this.activeDetails = []
this.detailTotal = 0
}
}).finally(() => {
this.loading = false
})
},
/* ---------- 重置 ---------- */
handleReset() {
if (!this.nd) {
this.$message.warning('请先选择年度')
return
}
resetConflict({ nd: this.nd }).then(response => {
this.applySummary(response.data)
this.activeKey = ''
this.activeDetails = []
this.detailTotal = 0
this.$message.success('检查结果已重置')
})
},
/* 点击卡片:仅已检查的卡片可查看其明细 */
selectCard(item) {
if (!item.checked) return
this.activeKey = item.key
this.detailQuery.pageNum = 1
this.loadDetails()
},
/* ---------- 冲突明细 ---------- */
loadDetails() {
if (!this.activeKey) {
this.activeDetails = []
this.detailTotal = 0
return
}
this.detailLoading = true
getConflictDetails({
nd: this.nd,
dimensionCode: this.activeKey,
pageNum: this.detailQuery.pageNum,
pageSize: this.detailQuery.pageSize
}).then(response => {
const page = response.data || {}
this.activeDetails = page.records || []
this.detailTotal = page.total || 0
}).catch(() => {
this.activeDetails = []
this.detailTotal = 0
}).finally(() => {
this.detailLoading = false
})
},
handlePageChange(page) {
this.detailQuery.pageNum = page
this.loadDetails()
},
/* 切换年度:该年度检查状态未知,重置为未检查 */
handleNdChange() {
this.conflictItems.forEach(i => {
i.checked = false
i.count = 0
})
this.activeKey = ''
this.activeDetails = []
this.detailTotal = 0
this.detailQuery.pageNum = 1
}
}
}
</script>
<style scoped lang="scss">
.conflict-page {
.section-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 16px 20px;
margin-bottom: 16px;
.section-title {
font-size: 16px;
font-weight: 700;
color: #303133;
}
.section-header {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
.header-actions {
display: flex;
align-items: center;
gap: 12px;
.toolbar-form {
margin-right: 4px;
.year-item {
margin-bottom: 0;
}
}
}
}
.section-desc {
margin-top: 8px;
font-size: 13px;
color: #909399;
}
.detail-header {
margin-bottom: 12px;
}
}
/* 检查项卡片网格 */
.check-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16px;
}
.check-item-card {
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 14px 16px;
transition: box-shadow 0.2s ease;
cursor: pointer;
&:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
&.active {
border-color: var(--edu-green-primary, #00875a);
box-shadow: 0 0 0 2px rgba(0, 135, 90, 0.15);
}
.check-item-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
.check-item-name {
font-size: 14px;
font-weight: 600;
color: #303133;
}
}
.check-item-desc {
margin-top: 8px;
font-size: 12px;
color: #909399;
line-height: 1.5;
}
.check-item-footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 12px;
.conflict-count {
font-size: 13px;
color: #606266;
b {
font-size: 18px;
}
}
}
}
.danger-text {
color: #f56c6c;
font-weight: 700;
}
.normal-text {
color: #67c23a;
font-weight: 700;
}
.active-label {
font-size: 14px;
font-weight: 400;
color: var(--edu-green-primary, #00875a);
}
.detail-count {
font-size: 13px;
color: #909399;
}
.detail-pagination {
margin-top: 12px;
text-align: right;
}
}
</style>
@@ -0,0 +1,776 @@
<template>
<div class="app-container training-plan-page">
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="100px" class="search-form" @submit.native.prevent>
<el-row :gutter="24">
<el-col :xs="24" :md="8">
<el-form-item label="专业名称">
<el-input v-model="searchForm.zymc" placeholder="请输入专业名称" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="专业代码">
<el-input v-model="searchForm.zydm" placeholder="请输入专业代码" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="培训类型">
<el-select
v-model="searchForm.pxlx"
placeholder="请选择培训类型"
clearable
filterable
class="w-full"
>
<el-option
v-for="item in trainingTypeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="培训层次">
<el-select
v-model="searchForm.pxcc"
placeholder="请选择培训层次"
clearable
filterable
class="w-full"
>
<el-option
v-for="item in trainingLevelOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<div class="search-actions">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- ==================== 2. 操作与上传区域 ==================== -->
<el-card shadow="never" class="action-card">
<div class="action-row">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建</el-button>
<el-button icon="el-icon-download" @click="handleDownload">下载</el-button>
</div>
<div class="action-row">
<el-button icon="el-icon-download" @click="handleTemplateDownload">【人才培养方案目录模板】下载</el-button>
</div>
<div class="upload-row">
<div class="upload-left">
<el-button icon="el-icon-folder-opened" @click="handleChooseFile">选择文件</el-button>
<span class="file-name" :class="{ 'has-file': selectedFile }">
<template v-if="selectedFile">{{ fileName }}</template>
<template v-else>请选择要上传的文件</template>
</span>
<input ref="fileInputRef" type="file" style="display: none" @change="handleFileChange" />
</div>
<div class="upload-right">
<el-button type="primary" icon="el-icon-upload2" :disabled="!selectedFile" @click="handleUpload">上传数据</el-button>
</div>
</div>
</el-card>
<!-- ==================== 3. 数据表格区域 ==================== -->
<el-card shadow="never" class="table-card">
<div class="list-header">
<div class="list-title">人才培养方案列表</div>
</div>
<el-table v-loading="loading" :data="tableData" border stripe highlight-current-row>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="zydh" label="专业代号" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="zymc" label="专业名称" width="140" align="center" show-overflow-tooltip />
<el-table-column prop="zyfx" label="专业方向" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="zydm" label="专业代码" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="pxlx" label="培训类型" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="pxcc" label="培训层次" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="pxlx2" label="培训类型2" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="xylb" label="学员类别" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="xnz" label="学年制" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="xqs" label="学期数" width="80" align="center" />
<el-table-column prop="zybb" label="专业版本" width="100" align="center" show-overflow-tooltip />
<el-table-column label="主干专业" width="90" align="center">
<template slot-scope="scope">{{ fmtYesNo(scope.row.zgzy) }}</template>
</el-table-column>
<el-table-column label="状态" width="80" align="center">
<template slot-scope="scope">
<el-tag :type="isTrue(scope.row.ty) ? 'danger' : 'success'" size="mini">
{{ isTrue(scope.row.ty) ? '停用' : '启用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="启用时间" width="150" align="center">
<template slot-scope="scope">{{ fmtDateTime(scope.row.qysj) }}</template>
</el-table-column>
<el-table-column label="停用时间" width="150" align="center">
<template slot-scope="scope">{{ fmtDateTime(scope.row.tysj) }}</template>
</el-table-column>
<el-table-column label="操作" width="240" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="mini" icon="el-icon-view" @click="handleDetail(scope.row)">详情</el-button>
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="text" size="mini" icon="el-icon-circle-close" class="danger-text-btn"
:disabled="isTrue(scope.row.ty)" @click="handleDisable(scope.row)">停用</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagination"
background
layout="total, sizes, prev, pager, next, jumper"
:current-page="pageNum"
:page-size="pageSize"
:total="total"
:page-sizes="[10, 20, 50, 100]"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</el-card>
<!-- 新增/编辑弹窗 -->
<el-dialog :title="dialog.title" :visible.sync="dialog.visible" width="860px" append-to-body
:close-on-click-modal="false">
<el-form ref="trainingForm" :model="dialog.form" :rules="rules" label-width="130px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="专业名称" prop="zymc">
<el-input v-model="dialog.form.zymc" placeholder="请输入专业名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业方向">
<el-select
v-model="dialog.form.zyfx"
placeholder="请选择专业方向"
clearable
filterable
class="training-dict-select"
>
<el-option
v-for="item in majorDirectionOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训层次" prop="pxcc">
<el-select
v-model="dialog.form.pxcc"
placeholder="请选择培训层次"
filterable
class="training-dict-select"
>
<el-option
v-for="item in trainingLevelOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训类型" prop="pxlx">
<el-select
v-model="dialog.form.pxlx"
placeholder="请选择培训类型"
filterable
class="training-dict-select"
>
<el-option
v-for="item in trainingTypeOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训类型2">
<el-input v-model="dialog.form.pxlx2" placeholder="请输入培训类型2" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学员类别">
<el-select
v-model="dialog.form.xylb"
placeholder="请选择学员类别"
clearable
filterable
class="training-dict-select"
>
<el-option
v-for="item in studentCategoryOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学年制">
<el-input v-model="dialog.form.xnz" placeholder="请输入学年制" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学期数">
<el-input-number v-model="dialog.form.xqs" :min="1" :max="20" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业版本">
<el-input v-model="dialog.form.zybb" placeholder="请输入专业版本" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="自定义分类">
<el-input v-model="dialog.form.zdyfl" placeholder="请输入自定义分类" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教学管理机构">
<el-select
v-model="dialog.form.jxgljgbh"
placeholder="请选择教学管理机构"
clearable
filterable
class="training-dict-select"
>
<el-option
v-for="item in teachingOrganizationOptions"
:key="item.dictCode || item.dictValue"
:label="item.dictLabel"
:value="item.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规范名称">
<el-input v-model="dialog.form.gfmc" placeholder="请输入规范名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业规范">
<el-input v-model="dialog.form.zygf" placeholder="请输入专业规范" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="简称">
<el-input v-model="dialog.form.jc" placeholder="请输入简称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="主干专业">
<el-radio-group v-model="dialog.form.zgzy">
<el-radio :label="true">是</el-radio>
<el-radio :label="false">否</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="专业备注">
<el-input v-model="dialog.form.zybz" placeholder="请输入专业备注" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="培养目标">
<el-input v-model="dialog.form.pymb" type="textarea" :rows="3" placeholder="请输入培养目标" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialog.visible = false">取 消</el-button>
<el-button type="primary" :loading="dialog.submitting" @click="submitDialog">确 定</el-button>
</div>
</el-dialog>
<!-- 详情弹窗 -->
<el-dialog title="人才培养方案详情" :visible.sync="detail.visible" width="760px" append-to-body
:close-on-click-modal="false">
<div v-loading="detail.loading" class="detail-body">
<el-descriptions :column="2" border>
<el-descriptions-item label="专业代号">{{ fmtVal(detail.data.zydh) }}</el-descriptions-item>
<el-descriptions-item label="专业名称">{{ fmtVal(detail.data.zymc) }}</el-descriptions-item>
<el-descriptions-item label="专业代码">{{ fmtVal(detail.data.zydm) }}</el-descriptions-item>
<el-descriptions-item label="专业方向">{{ fmtVal(detail.data.zyfx) }}</el-descriptions-item>
<el-descriptions-item label="培训类型">{{ fmtVal(detail.data.pxlx) }}</el-descriptions-item>
<el-descriptions-item label="培训层次">{{ fmtVal(detail.data.pxcc) }}</el-descriptions-item>
<el-descriptions-item label="培训类型2">{{ fmtVal(detail.data.pxlx2) }}</el-descriptions-item>
<el-descriptions-item label="学员类别">{{ fmtVal(detail.data.xylb) }}</el-descriptions-item>
<el-descriptions-item label="学年制">{{ fmtVal(detail.data.xnz) }}</el-descriptions-item>
<el-descriptions-item label="学期数">{{ fmtVal(detail.data.xqs) }}</el-descriptions-item>
<el-descriptions-item label="专业版本">{{ fmtVal(detail.data.zybb) }}</el-descriptions-item>
<el-descriptions-item label="主干专业">{{ fmtYesNo(detail.data.zgzy) }}</el-descriptions-item>
<el-descriptions-item label="自定义分类">{{ fmtVal(detail.data.zdyfl) }}</el-descriptions-item>
<el-descriptions-item label="教学管理机构">{{ fmtVal(detail.data.jxgljgbh) }}</el-descriptions-item>
<el-descriptions-item label="规范名称">{{ fmtVal(detail.data.gfmc) }}</el-descriptions-item>
<el-descriptions-item label="专业规范">{{ fmtVal(detail.data.zygf) }}</el-descriptions-item>
<el-descriptions-item label="简称">{{ fmtVal(detail.data.jc) }}</el-descriptions-item>
<el-descriptions-item label="专业标识号">{{ fmtVal(detail.data.zybsh) }}</el-descriptions-item>
<el-descriptions-item label="学科专业信息标识号">{{ fmtVal(detail.data.xkzyxxbsh) }}</el-descriptions-item>
<el-descriptions-item label="教学大纲编号">{{ fmtVal(detail.data.jxdgbh) }}</el-descriptions-item>
<el-descriptions-item label="人培编号">{{ fmtVal(detail.data.rpbh) }}</el-descriptions-item>
<el-descriptions-item label="节次类别">{{ fmtVal(detail.data.jclb) }}</el-descriptions-item>
<el-descriptions-item label="系统模式">{{ fmtVal(detail.data.xtms) }}</el-descriptions-item>
<el-descriptions-item label="启用时间">{{ fmtDateTime(detail.data.qysj) }}</el-descriptions-item>
<el-descriptions-item label="停用时间">{{ fmtDateTime(detail.data.tysj) }}</el-descriptions-item>
<el-descriptions-item label="专业备注" :span="2">{{ fmtVal(detail.data.zybz) }}</el-descriptions-item>
<el-descriptions-item label="培养目标" :span="2">{{ fmtVal(detail.data.pymb) }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="detail.visible = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import {
addTraining,
disableTraining,
updateTraining,
getTraining,
listTraining,
exportTrainingProgram,
downloadTrainingProgramTemplate,
importTrainingProgram
} from '@/api/teachBusiness/training'
import { getDicts } from '@/api/system/dict/data'
import { optionselect } from '@/api/system/dict/type'
const TRAINING_TYPE_DICT_CODE = 'train_type'
const TRAINING_LEVEL_DICT_CODE = 'train_level'
export default {
name: 'TrainingPlan',
data() {
return {
loading: false,
// 查询条件(仅传后端 ZYBMapper 支持的字段)
searchForm: {
zymc: '',
zydm: '',
pxlx: '',
pxcc: ''
},
trainingTypeOptions: [],
trainingLevelOptions: [],
majorDirectionOptions: [],
studentCategoryOptions: [],
teachingOrganizationOptions: [],
// 列表
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
// 上传
selectedFile: null,
fileName: '',
// 新增/编辑弹窗
dialog: {
visible: false,
title: '',
isEdit: false,
submitting: false,
form: this.createEmptyForm()
},
// 详情弹窗
detail: {
visible: false,
loading: false,
data: {}
},
rules: {
zymc: [{ required: true, message: '请输入专业名称', trigger: 'blur' }],
pxcc: [{ required: true, message: '请选择培训层次', trigger: 'change' }],
pxlx: [{ required: true, message: '请选择培训类型', trigger: 'change' }]
}
}
},
created() {
this.loadTrainingDictionaries()
this.fetchList()
},
methods: {
/**
* 从系统字典加载表单下拉选项;文本业务字段提交标签,机构字段提交编号。
*/
async loadTrainingDictionaries() {
const emptyResponse = { data: [] }
const [typeResponse, levelResponse, dictTypeResponse] = await Promise.all([
getDicts(TRAINING_TYPE_DICT_CODE).catch(() => emptyResponse),
getDicts(TRAINING_LEVEL_DICT_CODE).catch(() => emptyResponse),
optionselect().catch(() => emptyResponse)
])
this.trainingTypeOptions = typeResponse.data || []
this.trainingLevelOptions = levelResponse.data || []
const dictTypes = dictTypeResponse.data || []
const [directionOptions, categoryOptions, organizationOptions] = await Promise.all([
this.loadNamedDictionary(dictTypes, '专业方向'),
this.loadNamedDictionary(dictTypes, '学员类别'),
this.loadNamedDictionary(dictTypes, '教学管理机构')
])
this.majorDirectionOptions = directionOptions
this.studentCategoryOptions = categoryOptions
this.teachingOrganizationOptions = organizationOptions
this.mergeExistingSelectOptions()
},
async loadNamedDictionary(dictTypes, dictName) {
const dictType = dictTypes.find(item => item.dictName === dictName) ||
dictTypes.find(item => String(item.dictName || '').includes(dictName))
if (!dictType || !dictType.dictType) {
return []
}
try {
const response = await getDicts(dictType.dictType)
return response.data || []
} catch (error) {
return []
}
},
mergeExistingSelectOptions() {
this.majorDirectionOptions = this.mergeTextOptions(this.majorDirectionOptions, 'zyfx', true)
this.studentCategoryOptions = this.mergeTextOptions(this.studentCategoryOptions, 'xylb', true)
this.teachingOrganizationOptions = this.mergeTextOptions(
this.teachingOrganizationOptions,
'jxgljgbh',
false
)
},
mergeTextOptions(dictionaryOptions, fieldName, usesLabel) {
const options = dictionaryOptions.slice()
const existingValues = new Set(options.map(item => String(usesLabel ? item.dictLabel : item.dictValue)))
this.tableData.forEach(row => {
const value = row[fieldName]
if (value === '' || value === null || value === undefined || existingValues.has(String(value))) {
return
}
options.push({
dictLabel: String(value),
dictValue: String(value)
})
existingValues.add(String(value))
})
return options
},
/* ---------- 列表加载 ---------- */
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
Object.keys(this.searchForm).forEach(key => {
const value = this.searchForm[key]
if (value !== '' && value !== null && value !== undefined) {
params[key] = value
}
})
listTraining(params).then(response => {
const data = response.data || {}
this.tableData = data.records || []
this.total = data.total || 0
this.mergeExistingSelectOptions()
}).catch(() => {
this.tableData = []
this.total = 0
}).finally(() => {
this.loading = false
})
},
/* ---------- 查询 / 重置 ---------- */
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handleReset() {
this.searchForm = { zymc: '', zydm: '', pxlx: '', pxcc: '' }
this.pageNum = 1
this.fetchList()
},
/* ---------- 分页 ---------- */
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
/* ---------- 新增 / 编辑 ---------- */
handleAdd() {
this.dialog.title = '新建人才培养方案'
this.dialog.isEdit = false
this.dialog.form = this.createEmptyForm()
this.dialog.visible = true
this.$nextTick(() => {
if (this.$refs.trainingForm) this.$refs.trainingForm.clearValidate()
})
},
handleEdit(row) {
this.dialog.title = '编辑人才培养方案'
this.dialog.isEdit = true
this.dialog.form = Object.assign({}, this.createEmptyForm(), row)
this.dialog.visible = true
this.$nextTick(() => {
if (this.$refs.trainingForm) this.$refs.trainingForm.clearValidate()
})
},
submitDialog() {
this.$refs.trainingForm.validate(valid => {
if (!valid) return
this.dialog.submitting = true
const payload = this.cleanPayload(this.dialog.form)
const isEdit = this.dialog.isEdit
const req = isEdit ? updateTraining(payload) : addTraining(payload)
req.then(() => {
this.$message.success(isEdit ? '修改成功' : '新增成功')
this.dialog.visible = false
this.fetchList()
}).catch(() => {}).finally(() => {
this.dialog.submitting = false
})
})
},
/* ---------- 详情 ---------- */
handleDetail(row) {
this.detail.visible = true
this.detail.loading = true
this.detail.data = {}
getTraining(row.zydh).then(response => {
this.detail.data = response.data || {}
}).catch(() => {
this.detail.data = {}
}).finally(() => {
this.detail.loading = false
})
},
/* ---------- 停用(逻辑删除) ---------- */
handleDisable(row) {
this.$confirm('确定停用人才培养方案「' + (row.zymc || row.zydh) + '」吗?停用后列表不再展示。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return disableTraining(row.zydh)
}).then(() => {
this.$message.success('停用成功')
this.fetchList()
}).catch(() => {})
},
/* ---------- 下载 / 模板下载 / 上传 ---------- */
handleDownload() {
exportTrainingProgram().then(blob => {
saveAs(blob, '人才培养方案课程数据文件.xlsx')
this.$message.success('导出成功')
}).catch(() => {})
},
handleTemplateDownload() {
downloadTrainingProgramTemplate().then(blob => {
saveAs(blob, '人才培养方案课程数据文件模板.xls')
this.$message.success('模板下载成功')
}).catch(() => {})
},
handleChooseFile() {
this.$refs.fileInputRef && this.$refs.fileInputRef.click()
},
handleFileChange(e) {
const file = e.target.files && e.target.files[0]
this.selectedFile = file || null
this.fileName = file ? file.name : ''
},
handleUpload() {
if (!this.selectedFile) {
this.$message.warning('请先选择文件')
return
}
importTrainingProgram(this.selectedFile).then(response => {
const count = (response && response.data) || 0
this.$message.success(`导入成功,共导入 ${count} 条`)
this.selectedFile = null
this.fileName = ''
if (this.$refs.fileInputRef) this.$refs.fileInputRef.value = ''
this.fetchList()
}).catch(() => {})
},
/* ---------- 工具 ---------- */
createEmptyForm() {
return {
zydh: '',
zymc: '',
zyfx: '',
zydm: '',
pxcc: '',
pxlx: '',
pxlx2: '',
xylb: '',
xnz: '',
xqs: null,
zybb: '',
zdyfl: '',
jxgljgbh: '',
gfmc: '',
zygf: '',
jc: '',
zgzy: false,
zybz: '',
pymb: ''
}
},
/** 移除空值(''/null/undefined),保留 0/false 等有效值 */
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
isTrue(val) {
return val === true || val === 1 || val === '1' || val === 'true'
},
fmtYesNo(val) {
return this.isTrue(val) ? '是' : '否'
},
fmtDateTime(val) {
const s = (val || '').substring(0, 10)
return s || '-'
},
fmtVal(val) {
return val === '' || val === null || val === undefined ? '-' : val
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.training-plan-page {
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
.search-actions {
padding-top: 4px;
}
}
}
.action-card {
margin-bottom: 16px;
.action-row {
margin-bottom: 12px;
&:last-of-type {
margin-bottom: 0;
}
}
.upload-row {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
padding: 12px;
background: #fafafa;
border: 1px dashed #dcdfe6;
border-radius: 4px;
.upload-left {
display: flex;
align-items: center;
gap: 12px;
.file-name {
font-size: 13px;
color: #909399;
&.has-file {
color: #409eff;
}
}
}
}
}
.table-card {
.list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
}
.pagination {
margin-top: 16px;
text-align: right;
}
}
.detail-body {
min-height: 60px;
}
}
.danger-text-btn {
color: #f56c6c;
&:hover {
color: #f78989;
}
}
.training-dict-select {
width: 100%;
}
</style>
@@ -0,0 +1,495 @@
<template>
<div class="app-container venue-page">
<!-- 查询条件 -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="100px" class="search-form" @submit.native.prevent>
<el-row :gutter="24">
<el-col :xs="24" :md="8">
<el-form-item label="教室编号">
<el-input v-model="searchForm.jsbh" placeholder="请输入教室编号" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="教室名称">
<el-input v-model="searchForm.jsmc" placeholder="请输入教室名称" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="教学楼代号">
<el-input v-model="searchForm.jxldh" placeholder="请输入教学楼代号" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="教学场地类型">
<el-select v-model="searchForm.jxcdlx" placeholder="请选择场地类型" clearable filterable allow-create
default-first-option class="w-full">
<el-option v-for="item in jxcdlxOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<el-form-item label="停用">
<el-radio-group v-model="searchForm.ty">
<el-radio :label="false">否</el-radio>
<el-radio :label="true">是</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :xs="24" :md="8">
<div class="search-actions">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- 数据列表 -->
<el-card shadow="never" class="table-card">
<div class="list-header">
<div class="list-title">教室列表</div>
<div class="list-actions">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
<el-button icon="el-icon-download" @click="handleDownloadTemplate">【教学场地管理模板】下载</el-button>
</div>
</div>
<el-table v-loading="loading" :data="tableData" border stripe highlight-current-row>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="jsbh" label="教室编号" width="130" align="center" show-overflow-tooltip />
<el-table-column prop="jsmc" label="教室名称" width="140" align="center" show-overflow-tooltip />
<el-table-column prop="jxldh" label="教学楼代号" width="150" align="center" show-overflow-tooltip />
<el-table-column prop="jxcdlx" label="教学场地类型" width="150" align="center" show-overflow-tooltip />
<el-table-column prop="jc" label="简称" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="rnrs" label="容纳人数" width="90" align="center" />
<el-table-column prop="mj" label="面积" width="90" align="center" />
<el-table-column prop="ksrnrs" label="考试容纳人数" width="110" align="center" />
<el-table-column prop="ewyxkbs" label="额外可开班数" width="100" align="center" />
<el-table-column label="虚实类型" width="90" align="center">
<template slot-scope="scope">{{ fmtXslx(scope.row.xslx) }}</template>
</el-table-column>
<el-table-column label="停用" width="80" align="center">
<template slot-scope="scope">
<el-tag :type="isTrue(scope.row.ty) ? 'danger' : 'success'" size="mini">
{{ isTrue(scope.row.ty) ? '停用' : '正常' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="sssb" label="设施设备" width="140" show-overflow-tooltip header-align="center" />
<el-table-column label="操作" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="text" size="mini" icon="el-icon-delete" class="danger-text-btn" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagination"
background
layout="total, sizes, prev, pager, next"
:current-page="pageNum"
:page-size="pageSize"
:total="total"
:page-sizes="[10, 20, 50, 100]"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</el-card>
<!-- 新增/编辑弹窗 -->
<el-dialog :title="dialog.title" :visible.sync="dialog.visible" width="780px" append-to-body
:close-on-click-modal="false">
<el-form ref="classroomForm" :model="dialog.form" :rules="rules" label-width="110px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="教室名称" prop="jsmc">
<el-input v-model="dialog.form.jsmc" placeholder="请输入教室名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教学楼代号">
<el-input v-model="dialog.form.jxldh" placeholder="请输入教学楼代号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教学场地类型">
<el-select v-model="dialog.form.jxcdlx" placeholder="请选择场地类型" clearable filterable allow-create
default-first-option class="w-full">
<el-option v-for="item in jxcdlxOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="简称">
<el-input v-model="dialog.form.jc" placeholder="请输入简称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="容纳人数">
<el-input-number v-model="dialog.form.rnrs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="面积">
<div class="number-unit-field">
<el-input-number
v-model="dialog.form.mj"
:min="0"
:precision="1"
controls-position="right"
/>
<span class="number-unit">㎡</span>
</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试容纳人数">
<el-input-number v-model="dialog.form.ksrnrs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="额外可开班数">
<el-input-number v-model="dialog.form.ewyxkbs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="拼音">
<el-input v-model="dialog.form.py" placeholder="请输入拼音" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="虚实类型">
<el-radio-group v-model="dialog.form.xslx">
<el-radio :label="true">实教</el-radio>
<el-radio :label="false">非实教</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="停用">
<el-radio-group v-model="dialog.form.ty">
<el-radio :label="false">正常</el-radio>
<el-radio :label="true">停用</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="设施设备">
<el-input v-model="dialog.form.sssb" placeholder="请输入设施设备" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注">
<el-input v-model="dialog.form.bz" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialog.visible = false">取 消</el-button>
<el-button type="primary" :loading="dialog.submitting" @click="submitDialog">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import {
addClassroom,
deleteClassroom,
updateClassroom,
listClassroom,
listAllClassroom,
downloadClassroomTemplate
} from '@/api/teachBusiness/classroom'
export default {
name: 'Venue',
data() {
return {
loading: false,
searchForm: {
jsbh: '',
jsmc: '',
jxldh: '',
jxcdlx: '',
ty: false
},
tableData: [],
jxcdlxOptions: [],
total: 0,
pageNum: 1,
pageSize: 20,
dialog: {
visible: false,
title: '',
submitting: false,
form: this.createEmptyForm()
},
rules: {
jsmc: [{ required: true, message: '请输入教室名称', trigger: 'blur' }]
}
}
},
created() {
this.loadVenueTypeOptions()
this.fetchList()
},
methods: {
/**
* 独立加载全部场地类型,避免查询结果收窄后下拉候选项同步丢失。
*/
loadVenueTypeOptions() {
return listAllClassroom().then(response => {
this.jxcdlxOptions = this.collectVenueTypes(response.data || [])
}).catch(() => {
// 全量接口异常时保留已收集选项,避免影响列表的基本查询功能。
this.mergeVenueTypeOptions(this.tableData)
})
},
collectVenueTypes(classrooms) {
const venueTypes = new Set()
classrooms.forEach(classroom => {
const venueType = classroom.jxcdlx && String(classroom.jxcdlx).trim()
if (venueType) {
venueTypes.add(venueType)
}
})
return Array.from(venueTypes).sort((first, second) => first.localeCompare(second, 'zh-CN'))
},
mergeVenueTypeOptions(classrooms) {
const venueTypes = new Set(this.jxcdlxOptions)
this.collectVenueTypes(classrooms).forEach(venueType => venueTypes.add(venueType))
this.jxcdlxOptions = Array.from(venueTypes)
.sort((first, second) => first.localeCompare(second, 'zh-CN'))
},
/* ---------- 列表加载 ---------- */
fetchList() {
this.loading = true
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
Object.keys(this.searchForm).forEach(key => {
const value = this.searchForm[key]
if (value !== '' && value !== null && value !== undefined) {
params[key] = value
}
})
listClassroom(params).then(response => {
const data = response.data || {}
this.tableData = data.records || []
this.mergeVenueTypeOptions(this.tableData)
this.total = data.total || 0
}).catch(() => {
this.tableData = []
this.total = 0
}).finally(() => {
this.loading = false
})
},
/* ---------- 查询 / 重置 ---------- */
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handleReset() {
this.searchForm = {
jsbh: '',
jsmc: '',
jxldh: '',
jxcdlx: '',
ty: false
}
this.pageNum = 1
this.fetchList()
},
/* ---------- 分页 ---------- */
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
/* ---------- 新增 / 编辑 ---------- */
handleAdd() {
this.dialog.title = '新增教学场地'
this.dialog.form = this.createEmptyForm()
this.dialog.visible = true
this.$nextTick(() => {
if (this.$refs.classroomForm) this.$refs.classroomForm.clearValidate()
})
},
handleEdit(row) {
this.dialog.title = '编辑教学场地'
this.dialog.form = Object.assign({}, this.createEmptyForm(), row)
this.dialog.visible = true
this.$nextTick(() => {
if (this.$refs.classroomForm) this.$refs.classroomForm.clearValidate()
})
},
submitDialog() {
this.$refs.classroomForm.validate(valid => {
if (!valid) return
this.dialog.submitting = true
const payload = this.cleanPayload(this.dialog.form)
const isEdit = !!payload.id
const req = isEdit ? updateClassroom(payload) : addClassroom(payload)
req.then(() => {
this.$message.success(isEdit ? '修改成功' : '新增成功')
this.dialog.visible = false
this.loadVenueTypeOptions()
this.fetchList()
}).catch(() => {}).finally(() => {
this.dialog.submitting = false
})
})
},
/* ---------- 删除(后端仅提供单条删除,参数为 id) ---------- */
handleDelete(row) {
this.$confirm('确定删除教室「' + (row.jsmc || row.jsbh) + '」吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return deleteClassroom(row.id)
}).then(() => {
this.$message.success('删除成功')
this.loadVenueTypeOptions()
this.fetchList()
}).catch(() => {})
},
/* ---------- 模板下载 ---------- */
handleDownloadTemplate() {
downloadClassroomTemplate().then(blob => {
saveAs(blob, '教学场地管理模板.xls')
this.$message.success('模板下载成功')
}).catch(() => {})
},
/* ---------- 工具 ---------- */
createEmptyForm() {
return {
id: '',
jsbh: '',
jsmc: '',
jxldh: '',
jxcdlx: '',
jc: '',
rnrs: null,
mj: null,
ksrnrs: null,
ewyxkbs: null,
xh: '',
py: '',
xslx: false,
ty: false,
sssb: '',
bz: ''
}
},
/** 移除空值(''/null/undefined),保留 0/false 等有效值 */
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
isTrue(val) {
return val === true || val === 1 || val === '1' || val === 'true'
},
fmtXslx(val) {
return this.isTrue(val) ? '实教' : '非实教'
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.venue-page {
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
.search-actions {
padding-top: 4px;
}
}
}
.table-card {
.list-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
}
.pagination {
margin-top: 16px;
text-align: right;
}
}
}
.number-unit-field {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
.el-input-number {
flex: 1;
width: auto;
min-width: 0;
}
.number-unit {
display: inline-flex;
flex: none;
align-items: center;
justify-content: center;
height: 36px;
color: #606266;
}
}
.danger-text-btn {
color: #f56c6c;
&:hover {
color: #f78989;
}
}
</style>
+437
View File
@@ -0,0 +1,437 @@
<template>
<div class="app-container teach-notice">
<!-- 查询条件区域 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="标题" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入标题"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="公告类别">
<el-select
v-model="queryParams.category"
placeholder="请选择"
clearable
style="width: 160px"
>
<el-option
v-for="item in categoryOptions"
:key="item"
:label="item"
:value="item"
/>
</el-select>
</el-form-item>
<el-form-item label="发布日期">
<el-date-picker
v-model="queryParams.publishDateFrom"
type="date"
placeholder="从"
value-format="yyyy-MM-dd"
style="width: 140px"
/>
<span class="range-sep">-</span>
<el-date-picker
v-model="queryParams.publishDateTo"
type="date"
placeholder="到"
value-format="yyyy-MM-dd"
style="width: 140px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 数据列表区域 -->
<div class="list-heading">
<div class="list-title">公告列表</div>
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</div>
<el-table v-loading="loading" :data="noticeList" border :height="tableHeight">
<el-table-column label="序号" type="index" align="center" width="70" />
<el-table-column label="发布时间" align="center" width="165">
<template slot-scope="scope">{{ formatTime(scope.row.publishTime) }}</template>
</el-table-column>
<el-table-column label="标题" align="left" prop="title" min-width="300" :show-overflow-tooltip="true" />
<el-table-column label="公告状态" align="center" width="100">
<template slot-scope="scope">
<el-tag :type="statusTagType(scope.row.status)">{{ scope.row.status }}</el-tag>
</template>
</el-table-column>
<el-table-column label="公告类别" align="center" prop="category" width="110" />
<el-table-column label="优先级" align="center" prop="priority" width="80" />
<el-table-column label="阅读次数" align="center" prop="readCount" width="90" />
<el-table-column label="接收/已读" align="center" width="110">
<template slot-scope="scope">{{ scope.row.recipientCount }}/{{ scope.row.readerCount }}</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
width="300"
fixed="right"
class-name="small-padding fixed-width action-column"
>
<template slot-scope="scope">
<el-button
type="text"
size="mini"
icon="el-icon-view"
@click="handleView(scope.row)"
>详情</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
v-if="scope.row.status !== '已下架'"
type="text"
size="mini"
icon="el-icon-download"
@click="handleOffline(scope.row)"
>下架</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
style="color: #f56c6c"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 新增/修改 对话框 -->
<el-dialog
:title="dialogTitle"
:visible="dialogVisible"
:close-on-click-modal="false"
width="600px"
@update:visible="handleDialogVisible"
>
<el-form ref="noticeForm" :model="form" :rules="rules" label-width="80px">
<el-form-item label="公告标题" prop="title">
<el-input v-model="form.title" placeholder="请输入公告标题" />
</el-form-item>
<el-form-item label="公告类别" prop="category">
<el-select v-model="form.category" placeholder="请选择公告类别" clearable>
<el-option v-for="item in categoryOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="公告正文" prop="content">
<el-input type="textarea" v-model="form.content" rows="8" placeholder="请输入公告正文" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" size="mini" @click="submitForm">确 定</el-button>
<el-button size="mini" @click="handleDialogVisible(false)">取 消</el-button>
</div>
</el-dialog>
<!-- 详情 对话框 -->
<el-dialog
title="公告详情"
:visible="viewVisible"
:close-on-click-modal="false"
width="600px"
@update:visible="handleViewVisible"
>
<div class="detail-body">
<div class="detail-row">
<span class="detail-label">公告标题</span>
<span class="detail-value">{{ viewForm.title }}</span>
</div>
<div class="detail-row">
<span class="detail-label">公告类别</span>
<span class="detail-value">{{ viewForm.category }}</span>
</div>
<div class="detail-row">
<span class="detail-label">公告状态</span>
<span class="detail-value">{{ viewForm.status }}</span>
</div>
<div class="detail-row">
<span class="detail-label">优先级</span>
<span class="detail-value">{{ viewForm.priority }}</span>
</div>
<div class="detail-row">
<span class="detail-label">发布时间</span>
<span class="detail-value">{{ viewForm.publishTime }}</span>
</div>
<div class="detail-row">
<span class="detail-label">阅读次数</span>
<span class="detail-value">{{ viewForm.readCount }}</span>
</div>
<div class="detail-row">
<span class="detail-label">接收/已读</span>
<span class="detail-value">{{ viewForm.recipientCount }}/{{ viewForm.readerCount }}</span>
</div>
<div class="detail-row">
<span class="detail-label">发布范围</span>
<span class="detail-value">{{ viewForm.scopeName }}</span>
</div>
<div class="detail-row">
<span class="detail-label">公告正文</span>
<span class="detail-value detail-content">{{ viewForm.content }}</span>
</div>
<div class="detail-row">
<span class="detail-label">备注</span>
<span class="detail-value">{{ viewForm.remark }}</span>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="handleViewVisible(false)">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listTeachNotice, getTeachNotice, addTeachNotice, updateTeachNotice, delTeachNotice } from "@/api/teachNotice"
export default {
name: "TeachNotice",
data() {
return {
loading: true,
tableHeight: window.innerHeight - 320,
total: 0,
noticeList: [],
categoryOptions: ['教学公告', '考试通知', '调课通知'],
queryParams: {
pageNum: 1,
pageSize: 10,
title: undefined,
category: undefined,
publishDateFrom: undefined,
publishDateTo: undefined
},
// 新增/修改 对话框
dialogVisible: false,
dialogTitle: '',
form: {},
rules: {
title: [{ required: true, message: "公告标题不能为空", trigger: "blur" }],
content: [{ required: true, message: "公告正文不能为空", trigger: "blur" }],
category: [{ required: true, message: "公告类别不能为空", trigger: "change" }]
},
// 详情 对话框
viewVisible: false,
viewForm: {}
}
},
created() {
this.getList()
},
methods: {
/** 查询列表 */
getList() {
this.loading = true
listTeachNotice(this.queryParams).then(response => {
const data = response.data || {}
this.noticeList = data.records || []
this.total = data.total || 0
this.loading = false
}).catch(() => {
this.noticeList = []
this.total = 0
this.loading = false
})
},
/** 时间格式化:yyyy-MM-dd HH:mm:ss */
formatTime(time) {
if (!time) return ''
const date = new Date(time)
if (isNaN(date.getTime())) return time
const pad = n => String(n).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
},
/** 状态标签颜色 */
statusTagType(status) {
if (status === '已发布') return 'success'
if (status === '已下架') return 'info'
return 'warning'
},
/** 查询按钮 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮 */
resetQuery() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
title: undefined,
category: undefined,
publishDateFrom: undefined,
publishDateTo: undefined
}
this.handleQuery()
},
/** 新增 */
handleAdd() {
this.dialogTitle = '新增公告'
this.form = { title: undefined, content: undefined, category: undefined }
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.noticeForm && this.$refs.noticeForm.clearValidate()
})
},
/** 修改 */
handleUpdate(row) {
getTeachNotice(row.id).then(response => {
const data = response.data || {}
this.form = {
id: data.id,
title: data.title,
content: data.content,
category: data.category
}
}).catch(() => {})
this.dialogTitle = '修改公告'
this.dialogVisible = true
},
/** 提交新增/修改 */
submitForm() {
this.$refs.noticeForm.validate(valid => {
if (!valid) return
const isAdd = !this.form.id
if (isAdd) {
addTeachNotice(this.form).then(() => {
this.$message.success("新增成功")
this.dialogVisible = false
this.getList()
}).catch(() => {})
} else {
updateTeachNotice(this.form).then(() => {
this.$message.success("修改成功")
this.dialogVisible = false
this.getList()
}).catch(() => {})
}
})
},
/** 下架 */
handleOffline(row) {
this.$confirm("确认下架该公告吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
updateTeachNotice({ id: row.id, status: '已下架' }).then(() => {
this.$message.success("下架成功")
this.getList()
}).catch(() => {})
}).catch(() => {})
},
/** 删除(级联删除:仅拟制/已下架可删,后端校验) */
handleDelete(row) {
this.$confirm("确认删除该公告吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
delTeachNotice(row.id).then(() => {
this.$message.success("删除成功")
this.getList()
}).catch(() => {})
}).catch(() => {})
},
/** 详情 */
handleView(row) {
getTeachNotice(row.id).then(response => {
this.viewForm = response.data || {}
this.viewVisible = true
}).catch(() => {})
},
/** 对话框关闭事件(Vue2 兼容) */
handleDialogVisible(val) {
this.dialogVisible = val
},
handleViewVisible(val) {
this.viewVisible = val
}
}
}
</script>
<style scoped lang="scss">
.teach-notice {
.range-sep {
margin: 0 8px;
color: #909399;
}
.list-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 12px;
}
.list-title {
font-size: 16px;
font-weight: 600;
color: #303133;
padding-left: 10px;
border-left: 4px solid var(--edu-green-primary);
}
::v-deep .action-column .cell {
white-space: nowrap;
}
.detail-body {
padding: 0 8px;
.detail-row {
display: flex;
padding: 6px 0;
font-size: 13px;
line-height: 1.6;
.detail-label {
flex-shrink: 0;
width: 90px;
color: #909399;
text-align: right;
margin-right: 12px;
}
.detail-value {
flex: 1;
color: #303133;
word-break: break-all;
}
.detail-content {
white-space: pre-wrap;
}
}
}
@media (max-width: 768px) {
.list-heading {
align-items: stretch;
flex-direction: column;
}
.list-heading .el-button {
width: 100%;
}
}
}
</style>
@@ -0,0 +1,603 @@
<template>
<div class="app-container management-page elective-page">
<!-- ==================== 2. 查询条件区域 ==================== -->
<div class="section-card query-card">
<div class="section-heading">
<div>
<h2 class="section-title">筛选条件</h2>
<p class="section-description">按课程、班次、教员及状态筛选选修课</p>
</div>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
</div>
<el-form>
<el-row :gutter="32">
<!-- 左栏 -->
<el-col :xs="24" :md="12">
<div class="query-field">
<span class="q-label no-check">授课教员</span>
<el-input v-model="searchForm.js" placeholder="请输入授课教员" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">可选班次年级</span>
<el-input v-model="searchForm.kbcnj" placeholder="请输入可选班次年级" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">选修课状态</span>
<el-select
v-model="searchForm.xxkzt"
placeholder="请选择选修课状态"
clearable
class="q-control"
>
<el-option v-for="item in statusOptions" :key="item" :label="item" :value="item" />
</el-select>
</div>
</el-col>
<!-- 右栏 -->
<el-col :xs="24" :md="12">
<div class="query-field">
<span class="q-label no-check">课程科目名称</span>
<el-input v-model="searchForm.kckmmc" placeholder="请输入课程科目名称" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">选修班名称</span>
<el-input v-model="searchForm.xxbmc" placeholder="请输入选修班名称" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">培训层次</span>
<el-select v-model="searchForm.pxcc" placeholder="请选择培训层次" clearable class="q-control">
<el-option v-for="item in pxccOptions" :key="item" :label="item" :value="item" />
</el-select>
</div>
</el-col>
</el-row>
</el-form>
</div>
<!-- ==================== 3. 导出按钮区域 ==================== -->
<div class="section-card export-card">
<div class="section-heading section-heading--compact">
<div>
<h2 class="section-title">数据导出</h2>
<p class="section-description">下载选修班及学员名单</p>
</div>
</div>
<div class="export-bar">
<el-button icon="el-icon-download" @click="handleDownloadList">下载选修班列表</el-button>
<el-button icon="el-icon-download" @click="handleDownloadWord">下载选修班学员名单Word</el-button>
<el-button icon="el-icon-download" @click="handleDownloadExcel">下载选修班学员名单Excel</el-button>
</div>
</div>
<!-- ==================== 4. 操作按钮区域 ==================== -->
<div class="section-card action-card">
<div class="section-heading section-heading--compact">
<div>
<h2 class="section-title">选修课操作</h2>
<p class="section-description">新建选修课,或对已选数据执行批量操作</p>
</div>
</div>
<div class="action-row">
<el-button type="primary" icon="el-icon-plus" @click="handleOpenNew">新建选修课</el-button>
<el-button type="primary" plain icon="el-icon-circle-check" @click="handleOpenEarly">
所选批量开放报名
</el-button>
<el-button type="warning" plain icon="el-icon-remove-outline" @click="handleCancelEarly">
所选批量取消开放报名
</el-button>
<el-button type="danger" plain icon="el-icon-circle-close" @click="handleStopSignup">
批量停止报名
</el-button>
<!-- <el-button icon="el-icon-refresh" @click="handleReverseRange">
所选批量根据学员反向确定班次范围
</el-button> -->
</div>
</div>
<!-- ==================== 5. 文件上传区域 ==================== -->
<div class="section-card upload-card">
<div class="section-heading section-heading--compact">
<div>
<h2 class="section-title">数据导入</h2>
<p class="section-description">选择填写完成的模板文件并上传</p>
</div>
</div>
<div class="upload-row">
<div class="upload-left">
<el-button icon="el-icon-folder-opened" @click="handleSelectFile">选择文件</el-button>
<span class="file-name" :class="{ 'has-file': selectedFile }">{{ fileName }}</span>
<input ref="fileInputRef" type="file" style="display: none" @change="handleFileChange" />
</div>
<div class="upload-right">
<el-button type="primary" icon="el-icon-upload2" @click="handleUpload">上传数据</el-button>
</div>
</div>
</div>
<!-- ==================== 6. 数据表格区域 ==================== -->
<div class="section-card table-card">
<div class="section-heading section-heading--compact table-heading">
<div>
<h2 class="section-title">选修课列表</h2>
<p class="section-description">共 {{ total }} 条数据</p>
</div>
</div>
<el-table v-loading="loading" :data="tableData" border stripe class="main-table" @selection-change="handleSelectionChange">
<template slot="empty">
<span>无数据!</span>
</template>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="序号" width="60" align="center" :index="tableIndex" />
<el-table-column prop="kmc" label="课程" min-width="110" show-overflow-tooltip />
<el-table-column prop="jcmc" label="教材" min-width="120" show-overflow-tooltip />
<el-table-column prop="jyxm" label="实施教员" width="90" align="center" />
<el-table-column prop="jsmc" label="教学场地" width="100" show-overflow-tooltip />
<el-table-column prop="kxdlbc" label="显示可选队别班次" min-width="150" align="center" show-overflow-tooltip />
<el-table-column label="计划学时/运行学时/学分" width="130" align="center">
<template slot="header">
<div class="triple-header">
<span>计划学时</span>
<span>运行学时</span>
<span>学分</span>
</div>
</template>
<template slot-scope="{ row }">
<div class="triple-cell">
<span>{{ row.jhyxxsxf }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="开课结课日期" min-width="150" align="center">
<template slot-scope="{ row }">
{{ row.kkjkrq }}
</template>
</el-table-column>
<el-table-column label="报名日期" min-width="140" align="center">
<template slot-scope="{ row }">
{{ row.bmrq }}
</template>
</el-table-column>
<el-table-column prop="jhrs" label="计划人数" width="90" align="center" />
<el-table-column prop="yqsm" label="要求说明" min-width="120" show-overflow-tooltip />
</el-table>
<div class="pagination-wrap">
<el-pagination
background
layout="total, prev, pager, next, jumper"
:total="total"
:page-size="pageSize"
:current-page="currentPage"
@current-change="handlePageChange"
/>
</div>
</div>
<!-- 新建选修课弹窗 -->
<el-dialog
:visible="dialogVisible"
title="新建选修课"
width="560px"
@update:visible="val => (dialogVisible = val)"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
<el-form-item label="选修班名称" prop="xxbmc">
<el-input v-model="form.xxbmc" placeholder="请输入选修班名称" clearable />
</el-form-item>
<el-form-item label="年级">
<el-input v-model="form.nj" placeholder="新建选修班时填写,如 2024" clearable />
</el-form-item>
<el-form-item label="课程名称" prop="kcmc">
<el-input v-model="form.kcmc" placeholder="请输入课程名称,提交时按名称查找课编号" clearable />
</el-form-item>
<el-form-item label="实施教员" prop="js">
<el-input v-model="form.js" placeholder="请输入实施教员,提交时按名称查找教员编号" clearable />
</el-form-item>
<el-form-item label="教材">
<el-input v-model="form.jc" placeholder="请输入教材" clearable />
</el-form-item>
<el-form-item label="教学场地">
<el-input v-model="form.jxcd" placeholder="请输入教学场地,提交时按名称查找教室编号" clearable />
</el-form-item>
<el-form-item label="计划学时">
<el-input-number v-model="form.jhsxs" :min="0" :precision="0" class="w-full" />
</el-form-item>
<el-form-item label="运行学时">
<el-input-number v-model="form.yxsxs" :min="0" :precision="0" class="w-full" />
</el-form-item>
<el-form-item label="学分">
<el-input-number v-model="form.xf" :min="0" :precision="1" class="w-full" />
</el-form-item>
<el-form-item label="计划人数">
<el-input-number v-model="form.jh" :min="0" :precision="0" class="w-full" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleNewConfirm">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listElective,
addElective,
batchOpenElective,
batchCancelOpenElective,
batchStopElective,
exportElectiveList,
exportElectiveStudentsExcel,
exportElectiveStudentsWord
} from '@/api/teachOffice/elective'
import { listKb } from '@/api/teachOffice/kb'
import { listTeacher } from '@/api/teachOffice/teacher'
import { listClassroom } from '@/api/teachBusiness/classroom'
import { saveAs } from 'file-saver'
export default {
name: 'Elective',
data() {
return {
// ==================== 下拉选项 ====================
statusOptions: ['拟制', '开放报名', '停止报名', '已开课'],
pxccOptions: ['无', '本科', '硕士', '博士'],
// ==================== 查询条件 ====================
searchForm: {
js: '',
kbcnj: '',
xxkzt: '',
kckmmc: '',
xxbmc: '',
pxcc: ''
},
// ==================== 数据表格 ====================
tableData: [],
total: 0,
loading: false,
selectedRows: [],
// ==================== 文件上传 ====================
selectedFile: null,
// ==================== 新建选修课弹窗 ====================
dialogVisible: false,
form: {
xxbmc: '',
nj: '',
kcmc: '',
js: '',
jc: '',
jxcd: '',
jhsxs: 0,
yxsxs: 0,
xf: 0,
jh: 0
},
rules: {
xxbmc: [{ required: true, message: '请输入选修班名称', trigger: 'blur' }],
kcmc: [{ required: true, message: '请输入课程名称', trigger: 'blur' }],
js: [{ required: true, message: '请输入实施教员', trigger: 'blur' }]
},
// ==================== 分页 ====================
currentPage: 1,
pageSize: 20
}
},
computed: {
fileName() {
return (this.selectedFile && this.selectedFile.name) || '未选择任何文件'
}
},
created() {
this.loadList()
},
methods: {
// 组装查询过滤条件(列表与导出共用,导出不含分页参数)
buildFilter() {
const q = {}
if (this.searchForm.js) q.jyxm = this.searchForm.js
if (this.searchForm.kbcnj) q.kxbcnj = this.searchForm.kbcnj
if (this.searchForm.kckmmc) q.kmc = this.searchForm.kckmmc
if (this.searchForm.xxbmc) q.xxbmc = this.searchForm.xxbmc
if (this.searchForm.xxkzt) q.xkzt = this.searchForm.xxkzt
if (this.searchForm.pxcc) q.pxcc = this.searchForm.pxcc
return q
},
// ==================== 查询 ====================
handleQuery() {
this.currentPage = 1
this.loadList()
},
loadList() {
this.loading = true
const params = Object.assign({ pageNum: this.currentPage, pageSize: this.pageSize }, this.buildFilter())
listElective(params)
.then(res => {
const data = (res && res.data) || {}
this.tableData = data.records || []
this.total = data.total || 0
})
.finally(() => {
this.loading = false
})
},
// ==================== 导出 ====================
handleDownloadList() {
exportElectiveList(this.buildFilter())
.then(blob => {
saveAs(blob, '选修班列表.xlsx')
this.$message.success('选修班列表已下载')
})
.catch(() => {})
},
handleDownloadWord() {
const bhList = this.selectedRows.map(row => row.bh)
if (bhList.length === 0) {
this.$message.warning('请先选择选修班')
return
}
exportElectiveStudentsWord(bhList)
.then(blob => {
saveAs(blob, '选修班学员名单.docx')
this.$message.success('选修班学员名单Word已下载')
})
.catch(() => {})
},
handleDownloadExcel() {
const bhList = this.selectedRows.map(row => row.bh)
if (bhList.length === 0) {
this.$message.warning('请先选择选修班')
return
}
exportElectiveStudentsExcel(bhList)
.then(blob => {
saveAs(blob, '选修班学员名单.xlsx')
this.$message.success('选修班学员名单Excel已下载')
})
.catch(() => {})
},
// ==================== 操作按钮 ====================
handleOpenEarly() {
const bhList = this.selectedRows.map(row => row.bh)
if (bhList.length === 0) {
this.$message.warning('请先选择选修班')
return
}
batchOpenElective(bhList)
.then(() => {
this.$message.success('所选班已开放报名')
this.loadList()
})
.catch(() => {})
},
handleCancelEarly() {
const bhList = this.selectedRows.map(row => row.bh)
if (bhList.length === 0) {
this.$message.warning('请先选择选修班')
return
}
batchCancelOpenElective(bhList)
.then(() => {
this.$message.success('所选班已取消开放报名')
this.loadList()
})
.catch(() => {})
},
handleStopSignup() {
const bhList = this.selectedRows.map(row => row.bh)
if (bhList.length === 0) {
this.$message.warning('请先选择选修班')
return
}
batchStopElective(bhList)
.then(() => {
this.$message.success('已批量停止报名')
this.loadList()
})
.catch(() => {})
},
handleReverseRange() {
this.$message.warning('后端暂未提供该接口')
},
// ==================== 文件上传 ====================
handleSelectFile() {
this.$refs.fileInputRef && this.$refs.fileInputRef.click()
},
handleFileChange(e) {
this.selectedFile = e.target.files[0] || null
},
handleUpload() {
if (!this.selectedFile) {
this.$message.warning('请先选择文件')
return
}
this.$message.warning('后端暂未提供该接口')
},
// ==================== 表格多选 ====================
handleSelectionChange(rows) {
this.selectedRows = rows
},
// ==================== 新建选修课弹窗 ====================
handleOpenNew() {
this.form = {
xxbmc: '',
nj: '',
kcmc: '',
js: '',
jc: '',
jxcd: '',
jhsxs: 0,
yxsxs: 0,
xf: 0,
jh: 0
}
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleNewConfirm() {
if (!this.$refs.formRef) return
this.$refs.formRef.validate((valid) => {
if (!valid) return
this.submitNewElective()
})
},
submitNewElective() {
const emptyPage = { data: { records: [] } }
Promise.all([
listKb({ pageNum: 1, pageSize: 1, kmc: this.form.kcmc }),
listTeacher({ pageNum: 1, pageSize: 1, jyxm: this.form.js }),
this.form.jxcd ? listClassroom({ pageNum: 1, pageSize: 1, jsmc: this.form.jxcd }) : Promise.resolve(emptyPage)
])
.then(([kbRes, teacherRes, roomRes]) => {
const kbh = kbRes?.data?.records?.[0]?.kbh
const jybh = teacherRes?.data?.records?.[0]?.jybh
const jsbh = roomRes?.data?.records?.[0]?.jsbh
if (!kbh) {
this.$message.warning(`未找到课程科目:${this.form.kcmc}`)
return
}
const dto = {
kbh: kbh,
xxbmc: this.form.xxbmc,
nj: this.form.nj || undefined,
jybh: jybh || undefined,
jsbh: jsbh || undefined,
rs: this.form.jh || undefined,
xs: this.form.jhsxs || undefined,
xf: this.form.xf || undefined
}
return addElective(dto).then(() => {
this.$message.success('新建选修课成功')
this.dialogVisible = false
this.loadList()
})
})
.catch(() => {})
},
// ==================== 分页 ====================
handlePageChange(page) {
this.currentPage = page
this.loadList()
},
// 表格序号(跨页连续)
tableIndex(index) {
return (this.currentPage - 1) * this.pageSize + index + 1
}
}
}
</script>
<style scoped lang="scss">
// ==================== 2. 查询条件区域 ====================
.query-card {
.query-field {
display: flex;
align-items: center;
margin-bottom: 14px;
min-height: 32px;
.q-label {
width: 120px;
flex-shrink: 0;
font-size: 13px;
color: #303133;
text-align: right;
margin-right: 10px;
white-space: nowrap;
}
.q-control {
flex: 1;
min-width: 0;
}
}
}
.export-bar {
align-items: center;
}
// ==================== 4. 操作按钮区域 ====================
.action-card {
.action-row {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
}
// ==================== 5. 文件上传区域 ====================
.upload-card {
.upload-row {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
.upload-left {
display: flex;
align-items: center;
gap: 12px;
.file-name {
font-size: 12px;
color: #999;
&.has-file {
color: #303133;
}
}
}
.upload-right {
display: flex;
align-items: center;
}
}
}
// ==================== 6. 数据表格区域 ====================
.table-card {
.main-table {
::v-deep .cell {
font-size: 12px;
}
}
.triple-header,
.triple-cell {
display: flex;
flex-direction: column;
line-height: 1.4;
}
.pagination-wrap {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
}
</style>
@@ -0,0 +1,364 @@
<template>
<div class="app-container teach-office">
<!-- 查询条件区域 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="88px" v-show="showSearch">
<el-form-item label="教研室代号" prop="jysdh">
<el-input
v-model="queryParams.jysdh"
placeholder="请输入教研室代号"
clearable
style="width: 160px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="教研室名称" prop="jysmc">
<el-input
v-model="queryParams.jysmc"
placeholder="请输入教研室名称"
clearable
style="width: 180px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="部系" prop="bx">
<el-input
v-model="queryParams.bx"
placeholder="请输入部系"
clearable
style="width: 160px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停用" prop="ty">
<el-radio-group v-model="queryParams.ty">
<el-radio :label="1">是</el-radio>
<el-radio :label="0">否</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作按钮区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="openImport">导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleDownloadTemplate">模板下载</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 数据列表区域 -->
<el-table v-loading="loading" :data="officeList" border :height="tableHeight">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column label="教研室代号" align="center" prop="jysdh" min-width="110" />
<el-table-column label="教研室名称" align="center" prop="jysmc" min-width="160" :show-overflow-tooltip="true" />
<el-table-column label="简称" align="center" prop="jc" min-width="90" />
<el-table-column label="部系" align="center" prop="bx" min-width="100" />
<el-table-column label="机关性质" align="center" min-width="90">
<template slot-scope="scope">
<el-tag :type="scope.row.jgxz ? 'primary' : 'info'" size="mini">{{ scope.row.jgxz ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="停用" align="center" min-width="80">
<template slot-scope="scope">
<el-tag :type="scope.row.ty ? 'danger' : 'success'" size="mini">{{ scope.row.ty ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="bz" min-width="120" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" min-width="140" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-circle-close"
style="color: #f56c6c"
:disabled="scope.row.ty === 1"
@click="handleDisable(scope.row)"
>停用</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 新增/编辑对话框 -->
<el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="教研室代号" prop="jysdh">
<el-input v-model="form.jysdh" placeholder="请输入教研室代号" :disabled="!isAdd" maxlength="20" />
</el-form-item>
<el-form-item label="教研室名称" prop="jysmc">
<el-input v-model="form.jysmc" placeholder="请输入教研室名称" maxlength="50" />
</el-form-item>
<el-form-item label="简称" prop="jc">
<el-input v-model="form.jc" placeholder="请输入简称" maxlength="20" />
</el-form-item>
<el-form-item label="部系" prop="bx">
<el-input v-model="form.bx" placeholder="请输入部系" maxlength="30" />
</el-form-item>
<el-form-item label="序号" prop="xh">
<el-input v-model="form.xh" placeholder="请输入序号" maxlength="10" />
</el-form-item>
<el-form-item label="备注" prop="bz">
<el-input v-model="form.bz" type="textarea" placeholder="请输入备注" :rows="3" maxlength="200" show-word-limit />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog title="教研室数据导入" :visible.sync="importOpen" width="420px" append-to-body>
<el-upload
ref="uploadRef"
:action="importUrl"
:headers="uploadHeaders"
:on-success="handleImportSuccess"
:on-error="handleImportError"
:limit="1"
:before-upload="beforeImport"
accept=".xls, .xlsx"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入 xls、xlsx 格式文件。</span>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitImport">确 定</el-button>
<el-button @click="importOpen = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listOffice, addOffice, updateOffice, disableOffice, downloadOfficeTemplate } from "@/api/teachOffice/office"
import { getToken } from '@/utils/auth'
import { saveAs } from 'file-saver'
export default {
name: "Office",
data() {
return {
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 表格高度
tableHeight: window.innerHeight - 280,
// 总条数
total: 0,
// 教研室列表数据
officeList: [],
// 弹出层标题
title: "",
// 是否显示新增/编辑弹出层
open: false,
// 是否新增(false 为编辑)
isAdd: true,
// 是否显示导入弹出层
importOpen: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
jysdh: undefined,
jysmc: undefined,
bx: undefined,
ty: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
jysdh: [
{ required: true, message: "教研室代号不能为空", trigger: "blur" }
],
jysmc: [
{ required: true, message: "教研室名称不能为空", trigger: "blur" }
]
}
}
},
computed: {
importUrl() {
return process.env.VUE_APP_BASE_API + '/jys/office/import'
},
uploadHeaders() {
return { Authorization: 'Bearer ' + getToken() }
}
},
created() {
this.getList()
},
methods: {
/** 查询教研室列表 */
getList() {
this.loading = true
listOffice(this.queryParams).then(response => {
// 后端返回 MyBatis-Plus 分页结构:data.records / data.total
const data = response.data || {}
this.officeList = data.records || []
this.total = data.total || 0
this.loading = false
}).catch(() => {
this.officeList = []
this.total = 0
this.loading = false
})
},
/** 查询按钮 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 新增按钮 */
handleAdd() {
this.reset()
this.isAdd = true
this.open = true
this.title = "新增教研室"
},
/** 编辑按钮 */
handleUpdate(row) {
this.reset()
this.isAdd = false
// 编辑:jysdh 必传
this.form = {
jysdh: row.jysdh,
jysmc: row.jysmc,
jc: row.jc,
bx: row.bx,
xh: row.xh,
bz: row.bz
}
this.open = true
this.title = "编辑教研室"
},
/** 停用按钮 */
handleDisable(row) {
const jysdh = row.jysdh
this.$modal.confirm('确认停用教研室【' + row.jysmc + '】吗?').then(() => {
return disableOffice(jysdh)
}).then(() => {
this.getList()
this.$modal.msgSuccess("停用成功")
}).catch(() => {})
},
/** 提交表单 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.isAdd) {
addOffice(this.form).then(response => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
}).catch(() => {})
} else {
updateOffice(this.form).then(response => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
}).catch(() => {})
}
}
})
},
/** 重置表单 */
reset() {
this.form = {
jysdh: undefined,
jysmc: undefined,
jc: undefined,
bx: undefined,
xh: undefined,
bz: undefined
}
this.resetForm("form")
},
/** 取消按钮 */
cancel() {
this.open = false
this.reset()
},
/** 打开导入对话框 */
openImport() {
this.importOpen = true
this.$nextTick(() => {
if (this.$refs.uploadRef) {
this.$refs.uploadRef.clearFiles()
}
})
},
/** 导入前校验文件格式 */
beforeImport(file) {
const name = file.name.toLowerCase()
if (!name.endsWith('.xls') && !name.endsWith('.xlsx')) {
this.$modal.msgError('仅支持 xls、xlsx 格式文件')
return false
}
return true
},
/** 提交导入 */
submitImport() {
const files = this.$refs.uploadRef.uploadFiles
if (!files || files.length === 0) {
this.$modal.msgError('请选择要导入的文件')
return
}
this.$refs.uploadRef.submit()
},
/** 导入成功 */
handleImportSuccess(response) {
this.importOpen = false
this.$alert("<div style='overflow:auto;overflow-x:hidden;max-height:70vh;padding:10px 20px 0;'>" + response.msg + '</div>', '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
/** 导入失败 */
handleImportError() {
this.$modal.msgError('导入失败,请稍后重试')
},
/** 下载导入模板 */
handleDownloadTemplate() {
downloadOfficeTemplate().then(blob => {
saveAs(blob, '教研室导入模板.xlsx')
this.$modal.msgSuccess('模板下载成功')
}).catch(() => {})
}
}
}
</script>
<style scoped lang="scss">
.teach-office {
.mb8 {
margin-bottom: 8px;
}
}
</style>
@@ -0,0 +1,752 @@
<template>
<el-dialog
:visible="dialogVisible"
:title="`班历管理——${semesterTitle}`"
width="1200px"
top="6vh"
:close-on-click-modal="false"
class="class-calendar-dialog"
@update:visible="val => dialogVisible = val"
>
<div v-loading="loading" class="class-calendar">
<!-- ==================== 1. 学期与班次信息 ==================== -->
<div class="info-panel">
<div class="info-title-row">
<span class="semester-name">{{ semesterTitle }}</span>
<span class="class-name">{{ className }}</span>
</div>
<div class="date-range-row">
<div class="range-item">学期日期:{{ fmtDate(safeSemester.kxrq) }} 至 {{ fmtDate(safeSemester.jsrq) }},共 {{ semesterWeeks }} 周</div>
<div class="range-item">班历记录:{{ records.length }} 条,总学时 {{ summary.totalXs }},总学分 {{ summary.totalXf }}</div>
</div>
</div>
<!-- ==================== 2. 操作按钮区域 ==================== -->
<div class="settings-panel">
<div class="action-buttons-row">
<el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd">新增记录</el-button>
<el-button size="small" @click="handleAutoGenerate">自动生成必修课程</el-button>
<el-button size="small" @click="handlePresetMerge">预设合班</el-button>
<el-button size="small" @click="handlePresetSplit">预设拆班</el-button>
<el-button size="small" @click="handleApplyRegion">选定区域应用于其它班次</el-button>
<el-button size="small" @click="handleApplyWhole">整个班历应用于其它班次</el-button>
<el-button size="small" icon="el-icon-refresh" @click="handleRefresh">刷新</el-button>
</div>
</div>
<!-- ==================== 3. 班历记录表格 ==================== -->
<div class="table-area">
<el-table
ref="tableRef"
:data="records"
border
stripe
size="small"
max-height="480"
class="calendar-table"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="kcxh" label="课次序号" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="jhkcxh" label="计划课次" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="jc" label="简称" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="kbh" label="课编号" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="klx" label="课类型" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="jybh" label="教员编号" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="jsbh" label="教室编号" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="zks" label="周课时" width="70" align="center" show-overflow-tooltip />
<el-table-column prop="xs" label="学时" width="60" align="center" show-overflow-tooltip />
<el-table-column prop="llxs" label="理论学时" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="sjxs" label="实践学时" width="80" align="center" show-overflow-tooltip />
<el-table-column prop="xf" label="学分" width="60" align="center" show-overflow-tooltip />
<el-table-column prop="rs" label="人数" width="60" align="center" show-overflow-tooltip />
<el-table-column prop="ksbh" label="考试编号" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="ksdd" label="考试地点" width="110" align="center" show-overflow-tooltip />
<el-table-column prop="bz" label="备注" min-width="120" align="left" header-align="center" show-overflow-tooltip />
<el-table-column label="操作" width="120" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="select-tip">
提示:勾选多条记录后可进行 预设合班 / 预设拆班 / 选定区域应用于其它班次 操作;删除为物理删除,请谨慎操作。
</div>
</div>
</div>
<div slot="footer">
<el-button @click="dialogVisible = false">关闭</el-button>
</div>
<!-- ==================== 班历记录新增/编辑弹窗 ==================== -->
<el-dialog
:visible="editVisible"
:title="editTitle"
width="760px"
:close-on-click-modal="false"
append-to-body
@update:visible="val => editVisible = val"
>
<el-form ref="editFormRef" :model="editForm" :rules="editRules" label-width="120px" size="small" class="edit-form">
<div class="form-section-title">基本信息</div>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="简称" prop="jc">
<el-input v-model="editForm.jc" placeholder="课程简称" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="课编号">
<el-input v-model="editForm.kbh" placeholder="课程编号" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="课类型">
<el-input v-model="editForm.klx" placeholder="如 必修/选修/实践" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="课次序号">
<el-input-number v-model="editForm.kcxh" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="计划课次序号">
<el-input-number v-model="editForm.jhkcxh" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="序号标识">
<el-input-number v-model="editForm.xhbs" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="教员编号">
<el-input v-model="editForm.jybh" placeholder="教员编号" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教室编号">
<el-input v-model="editForm.jsbh" placeholder="教室编号" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="人数">
<el-input-number v-model="editForm.rs" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="周课时">
<el-input-number v-model="editForm.zks" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<div class="form-section-title">学时学分</div>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="学时">
<el-input-number v-model="editForm.xs" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="理论学时">
<el-input-number v-model="editForm.llxs" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="实践学时">
<el-input-number v-model="editForm.sjxs" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学分">
<el-input-number v-model="editForm.xf" :min="0" :precision="1" :step="0.5" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<div class="form-section-title">考试信息</div>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="考试课时">
<el-input-number v-model="editForm.ksks" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试编号">
<el-input v-model="editForm.ksbh" placeholder="考试编号" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="考试地点">
<el-input v-model="editForm.ksdd" placeholder="考试地点" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="成绩分制">
<el-input v-model="editForm.cjfz" placeholder="如 百分制/等级制" clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="不计入平均分">
<el-select v-model="editForm.bjrxypjf" clearable style="width: 100%">
<el-option label="是" :value="1" />
<el-option label="否" :value="0" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试课时不显示">
<el-select v-model="editForm.ksksbxs" clearable style="width: 100%">
<el-option label="是" :value="1" />
<el-option label="否" :value="0" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<div class="form-section-title">教研室计划</div>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="教研室代号">
<el-input v-model="editForm.jysdh" placeholder="教研室代号" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="计划教员编号">
<el-input v-model="editForm.jysjhjybh" placeholder="教研室计划教员编号" clearable />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="计划备注">
<el-input v-model="editForm.jysjhbz" type="textarea" :rows="2" placeholder="教研室计划备注" clearable />
</el-form-item>
<div class="form-section-title">配档设置</div>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="配档序号">
<el-input-number v-model="editForm.pdxh" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="配档起始周">
<el-input-number v-model="editForm.pdqsz" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="配档按周">
<el-input-number v-model="editForm.pdaz" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="占正课时间">
<el-input-number v-model="editForm.pdzzksj" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="配档编组">
<el-input-number v-model="editForm.pdbz" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="同班异课选修编组">
<el-select v-model="editForm.pdtbykxxbz" clearable style="width: 100%">
<el-option label="是" :value="1" />
<el-option label="否" :value="0" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="启用自定义学时">
<el-select v-model="editForm.pdqyzdyxs" clearable style="width: 100%">
<el-option label="是" :value="1" />
<el-option label="否" :value="0" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="编组">
<el-input-number v-model="editForm.bz2" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="自定义学时分布">
<el-input v-model="editForm.pdzdyxsfbsj" type="textarea" :rows="2" placeholder="配档自定义学时分布数据" clearable />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="editForm.bz" type="textarea" :rows="2" placeholder="备注" clearable />
</el-form-item>
</el-form>
<div slot="footer">
<el-button size="small" @click="editVisible = false">取消</el-button>
<el-button size="small" type="primary" :loading="saving" @click="handleEditSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 目标班次学期选取弹窗 ==================== -->
<ClassTeamSelectDialog
:visible="teamSelectVisible"
:semester-list="semesterOptions"
:exclude-bh="safeSemester.bh"
:exclude-note="copyNote"
@update:visible="val => teamSelectVisible = val"
@confirm="handleTeamConfirm"
/>
</el-dialog>
</template>
<script>
import ClassTeamSelectDialog from './ClassTeamSelectDialog.vue'
import {
listClassCalendar,
updateClassCalendar,
batchCopyCalendar,
batchCopyCalendarBySemester,
addTeamTask,
delTeamTask,
batchPresetMerge,
batchPresetSplit,
autoGenerateRequiredCourses
} from '@/api/studentRecords/classCalendar'
export default {
name: 'ClassCalendarDialog',
components: { ClassTeamSelectDialog },
props: {
visible: { type: Boolean, default: false },
/** 选中的班次学期记录(含 bh/xydbh/xqdc/nd/xydmc/kxrq/jsrq) */
semester: { type: Object, default: null },
/** 可选的目标班次学期列表(已含班次名称的完整列表) */
semesterOptions: { type: Array, default: () => [] }
},
data() {
return {
loading: false,
saving: false,
records: [],
selection: [],
// ==================== 新增/编辑 ====================
editVisible: false,
editMode: 'add',
editForm: this.createEmptyEditForm(),
editRules: {
jc: [{ required: true, message: '请输入课程简称', trigger: 'blur' }]
},
// ==================== 复制到其它班次 ====================
teamSelectVisible: false,
applyMode: 'region',
copyNote: ''
}
},
computed: {
dialogVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
},
safeSemester() {
return this.semester || {}
},
className() {
const s = this.safeSemester
return s.xydmc || s.xydbh || ''
},
semesterTitle() {
const s = this.safeSemester
const nd = s.nd !== undefined && s.nd !== null && s.nd !== '' ? `${s.nd}年` : ''
const xq = this.xqdcLabel(s.xqdc)
return `${nd}${xq}`
},
semesterWeeks() {
const s = this.safeSemester
if (!s.kxrq || !s.jsrq) return '-'
const start = new Date(String(s.kxrq).slice(0, 10))
const end = new Date(String(s.jsrq).slice(0, 10))
const diff = Math.round((end - start) / (1000 * 60 * 60 * 24)) + 1
return diff > 0 ? Math.ceil(diff / 7) : '-'
},
/** 班历统计:课程数 / 总学时 / 总学分 */
summary() {
const totalXs = this.records.reduce((sum, r) => sum + (Number(r.xs) || 0), 0)
const totalXf = this.records.reduce((sum, r) => sum + (Number(r.xf) || 0), 0)
return { totalXs, totalXf }
},
editTitle() {
return this.editMode === 'edit' ? '编辑班历记录' : '新增班历记录'
}
},
watch: {
visible(val) {
if (val) {
this.loadData()
}
}
},
methods: {
/* ---------- 格式化 ---------- */
fmtDate(val) {
if (!val) return '-'
return String(val).slice(0, 10)
},
xqdcLabel(val) {
if (val === 1 || val === '1') return '第1学期'
if (val === 2 || val === '2') return '第2学期'
if (val === 3 || val === '3') return '第3学期'
return val !== undefined && val !== null && val !== '' ? `第${val}学期` : '-'
},
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
/* ---------- 列表加载 ---------- */
loadData() {
const s = this.semester || {}
if (!s.bh) return
this.loading = true
listClassCalendar(s.bh).then(res => {
this.records = (res && res.data) || []
this.loading = false
}).catch(() => {
this.records = []
this.loading = false
})
},
handleSelectionChange(rows) {
this.selection = rows
},
/* ---------- 新增 / 编辑 ---------- */
createEmptyEditForm() {
const s = this.semester || {}
return {
bh: '',
nd: s.nd,
xydbh: s.xydbh || '',
xqdc: s.xqdc,
xydxqbh: s.bh || '',
jc: '',
kbh: '',
klx: '',
kcxh: undefined,
jhkcxh: undefined,
xhbs: undefined,
jybh: '',
jsbh: '',
rs: undefined,
zks: undefined,
xs: undefined,
llxs: undefined,
sjxs: undefined,
xf: undefined,
ksks: undefined,
ksbh: '',
ksdd: '',
cjfz: '',
bjrxypjf: undefined,
ksksbxs: undefined,
jysdh: '',
jysjhjybh: '',
jysjhbz: '',
pdxh: undefined,
pdqsz: undefined,
pdaz: undefined,
pdzzksj: undefined,
pdbz: undefined,
pdtbykxxbz: undefined,
pdqyzdyxs: undefined,
pdzdyxsfbsj: '',
bz2: undefined,
bz: ''
}
},
handleAdd() {
this.editMode = 'add'
this.editForm = this.createEmptyEditForm()
this.editVisible = true
this.$nextTick(() => {
if (this.$refs.editFormRef) this.$refs.editFormRef.clearValidate()
})
},
handleEdit(row) {
this.editMode = 'edit'
const s = this.semester || {}
const form = this.createEmptyEditForm()
Object.keys(form).forEach(key => {
if (row[key] !== undefined && row[key] !== null) form[key] = row[key]
})
form.xydxqbh = s.bh || row.xydxqbh
this.editForm = form
this.editVisible = true
this.$nextTick(() => {
if (this.$refs.editFormRef) this.$refs.editFormRef.clearValidate()
})
},
handleEditSubmit() {
this.$refs.editFormRef.validate(valid => {
if (!valid) return
const payload = this.cleanPayload({ ...this.editForm })
const req = this.editMode === 'edit'
? updateClassCalendar(payload)
: addTeamTask(payload)
this.saving = true
req.then(() => {
this.saving = false
this.editVisible = false
this.$message.success(this.editMode === 'edit' ? '班历记录已更新' : '班历记录已新增')
this.loadData()
}).catch(() => {
this.saving = false
})
})
},
/* ---------- 删除 ---------- */
handleDelete(row) {
this.$confirm(`确定删除该班历记录(${row.jc || row.bh})吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delTeamTask(row.bh).then(() => {
this.$message.success('已删除')
this.loadData()
})
}).catch(() => {})
},
/* ---------- 自动生成必修课程 ---------- */
handleAutoGenerate() {
const s = this.semester || {}
if (!s.xydbh || !s.xqdc) {
this.$message.warning('当前班次学期缺少学员队编号或学期第次,无法自动生成')
return
}
this.$confirm('将按专业教学计划自动生成该班次的必修课程(已存在的课程不会重复添加),是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
autoGenerateRequiredCourses(s.xydbh, s.xqdc).then(res => {
const count = (res && res.data) || 0
this.$message.success(`已自动生成 ${count} 门必修课程`)
this.loadData()
})
}).catch(() => {})
},
/* ---------- 预设合班 / 拆班 ---------- */
handlePresetMerge() {
const bhs = this.selection.map(r => r.bh)
if (!bhs.length) {
this.$message.warning('请先勾选要合班的班历记录')
return
}
this.$confirm(`将按年度为选中的 ${bhs.length} 条记录设置统一的课次序号,是否继续?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
batchPresetMerge(bhs).then(res => {
const count = (res && res.data) || 0
this.$message.success(`已完成 ${count} 条记录的预设合班`)
this.loadData()
})
}).catch(() => {})
},
handlePresetSplit() {
const bhs = this.selection.map(r => r.bh)
if (!bhs.length) {
this.$message.warning('请先勾选要拆班的班历记录')
return
}
this.$confirm(`将清空选中的 ${bhs.length} 条记录的课次序号,是否继续?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
batchPresetSplit(bhs).then(res => {
const count = (res && res.data) || 0
this.$message.success(`已完成 ${count} 条记录的预设拆班`)
this.loadData()
})
}).catch(() => {})
},
/* ---------- 应用于其它班次 ---------- */
handleApplyRegion() {
const bhs = this.selection.map(r => r.bh)
if (!bhs.length) {
this.$message.warning('请先勾选要应用的班历记录(选定区域)')
return
}
this.applyMode = 'region'
this.copyNote = `将选中的 ${bhs.length} 条班历记录复制到所选班次`
this.teamSelectVisible = true
},
handleApplyWhole() {
this.applyMode = 'whole'
this.copyNote = '将整个班历复制到所选班次'
this.teamSelectVisible = true
},
handleTeamConfirm(targets) {
if (!targets || !targets.length) return
const targetBhList = targets.map(t => t.bh)
if (this.applyMode === 'whole') {
batchCopyCalendarBySemester({
sourceXydxqbh: this.semester.bh,
targetBhList: targetBhList
}).then(res => {
const data = (res && res.data) || {}
this.$message.success(`已复制整个班历,共新增 ${data.count || 0} 条记录`)
this.loadData()
})
} else {
batchCopyCalendar({
sourceBhList: this.selection.map(r => r.bh),
targetBhList: targetBhList
}).then(res => {
const data = (res && res.data) || {}
this.$message.success(`已复制选定区域,共新增 ${data.count || 0} 条记录`)
this.loadData()
})
}
},
/* ---------- 刷新 ---------- */
handleRefresh() {
this.loadData()
this.$message.success('已刷新班历')
}
}
}
</script>
<style scoped lang="scss">
.class-calendar {
// ========== 1. 学期与班次信息 ==========
.info-panel {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 12px 20px;
margin-bottom: 12px;
.info-title-row {
display: flex;
align-items: baseline;
gap: 20px;
margin-bottom: 8px;
.semester-name,
.class-name {
font-size: 20px;
font-weight: 700;
color: #1e6fff;
}
}
.date-range-row {
display: flex;
flex-direction: column;
gap: 4px;
.range-item {
font-size: 13px;
font-weight: 600;
color: #1e6fff;
}
}
}
// ========== 2. 操作按钮区域 ==========
.settings-panel {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 12px 20px;
margin-bottom: 12px;
.action-buttons-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
}
// ========== 3. 表格区域 ==========
.table-area {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
overflow: hidden;
.select-tip {
padding: 6px 12px;
font-size: 12px;
color: #909399;
border-top: 1px solid #ebeef5;
background: #fafafa;
}
}
.text-danger {
color: #f56c6c;
}
}
// ========== 弹窗内表单分区标题 ==========
.edit-form {
.form-section-title {
font-size: 13px;
font-weight: 600;
color: #303133;
margin: 6px 0 10px;
padding: 6px 10px;
background: #f0f7ff;
border-left: 3px solid #1e6fff;
}
}
</style>
@@ -0,0 +1,223 @@
<template>
<el-dialog
:visible="dialogVisible"
:title="isEdit ? '编辑班次学期信息' : '教学班次学期信息明细'"
width="620px"
class="class-detail-dialog"
:close-on-click-modal="false"
@update:visible="val => dialogVisible = val"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px" class="detail-form">
<!-- 班次信息(只读展示) -->
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="班次">
<el-input :value="form.xydmc || form.xydbh" readonly />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="班次编号">
<el-input v-model="form.xydbh" :readonly="isEdit" :disabled="isEdit" placeholder="编辑模式不可修改" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="年度" prop="nd">
<el-select v-model="form.nd" placeholder="请选择年度" filterable style="width: 100%">
<el-option v-for="y in yearOptions" :key="y" :label="`${y}年`" :value="y" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="学期第次" prop="xqdc">
<el-select v-model="form.xqdc" placeholder="请选择学期" style="width: 100%">
<el-option v-for="opt in levelOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="开学日期" prop="kxrq">
<el-date-picker v-model="form.kxrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期" prop="jsrq">
<el-date-picker v-model="form.jsrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="专用教室">
<el-input v-model="form.zyjsbh" placeholder="请输入专用教室编号" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教学任务">
<el-select v-model="form.jxrwbh" clearable filterable placeholder="请选择教学任务" style="width: 100%">
<el-option v-for="opt in taskOptions" :key="opt.bh" :label="opt.rwmc" :value="opt.bh" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="开放教员排课">
<el-checkbox v-model="form.kfjypk">开放教员排课</el-checkbox>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.bz" type="textarea" :rows="3" placeholder="请输入备注" clearable />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleSubmit">确定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'ClassSemesterDetailDialog',
props: {
visible: { type: Boolean, default: false },
/** 编辑模式:edit / add */
mode: { type: String, default: 'add' },
/** 编辑时的班次学期记录 */
semester: { type: Object, default: null },
/** 新增时选中的班次(学员队)信息 */
teamInfo: { type: Object, default: null },
/** 年度下拉 */
yearOptions: { type: Array, default: () => [] },
/** 教学任务下拉({ bh, rwmc }) */
taskOptions: { type: Array, default: () => [] }
},
data() {
return {
form: this.createEmptyForm(),
levelOptions: [
{ label: '第1学期', value: 1 },
{ label: '第2学期', value: 2 },
{ label: '第3学期', value: 3 }
],
saving: false,
rules: {
nd: [{ required: true, message: '请选择年度', trigger: 'change' }],
xqdc: [{ required: true, message: '请选择学期第次', trigger: 'change' }],
kxrq: [{ required: true, message: '请选择开学日期', trigger: 'change' }],
jsrq: [{ required: true, message: '请选择结束日期', trigger: 'change' }]
}
}
},
computed: {
dialogVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
},
isEdit() {
return this.mode === 'edit'
}
},
watch: {
visible(val) {
if (!val) return
this.initForm()
this.$nextTick(() => {
if (this.$refs.formRef) this.$refs.formRef.clearValidate()
})
}
},
methods: {
createEmptyForm() {
return {
bh: '',
xydbh: '',
xydmc: '',
nd: undefined,
xqdc: undefined,
kxrq: '',
jsrq: '',
zyjsbh: '',
jxrwbh: undefined,
kfjypk: false,
bz: ''
}
},
/** 打开时按编辑/新增模式初始化表单 */
initForm() {
const form = this.createEmptyForm()
if (this.isEdit && this.semester) {
const row = this.semester
form.bh = row.bh || ''
form.xydbh = row.xydbh || ''
form.xydmc = row.xydmc || ''
form.nd = row.nd
form.xqdc = row.xqdc
form.kxrq = row.kxrq ? String(row.kxrq).slice(0, 10) : ''
form.jsrq = row.jsrq ? String(row.jsrq).slice(0, 10) : ''
form.zyjsbh = row.zyjsbh || ''
form.jxrwbh = row.jxrwbh || undefined
form.kfjypk = Number(row.kfjypk) === 1
form.bz = row.bz || ''
} else if (this.teamInfo) {
form.xydbh = this.teamInfo.xydbh || ''
form.xydmc = this.teamInfo.xydmc || ''
// 默认取当前选中年度的第一学期,日期可后续修改
form.nd = this.yearOptions[0]
form.xqdc = 1
}
this.form = form
},
/** 移除空值(保留 0 等有效值) */
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
handleSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) return
if (!this.form.xydbh) {
this.$message.warning('缺少班次编号,无法保存')
return
}
const payload = this.cleanPayload({
bh: this.form.bh,
xydbh: this.form.xydbh,
nd: this.form.nd,
xqdc: this.form.xqdc,
kxrq: this.form.kxrq,
jsrq: this.form.jsrq,
zyjsbh: this.form.zyjsbh,
jxrwbh: this.form.jxrwbh,
kfjypk: this.form.kfjypk ? 1 : 0,
bz: this.form.bz
})
this.$emit('submit', payload)
})
}
}
}
</script>
<style scoped lang="scss">
.class-detail-dialog {
.detail-form {
// 只读输入框灰色底
::v-deep .el-input__inner[readonly] {
background-color: #f5f7fa;
}
}
}
</style>
@@ -0,0 +1,224 @@
<template>
<el-dialog
:visible="dialogVisible"
:title="title"
width="900px"
top="8vh"
:close-on-click-modal="false"
class="team-select-dialog"
@update:visible="val => dialogVisible = val"
>
<div class="team-select">
<!-- ==================== 操作说明 ==================== -->
<div v-if="excludeNote" class="note-bar">
<i class="el-icon-info"></i>
<span>{{ excludeNote }}</span>
</div>
<!-- ==================== 查询条件区域 ==================== -->
<div class="query-panel">
<el-form :inline="true" class="query-form" @submit.native.prevent>
<el-form-item label="班次编号">
<el-input
v-model="queryForm.xydbh"
placeholder="请输入班次编号(模糊)"
clearable
style="width: 220px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button size="small" @click="handleResetQuery">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- ==================== 目标班次学期表格 ==================== -->
<div class="table-panel">
<el-table
ref="tableRef"
v-loading="loading"
:data="filteredList"
border
stripe
size="small"
max-height="360"
class="team-table"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="44" align="center" reserve-selection />
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="nd" label="年度" width="80" align="center" show-overflow-tooltip />
<el-table-column label="学期第次" width="90" align="center">
<template slot-scope="{ row }">{{ xqdcLabel(row.xqdc) }}</template>
</el-table-column>
<el-table-column prop="xydbh" label="班次编号" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="kxrq" label="开学日期" width="110" align="center" :formatter="fmtDate" />
<el-table-column prop="jsrq" label="结束日期" width="110" align="center" :formatter="fmtDate" />
<el-table-column prop="bz" label="备注" min-width="120" align="left" header-align="center" show-overflow-tooltip />
</el-table>
<el-empty v-if="!filteredList.length" description="暂无可选的目标班次学期" :image-size="60" />
</div>
<!-- ==================== 底部按钮区域 ==================== -->
<div class="footer-actions">
<span class="selected-count">已选择 {{ selection.length }} 个班次学期</span>
<el-button size="small" @click="dialogVisible = false">取消</el-button>
<el-button size="small" type="primary" :disabled="!selection.length" @click="handleConfirm">确定</el-button>
</div>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'ClassTeamSelectDialog',
props: {
visible: { type: Boolean, default: false },
/** 标题(可选) */
title: { type: String, default: '目标班次学期选取' },
/** 可选的目标班次学期列表(含 bh/nd/xqdc/xydbh/kxrq/jsrq 等) */
semesterList: { type: Array, default: () => [] },
/** 需要排除的班次学期编号(当前班次学期,不可复制给自己) */
excludeBh: { type: String, default: '' },
/** 顶部操作说明 */
excludeNote: { type: String, default: '' }
},
data() {
return {
loading: false,
queryForm: { xydbh: '' },
selection: []
}
},
computed: {
dialogVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
},
/** 排除当前班次学期后的可选列表 */
availableList() {
const excludeBh = this.excludeBh || ''
return (this.semesterList || []).filter(item => item.bh && String(item.bh) !== String(excludeBh))
},
/** 本地过滤后的列表 */
filteredList() {
const kw = (this.queryForm.xydbh || '').trim()
if (!kw) return this.availableList
return this.availableList.filter(item => item.xydbh && String(item.xydbh).includes(kw))
}
},
watch: {
visible(val) {
if (val) {
this.selection = []
this.queryForm.xydbh = ''
this.$nextTick(() => {
if (this.$refs.tableRef) this.$refs.tableRef.clearSelection()
})
}
}
},
methods: {
fmtDate(val) {
if (!val) return '-'
return String(val).slice(0, 10)
},
xqdcLabel(val) {
if (val === 1 || val === '1') return '第1学期'
if (val === 2 || val === '2') return '第2学期'
if (val === 3 || val === '3') return '第3学期'
return val !== undefined && val !== null && val !== '' ? `第${val}学期` : '-'
},
handleSelectionChange(rows) {
this.selection = rows
},
handleQuery() {},
handleResetQuery() {
this.queryForm.xydbh = ''
},
handleConfirm() {
if (!this.selection.length) {
this.$message.warning('请先勾选目标班次学期')
return
}
this.$emit('confirm', this.selection.slice())
this.dialogVisible = false
}
}
}
</script>
<style scoped lang="scss">
.team-select {
display: flex;
flex-direction: column;
gap: 12px;
// ========== 操作说明 ==========
.note-bar {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 12px;
font-size: 13px;
color: #1e6fff;
background: #ecf5ff;
border: 1px solid #d9ecff;
border-radius: 4px;
}
// ========== 查询条件区域 ==========
.query-panel {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 10px 12px 2px;
.query-form {
::v-deep .el-form-item {
margin-bottom: 8px;
}
}
}
// ========== 表格区域 ==========
.table-panel {
position: relative;
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 10px;
overflow: hidden;
.team-table {
width: 100%;
}
::v-deep .el-empty {
padding: 12px 0;
}
}
// ========== 底部按钮区域 ==========
.footer-actions {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 8px;
padding-top: 12px;
border-top: 1px solid #ebeef5;
.selected-count {
flex: 1;
font-size: 13px;
color: #606266;
}
}
}
</style>
@@ -0,0 +1,656 @@
<template>
<div class="app-container shift-semester-page">
<!-- ==================== 页面标题 ==================== -->
<div class="page-title">班次学期信息管理</div>
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="班次编号">
<el-input
v-model="searchForm.xydbh"
placeholder="请输入班次编号(模糊)"
clearable
style="width: 220px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="年度">
<el-select
v-model="filterYear"
placeholder="全部年度"
clearable
filterable
style="width: 140px"
@change="handleYearChange"
>
<el-option v-for="y in yearFilterOptions" :key="y" :label="`${y}年`" :value="y" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- ==================== 2. 工具栏按钮区 ==================== -->
<div class="list-toolbar">
<div class="left-group">
<el-button type="primary" icon="el-icon-plus" @click="handleBatchAdd">批量创建班次学期</el-button>
<el-button type="primary" plain icon="el-icon-document-add" @click="handleAdd">新增</el-button>
<el-button type="primary" plain icon="el-icon-edit" :disabled="!currentRow" @click="handleEdit">编辑</el-button>
<el-button type="danger" plain icon="el-icon-delete" :disabled="!selection.length" @click="handleDelete">删除所选</el-button>
<el-button type="primary" plain icon="el-icon-date" :disabled="!selection.length" @click="handleQuickSetDates">快速设定学期日期</el-button>
<el-button type="primary" plain icon="el-icon-notebook-2" :disabled="!selection.length" @click="handleSetJxrw">批量设置教学任务</el-button>
</div>
<div class="right-group">
<el-button type="success" plain icon="el-icon-calendar" :disabled="!currentRow" @click="handleEditCalendar">编辑班历</el-button>
</div>
</div>
<!-- ==================== 3. 班次学期信息列表 ==================== -->
<el-card shadow="never" class="table-card">
<el-table
ref="tableRef"
v-loading="loading"
:data="displayData"
border
stripe
highlight-current-row
size="small"
max-height="480"
class="class-table"
@selection-change="handleSelectionChange"
@current-change="handleCurrentChange"
>
<template slot="empty">
<span>无数据!</span>
</template>
<el-table-column type="selection" width="44" align="center" />
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="xydbh" label="班次编号" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="nd" label="年度" width="80" align="center" show-overflow-tooltip />
<el-table-column label="学期第次" width="90" align="center">
<template slot-scope="{ row }">{{ xqdcLabel(row.xqdc) }}</template>
</el-table-column>
<el-table-column prop="kxrq" label="开学日期" width="110" align="center" :formatter="fmtDate" />
<el-table-column prop="jsrq" label="结束日期" width="110" align="center" :formatter="fmtDate" />
<el-table-column prop="zyjsbh" label="专用教室" width="100" align="center" show-overflow-tooltip />
<el-table-column label="教学任务" min-width="160" align="center" show-overflow-tooltip>
<template slot-scope="{ row }">{{ taskName(row.jxrwbh) }}</template>
</el-table-column>
<el-table-column label="开放教员排课" width="110" align="center">
<template slot-scope="{ row }">
<el-tag v-if="Number(row.kfjypk) === 1" type="success" size="small">开放</el-tag>
<el-tag v-else type="info" size="small">关闭</el-tag>
</template>
</el-table-column>
<el-table-column prop="bz" label="备注" min-width="120" align="left" header-align="center" show-overflow-tooltip />
<el-table-column label="操作" width="200" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" size="small" @click="handleEditCalendar(row)">班历</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDeleteRow(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
class="list-pagination"
:current-page="pageNum"
:page-size="pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</el-card>
<!-- ==================== 班次学期新增/编辑弹窗 ==================== -->
<ClassSemesterDetailDialog
:visible="detailVisible"
:mode="detailMode"
:semester="detailSemester"
:team-info="detailTeamInfo"
:year-options="yearOptions"
:task-options="taskOptions"
@update:visible="val => detailVisible = val"
@submit="handleDetailSubmit"
/>
<!-- ==================== 班历管理弹窗 ==================== -->
<ClassCalendarDialog
:visible="calendarVisible"
:semester="calendarSemester"
:semester-options="semesterOptions"
@update:visible="val => calendarVisible = val"
/>
<!-- ==================== 批量创建班次学期弹窗 ==================== -->
<el-dialog
:visible="batchAddVisible"
title="批量创建班次学期"
width="520px"
:close-on-click-modal="false"
@update:visible="val => batchAddVisible = val"
>
<el-form ref="batchAddFormRef" :model="batchAddForm" :rules="batchAddRules" label-width="100px">
<el-form-item label="年度" prop="nd">
<el-select v-model="batchAddForm.nd" placeholder="请选择年度" filterable style="width: 100%">
<el-option v-for="y in yearOptions" :key="y" :label="`${y}年`" :value="y" />
</el-select>
</el-form-item>
<el-form-item label="学期" prop="xqdc">
<el-select v-model="batchAddForm.xqdc" placeholder="请选择学期" style="width: 100%">
<el-option label="春季学期" value="春季学期" />
<el-option label="夏季学期" value="夏季学期" />
<el-option label="秋季学期" value="秋季学期" />
</el-select>
</el-form-item>
<el-form-item label="开始日期" prop="startTime">
<el-date-picker v-model="batchAddForm.startTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择开始日期" style="width: 100%" />
</el-form-item>
<el-form-item label="结束日期" prop="endTime">
<el-date-picker v-model="batchAddForm.endTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择结束日期" style="width: 100%" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="batchAddVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleBatchAddSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 快速设定学期日期弹窗 ==================== -->
<el-dialog
:visible="dateRangeVisible"
title="快速设定学期日期"
width="480px"
:close-on-click-modal="false"
@update:visible="val => dateRangeVisible = val"
>
<el-alert
type="info"
:closable="false"
show-icon
:title="`将对选中的 ${selection.length} 条班次学期统一设定开学/结束日期`"
style="margin-bottom: 16px"
/>
<el-form ref="dateRangeFormRef" :model="dateRangeForm" :rules="dateRangeRules" label-width="100px">
<el-form-item label="开学日期" prop="kxrq">
<el-date-picker v-model="dateRangeForm.kxrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择开学日期" style="width: 100%" />
</el-form-item>
<el-form-item label="结束日期" prop="jsrq">
<el-date-picker v-model="dateRangeForm.jsrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择结束日期" style="width: 100%" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dateRangeVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleDateRangeSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 批量设置教学任务弹窗 ==================== -->
<el-dialog
:visible="jxrwVisible"
title="批量设置教学任务"
width="480px"
:close-on-click-modal="false"
@update:visible="val => jxrwVisible = val"
>
<el-alert
type="info"
:closable="false"
show-icon
:title="`将对选中的 ${selection.length} 条班次学期统一设置教学任务`"
style="margin-bottom: 16px"
/>
<el-form ref="jxrwFormRef" :model="jxrwForm" :rules="jxrwRules" label-width="100px">
<el-form-item label="教学任务" prop="jxrwbh">
<el-select v-model="jxrwForm.jxrwbh" placeholder="请选择教学任务" filterable style="width: 100%">
<el-option v-for="opt in taskOptions" :key="opt.bh" :label="opt.rwmc" :value="opt.bh" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="jxrwVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleJxrwSubmit">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import ClassSemesterDetailDialog from './ClassSemesterDetailDialog.vue'
import ClassCalendarDialog from './ClassCalendarDialog.vue'
import { listSemester, allSemester, addSemester, updateSemester, delSemester, batchDeleteSemester, batchUpdateDateRange, batchUpdateJxrwbh, batchAddFromElective } from '@/api/studentRecords/semester'
import { listAllSemester } from '@/api/teachBusiness/semester'
import { listTeachingTask } from '@/api/teachBusiness/teachingTask'
export default {
name: 'ShiftSemester',
components: {
ClassSemesterDetailDialog,
ClassCalendarDialog
},
data() {
return {
loading: false,
saving: false,
// ==================== 查询条件 ====================
searchForm: { xydbh: '' },
filterYear: undefined,
yearFilterOptions: [],
// ==================== 列表与分页 ====================
tableData: [],
selection: [],
currentRow: null,
pageNum: 1,
pageSize: 10,
total: 0,
// ==================== 下拉数据 ====================
/** 年度下拉(来自 /semester/all) */
yearOptions: [],
/** 教学任务下拉({ bh, rwmc }) */
taskOptions: [],
/** 全部班次学期(用于班历复制目标选择) */
semesterOptions: [],
// ==================== 班次学期新增/编辑 ====================
detailVisible: false,
detailMode: 'add',
detailSemester: null,
detailTeamInfo: null,
// ==================== 班历管理 ====================
calendarVisible: false,
calendarSemester: null,
// ==================== 批量创建班次学期 ====================
batchAddVisible: false,
batchAddForm: { nd: undefined, xqdc: '', startTime: '', endTime: '' },
batchAddRules: {
nd: [{ required: true, message: '请选择年度', trigger: 'change' }],
xqdc: [{ required: true, message: '请选择学期', trigger: 'change' }],
startTime: [{ required: true, message: '请选择开始日期', trigger: 'change' }],
endTime: [{ required: true, message: '请选择结束日期', trigger: 'change' }]
},
// ==================== 快速设定学期日期 ====================
dateRangeVisible: false,
dateRangeForm: { kxrq: '', jsrq: '' },
dateRangeRules: {
kxrq: [{ required: true, message: '请选择开学日期', trigger: 'change' }],
jsrq: [{ required: true, message: '请选择结束日期', trigger: 'change' }]
},
// ==================== 批量设置教学任务 ====================
jxrwVisible: false,
jxrwForm: { jxrwbh: undefined },
jxrwRules: {
jxrwbh: [{ required: true, message: '请选择教学任务', trigger: 'change' }]
}
}
},
computed: {
/** 本地按年度过滤(后端 /semester/list 仅支持 xydbh 模糊筛选) */
displayData() {
if (!this.filterYear) return this.tableData
return this.tableData.filter(item => String(item.nd) === String(this.filterYear))
}
},
mounted() {
this.loadYearOptions()
this.loadTaskOptions()
this.loadSemesterOptions()
this.loadList()
},
methods: {
/* ==================== 格式化 ==================== */
fmtDate(val) {
if (!val) return '-'
return String(val).slice(0, 10)
},
xqdcLabel(val) {
if (val === 1 || val === '1') return '第1学期'
if (val === 2 || val === '2') return '第2学期'
if (val === 3 || val === '3') return '第3学期'
return val !== undefined && val !== null && val !== '' ? `第${val}学期` : '-'
},
/** 教学任务编号 → 名称 */
taskName(bh) {
if (!bh) return '-'
const opt = this.taskOptions.find(o => o.bh === bh)
return opt ? opt.rwmc : bh
},
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
/* ==================== 下拉数据加载 ==================== */
loadYearOptions() {
listAllSemester().then(res => {
const list = (res && res.data) || []
const years = list.map(x => x.nd).filter(v => v !== undefined && v !== null && v !== '')
this.yearOptions = [...new Set(years)].sort((a, b) => Number(a) - Number(b))
}).catch(() => {
this.yearOptions = []
})
},
loadTaskOptions() {
listTeachingTask({ pageNum: 1, pageSize: 1000 }).then(res => {
const list = (res && res.data && res.data.records) || []
this.taskOptions = list.filter(o => o.bh)
}).catch(() => {
this.taskOptions = []
})
},
loadSemesterOptions() {
allSemester().then(res => {
this.semesterOptions = (res && res.data) || []
}).catch(() => {
this.semesterOptions = []
})
},
/* ==================== 列表加载 ==================== */
loadList() {
this.loading = true
const query = this.cleanPayload({
pageNum: this.pageNum,
pageSize: this.pageSize,
xydbh: this.searchForm.xydbh
})
listSemester(query).then(res => {
const data = (res && res.data) || {}
this.tableData = data.records || []
this.total = data.total || 0
this.buildYearFilterOptions()
this.loading = false
}).catch(() => {
this.tableData = []
this.total = 0
this.loading = false
})
},
/** 本地年度过滤下拉(从当前数据动态生成,避免硬编码) */
buildYearFilterOptions() {
const years = this.tableData.map(r => r.nd).filter(v => v !== undefined && v !== null && v !== '')
this.yearFilterOptions = [...new Set(years)].sort((a, b) => Number(a) - Number(b))
},
handleYearChange() {
this.$nextTick(() => {
if (this.$refs.tableRef) this.$refs.tableRef.setCurrentRow(null)
this.currentRow = null
})
},
handleSizeChange(size) {
this.pageSize = size
this.loadList()
},
handlePageChange(page) {
this.pageNum = page
this.loadList()
},
handleSelectionChange(rows) {
this.selection = rows
},
handleCurrentChange(row) {
this.currentRow = row
},
/* ==================== 查询 / 重置 ==================== */
handleQuery() {
this.pageNum = 1
this.loadList()
},
handleReset() {
this.searchForm.xydbh = ''
this.filterYear = undefined
this.pageNum = 1
this.loadList()
},
/* ==================== 新增 / 编辑 ==================== */
handleAdd() {
this.detailMode = 'add'
this.detailSemester = null
this.detailTeamInfo = null
this.detailVisible = true
},
handleEdit(row) {
const target = row || this.currentRow
if (!target) {
this.$message.warning('请先选择一条班次学期信息')
return
}
this.detailMode = 'edit'
this.detailSemester = target
this.detailTeamInfo = null
this.detailVisible = true
},
handleDetailSubmit(payload) {
this.saving = true
const req = this.detailMode === 'edit'
? updateSemester(payload)
: addSemester(payload)
req.then(() => {
this.saving = false
this.detailVisible = false
this.$message.success(this.detailMode === 'edit' ? '班次学期已更新' : '班次学期已新增')
this.loadList()
this.loadSemesterOptions()
}).catch(() => {
this.saving = false
})
},
/* ==================== 删除 ==================== */
handleDelete() {
if (!this.selection.length) {
this.$message.warning('请先勾选要删除的班次学期')
return
}
this.$confirm(`确定删除选中的 ${this.selection.length} 条班次学期吗?删除后其下班历记录将一并删除。`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const bhList = this.selection.map(r => r.bh)
batchDeleteSemester(bhList).then(() => {
this.$message.success('已删除')
this.loadList()
this.loadSemesterOptions()
})
}).catch(() => {})
},
handleDeleteRow(row) {
this.$confirm(`确定删除班次学期「${row.xydbh || row.bh}」吗?删除后其下班历记录将一并删除。`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delSemester(row.bh).then(() => {
this.$message.success('已删除')
this.loadList()
this.loadSemesterOptions()
})
}).catch(() => {})
},
/* ==================== 编辑班历 ==================== */
handleEditCalendar(row) {
const target = row || this.currentRow
if (!target) {
this.$message.warning('请先在列表中选择一条班次学期信息')
return
}
this.calendarSemester = target
this.calendarVisible = true
},
/* ==================== 批量创建班次学期 ==================== */
handleBatchAdd() {
this.batchAddForm = { nd: this.yearOptions[0] || undefined, xqdc: '', startTime: '', endTime: '' }
this.batchAddVisible = true
this.$nextTick(() => {
if (this.$refs.batchAddFormRef) this.$refs.batchAddFormRef.clearValidate()
})
},
handleBatchAddSubmit() {
this.$refs.batchAddFormRef.validate(valid => {
if (!valid) return
const f = this.batchAddForm
this.saving = true
batchAddFromElective({
nd: f.nd,
xqdc: f.xqdc,
startTime: f.startTime,
endTime: f.endTime
}).then(res => {
this.saving = false
this.batchAddVisible = false
const count = (res && res.data) || 0
this.$message.success(`已创建 ${count} 个班次学期`)
this.loadList()
this.loadSemesterOptions()
}).catch(() => {
this.saving = false
})
})
},
/* ==================== 快速设定学期日期 ==================== */
handleQuickSetDates() {
if (!this.selection.length) {
this.$message.warning('请先勾选要设定日期的班次学期')
return
}
this.dateRangeForm = { kxrq: '', jsrq: '' }
this.dateRangeVisible = true
this.$nextTick(() => {
if (this.$refs.dateRangeFormRef) this.$refs.dateRangeFormRef.clearValidate()
})
},
handleDateRangeSubmit() {
this.$refs.dateRangeFormRef.validate(valid => {
if (!valid) return
const f = this.dateRangeForm
this.saving = true
batchUpdateDateRange({
bhList: this.selection.map(r => r.bh),
xqkssj: f.kxrq,
xqjssj: f.jsrq
}).then(res => {
this.saving = false
this.dateRangeVisible = false
const count = (res && res.data) || 0
this.$message.success(`已更新 ${count} 条班次学期的日期`)
this.loadList()
}).catch(() => {
this.saving = false
})
})
},
/* ==================== 批量设置教学任务 ==================== */
handleSetJxrw() {
if (!this.selection.length) {
this.$message.warning('请先勾选要设置教学任务的班次学期')
return
}
this.jxrwForm = { jxrwbh: undefined }
this.jxrwVisible = true
this.$nextTick(() => {
if (this.$refs.jxrwFormRef) this.$refs.jxrwFormRef.clearValidate()
})
},
handleJxrwSubmit() {
this.$refs.jxrwFormRef.validate(valid => {
if (!valid) return
this.saving = true
batchUpdateJxrwbh({
bhList: this.selection.map(r => r.bh),
jxrwbh: this.jxrwForm.jxrwbh
}).then(res => {
this.saving = false
this.jxrwVisible = false
const count = (res && res.data) || 0
this.$message.success(`已更新 ${count} 条班次学期的教学任务`)
this.loadList()
}).catch(() => {
this.saving = false
})
})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.shift-semester-page {
// ========== 页面标题 ==========
.page-title {
font-size: 16px;
font-weight: 600;
color: #303133;
margin-bottom: 12px;
padding-left: 10px;
border-left: 4px solid var(--edu-green-primary);
}
// ========== 1. 查询条件区域 ==========
.search-card {
margin-bottom: 16px;
}
// ========== 2. 工具栏按钮区 ==========
.list-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
.left-group,
.right-group {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
}
// ========== 3. 数据表格区 ==========
.table-card {
.class-table {
width: 100%;
}
.text-danger {
color: #f56c6c;
}
.list-pagination {
margin-top: 12px;
text-align: right;
}
}
}
</style>
@@ -0,0 +1,740 @@
<template>
<div class="app-container management-page subject-page">
<!-- ==================== 2. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<div class="section-heading">
<div>
<h2 class="section-title">筛选条件</h2>
<p class="section-description">按课程名称、代码和培训属性筛选课程科目</p>
</div>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
</div>
<el-form :model="searchForm">
<el-row :gutter="32">
<!-- 左栏 -->
<el-col :xs="24" :md="12">
<div class="query-field">
<span class="q-label no-check">课名称</span>
<el-input v-model="searchForm.kmc" placeholder="请输入课名称" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">科目代码</span>
<el-input v-model="searchForm.kmdm" placeholder="请输入科目代码" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">培训层次</span>
<el-input v-model="searchForm.pxcc" placeholder="请输入培训层次" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">课程类型</span>
<el-input v-model="searchForm.kclx" placeholder="请输入课程类型" clearable class="q-control" />
</div>
</el-col>
<!-- 右栏 -->
<el-col :xs="24" :md="12">
<div class="query-field">
<span class="q-label no-check">简称</span>
<el-input v-model="searchForm.jc" placeholder="请输入简称" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">教研室代号</span>
<el-input v-model="searchForm.jysdh" placeholder="请输入教研室代号" clearable class="q-control" />
</div>
<div class="query-field">
<span class="q-label no-check">培训类型</span>
<el-input v-model="searchForm.pxlx" placeholder="请输入培训类型" clearable class="q-control" />
</div>
</el-col>
</el-row>
</el-form>
</el-card>
<!-- ==================== 3. 操作按钮区域 ==================== -->
<el-card shadow="never" class="action-card">
<div class="section-heading section-heading--compact">
<div>
<h2 class="section-title">课程科目操作</h2>
<p class="section-description">维护课程科目,或下载业务数据与导入模板</p>
</div>
</div>
<div class="action-row">
<el-button type="primary" icon="el-icon-plus" @click="handleOpenDialog">新建课程科目</el-button>
<el-button type="danger" plain icon="el-icon-delete" @click="handleBatchDelete">删除所选</el-button>
</div>
<div class="action-row">
<el-button icon="el-icon-download" @click="handleDownloadTemplate">【课程科目数据文件模板】下载</el-button>
</div>
</el-card>
<!-- ==================== 4. 文件上传区域 ==================== -->
<el-card shadow="never" class="upload-card">
<div class="section-heading section-heading--compact">
<div>
<h2 class="section-title">数据导入</h2>
<p class="section-description">选择填写完成的课程科目模板并上传</p>
</div>
</div>
<div class="upload-row">
<div class="upload-left">
<el-button icon="el-icon-folder-opened" @click="handleSelectFile">选择文件</el-button>
<span class="file-name" :class="{ 'has-file': selectedFile }">{{ fileName }}</span>
<input ref="fileInputRef" type="file" style="display: none" @change="handleFileChange" />
</div>
<div class="upload-right">
<el-checkbox v-model="coverExist">覆盖已存在课程科目</el-checkbox>
<el-button type="primary" icon="el-icon-upload2" @click="handleUpload">上传数据</el-button>
</div>
</div>
</el-card>
<!-- ==================== 6. 数据表格区域 ==================== -->
<el-card shadow="never" class="table-card">
<div class="section-heading section-heading--compact table-heading">
<div>
<h2 class="section-title">课程科目列表</h2>
<p class="section-description">共 {{ total }} 条数据</p>
</div>
</div>
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="40" align="center" />
<el-table-column prop="kbh" label="课编号" width="130" show-overflow-tooltip />
<el-table-column prop="kmc" label="课名称" width="200" show-overflow-tooltip />
<el-table-column prop="jc" label="简称" width="130" show-overflow-tooltip />
<el-table-column prop="jysdh" label="教研室代号" width="150" show-overflow-tooltip />
<el-table-column prop="kclx" label="课程类型" width="150" align="center" />
<el-table-column prop="pxlx" label="培训类型" width="150" align="center" />
<el-table-column prop="pxcc" label="培训层次" width="200" align="center" />
<el-table-column prop="xf" label="学分" align="center" />
<el-table-column prop="xs" label="学时" width="160" align="center" />
<el-table-column label="操作" width="150" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(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>
<!-- 新增/编辑课程科目弹窗 -->
<el-dialog
:visible="dialogVisible"
:title="dialogTitle"
width="1000px"
:close-on-click-modal="false"
class="add-dialog"
@update:visible="val => dialogVisible = val"
>
<el-form ref="addFormRef" :model="addForm" :rules="rules" label-width="120px" class="add-form" :status-icon="false">
<el-row :gutter="24">
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课编号" prop="kbh">
<el-input v-model="addForm.kbh" :disabled="isEdit" placeholder="新增时留空自动生成" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课名称" prop="kmc">
<el-input v-model="addForm.kmc" placeholder="请输入课名称" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="简称" prop="jc">
<el-input v-model="addForm.jc" placeholder="请输入简称" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="教研室代号" prop="jysdh">
<el-input v-model="addForm.jysdh" placeholder="请输入教研室代号" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="学分" prop="xf">
<el-input-number v-model="addForm.xf" :min="0" :precision="1" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="学时" prop="xs">
<el-input-number v-model="addForm.xs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="培训层次" prop="pxcc">
<el-input v-model="addForm.pxcc" placeholder="请输入培训层次" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="培训类型" prop="pxlx">
<el-input v-model="addForm.pxlx" placeholder="请输入培训类型" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课程类型" prop="kclx">
<el-input v-model="addForm.kclx" placeholder="请输入课程类型" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="考试课时" prop="ksks">
<el-input-number v-model="addForm.ksks" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="成绩分制" prop="cjfz">
<el-input v-model="addForm.cjfz" placeholder="请输入成绩分制" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="不计入学员平均分" prop="bjrxypjf">
<el-select v-model="addForm.bjrxypjf" class="w-full">
<el-option label="否" :value="0" />
<el-option label="是" :value="1" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="理论学时" prop="llxs">
<el-input-number v-model="addForm.llxs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="实践学时" prop="sjxs">
<el-input-number v-model="addForm.sjxs" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="周课时" prop="zks">
<el-input-number v-model="addForm.zks" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课类型" prop="klx">
<el-input v-model="addForm.klx" placeholder="请输入课类型" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="考试课时不显示" prop="ksksbxs">
<el-select v-model="addForm.ksksbxs" class="w-full">
<el-option label="否" :value="0" />
<el-option label="是" :value="1" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课程统一编号" prop="kctybh">
<el-input v-model="addForm.kctybh" placeholder="请输入课程统一编号" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="辅导答疑课时" prop="fddyks">
<el-input-number v-model="addForm.fddyks" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="自修课时" prop="zxks">
<el-input-number v-model="addForm.zxks" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="修订日期" prop="xdrq">
<el-input v-model="addForm.xdrq" placeholder="如 2026-08-24" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="节次优选级" prop="jcyxj">
<el-input v-model="addForm.jcyxj" placeholder="请输入节次优选级" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课程支持方式" prop="kczcfs">
<el-input v-model="addForm.kczcfs" placeholder="请输入课程支持方式" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="课程建设方式" prop="kcjsfs">
<el-input v-model="addForm.kcjsfs" placeholder="请输入课程建设方式" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="政治类课程" prop="zzlkc">
<el-select v-model="addForm.zzlkc" class="w-full">
<el-option label="否" :value="0" />
<el-option label="是" :value="1" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="考核方式" prop="khfs">
<el-input v-model="addForm.khfs" placeholder="请输入考核方式" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="形成性成绩分值" prop="xcxcjfz">
<el-input-number v-model="addForm.xcxcjfz" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="终结性成绩分值" prop="zjxcjfz">
<el-input-number v-model="addForm.zjxcjfz" :min="0" controls-position="right" class="w-full" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="密级" prop="mj">
<el-input v-model="addForm.mj" placeholder="请输入密级" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8">
<el-form-item label="评选情况" prop="pxqk">
<el-input v-model="addForm.pxqk" placeholder="请输入评选情况" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24">
<el-form-item label="备注">
<el-input v-model="addForm.bz" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer">
<div class="dialog-footer">
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" :loading="addLoading" @click="handleSubmit">保存</el-button>
</div>
</div>
</el-dialog>
</div>
</template>
<script>
import { saveAs } from 'file-saver'
import { listKb as listSubject, addKb as addSubject, updateKb as updateSubject, deleteKb as deleteSubject, getKb, downloadCourseSubjectTemplate } from '@/api/teachOffice/kb'
export default {
name: 'SubjectIndex',
data() {
return {
// ==================== 1. 顶部状态提示 ====================
statusTip: '请输入查询条件',
// ==================== 2. 查询条件 ====================
searchForm: {
kmc: '',
jc: '',
kmdm: '',
jysdh: '',
kclx: '',
pxlx: '',
pxcc: ''
},
// ==================== 列表数据 ====================
loading: false,
tableData: [],
total: 0,
pageNum: 1,
pageSize: 20,
selectedRows: [],
// ==================== 文件上传 ====================
selectedFile: null,
coverExist: false,
// ==================== 新增/编辑弹窗 ====================
dialogVisible: false,
addLoading: false,
isEdit: false,
addForm: this.createEmptyForm(),
rules: {
kmc: [{ required: true, message: '请输入课名称', trigger: 'blur' }],
jysdh: [{ required: true, message: '请输入教研室代号', trigger: 'blur' }],
xf: [{ required: true, message: '请输入学分', trigger: 'blur' }],
pxcc: [{ required: true, message: '请输入培训层次', trigger: 'blur' }],
pxlx: [{ required: true, message: '请输入培训类型', trigger: 'blur' }],
kclx: [{ required: true, message: '请输入课程类型', trigger: 'blur' }],
ksks: [{ required: true, message: '请输入考试课时', trigger: 'blur' }],
cjfz: [{ required: true, message: '请输入成绩分制', trigger: 'blur' }],
llxs: [{ required: true, message: '请输入理论学时', trigger: 'blur' }],
sjxs: [{ required: true, message: '请输入实践学时', trigger: 'blur' }],
zks: [{ required: true, message: '请输入周课时', trigger: 'blur' }],
klx: [{ required: true, message: '请输入课类型', trigger: 'blur' }],
kctybh: [{ required: true, message: '请输入课程统一编号', trigger: 'blur' }],
fddyks: [{ required: true, message: '请输入辅导答疑课时', trigger: 'blur' }],
zxks: [{ required: true, message: '请输入自修课时', trigger: 'blur' }],
xdrq: [{ required: true, message: '请输入修订日期', trigger: 'blur' }],
jcyxj: [{ required: true, message: '请输入节次优选级', trigger: 'blur' }],
kczcfs: [{ required: true, message: '请输入课程支持方式', trigger: 'blur' }],
kcjsfs: [{ required: true, message: '请输入课程建设方式', trigger: 'blur' }],
khfs: [{ required: true, message: '请输入考核方式', trigger: 'blur' }],
xcxcjfz: [{ required: true, message: '请输入形成性成绩分值', trigger: 'blur' }],
zjxcjfz: [{ required: true, message: '请输入终结性成绩分值', trigger: 'blur' }],
mj: [{ required: true, message: '请输入密级', trigger: 'blur' }],
pxqk: [{ required: true, message: '请输入评选情况', trigger: 'blur' }]
}
}
},
computed: {
dialogTitle() {
return this.isEdit ? '编辑课程科目' : '新增课程科目'
},
fileName() {
return (this.selectedFile && this.selectedFile.name) || '未选择任何文件'
}
},
mounted() {
this.fetchList()
},
methods: {
/** 移除空值 */
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
/** 创建空白课程科目表单 */
createEmptyForm() {
return {
kbh: '', kmc: '', jysdh: '', bz: '', xh: '', xf: 0, jc: '', xs: 0,
pxcc: '', pxlx: '', kclx: '', ksks: 0, py: '', gfmc: '', cjfz: '',
bjrxypjf: 0, jxglbmbh: '', llxs: 0, sjxs: 0, kmdm: '', zks: 0, klx: '',
ksksbxs: 0, kctybh: '', sydx: '', fddyks: 0, zxks: 0, bb: '', xdrq: '',
jcyxj: '', kczcfs: '', kcjsfs: '', jsonzd: '', zzlkc: 0, khfs: '',
xcxcjfz: 0, zjxcjfz: 0, mj: '', pxqk: ''
}
},
resetForm() {
this.addForm = this.createEmptyForm()
},
// ==================== 列表加载 ====================
buildQuery() {
return this.cleanPayload({
pageNum: this.pageNum,
pageSize: this.pageSize,
kmc: this.searchForm.kmc,
jc: this.searchForm.jc,
kmdm: this.searchForm.kmdm,
jysdh: this.searchForm.jysdh,
kclx: this.searchForm.kclx,
pxlx: this.searchForm.pxlx,
pxcc: this.searchForm.pxcc
})
},
fetchList() {
this.loading = true
listSubject(this.buildQuery())
.then(res => {
const data = (res && res.data) || {}
this.tableData = data.records || []
this.total = data.total || 0
this.statusTip = `共检索到 ${this.total} 条记录`
})
.finally(() => {
this.loading = false
})
},
// ==================== 查询 ====================
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handlePageChange(current) {
this.pageNum = current
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
handleSelectionChange(rows) {
this.selectedRows = rows
},
// ==================== 删除所选 ====================
handleBatchDelete() {
if (this.selectedRows.length === 0) {
this.$message.warning('请先选择要删除的记录')
return
}
const kbhList = this.selectedRows.map(r => r.kbh)
this.$confirm(`确定删除所选 ${kbhList.length} 条课程科目吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const tasks = kbhList.map(kbh => deleteSubject(kbh))
Promise.all(tasks)
.then(() => {
this.$message.success(`已删除 ${kbhList.length} 条记录`)
this.fetchList()
})
.catch(() => {
this.$message.error('删除失败')
})
}).catch(() => {})
},
/** 单条删除 */
handleDelete(row) {
this.$confirm(`确定删除课程科目「${row.kmc || row.kbh}」吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return deleteSubject(row.kbh)
}).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch((err) => {
if (err && err !== 'cancel') {
this.$message.error('删除失败')
}
})
},
// ==================== 下载 ====================
handleDownloadTemplate() {
downloadCourseSubjectTemplate().then(blob => {
saveAs(blob, '课程课目数据文件模板.xls')
this.$message.success('模板下载成功')
}).catch(() => {})
},
// ==================== 文件上传(后端暂未提供) ====================
handleSelectFile() {
this.$refs.fileInputRef && this.$refs.fileInputRef.click()
},
handleFileChange(e) {
const input = e.target
this.selectedFile = (input.files && input.files[0]) || null
},
handleUpload() {
this.$message.warning('后端暂未提供该接口')
},
// ==================== 新增/编辑弹窗 ====================
handleOpenDialog() {
this.isEdit = false
this.resetForm()
this.dialogVisible = true
},
handleEdit(row) {
this.addLoading = true
getKb(row.kbh)
.then(res => {
const data = (res && res.data) || row
this.isEdit = true
this.addForm = Object.assign(this.createEmptyForm(), data)
this.dialogVisible = true
})
.finally(() => {
this.addLoading = false
})
},
handleSubmit() {
this.$refs.addFormRef.validate((valid) => {
if (!valid) return
this.addLoading = true
const payload = this.cleanPayload({ ...this.addForm })
const requestFn = this.isEdit ? updateSubject : addSubject
requestFn(payload)
.then(() => {
this.$message.success(this.isEdit ? '修改成功' : '保存成功')
this.dialogVisible = false
this.fetchList()
})
.finally(() => {
this.addLoading = false
})
})
},
handleCancel() {
this.dialogVisible = false
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
// ==================== 1. 顶部状态提示 ====================
.status-tip {
display: inline-block;
background: #dc3545;
color: #fff;
font-size: 12px;
padding: 3px 10px;
border-radius: 4px;
margin-bottom: 12px;
}
// ==================== 2. 查询条件区域 ====================
.search-card {
margin-bottom: 16px;
.query-field {
display: flex;
align-items: center;
margin-bottom: 14px;
min-height: 32px;
::v-deep(.el-checkbox) {
margin-right: 6px;
flex-shrink: 0;
}
.q-label {
width: 120px;
flex-shrink: 0;
font-size: 13px;
color: #303133;
text-align: right;
margin-right: 10px;
white-space: nowrap;
&.no-check {
margin-left: 24px;
}
}
.q-control {
flex: 1;
min-width: 0;
}
}
.notice {
font-size: 12px;
color: #f56c6c;
margin-top: 8px;
text-align: left;
}
}
// ==================== 3. 操作按钮区域 ====================
.action-card {
margin-bottom: 16px;
.action-row {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
}
// ==================== 4. 文件上传区域 ====================
.upload-card {
margin-bottom: 16px;
.upload-row {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
.upload-left {
display: flex;
align-items: center;
gap: 12px;
.file-name {
font-size: 12px;
color: #999;
&.has-file {
color: #303133;
}
}
}
.upload-right {
display: flex;
align-items: center;
gap: 12px;
}
}
}
// ==================== 5. 红色提示文字 ====================
.red-tip {
font-size: 14px;
color: #f56c6c;
margin-bottom: 16px;
line-height: 1.6;
}
// ==================== 6. 数据表格区域 ====================
.table-card {
.pagination-wrapper {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
::v-deep(.el-table .cell) {
font-size: 12px;
}
.text-danger {
color: #f56c6c;
}
}
// ==================== 新增/编辑弹窗 ====================
.add-dialog {
::v-deep(.el-dialog__body) {
max-height: 70vh;
overflow: auto;
}
}
.add-form {
.w-full {
width: 100%;
}
}
.dialog-footer {
display: flex;
justify-content: flex-end;
gap: 12px;
}
</style>
@@ -0,0 +1,513 @@
<template>
<div class="app-container task-plan-page">
<!-- ==================== 页面标题 ==================== -->
<div class="page-title">教学任务计划管理</div>
<!-- ==================== 1. 查询条件区域 ==================== -->
<el-card shadow="never" class="search-card">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="任务名称">
<el-input
v-model="searchForm.rwmc"
placeholder="请输入任务名称"
clearable
style="width: 180px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="年度">
<el-select v-model="searchForm.nd" placeholder="请选择年度" clearable filterable style="width: 140px">
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.zt" placeholder="请选择状态" clearable style="width: 140px">
<el-option
v-for="opt in statusOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- ==================== 2. 操作区域 ==================== -->
<div class="list-toolbar">
<div class="left-group">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建教学任务</el-button>
</div>
</div>
<!-- ==================== 3. 数据表格 ==================== -->
<el-card shadow="never" class="table-card">
<el-table v-loading="loading" :data="tableData" border stripe class="task-table">
<template slot="empty">
<span>无数据!</span>
</template>
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="rwmc" label="任务名称" width="250" align="center" show-overflow-tooltip />
<el-table-column prop="nd" label="年度" width="150" align="center" />
<el-table-column label="状态" width="100" align="center">
<template slot-scope="{ row }">
<el-tag :type="row.zt === '发布' ? 'success' : 'info'" size="small">
{{ row.zt || '-' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="fbsj" label="发布时间" width="180" align="center" :formatter="fmtDateTime" />
<el-table-column prop="jssj" label="结束时间" width="180" align="center" :formatter="fmtDateTime" />
<el-table-column prop="cjsj" label="创建时间" width="180" align="center" :formatter="fmtDateTime" />
<el-table-column prop="jcxqscsj" label="教材需求生成时间" align="center" :formatter="fmtDateTime" />
<el-table-column label="操作" width="300" align="center" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleDetail(row)">详情</el-button>
<el-button type="text" size="small" @click="handleEdit(row)">编辑</el-button>
<el-button
type="text"
size="small"
:disabled="row.zt === '发布'"
@click="handlePublish(row)"
>发布</el-button>
<el-button type="text" size="small" class="text-danger" @click="handleDelete(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"
@current-change="handlePageChange"
@size-change="handleSizeChange"
/>
</el-card>
<!-- ==================== 4. 新增/修改对话框 ==================== -->
<el-dialog
:visible="dialogVisible"
:title="dialogTitle"
width="560px"
:close-on-click-modal="false"
@update:visible="val => dialogVisible = val"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="140px" class="add-form">
<el-form-item v-if="isEdit" label="编号" prop="bh">
<el-input v-model="form.bh" disabled placeholder="编号不可修改" />
</el-form-item>
<el-form-item v-else label="编号">
<el-input disabled placeholder="新增后由系统自动生成" />
</el-form-item>
<el-form-item label="任务名称" prop="rwmc">
<el-input v-model="form.rwmc" placeholder="请输入任务名称" clearable />
</el-form-item>
<el-form-item label="年度" prop="nd">
<el-select v-model="form.nd" placeholder="请选择年度" filterable style="width: 100%">
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="zt">
<el-select v-model="form.zt" placeholder="请选择状态" style="width: 100%">
<el-option
v-for="opt in statusOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="form.fbsj"
type="datetime"
value-format="yyyy-MM-ddTHH:mm:ss"
placeholder="请选择发布时间"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker
v-model="form.jssj"
type="datetime"
value-format="yyyy-MM-ddTHH:mm:ss"
placeholder="请选择结束时间"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="教材需求生成时间">
<el-date-picker
v-model="form.jcxqscsj"
type="datetime"
value-format="yyyy-MM-ddTHH:mm:ss"
placeholder="请选择教材需求生成时间"
style="width: 100%"
/>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="handleSubmit">确定</el-button>
</div>
</el-dialog>
<!-- ==================== 5. 详情对话框 ==================== -->
<el-dialog
:visible="detailVisible"
title="教学任务详情"
width="620px"
:close-on-click-modal="false"
@update:visible="val => detailVisible = val"
>
<el-descriptions v-if="detailData.bh" :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="任务名称">{{ detailData.rwmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="年度">{{ fmtVal(detailData.nd) }}</el-descriptions-item>
<el-descriptions-item label="状态">{{ detailData.zt || '-' }}</el-descriptions-item>
<el-descriptions-item label="发布时间">{{ fmtVal(detailData.fbsj) }}</el-descriptions-item>
<el-descriptions-item label="结束时间">{{ fmtVal(detailData.jssj) }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ fmtVal(detailData.cjsj) }}</el-descriptions-item>
<el-descriptions-item label="教材需求生成时间">{{ fmtVal(detailData.jcxqscsj) }}</el-descriptions-item>
</el-descriptions>
<div v-else v-loading="detailLoading" class="detail-empty">加载中...</div>
<div slot="footer">
<el-button @click="detailVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
/**
* 教学任务计划管理(完整管理页)
* 对应菜单:teachOffice/taskPlan
* 提供 teachingTask 全套真实接口操作:分页查询 list、详情 get?bh=、新增 add、编辑 update、
* 发布 batchPublish?bh=(需先填写教研室任务书)、删除 delete?bh=(级联删除教研室任务书)
* 只读查询视图在 src/views/teachBusiness/teachingTask/index.vue(教学任务列表)提供,避免重复操作同一实体
*/
import {
listTeachingTask,
getTeachingTask,
addTeachingTask,
updateTeachingTask,
deleteTeachingTask,
publishTeachingTask
} from '@/api/teachBusiness/teachingTask'
import { listAllSemester } from '@/api/teachBusiness/semester'
export default {
name: 'TaskPlan',
data() {
return {
// ==================== 1. 查询条件 ====================
searchForm: {
rwmc: '',
nd: undefined,
zt: ''
},
yearOptions: [],
statusOptions: [
{ label: '未发布', value: '未发布' },
{ label: '发布', value: '发布' }
],
// ==================== 2. 表格数据 ====================
loading: false,
tableData: [],
pageNum: 1,
pageSize: 10,
total: 0,
// ==================== 3. 新增/修改表单 ====================
dialogVisible: false,
dialogTitle: '新建教学任务',
isEdit: false,
saving: false,
form: this.createEmptyForm(),
rules: {
rwmc: [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
nd: [{ required: true, message: '请选择年度', trigger: 'change' }],
zt: [{ required: true, message: '请选择状态', trigger: 'change' }]
},
// ==================== 4. 详情 ====================
detailVisible: false,
detailLoading: false,
detailData: {}
}
},
created() {
this.loadYearOptions().then(() => this.fetchList())
},
methods: {
/* ---------- 年度下拉(数据来自 /semester/all,禁止硬编码) ---------- */
loadYearOptions() {
return listAllSemester().then(response => {
const list = response.data || []
const map = {}
list.forEach(item => {
if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item
})
const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a)))
this.yearOptions = arr
// 默认年度:优先当前学期(dqxq=true),否则取最新年度
const current = list.find(item => item.dqxq === true)
const defaultNd = (current && current.nd) || arr[0]
if (!this.searchForm.nd) this.searchForm.nd = defaultNd
return arr
}).catch(() => {
this.yearOptions = []
return []
})
},
/* ---------- 通用格式化 ---------- */
fmtDateTime(row, column, cellValue) {
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
return String(cellValue).replace('T', ' ').slice(0, 16)
},
fmtVal(val) {
if (val === null || val === undefined || val === '') return '-'
return String(val).replace('T', ' ').slice(0, 16)
},
/** 移除空值(''/null/undefined),保留 0 等有效值 */
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {
const value = obj[key]
if (value !== '' && value !== null && value !== undefined) {
payload[key] = value
}
})
return payload
},
/* ---------- 列表加载 ---------- */
fetchList() {
this.loading = true
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (this.searchForm.rwmc && this.searchForm.rwmc.trim()) params.rwmc = this.searchForm.rwmc.trim()
if (this.searchForm.nd !== undefined && this.searchForm.nd !== null && this.searchForm.nd !== '') {
params.nd = this.searchForm.nd
}
if (this.searchForm.zt && this.searchForm.zt.trim()) params.zt = this.searchForm.zt.trim()
listTeachingTask(params).then(res => {
const data = (res && res.data) || {}
this.tableData = data.records || []
this.total = data.total || 0
this.loading = false
}).catch(() => {
this.tableData = []
this.total = 0
this.loading = false
})
},
handleQuery() {
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
/* ---------- 新增 / 修改 ---------- */
createEmptyForm() {
return {
bh: '',
rwmc: '',
nd: undefined,
zt: '未发布',
fbsj: '',
jssj: '',
jcxqscsj: ''
}
},
handleAdd() {
this.form = this.createEmptyForm()
if (!this.form.nd && this.searchForm.nd) this.form.nd = this.searchForm.nd
this.isEdit = false
this.dialogTitle = '新建教学任务'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleEdit(row) {
this.form = {
bh: row.bh || '',
rwmc: row.rwmc || '',
nd: row.nd,
zt: row.zt || '未发布',
fbsj: row.fbsj || '',
jssj: row.jssj || '',
jcxqscsj: row.jcxqscsj || ''
}
this.isEdit = true
this.dialogTitle = '修改教学任务'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) {
this.$message.warning('请完善必填项后再提交')
return
}
const payload = this.cleanPayload(this.buildPayload())
this.saving = true
const req = this.isEdit ? updateTeachingTask(payload) : addTeachingTask(payload)
req.then(() => {
this.$message.success(this.isEdit ? '修改成功' : '新建成功')
this.dialogVisible = false
this.fetchList()
}).catch(() => {}).finally(() => {
this.saving = false
})
})
},
/** 构建请求体:年度转数字以匹配后端 Integer,时间字段有值才传 */
buildPayload() {
const f = this.form
const payload = {}
if (this.isEdit && f.bh && String(f.bh).trim()) payload.bh = String(f.bh).trim()
if (f.rwmc && String(f.rwmc).trim()) payload.rwmc = String(f.rwmc).trim()
if (f.nd !== undefined && f.nd !== null && f.nd !== '') payload.nd = Number(f.nd)
if (f.zt && String(f.zt).trim()) payload.zt = String(f.zt).trim()
if (f.fbsj) payload.fbsj = f.fbsj
if (f.jssj) payload.jssj = f.jssj
if (f.jcxqscsj) payload.jcxqscsj = f.jcxqscsj
return payload
},
/* ---------- 详情 ---------- */
handleDetail(row) {
this.detailVisible = true
this.detailLoading = true
this.detailData = {}
getTeachingTask(row.bh).then(res => {
this.detailData = (res && res.data) || {}
this.detailLoading = false
}).catch(() => {
this.detailLoading = false
})
},
/* ---------- 删除 ---------- */
handleDelete(row) {
this.$confirm(`确定要删除「${row.rwmc || row.bh || '该记录'}」吗?删除将级联删除关联的教研室任务书。`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => deleteTeachingTask(row.bh)).then(() => {
this.$message.success('删除成功')
this.fetchList()
}).catch(() => {})
},
/* ---------- 发布 ---------- */
handlePublish(row) {
this.$confirm(`确定要发布教学任务「${row.rwmc || row.bh || '该记录'}」吗?发布前请先填写关联的教研室任务书。`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => publishTeachingTask(row.bh)).then(() => {
this.$message.success('发布成功')
this.fetchList()
}).catch(() => {})
}
}
}
</script>
<style scoped lang="scss">
.app-container {
padding: 20px;
}
.task-plan-page {
.page-title {
text-align: center;
font-size: 20px;
font-weight: 600;
color: #303133;
margin-bottom: 20px;
}
// ========== 1. 查询条件区域 ==========
.search-card {
margin-bottom: 16px;
.search-form {
.el-form-item {
margin-bottom: 0;
margin-right: 24px;
}
}
}
// ========== 2. 工具栏 ==========
.list-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
.left-group,
.right-group {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
}
}
// ========== 3. 数据表格区域 ==========
.table-card {
.task-table {
width: 100%;
}
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
.text-danger {
color: #f56c6c;
}
}
// ========== 4. 详情 ==========
.detail-empty {
min-height: 120px;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
}
}
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,387 @@
<template>
<div class="page-container">
<!-- 查询条件 -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="110px" class="search-form">
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="开始日期">
<el-date-picker v-model="searchForm.ksrq" type="date" value-format="yyyy-MM-dd" placeholder="选择开始日期"
class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期">
<el-date-picker v-model="searchForm.jsrq" type="date" value-format="yyyy-MM-dd" placeholder="选择结束日期"
class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="课程名称">
<el-input v-model="searchForm.kcmc" placeholder="请输入课程名称" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教研室">
<el-select v-model="searchForm.jys" placeholder="请选择教研室" clearable class="w-full">
<el-option v-for="item in jysOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="教学方法">
<el-select v-model="searchForm.jxff" placeholder="请选择教学方法" clearable class="w-full">
<el-option v-for="item in jxffOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="授课教员">
<el-select v-model="searchForm.skjy" placeholder="请选择授课教员" clearable class="w-full">
<el-option v-for="item in skjyOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<!-- <el-row :gutter="0">
<el-col :span="24">
<el-form-item label="改动情况">
<div class="change-options">
<el-radio-group v-model="searchForm.createSource">
<el-radio v-for="item in createSourceOptions" :key="item" :label="item">{{ item }}</el-radio>
</el-radio-group>
<el-checkbox-group v-model="searchForm.changeTypes">
<el-checkbox v-for="item in changeTypeOptions" :key="item" :label="item">{{ item }}</el-checkbox>
</el-checkbox-group>
</div>
</el-form-item>
</el-col>
</el-row> -->
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="任务类别">
<el-select v-model="searchForm.rwlb" placeholder="请选择任务类别" clearable class="w-full">
<el-option v-for="item in rwlbOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训期班">
<el-input v-model="searchForm.pxqb" placeholder="请输入培训期班" clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="search-actions">
<el-button type="primary" @click="handleSearch">查询</el-button>
</div>
</el-card>
<!-- 数据表格 -->
<el-card shadow="never" class="table-card">
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="rwlb" label="任务类别" width="130" align="center" show-overflow-tooltip />
<el-table-column prop="jyxm" label="主讲教员" width="100" align="center" />
<el-table-column prop="rq" label="日期" width="150" align="center">
<template slot-scope="scope">{{ scope.row.rq ? formatDate(scope.row.rq) : '-' }}</template>
</el-table-column>
<el-table-column label="节次" width="80" align="center">
<template slot-scope="scope">
{{ scope.row.qsjc && scope.row.jsjc ? `${scope.row.qsjc}-${scope.row.jsjc}节` : (scope.row.qsjc || '-') }}
</template>
</el-table-column>
<el-table-column prop="kcmc" label="课程名称" min-width="150" show-overflow-tooltip />
<el-table-column prop="pxqbxx" label="培训期班信息" min-width="140" show-overflow-tooltip />
<el-table-column label="人数" width="70" align="center">
<template slot-scope="scope">{{ scope.row.sdrs || scope.row.ydrs || '-' }}</template>
</el-table-column>
<el-table-column label="分组指导教员" width="120" align="center">
<template slot-scope="scope">{{ scope.row.fzyzdjy || '-' }}</template>
</el-table-column>
<el-table-column prop="jsfs" label="教学方法" width="100" align="center" />
<el-table-column prop="zt" label="日志状态" width="100" align="center" />
<el-table-column prop="gdqk" label="变动汇总" min-width="120" show-overflow-tooltip />
<el-table-column prop="jxrzcjfs" label="创建方式" width="100" align="center" />
</el-table>
<!-- 分页 -->
<div class="pagination-wrapper">
<el-pagination :current-page="pageNum" :page-size="pageSize" :total="total" :page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper" background @current-change="handlePageChange"
@size-change="handleSizeChange" />
</div>
</el-card>
<!-- 日志详情对话框 -->
<el-dialog :visible.sync="detailVisible" title="教学日志详情" width="700px" destroy-on-close>
<div v-loading="detailLoading">
<el-descriptions v-if="!detailLoading" :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="统一编号">{{ detailData.tybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教员编号">{{ detailData.jybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教员姓名">{{ detailData.jyxm || '-' }}</el-descriptions-item>
<el-descriptions-item label="课程名称">{{ detailData.kcmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="任务类别">{{ detailData.rwlb || '-' }}</el-descriptions-item>
<el-descriptions-item label="日期">{{ detailData.rq || '-' }}</el-descriptions-item>
<el-descriptions-item label="节次">
{{ detailData.qsjc && detailData.jsjc ? `${detailData.qsjc}-${detailData.jsjc}节` : '-' }}
</el-descriptions-item>
<el-descriptions-item label="教学方法">{{ detailData.jsfs || detailData.jxff || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建方式">{{ detailData.jxrzcjfs || '-' }}</el-descriptions-item>
<el-descriptions-item label="应到人数">{{ detailData.ydrs || '-' }}</el-descriptions-item>
<el-descriptions-item label="实到人数">{{ detailData.sdrs || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训期班信息" :span="2">{{ detailData.pxqbxx || '-' }}</el-descriptions-item>
<el-descriptions-item label="授课地点" :span="2">{{ detailData.skdd || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">{{ detailData.zt || '-' }}</el-descriptions-item>
<el-descriptions-item label="教研室">{{ detailData.jysmc || detailData.jys || '-' }}</el-descriptions-item>
<el-descriptions-item label="变动汇总" :span="2">{{ detailData.gdqk || '-' }}</el-descriptions-item>
<el-descriptions-item label="变动详细情况" :span="2">{{ detailData.gdxxqk || '-' }}</el-descriptions-item>
<el-descriptions-item label="退回意见" :span="2">{{ detailData.thyj || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detailData.cjsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="修改时间">{{ detailData.xgsj || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="detailVisible = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { formatDate } from '@/utils/index'
import { getAuditedTeachingLogList, getTeachingLogByBh } from '@/api/log'
export default {
name: 'AuditedView',
data() {
return {
// ==================== 查询表单 ====================
searchForm: {
ksrq: '',
jsrq: '',
kcmc: '',
jys: '',
jxff: '',
skjy: '',
createSource: '',
changeTypes: [],
rwlb: '',
pxqb: ''
},
jysOptions: ['教研室', '防空兵系', '通信工程系', '装甲兵系'],
jxffOptions: ['理论讲授', '讨论', '实操', '演示'],
skjyOptions: ['教务处', '张三', '李四', '王五'],
rwlbOptions: ['全军院校训练规划内任务', '其他任务'],
createSourceOptions: ['由教学计划创建', '已改动教学计划', '手动拟制'],
changeTypeOptions: [
'教员变动',
'时间变动',
'课程变动',
'授课方式变动',
'任务类别变动',
'期班变动',
'地点变动',
'课题变动'
],
// ==================== 数据表格 ====================
loading: false,
tableData: [],
selectedRows: [],
pageNum: 1,
pageSize: 20,
total: 0,
// ==================== 详情 ====================
detailVisible: false,
detailLoading: false,
detailData: {}
}
},
created() {
this.fetchList()
},
methods: {
handleSelectionChange(rows) {
this.selectedRows = rows
},
/** 组件方法:包一层全局 formatDate,供模板调用 */
formatDate(val) {
return formatDate(val)
},
/** 根据已填写的查询值构建实际查询参数 */
buildSearchParams() {
const form = this.searchForm
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (form.ksrq) params.ksrq = form.ksrq
if (form.jsrq) params.jsrq = form.jsrq
if (form.kcmc) params.kcmc = form.kcmc
if (form.jys) params.jys = form.jys
if (form.jxff) params.jxff = form.jxff
if (form.skjy) params.skjy = form.skjy
if (form.rwlb) params.rwlb = form.rwlb
if (form.pxqb) params.pxqb = form.pxqb
if (form.createSource) params.gdqk = form.createSource
if (form.changeTypes.length > 0) {
params.gdxxqk = form.changeTypes.join(',')
}
return params
},
extractListData(res) {
const data = res.data || res
const list = data.records || data.list || data.rows || []
const totalCount = data.total ?? data.totalCount ?? data.totalRows ?? 0
return { list, total: totalCount }
},
fetchList() {
this.loading = true
return getAuditedTeachingLogList(this.buildSearchParams())
.then((res) => {
// 列表接口返回裸 PageResult(无 code 包装),拦截器已保证成功,直接取数据
const { list, total } = this.extractListData(res)
this.tableData = list
this.total = total
})
.catch(() => {})
.finally(() => {
this.loading = false
})
},
handleSearch() {
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
handleDetail(row) {
this.detailData = { ...row }
this.detailVisible = true
const bh = row.bh
if (!bh) return
this.detailLoading = true
getTeachingLogByBh(String(bh))
.then((res) => {
if ((res.code === 200 || res.code === 0) && res.data) {
this.detailData = res.data
}
})
.catch(() => {})
.finally(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.page-container {
padding: 4px 8px;
}
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
::v-deep .el-row {
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
}
::v-deep .el-col {
border-right: 1px solid #ebeef5;
&:last-child {
border-right: none;
}
}
::v-deep .el-form-item__label {
white-space: normal;
line-height: 1.4;
text-align: left;
justify-content: flex-start;
}
.el-form-item {
margin-bottom: 0;
padding: 10px 12px;
}
.change-options {
display: flex;
flex-direction: column;
gap: 8px;
::v-deep .el-radio-group,
::v-deep .el-checkbox-group {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
}
}
.search-tip {
padding: 6px 12px 0;
font-size: 12px;
color: #f56c6c;
}
.search-actions {
display: flex;
justify-content: flex-end;
padding: 12px;
border-top: 1px solid #ebeef5;
}
}
.table-card {
.el-table {
width: 100%;
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
padding: 16px 0 0;
}
}
</style>
@@ -0,0 +1,567 @@
<template>
<div class="page-container">
<!-- 查询条件 -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="110px" class="search-form">
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="开始日期">
<el-date-picker v-model="searchForm.ksrq" type="date" value-format="yyyy-MM-dd" placeholder="选择开始日期"
class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期">
<el-date-picker v-model="searchForm.jsrq" type="date" value-format="yyyy-MM-dd" placeholder="选择结束日期"
class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="课程名称">
<el-input v-model="searchForm.kcmc" placeholder="请输入课程名称" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教研室">
<el-select v-model="searchForm.jys" placeholder="请选择教研室" clearable class="w-full">
<el-option v-for="item in jysOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="教学方法">
<el-select v-model="searchForm.jxff" placeholder="请选择教学方法" clearable class="w-full">
<el-option v-for="item in jxffOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日志状态">
<el-select v-model="searchForm.rzzt" placeholder="请选择日志状态" clearable class="w-full">
<el-option v-for="item in rzztOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="授课教员">
<el-select v-model="searchForm.skjy" placeholder="请选择授课教员" clearable class="w-full">
<el-option v-for="item in skjyOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训期班">
<el-input v-model="searchForm.pxqb" placeholder="请输入培训期班" clearable />
</el-form-item>
</el-col>
</el-row>
<!-- <el-row :gutter="0">
<el-col :span="12">
<el-form-item label="改动情况">
<div class="change-options">
<el-radio-group v-model="searchForm.changeType">
<el-radio v-for="item in changeTypeOptions" :key="item.value" :label="item.value">{{ item.label
}}</el-radio>
</el-radio-group>
<el-checkbox-group v-model="searchForm.changeTypes">
<el-checkbox v-for="item in changeTypeList" :key="item.value" :label="item.value">{{ item.label
}}</el-checkbox>
</el-checkbox-group>
</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务类别">
<el-select v-model="searchForm.rwlb" placeholder="请选择任务类别" clearable class="w-full">
<el-option v-for="item in rwlbOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row> -->
</el-form>
<div class="search-actions">
<div class="left-group">
<el-button type="primary" @click="handleBatchReport">批准上报所选</el-button>
<!-- <el-button @click="handleRecheck">重新检查通报变更情况</el-button> -->
<el-button icon="el-icon-download" @click="handleExport">导出</el-button>
<el-button icon="el-icon-refresh" @click="handleRefresh">刷新</el-button>
<el-button icon="el-icon-upload2" :loading="importing" @click="handleImportExcel">导入教学日志</el-button>
<el-button icon="el-icon-download" @click="handleDownloadTemplate">下载模板</el-button>
</div>
<el-button type="primary" @click="handleSearch">查询</el-button>
</div>
<!-- 隐藏的文件选择器,用于导入 Excel -->
<input ref="importFileInput" type="file" accept=".xls,.xlsx" style="display: none" @change="handleImportFileChange" />
</el-card>
<!-- 数据表格 -->
<el-card shadow="never" class="table-card">
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="rwlb" label="库任务类别" width="120" align="center" />
<el-table-column prop="jyxm" label="主讲教员" width="100" align="center" />
<el-table-column prop="rq" label="日期" width="150" align="center">
<template slot-scope="scope">{{ scope.row.rq ? formatDate(scope.row.rq) : '-' }}</template>
</el-table-column>
<el-table-column label="节次" width="80" align="center">
<template slot-scope="scope">
{{ scope.row.qsjc && scope.row.jsjc ? `${scope.row.qsjc}-${scope.row.jsjc}节` : (scope.row.qsjc || '-') }}
</template>
</el-table-column>
<el-table-column prop="kcmc" label="课程名称" min-width="150" show-overflow-tooltip />
<el-table-column prop="pxqbxx" label="培训期班信息" min-width="140" show-overflow-tooltip />
<el-table-column label="人数" width="70" align="center">
<template slot-scope="scope">{{ scope.row.sdrs || scope.row.ydrs || '-' }}</template>
</el-table-column>
<el-table-column label="分组指导教员" width="120" align="center">
<template slot-scope="scope">{{ scope.row.fzyzdjy || '-' }}</template>
</el-table-column>
<el-table-column prop="jsfs" label="教学方法" width="100" align="center" />
<el-table-column prop="zt" label="日志状态" width="100" align="center" />
<el-table-column prop="gdqk" label="变动汇总" min-width="120" show-overflow-tooltip />
<el-table-column prop="jxrzcjfs" label="创建方式" width="100" align="center" />
<el-table-column label="操作" width="80" align="center" fixed="right" class-name="table-action-column">
<template slot-scope="scope">
<el-button type="text" @click="handleReport(scope.row)">上报</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-wrapper">
<el-pagination :current-page="pageNum" :page-size="pageSize" :total="total" :page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper" background @current-change="handlePageChange"
@size-change="handleSizeChange" />
</div>
</el-card>
<!-- 日志详情对话框 -->
<el-dialog :visible.sync="detailVisible" title="教学日志详情" width="700px" destroy-on-close>
<div v-loading="detailLoading">
<el-descriptions v-if="!detailLoading" :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="统一编号">{{ detailData.tybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教员编号">{{ detailData.jybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教员姓名">{{ detailData.jyxm || '-' }}</el-descriptions-item>
<el-descriptions-item label="课程名称">{{ detailData.kcmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="任务类别">{{ detailData.rwlb || '-' }}</el-descriptions-item>
<el-descriptions-item label="日期">{{ detailData.rq || '-' }}</el-descriptions-item>
<el-descriptions-item label="节次">
{{ detailData.qsjc && detailData.jsjc ? `${detailData.qsjc}-${detailData.jsjc}节` : '-' }}
</el-descriptions-item>
<el-descriptions-item label="教学方法">{{ detailData.jsfs || detailData.jxff || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建方式">{{ detailData.jxrzcjfs || '-' }}</el-descriptions-item>
<el-descriptions-item label="应到人数">{{ detailData.ydrs || '-' }}</el-descriptions-item>
<el-descriptions-item label="实到人数">{{ detailData.sdrs || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训期班信息" :span="2">{{ detailData.pxqbxx || '-' }}</el-descriptions-item>
<el-descriptions-item label="授课地点" :span="2">{{ detailData.skdd || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">{{ detailData.zt || '-' }}</el-descriptions-item>
<el-descriptions-item label="教研室">{{ detailData.jysmc || detailData.jys || '-' }}</el-descriptions-item>
<el-descriptions-item label="变动汇总" :span="2">{{ detailData.gdqk || '-' }}</el-descriptions-item>
<el-descriptions-item label="变动详细情况" :span="2">{{ detailData.gdxxqk || '-' }}</el-descriptions-item>
<el-descriptions-item label="退回意见" :span="2">{{ detailData.thyj || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detailData.cjsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="修改时间">{{ detailData.xgsj || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="detailVisible = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { formatDate } from '@/utils/index'
import {
getTeachingLogList,
exportTeachingLog,
importTeachingLogExcel,
downloadTeachingLogTemplate,
getTeachingLogByBh,
batchReportTeachingLog
} from '@/api/log'
export default {
name: 'LogView',
data() {
return {
// ==================== 查询表单 ====================
searchForm: {
ksrq: '',
jsrq: '',
kcmc: '',
jys: '',
jxff: '',
rzzt: '',
skjy: '',
pxqb: '',
changeType: '',
changeTypes: [],
rwlb: ''
},
jysOptions: ['教研室', '防空兵系', '通信工程系', '装甲兵系'],
jxffOptions: ['理论讲授', '讨论', '实操', '演示', '实验', '演习'],
skjyOptions: ['教务处', '张三', '李四', '王五', '赵六'],
rzztOptions: ['教务部门导入教员类', '管理员手工添加'],
rwlbOptions: ['全军院校训练规划内任务', '其他任务'],
changeTypeOptions: [
{ label: '与教学计划一致', value: '与教学计划一致' },
{ label: '已改动教学计划', value: '已改动教学计划' },
{ label: '手动拟制', value: '手动拟制' }
],
changeTypeList: [
{ label: '已改动教员', value: '已改动教员' },
{ label: '已改动时间', value: '已改动时间' },
{ label: '已改动课目', value: '已改动课目' },
{ label: '已改动内容', value: '已改动内容' },
{ label: '已改动教学方法', value: '已改动教学方法' },
{ label: '已改动场地', value: '已改动场地' },
{ label: '已改动期班', value: '已改动期班' }
],
// ==================== 数据表格 ====================
loading: false,
tableData: [],
selectedRows: [],
pageNum: 1,
pageSize: 20,
total: 0,
// ==================== 导入 ====================
importing: false,
// 导入成功后是否跳到最后一页(定位到刚导入的数据)
importJumpLast: false,
// ==================== 详情 ====================
detailVisible: false,
detailLoading: false,
detailData: {}
}
},
created() {
this.fetchList()
},
methods: {
formatDate(val) {
return formatDate(val)
},
handleSelectionChange(rows) {
this.selectedRows = rows
},
/** 根据已填写的查询值构建实际查询参数 */
buildSearchParams() {
const form = this.searchForm
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (form.ksrq) params.ksrq = form.ksrq
if (form.jsrq) params.jsrq = form.jsrq
if (form.kcmc) params.kcmc = form.kcmc
if (form.jys) params.jys = form.jys
if (form.jxff) params.jxff = form.jxff
if (form.rzzt) params.rzzt = form.rzzt
if (form.skjy) params.skjy = form.skjy
if (form.pxqb) params.pxqb = form.pxqb
if (form.rwlb) params.rwlb = form.rwlb
if (form.changeType) params.gdqk = form.changeType
if (form.changeTypes.length > 0) {
params.gdxxqk = form.changeTypes.join(',')
}
return params
},
/** 从响应中提取列表数据和总数(兼容 records / list / rows 等常见字段名) */
extractListData(res) {
const data = res.data || res
const list = data.records || data.list || data.rows || []
const totalCount = data.total ?? data.totalCount ?? data.totalRows ?? 0
return { list, total: totalCount }
},
fetchList() {
this.loading = true
return getTeachingLogList(this.buildSearchParams())
.then((res) => {
// 列表接口返回裸 PageResult(无 code 包装),拦截器已保证成功,直接取数据
const { list, total } = this.extractListData(res)
// 导入成功后:跳到最后一页,定位刚导入的数据
if (this.importJumpLast) {
this.importJumpLast = false
const lastPage = total > 0 ? Math.ceil(total / this.pageSize) : 1
if (lastPage !== this.pageNum) {
this.pageNum = lastPage
this.fetchList()
return
}
}
this.tableData = list
this.total = total
})
.catch(() => {
// 错误已由拦截器统一处理
})
.finally(() => {
this.loading = false
})
},
handleSearch() {
this.pageNum = 1
this.fetchList()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
handleRefresh() {
this.fetchList()
},
getSelectedBhs() {
const ids = this.selectedRows.map((row) => row.bh).filter(Boolean)
if (ids.length === 0) {
this.$message.warning('请先选择要操作的记录')
return []
}
return ids
},
handleBatchReport() {
const ids = this.getSelectedBhs()
if (ids.length === 0) return
this.$confirm(`确定要上报选中的 ${ids.length} 条记录吗?`, '上报确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
// 批量上报教学日志
return batchReportTeachingLog(ids)
})
.then(() => {
this.$message.success(`已上报 ${ids.length} 条记录`)
this.fetchList()
})
.catch(() => {})
},
handleReport(row) {
const bh = row && row.bh
if (!bh) {
this.$message.warning('记录编号不存在,无法上报')
return
}
this.$confirm('确定要上报该条教学日志吗?', '上报确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => batchReportTeachingLog([String(bh)]))
.then(() => {
this.$message.success('上报成功')
this.fetchList()
})
.catch(() => {})
},
handleRecheck() {
// 后端暂未提供重新检查接口,仅作提示
this.$message.info('后端暂未提供该接口')
},
downloadBlob(blob, fileName) {
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
},
handleExport() {
const params = this.buildSearchParams()
delete params.pageNum
delete params.pageSize
exportTeachingLog(params)
.then((blob) => {
this.downloadBlob(blob, `教学日志_${new Date().toISOString().slice(0, 10)}.xls`)
this.$message.success('导出成功')
})
.catch(() => {})
},
handleImportExcel() {
this.$refs.importFileInput && this.$refs.importFileInput.click()
},
handleImportFileChange(e) {
const files = e.target.files
if (!files || files.length === 0) return
const file = files[0]
this.importing = true
importTeachingLogExcel(file)
.then((res) => {
if (res.code === 200 || res.code === 0) {
this.$message.success(res.message || '导入成功')
this.importJumpLast = true
this.fetchList()
} else {
this.$message.error(res.message || '导入失败')
}
})
.catch(() => {})
.finally(() => {
this.importing = false
if (this.$refs.importFileInput) {
this.$refs.importFileInput.value = ''
}
})
},
handleDownloadTemplate() {
downloadTeachingLogTemplate()
.then((blob) => {
this.downloadBlob(blob, '导入教学日志模板.xls')
this.$message.success('模板下载成功')
})
.catch(() => {})
},
handleDetail(row) {
this.detailData = { ...row }
this.detailVisible = true
const bh = row.bh
if (!bh) return
this.detailLoading = true
getTeachingLogByBh(String(bh))
.then((res) => {
if ((res.code === 200 || res.code === 0) && res.data) {
this.detailData = res.data
}
})
.catch(() => {
// 详情接口不可用时保留行数据兜底展示
})
.finally(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.page-container {
padding: 4px 8px;
}
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
::v-deep .el-row {
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
}
::v-deep .el-col {
border-right: 1px solid #ebeef5;
&:last-child {
border-right: none;
}
}
::v-deep .el-form-item__label {
white-space: normal;
line-height: 1.4;
text-align: left;
justify-content: flex-start;
}
.el-form-item {
margin-bottom: 0;
padding: 10px 12px;
}
.change-options {
display: flex;
flex-direction: column;
gap: 8px;
::v-deep .el-radio-group,
::v-deep .el-checkbox-group {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
}
}
.search-tip {
padding: 6px 12px 0;
font-size: 12px;
color: #f56c6c;
}
.search-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
border-top: 1px solid #ebeef5;
.left-group {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
}
}
.table-card {
.el-table {
width: 100%;
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
padding: 16px 0 0;
}
}
</style>
@@ -0,0 +1,554 @@
<template>
<div class="page-container">
<!-- 查询条件 -->
<el-card shadow="never" class="search-card">
<el-form :model="searchForm" label-width="110px" class="search-form">
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="开始日期">
<el-date-picker v-model="searchForm.startDate" type="date" value-format="yyyy-MM-dd" placeholder="选择开始日期"
class="w-full" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期">
<el-date-picker v-model="searchForm.endDate" type="date" value-format="yyyy-MM-dd" placeholder="选择结束日期"
class="w-full" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="课程名称">
<el-input v-model="searchForm.courseName" placeholder="请输入课程名称" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教学方法">
<el-select v-model="searchForm.teachMethod" placeholder="请选择教学方法" clearable class="w-full">
<el-option v-for="item in teachMethodOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<!-- <el-col :span="12">
<el-form-item label="改动情况">
<el-select v-model="searchForm.change" placeholder="请选择改动情况" clearable class="w-full">
<el-option v-for="item in changeOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col> -->
<el-col :span="12">
<el-form-item label="任务类别">
<el-select v-model="searchForm.taskCategory" placeholder="请选择任务类别" clearable class="w-full">
<el-option v-for="item in taskCategoryOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="教研室">
<el-select v-model="searchForm.dept" placeholder="请选择教研室" clearable class="w-full">
<el-option v-for="item in deptOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="授课教员">
<el-select v-model="searchForm.teacher" placeholder="请选择授课教员" clearable class="w-full">
<el-option v-for="item in teacherOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="0">
<el-col :span="12">
<el-form-item label="培训班">
<el-input v-model="searchForm.className" placeholder="请输入培训班" clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="search-actions">
<div class="left-group">
<el-button v-if="!isTeacher" type="primary" @click="handleBatchAudit">审核通过所选</el-button>
<el-button icon="el-icon-download" @click="handleExport">导出到 Word</el-button>
</div>
<div class="right-group">
<el-button @click="handleReset">重置</el-button>
<el-button type="primary" @click="handleSearch">查询</el-button>
</div>
</div>
</el-card>
<!-- 数据表格 -->
<el-card shadow="never" class="table-card">
<el-table v-loading="loading" :data="tableData" stripe border highlight-current-row
@selection-change="handleSelectionChange">
<el-table-column v-if="!isTeacher" type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="rwlb" label="任务类别" width="120" align="center" show-overflow-tooltip />
<el-table-column prop="jyxm" label="主讲教员" width="100" align="center" />
<el-table-column prop="rq" label="日期" width="150" align="center">
<template slot-scope="scope">{{ scope.row.rq ? formatDate(scope.row.rq) : '-' }}</template>
</el-table-column>
<el-table-column label="节次" width="80" align="center">
<template slot-scope="scope">
{{ scope.row.qsjc && scope.row.jsjc ? `${scope.row.qsjc}-${scope.row.jsjc}节` : (scope.row.qsjc || '-') }}
</template>
</el-table-column>
<el-table-column prop="kcmc" label="课程名称" width="80" show-overflow-tooltip />
<el-table-column prop="pxqbxx" label="培训期班信息" show-overflow-tooltip />
<el-table-column label="人数" width="80" align="center">
<template slot-scope="scope">{{ scope.row.sdrs || scope.row.ydrs || '-' }}</template>
</el-table-column>
<el-table-column label="分组指导教员" width="100" align="center">
<template slot-scope="scope">{{ scope.row.fzyzdjy || '-' }}</template>
</el-table-column>
<el-table-column prop="jsfs" label="教学方法" width="80" align="center" />
<el-table-column prop="zt" label="日志状态" width="100" align="center" />
<el-table-column prop="gdqk" label="变动汇总" width="100" show-overflow-tooltip />
<el-table-column prop="jxrzcjfs" label="创建方式" width="100" align="center" />
<el-table-column v-if="!isTeacher" label="操作" width="160" align="center" fixed="right" class-name="table-action-column">
<template slot-scope="scope">
<el-button type="text" @click="handleAudit(scope.row)">审核</el-button>
<el-button type="text" @click="handleReject(scope.row)">退回</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-wrapper">
<el-pagination :current-page="pageNum" :page-size="pageSize" :total="total" :page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper" background @current-change="handlePageChange"
@size-change="handleSizeChange" />
</div>
</el-card>
<!-- 日志详情对话框 -->
<el-dialog :visible.sync="detailVisible" title="教学日志详情" width="700px" destroy-on-close>
<div v-loading="detailLoading">
<el-descriptions v-if="!detailLoading" :column="2" border>
<el-descriptions-item label="编号">{{ detailData.bh || '-' }}</el-descriptions-item>
<el-descriptions-item label="统一编号">{{ detailData.tybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教员编号">{{ detailData.jybh || '-' }}</el-descriptions-item>
<el-descriptions-item label="教员姓名">{{ detailData.jyxm || '-' }}</el-descriptions-item>
<el-descriptions-item label="课程名称">{{ detailData.kcmc || '-' }}</el-descriptions-item>
<el-descriptions-item label="任务类别">{{ detailData.rwlb || '-' }}</el-descriptions-item>
<el-descriptions-item label="日期">{{ detailData.rq || '-' }}</el-descriptions-item>
<el-descriptions-item label="节次">
{{ detailData.qsjc && detailData.jsjc ? `${detailData.qsjc}-${detailData.jsjc}节` : '-' }}
</el-descriptions-item>
<el-descriptions-item label="教学方法">{{ detailData.jsfs || detailData.jxff || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建方式">{{ detailData.jxrzcjfs || '-' }}</el-descriptions-item>
<el-descriptions-item label="应到人数">{{ detailData.ydrs || '-' }}</el-descriptions-item>
<el-descriptions-item label="实到人数">{{ detailData.sdrs || '-' }}</el-descriptions-item>
<el-descriptions-item label="培训期班信息" :span="2">{{ detailData.pxqbxx || '-' }}</el-descriptions-item>
<el-descriptions-item label="授课地点" :span="2">{{ detailData.skdd || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">{{ detailData.zt || '-' }}</el-descriptions-item>
<el-descriptions-item label="教研室">{{ detailData.jysmc || detailData.jys || '-' }}</el-descriptions-item>
<el-descriptions-item label="变动汇总" :span="2">{{ detailData.gdqk || '-' }}</el-descriptions-item>
<el-descriptions-item label="变动详细情况" :span="2">{{ detailData.gdxxqk || '-' }}</el-descriptions-item>
<el-descriptions-item label="退回意见" :span="2">{{ detailData.thyj || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ detailData.cjsj || '-' }}</el-descriptions-item>
<el-descriptions-item label="修改时间">{{ detailData.xgsj || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="detailVisible = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { formatDate } from '@/utils/index'
import {
getReportedTeachingLogList,
rejectTeachingLog,
exportTeachingLog,
getTeachingLogByBh,
batchAuditTeachingLog
} from '@/api/log'
export default {
name: 'ReportedView',
props: {
/** 当前用户是否为教员角色,用于隐藏审核相关操作 */
isTeacher: {
type: Boolean,
default: false
}
},
data() {
return {
// ==================== 查询表单 ====================
searchForm: {
startDate: '',
endDate: '',
courseName: '',
teachMethod: '',
change: '',
taskCategory: '',
dept: '',
teacher: '',
className: ''
},
teachMethodOptions: ['理论讲授', '实践教学', '研讨教学', '案例教学', '实操演练'],
changeOptions: [
'与教学计划一致',
'已改动教学计划',
'手动拟制',
'教员变动',
'时间变动',
'课程变动',
'授课方式变动',
'任务类别变动',
'期班变动',
'地点变动',
'课题变动'
],
taskCategoryOptions: ['全军院校训练规划内任务', '其他任务(含研究生导师指导)'],
deptOptions: ['教务处', '指挥系', '政治工作教研室', '军事基础教研室', '装备保障教研室'],
teacherOptions: ['教务处', '张三', '李四', '王五', '赵六', '孙七'],
// ==================== 数据表格 ====================
loading: false,
tableData: [],
selectedRows: [],
pageNum: 1,
pageSize: 20,
total: 0,
// ==================== 退回意见 ====================
remark: '',
// ==================== 详情 ====================
detailVisible: false,
detailLoading: false,
detailData: {}
}
},
created() {
this.fetchList()
},
methods: {
handleSelectionChange(rows) {
this.selectedRows = rows
},
/** 组件方法:包一层全局 formatDate,供模板调用 */
formatDate(val) {
return formatDate(val)
},
/** 根据已填写的查询值构建实际查询参数 */
buildSearchParams() {
const form = this.searchForm
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
if (form.startDate) params.ksrq = form.startDate
if (form.endDate) params.jsrq = form.endDate
if (form.courseName) params.kcmc = form.courseName
if (form.teachMethod) params.jxff = form.teachMethod
if (form.change) params.gdqk = form.change
if (form.taskCategory) params.rwlb = form.taskCategory
if (form.dept) params.jys = form.dept
if (form.teacher) params.skjy = form.teacher
if (form.className) params.pxqb = form.className
return params
},
extractListData(res) {
const data = res.data || res
const list = data.records || data.list || data.rows || []
const totalCount = data.total ?? data.totalCount ?? data.totalRows ?? 0
return { list, total: totalCount }
},
fetchList() {
this.loading = true
return getReportedTeachingLogList(this.buildSearchParams())
.then((res) => {
// 列表接口返回裸 PageResult(无 code 包装),拦截器已保证成功,直接取数据
const { list, total } = this.extractListData(res)
this.tableData = list
this.total = total
})
.catch(() => {})
.finally(() => {
this.loading = false
})
},
handleSearch() {
this.pageNum = 1
this.fetchList()
},
handleReset() {
this.searchForm = {
startDate: '',
endDate: '',
courseName: '',
teachMethod: '',
change: '',
taskCategory: '',
dept: '',
teacher: '',
className: ''
}
this.remark = ''
this.handleSearch()
},
handlePageChange(page) {
this.pageNum = page
this.fetchList()
},
handleSizeChange(size) {
this.pageSize = size
this.pageNum = 1
this.fetchList()
},
getSelectedBhs() {
const ids = this.selectedRows.map((row) => row.bh).filter(Boolean)
if (ids.length === 0) {
this.$message.warning('请先选择记录')
return []
}
return ids
},
handleDelete() {
// 后端暂未提供删除接口,仅作提示
this.$message.info('后端暂未提供该接口')
},
handleBatchAudit() {
const ids = this.getSelectedBhs()
if (ids.length === 0) return
this.$confirm(`确定要审核通过选中的 ${ids.length} 条记录吗?`, '审核确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
// 批量审核教学日志
return batchAuditTeachingLog(ids)
})
.then(() => {
this.$message.success(`已审核通过 ${ids.length} 条记录`)
this.fetchList()
})
.catch(() => {})
},
handleAudit(row) {
const bh = row && row.bh
if (!bh) {
this.$message.warning('记录编号不存在,无法审核')
return
}
this.$confirm('确定要审核通过该条教学日志吗?', '审核确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => batchAuditTeachingLog([String(bh)]))
.then(() => {
this.$message.success('审核通过成功')
this.fetchList()
})
.catch(() => {})
},
handleReject(row) {
const bh = row && row.bh
if (!bh) {
this.$message.warning('记录编号不存在,无法退回')
return
}
this.$prompt('请输入退回原因/意见', '退回确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /\S/,
inputErrorMessage: '退回原因不能为空'
})
.then(({ value }) => rejectTeachingLog(String(bh), value.trim()))
.then(() => {
this.$message.success('退回成功')
this.fetchList()
})
.catch(() => {})
},
handleWithdraw() {
const ids = this.getSelectedBhs()
if (ids.length === 0) return
if (!this.remark.trim()) {
this.$message.warning('请填写退回原因/意见')
return
}
const opinion = this.remark.trim()
let settled = Promise.resolve()
ids.forEach((bh) => {
settled = settled.then(() => rejectTeachingLog(bh, opinion))
})
this.$confirm(`确定要撤回重填选中的 ${ids.length} 条记录吗?`, '撤回确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => settled)
.then(() => {
this.$message.success(`已撤回 ${ids.length} 条记录`)
this.fetchList()
})
.catch(() => {})
},
handleRecheck() {
// 后端暂未提供重新检查接口,仅作提示
this.$message.info('后端暂未提供该接口')
},
downloadBlob(blob, fileName) {
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
},
handleExport() {
const params = this.buildSearchParams()
delete params.pageNum
delete params.pageSize
exportTeachingLog(params)
.then((blob) => {
this.downloadBlob(blob, `已上报教学日志_${new Date().toISOString().slice(0, 10)}.xls`)
this.$message.success('导出成功')
})
.catch(() => {})
},
handleDetail(row) {
this.detailData = { ...row }
this.detailVisible = true
const bh = row.bh
if (!bh) return
this.detailLoading = true
getTeachingLogByBh(String(bh))
.then((res) => {
if ((res.code === 200 || res.code === 0) && res.data) {
this.detailData = res.data
}
})
.catch(() => {})
.finally(() => {
this.detailLoading = false
})
}
}
}
</script>
<style scoped lang="scss">
.page-container {
padding: 4px 8px;
}
.search-card {
margin-bottom: 16px;
.search-form {
.w-full {
width: 100%;
}
::v-deep .el-row {
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
}
::v-deep .el-col {
border-right: 1px solid #ebeef5;
&:last-child {
border-right: none;
}
}
::v-deep .el-form-item__label {
white-space: normal;
line-height: 1.4;
text-align: left;
justify-content: flex-start;
}
.el-form-item {
margin-bottom: 0;
padding: 10px 12px;
}
}
.search-tip {
padding: 6px 12px 0;
font-size: 12px;
color: #f56c6c;
}
.search-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
border-top: 1px solid #ebeef5;
.left-group {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
.action-input {
width: 240px;
}
}
.right-group {
display: flex;
align-items: center;
gap: 8px;
}
}
}
.table-card {
.el-table {
width: 100%;
}
.pagination-wrapper {
display: flex;
justify-content: flex-end;
padding: 16px 0 0;
}
}
</style>
@@ -0,0 +1,75 @@
<template>
<div class="page-container">
<el-card shadow="never" class="tab-card">
<el-tabs v-model="activeTab" class="organ-tabs">
<!-- 教学日志管理查询页:仅管理员/教研室等非教员、非机关人员可见 -->
<el-tab-pane v-if="hasQueryAccess" label="教学日志管理查询" name="query">
<log-view v-if="activeTab === 'query'" />
</el-tab-pane>
<el-tab-pane label="已上报机关教学日志" name="reported">
<reported-view v-if="activeTab === 'reported'" :is-teacher="isTeacher" />
</el-tab-pane>
<el-tab-pane label="机关已审核教学日志" name="audited">
<audited-view v-if="activeTab === 'audited'" />
</el-tab-pane>
</el-tabs>
</el-card>
</div>
</template>
<script>
import LogView from './components/logView.vue'
import ReportedView from './components/reportedView.vue'
import AuditedView from './components/auditedView.vue'
export default {
name: 'OrganLog',
components: { LogView, ReportedView, AuditedView },
data() {
return {
activeTab: 'query'
}
},
computed: {
roles() {
return this.$store.getters.roles || []
},
/** 教员角色 */
isTeacher() {
return this.roles.includes('TEACHER')
},
/** 机关人员角色 */
isDepartmentPersonnel() {
return this.roles.includes('DEPARTMENT_PERSONNEL')
},
/** 教学日志管理查询页仅非教员、非机关人员可见 */
hasQueryAccess() {
return !this.isTeacher && !this.isDepartmentPersonnel
}
},
created() {
// 教员/机关人员无法查看教学日志管理查询页,默认落在已上报页
if (!this.hasQueryAccess) {
this.activeTab = 'reported'
}
}
}
</script>
<style scoped lang="scss">
.page-container {
padding: 20px;
}
.tab-card {
.organ-tabs {
::v-deep .el-tabs__header {
margin-bottom: 8px;
}
::v-deep .el-tabs__content {
padding-top: 4px;
}
}
}
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,106 @@
<template>
<div>
<el-dialog
v-bind="$attrs"
width="500px"
:close-on-click-modal="false"
:modal-append-to-body="false"
v-on="$listeners"
@open="onOpen"
@close="onClose"
>
<el-row :gutter="15">
<el-form
ref="elForm"
:model="formData"
:rules="rules"
size="medium"
label-width="100px"
>
<el-col :span="24">
<el-form-item label="生成类型" prop="type">
<el-radio-group v-model="formData.type">
<el-radio-button
v-for="(item, index) in typeOptions"
:key="index"
:label="item.value"
:disabled="item.disabled"
>
{{ item.label }}
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="showFileName" label="文件名" prop="fileName">
<el-input v-model="formData.fileName" placeholder="请输入文件名" clearable />
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer">
<el-button @click="close">
取消
</el-button>
<el-button type="primary" @click="handleConfirm">
确定
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
inheritAttrs: false,
props: ['showFileName'],
data() {
return {
formData: {
fileName: undefined,
type: 'file'
},
rules: {
fileName: [{
required: true,
message: '请输入文件名',
trigger: 'blur'
}],
type: [{
required: true,
message: '生成类型不能为空',
trigger: 'change'
}]
},
typeOptions: [{
label: '页面',
value: 'file'
}, {
label: '弹窗',
value: 'dialog'
}]
}
},
computed: {
},
watch: {},
mounted() {},
methods: {
onOpen() {
if (this.showFileName) {
this.formData.fileName = `${+new Date()}.vue`
}
},
onClose() {
},
close(e) {
this.$emit('update:visible', false)
},
handleConfirm() {
this.$refs.elForm.validate(valid => {
if (!valid) return
this.$emit('confirm', { ...this.formData })
this.close()
})
}
}
}
</script>
@@ -0,0 +1,100 @@
<script>
import draggable from 'vuedraggable'
import render from '@/utils/generator/render'
const components = {
itemBtns(h, element, index, parent) {
const { copyItem, deleteItem } = this.$listeners
return [
<span class="drawing-item-copy" title="复制" onClick={event => {
copyItem(element, parent); event.stopPropagation()
}}>
<i class="el-icon-copy-document" />
</span>,
<span class="drawing-item-delete" title="删除" onClick={event => {
deleteItem(index, parent); event.stopPropagation()
}}>
<i class="el-icon-delete" />
</span>
]
}
}
const layouts = {
colFormItem(h, element, index, parent) {
const { activeItem } = this.$listeners
let className = this.activeId === element.formId ? 'drawing-item active-from-item' : 'drawing-item'
if (this.formConf.unFocusedComponentBorder) className += ' unfocus-bordered'
return (
<el-col span={element.span} class={className}
nativeOnClick={event => { activeItem(element); event.stopPropagation() }}>
<el-form-item label-width={element.labelWidth ? `${element.labelWidth}px` : null}
label={element.label} required={element.required}>
<render key={element.renderKey} conf={element} onInput={ event => {
this.$set(element, 'defaultValue', event)
}} />
</el-form-item>
{components.itemBtns.apply(this, arguments)}
</el-col>
)
},
rowFormItem(h, element, index, parent) {
const { activeItem } = this.$listeners
const className = this.activeId === element.formId ? 'drawing-row-item active-from-item' : 'drawing-row-item'
let child = renderChildren.apply(this, arguments)
if (element.type === 'flex') {
child = <el-row type={element.type} justify={element.justify} align={element.align}>
{child}
</el-row>
}
return (
<el-col span={element.span}>
<el-row gutter={element.gutter} class={className}
nativeOnClick={event => { activeItem(element); event.stopPropagation() }}>
<span class="component-name">{element.componentName}</span>
<draggable list={element.children} animation={340} group="componentsGroup" class="drag-wrapper">
{child}
</draggable>
{components.itemBtns.apply(this, arguments)}
</el-row>
</el-col>
)
}
}
function renderChildren(h, element, index, parent) {
if (!Array.isArray(element.children)) return null
return element.children.map((el, i) => {
const layout = layouts[el.layout]
if (layout) {
return layout.call(this, h, el, i, element.children)
}
return layoutIsNotFound()
})
}
function layoutIsNotFound() {
throw new Error(`没有与${this.element.layout}匹配的layout`)
}
export default {
components: {
render,
draggable
},
props: [
'element',
'index',
'drawingList',
'activeId',
'formConf'
],
render(h) {
const layout = layouts[this.element.layout]
if (layout) {
return layout.call(this, h, this.element, this.index, this.drawingList)
}
return layoutIsNotFound()
}
}
</script>
@@ -0,0 +1,123 @@
<template>
<div class="icon-dialog">
<el-dialog
v-bind="$attrs"
width="980px"
:modal-append-to-body="false"
v-on="$listeners"
@open="onOpen"
@close="onClose"
>
<div slot="title">
选择图标
<el-input
v-model="key"
size="mini"
:style="{width: '260px'}"
placeholder="请输入图标名称"
prefix-icon="el-icon-search"
clearable
/>
</div>
<ul class="icon-ul">
<li
v-for="icon in iconList"
:key="icon"
:class="active===icon?'active-item':''"
@click="onSelect(icon)"
>
<i :class="icon" />
<div>{{ icon }}</div>
</li>
</ul>
</el-dialog>
</div>
</template>
<script>
import iconList from '@/utils/generator/icon.json'
const originList = iconList.map(name => `el-icon-${name}`)
export default {
inheritAttrs: false,
props: ['current'],
data() {
return {
iconList: originList,
active: null,
key: ''
}
},
watch: {
key(val) {
if (val) {
this.iconList = originList.filter(name => name.indexOf(val) > -1)
} else {
this.iconList = originList
}
}
},
methods: {
onOpen() {
this.active = this.current
this.key = ''
},
onClose() {},
onSelect(icon) {
this.active = icon
this.$emit('select', icon)
this.$emit('update:visible', false)
}
}
}
</script>
<style lang="scss" scoped>
.icon-ul {
margin: 0;
padding: 0;
font-size: 0;
li {
list-style-type: none;
text-align: center;
font-size: 14px;
display: inline-block;
width: 16.66%;
box-sizing: border-box;
height: 108px;
padding: 15px 6px 6px 6px;
cursor: pointer;
overflow: hidden;
&:hover {
background: #f2f2f2;
}
&.active-item{
background: #e1f3fb;
color: #7a6df0
}
> i {
font-size: 30px;
line-height: 50px;
}
}
}
.icon-dialog {
::v-deep .el-dialog {
border-radius: 8px;
margin-bottom: 0;
margin-top: 4vh !important;
display: flex;
flex-direction: column;
max-height: 92vh;
overflow: hidden;
box-sizing: border-box;
.el-dialog__header {
padding-top: 14px;
}
.el-dialog__body {
margin: 0 20px 20px 20px;
padding: 0;
overflow: auto;
}
}
}
</style>
@@ -0,0 +1,944 @@
<template>
<div class="right-board">
<el-tabs v-model="currentTab" class="center-tabs">
<el-tab-pane label="组件属性" name="field" />
<el-tab-pane label="表单属性" name="form" />
</el-tabs>
<div class="field-box">
<a class="document-link" target="_blank" :href="documentLink" title="查看组件文档">
<i class="el-icon-link" />
</a>
<el-scrollbar class="right-scrollbar">
<!-- 组件属性 -->
<el-form v-show="currentTab==='field' && showField" size="small" label-width="90px">
<el-form-item v-if="activeData.changeTag" label="组件类型">
<el-select
v-model="activeData.tagIcon"
placeholder="请选择组件类型"
:style="{width: '100%'}"
@change="tagChange"
>
<el-option-group v-for="group in tagList" :key="group.label" :label="group.label">
<el-option
v-for="item in group.options"
:key="item.label"
:label="item.label"
:value="item.tagIcon"
>
<svg-icon class="node-icon" :icon-class="item.tagIcon" />
<span> {{ item.label }}</span>
</el-option>
</el-option-group>
</el-select>
</el-form-item>
<el-form-item v-if="activeData.vModel!==undefined" label="字段名">
<el-input v-model="activeData.vModel" placeholder="请输入字段名(v-model)" />
</el-form-item>
<el-form-item v-if="activeData.componentName!==undefined" label="组件名">
{{ activeData.componentName }}
</el-form-item>
<el-form-item v-if="activeData.label!==undefined" label="标题">
<el-input v-model="activeData.label" placeholder="请输入标题" />
</el-form-item>
<el-form-item v-if="activeData.placeholder!==undefined" label="占位提示">
<el-input v-model="activeData.placeholder" placeholder="请输入占位提示" />
</el-form-item>
<el-form-item v-if="activeData['start-placeholder']!==undefined" label="开始占位">
<el-input v-model="activeData['start-placeholder']" placeholder="请输入占位提示" />
</el-form-item>
<el-form-item v-if="activeData['end-placeholder']!==undefined" label="结束占位">
<el-input v-model="activeData['end-placeholder']" placeholder="请输入占位提示" />
</el-form-item>
<el-form-item v-if="activeData.span!==undefined" label="表单栅格">
<el-slider v-model="activeData.span" :max="24" :min="1" :marks="{12:''}" @change="spanChange" />
</el-form-item>
<el-form-item v-if="activeData.layout==='rowFormItem'" label="栅格间隔">
<el-input-number v-model="activeData.gutter" :min="0" placeholder="栅格间隔" />
</el-form-item>
<el-form-item v-if="activeData.layout==='rowFormItem'" label="布局模式">
<el-radio-group v-model="activeData.type">
<el-radio-button label="default" />
<el-radio-button label="flex" />
</el-radio-group>
</el-form-item>
<el-form-item v-if="activeData.justify!==undefined&&activeData.type==='flex'" label="水平排列">
<el-select v-model="activeData.justify" placeholder="请选择水平排列" :style="{width: '100%'}">
<el-option
v-for="(item, index) in justifyOptions"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="activeData.align!==undefined&&activeData.type==='flex'" label="垂直排列">
<el-radio-group v-model="activeData.align">
<el-radio-button label="top" />
<el-radio-button label="middle" />
<el-radio-button label="bottom" />
</el-radio-group>
</el-form-item>
<el-form-item v-if="activeData.labelWidth!==undefined" label="标签宽度">
<el-input v-model.number="activeData.labelWidth" type="number" placeholder="请输入标签宽度" />
</el-form-item>
<el-form-item v-if="activeData.style&&activeData.style.width!==undefined" label="组件宽度">
<el-input v-model="activeData.style.width" placeholder="请输入组件宽度" clearable />
</el-form-item>
<el-form-item v-if="activeData.vModel!==undefined" label="默认值">
<el-input
:value="setDefaultValue(activeData.defaultValue)"
placeholder="请输入默认值"
@input="onDefaultValueInput"
/>
</el-form-item>
<el-form-item v-if="activeData.tag==='el-checkbox-group'" label="至少应选">
<el-input-number
:value="activeData.min"
:min="0"
placeholder="至少应选"
@input="$set(activeData, 'min', $event?$event:undefined)"
/>
</el-form-item>
<el-form-item v-if="activeData.tag==='el-checkbox-group'" label="最多可选">
<el-input-number
:value="activeData.max"
:min="0"
placeholder="最多可选"
@input="$set(activeData, 'max', $event?$event:undefined)"
/>
</el-form-item>
<el-form-item v-if="activeData.prepend!==undefined" label="前缀">
<el-input v-model="activeData.prepend" placeholder="请输入前缀" />
</el-form-item>
<el-form-item v-if="activeData.append!==undefined" label="后缀">
<el-input v-model="activeData.append" placeholder="请输入后缀" />
</el-form-item>
<el-form-item v-if="activeData['prefix-icon']!==undefined" label="前图标">
<el-input v-model="activeData['prefix-icon']" placeholder="请输入前图标名称">
<el-button slot="append" icon="el-icon-thumb" @click="openIconsDialog('prefix-icon')">
选择
</el-button>
</el-input>
</el-form-item>
<el-form-item v-if="activeData['suffix-icon'] !== undefined" label="后图标">
<el-input v-model="activeData['suffix-icon']" placeholder="请输入后图标名称">
<el-button slot="append" icon="el-icon-thumb" @click="openIconsDialog('suffix-icon')">
选择
</el-button>
</el-input>
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-cascader'" label="选项分隔符">
<el-input v-model="activeData.separator" placeholder="请输入选项分隔符" />
</el-form-item>
<el-form-item v-if="activeData.autosize !== undefined" label="最小行数">
<el-input-number v-model="activeData.autosize.minRows" :min="1" placeholder="最小行数" />
</el-form-item>
<el-form-item v-if="activeData.autosize !== undefined" label="最大行数">
<el-input-number v-model="activeData.autosize.maxRows" :min="1" placeholder="最大行数" />
</el-form-item>
<el-form-item v-if="activeData.min !== undefined" label="最小值">
<el-input-number v-model="activeData.min" placeholder="最小值" />
</el-form-item>
<el-form-item v-if="activeData.max !== undefined" label="最大值">
<el-input-number v-model="activeData.max" placeholder="最大值" />
</el-form-item>
<el-form-item v-if="activeData.step !== undefined" label="步长">
<el-input-number v-model="activeData.step" placeholder="步数" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-input-number'" label="精度">
<el-input-number v-model="activeData.precision" :min="0" placeholder="精度" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-input-number'" label="按钮位置">
<el-radio-group v-model="activeData['controls-position']">
<el-radio-button label="">
默认
</el-radio-button>
<el-radio-button label="right">
右侧
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="activeData.maxlength !== undefined" label="最多输入">
<el-input v-model="activeData.maxlength" placeholder="请输入字符长度">
<template slot="append">
个字符
</template>
</el-input>
</el-form-item>
<el-form-item v-if="activeData['active-text'] !== undefined" label="开启提示">
<el-input v-model="activeData['active-text']" placeholder="请输入开启提示" />
</el-form-item>
<el-form-item v-if="activeData['inactive-text'] !== undefined" label="关闭提示">
<el-input v-model="activeData['inactive-text']" placeholder="请输入关闭提示" />
</el-form-item>
<el-form-item v-if="activeData['active-value'] !== undefined" label="开启值">
<el-input
:value="setDefaultValue(activeData['active-value'])"
placeholder="请输入开启值"
@input="onSwitchValueInput($event, 'active-value')"
/>
</el-form-item>
<el-form-item v-if="activeData['inactive-value'] !== undefined" label="关闭值">
<el-input
:value="setDefaultValue(activeData['inactive-value'])"
placeholder="请输入关闭值"
@input="onSwitchValueInput($event, 'inactive-value')"
/>
</el-form-item>
<el-form-item
v-if="activeData.type !== undefined && 'el-date-picker' === activeData.tag"
label="时间类型"
>
<el-select
v-model="activeData.type"
placeholder="请选择时间类型"
:style="{ width: '100%' }"
@change="dateTypeChange"
>
<el-option
v-for="(item, index) in dateOptions"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="activeData.name !== undefined" label="文件字段名">
<el-input v-model="activeData.name" placeholder="请输入上传文件字段名" />
</el-form-item>
<el-form-item v-if="activeData.accept !== undefined" label="文件类型">
<el-select
v-model="activeData.accept"
placeholder="请选择文件类型"
:style="{ width: '100%' }"
clearable
>
<el-option label="图片" value="image/*" />
<el-option label="视频" value="video/*" />
<el-option label="音频" value="audio/*" />
<el-option label="excel" value=".xls,.xlsx" />
<el-option label="word" value=".doc,.docx" />
<el-option label="pdf" value=".pdf" />
<el-option label="txt" value=".txt" />
</el-select>
</el-form-item>
<el-form-item v-if="activeData.fileSize !== undefined" label="文件大小">
<el-input v-model.number="activeData.fileSize" placeholder="请输入文件大小">
<el-select slot="append" v-model="activeData.sizeUnit" :style="{ width: '66px' }">
<el-option label="KB" value="KB" />
<el-option label="MB" value="MB" />
<el-option label="GB" value="GB" />
</el-select>
</el-input>
</el-form-item>
<el-form-item v-if="activeData.action !== undefined" label="上传地址">
<el-input v-model="activeData.action" placeholder="请输入上传地址" clearable />
</el-form-item>
<el-form-item v-if="activeData['list-type'] !== undefined" label="列表类型">
<el-radio-group v-model="activeData['list-type']" size="small">
<el-radio-button label="text">
text
</el-radio-button>
<el-radio-button label="picture">
picture
</el-radio-button>
<el-radio-button label="picture-card">
picture-card
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="activeData.buttonText !== undefined"
v-show="'picture-card' !== activeData['list-type']"
label="按钮文字"
>
<el-input v-model="activeData.buttonText" placeholder="请输入按钮文字" />
</el-form-item>
<el-form-item v-if="activeData['range-separator'] !== undefined" label="分隔符">
<el-input v-model="activeData['range-separator']" placeholder="请输入分隔符" />
</el-form-item>
<el-form-item v-if="activeData['picker-options'] !== undefined" label="时间段">
<el-input
v-model="activeData['picker-options'].selectableRange"
placeholder="请输入时间段"
/>
</el-form-item>
<el-form-item v-if="activeData.format !== undefined" label="时间格式">
<el-input
:value="activeData.format"
placeholder="请输入时间格式"
@input="setTimeValue($event)"
/>
</el-form-item>
<template v-if="['el-checkbox-group', 'el-radio-group', 'el-select'].indexOf(activeData.tag) > -1">
<el-divider>选项</el-divider>
<draggable
:list="activeData.options"
:animation="340"
group="selectItem"
handle=".option-drag"
>
<div v-for="(item, index) in activeData.options" :key="index" class="select-item">
<div class="select-line-icon option-drag">
<i class="el-icon-s-operation" />
</div>
<el-input v-model="item.label" placeholder="选项名" size="small" />
<el-input
placeholder="选项值"
size="small"
:value="item.value"
@input="setOptionValue(item, $event)"
/>
<div class="close-btn select-line-icon" @click="activeData.options.splice(index, 1)">
<i class="el-icon-remove-outline" />
</div>
</div>
</draggable>
<div style="margin-left: 20px;">
<el-button
style="padding-bottom: 0"
icon="el-icon-circle-plus-outline"
type="text"
@click="addSelectItem"
>
添加选项
</el-button>
</div>
<el-divider />
</template>
<template v-if="['el-cascader'].indexOf(activeData.tag) > -1">
<el-divider>选项</el-divider>
<el-form-item label="数据类型">
<el-radio-group v-model="activeData.dataType" size="small">
<el-radio-button label="dynamic">
动态数据
</el-radio-button>
<el-radio-button label="static">
静态数据
</el-radio-button>
</el-radio-group>
</el-form-item>
<template v-if="activeData.dataType === 'dynamic'">
<el-form-item label="标签键名">
<el-input v-model="activeData.labelKey" placeholder="请输入标签键名" />
</el-form-item>
<el-form-item label="值键名">
<el-input v-model="activeData.valueKey" placeholder="请输入值键名" />
</el-form-item>
<el-form-item label="子级键名">
<el-input v-model="activeData.childrenKey" placeholder="请输入子级键名" />
</el-form-item>
</template>
<el-tree
v-if="activeData.dataType === 'static'"
draggable
:data="activeData.options"
node-key="id"
:expand-on-click-node="false"
:render-content="renderContent"
/>
<div v-if="activeData.dataType === 'static'" style="margin-left: 20px">
<el-button
style="padding-bottom: 0"
icon="el-icon-circle-plus-outline"
type="text"
@click="addTreeItem"
>
添加父级
</el-button>
</div>
<el-divider />
</template>
<el-form-item v-if="activeData.optionType !== undefined" label="选项样式">
<el-radio-group v-model="activeData.optionType">
<el-radio-button label="default">
默认
</el-radio-button>
<el-radio-button label="button">
按钮
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="activeData['active-color'] !== undefined" label="开启颜色">
<el-color-picker v-model="activeData['active-color']" />
</el-form-item>
<el-form-item v-if="activeData['inactive-color'] !== undefined" label="关闭颜色">
<el-color-picker v-model="activeData['inactive-color']" />
</el-form-item>
<el-form-item v-if="activeData['allow-half'] !== undefined" label="允许半选">
<el-switch v-model="activeData['allow-half']" />
</el-form-item>
<el-form-item v-if="activeData['show-text'] !== undefined" label="辅助文字">
<el-switch v-model="activeData['show-text']" @change="rateTextChange" />
</el-form-item>
<el-form-item v-if="activeData['show-score'] !== undefined" label="显示分数">
<el-switch v-model="activeData['show-score']" @change="rateScoreChange" />
</el-form-item>
<el-form-item v-if="activeData['show-stops'] !== undefined" label="显示间断点">
<el-switch v-model="activeData['show-stops']" />
</el-form-item>
<el-form-item v-if="activeData.range !== undefined" label="范围选择">
<el-switch v-model="activeData.range" @change="rangeChange" />
</el-form-item>
<el-form-item
v-if="activeData.border !== undefined && activeData.optionType === 'default'"
label="是否带边框"
>
<el-switch v-model="activeData.border" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-color-picker'" label="颜色格式">
<el-select
v-model="activeData['color-format']"
placeholder="请选择颜色格式"
:style="{ width: '100%' }"
@change="colorFormatChange"
>
<el-option
v-for="(item, index) in colorFormatOptions"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="activeData.size !== undefined &&
(activeData.optionType === 'button' ||
activeData.border ||
activeData.tag === 'el-color-picker')"
label="选项尺寸"
>
<el-radio-group v-model="activeData.size">
<el-radio-button label="medium">
中等
</el-radio-button>
<el-radio-button label="small">
较小
</el-radio-button>
<el-radio-button label="mini">
迷你
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="activeData['show-word-limit'] !== undefined" label="输入统计">
<el-switch v-model="activeData['show-word-limit']" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-input-number'" label="严格步数">
<el-switch v-model="activeData['step-strictly']" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-cascader'" label="是否多选">
<el-switch v-model="activeData.props.props.multiple" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-cascader'" label="展示全路径">
<el-switch v-model="activeData['show-all-levels']" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-cascader'" label="可否筛选">
<el-switch v-model="activeData.filterable" />
</el-form-item>
<el-form-item v-if="activeData.clearable !== undefined" label="能否清空">
<el-switch v-model="activeData.clearable" />
</el-form-item>
<el-form-item v-if="activeData.showTip !== undefined" label="显示提示">
<el-switch v-model="activeData.showTip" />
</el-form-item>
<el-form-item v-if="activeData.multiple !== undefined" label="多选文件">
<el-switch v-model="activeData.multiple" />
</el-form-item>
<el-form-item v-if="activeData['auto-upload'] !== undefined" label="自动上传">
<el-switch v-model="activeData['auto-upload']" />
</el-form-item>
<el-form-item v-if="activeData.readonly !== undefined" label="是否只读">
<el-switch v-model="activeData.readonly" />
</el-form-item>
<el-form-item v-if="activeData.disabled !== undefined" label="是否禁用">
<el-switch v-model="activeData.disabled" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-select'" label="是否可搜索">
<el-switch v-model="activeData.filterable" />
</el-form-item>
<el-form-item v-if="activeData.tag === 'el-select'" label="是否多选">
<el-switch v-model="activeData.multiple" @change="multipleChange" />
</el-form-item>
<el-form-item v-if="activeData.required !== undefined" label="是否必填">
<el-switch v-model="activeData.required" />
</el-form-item>
<template v-if="activeData.layoutTree">
<el-divider>布局结构树</el-divider>
<el-tree
:data="[activeData]"
:props="layoutTreeProps"
node-key="renderKey"
default-expand-all
draggable
>
<span slot-scope="{ node, data }">
<span class="node-label">
<svg-icon class="node-icon" :icon-class="data.tagIcon" />
{{ node.label }}
</span>
</span>
</el-tree>
</template>
<template v-if="activeData.layout === 'colFormItem' && activeData.tag !== 'el-button'">
<el-divider>正则校验</el-divider>
<div
v-for="(item, index) in activeData.regList"
:key="index"
class="reg-item"
>
<span class="close-btn" @click="activeData.regList.splice(index, 1)">
<i class="el-icon-close" />
</span>
<el-form-item label="表达式">
<el-input v-model="item.pattern" placeholder="请输入正则" />
</el-form-item>
<el-form-item label="错误提示" style="margin-bottom:0">
<el-input v-model="item.message" placeholder="请输入错误提示" />
</el-form-item>
</div>
<div style="margin-left: 20px">
<el-button icon="el-icon-circle-plus-outline" type="text" @click="addReg">
添加规则
</el-button>
</div>
</template>
</el-form>
<!-- 表单属性 -->
<el-form v-show="currentTab === 'form'" size="small" label-width="90px">
<el-form-item label="表单名">
<el-input v-model="formConf.formRef" placeholder="请输入表单名(ref)" />
</el-form-item>
<el-form-item label="表单模型">
<el-input v-model="formConf.formModel" placeholder="请输入数据模型" />
</el-form-item>
<el-form-item label="校验模型">
<el-input v-model="formConf.formRules" placeholder="请输入校验模型" />
</el-form-item>
<el-form-item label="表单尺寸">
<el-radio-group v-model="formConf.size">
<el-radio-button label="medium">
中等
</el-radio-button>
<el-radio-button label="small">
较小
</el-radio-button>
<el-radio-button label="mini">
迷你
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="标签对齐">
<el-radio-group v-model="formConf.labelPosition">
<el-radio-button label="left">
左对齐
</el-radio-button>
<el-radio-button label="right">
右对齐
</el-radio-button>
<el-radio-button label="top">
顶部对齐
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="标签宽度">
<el-input-number v-model="formConf.labelWidth" placeholder="标签宽度" />
</el-form-item>
<el-form-item label="栅格间隔">
<el-input-number v-model="formConf.gutter" :min="0" placeholder="栅格间隔" />
</el-form-item>
<el-form-item label="禁用表单">
<el-switch v-model="formConf.disabled" />
</el-form-item>
<el-form-item label="表单按钮">
<el-switch v-model="formConf.formBtns" />
</el-form-item>
<el-form-item label="显示未选中组件边框">
<el-switch v-model="formConf.unFocusedComponentBorder" />
</el-form-item>
</el-form>
</el-scrollbar>
</div>
<treeNode-dialog :visible.sync="dialogVisible" title="添加选项" @commit="addNode" />
<icons-dialog :visible.sync="iconsVisible" :current="activeData[currentIconModel]" @select="setIcon" />
</div>
</template>
<script>
import draggable from 'vuedraggable'
import TreeNodeDialog from './TreeNodeDialog'
import { isNumberStr } from '@/utils/index'
import IconsDialog from './IconsDialog'
import {
inputComponents,
selectComponents
} from '@/utils/generator/config'
const dateTimeFormat = {
date: 'yyyy-MM-dd',
week: 'yyyy 第 WW 周',
month: 'yyyy-MM',
year: 'yyyy',
datetime: 'yyyy-MM-dd HH:mm:ss',
daterange: 'yyyy-MM-dd',
monthrange: 'yyyy-MM',
datetimerange: 'yyyy-MM-dd HH:mm:ss'
}
export default {
components: {
draggable,
TreeNodeDialog,
IconsDialog
},
props: ['showField', 'activeData', 'formConf'],
data() {
return {
currentTab: 'field',
currentNode: null,
dialogVisible: false,
iconsVisible: false,
currentIconModel: null,
dateTypeOptions: [
{
label: '日(date)',
value: 'date'
},
{
label: '周(week)',
value: 'week'
},
{
label: '月(month)',
value: 'month'
},
{
label: '年(year)',
value: 'year'
},
{
label: '日期时间(datetime)',
value: 'datetime'
}
],
dateRangeTypeOptions: [
{
label: '日期范围(daterange)',
value: 'daterange'
},
{
label: '月范围(monthrange)',
value: 'monthrange'
},
{
label: '日期时间范围(datetimerange)',
value: 'datetimerange'
}
],
colorFormatOptions: [
{
label: 'hex',
value: 'hex'
},
{
label: 'rgb',
value: 'rgb'
},
{
label: 'rgba',
value: 'rgba'
},
{
label: 'hsv',
value: 'hsv'
},
{
label: 'hsl',
value: 'hsl'
}
],
justifyOptions: [
{
label: 'start',
value: 'start'
},
{
label: 'end',
value: 'end'
},
{
label: 'center',
value: 'center'
},
{
label: 'space-around',
value: 'space-around'
},
{
label: 'space-between',
value: 'space-between'
}
],
layoutTreeProps: {
label(data) {
return data.componentName || `${data.label}: ${data.vModel}`
}
}
}
},
computed: {
documentLink() {
return (
this.activeData.document
|| 'https://element.eleme.cn/#/zh-CN/component/installation'
)
},
dateOptions() {
if (
this.activeData.type !== undefined
&& this.activeData.tag === 'el-date-picker'
) {
if (this.activeData['start-placeholder'] === undefined) {
return this.dateTypeOptions
}
return this.dateRangeTypeOptions
}
return []
},
tagList() {
return [
{
label: '输入型组件',
options: inputComponents
},
{
label: '选择型组件',
options: selectComponents
}
]
}
},
methods: {
addReg() {
this.activeData.regList.push({
pattern: '',
message: ''
})
},
addSelectItem() {
this.activeData.options.push({
label: '',
value: ''
})
},
addTreeItem() {
++this.idGlobal
this.dialogVisible = true
this.currentNode = this.activeData.options
},
renderContent(h, { node, data }) {
return (
<div class="custom-tree-node">
<span>{node.label}</span>
<span class="node-operation">
<i on-click={() => this.append(data)}
class="el-icon-plus"
title="添加"
></i>
<i on-click={() => this.remove(node, data)}
class="el-icon-delete"
title="删除"
></i>
</span>
</div>
)
},
append(data) {
if (!data.children) {
this.$set(data, 'children', [])
}
this.dialogVisible = true
this.currentNode = data.children
},
remove(node, data) {
const { parent } = node
const children = parent.data.children || parent.data
const index = children.findIndex(d => d.id === data.id)
children.splice(index, 1)
},
addNode(data) {
this.currentNode.push(data)
},
setOptionValue(item, val) {
item.value = isNumberStr(val) ? +val : val
},
setDefaultValue(val) {
if (Array.isArray(val)) {
return val.join(',')
}
if (['string', 'number'].indexOf(val) > -1) {
return val
}
if (typeof val === 'boolean') {
return `${val}`
}
return val
},
onDefaultValueInput(str) {
if (Array.isArray(this.activeData.defaultValue)) {
// 数组
this.$set(
this.activeData,
'defaultValue',
str.split(',').map(val => (isNumberStr(val) ? +val : val))
)
} else if (['true', 'false'].indexOf(str) > -1) {
// 布尔
this.$set(this.activeData, 'defaultValue', JSON.parse(str))
} else {
// 字符串和数字
this.$set(
this.activeData,
'defaultValue',
isNumberStr(str) ? +str : str
)
}
},
onSwitchValueInput(val, name) {
if (['true', 'false'].indexOf(val) > -1) {
this.$set(this.activeData, name, JSON.parse(val))
} else {
this.$set(this.activeData, name, isNumberStr(val) ? +val : val)
}
},
setTimeValue(val, type) {
const valueFormat = type === 'week' ? dateTimeFormat.date : val
this.$set(this.activeData, 'defaultValue', null)
this.$set(this.activeData, 'value-format', valueFormat)
this.$set(this.activeData, 'format', val)
},
spanChange(val) {
this.formConf.span = val
},
multipleChange(val) {
this.$set(this.activeData, 'defaultValue', val ? [] : '')
},
dateTypeChange(val) {
this.setTimeValue(dateTimeFormat[val], val)
},
rangeChange(val) {
this.$set(
this.activeData,
'defaultValue',
val ? [this.activeData.min, this.activeData.max] : this.activeData.min
)
},
rateTextChange(val) {
if (val) this.activeData['show-score'] = false
},
rateScoreChange(val) {
if (val) this.activeData['show-text'] = false
},
colorFormatChange(val) {
this.activeData.defaultValue = null
this.activeData['show-alpha'] = val.indexOf('a') > -1
this.activeData.renderKey = +new Date() // 更新renderKey,重新渲染该组件
},
openIconsDialog(model) {
this.iconsVisible = true
this.currentIconModel = model
},
setIcon(val) {
this.activeData[this.currentIconModel] = val
},
tagChange(tagIcon) {
let target = inputComponents.find(item => item.tagIcon === tagIcon)
if (!target) target = selectComponents.find(item => item.tagIcon === tagIcon)
this.$emit('tag-change', target)
}
}
}
</script>
<style lang="scss" scoped>
.right-board {
width: 350px;
position: absolute;
right: 0;
top: 0;
padding-top: 3px;
.field-box {
position: relative;
height: calc(100vh - 42px);
box-sizing: border-box;
overflow: hidden;
}
.el-scrollbar {
height: 100%;
}
}
.select-item {
display: flex;
border: 1px dashed #fff;
box-sizing: border-box;
& .close-btn {
cursor: pointer;
color: #f56c6c;
}
& .el-input + .el-input {
margin-left: 4px;
}
}
.select-item + .select-item {
margin-top: 4px;
}
.select-item.sortable-chosen {
border: 1px dashed #00875A;
}
.select-line-icon {
line-height: 32px;
font-size: 22px;
padding: 0 4px;
color: #777;
}
.option-drag {
cursor: move;
}
.time-range {
.el-date-editor {
width: 227px;
}
::v-deep .el-icon-time {
display: none;
}
}
.document-link {
position: absolute;
display: block;
width: 26px;
height: 26px;
top: 0;
left: 0;
cursor: pointer;
background: #00875A;
z-index: 1;
border-radius: 0 0 6px 0;
text-align: center;
line-height: 26px;
color: #fff;
font-size: 18px;
}
.node-label{
font-size: 14px;
}
.node-icon{
color: #bebfc3;
}
</style>
@@ -0,0 +1,148 @@
<template>
<div>
<el-dialog
v-bind="$attrs"
:close-on-click-modal="false"
:modal-append-to-body="false"
v-on="$listeners"
@open="onOpen"
@close="onClose"
>
<el-row :gutter="0">
<el-form
ref="elForm"
:model="formData"
:rules="rules"
size="small"
label-width="100px"
>
<el-col :span="24">
<el-form-item
label="选项名"
prop="label"
>
<el-input
v-model="formData.label"
placeholder="请输入选项名"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item
label="选项值"
prop="value"
>
<el-input
v-model="formData.value"
placeholder="请输入选项值"
clearable
>
<el-select
slot="append"
v-model="dataType"
:style="{width: '100px'}"
>
<el-option
v-for="(item, index) in dataTypeOptions"
:key="index"
:label="item.label"
:value="item.value"
:disabled="item.disabled"
/>
</el-select>
</el-input>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer">
<el-button
type="primary"
@click="handleConfirm"
>
确定
</el-button>
<el-button @click="close">
取消
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { isNumberStr } from '@/utils/index'
export default {
components: {},
inheritAttrs: false,
props: [],
data() {
return {
id: 100,
formData: {
label: undefined,
value: undefined
},
rules: {
label: [
{
required: true,
message: '请输入选项名',
trigger: 'blur'
}
],
value: [
{
required: true,
message: '请输入选项值',
trigger: 'blur'
}
]
},
dataType: 'string',
dataTypeOptions: [
{
label: '字符串',
value: 'string'
},
{
label: '数字',
value: 'number'
}
]
}
},
computed: {},
watch: {
'formData.value': function (val) {
this.dataType = isNumberStr(val) ? 'number' : 'string'
}
},
created() {},
mounted() {},
methods: {
onOpen() {
this.formData = {
label: undefined,
value: undefined
}
},
onClose() {},
close() {
this.$emit('update:visible', false)
},
handleConfirm() {
this.$refs.elForm.validate(valid => {
if (!valid) return
if (this.dataType === 'number') {
this.formData.value = parseFloat(this.formData.value)
}
this.formData.id = this.id++
this.$emit('commit', this.formData)
this.close()
})
}
}
}
</script>
+775
View File
@@ -0,0 +1,775 @@
<template>
<div class="container">
<div class="left-board">
<div class="logo-wrapper">
<div class="logo">
<img :src="logo" alt="logo"> Form Generator
</div>
</div>
<el-scrollbar class="left-scrollbar">
<div class="components-list">
<div class="components-title">
<svg-icon icon-class="component" />输入型组件
</div>
<draggable
class="components-draggable"
:list="inputComponents"
:group="{ name: 'componentsGroup', pull: 'clone', put: false }"
:clone="cloneComponent"
draggable=".components-item"
:sort="false"
@end="onEnd"
>
<div
v-for="(element, index) in inputComponents" :key="index" class="components-item"
@click="addComponent(element)"
>
<div class="components-body">
<svg-icon :icon-class="element.tagIcon" />
{{ element.label }}
</div>
</div>
</draggable>
<div class="components-title">
<svg-icon icon-class="component" />选择型组件
</div>
<draggable
class="components-draggable"
:list="selectComponents"
:group="{ name: 'componentsGroup', pull: 'clone', put: false }"
:clone="cloneComponent"
draggable=".components-item"
:sort="false"
@end="onEnd"
>
<div
v-for="(element, index) in selectComponents"
:key="index"
class="components-item"
@click="addComponent(element)"
>
<div class="components-body">
<svg-icon :icon-class="element.tagIcon" />
{{ element.label }}
</div>
</div>
</draggable>
<div class="components-title">
<svg-icon icon-class="component" /> 布局型组件
</div>
<draggable
class="components-draggable" :list="layoutComponents"
:group="{ name: 'componentsGroup', pull: 'clone', put: false }" :clone="cloneComponent"
draggable=".components-item" :sort="false" @end="onEnd"
>
<div
v-for="(element, index) in layoutComponents" :key="index" class="components-item"
@click="addComponent(element)"
>
<div class="components-body">
<svg-icon :icon-class="element.tagIcon" />
{{ element.label }}
</div>
</div>
</draggable>
</div>
</el-scrollbar>
</div>
<div class="center-board">
<div class="action-bar">
<el-button icon="el-icon-download" type="text" @click="download">
导出vue文件
</el-button>
<el-button class="copy-btn-main" icon="el-icon-document-copy" type="text" @click="copy">
复制代码
</el-button>
<el-button class="delete-btn" icon="el-icon-delete" type="text" @click="empty">
清空
</el-button>
</div>
<el-scrollbar class="center-scrollbar">
<el-row class="center-board-row" :gutter="formConf.gutter">
<el-form
:size="formConf.size"
:label-position="formConf.labelPosition"
:disabled="formConf.disabled"
:label-width="formConf.labelWidth + 'px'"
>
<draggable class="drawing-board" :list="drawingList" :animation="340" group="componentsGroup">
<draggable-item
v-for="(element, index) in drawingList"
:key="element.renderKey"
:drawing-list="drawingList"
:element="element"
:index="index"
:active-id="activeId"
:form-conf="formConf"
@activeItem="activeFormItem"
@copyItem="drawingItemCopy"
@deleteItem="drawingItemDelete"
/>
</draggable>
<div v-show="!drawingList.length" class="empty-info">
从左侧拖入或点选组件进行表单设计
</div>
</el-form>
</el-row>
</el-scrollbar>
</div>
<right-panel
:active-data="activeData"
:form-conf="formConf"
:show-field="!!drawingList.length"
@tag-change="tagChange"
/>
<code-type-dialog
:visible.sync="dialogVisible"
title="选择生成类型"
:show-file-name="showFileName"
@confirm="generate"
/>
<input id="copyNode" type="hidden">
</div>
</template>
<script>
import draggable from 'vuedraggable'
import beautifier from 'js-beautify'
import ClipboardJS from 'clipboard'
import render from '@/utils/generator/render'
import RightPanel from './RightPanel'
import { inputComponents, selectComponents, layoutComponents, formConf } from '@/utils/generator/config'
import { beautifierConf, titleCase } from '@/utils/index'
import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html'
import { makeUpJs } from '@/utils/generator/js'
import { makeUpCss } from '@/utils/generator/css'
import { drawingDefaultValue, initDrawingDefaultValue, cleanDrawingDefaultValue } from '@/utils/generator/drawingDefault'
import logo from '@/assets/logo/logo.png'
import CodeTypeDialog from './CodeTypeDialog'
import DraggableItem from './DraggableItem'
let oldActiveId
let tempActiveData
let clipboard = null
export default {
components: {
draggable,
render,
RightPanel,
CodeTypeDialog,
DraggableItem
},
data() {
return {
logo,
idGlobal: 100,
formConf,
inputComponents,
selectComponents,
layoutComponents,
labelWidth: 100,
drawingList: drawingDefaultValue,
drawingData: {},
activeId: drawingDefaultValue[0].formId,
drawerVisible: false,
formData: {},
dialogVisible: false,
generateConf: null,
showFileName: false,
activeData: drawingDefaultValue[0]
}
},
beforeCreate() {
initDrawingDefaultValue()
},
created() {
// 防止 firefox 下 拖拽 会新打卡一个选项卡
document.body.ondrop = event => {
event.preventDefault()
event.stopPropagation()
}
},
watch: {
'activeData.label': function (val, oldVal) {
if (
this.activeData.placeholder === undefined
|| !this.activeData.tag
|| oldActiveId !== this.activeId
) {
return
}
this.activeData.placeholder = this.activeData.placeholder.replace(oldVal, '') + val
},
activeId: {
handler(val) {
oldActiveId = val
},
immediate: true
}
},
mounted() {
clipboard = new ClipboardJS('#copyNode', {
text: () => {
const codeStr = this.generateCode()
this.$notify({
title: '成功',
message: '代码已复制到剪切板,可粘贴。',
type: 'success'
})
return codeStr
}
})
clipboard.on('error', () => {
this.$message.error('代码复制失败')
})
},
beforeDestroy() {
clipboard.destroy()
},
methods: {
activeFormItem(element) {
this.activeData = element
this.activeId = element.formId
},
onEnd(obj) {
if (obj.from !== obj.to) {
this.activeData = tempActiveData
this.activeId = this.idGlobal
}
},
addComponent(item) {
const clone = this.cloneComponent(item)
this.drawingList.push(clone)
this.activeFormItem(clone)
},
cloneComponent(origin) {
const clone = JSON.parse(JSON.stringify(origin))
clone.formId = ++this.idGlobal
clone.span = formConf.span
clone.renderKey = +new Date() // 改变renderKey后可以实现强制更新组件
if (!clone.layout) clone.layout = 'colFormItem'
if (clone.layout === 'colFormItem') {
clone.vModel = `field${this.idGlobal}`
clone.placeholder !== undefined && (clone.placeholder += clone.label)
tempActiveData = clone
} else if (clone.layout === 'rowFormItem') {
delete clone.label
clone.componentName = `row${this.idGlobal}`
clone.gutter = this.formConf.gutter
tempActiveData = clone
}
return tempActiveData
},
AssembleFormData() {
this.formData = {
fields: JSON.parse(JSON.stringify(this.drawingList)),
...this.formConf
}
},
generate(data) {
const func = this[`exec${titleCase(this.operationType)}`]
this.generateConf = data
func && func(data)
},
execRun() {
this.AssembleFormData()
this.drawerVisible = true
},
execDownload(data) {
const codeStr = this.generateCode()
const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' })
this.$download.saveAs(blob, data.fileName)
},
execCopy() {
document.getElementById('copyNode').click()
},
empty() {
this.$confirm('确定要清空所有组件吗?', '提示', { type: 'warning' }).then(
() => {
this.drawingList = []
cleanDrawingDefaultValue()
}
)
},
drawingItemCopy(item, parent) {
let clone = JSON.parse(JSON.stringify(item))
clone = this.createIdAndKey(clone)
parent.push(clone)
this.activeFormItem(clone)
},
createIdAndKey(item) {
item.formId = ++this.idGlobal
item.renderKey = +new Date()
if (item.layout === 'colFormItem') {
item.vModel = `field${this.idGlobal}`
} else if (item.layout === 'rowFormItem') {
item.componentName = `row${this.idGlobal}`
}
if (Array.isArray(item.children)) {
item.children = item.children.map(childItem => this.createIdAndKey(childItem))
}
return item
},
drawingItemDelete(index, parent) {
parent.splice(index, 1)
this.$nextTick(() => {
const len = this.drawingList.length
if (len) {
this.activeFormItem(this.drawingList[len - 1])
}
})
},
generateCode() {
const { type } = this.generateConf
this.AssembleFormData()
const script = vueScript(makeUpJs(this.formData, type))
const html = vueTemplate(makeUpHtml(this.formData, type))
const css = cssStyle(makeUpCss(this.formData))
return beautifier.html(html + script + css, beautifierConf.html)
},
download() {
this.dialogVisible = true
this.showFileName = true
this.operationType = 'download'
},
run() {
this.dialogVisible = true
this.showFileName = false
this.operationType = 'run'
},
copy() {
this.dialogVisible = true
this.showFileName = false
this.operationType = 'copy'
},
tagChange(newTag) {
newTag = this.cloneComponent(newTag)
newTag.vModel = this.activeData.vModel
newTag.formId = this.activeId
newTag.span = this.activeData.span
delete this.activeData.tag
delete this.activeData.tagIcon
delete this.activeData.document
Object.keys(newTag).forEach(key => {
if (this.activeData[key] !== undefined
&& typeof this.activeData[key] === typeof newTag[key]) {
newTag[key] = this.activeData[key]
}
})
this.activeData = newTag
this.updateDrawingList(newTag, this.drawingList)
},
updateDrawingList(newTag, list) {
const index = list.findIndex(item => item.formId === this.activeId)
if (index > -1) {
list.splice(index, 1, newTag)
} else {
list.forEach(item => {
if (Array.isArray(item.children)) this.updateDrawingList(newTag, item.children)
})
}
}
}
}
</script>
<style lang='scss'>
.editor-tabs{
background: #121315;
.el-tabs__header{
margin: 0;
border-bottom-color: #121315;
.el-tabs__nav{
border-color: #121315;
}
}
.el-tabs__item{
height: 32px;
line-height: 32px;
color: #888a8e;
border-left: 1px solid #121315 !important;
background: #363636;
margin-right: 5px;
user-select: none;
}
.el-tabs__item.is-active{
background: #1e1e1e;
border-bottom-color: #1e1e1e!important;
color: #fff;
}
.el-icon-edit{
color: #f1fa8c;
}
.el-icon-document{
color: #a95812;
}
}
// home
.right-scrollbar {
.el-scrollbar__view {
padding: 12px 18px 15px 15px;
}
}
.left-scrollbar .el-scrollbar__wrap {
box-sizing: border-box;
overflow-x: hidden !important;
margin-bottom: 0 !important;
}
.center-tabs{
.el-tabs__header{
margin-bottom: 0!important;
}
.el-tabs__item{
width: 50%;
text-align: center;
}
.el-tabs__nav{
width: 100%;
}
}
.reg-item{
padding: 12px 6px;
background: #f8f8f8;
position: relative;
border-radius: 4px;
.close-btn{
position: absolute;
right: -6px;
top: -6px;
display: block;
width: 16px;
height: 16px;
line-height: 16px;
background: rgba(0, 0, 0, 0.2);
border-radius: 50%;
color: #fff;
text-align: center;
z-index: 1;
cursor: pointer;
font-size: 12px;
&:hover{
background: rgba(210, 23, 23, 0.5)
}
}
& + .reg-item{
margin-top: 18px;
}
}
.action-bar{
& .el-button+.el-button {
margin-left: 15px;
}
& i {
font-size: 20px;
vertical-align: middle;
position: relative;
top: -1px;
}
}
.custom-tree-node{
width: 100%;
font-size: 14px;
.node-operation{
float: right;
}
i[class*="el-icon"] + i[class*="el-icon"]{
margin-left: 6px;
}
.el-icon-plus{
color: #00875A;
}
.el-icon-delete{
color: #157a0c;
}
}
.left-scrollbar .el-scrollbar__view{
overflow-x: hidden;
}
.el-rate{
display: inline-block;
vertical-align: text-top;
}
.el-upload__tip{
line-height: 1.2;
}
$selectedColor: #f6f7ff;
$lighterBlue: #00875A;
.container {
position: relative;
width: 100%;
height: 100%;
}
.components-list {
padding: 8px;
box-sizing: border-box;
height: 100%;
.components-item {
display: inline-block;
width: 48%;
margin: 1%;
transition: transform 0ms !important;
}
}
.components-draggable{
padding-bottom: 20px;
}
.components-title{
font-size: 14px;
color: #222;
margin: 6px 2px;
.svg-icon{
color: #666;
font-size: 18px;
}
}
.components-body {
padding: 8px 10px;
background: $selectedColor;
font-size: 12px;
cursor: move;
border: 1px dashed $selectedColor;
border-radius: 3px;
.svg-icon{
color: #777;
font-size: 15px;
}
&:hover {
border: 1px dashed #787be8;
color: #787be8;
.svg-icon {
color: #787be8;
}
}
}
.left-board {
width: 260px;
position: absolute;
left: 0;
top: 0;
height: 100vh;
}
.left-scrollbar{
height: calc(100vh - 42px);
overflow: hidden;
}
.center-scrollbar {
height: calc(100vh - 42px);
overflow: hidden;
border-left: 1px solid #f1e8e8;
border-right: 1px solid #f1e8e8;
box-sizing: border-box;
}
.center-board {
height: 100vh;
width: auto;
margin: 0 350px 0 260px;
box-sizing: border-box;
}
.empty-info{
position: absolute;
top: 46%;
left: 0;
right: 0;
text-align: center;
font-size: 18px;
color: #ccb1ea;
letter-spacing: 4px;
}
.action-bar{
position: relative;
height: 42px;
text-align: right;
padding: 0 15px;
box-sizing: border-box;;
border: 1px solid #f1e8e8;
border-top: none;
border-left: none;
.delete-btn{
color: #F56C6C;
}
}
.logo-wrapper{
position: relative;
height: 42px;
background: #fff;
border-bottom: 1px solid #f1e8e8;
box-sizing: border-box;
}
.logo{
position: absolute;
left: 12px;
top: 6px;
line-height: 30px;
color: #00afff;
font-weight: 600;
font-size: 17px;
white-space: nowrap;
> img{
width: 30px;
height: 30px;
vertical-align: top;
}
.github{
display: inline-block;
vertical-align: sub;
margin-left: 15px;
> img{
height: 22px;
}
}
}
.center-board-row {
padding: 12px 12px 15px 12px;
box-sizing: border-box;
& > .el-form {
// 69 = 12+15+42
height: calc(100vh - 69px);
}
}
.drawing-board {
height: 100%;
position: relative;
.components-body {
padding: 0;
margin: 0;
font-size: 0;
}
.sortable-ghost {
position: relative;
display: block;
overflow: hidden;
&::before {
content: " ";
position: absolute;
left: 0;
right: 0;
top: 0;
height: 3px;
background: rgb(89, 89, 223);
z-index: 2;
}
}
.components-item.sortable-ghost {
width: 100%;
height: 60px;
background-color: $selectedColor;
}
.active-from-item {
& > .el-form-item{
background: $selectedColor;
border-radius: 6px;
}
& > .drawing-item-copy, & > .drawing-item-delete{
display: initial;
}
& > .component-name{
color: $lighterBlue;
}
}
.el-form-item{
margin-bottom: 15px;
}
}
.drawing-item{
position: relative;
cursor: move;
&.unfocus-bordered:not(.activeFromItem) > div:first-child {
border: 1px dashed #ccc;
}
.el-form-item{
padding: 12px 10px;
}
}
.drawing-row-item{
position: relative;
cursor: move;
box-sizing: border-box;
border: 1px dashed #ccc;
border-radius: 3px;
padding: 0 2px;
margin-bottom: 15px;
.drawing-row-item {
margin-bottom: 2px;
}
.el-col{
margin-top: 22px;
}
.el-form-item{
margin-bottom: 0;
}
.drag-wrapper{
min-height: 80px;
}
&.active-from-item{
border: 1px dashed $lighterBlue;
}
.component-name{
position: absolute;
top: 0;
left: 0;
font-size: 12px;
color: #bbb;
display: inline-block;
padding: 0 6px;
}
}
.drawing-item, .drawing-row-item{
&:hover {
& > .el-form-item{
background: $selectedColor;
border-radius: 6px;
}
& > .drawing-item-copy, & > .drawing-item-delete{
display: initial;
}
}
& > .drawing-item-copy, & > .drawing-item-delete{
display: none;
position: absolute;
top: -10px;
width: 22px;
height: 22px;
line-height: 22px;
text-align: center;
border-radius: 50%;
font-size: 12px;
border: 1px solid;
cursor: pointer;
z-index: 1;
}
& > .drawing-item-copy{
right: 56px;
border-color: $lighterBlue;
color: $lighterBlue;
background: #fff;
&:hover{
background: $lighterBlue;
color: #fff;
}
}
& > .drawing-item-delete{
right: 24px;
border-color: #F56C6C;
color: #F56C6C;
background: #fff;
&:hover{
background: #F56C6C;
color: #fff;
}
}
}
</style>
@@ -0,0 +1,60 @@
<template>
<el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
<el-row>
<el-col :span="12">
<el-form-item label="表名称" prop="tableName">
<el-input placeholder="请输入仓库名称" v-model="info.tableName" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="表描述" prop="tableComment">
<el-input placeholder="请输入" v-model="info.tableComment" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="实体类名称" prop="className">
<el-input placeholder="请输入" v-model="info.className" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="作者" prop="functionAuthor">
<el-input placeholder="请输入" v-model="info.functionAuthor" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="3" v-model="info.remark"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
props: {
info: {
type: Object,
default: null
}
},
data() {
return {
rules: {
tableName: [
{ required: true, message: "请输入表名称", trigger: "blur" }
],
tableComment: [
{ required: true, message: "请输入表描述", trigger: "blur" }
],
className: [
{ required: true, message: "请输入实体类名称", trigger: "blur" }
],
functionAuthor: [
{ required: true, message: "请输入作者", trigger: "blur" }
]
}
}
}
}
</script>
@@ -0,0 +1,45 @@
<template>
<!-- 创建表 -->
<el-dialog title="创建表" :visible.sync="visible" width="800px" top="5vh" append-to-body>
<span>创建表语句(支持多个建表语句):</span>
<el-input type="textarea" :rows="10" placeholder="请输入文本" v-model="content"></el-input>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleCreateTable">确 定</el-button>
<el-button @click="visible = false">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import { createTable } from "@/api/tool/gen"
export default {
data() {
return {
// 遮罩层
visible: false,
// 文本内容
content: ""
}
},
methods: {
// 显示弹框
show() {
this.visible = true
},
/** 创建按钮操作 */
handleCreateTable() {
if (this.content === "") {
this.$modal.msgError("请输入建表语句")
return
}
createTable({ sql: this.content, tplWebType: 'element-ui' }).then(res => {
this.$modal.msgSuccess(res.msg)
if (res.code === 200) {
this.visible = false
this.$emit("ok")
}
})
}
}
}
</script>
+230
View File
@@ -0,0 +1,230 @@
<template>
<el-card>
<el-tabs v-model="activeName">
<el-tab-pane label="基本信息" name="basic">
<basic-info-form ref="basicInfo" :info="info" />
</el-tab-pane>
<el-tab-pane label="字段信息" name="columnInfo">
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column label="字段列名" prop="columnName" min-width="10%" :show-overflow-tooltip="true" class-name="allowDrag"/>
<el-table-column label="字段描述" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.columnComment"></el-input>
</template>
</el-table-column>
<el-table-column
label="物理类型"
prop="columnType"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="Java类型" min-width="11%">
<template slot-scope="scope">
<el-select v-model="scope.row.javaType">
<el-option label="Long" value="Long" />
<el-option label="String" value="String" />
<el-option label="Integer" value="Integer" />
<el-option label="Double" value="Double" />
<el-option label="BigDecimal" value="BigDecimal" />
<el-option label="Date" value="Date" />
<el-option label="Boolean" value="Boolean" />
</el-select>
</template>
</el-table-column>
<el-table-column label="java属性" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.javaField"></el-input>
</template>
</el-table-column>
<el-table-column label="插入" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isInsert"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="编辑" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isEdit"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="列表" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isList"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isQuery"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询方式" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.queryType">
<el-option label="=" value="EQ" />
<el-option label="!=" value="NE" />
<el-option label=">" value="GT" />
<el-option label=">=" value="GTE" />
<el-option label="<" value="LT" />
<el-option label="<=" value="LTE" />
<el-option label="LIKE" value="LIKE" />
<el-option label="BETWEEN" value="BETWEEN" />
</el-select>
</template>
</el-table-column>
<el-table-column label="必填" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isRequired"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="显示类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.htmlType">
<el-option label="文本框" value="input" />
<el-option label="文本域" value="textarea" />
<el-option label="下拉框" value="select" />
<el-option label="单选框" value="radio" />
<el-option label="复选框" value="checkbox" />
<el-option label="日期控件" value="datetime" />
<el-option label="图片上传" value="imageUpload" />
<el-option label="文件上传" value="fileUpload" />
<el-option label="富文本控件" value="editor" />
</el-select>
</template>
</el-table-column>
<el-table-column label="字典类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
<el-option
v-for="dict in dictOptions"
:key="dict.dictType"
:label="dict.dictName"
:value="dict.dictType">
<span style="float: left">{{ dict.dictName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo">
<gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
</el-tab-pane>
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
<el-button type="primary" @click="submitForm()">提交</el-button>
<el-button @click="close()">返回</el-button>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
import { getGenTable, updateGenTable } from "@/api/tool/gen"
import { optionselect as getDictOptionselect } from "@/api/system/dict/type"
import { listMenu as getMenuTreeselect } from "@/api/system/menu"
import basicInfoForm from "./basicInfoForm"
import genInfoForm from "./genInfoForm"
import Sortable from 'sortablejs'
export default {
name: "GenEdit",
components: {
basicInfoForm,
genInfoForm
},
data() {
return {
// 选中选项卡的 name
activeName: "columnInfo",
// 表格的高度
tableHeight: document.documentElement.scrollHeight - 245 + "px",
// 表信息
tables: [],
// 表列信息
columns: [],
// 字典信息
dictOptions: [],
// 菜单信息
menus: [],
// 表详细信息
info: {}
}
},
created() {
const tableId = this.$route.params && this.$route.params.tableId
if (tableId) {
// 获取表详细信息
getGenTable(tableId).then(res => {
this.columns = res.data.rows
this.info = res.data.info
this.tables = res.data.tables
})
/** 查询字典下拉列表 */
getDictOptionselect().then(response => {
this.dictOptions = response.data
})
/** 查询菜单下拉列表 */
getMenuTreeselect().then(response => {
this.menus = this.handleTree(response.data, "menuId")
})
}
},
methods: {
/** 提交按钮 */
submitForm() {
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm
const genForm = this.$refs.genInfo.$refs.genInfoForm
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
const validateResult = res.every(item => !!item)
if (validateResult) {
const genTable = Object.assign({}, basicForm.model, genForm.model)
genTable.columns = this.columns
genTable.params = {
genView: genTable.view ? '1' : '0',
treeCode: genTable.treeCode,
treeName: genTable.treeName,
treeParentCode: genTable.treeParentCode,
parentMenuId: genTable.parentMenuId
}
updateGenTable(genTable).then(res => {
this.$modal.msgSuccess(res.msg)
if (res.code === 200) {
this.close()
}
})
} else {
this.$modal.msgError("表单校验未通过,请重新检查提交内容")
}
})
},
getFormPromise(form) {
return new Promise(resolve => {
form.validate(res => {
resolve(res)
})
})
},
/** 关闭按钮 */
close() {
const obj = { path: "/tool/gen", query: { t: Date.now(), pageNum: this.$route.query.pageNum } }
this.$tab.closeOpenPage(obj)
}
},
mounted() {
const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0]
const sortable = Sortable.create(el, {
handle: ".allowDrag",
onEnd: evt => {
const targetRow = this.columns.splice(evt.oldIndex, 1)[0]
this.columns.splice(evt.newIndex, 0, targetRow)
for (let index in this.columns) {
this.columns[index].sort = parseInt(index) + 1
}
}
})
}
}
</script>
+336
View File
@@ -0,0 +1,336 @@
<template>
<el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px">
<el-row>
<el-col :span="12">
<el-form-item prop="tplCategory">
<span slot="label">生成模板</span>
<el-select v-model="info.tplCategory" @change="tplSelectChange">
<el-option label="单表(增删改查)" value="crud" />
<el-option label="树表(增删改查)" value="tree" />
<el-option label="主子表(增删改查)" value="sub" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="tplWebType">
<span slot="label">前端类型</span>
<el-select v-model="info.tplWebType">
<el-option label="Vue2 Element UI 模版" value="element-ui" />
<el-option label="Vue3 Element Plus 模版" value="element-plus" />
<el-option label="Vue3 Element Plus TypeScript 模版" value="element-plus-typescript" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="packageName">
<span slot="label">
生成包路径
<el-tooltip content="生成在哪个java包下,例如 com.roomroot.system" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-input v-model="info.packageName" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="moduleName">
<span slot="label">
生成模块名
<el-tooltip content="可理解为子系统名,例如 system" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-input v-model="info.moduleName" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="businessName">
<span slot="label">
生成业务名
<el-tooltip content="可理解为功能英文名,例如 user" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-input v-model="info.businessName" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="functionName">
<span slot="label">
生成功能名
<el-tooltip content="用作类描述,例如 用户" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-input v-model="info.functionName" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="formColNum">
<span slot="label">
表单布局
<el-tooltip content="选择表单的栅格布局方式" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.formColNum">
<el-option label="单列" :value="1" />
<el-option label="双列" :value="2" />
<el-option label="三列" :value="3" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="genView">
<span slot="label">扩展功能</span>
<el-checkbox v-model="info.view">生成详情页</el-checkbox>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="genType">
<span slot="label">
生成代码方式
<el-tooltip content="默认为zip压缩包下载,也可以自定义生成路径" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-radio v-model="info.genType" label="0">zip压缩包</el-radio>
<el-radio v-model="info.genType" label="1">自定义路径</el-radio>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item>
<span slot="label">
上级菜单
<el-tooltip content="分配到指定菜单下,例如 系统管理" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<treeselect
:append-to-body="true"
v-model="info.parentMenuId"
:options="menus"
:normalizer="normalizer"
:show-count="true"
placeholder="请选择系统菜单"
/>
</el-form-item>
</el-col>
<el-col :span="24" v-if="info.genType == '1'">
<el-form-item prop="genPath">
<span slot="label">
自定义路径
<el-tooltip content="填写磁盘绝对路径,若不填写,则生成到当前Web项目下" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-input v-model="info.genPath">
<el-dropdown slot="append">
<el-button type="primary">
最近路径快速选择
<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="info.genPath = '/'">恢复默认的生成基础路径</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row v-show="info.tplCategory == 'tree'">
<h4 class="form-header">其他信息</h4>
<el-col :span="12">
<el-form-item>
<span slot="label">
树编码字段
<el-tooltip content="树显示的编码字段名, 如:dept_id" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.treeCode" placeholder="请选择">
<el-option
v-for="(column, index) in info.columns"
:key="index"
:label="column.columnName + ':' + column.columnComment"
:value="column.columnName"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item>
<span slot="label">
树父编码字段
<el-tooltip content="树显示的父编码字段名, 如:parent_Id" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.treeParentCode" placeholder="请选择">
<el-option
v-for="(column, index) in info.columns"
:key="index"
:label="column.columnName + ':' + column.columnComment"
:value="column.columnName"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item>
<span slot="label">
树名称字段
<el-tooltip content="树节点的显示名称字段名, 如:dept_name" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.treeName" placeholder="请选择">
<el-option
v-for="(column, index) in info.columns"
:key="index"
:label="column.columnName + ':' + column.columnComment"
:value="column.columnName"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row v-show="info.tplCategory == 'sub'">
<h4 class="form-header">关联信息</h4>
<el-col :span="12">
<el-form-item>
<span slot="label">
关联子表的表名
<el-tooltip content="关联子表的表名, 如:sys_user" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.subTableName" placeholder="请选择" @change="subSelectChange">
<el-option
v-for="(table, index) in tables"
:key="index"
:label="table.tableName + ':' + table.tableComment"
:value="table.tableName"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item>
<span slot="label">
子表关联的外键名
<el-tooltip content="子表关联的外键名, 如:user_id" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.subTableFkName" placeholder="请选择">
<el-option
v-for="(column, index) in subColumns"
:key="index"
:label="column.columnName + ':' + column.columnComment"
:value="column.columnName"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
export default {
components: { Treeselect },
props: {
info: {
type: Object,
default: null
},
tables: {
type: Array,
default: null
},
menus: {
type: Array,
default: []
}
},
data() {
return {
subColumns: [],
rules: {
tplCategory: [
{ required: true, message: "请选择生成模板", trigger: "blur" }
],
packageName: [
{ required: true, message: "请输入生成包路径", trigger: "blur" }
],
moduleName: [
{ required: true, message: "请输入生成模块名", trigger: "blur" }
],
businessName: [
{ required: true, message: "请输入生成业务名", trigger: "blur" }
],
functionName: [
{ required: true, message: "请输入生成功能名", trigger: "blur" }
]
}
}
},
watch: {
'info.subTableName': function(val) {
this.setSubTableColumns(val)
},
'info.tplWebType': function(val) {
if (val === '') {
this.info.tplWebType = "element-ui"
}
}
},
methods: {
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children
}
return {
id: node.menuId,
label: node.menuName,
children: node.children
}
},
/** 选择子表名触发 */
subSelectChange(value) {
this.info.subTableFkName = ''
},
/** 选择生成模板触发 */
tplSelectChange(value) {
if (value !== 'sub') {
this.info.subTableName = ''
this.info.subTableFkName = ''
}
},
/** 设置关联外键 */
setSubTableColumns(value) {
for (var item in this.tables) {
const name = this.tables[item].tableName
if (value === name) {
this.subColumns = this.tables[item].columns
break
}
}
}
}
}
</script>
+120
View File
@@ -0,0 +1,120 @@
<template>
<!-- 导入表 -->
<el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
<el-form-item label="表名称" prop="tableName">
<el-input
v-model="queryParams.tableName"
placeholder="请输入表名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="表描述" prop="tableComment">
<el-input
v-model="queryParams.tableComment"
placeholder="请输入表描述"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row>
<el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="createTime" label="创建时间"></el-table-column>
<el-table-column prop="updateTime" label="更新时间"></el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleImportTable">确 定</el-button>
<el-button @click="visible = false">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import { listDbTable, importTable } from "@/api/tool/gen"
export default {
data() {
return {
// 遮罩层
visible: false,
// 选中数组值
tables: [],
// 总条数
total: 0,
// 表数据
dbTableList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
tableName: undefined,
tableComment: undefined
}
}
},
methods: {
// 显示弹框
show() {
this.getList()
this.visible = true
},
clickRow(row) {
this.$refs.table.toggleRowSelection(row)
},
// 多选框选中数据
handleSelectionChange(selection) {
this.tables = selection.map(item => item.tableName)
},
// 查询表数据
getList() {
listDbTable(this.queryParams).then(res => {
if (res.code === 200) {
this.dbTableList = res.rows
this.total = res.total
}
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 导入按钮操作 */
handleImportTable() {
const tableNames = this.tables.join(",")
if (tableNames == "") {
this.$modal.msgError("请选择要导入的表")
return
}
importTable({ tables: tableNames, tplWebType: 'element-ui' }).then(res => {
this.$modal.msgSuccess(res.msg)
if (res.code === 200) {
this.visible = false
this.$emit("ok")
}
})
}
}
}
</script>
+386
View File
@@ -0,0 +1,386 @@
<template>
<div class="app-container tool-gen">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="表名称" prop="tableName">
<el-input
v-model="queryParams.tableName"
placeholder="请输入表名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="表描述" prop="tableComment">
<el-input
v-model="queryParams.tableComment"
placeholder="请输入表描述"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-download"
size="mini"
:disabled="multiple"
@click="handleGenTable"
v-hasPermi="['tool:gen:code']"
>生成</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="openCreateTable"
v-hasRole="['admin']"
>创建</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload"
size="mini"
@click="openImportTable"
v-hasPermi="['tool:gen:import']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleEditTable"
v-hasPermi="['tool:gen:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['tool:gen:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table ref="tables" v-loading="loading" :data="tableList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange" :height="tableHeight">
<el-table-column type="selection" align="center" width="55"></el-table-column>
<el-table-column label="序号" type="index" width="50" align="center">
<template slot-scope="scope">
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column label="表名称" align="center" prop="tableName" :show-overflow-tooltip="true" width="140" />
<el-table-column label="表描述" align="center" prop="tableComment" :show-overflow-tooltip="true" width="140" />
<el-table-column label="实体" align="center" prop="className" :show-overflow-tooltip="true" width="140" />
<el-table-column label="创建时间" align="center" prop="createTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="160" />
<el-table-column label="更新时间" align="center" prop="updateTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
type="text"
size="small"
icon="el-icon-view"
@click="handlePreview(scope.row)"
v-hasPermi="['tool:gen:preview']"
>预览</el-button>
<el-button
type="text"
size="small"
icon="el-icon-edit"
@click="handleEditTable(scope.row)"
v-hasPermi="['tool:gen:edit']"
>编辑</el-button>
<el-button
type="text"
size="small"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['tool:gen:remove']"
>删除</el-button>
<el-button
type="text"
size="small"
icon="el-icon-refresh"
@click="handleSynchDb(scope.row)"
v-hasPermi="['tool:gen:edit']"
>同步</el-button>
<el-button
type="text"
size="small"
icon="el-icon-download"
@click="handleGenTable(scope.row)"
v-hasPermi="['tool:gen:code']"
>生成代码</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 预览界面 -->
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body class="scrollbar">
<el-tabs v-model="preview.activeName">
<el-tab-pane
v-for="(value, key) in preview.data"
:label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
:key="key"
>
<el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="value" v-clipboard:success="clipboardSuccess" style="float:right">复制</el-link>
<pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
</el-tab-pane>
</el-tabs>
</el-dialog>
<import-table ref="import" @ok="handleQuery" />
<create-table ref="create" @ok="handleQuery" />
</div>
</template>
<script>
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"
import importTable from "./importTable"
import createTable from "./createTable"
import hljs from "highlight.js/lib/highlight"
import "highlight.js/styles/github-gist.css"
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"))
hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"))
hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"))
hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"))
hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript"))
hljs.registerLanguage("typescript", require("highlight.js/lib/languages/typescript"))
hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"))
export default {
name: "Gen",
components: { importTable, createTable },
data() {
return {
// 遮罩层
loading: true,
// 唯一标识符
uniqueId: "",
// 选中数组
ids: [],
// 选中表数组
tableNames: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 表数据
tableList: [],
// 日期范围
dateRange: "",
// 默认排序
defaultSort: { prop: "createTime", order: "descending" },
// 表格高度
tableHeight: window.innerHeight - 240,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
tableName: undefined,
tableComment: undefined
},
// 预览参数
preview: {
open: false,
title: "代码预览",
data: {},
activeName: "domain.java"
}
}
},
created() {
this.queryParams.orderByColumn = this.defaultSort.prop
this.queryParams.isAsc = this.defaultSort.order
this.getList()
},
activated() {
const time = this.$route.query.t
if (time != null && time != this.uniqueId) {
this.uniqueId = time
this.queryParams.pageNum = Number(this.$route.query.pageNum)
this.getList()
}
},
mounted() {
this.getTableHeight()
window.addEventListener('resize', this.getTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.getTableHeight)
},
watch: {
showSearch() {
this.$nextTick(() => {
this.getTableHeight()
})
}
},
methods: {
getTableHeight() {
const offset = this.showSearch ? 240 : 190
this.tableHeight = window.innerHeight - offset
},
/** 查询表集合 */
getList() {
this.loading = true
listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.tableList = response.rows
this.total = response.total
this.loading = false
}
)
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 生成代码操作 */
handleGenTable(row) {
const tableNames = row.tableName || this.tableNames
if (tableNames == "") {
this.$modal.msgError("请选择要生成的数据")
return
}
if (row.genType === "1") {
genCode(row.tableName).then(() => {
this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath)
})
} else {
const zipName = Array.isArray(tableNames) ? "roomroot.zip" : tableNames + ".zip"
this.$download.zip("/tool/gen/batchGenCode?tables=" + tableNames, zipName)
}
},
/** 同步数据库操作 */
handleSynchDb(row) {
const tableName = row.tableName
this.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function() {
return synchDb(tableName)
}).then(() => {
this.$modal.msgSuccess("同步成功")
}).catch(() => {})
},
/** 打开导入表弹窗 */
openImportTable() {
this.$refs.import.show()
},
/** 打开创建表弹窗 */
openCreateTable() {
this.$refs.create.show()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm("queryForm")
this.queryParams.pageNum = 1
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
},
/** 预览按钮 */
handlePreview(row) {
previewTable(row.tableId).then(response => {
this.preview.data = response.data
this.preview.open = true
this.preview.activeName = "domain.java"
})
},
/** 高亮显示 */
highlightedCode(code, key) {
const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"))
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length)
const result = hljs.highlight(language, code || "", true)
return result.value || '&nbsp;'
},
/** 复制代码成功 */
clipboardSuccess() {
this.$modal.msgSuccess("复制成功")
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.tableId)
this.tableNames = selection.map(item => item.tableName)
this.single = selection.length != 1
this.multiple = !selection.length
},
/** 排序触发事件 */
handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop
this.queryParams.isAsc = column.order
this.getList()
},
/** 修改按钮操作 */
handleEditTable(row) {
const tableId = row.tableId || this.ids[0]
const tableName = row.tableName || this.tableNames[0]
const params = { pageNum: this.queryParams.pageNum }
this.$tab.openPage("修改[" + tableName + "]生成配置", '/tool/gen-edit/index/' + tableId, params)
},
/** 删除按钮操作 */
handleDelete(row) {
const tableIds = row.tableId || this.ids
this.$modal.confirm('是否确认删除表编号为"' + tableIds + '"的数据项?').then(function() {
return delTable(tableIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
}
}
</script>
<style scoped>
.tool-gen ::v-deep .el-table ::-webkit-scrollbar {
display: none;
}
.tool-gen ::v-deep .el-table {
scrollbar-width: none;
-ms-overflow-style: none;
}
.tool-gen ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
display: none;
}
.tool-gen ::v-deep .el-table__body-wrapper {
scrollbar-width: none;
-ms-overflow-style: none;
}
</style>
+15
View File
@@ -0,0 +1,15 @@
<template>
<i-frame :src="url" />
</template>
<script>
import iFrame from "@/components/iFrame/index"
export default {
name: "Swagger",
components: { iFrame },
data() {
return {
url: process.env.VUE_APP_BASE_API + "/swagger-ui/index.html"
}
}
}
</script>