1
This commit is contained in:
@@ -32,7 +32,7 @@ export const importComment = (file: File) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return request({
|
||||
url: '/ems/emsqualityreport/importComment',
|
||||
url: '/ems/file/importStudentComment',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: {
|
||||
@@ -47,7 +47,7 @@ export const importComment = (file: File) => {
|
||||
*/
|
||||
export const setClassStartTime = (data: any) => {
|
||||
return request({
|
||||
url: '/ems/emsqualityreport/setClassStartTime',
|
||||
url: '/ems/emsopenschooltime/edit',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
@@ -66,3 +66,14 @@ export const exportExcel = (query?: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出学生评语模板
|
||||
*/
|
||||
export const exportStudentCommentTemplate = () => {
|
||||
return request({
|
||||
url: '/ems/file/exportStudentCommentTemplate',
|
||||
method: 'get',
|
||||
responseType: 'blob'
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -278,9 +278,9 @@ import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObj, putObjs, classExportData, getDeptList, getClassListByRole } from "/@/api/basic/basicclass";
|
||||
import { makeExportClassOverviewTask } from "/@/api/stuwork/file";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { fetchList as getRuleList } from "/@/api/stuwork/entrancerule";
|
||||
import { downBlobFile, adaptationUrl } from "/@/utils/other";
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
|
||||
import { List, OfficeBuilding, Grid, Document, UserFilled, Phone, User, Lock, CircleCheck, TrendCharts, Setting, Menu, Search } from '@element-plus/icons-vue'
|
||||
import { useTableColumnControl } from '/@/hooks/tableColumn'
|
||||
@@ -467,8 +467,8 @@ const confirmLinkRule = async () => {
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await downBlobFile(adaptationUrl('/basic/basicclass/classExportData'), searchForm, '班级信息.xlsx')
|
||||
useMessage().success('导出成功')
|
||||
await makeExportClassOverviewTask(searchForm)
|
||||
useMessage().success('导出任务已创建,请在文件管理中下载')
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导出失败')
|
||||
}
|
||||
|
||||
@@ -388,10 +388,10 @@
|
||||
<SimpleEditDialog ref="simpleEditDialogRef" @refresh="getDataList(false)" />
|
||||
|
||||
<!-- 段段清证书导入对话框 -->
|
||||
<el-dialog
|
||||
title="段段清证书导入"
|
||||
<el-dialog
|
||||
title="段段清证书导入"
|
||||
v-model="importCertificateDialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-click-modal="false"
|
||||
draggable
|
||||
width="500px">
|
||||
<el-upload
|
||||
@@ -416,6 +416,44 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 学生信息导出字段选择弹窗 -->
|
||||
<el-dialog
|
||||
title="选择导出字段"
|
||||
v-model="exportFieldDialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
draggable
|
||||
width="600px">
|
||||
<div class="export-field-container">
|
||||
<div class="field-header">
|
||||
<el-checkbox
|
||||
v-model="exportFieldCheckAll"
|
||||
:indeterminate="exportFieldIndeterminate"
|
||||
@change="handleExportFieldCheckAllChange">
|
||||
全选
|
||||
</el-checkbox>
|
||||
<el-button type="primary" link @click="handleExportFieldReset">重置</el-button>
|
||||
</div>
|
||||
<el-divider />
|
||||
<el-checkbox-group v-model="selectedExportFields" class="field-checkbox-group">
|
||||
<el-checkbox
|
||||
v-for="field in exportFieldOptions"
|
||||
:key="field.value"
|
||||
:label="field.value"
|
||||
class="field-checkbox">
|
||||
{{ field.label }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="exportFieldDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleExportFieldConfirm" :loading="exportFieldLoading" :disabled="selectedExportFields.length === 0">
|
||||
确认导出
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -448,6 +486,7 @@ import { downBlobFile, adaptationUrl } from "/@/utils/other";
|
||||
import { Session } from "/@/utils/storage";
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
|
||||
import GenderTag from '/@/components/GenderTag/index.vue'
|
||||
import {makeExportClassRoomHygieneMonthlyTask} from "/@/api/stuwork/file";
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
@@ -472,6 +511,12 @@ const selectedRows = ref<any[]>([])
|
||||
const importCertificateDialogVisible = ref(false)
|
||||
const uploadLoading = ref(false)
|
||||
const fileList = ref<any[]>([])
|
||||
// 导出字段选择相关
|
||||
const exportFieldDialogVisible = ref(false)
|
||||
const exportFieldLoading = ref(false)
|
||||
const selectedExportFields = ref<string[]>([])
|
||||
const exportFieldCheckAll = ref(false)
|
||||
const exportFieldIndeterminate = ref(false)
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
@@ -499,6 +544,36 @@ const visibleColumns = ref<string[]>([])
|
||||
// 列排序顺序
|
||||
const columnOrder = ref<string[]>([])
|
||||
|
||||
// 导出字段选项
|
||||
const exportFieldOptions = [
|
||||
{ value: 'deptName', label: '学院' },
|
||||
{ value: 'majorName', label: '专业' },
|
||||
{ value: 'className', label: '班级' },
|
||||
{ value: 'classNo', label: '班号' },
|
||||
{ value: 'stuNo', label: '学号' },
|
||||
{ value: 'realName', label: '姓名' },
|
||||
{ value: 'gender', label: '性别' },
|
||||
{ value: 'idCard', label: '身份证号' },
|
||||
{ value: 'birthday', label: '出生日期' },
|
||||
{ value: 'nation', label: '民族' },
|
||||
{ value: 'politicalStatus', label: '政治面貌' },
|
||||
{ value: 'phone', label: '个人电话' },
|
||||
{ value: 'parentPhone', label: '家长电话' },
|
||||
{ value: 'education', label: '文化程度' },
|
||||
{ value: 'householdType', label: '户口性质' },
|
||||
{ value: 'householdAddress', label: '户籍所在地' },
|
||||
{ value: 'currentAddress', label: '现住址' },
|
||||
{ value: 'isDorm', label: '是否住宿' },
|
||||
{ value: 'dormNo', label: '宿舍号' },
|
||||
{ value: 'enrollStatus', label: '学籍状态' },
|
||||
{ value: 'stuStatus', label: '学生状态' },
|
||||
{ value: 'teacherName', label: '班主任' },
|
||||
{ value: 'isClassLeader', label: '是否班干部' },
|
||||
{ value: 'bankCard', label: '银行卡号' },
|
||||
{ value: 'bankName', label: '开户行' },
|
||||
{ value: 'remark', label: '备注' }
|
||||
]
|
||||
|
||||
// 从本地统一存储加载配置
|
||||
const loadSavedConfig = () => {
|
||||
const routePath = route.path.replace(/^\//, '').replace(/\//g, '-')
|
||||
@@ -654,8 +729,56 @@ const handleSelectionChange = (selection: any[]) => {
|
||||
}
|
||||
|
||||
// 学生信息导出
|
||||
const handleExportStudent = async () => {
|
||||
useMessage().warning('功能开发中')
|
||||
const handleExportStudent = () => {
|
||||
// 打开字段选择弹窗
|
||||
exportFieldDialogVisible.value = true
|
||||
// 默认选中常用字段
|
||||
if (selectedExportFields.value.length === 0) {
|
||||
selectedExportFields.value = ['deptName', 'majorName', 'className', 'stuNo', 'realName', 'gender', 'idCard', 'phone', 'education', 'enrollStatus']
|
||||
}
|
||||
updateExportFieldCheckAll()
|
||||
}
|
||||
|
||||
// 全选/取消全选
|
||||
const handleExportFieldCheckAllChange = (val: boolean) => {
|
||||
selectedExportFields.value = val ? exportFieldOptions.map(item => item.value) : []
|
||||
exportFieldIndeterminate.value = false
|
||||
}
|
||||
|
||||
// 更新全选状态
|
||||
const updateExportFieldCheckAll = () => {
|
||||
const total = exportFieldOptions.length
|
||||
const selected = selectedExportFields.value.length
|
||||
exportFieldCheckAll.value = selected === total
|
||||
exportFieldIndeterminate.value = selected > 0 && selected < total
|
||||
}
|
||||
|
||||
// 重置选择
|
||||
const handleExportFieldReset = () => {
|
||||
selectedExportFields.value = ['deptName', 'majorName', 'className', 'stuNo', 'realName', 'gender', 'idCard', 'phone', 'education', 'enrollStatus']
|
||||
updateExportFieldCheckAll()
|
||||
}
|
||||
|
||||
// 确认导出
|
||||
const handleExportFieldConfirm = async () => {
|
||||
if (selectedExportFields.value.length === 0) {
|
||||
useMessage().warning('请至少选择一个导出字段')
|
||||
return
|
||||
}
|
||||
|
||||
exportFieldLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
...searchForm,
|
||||
fields: selectedExportFields.value.join(',')
|
||||
}
|
||||
await exportStudentData(params)
|
||||
useMessage().success('导出任务已创建,请在文件管理中下载')
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导出失败')
|
||||
} finally {
|
||||
exportFieldLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 申请顶岗
|
||||
@@ -889,3 +1012,30 @@ onMounted(() => {
|
||||
getStuStatusListData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.export-field-container {
|
||||
.field-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.field-checkbox-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
padding: 10px;
|
||||
|
||||
.field-checkbox {
|
||||
width: calc(25% - 12px);
|
||||
margin-right: 0;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
width: calc(50% - 12px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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