活动子项导入
This commit is contained in:
@@ -69,11 +69,23 @@ export const importSub = (id: string, file: File) => {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
return request({
|
return request({
|
||||||
url: `/stuwork/activityinfo/importSub/${id}`,
|
url: '/stuwork/file/importActivityInfoSub',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: formData,
|
data: formData,
|
||||||
|
params: { activityInfoId: id },
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载活动子项导入模板
|
||||||
|
*/
|
||||||
|
export const downloadImportTemplate = () => {
|
||||||
|
return request({
|
||||||
|
url: '/stuwork/file/getActivityInfoSubImportTemplate',
|
||||||
|
method: 'get',
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -123,7 +123,10 @@
|
|||||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
<template #tip>
|
<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>
|
</template>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -139,7 +142,7 @@
|
|||||||
<script setup lang="ts" name="ActivityInfo">
|
<script setup lang="ts" name="ActivityInfo">
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
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 { useMessage, useMessageBox } from '/@/hooks/message';
|
||||||
import { parseTime } from '/@/utils/formatTime';
|
import { parseTime } from '/@/utils/formatTime';
|
||||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
|
import TableColumnControl from '/@/components/TableColumnControl/index.vue';
|
||||||
@@ -254,6 +257,22 @@ const handleImportSubmit = async () => {
|
|||||||
importLoading.value = false;
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user