From 0ef47a49fa6dce546be2d0f23b4949734e6a0cf9 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 29 Jan 2026 18:31:55 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/jagzwxm/ja_web

---
 applications/task-work-order/src/views/orderView/organizational/zoningManagement/index.vue |   61 +++++++++++++++++++++++++++---
 1 files changed, 54 insertions(+), 7 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 bdcccd5..c1f3dbc 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
@@ -40,7 +40,7 @@
     <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" @click="handleExport">导出区划</el-button>
+      <el-button :icon="Download" :loading="exportLoading" :disabled="exportLoading" @click="handleExport">导出区划</el-button>
     </div>
 
     <div class="gd-table-container" v-loading="loading">
@@ -102,17 +102,27 @@
       @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 size="small" type="primary">点击上传</el-button>
+            <el-button type="primary">点击上传</el-button>
           </el-upload>
         </el-form-item>
       </el-form>
       <template #footer>
         <el-button color="#F2F3F5" @click="isShowImportView = false">取消</el-button>
         <el-button
-          class=""
           color="#4C34FF"
           :loading="importSubmitting"
           :disabled="importSubmitting"
@@ -135,6 +145,7 @@
   zoningRemoveApi,
   zoningImportApi,
   zoningExportApi,
+  zoningExportTemplateApi,
   regionLazyTreeApi,
   zoningSubmitApi
 } from './zoningApi'
@@ -171,6 +182,12 @@
 const importRules = ref({
   file: [{ required: true, message: '请上传文件', trigger: ['change'] }],
 })
+
+// 导出加载状态
+const exportLoading = ref(false)
+
+// 模板导出加载状态
+const templateExportLoading = ref(false)
 
 provide('regionOptions', regionOptions)
 provide('dictObj', dictObj)
@@ -264,8 +281,32 @@
   }
 }
 
+// 导出模板
+async function handleExportTemplate() {
+  templateExportLoading.value = true
+  try {
+    const res = await zoningExportTemplateApi()
+    const blob = new Blob([res.data])
+    const url = URL.createObjectURL(blob)
+    const a = document.createElement('a')
+    a.href = url
+    a.download = `区划导入模板.xlsx`
+    document.body.appendChild(a)
+    a.click()
+    document.body.removeChild(a)
+    URL.revokeObjectURL(url)
+  } catch (error) {
+    console.error('导出模板失败:', error)
+  } finally {
+    templateExportLoading.value = false
+  }
+}
+
 // 上传文件前处理
 function onImportFileBefore(file) {
+  // 提示请先导出模板
+  // ElMessage.warning('请先导出模板并按模板格式填写数据')
+  
   // 检查文件类型
   const allowedTypes = ['.xlsx', '.xls']
   const fileExtension = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
@@ -313,18 +354,24 @@
 }
 
 // 导出区划
-function handleExport() {
-  zoningExportApi(searchParams.value).then(res => {
+async function handleExport() {
+  exportLoading.value = true
+  try {
+    const res = await zoningExportApi(searchParams.value)
     const blob = new Blob([res.data])
     const url = URL.createObjectURL(blob)
     const a = document.createElement('a')
     a.href = url
-    a.download = `区划列表${new Date().getTime()}.xlsx`
+    a.download = `区划列表.xlsx`
     document.body.appendChild(a)
     a.click()
     document.body.removeChild(a)
     URL.revokeObjectURL(url)
-  })
+  } catch (error) {
+    console.error('导出失败:', error)
+  } finally {
+    exportLoading.value = false
+  }
 }
 
 onMounted(() => {

--
Gitblit v1.9.3