准备验证
This commit is contained in:
406
src/views/stuwork/stuconduct/form.vue
Normal file
406
src/views/stuwork/stuconduct/form.vue
Normal file
@@ -0,0 +1,406 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="form.id ? '编辑' : '新增'"
|
||||
v-model="visible"
|
||||
:width="800"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<el-form
|
||||
ref="dataFormRef"
|
||||
:model="form"
|
||||
:rules="dataRules"
|
||||
label-width="120px"
|
||||
v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select
|
||||
v-model="form.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
:disabled="!!form.id">
|
||||
<el-option
|
||||
v-for="item in schoolYearList"
|
||||
:key="item.year"
|
||||
:label="item.year"
|
||||
:value="item.year">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="学期" prop="schoolTerm">
|
||||
<el-select
|
||||
v-model="form.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="!!form.id">
|
||||
<el-option
|
||||
v-for="item in schoolTermList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="班级" prop="classCode">
|
||||
<el-select
|
||||
v-model="form.classCode"
|
||||
placeholder="请选择班级"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleClassChange">
|
||||
<el-option
|
||||
v-for="item in classList"
|
||||
:key="item.classCode"
|
||||
:label="item.classNo"
|
||||
:value="item.classCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="学生" prop="stuNo">
|
||||
<el-select
|
||||
v-model="form.stuNo"
|
||||
:placeholder="form.classCode ? '请选择学生' : '请先选择班级'"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
:disabled="!form.classCode || studentLoading"
|
||||
:loading="studentLoading"
|
||||
@change="handleStudentChange">
|
||||
<el-option
|
||||
v-for="item in studentList"
|
||||
:key="item.stuNo"
|
||||
:label="`${item.realName} (${item.stuNo})`"
|
||||
:value="item.stuNo">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="分数" prop="score">
|
||||
<el-input-number
|
||||
v-model="form.score"
|
||||
:min="0"
|
||||
:max="100"
|
||||
placeholder="请输入分数"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="类型" prop="conductType">
|
||||
<el-select
|
||||
v-model="form.conductType"
|
||||
placeholder="请选择类型"
|
||||
clearable
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in typeList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="考核时间" prop="recordDate">
|
||||
<el-date-picker
|
||||
v-model="form.recordDate"
|
||||
type="date"
|
||||
placeholder="选择考核时间"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="情况记录" prop="description">
|
||||
<el-input
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="请输入情况记录"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="附件" prop="attachment">
|
||||
<upload-file
|
||||
v-model="form.attachment"
|
||||
:limit="5"
|
||||
:fileSize="10"
|
||||
type="simple" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确 认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="StuConductFormDialog">
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue'
|
||||
import { useMessage } from '/@/hooks/message'
|
||||
import { addObj, editObj, getDetail } from '/@/api/stuwork/stuconduct'
|
||||
import { getClassListByRole } from '/@/api/basic/basicclass'
|
||||
import { queryAllSchoolYear } from '/@/api/basic/basicyear'
|
||||
import { queryAllStudentByClassCode } from '/@/api/basic/basicstudent'
|
||||
import { getDicts } from '/@/api/admin/dict'
|
||||
import UploadFile from '/@/components/Upload/index.vue'
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const studentLoading = ref(false)
|
||||
const operType = ref('add')
|
||||
const classList = ref<any[]>([])
|
||||
const studentList = ref<any[]>([])
|
||||
const schoolYearList = ref<any[]>([])
|
||||
const schoolTermList = ref<any[]>([])
|
||||
const typeList = ref<any[]>([])
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
classCode: '',
|
||||
stuNo: '',
|
||||
score: 0,
|
||||
conductType: '',
|
||||
recordDate: '',
|
||||
description: '',
|
||||
attachment: ''
|
||||
})
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = {
|
||||
schoolYear: [
|
||||
{ required: true, message: '请选择学年', trigger: 'change' }
|
||||
],
|
||||
schoolTerm: [
|
||||
{ required: true, message: '请选择学期', trigger: 'change' }
|
||||
],
|
||||
classCode: [
|
||||
{ required: true, message: '请选择班级', trigger: 'change' }
|
||||
],
|
||||
stuNo: [
|
||||
{ required: true, message: '请选择学生', trigger: 'change' }
|
||||
],
|
||||
score: [
|
||||
{ required: true, message: '请输入分数', trigger: 'blur' }
|
||||
],
|
||||
conductType: [
|
||||
{ required: true, message: '请选择类型', trigger: 'change' }
|
||||
],
|
||||
recordDate: [
|
||||
{ required: true, message: '请选择考核时间', trigger: 'change' }
|
||||
],
|
||||
description: [
|
||||
{ required: true, message: '请输入情况记录', trigger: 'blur' }
|
||||
]
|
||||
// attachment 非必填,不需要验证规则
|
||||
}
|
||||
|
||||
// 班级变化
|
||||
const handleClassChange = async () => {
|
||||
form.stuNo = ''
|
||||
studentList.value = []
|
||||
|
||||
if (form.classCode) {
|
||||
studentLoading.value = true
|
||||
try {
|
||||
const res = await queryAllStudentByClassCode(form.classCode)
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
studentList.value = res.data
|
||||
} else {
|
||||
studentList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学生列表失败', err)
|
||||
useMessage().error('获取学生列表失败')
|
||||
studentList.value = []
|
||||
} finally {
|
||||
studentLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 学生变化
|
||||
const handleStudentChange = () => {
|
||||
// 学生选择后可以做一些处理,这里暂时不需要
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = async (type: string = 'add', row?: any) => {
|
||||
visible.value = true
|
||||
operType.value = type
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields()
|
||||
form.id = ''
|
||||
form.schoolYear = ''
|
||||
form.schoolTerm = ''
|
||||
form.classCode = ''
|
||||
form.stuNo = ''
|
||||
form.score = 0
|
||||
form.conductType = ''
|
||||
form.recordDate = ''
|
||||
form.description = ''
|
||||
form.attachment = ''
|
||||
studentList.value = []
|
||||
|
||||
// 编辑时填充数据
|
||||
if (type === 'edit' && row) {
|
||||
form.id = row.id
|
||||
form.schoolYear = row.schoolYear || ''
|
||||
form.schoolTerm = row.schoolTerm || ''
|
||||
form.classCode = row.classCode || ''
|
||||
form.stuNo = row.stuNo || ''
|
||||
form.score = row.score || 0
|
||||
form.conductType = row.conductType || ''
|
||||
form.recordDate = row.recordDate || ''
|
||||
form.description = row.description || ''
|
||||
form.attachment = row.attachment || ''
|
||||
|
||||
// 加载学生列表
|
||||
if (form.classCode) {
|
||||
handleClassChange()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const onSubmit = async () => {
|
||||
if (!dataFormRef.value) return
|
||||
|
||||
await dataFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const submitData = {
|
||||
schoolYear: form.schoolYear,
|
||||
schoolTerm: form.schoolTerm,
|
||||
classCode: form.classCode,
|
||||
stuNo: form.stuNo,
|
||||
score: form.score,
|
||||
conductType: form.conductType,
|
||||
recordDate: form.recordDate,
|
||||
description: form.description,
|
||||
attachment: form.attachment || ''
|
||||
}
|
||||
|
||||
if (operType.value === 'add') {
|
||||
await addObj(submitData)
|
||||
useMessage().success('新增成功')
|
||||
} else {
|
||||
await editObj({
|
||||
id: form.id,
|
||||
...submitData
|
||||
})
|
||||
useMessage().success('编辑成功')
|
||||
}
|
||||
visible.value = false
|
||||
emit('refresh')
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || (operType.value === 'add' ? '新增失败' : '编辑失败'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取学年列表
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
const res = await queryAllSchoolYear()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学年列表失败', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取学期字典
|
||||
const getSchoolTermDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('school_term')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学期字典失败', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await getClassListByRole()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取类型字典
|
||||
const getTypeDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('conduct_type')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
typeList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取类型字典失败', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
getSchoolTermDict()
|
||||
getClassListData()
|
||||
getTypeDict()
|
||||
})
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
openDialog
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mb20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
472
src/views/stuwork/stuconduct/index.vue
Normal file
472
src/views/stuwork/stuconduct/index.vue
Normal file
@@ -0,0 +1,472 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<!-- 搜索表单 -->
|
||||
<el-row v-show="showSearch">
|
||||
<el-form :model="state.queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select
|
||||
v-model="state.queryForm.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<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="学期" prop="schoolTerm">
|
||||
<el-select
|
||||
v-model="state.queryForm.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 200px">
|
||||
<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 label="学院" prop="deptCode">
|
||||
<el-select
|
||||
v-model="state.queryForm.deptCode"
|
||||
placeholder="请选择学院"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px"
|
||||
@change="handleDeptChange">
|
||||
<el-option
|
||||
v-for="item in deptList"
|
||||
:key="item.deptCode"
|
||||
:label="item.deptName"
|
||||
:value="item.deptCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="班级" prop="classCode">
|
||||
<el-select
|
||||
v-model="state.queryForm.classCode"
|
||||
placeholder="请选择班级"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in classList"
|
||||
:key="item.classCode"
|
||||
:label="item.classNo"
|
||||
:value="item.classCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="realName">
|
||||
<el-input
|
||||
v-model="state.queryForm.realName"
|
||||
placeholder="请输入姓名"
|
||||
clearable
|
||||
style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="conductType">
|
||||
<el-select
|
||||
v-model="state.queryForm.conductType"
|
||||
placeholder="请选择类型"
|
||||
clearable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in typeList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" plain icon="Search" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button
|
||||
icon="Plus"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="formDialogRef.openDialog()">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Upload"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="handleImport">
|
||||
导入
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
class="ml10 mr20"
|
||||
style="float: right;"
|
||||
@queryTable="getDataList">
|
||||
</right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
|
||||
<!-- 表格 -->
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="state.loading"
|
||||
border
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="schoolYear" label="学年" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="schoolTerm" label="学期" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ formatSchoolTerm(scope.row.schoolTerm) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="deptName" label="学院" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="classNo" label="班级" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="conductType" label="类型" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ formatType(scope.row.conductType) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="recordDate" label="考核时间" show-overflow-tooltip align="center" width="120">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.recordDate || '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="description" label="情况记录" show-overflow-tooltip align="center" min-width="150" />
|
||||
<el-table-column prop="attachment" label="附件" show-overflow-tooltip align="center" width="100">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.attachment"
|
||||
icon="Document"
|
||||
text
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleViewAttachment(scope.row)">
|
||||
查看
|
||||
</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="Edit"
|
||||
text
|
||||
type="primary"
|
||||
@click="handleEdit(scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Delete"
|
||||
text
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑表单弹窗 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<el-dialog
|
||||
title="导入操行考核"
|
||||
v-model="importDialogVisible"
|
||||
:width="500"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
:auto-upload="false"
|
||||
:on-change="handleFileChange"
|
||||
:limit="1"
|
||||
accept=".xlsx,.xls"
|
||||
drag>
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或<em>点击上传</em>
|
||||
</div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
只能上传 xlsx/xls 文件
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="importDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleImportSubmit" :disabled="!importFile || importLoading">确 认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="StuConduct">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObj, importExcel } from "/@/api/stuwork/stuconduct";
|
||||
import { getDeptList } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import FormDialog from './form.vue'
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
const uploadRef = ref()
|
||||
const searchFormRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const schoolYearList = ref<any[]>([])
|
||||
const schoolTermList = ref<any[]>([])
|
||||
const deptList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
const typeList = ref<any[]>([])
|
||||
const importDialogVisible = ref(false)
|
||||
const importFile = ref<File | null>(null)
|
||||
const importLoading = ref(false)
|
||||
|
||||
// 配置 useTable
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
deptCode: '',
|
||||
classCode: '',
|
||||
realName: '',
|
||||
conductType: ''
|
||||
},
|
||||
pageList: fetchList,
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total'
|
||||
},
|
||||
createdIsNeed: true
|
||||
})
|
||||
|
||||
// table hook
|
||||
const {
|
||||
getDataList,
|
||||
currentChangeHandle,
|
||||
sizeChangeHandle,
|
||||
tableStyle
|
||||
} = useTable(state)
|
||||
|
||||
// 格式化学期
|
||||
const formatSchoolTerm = (value: string | number) => {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '-'
|
||||
}
|
||||
const dictItem = schoolTermList.value.find(item => item.value == value)
|
||||
return dictItem ? dictItem.label : value
|
||||
}
|
||||
|
||||
// 格式化类型
|
||||
const formatType = (value: string) => {
|
||||
if (!value) return '-'
|
||||
const item = typeList.value.find((item: any) => item.value === value)
|
||||
return item ? item.label : value
|
||||
}
|
||||
|
||||
// 学院变化
|
||||
const handleDeptChange = () => {
|
||||
// 可以根据学院筛选班级,这里暂时不实现
|
||||
}
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
searchFormRef.value?.resetFields()
|
||||
state.queryForm.schoolYear = ''
|
||||
state.queryForm.schoolTerm = ''
|
||||
state.queryForm.deptCode = ''
|
||||
state.queryForm.classCode = ''
|
||||
state.queryForm.realName = ''
|
||||
state.queryForm.conductType = ''
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 查看附件
|
||||
const handleViewAttachment = (row: any) => {
|
||||
if (row.attachment) {
|
||||
const urls = typeof row.attachment === 'string' ? row.attachment.split(',') : [row.attachment]
|
||||
urls.forEach((url: string) => {
|
||||
if (url.trim()) {
|
||||
window.open(url.trim(), '_blank')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 导入
|
||||
const handleImport = () => {
|
||||
importDialogVisible.value = true
|
||||
importFile.value = null
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
|
||||
// 文件变化
|
||||
const handleFileChange = (file: any) => {
|
||||
importFile.value = file.raw
|
||||
}
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
useMessage().warning('请选择要导入的文件')
|
||||
return
|
||||
}
|
||||
|
||||
importLoading.value = true
|
||||
try {
|
||||
await importExcel(importFile.value)
|
||||
useMessage().success('导入成功')
|
||||
importDialogVisible.value = false
|
||||
importFile.value = null
|
||||
uploadRef.value?.clearFiles()
|
||||
getDataList()
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导入失败')
|
||||
} finally {
|
||||
importLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑
|
||||
const handleEdit = (row: any) => {
|
||||
formDialogRef.value?.openDialog('edit', row)
|
||||
}
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (row: any) => {
|
||||
const { confirm } = useMessageBox()
|
||||
try {
|
||||
await confirm('确定要删除该操行考核记录吗?')
|
||||
await delObj([row.id])
|
||||
useMessage().success('删除成功')
|
||||
getDataList()
|
||||
} catch (err: any) {
|
||||
if (err !== 'cancel') {
|
||||
useMessage().error(err.msg || '删除失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取学年列表
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
const res = await queryAllSchoolYear()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data
|
||||
} else {
|
||||
schoolYearList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学年列表失败', err)
|
||||
schoolYearList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取学期字典
|
||||
const getSchoolTermDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('school_term')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
} else {
|
||||
schoolTermList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学期字典失败', err)
|
||||
schoolTermList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取学院列表
|
||||
const getDeptListData = async () => {
|
||||
try {
|
||||
const res = await getDeptList()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
deptList.value = res.data
|
||||
} else {
|
||||
deptList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学院列表失败', err)
|
||||
deptList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await getClassListByRole()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data
|
||||
} else {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取类型字典
|
||||
const getTypeDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('conduct_type')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
typeList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
} else {
|
||||
typeList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取类型字典失败', err)
|
||||
typeList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
getSchoolTermDict()
|
||||
getDeptListData()
|
||||
getClassListData()
|
||||
getTypeDict()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
|
||||
372
src/views/stuwork/stuconduct/indexTerm.vue
Normal file
372
src/views/stuwork/stuconduct/indexTerm.vue
Normal file
@@ -0,0 +1,372 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<!-- 搜索表单 -->
|
||||
<el-row v-show="showSearch">
|
||||
<el-form :model="queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select
|
||||
v-model="queryForm.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<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="学期" prop="schoolTerm">
|
||||
<el-select
|
||||
v-model="queryForm.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 200px">
|
||||
<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 label="班级" prop="classCode">
|
||||
<el-select
|
||||
v-model="queryForm.classCode"
|
||||
placeholder="请选择班级"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in classList"
|
||||
:key="item.classCode"
|
||||
:label="item.classNo"
|
||||
:value="item.classCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" plain icon="Search" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<!-- 统计表格 -->
|
||||
<el-row style="margin-bottom: 20px;">
|
||||
<el-table
|
||||
:data="statisticsData"
|
||||
v-loading="loading"
|
||||
border
|
||||
style="width: 100%"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column prop="label" label="" width="120" align="center" fixed="left" />
|
||||
<el-table-column prop="classNo" label="班级" min-width="150" align="center" />
|
||||
<el-table-column prop="excellent" label="优秀" min-width="100" align="center" />
|
||||
<el-table-column prop="good" label="良好" min-width="100" align="center" />
|
||||
<el-table-column prop="pass" label="及格" min-width="100" align="center" />
|
||||
<el-table-column prop="fail" label="不及格" min-width="100" align="center" />
|
||||
</el-table>
|
||||
</el-row>
|
||||
|
||||
<!-- 学生列表表格 -->
|
||||
<el-row>
|
||||
<el-table
|
||||
:data="studentList"
|
||||
v-loading="loading"
|
||||
border
|
||||
:max-height="600"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="score" label="学期总评" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.score !== null && scope.row.score !== undefined ? scope.row.score.toFixed(2) : '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="View"
|
||||
text
|
||||
type="primary"
|
||||
@click="handleView(scope.row)">
|
||||
查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="StuConductTerm">
|
||||
import { reactive, ref, onMounted, computed } from 'vue'
|
||||
import { getStuConductTerm } from "/@/api/stuwork/stuconduct";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
|
||||
// 表格样式 - 在组件内部定义,不从外部导入
|
||||
const tableStyle = {
|
||||
cellStyle: { padding: '8px 0' },
|
||||
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' }
|
||||
}
|
||||
|
||||
// 定义变量内容
|
||||
const searchFormRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const loading = ref(false)
|
||||
const schoolYearList = ref<any[]>([])
|
||||
const schoolTermList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
const studentList = ref<any[]>([])
|
||||
|
||||
// 查询表单
|
||||
const queryForm = reactive({
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
classCode: ''
|
||||
})
|
||||
|
||||
// 统计表格数据
|
||||
const statisticsData = computed(() => {
|
||||
if (studentList.value.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
// 计算各等级人数
|
||||
// 优秀:>=90,良好:80-89,及格:60-79,不及格:<60
|
||||
let excellent = 0 // 优秀
|
||||
let good = 0 // 良好
|
||||
let pass = 0 // 及格
|
||||
let fail = 0 // 不及格
|
||||
const total = studentList.value.length
|
||||
|
||||
studentList.value.forEach((student: any) => {
|
||||
const score = student.score
|
||||
if (score !== null && score !== undefined) {
|
||||
if (score >= 90) {
|
||||
excellent++
|
||||
} else if (score >= 80) {
|
||||
good++
|
||||
} else if (score >= 60) {
|
||||
pass++
|
||||
} else {
|
||||
fail++
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 计算比率
|
||||
const excellentRate = total > 0 ? ((excellent / total) * 100).toFixed(2) + '%' : '0%'
|
||||
const goodRate = total > 0 ? ((good / total) * 100).toFixed(2) + '%' : '0%'
|
||||
const passRate = total > 0 ? ((pass / total) * 100).toFixed(2) + '%' : '0%'
|
||||
const failRate = total > 0 ? ((fail / total) * 100).toFixed(2) + '%' : '0%'
|
||||
|
||||
// 优良率 = (优秀 + 良好) / 总人数
|
||||
const excellentGoodCount = excellent + good
|
||||
const excellentGoodRate = total > 0 ? ((excellentGoodCount / total) * 100).toFixed(2) + '%' : '0%'
|
||||
|
||||
// 获取班级名称
|
||||
const classNo = studentList.value.length > 0 ? (studentList.value[0].classNo || '-') : '-'
|
||||
|
||||
return [
|
||||
{
|
||||
label: '人数',
|
||||
classNo: classNo,
|
||||
excellent: excellent,
|
||||
good: good,
|
||||
pass: pass,
|
||||
fail: fail
|
||||
},
|
||||
{
|
||||
label: '比率',
|
||||
classNo: classNo,
|
||||
excellent: excellentRate,
|
||||
good: goodRate,
|
||||
pass: passRate,
|
||||
fail: failRate
|
||||
},
|
||||
{
|
||||
label: '优良率',
|
||||
classNo: classNo,
|
||||
excellent: excellentGoodRate,
|
||||
good: '-',
|
||||
pass: '-',
|
||||
fail: '-'
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
classNo: classNo,
|
||||
excellent: '-',
|
||||
good: '-',
|
||||
pass: '-',
|
||||
fail: '-'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 获取数据列表
|
||||
const getDataList = async () => {
|
||||
if (!queryForm.schoolYear || !queryForm.schoolTerm || !queryForm.classCode) {
|
||||
useMessage().warning('请选择学年、学期和班级')
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getStuConductTerm({
|
||||
schoolYear: queryForm.schoolYear,
|
||||
schoolTerm: queryForm.schoolTerm,
|
||||
classCode: queryForm.classCode
|
||||
})
|
||||
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
// 处理返回的数据,提取学生列表
|
||||
// 根据API文档,返回的是StuConductTermVO数组
|
||||
const tempList: any[] = []
|
||||
|
||||
res.data.forEach((item: any) => {
|
||||
// 如果返回的数据结构中有basicStudentVOList,需要展开
|
||||
if (item.basicStudentVOList && Array.isArray(item.basicStudentVOList) && item.basicStudentVOList.length > 0) {
|
||||
item.basicStudentVOList.forEach((student: any) => {
|
||||
tempList.push({
|
||||
stuNo: student.stuNo || item.stuNo,
|
||||
realName: student.realName || item.realName,
|
||||
score: item.score, // 学期总评分数
|
||||
classNo: item.classNo,
|
||||
classCode: item.classCode
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// 直接使用item作为学生信息
|
||||
tempList.push({
|
||||
stuNo: item.stuNo,
|
||||
realName: item.realName,
|
||||
score: item.score,
|
||||
classNo: item.classNo,
|
||||
classCode: item.classCode
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
studentList.value = tempList
|
||||
} else {
|
||||
studentList.value = []
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('获取数据列表失败', err)
|
||||
useMessage().error(err.msg || '获取数据列表失败')
|
||||
studentList.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
searchFormRef.value?.resetFields()
|
||||
queryForm.schoolYear = ''
|
||||
queryForm.schoolTerm = ''
|
||||
queryForm.classCode = ''
|
||||
studentList.value = []
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleView = (row: any) => {
|
||||
// 可以跳转到详情页面或打开详情弹窗
|
||||
useMessage().info('查看详情功能待实现')
|
||||
}
|
||||
|
||||
// 获取学年列表
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
const res = await queryAllSchoolYear()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data
|
||||
} else {
|
||||
schoolYearList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学年列表失败', err)
|
||||
schoolYearList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取学期字典
|
||||
const getSchoolTermDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('school_term')
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolTermList.value = res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
}))
|
||||
} else {
|
||||
schoolTermList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学期字典失败', err)
|
||||
schoolTermList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await getClassListByRole()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data
|
||||
} else {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
getSchoolTermDict()
|
||||
getClassListData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.layout-padding {
|
||||
.layout-padding-auto {
|
||||
.layout-padding-view {
|
||||
.el-row {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 确保页面可以滚动
|
||||
.layout-padding {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
.layout-padding-auto {
|
||||
height: 100%;
|
||||
|
||||
.layout-padding-view {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
334
src/views/stuwork/stuconduct/indexYear.vue
Normal file
334
src/views/stuwork/stuconduct/indexYear.vue
Normal file
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<!-- 搜索表单 -->
|
||||
<el-row v-show="showSearch">
|
||||
<el-form :model="queryForm" ref="searchFormRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select
|
||||
v-model="queryForm.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<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="班级" prop="classCode">
|
||||
<el-select
|
||||
v-model="queryForm.classCode"
|
||||
placeholder="请选择班级"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in classList"
|
||||
:key="item.classCode"
|
||||
:label="item.classNo"
|
||||
:value="item.classCode">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" plain icon="Search" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<!-- 统计表格 -->
|
||||
<el-row style="margin-bottom: 20px;">
|
||||
<el-table
|
||||
:data="statisticsData"
|
||||
v-loading="loading"
|
||||
border
|
||||
style="width: 100%"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column prop="label" label="" width="120" align="center" fixed="left" />
|
||||
<el-table-column prop="classNo" label="班级" min-width="150" align="center" />
|
||||
<el-table-column prop="excellent" label="优秀" min-width="100" align="center" />
|
||||
<el-table-column prop="good" label="良好" min-width="100" align="center" />
|
||||
<el-table-column prop="pass" label="及格" min-width="100" align="center" />
|
||||
<el-table-column prop="fail" label="不及格" min-width="100" align="center" />
|
||||
</el-table>
|
||||
</el-row>
|
||||
|
||||
<!-- 学生列表表格 -->
|
||||
<el-row>
|
||||
<el-table
|
||||
:data="studentList"
|
||||
v-loading="loading"
|
||||
border
|
||||
:max-height="600"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="score" label="学年总评" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.score !== null && scope.row.score !== undefined ? scope.row.score.toFixed(2) : '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="View"
|
||||
text
|
||||
type="primary"
|
||||
@click="handleView(scope.row)">
|
||||
查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="StuConductYear">
|
||||
import { reactive, ref, onMounted, computed } from 'vue'
|
||||
import { getStuConductYear } from "/@/api/stuwork/stuconduct";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
|
||||
// 表格样式 - 在组件内部定义,不从外部导入
|
||||
const tableStyle = {
|
||||
cellStyle: { padding: '8px 0' },
|
||||
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' }
|
||||
}
|
||||
|
||||
// 定义变量内容
|
||||
const searchFormRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const loading = ref(false)
|
||||
const schoolYearList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
const studentList = ref<any[]>([])
|
||||
|
||||
// 查询表单
|
||||
const queryForm = reactive({
|
||||
schoolYear: '',
|
||||
classCode: ''
|
||||
})
|
||||
|
||||
// 统计表格数据
|
||||
const statisticsData = computed(() => {
|
||||
if (studentList.value.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
// 计算各等级人数
|
||||
// 优秀:>=90,良好:80-89,及格:60-79,不及格:<60
|
||||
let excellent = 0 // 优秀
|
||||
let good = 0 // 良好
|
||||
let pass = 0 // 及格
|
||||
let fail = 0 // 不及格
|
||||
const total = studentList.value.length
|
||||
|
||||
studentList.value.forEach((student: any) => {
|
||||
const score = student.score
|
||||
if (score !== null && score !== undefined) {
|
||||
if (score >= 90) {
|
||||
excellent++
|
||||
} else if (score >= 80) {
|
||||
good++
|
||||
} else if (score >= 60) {
|
||||
pass++
|
||||
} else {
|
||||
fail++
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 计算比率
|
||||
const excellentRate = total > 0 ? ((excellent / total) * 100).toFixed(2) + '%' : '0%'
|
||||
const goodRate = total > 0 ? ((good / total) * 100).toFixed(2) + '%' : '0%'
|
||||
const passRate = total > 0 ? ((pass / total) * 100).toFixed(2) + '%' : '0%'
|
||||
const failRate = total > 0 ? ((fail / total) * 100).toFixed(2) + '%' : '0%'
|
||||
|
||||
// 优良率 = (优秀 + 良好) / 总人数
|
||||
const excellentGoodCount = excellent + good
|
||||
const excellentGoodRate = total > 0 ? ((excellentGoodCount / total) * 100).toFixed(2) + '%' : '0%'
|
||||
|
||||
// 获取班级名称
|
||||
const classNo = studentList.value.length > 0 ? (studentList.value[0].classNo || '-') : '-'
|
||||
|
||||
return [
|
||||
{
|
||||
label: '人数',
|
||||
classNo: classNo,
|
||||
excellent: excellent,
|
||||
good: good,
|
||||
pass: pass,
|
||||
fail: fail
|
||||
},
|
||||
{
|
||||
label: '比率',
|
||||
classNo: classNo,
|
||||
excellent: excellentRate,
|
||||
good: goodRate,
|
||||
pass: passRate,
|
||||
fail: failRate
|
||||
},
|
||||
{
|
||||
label: '优良率',
|
||||
classNo: classNo,
|
||||
excellent: excellentGoodRate,
|
||||
good: '-',
|
||||
pass: '-',
|
||||
fail: '-'
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
classNo: classNo,
|
||||
excellent: '-',
|
||||
good: '-',
|
||||
pass: '-',
|
||||
fail: '-'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 获取数据列表
|
||||
const getDataList = async () => {
|
||||
if (!queryForm.schoolYear || !queryForm.classCode) {
|
||||
useMessage().warning('请选择学年和班级')
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getStuConductYear({
|
||||
schoolYear: queryForm.schoolYear,
|
||||
classCode: queryForm.classCode
|
||||
})
|
||||
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
// 处理返回的数据,提取学生列表
|
||||
// 根据API文档,返回的是StuConductYearVO数组
|
||||
const tempList: any[] = []
|
||||
|
||||
res.data.forEach((item: any) => {
|
||||
// 如果返回的数据结构中有basicStudentVOList,需要展开
|
||||
if (item.basicStudentVOList && Array.isArray(item.basicStudentVOList) && item.basicStudentVOList.length > 0) {
|
||||
item.basicStudentVOList.forEach((student: any) => {
|
||||
tempList.push({
|
||||
stuNo: student.stuNo || item.stuNo,
|
||||
realName: student.realName || item.realName,
|
||||
score: item.score, // 学年总评分数
|
||||
classNo: item.classNo,
|
||||
classCode: item.classCode
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// 直接使用item作为学生信息
|
||||
tempList.push({
|
||||
stuNo: item.stuNo,
|
||||
realName: item.realName,
|
||||
score: item.score,
|
||||
classNo: item.classNo,
|
||||
classCode: item.classCode
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
studentList.value = tempList
|
||||
} else {
|
||||
studentList.value = []
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('获取数据列表失败', err)
|
||||
useMessage().error(err.msg || '获取数据列表失败')
|
||||
studentList.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
searchFormRef.value?.resetFields()
|
||||
queryForm.schoolYear = ''
|
||||
queryForm.classCode = ''
|
||||
studentList.value = []
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleView = (row: any) => {
|
||||
// 可以跳转到详情页面或打开详情弹窗
|
||||
useMessage().info('查看详情功能待实现')
|
||||
}
|
||||
|
||||
// 获取学年列表
|
||||
const getSchoolYearList = async () => {
|
||||
try {
|
||||
const res = await queryAllSchoolYear()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
schoolYearList.value = res.data
|
||||
} else {
|
||||
schoolYearList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学年列表失败', err)
|
||||
schoolYearList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await getClassListByRole()
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
classList.value = res.data
|
||||
} else {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getSchoolYearList()
|
||||
getClassListData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.layout-padding {
|
||||
.layout-padding-auto {
|
||||
.layout-padding-view {
|
||||
.el-row {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 确保页面可以滚动
|
||||
.layout-padding {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
.layout-padding-auto {
|
||||
height: 100%;
|
||||
|
||||
.layout-padding-view {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user