导入导出

This commit is contained in:
yaojian
2026-03-06 11:49:01 +08:00
parent 9bbfc6e736
commit c70f302247
16 changed files with 1663 additions and 237 deletions

View File

@@ -10,19 +10,26 @@
获奖活动信息列表
</span>
<div class="header-actions">
<el-button
icon="Plus"
type="primary"
<el-button
icon="Plus"
type="primary"
@click="formDialogRef.openDialog()">
新增
</el-button>
<el-button
icon="Upload"
type="primary"
class="ml10"
<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"
class="ml10"
@@ -178,7 +185,8 @@
<script setup lang="ts" name="ActivityAwards">
import { reactive, ref } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObj, importExcel } from "/@/api/stuwork/activityawards";
import { fetchList, delObj } from "/@/api/stuwork/activityawards";
import { exportActivityAwardsTemplate, importActivityAwards, downloadBlobFile } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { parseTime } from "/@/utils/formatTime";
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
@@ -266,28 +274,14 @@ const handleImport = () => {
uploadRef.value?.clearFiles()
}
// 导出
const handleExport = async () => {
await downloadBlobFile(exportActivityAwardsTemplate(), '活动获奖导入模板.xlsx')
}
// 下载模板
const handleDownloadTemplate = async () => {
try {
const fileName = '获奖活动信息导入模板.xlsx'
const fileUrl = new URL(`../../../assets/file/${fileName}`, import.meta.url).href
const response = await fetch(fileUrl)
if (!response.ok) {
throw new Error('文件下载失败')
}
const blob = await response.blob()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
window.URL.revokeObjectURL(url)
document.body.removeChild(link)
useMessage().success('模板下载成功')
} catch (error) {
useMessage().error('模板下载失败,请检查模板文件是否存在')
}
await downloadBlobFile(exportActivityAwardsTemplate(), '活动获奖导入模板.xlsx')
}
// 文件变化
@@ -301,10 +295,12 @@ const handleImportSubmit = async () => {
useMessage().warning('请选择要导入的文件')
return
}
importLoading.value = true
try {
await importExcel(importFile.value)
const formData = new FormData()
formData.append('file', importFile.value)
await importActivityAwards(formData)
useMessage().success('导入成功')
importDialogVisible.value = false
importFile.value = null

View File

@@ -93,23 +93,30 @@
日常巡检列表
</span>
<div class="header-actions">
<el-button
icon="FolderAdd"
type="primary"
<el-button
icon="FolderAdd"
type="primary"
@click="formDialogRef.openDialog()">
新增
</el-button>
<el-button
icon="Download"
type="success"
class="ml10"
<el-button
icon="Upload"
type="success"
class="ml10"
@click="handleImport">
导入
</el-button>
<el-button
icon="Download"
type="warning"
class="ml10"
@click="handleExport">
导出
</el-button>
<el-button
icon="DataAnalysis"
type="info"
class="ml10"
<el-button
icon="DataAnalysis"
type="info"
class="ml10"
@click="handleRank">
学期统计
</el-button>
@@ -212,7 +219,15 @@
<!-- 编辑新增 -->
<FormDialog ref="formDialogRef" @refresh="getDataList(false)" />
<!-- 导入对话框 -->
<upload-excel
ref="uploadExcelRef"
:title="'导入日常巡检'"
:url="'/stuwork/classcheckdaily/import'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
<!-- 学期统计对话框 -->
<el-dialog
title="学期统计"
@@ -271,6 +286,7 @@
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs, exportData, getRank } from "/@/api/stuwork/classcheckdaily";
import { makeExportClassCheckDailyTask } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { getDeptList } from '/@/api/basic/basicclass'
import { getClassListByRole } from '/@/api/basic/basicclass'
@@ -281,15 +297,19 @@ import { useTableColumnControl } from '/@/hooks/tableColumn'
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
// 定义变量内容
const formDialogRef = ref()
const searchFormRef = ref()
const columnControlRef = ref()
const uploadExcelRef = ref()
const showSearch = ref(true)
const deptList = ref<any[]>([])
const classList = ref<any[]>([])
const schoolYearList = ref<any[]>([])
// 模板文件URL
const templateUrl = ref('/stuwork/classcheckdaily/importTemplate')
// 表格列配置
const tableColumns = [
@@ -402,22 +422,20 @@ const handleDelete = async (ids: string[]) => {
// 导出
const handleExport = async () => {
try {
const res = await exportData(searchForm)
const blob = new Blob([res.data])
const elink = document.createElement('a')
elink.download = '日常巡检.xlsx'
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
document.body.removeChild(elink)
useMessage().success('导出成功')
await makeExportClassCheckDailyTask(searchForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}
}
// 导入
const handleImport = () => {
if (uploadExcelRef.value) {
uploadExcelRef.value.show()
}
}
// 打开学期统计对话框
const handleRank = () => {
rankDialogVisible.value = true

View File

@@ -82,12 +82,26 @@
班级卫生日常检查列表
</span>
<div class="header-actions">
<el-button
icon="FolderAdd"
type="primary"
<el-button
icon="FolderAdd"
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"
class="ml10"
@@ -194,6 +208,14 @@
<!-- 编辑新增 -->
<FormDialog ref="formDialogRef" @refresh="getDataList(false)" />
<!-- 导入对话框 -->
<upload-excel
ref="uploadExcelRef"
:title="'导入日常行为'"
:url="'/stuwork/classhygienedaily/import'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
</div>
</template>
@@ -201,6 +223,7 @@
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs } from "/@/api/stuwork/classhygienedaily";
import { downloadClassHygieneDailyTemplate, makeExportClassHygieneDailyTask } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { getDeptList } from '/@/api/basic/basicclass'
import { getClassListByRole } from '/@/api/basic/basicclass'
@@ -210,14 +233,18 @@ import { useTableColumnControl } from '/@/hooks/tableColumn'
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
// 定义变量内容
const formDialogRef = ref()
const searchFormRef = ref()
const columnControlRef = ref()
const uploadExcelRef = ref()
const showSearch = ref(true)
const deptList = ref<any[]>([])
const classList = ref<any[]>([])
// 模板文件URL
const templateUrl = ref('/stuwork/classhygienedaily/importTemplate')
// 表格列配置
const tableColumns = [
@@ -292,6 +319,23 @@ const handleReset = () => {
getDataList()
}
// 导入
const handleImport = () => {
if (uploadExcelRef.value) {
uploadExcelRef.value.show()
}
}
// 导出
const handleExport = async () => {
try {
await makeExportClassHygieneDailyTask(searchForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}
}
// 删除
const handleDelete = async (ids: string[]) => {
try {

View File

@@ -274,7 +274,7 @@
<upload-excel
ref="uploadExcelRef"
:title="'导入班主任考核'"
:url="'/stuwork/classmasterevaluation/importData'"
:url="'/stuwork/file/importClassMasterEvaluation'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
@@ -323,7 +323,8 @@
<script setup lang="ts" name="ClassMasterEvaluation">
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs, exportData } from "/@/api/stuwork/classmasterevaluation";
import { fetchList, delObjs } from "/@/api/stuwork/classmasterevaluation";
import { downloadClassMasterEvaluationTemplate, makeExportClassMasterEvaluationTask } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { getDeptList } from '/@/api/basic/basicclass'
import { getClassListByRole } from '/@/api/basic/basicclass'
@@ -347,7 +348,7 @@ const classList = ref<any[]>([])
const assessmentCategoryList = ref<any[]>([])
const assessmentPointList = ref<any[]>([])
const appealDialogVisible = ref(false)
const templateUrl = ref('assets/file/班主任考核导入模板.xlsx')
const templateUrl = ref('/stuwork/file/getClassMasterEvaluationImportTemplate')
const appealForm = reactive({
id: '',
virtualClassNo: '',
@@ -472,17 +473,8 @@ const handleImport = () => {
// 导出
const handleExport = async () => {
try {
const res = await exportData(searchForm)
const blob = new Blob([res.data])
const elink = document.createElement('a')
elink.download = '班主任考核.xlsx'
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
document.body.removeChild(elink)
useMessage().success('导出成功')
await makeExportClassMasterEvaluationTask(searchForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}

View File

@@ -81,12 +81,26 @@
教室日常卫生列表
</span>
<div class="header-actions">
<el-button
icon="FolderAdd"
type="primary"
<el-button
icon="FolderAdd"
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"
:export="'stuwork_classRoomHygieneDaily_export'"
@@ -195,6 +209,14 @@
<!-- 编辑新增 -->
<FormDialog ref="formDialogRef" @refresh="getDataList(false)" />
<!-- 导入对话框 -->
<upload-excel
ref="uploadExcelRef"
:title="'导入教室日卫生'"
:url="'/stuwork/classRoomHygieneDaily/import'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
</div>
</template>
@@ -202,6 +224,7 @@
import { ref, reactive, defineAsyncComponent, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs } from "/@/api/stuwork/classroomhygienedaily";
import { downloadClassRoomHygieneDailyTemplate, makeExportClassRoomHygieneDailyTask, downloadBlobFile } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { getDeptList } from '/@/api/basic/basicclass'
import { getClassListByRole } from '/@/api/basic/basicclass'
@@ -211,15 +234,19 @@ import { useTableColumnControl } from '/@/hooks/tableColumn'
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
// 定义变量内容
const formDialogRef = ref()
const searchFormRef = ref()
const columnControlRef = ref()
const uploadExcelRef = ref()
// 搜索变量
const showSearch = ref(true)
const deptList = ref<any[]>([])
const classList = ref<any[]>([])
// 模板文件URL
const templateUrl = ref('/stuwork/classRoomHygieneDaily/import/template')
// 表格列配置
const tableColumns = [
@@ -310,12 +337,29 @@ const getClassListData = async () => {
// 导出excel
const exportExcel = () => {
downBlobFile(
'/stuwork/classRoomHygieneDaily/export',
searchForm,
'/stuwork/classRoomHygieneDaily/export',
searchForm,
'教室卫生.xlsx'
)
}
// 导入
const handleImport = () => {
if (uploadExcelRef.value) {
uploadExcelRef.value.show()
}
}
// 导出
const handleExport = async () => {
try {
await makeExportClassRoomHygieneDailyTask(searchForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {

View File

@@ -89,16 +89,23 @@
教室卫生月度分析列表
</span>
<div class="header-actions">
<el-button
icon="Upload"
type="primary"
<el-button
icon="Upload"
type="primary"
@click="handleImport">
导入
</el-button>
<el-button
icon="DocumentChecked"
type="success"
class="ml10"
<el-button
icon="Download"
type="warning"
class="ml10"
@click="handleExport">
导出
</el-button>
<el-button
icon="DocumentChecked"
type="success"
class="ml10"
@click="handleCheck">
考核
</el-button>
@@ -271,6 +278,7 @@ import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs, checkClassRoomHygieneMonthly } from "/@/api/stuwork/classroomhygienemonthly";
import { makeExportClassRoomHygieneMonthlyTask } from "/@/api/stuwork/file";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { queryAllSchoolYear } from '/@/api/basic/basicyear'
import { getDeptList } from '/@/api/basic/basicclass'
@@ -299,8 +307,8 @@ const schoolTermList = ref<any[]>([])
const deptList = ref<any[]>([])
const classList = ref<any[]>([])
const checkDialogVisible = ref(false)
// 模板文件URL
const templateUrl = ref('assets/file/教室月卫生导入模板.xlsx')
// 模板文件URL - 使用后端接口
const templateUrl = ref('/stuwork/classroomhygienemonthly/import/template')
// 表格列配置
const tableColumns = [
@@ -457,6 +465,16 @@ const handleImport = () => {
(uploadExcelRef.value as any)?.show()
}
// 导出
const handleExport = async () => {
try {
await makeExportClassRoomHygieneMonthlyTask(searchForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}
}
// 考核
const handleCheck = () => {
checkDialogVisible.value = true

View File

@@ -59,6 +59,19 @@
宿舍月卫生列表
</span>
<div class="header-actions">
<el-button
icon="Upload"
type="primary"
@click="handleImport">
导入
</el-button>
<el-button
icon="Download"
type="warning"
class="ml10"
@click="handleExport">
导出
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
class="ml10"
@@ -195,20 +208,33 @@
<el-button type="primary" @click="submitEvaluation" :loading="evalLoading">确定评比</el-button>
</template>
</el-dialog>
<!-- 导入对话框 -->
<upload-excel
ref="uploadExcelRef"
:title="'导入宿舍月卫生'"
:url="'/stuwork/file/importDormHygieneMonthly'"
:temp-url="templateUrl"
@refreshDataList="getDataList" />
</div>
</template>
<script setup lang="ts" name="DormHygieneMonthly">
import { reactive, ref, onMounted } from 'vue'
import { reactive, ref, onMounted, defineAsyncComponent } from 'vue'
import { fetchList, addObj, editObj, delObj, triggerEvaluation } from '/@/api/stuwork/dormhygienemonthly'
import { exportDormHygieneMonthlyTemplate, downloadBlobFile } from '/@/api/stuwork/file'
import { getBuildingList } from '/@/api/stuwork/dormbuilding'
import { useMessage } from '/@/hooks/message'
import { Search, Document, Plus, Edit, Delete, Promotion } from '@element-plus/icons-vue'
// 引入组件
const UploadExcel = defineAsyncComponent(() => import('/@/components/Upload/Excel.vue'));
// 定义变量内容
const searchFormRef = ref()
const formRef = ref()
const evalFormRef = ref()
const uploadExcelRef = ref()
const showSearch = ref(true)
const loading = ref(false)
const submitLoading = ref(false)
@@ -218,6 +244,8 @@ const buildingList = ref<any[]>([])
const dialogVisible = ref(false)
const evalDialogVisible = ref(false)
const dialogTitle = ref('新增宿舍月卫生')
// 模板文件URL
const templateUrl = ref('/stuwork/file/exportDormHygieneMonthlyTemplate')
// 分页
const page = reactive({
@@ -361,6 +389,18 @@ const handleEvaluation = () => {
evalDialogVisible.value = true
}
// 导入
const handleImport = () => {
if (uploadExcelRef.value) {
uploadExcelRef.value.show()
}
}
// 导出
const handleExport = async () => {
await downloadBlobFile(exportDormHygieneMonthlyTemplate(searchForm), '宿舍月卫生.xlsx')
}
// 提交评比
const submitEvaluation = async () => {
evalLoading.value = true

View File

@@ -88,19 +88,26 @@
文明班级列表
</span>
<div class="header-actions">
<el-button
icon="Plus"
type="primary"
<el-button
icon="Plus"
type="primary"
@click="formDialogRef.openDialog()">
新增
</el-button>
<el-button
icon="Upload"
type="success"
class="ml10"
<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"
class="ml10"
@@ -254,7 +261,8 @@
<script setup lang="ts" name="RewardClass">
import { reactive, ref, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObj, importExcel } from "/@/api/stuwork/rewardclass";
import { fetchList, delObj } from "/@/api/stuwork/rewardclass";
import { exportRewardClassTemplate, importRewardClass, downloadBlobFile } from "/@/api/stuwork/file";
import { getDeptList } from "/@/api/basic/basicclass";
import { getClassListByRole } from "/@/api/basic/basicclass";
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
@@ -360,29 +368,14 @@ const handleImport = () => {
uploadRef.value?.clearFiles()
}
// 导出
const handleExport = async () => {
await downloadBlobFile(exportRewardClassTemplate(), '文明班级导入模板.xlsx')
}
// 下载模板
const handleDownloadTemplate = async () => {
try {
const fileName = '文明班级导入模板.xlsx'
// 使用动态导入获取文件URL从 views/stuwork/rewardclass 到 assets/file 的相对路径
const fileUrl = new URL(`../../../assets/file/${fileName}`, import.meta.url).href
const response = await fetch(fileUrl)
if (!response.ok) {
throw new Error('文件下载失败')
}
const blob = await response.blob()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
window.URL.revokeObjectURL(url)
document.body.removeChild(link)
useMessage().success('模板下载成功')
} catch (error) {
useMessage().error('模板下载失败,请检查模板文件是否存在')
}
await downloadBlobFile(exportRewardClassTemplate(), '文明班级导入模板.xlsx')
}
// 文件变化
@@ -396,10 +389,12 @@ const handleImportSubmit = async () => {
useMessage().warning('请选择要导入的文件')
return
}
importLoading.value = true
try {
await importExcel(importFile.value)
const formData = new FormData()
formData.append('file', importFile.value)
await importRewardClass(formData)
useMessage().success('导入成功')
importDialogVisible.value = false
importFile.value = null

View File

@@ -71,19 +71,26 @@
文明宿舍列表
</span>
<div class="header-actions">
<el-button
icon="Plus"
type="primary"
<el-button
icon="Plus"
type="primary"
@click="formDialogRef.openDialog()">
新增
</el-button>
<el-button
icon="Upload"
type="success"
class="ml10"
<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"
class="ml10"
@@ -235,7 +242,8 @@
import { reactive, ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObj, importExcel } from "/@/api/stuwork/rewarddorm";
import { fetchList, delObj } from "/@/api/stuwork/rewarddorm";
import { exportRewardDormTemplate, importRewardDorm, downloadBlobFile } from "/@/api/stuwork/file";
import { queryAllSchoolYear } from "/@/api/basic/basicyear";
import { getDicts } from "/@/api/admin/dict";
import { useMessage, useMessageBox } from "/@/hooks/message";
@@ -332,29 +340,14 @@ const handleImport = () => {
uploadRef.value?.clearFiles()
}
// 导出
const handleExport = async () => {
await downloadBlobFile(exportRewardDormTemplate(), '文明宿舍导入模板.xlsx')
}
// 下载模板
const handleDownloadTemplate = async () => {
try {
const fileName = '文明宿舍导入模板.xlsx'
// 模板文件位于 views/stuwork/rewarddorm 下的 assets/file 目录
const fileUrl = new URL(`../../../assets/file/${fileName}`, import.meta.url).href
const response = await fetch(fileUrl)
if (!response.ok) {
throw new Error('下载失败')
}
const blob = await response.blob()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
window.URL.revokeObjectURL(url)
document.body.removeChild(link)
useMessage().success('下载成功')
} catch (error) {
useMessage().error('下载失败')
}
await downloadBlobFile(exportRewardDormTemplate(), '文明宿舍导入模板.xlsx')
}
// 文件变化
@@ -368,10 +361,12 @@ const handleImportSubmit = async () => {
useMessage().warning('请先选择要上传的文件')
return
}
importLoading.value = true
try {
await importExcel(importFile.value)
const formData = new FormData()
formData.append('file', importFile.value)
await importRewardDorm(formData)
useMessage().success('导入成功')
importDialogVisible.value = false
importFile.value = null

View File

@@ -289,7 +289,8 @@
import { reactive, ref, onMounted, computed, nextTick } from 'vue'
import { useRoute } from 'vue-router'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObj, importExcel, exportExcel, getStatistics } from "/@/api/stuwork/stuunionleague";
import { fetchList, delObj, getStatistics } from "/@/api/stuwork/stuunionleague";
import { exportStuUnionLeagueTemplate, importStuUnionLeague, makeExportStuUnionLeagueTask } from "/@/api/stuwork/file";
import { getClassListByRole } from "/@/api/basic/basicclass";
import { getGradeList } from "/@/api/basic/basicclass";
import { useMessage, useMessageBox } from "/@/hooks/message";
@@ -439,16 +440,18 @@ const handleImportSubmit = async () => {
useMessage().warning('请先选择要上传的文件')
return
}
const file = fileList.value[0].raw
if (!file) {
useMessage().warning('文件无效')
return
}
importLoading.value = true
try {
await importExcel(file as File)
const formData = new FormData()
formData.append('file', file as File)
await importStuUnionLeague(formData)
useMessage().success('导入成功')
importDialogVisible.value = false
fileList.value = []
@@ -463,17 +466,8 @@ const handleImportSubmit = async () => {
// 导出
const handleExport = async () => {
try {
const res = await exportExcel(state.queryForm)
const blob = new Blob([res.data as BlobPart])
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`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
useMessage().success('导出成功')
await makeExportStuUnionLeagueTask(state.queryForm)
useMessage().success('导出任务已创建,请在文件管理中下载')
} catch (err: any) {
useMessage().error(err.msg || '导出失败')
}