From d60b1396df45de76c6bae6aa75c15602dd4c2570 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Sat, 31 Jan 2026 14:22:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue | 80 ++++++++++++++++++++++++---------------
1 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue b/applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue
index c1f3dbc..400ce59 100644
--- a/applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue
+++ b/applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue
@@ -39,13 +39,14 @@
<div class="gd-table-toolbar">
<el-button :icon="Plus" color="#4C34FF" type="primary" @click="openForm('add')">新增区划</el-button>
- <el-button :icon="Upload" @click="handleImport">导入区划</el-button>
- <el-button :icon="Download" :loading="exportLoading" :disabled="exportLoading" @click="handleExport">导出区划</el-button>
+ <el-button :icon="Upload" @click="handleImport">区划导入</el-button>
+ <el-button :icon="Download" :loading="exportLoading" :disabled="exportLoading" @click="handleExport">区划导出</el-button>
</div>
<div class="gd-table-container" v-loading="loading">
<div class="gd-table-content gd-table-content-bg">
- <el-table class="gd-table" :data="list">
+ <el-table class="gd-table" :data="list" @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="46" />
<el-table-column label="序号" width="80">
<template v-slot="{ $index }">
{{ $index + 1 }}
@@ -95,29 +96,29 @@
class="gd-dialog"
append-to-body
v-model="isShowImportView"
- title="导入区划"
- :width="pxToRem(600)"
+ title="区划导入"
+ :width="pxToRem(500)"
:close-on-click-modal="false"
:destroy-on-close="true"
@close="handleImportClose"
>
<el-form class="gd-dialog-form" ref="importFormRef" :model="importParams" :rules="importRules" label-width="140px">
<el-form-item label="导出模板">
- <!-- :loading="templateExportLoading"
- :disabled="templateExportLoading" -->
<el-button
type="primary"
color="#F2F3F5"
@click="handleExportTemplate"
>
- 点击导出
+ 下载模板
</el-button>
</el-form-item>
<el-form-item label="上传文件" prop="file">
- {{ importFileName }}
<el-upload class="avatar-uploader" action="" :show-file-list="false" :before-upload="onImportFileBefore">
<el-button type="primary">点击上传</el-button>
</el-upload>
+ <div class="upload-tip">
+ {{ importFileName }}
+ </div>
</el-form-item>
</el-form>
<template #footer>
@@ -169,6 +170,7 @@
const dialogVisible = ref(false)
const regionOptions = ref([]) // 区域选项
const dictObj = ref({}) // 字典对象
+const selectedFiles = ref([]) // 勾选的文件列表
// 导入区划相关
const isShowImportView = ref(false)
@@ -281,6 +283,11 @@
}
}
+// 勾选值设置
+function handleSelectionChange(rows) {
+ selectedFiles.value = rows
+}
+
// 导出模板
async function handleExportTemplate() {
templateExportLoading.value = true
@@ -304,9 +311,6 @@
// 上传文件前处理
function onImportFileBefore(file) {
- // 提示请先导出模板
- // ElMessage.warning('请先导出模板并按模板格式填写数据')
-
// 检查文件类型
const allowedTypes = ['.xlsx', '.xls']
const fileExtension = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
@@ -314,21 +318,11 @@
ElMessage.error('请上传Excel文件(.xlsx 或 .xls)')
return false
}
- let data = new FormData()
- data.append('file', file)
-
- zoningImportApi(data, { isCovered: importParams.value.isCovered }).then(res => {
- if (res.data.code === 200) {
- ElMessage.success('导入成功')
- // 保存文件名
- importFileName.value = file.name
- importParams.value.file = file
- isShowImportView.value = false
- getList()
- } else {
- ElMessage.error(res.msg || '导入失败')
- }
- })
+
+ // 保存文件名和文件对象
+ importFileName.value = file.name
+ importParams.value.file = file
+ ElMessage.success('上传成功')
return false // 阻止组件的默认上传行为
}
@@ -344,8 +338,18 @@
ElMessage.error('请先上传文件')
return
}
- // 触发上传操作
- await onImportFileBefore(importParams.value.file)
+
+ // 构建表单数据并调用导入接口
+ let data = new FormData()
+ data.append('file', importParams.value.file)
+ const res = await zoningImportApi(data, { isCovered: importParams.value.isCovered })
+ if (res.data.code === 200) {
+ ElMessage.success('导入成功')
+ isShowImportView.value = false
+ getList()
+ } else {
+ ElMessage.error(res.msg || '导入失败')
+ }
} finally {
importSubmitting.value = false
}
@@ -355,14 +359,25 @@
// 导出区划
async function handleExport() {
+ // 检查是否有选中的数据
+ if (selectedFiles.value.length === 0) {
+ ElMessage.warning('请选择要导出的区划')
+ return
+ }
+
exportLoading.value = true
try {
- const res = await zoningExportApi(searchParams.value)
+ const params = {}
+ params.regionIds = selectedFiles.value.map(i => i.id)
+ // 调用导出API
+ const res = await zoningExportApi(params)
const blob = new Blob([res.data])
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
- a.download = `区划列表.xlsx`
+ const fileName = `区划列表.xlsx`
+ a.download = fileName
+
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
@@ -381,4 +396,7 @@
</script>
<style scoped lang="scss">
+.upload-tip {
+margin-left: 5px;
+}
</style>
\ No newline at end of file
--
Gitblit v1.9.3