活动子项导入

This commit is contained in:
yaojian
2026-03-12 10:45:02 +08:00
parent 6dc986144c
commit c54a8d05bb
2 changed files with 34 additions and 3 deletions

View File

@@ -123,7 +123,10 @@
<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>
<div class="el-upload__tip">
只能上传 xlsx/xls 文件
<el-link type="primary" :underline="false" @click="handleDownloadTemplate">下载导入模板</el-link>
</div>
</template>
</el-upload>
<template #footer>
@@ -139,7 +142,7 @@
<script setup lang="ts" name="ActivityInfo">
import { reactive, ref } from 'vue';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { fetchList, delObj, importSub } from '/@/api/stuwork/activityinfo';
import { fetchList, delObj, importSub, downloadImportTemplate } from '/@/api/stuwork/activityinfo';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { parseTime } from '/@/utils/formatTime';
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
@@ -254,6 +257,22 @@ const handleImportSubmit = async () => {
importLoading.value = false;
}
};
// 下载导入模板
const handleDownloadTemplate = async () => {
try {
const res = await downloadImportTemplate();
const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = '活动子项导入模板.xlsx';
link.click();
window.URL.revokeObjectURL(url);
} catch (err: any) {
useMessage().error(err.msg || '下载模板失败');
}
};
</script>
<style scoped lang="scss">