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/agenciesManagement/index.vue |   61 ++++++++++++++++++++++++++----
 1 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue b/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
index 5621c62..ba5a2c2 100644
--- a/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
+++ b/applications/task-work-order/src/views/orderView/organizational/agenciesManagement/index.vue
@@ -48,7 +48,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">
@@ -105,17 +105,26 @@
       @close="handleImportClose"
     >
       <el-form class="gd-dialog-form" ref="importFormRef" :model="importParams" :rules="importRules" label-width="140px">
+        <el-form-item label="导出模板">
+          <el-button 
+            color="#F2F3F5"
+            type="primary" 
+            @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"
@@ -138,6 +147,7 @@
   agenciesRemoveApi,
   agenciesImportApi,
   agenciesExportApi,
+  agenciesExportTemplateApi,
   regionLazyTreeApi,
   agenciesSubmitApi
 } from './agenciesApi'
@@ -183,6 +193,12 @@
   file: [{ required: true, message: '请上传文件', trigger: ['change'] }],
 })
 
+// 导出加载状态
+const exportLoading = ref(false)
+
+// 模板导出加载状态
+const templateExportLoading = ref(false)
+
 provide('regionOptions', regionOptions)
 provide('dictObj', dictObj)
 
@@ -217,9 +233,6 @@
     resolve([])
   }
 }
-
-
-
 // 获取列表
 async function getList() {
   loading.value = true
@@ -302,8 +315,32 @@
   }
 }
 
+// 导出模板
+async function handleExportTemplate() {
+  templateExportLoading.value = true
+  try {
+    const res = await agenciesExportTemplateApi()
+    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()
@@ -351,8 +388,10 @@
 }
 
 // 导出机构
-function handleExport() {
-  agenciesExportApi(searchParams.value).then(res => {
+async function handleExport() {
+  exportLoading.value = true
+  try {
+    const res = await agenciesExportApi(searchParams.value)
     const blob = new Blob([res.data])
     const url = URL.createObjectURL(blob)
     const a = document.createElement('a')
@@ -363,7 +402,11 @@
     a.click()
     document.body.removeChild(a)
     URL.revokeObjectURL(url)
-  })
+  } catch (error) {
+    console.error('导出失败:', error)
+  } finally {
+    exportLoading.value = false
+  }
 }
 
 onMounted(() => {

--
Gitblit v1.9.3