修复文件问题 修改bug

This commit is contained in:
2026-02-06 00:04:33 +08:00
parent 779b779910
commit de2d64210f
18 changed files with 1712 additions and 894 deletions

View File

@@ -1,13 +1,13 @@
<template>
<div class="modern-page-container">
<div class="page-wrapper">
<!-- ?????? -->
<!-- 查询条件 -->
<el-card v-show="showSearch" class="search-card" shadow="never">
<template #header>
<div class="card-header">
<span class="card-title">
<el-icon class="title-icon"><Search /></el-icon>
????
查询条件
</span>
</div>
</template>
@@ -15,7 +15,7 @@
<el-form-item label="班级" prop="classCode">
<el-select
v-model="state.queryForm.classCode"
placeholder="请选择学年"
placeholder="请选择班级"
clearable
filterable
style="width: 200px">
@@ -27,10 +27,10 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="??" prop="classNo">
<el-form-item label="班级编号" prop="classNo">
<el-input
v-model="state.queryForm.classNo"
placeholder="请输入姓名"
placeholder="请输入班级编号"
clearable
style="width: 200px" />
</el-form-item>
@@ -41,17 +41,17 @@
clearable
style="width: 200px" />
</el-form-item>
<el-form-item label="????" prop="serNo">
<el-form-item label="序列号" prop="serNo">
<el-input
v-model="state.queryForm.serNo"
placeholder="请输入奖项名称"
placeholder="请输入序列号"
clearable
style="width: 200px" />
</el-form-item>
<el-form-item label="入学年份" prop="grade">
<el-select
v-model="state.queryForm.grade"
placeholder="请输入奖项名称"
placeholder="请选择入学年份"
clearable
style="width: 200px">
<el-option
@@ -63,40 +63,40 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" plain icon="Search" @click="getDataList">??</el-button>
<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-card>
<!-- ???? -->
<!-- 数据列表 -->
<el-card class="content-card" shadow="never">
<template #header>
<div class="card-header">
<span class="card-title">
<el-icon class="title-icon"><Document /></el-icon>
??????
学生团组织列表
</span>
<div class="header-actions">
<el-button
icon="Plus"
type="primary"
@click="formDialogRef.openDialog()">
??
新增
</el-button>
<el-button
icon="Upload"
type="success"
class="ml10"
@click="handleImport">
??
导入
</el-button>
<el-button
icon="Download"
type="warning"
class="ml10"
@click="handleExport">
??
导出
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
@@ -153,11 +153,11 @@
<el-icon><component :is="columnConfigMap[col.prop]?.icon || Calendar" /></el-icon>
<span style="margin-left: 4px">{{ col.label }}</span>
</template>
<!-- ????????? -->
<!-- 入团时间格式化 -->
<template v-if="col.prop === 'enterTime'" #default="scope">
<span>{{ parseTime(scope.row.enterTime, '{y}-{m}-{d}') }}</span>
</template>
<!-- ????????? -->
<!-- 职务格式化 -->
<template v-else-if="col.prop === 'position'" #default="scope">
<el-tag v-if="scope.row.position" size="small" type="primary" effect="plain">
{{ scope.row.position }}
@@ -200,12 +200,12 @@
</el-card>
</div>
<!-- ??/?????? -->
<!-- 新增/编辑对话框 -->
<form-dialog ref="formDialogRef" @refresh="getDataList" />
<!-- ???? -->
<!-- 导入对话框 -->
<el-dialog
title="????"
title="导入数据"
v-model="importDialogVisible"
:close-on-click-modal="false"
width="500px">
@@ -220,18 +220,18 @@
drag>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">
????????<em>????</em>
将文件拖到此处<em>点击上传</em>
</div>
<template #tip>
<div class="el-upload__tip">
???? xlsx/xls ??
只能上传 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" :loading="importLoading">??</el-button>
<el-button type="primary" @click="handleImportSubmit" :loading="importLoading">确认</el-button>
</span>
</template>
</el-dialog>
@@ -254,7 +254,7 @@ import { useTableColumnControl } from '/@/hooks/tableColumn'
import type { UploadFile, UploadFiles } from 'element-plus';
import FormDialog from './form.vue'
// ??????
// 定义变量
const route = useRoute()
const formDialogRef = ref()
const columnControlRef = ref<any>()
@@ -267,19 +267,19 @@ const importDialogVisible = ref(false)
const importLoading = ref(false)
const fileList = ref<UploadFile[]>([])
// ?????
// 表格列配置
const tableColumns = [
{ prop: 'deptName', label: '????', minWidth: 150 },
{ prop: 'classNo', label: '??', width: 120 },
{ prop: 'stuNo', label: '??', width: 120 },
{ prop: 'realName', label: '??', width: 100 },
{ prop: 'phone', label: '???', width: 120 },
{ prop: 'enterTime', label: '????', width: 120 },
{ prop: 'serNo', label: '????', width: 120 },
{ prop: 'position', label: '????', width: 120 }
{ prop: 'deptName', label: '学院名称', minWidth: 150 },
{ prop: 'classNo', label: '班级', width: 120 },
{ prop: 'stuNo', label: '学号', width: 120 },
{ prop: 'realName', label: '姓名', width: 100 },
{ prop: 'phone', label: '手机号', width: 120 },
{ prop: 'enterTime', label: '入团时间', width: 120 },
{ prop: 'serNo', label: '序列号', width: 120 },
{ prop: 'position', label: '职务名称', width: 120 }
]
// ?????????????
// 列配置映射
const columnConfigMap: Record<string, { icon: any }> = {
deptName: { icon: OfficeBuilding },
classNo: { icon: Grid },
@@ -291,22 +291,22 @@ const columnConfigMap: Record<string, { icon: any }> = {
position: { icon: Briefcase }
}
// ???????hook
// 表格列控制hook
const {
visibleColumns,
visibleColumnsSorted,
checkColumnVisible,
handleColumnChange,
handleColumnOrderChange
} = useTableColumnControl(tableColumns, route.path)
} = useTableColumnControl(tableColumns)
// ????
// 表格样式
const tableStyle = {
cellStyle: { padding: '8px 0' },
headerCellStyle: { background: '#f5f7fa', color: '#606266', fontWeight: 'bold' }
}
// ?? useTable
// 使用 useTable
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
classCode: '',
@@ -331,7 +331,7 @@ const {
tableStyle: _tableStyle
} = useTable(state)
// ??
// 重置
const handleReset = () => {
searchFormRef.value?.resetFields()
state.queryForm.classCode = ''
@@ -342,70 +342,70 @@ const handleReset = () => {
getDataList()
}
// ??
// 编辑
const handleEdit = (row: any) => {
formDialogRef.value?.openDialog('edit', row)
}
// ??
// 删除
const handleDelete = async (row: any) => {
const { confirm } = useMessageBox()
try {
await confirm('???????????')
await confirm('确定要删除该记录吗?')
await delObj([row.id])
useMessage().success('????')
useMessage().success('删除成功')
getDataList()
} catch (err: any) {
if (err !== 'cancel') {
useMessage().error(err.msg || '????')
useMessage().error(err.msg || '删除失败')
}
}
}
// ??
// 导入
const handleImport = () => {
importDialogVisible.value = true
fileList.value = []
}
// ????
// 文件变化
const handleFileChange = (file: UploadFile, files: UploadFiles) => {
fileList.value = [file]
}
// ??????
// 文件超出限制
const handleExceed = () => {
useMessage().warning('????????')
useMessage().warning('文件数量超出限制')
}
// ????
// 提交导入
const handleImportSubmit = async () => {
if (fileList.value.length === 0) {
useMessage().warning('?????????')
useMessage().warning('请先选择要上传的文件')
return
}
const file = fileList.value[0].raw
if (!file) {
useMessage().warning('?????')
useMessage().warning('文件无效')
return
}
importLoading.value = true
try {
await importExcel(file as File)
useMessage().success('????')
useMessage().success('导入成功')
importDialogVisible.value = false
fileList.value = []
getDataList()
} catch (err: any) {
useMessage().error(err.msg || '????')
useMessage().error(err.msg || '导入失败')
} finally {
importLoading.value = false
}
}
// ??
// 导出
const handleExport = async () => {
try {
const res = await exportExcel(state.queryForm)
@@ -413,18 +413,18 @@ const handleExport = async () => {
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = `??_${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`
link.download = `学生团组织_${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
useMessage().success('????')
useMessage().success('导出成功')
} catch (err: any) {
useMessage().error(err.msg || '????')
useMessage().error(err.msg || '导出失败')
}
}
// ??????
// 获取班级列表
const getClassListData = async () => {
try {
const res = await getClassListByRole()
@@ -438,7 +438,7 @@ const getClassListData = async () => {
}
}
// ????????
// 获取入学年份列表
const getGradeListData = async () => {
try {
const res = await getGradeList()