评优和安全教育功能
This commit is contained in:
@@ -81,16 +81,22 @@
|
||||
安全教育列表
|
||||
</span>
|
||||
<div class="header-actions">
|
||||
<el-button
|
||||
icon="Plus"
|
||||
type="primary"
|
||||
<el-button
|
||||
icon="DataAnalysis"
|
||||
type="success"
|
||||
@click="handleStatistics">
|
||||
统计汇总
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Plus"
|
||||
type="primary"
|
||||
@click="formDialogRef.openDialog()">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="success"
|
||||
class="ml10"
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="success"
|
||||
class="ml10"
|
||||
@click="handleExport">
|
||||
导出
|
||||
</el-button>
|
||||
@@ -232,16 +238,90 @@
|
||||
|
||||
<!-- 新增/编辑表单弹窗 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
|
||||
<!-- 查看详情弹窗 -->
|
||||
<detail-dialog ref="detailDialogRef" />
|
||||
|
||||
<!-- 统计对话框 -->
|
||||
<el-dialog
|
||||
v-model="statisticsDialogVisible"
|
||||
title="安全教育统计汇总"
|
||||
width="800px"
|
||||
destroy-on-close>
|
||||
<!-- 搜索条件 -->
|
||||
<el-form :inline="true" class="statistics-form">
|
||||
<el-form-item label="学年">
|
||||
<el-select
|
||||
v-model="statisticsQuery.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 180px">
|
||||
<el-option
|
||||
v-for="item in schoolYearList"
|
||||
:key="item.year"
|
||||
:label="item.year"
|
||||
:value="item.year">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="学期">
|
||||
<el-select
|
||||
v-model="statisticsQuery.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 180px">
|
||||
<el-option
|
||||
v-for="item in schoolTermList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="getStatisticsData">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 统计表格 -->
|
||||
<el-table
|
||||
:data="statisticsData"
|
||||
v-loading="statisticsLoading"
|
||||
stripe
|
||||
max-height="400px"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||||
<el-table-column prop="classNo" label="班号" align="center" />
|
||||
<el-table-column prop="schoolYear" label="学年" align="center" />
|
||||
<el-table-column prop="schoolTerm" label="学期" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="primary" effect="plain" round>
|
||||
{{ formatSchoolTerm(row.schoolTerm) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="eduCount" label="安全教育次数" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" type="success" effect="plain" round>
|
||||
{{ row.eduCount }} 次
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="statisticsDialogVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="ClassSafeEdu">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObj, exportExcel } from "/@/api/stuwork/classsafeedu";
|
||||
import { fetchList, delObj, exportExcel, statisticsByYearTerm } from "/@/api/stuwork/classsafeedu";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
@@ -249,7 +329,7 @@ import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
|
||||
import FormDialog from './form.vue'
|
||||
import DetailDialog from './detail.vue'
|
||||
import { List, Calendar, Clock, Grid, Trophy, User, Location, UserFilled, Setting, Menu, Search, Document } from '@element-plus/icons-vue'
|
||||
import { List, Calendar, Clock, Grid, Trophy, User, Location, UserFilled, Setting, Menu, Search, Document, DataAnalysis } from '@element-plus/icons-vue'
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn'
|
||||
|
||||
// 定义变量内容
|
||||
@@ -262,6 +342,15 @@ const schoolYearList = ref<any[]>([])
|
||||
const schoolTermList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
|
||||
// 统计相关变量
|
||||
const statisticsDialogVisible = ref(false)
|
||||
const statisticsLoading = ref(false)
|
||||
const statisticsData = ref<any[]>([])
|
||||
const statisticsQuery = reactive({
|
||||
schoolYear: '',
|
||||
schoolTerm: ''
|
||||
})
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
{ prop: 'schoolYear', label: '学年', icon: Calendar },
|
||||
@@ -449,6 +538,40 @@ const getClassListData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 打开统计对话框
|
||||
const handleStatistics = () => {
|
||||
// 使用当前搜索条件的学年和学期
|
||||
statisticsQuery.schoolYear = state.queryForm.schoolYear || ''
|
||||
statisticsQuery.schoolTerm = state.queryForm.schoolTerm || ''
|
||||
statisticsData.value = []
|
||||
statisticsDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 获取统计数据
|
||||
const getStatisticsData = async () => {
|
||||
// 必须选择学年或学期才能查询
|
||||
if (!statisticsQuery.schoolYear && !statisticsQuery.schoolTerm) {
|
||||
useMessage().warning('请选择学年或学期进行查询')
|
||||
return
|
||||
}
|
||||
statisticsLoading.value = true
|
||||
try {
|
||||
const res = await statisticsByYearTerm(
|
||||
statisticsQuery.schoolYear || undefined,
|
||||
statisticsQuery.schoolTerm || undefined
|
||||
)
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
statisticsData.value = res.data
|
||||
} else {
|
||||
statisticsData.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
statisticsData.value = []
|
||||
} finally {
|
||||
statisticsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
|
||||
@@ -176,16 +176,105 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<!-- 操作列 -->
|
||||
<el-table-column label="操作" width="180" align="center" fixed="right">
|
||||
<template #header>
|
||||
<el-icon><Setting /></el-icon>
|
||||
<span style="margin-left: 4px">操作</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Trophy" @click="handleAward(scope.row)">评优</el-button>
|
||||
<el-button link type="success" icon="View" @click="handleViewRecord(scope.row)">记录</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<!-- 评优对话框 -->
|
||||
<el-dialog
|
||||
title="学生评优"
|
||||
v-model="awardDialogVisible"
|
||||
:width="500"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<el-form :model="awardForm" label-width="80px">
|
||||
<el-form-item label="学号">
|
||||
<el-input v-model="awardForm.stuNo" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="awardForm.realName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="奖项">
|
||||
<el-select
|
||||
v-model="awardForm.ruleName"
|
||||
multiple
|
||||
placeholder="请选择奖项"
|
||||
filterable
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in rewardRuleList"
|
||||
:key="item.id"
|
||||
:label="item.ruleName"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="awardDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleAwardSubmit" :loading="awardLoading">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 评优记录对话框 -->
|
||||
<el-dialog
|
||||
title="评优记录"
|
||||
v-model="recordDialogVisible"
|
||||
:width="600"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<div v-if="currentRow" class="record-header">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="学号">{{ currentRow.stuNo }}</el-descriptions-item>
|
||||
<el-descriptions-item label="姓名">{{ currentRow.realName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="学年">{{ queryForm.schoolYear || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="学期">{{ formatSchoolTerm(queryForm.schoolTerm) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<el-table
|
||||
:data="rewardRecordList"
|
||||
v-loading="recordLoading"
|
||||
stripe
|
||||
border
|
||||
style="margin-top: 15px;">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="ruleId" label="奖项ID" align="center" />
|
||||
<el-table-column prop="ruleName" label="奖项名称" align="center">
|
||||
<template #default="scope">
|
||||
{{ getRuleNameById(scope.row.ruleId) || scope.row.ruleId || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="评选时间" align="center" width="180">
|
||||
<template #default="scope">
|
||||
{{ parseTime(scope.row.createTime, dateTimeFormat) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #empty>
|
||||
<el-empty description="暂无评优记录" :image-size="80" />
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button @click="recordDialogVisible = false">关 闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="RewardStudent">
|
||||
import { reactive, ref, onMounted, computed, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { fetchList, exportExcel } from "/@/api/stuwork/rewardstudent";
|
||||
import { fetchList, exportExcel, updateStuAward, getStuRewardList, getRewardRuleList } from "/@/api/stuwork/rewardstudent";
|
||||
import { getDeptList } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
@@ -193,7 +282,7 @@ import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
import { parseTime } from "/@/utils/formatTime";
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
|
||||
import { List, OfficeBuilding, Grid, CreditCard, Avatar, DataAnalysis, Warning, Trophy, Clock, Menu, Search, Document } from '@element-plus/icons-vue'
|
||||
import { List, OfficeBuilding, Grid, CreditCard, Avatar, DataAnalysis, Warning, Trophy, Clock, Menu, Search, Document, Setting, View } from '@element-plus/icons-vue'
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn'
|
||||
|
||||
const dateTimeFormat = '{y}-{m}-{d} {h}:{i}:{s}'
|
||||
@@ -210,6 +299,24 @@ const schoolTermList = ref<any[]>([])
|
||||
const deptList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
|
||||
// 评优相关
|
||||
const awardDialogVisible = ref(false)
|
||||
const awardLoading = ref(false)
|
||||
const awardForm = reactive({
|
||||
stuNo: '',
|
||||
realName: '',
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
ruleName: [] as string[]
|
||||
})
|
||||
const rewardRuleList = ref<any[]>([])
|
||||
|
||||
// 评优记录相关
|
||||
const recordDialogVisible = ref(false)
|
||||
const recordLoading = ref(false)
|
||||
const currentRow = ref<any>(null)
|
||||
const rewardRecordList = ref<any[]>([])
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
{ prop: 'departName', label: '学院名称' },
|
||||
@@ -391,12 +498,88 @@ const getClassListData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取奖项规则列表
|
||||
const getRewardRuleListData = async () => {
|
||||
try {
|
||||
const res = await getRewardRuleList()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
rewardRuleList.value = res.data
|
||||
} else {
|
||||
rewardRuleList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
rewardRuleList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 根据ruleId获取奖项名称
|
||||
const getRuleNameById = (ruleId: string) => {
|
||||
const rule = rewardRuleList.value.find(item => item.id === ruleId)
|
||||
return rule ? rule.ruleName : null
|
||||
}
|
||||
|
||||
// 打开评优对话框
|
||||
const handleAward = (row: any) => {
|
||||
if (!queryForm.schoolYear || !queryForm.schoolTerm) {
|
||||
useMessage().warning('请先选择学年 and 学期')
|
||||
return
|
||||
}
|
||||
awardForm.stuNo = row.stuNo
|
||||
awardForm.realName = row.realName
|
||||
awardForm.schoolYear = queryForm.schoolYear
|
||||
awardForm.schoolTerm = queryForm.schoolTerm
|
||||
// 如果已有奖项,设置默认值
|
||||
awardForm.ruleName = row.ruleName && Array.isArray(row.ruleName) ? [...row.ruleName] : []
|
||||
awardDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 提交评优
|
||||
const handleAwardSubmit = async () => {
|
||||
awardLoading.value = true
|
||||
try {
|
||||
await updateStuAward(awardForm)
|
||||
useMessage().success('评优成功')
|
||||
awardDialogVisible.value = false
|
||||
getDataList()
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '评优失败')
|
||||
} finally {
|
||||
awardLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 查看评优记录
|
||||
const handleViewRecord = async (row: any) => {
|
||||
if (!queryForm.schoolYear || !queryForm.schoolTerm) {
|
||||
useMessage().warning('请先选择学年 and 学期')
|
||||
return
|
||||
}
|
||||
currentRow.value = row
|
||||
recordDialogVisible.value = true
|
||||
recordLoading.value = true
|
||||
rewardRecordList.value = []
|
||||
try {
|
||||
const res = await getStuRewardList(row.stuNo, queryForm.schoolYear, queryForm.schoolTerm)
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
rewardRecordList.value = res.data
|
||||
} else {
|
||||
rewardRecordList.value = []
|
||||
}
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '获取记录失败')
|
||||
rewardRecordList.value = []
|
||||
} finally {
|
||||
recordLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
getSchoolTermDict()
|
||||
getDeptListData()
|
||||
getClassListData()
|
||||
getRewardRuleListData()
|
||||
getDataList()
|
||||
nextTick(() => {
|
||||
if (visibleColumns.value.length === 0) {
|
||||
@@ -407,5 +590,9 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '/@/assets/styles/modern-page.scss';
|
||||
|
||||
.record-header {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user