This commit is contained in:
Teo
2025-08-30 08:18:27 +08:00
parent 3b1ad5cd05
commit 8b57f957b6
6 changed files with 48 additions and 16 deletions

View File

@ -42,10 +42,13 @@
<el-col :span="1.5">
<el-upload ref="uploadRef" class="upload-demo" :http-request="handleImport" :show-file-list="false">
<template #trigger>
<el-button plain type="primary">导入excel</el-button>
<el-button plain type="primary" icon="upload">导入excel</el-button>
</template>
</el-upload>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Download" @click="exportFile">导出模版</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@ -521,7 +524,24 @@ const handleImport = (options: { file: File }) => {
loading.value = false;
});
};
const exportFile = () => {
// 导出模版文件
try {
// 创建a标签
const link = document.createElement('a');
// 设置PDF文件路径 - 相对于public目录
link.href = '/dikuai.xlsx';
// 设置下载后的文件名
link.download = '地块信息导入模版.xlsx';
// 触发点击
document.body.appendChild(link);
link.click();
// 清理
document.body.removeChild(link);
} catch (error) {
alert('下载失败,请重试');
}
};
/** 下载导入模板 */
const downloadTemplate = () => {
try {