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

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

@ -36,6 +36,16 @@
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['land:landBlock: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:landBlock:remove']"
>删除</el-button
@ -143,7 +153,7 @@
</template>
<script setup name="LandBlock" lang="ts">
import { listLandBlock, getLandBlock, delLandBlock, LandUnit, addLandBlock, updateLandBlock, subMatrix } from '@/api/system/landTransfer/landBlock';
import { listLandBlock, getLandBlock, delLandBlock, LandUnit, addLandBlock, updateLandBlock, subMatrix,importLandBlock } from '@/api/system/landTransfer/landBlock';
import { LandBlockVO, LandBlockQuery, LandBlockForm } from '@/api/system/landTransfer/landBlock/types';
import { useUserStoreHook } from '@/store/modules/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -388,6 +398,44 @@ const listeningProject = watch(
}
);
// 导入文件
const handleImport = (options:any) => {
loading.value = true;
let formData = new FormData();
formData.append('file', options.file);
importLandBlock(currentProject.value?.id,formData).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess(res.msg || '导入成功');
getList();
getfangzhenList();
}
}).catch((err) => {
proxy.$modal.msgError(err.msg || '导入失败');
}).finally(() => {
loading.value = false;
});
};
// 下载模板
const downloadTemplate = () => {
// 导出模版文件
try {
// 创建a标签
const link = document.createElement('a');
// 设置PDF文件路径 - 相对于public目录
link.href = '/landBlock.xlsx';
// 设置下载后的文件名
link.download = '地块信息导入模板.xlsx';
// 触发点击
document.body.appendChild(link);
link.click();
// 清理
document.body.removeChild(link);
} catch (error) {
alert('下载失败,请重试');
}
};
onUnmounted(() => {
listeningProject();
});