1
This commit is contained in:
@@ -88,25 +88,25 @@
|
||||
<!-- 操作按钮 -->
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button
|
||||
icon="Upload"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
<el-button
|
||||
icon="Upload"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="handleImportComment">
|
||||
评语导入
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Calendar"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
<el-button
|
||||
icon="Calendar"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="handleSetClassStartTime">
|
||||
设置班级开学时间
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="handleExport">
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="handleExportIntroduction">
|
||||
名单导出
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
@@ -131,15 +131,22 @@
|
||||
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="comment" label="评语" show-overflow-tooltip align="center" min-width="200" />
|
||||
<el-table-column prop="parentalMsg" label="家长寄语" show-overflow-tooltip align="center" min-width="200" />
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="200" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="Edit"
|
||||
text
|
||||
type="primary"
|
||||
<el-button
|
||||
icon="Edit"
|
||||
text
|
||||
type="primary"
|
||||
@click="handleEdit(scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Document"
|
||||
text
|
||||
type="success"
|
||||
@click="handleExportSingle(scope.row)">
|
||||
导出评语
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -155,12 +162,15 @@
|
||||
<edit-dialog ref="editDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 评语导入弹窗 -->
|
||||
<el-dialog
|
||||
title="评语导入"
|
||||
v-model="importDialogVisible"
|
||||
:width="500"
|
||||
:close-on-click-modal="false"
|
||||
<el-dialog
|
||||
title="评语导入"
|
||||
v-model="importDialogVisible"
|
||||
:width="500"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<div style="text-align: center; margin-bottom: 20px">
|
||||
<el-button type="success" :icon="Download" @click="handleDownloadTemplate">下载模板</el-button>
|
||||
</div>
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
:auto-upload="false"
|
||||
@@ -187,11 +197,11 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 设置班级开学时间弹窗 -->
|
||||
<el-dialog
|
||||
title="设置班级开学时间"
|
||||
v-model="startTimeDialogVisible"
|
||||
:width="500"
|
||||
:close-on-click-modal="false"
|
||||
<el-dialog
|
||||
title="设置班级开学时间"
|
||||
v-model="startTimeDialogVisible"
|
||||
:width="500"
|
||||
:close-on-click-modal="false"
|
||||
draggable>
|
||||
<el-form
|
||||
ref="startTimeFormRef"
|
||||
@@ -199,6 +209,35 @@
|
||||
:rules="startTimeRules"
|
||||
label-width="120px"
|
||||
v-loading="startTimeLoading">
|
||||
<el-form-item label="学年" prop="schoolYear">
|
||||
<el-select
|
||||
v-model="startTimeForm.schoolYear"
|
||||
placeholder="请选择学年"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%">
|
||||
<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="startTimeForm.schoolTerm"
|
||||
placeholder="请选择学期"
|
||||
clearable
|
||||
style="width: 100%">
|
||||
<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="startTimeForm.classCode"
|
||||
@@ -217,10 +256,10 @@
|
||||
<el-form-item label="开学时间" prop="startTime">
|
||||
<el-date-picker
|
||||
v-model="startTimeForm.startTime"
|
||||
type="date"
|
||||
type="datetime"
|
||||
placeholder="选择开学时间"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
value-format="YYYY-MM-DD HH:mm"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -237,13 +276,14 @@
|
||||
<script setup lang="ts" name="QualityReport">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, importComment, setClassStartTime, exportExcel } from "/@/api/ems/qualityReport";
|
||||
import { fetchList, importComment, setClassStartTime, exportExcel, exportStudentCommentTemplate } from "/@/api/ems/qualityReport";
|
||||
import { exportClassAssetsIntroduction, downloadBlobFile } from "/@/api/stuwork/file";
|
||||
import { getDeptList } from "/@/api/basic/basicclass";
|
||||
import { getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import { UploadFilled, Download } from '@element-plus/icons-vue'
|
||||
import EditDialog from './edit.vue'
|
||||
|
||||
// 定义变量内容
|
||||
@@ -265,14 +305,23 @@ const startTimeLoading = ref(false)
|
||||
// 设置班级开学时间表单
|
||||
const startTimeForm = reactive({
|
||||
classCode: '',
|
||||
classNo: '',
|
||||
schoolYear: '',
|
||||
schoolTerm: '',
|
||||
startTime: ''
|
||||
})
|
||||
|
||||
// 设置班级开学时间表单验证规则
|
||||
const startTimeRules = {
|
||||
schoolYear: [
|
||||
{ required: true, message: '请选择学年', trigger: 'change' }
|
||||
],
|
||||
classCode: [
|
||||
{ required: true, message: '请选择班级', trigger: 'change' }
|
||||
],
|
||||
schoolTerm: [
|
||||
{ required: true, message: '请选择学期', trigger: 'change' }
|
||||
],
|
||||
startTime: [
|
||||
{ required: true, message: '请选择开学时间', trigger: 'change' }
|
||||
]
|
||||
@@ -339,6 +388,24 @@ const handleFileChange = (file: any) => {
|
||||
importFile.value = file.raw
|
||||
}
|
||||
|
||||
// 下载模板
|
||||
const handleDownloadTemplate = async () => {
|
||||
try {
|
||||
const res = await exportStudentCommentTemplate()
|
||||
const blob = res instanceof Blob ? res : (res.data instanceof Blob ? res.data : new Blob([res.data || res]))
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = '学生评语导入模板.xlsx'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
document.body.removeChild(link)
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '下载模板失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 提交导入
|
||||
const handleImportSubmit = async () => {
|
||||
if (!importFile.value) {
|
||||
@@ -365,6 +432,9 @@ const handleImportSubmit = async () => {
|
||||
const handleSetClassStartTime = () => {
|
||||
startTimeDialogVisible.value = true
|
||||
startTimeForm.classCode = ''
|
||||
startTimeForm.classNo = ''
|
||||
startTimeForm.schoolYear = ''
|
||||
startTimeForm.schoolTerm = ''
|
||||
startTimeForm.startTime = ''
|
||||
startTimeFormRef.value?.resetFields()
|
||||
}
|
||||
@@ -372,15 +442,29 @@ const handleSetClassStartTime = () => {
|
||||
// 提交设置班级开学时间
|
||||
const handleStartTimeSubmit = async () => {
|
||||
if (!startTimeFormRef.value) return
|
||||
|
||||
|
||||
await startTimeFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
|
||||
|
||||
startTimeLoading.value = true
|
||||
try {
|
||||
// 解析开学时间
|
||||
const dateTime = startTimeForm.startTime.split(' ')
|
||||
const dateParts = dateTime[0].split('-')
|
||||
const timeParts = dateTime[1] ? dateTime[1].split(':') : ['00', '00']
|
||||
|
||||
// 查找选中班级的 classNo
|
||||
const selectedClass = classList.value.find(item => item.classCode === startTimeForm.classCode)
|
||||
const classNo = selectedClass ? selectedClass.classCode : ''
|
||||
|
||||
await setClassStartTime({
|
||||
classCode: startTimeForm.classCode,
|
||||
startTime: startTimeForm.startTime
|
||||
classNo: classNo, // 班级代码
|
||||
schoolYear: startTimeForm.schoolYear,
|
||||
schoolTerm: startTimeForm.schoolTerm || '',
|
||||
openYear: dateParts[0], // 开学年
|
||||
openMonth: dateParts[1], // 开学月
|
||||
openDate: dateParts[2], // 开学日
|
||||
openHour: timeParts[0] // 开学时
|
||||
})
|
||||
useMessage().success('设置成功')
|
||||
startTimeDialogVisible.value = false
|
||||
@@ -396,29 +480,29 @@ const handleStartTimeSubmit = async () => {
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
const res = await exportExcel(state.queryForm)
|
||||
|
||||
|
||||
// 创建blob对象
|
||||
const blob = new Blob([res as unknown as BlobPart], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
const blob = new Blob([res as unknown as BlobPart], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
})
|
||||
|
||||
|
||||
// 创建下载链接
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
|
||||
|
||||
// 设置文件名
|
||||
const fileName = `素质报告单名单_${new Date().getTime()}.xlsx`
|
||||
link.setAttribute('download', fileName)
|
||||
|
||||
|
||||
// 触发下载
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
||||
|
||||
// 清理
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
|
||||
|
||||
useMessage().success('导出成功')
|
||||
} catch (err: any) {
|
||||
console.error('导出失败', err)
|
||||
@@ -426,6 +510,107 @@ const handleExport = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 blob 是否包含错误信息(后端可能将错误以 blob 格式返回)
|
||||
const checkBlobError = async (blob: Blob): Promise<boolean> => {
|
||||
// 尝试读取 blob 内容检查是否为 JSON 错误信息
|
||||
try {
|
||||
const text = await blob.text()
|
||||
// 尝试解析为 JSON
|
||||
const errorData = JSON.parse(text)
|
||||
// 检查是否有错误标识(code 不为 0 或有 msg 字段)
|
||||
if (errorData.code !== undefined && errorData.code !== 0) {
|
||||
useMessage().error(errorData.msg || errorData.message || '操作失败')
|
||||
return true
|
||||
}
|
||||
// 如果有 msg 字段且不是成功状态
|
||||
if (errorData.msg && errorData.code !== 0) {
|
||||
useMessage().error(errorData.msg)
|
||||
return true
|
||||
}
|
||||
} catch {
|
||||
// 解析失败,不是 JSON,继续当作文件处理
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 导出班级评语(整班)
|
||||
const handleExportIntroduction = async () => {
|
||||
// 验证是否选择了班级
|
||||
if (!state.queryForm.classCode || !state.queryForm.schoolYear || !state.queryForm.schoolTerm) {
|
||||
useMessage().warning('请先选择班级 学年 学期')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const params = {
|
||||
classCode: state.queryForm.classCode,
|
||||
schoolYear: state.queryForm.schoolYear,
|
||||
schoolTerm: state.queryForm.schoolTerm,
|
||||
classNo: state.queryForm.classCode
|
||||
// 不传 stuNo 则整班导出
|
||||
}
|
||||
|
||||
const res = await exportClassAssetsIntroduction(params)
|
||||
|
||||
// 创建 blob 对象(docx 格式)- response 直接包含文件数据
|
||||
const blob = res instanceof Blob ? res : (res.data instanceof Blob ? res.data : new Blob([res.data || res]))
|
||||
|
||||
// 检查是否是错误响应(blob 中包含 JSON 错误信息)
|
||||
const isError = await checkBlobError(blob)
|
||||
if (isError) return
|
||||
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `班级评语_${state.queryForm.classCode}.docx`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
document.body.removeChild(link)
|
||||
|
||||
useMessage().success('导出成功')
|
||||
} catch (err: any) {
|
||||
console.error('导出班级评语失败', err)
|
||||
useMessage().error(err.msg || '导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 导出单个学生评语
|
||||
const handleExportSingle = async (row: any) => {
|
||||
try {
|
||||
const params = {
|
||||
classCode: row.classCode || state.queryForm.classCode,
|
||||
schoolYear: state.queryForm.schoolYear,
|
||||
schoolTerm: state.queryForm.schoolTerm,
|
||||
classNo: state.queryForm.classCode,
|
||||
stuNo: row.stuNo // 传学号则是单人导出
|
||||
}
|
||||
|
||||
const res = await exportClassAssetsIntroduction(params)
|
||||
|
||||
// 创建 blob 对象(docx 格式)- response 直接包含文件数据
|
||||
const blob = res instanceof Blob ? res : (res.data instanceof Blob ? res.data : new Blob([res.data || res]))
|
||||
|
||||
// 检查是否是错误响应(blob 中包含 JSON 错误信息)
|
||||
const isError = await checkBlobError(blob)
|
||||
if (isError) return
|
||||
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `学生评语_${row.realName || row.stuNo}.docx`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
document.body.removeChild(link)
|
||||
|
||||
useMessage().success('导出成功')
|
||||
} catch (err: any) {
|
||||
console.error('导出学生评语失败', err)
|
||||
useMessage().error(err.msg || '导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑
|
||||
const handleEdit = (row: any) => {
|
||||
editDialogRef.value?.openDialog(row)
|
||||
|
||||
Reference in New Issue
Block a user