土地流转(地块信息、进场道路(下载模板、)

This commit is contained in:
2025-08-25 19:58:42 +08:00
parent 369ba1ad20
commit 70db0367e1
9 changed files with 118 additions and 239 deletions

View File

@ -27,6 +27,16 @@
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['land:enterRoad:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Plus" @click="downloadTemplate" v-hasPermi="['land:enterRoad:import']">模板下载</el-button>
</el-col>
<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>
</template>
</el-upload>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['land:enterRoad:remove']"
>删除</el-button
@ -92,7 +102,7 @@
</template>
<script setup name="EnterRoad" lang="ts">
import { listEnterRoad, getEnterRoad, delEnterRoad, addEnterRoad, updateEnterRoad } from '@/api/system/landTransfer/enterRoad';
import { listEnterRoad, getEnterRoad, delEnterRoad, addEnterRoad, updateEnterRoad ,importEnterRoad} from '@/api/system/landTransfer/enterRoad';
import { EnterRoadVO, EnterRoadQuery, EnterRoadForm } from '@/api/system/landTransfer/enterRoad/types';
import { listLandBlock } from '@/api/system/landTransfer/landBlock';
import { useUserStoreHook } from '@/store/modules/user';
@ -255,6 +265,43 @@ const listeningProject = watch(
}
);
// 导入文件
const handleImport = (options: any) => {
loading.value = true;
let formData = new FormData();
formData.append('file', options.file);
importEnterRoad(currentProject.value?.id,formData).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess(res.msg || '导入成功');
getListLand();
getList();
}
}).catch((err) => {
proxy.$modal.msgError(err.msg || '导入失败');
}).finally(() => {
loading.value = false;
});
};
// 下载模板
const downloadTemplate = () => {
// 导出模版文件
try {
// 创建a标签
const link = document.createElement('a');
// 设置PDF文件路径 - 相对于public目录
link.href = '/enterRoad.xlsx';
// 设置下载后的文件名
link.download = '道路信息导入模板.xlsx';
// 触发点击
document.body.appendChild(link);
link.click();
// 清理
document.body.removeChild(link);
} catch (error) {
alert('下载失败,请重试');
}
};
onUnmounted(() => {
listeningProject();
});