Browse Source

feat(数据填充): 添加工程Excel模板下载功能

duy 4 months ago
parent
commit
74c87dbad1
2 changed files with 31 additions and 4 deletions
  1. 8 0
      src/api/modules/data-fill/division.js
  2. 23 4
      src/views/data-fill/division.vue

+ 8 - 0
src/api/modules/data-fill/division.js

@@ -98,5 +98,13 @@ export default {
             params,
         })
     },
+    //导入模板
+    async downloadGongChengExcel(params) {
+        return HcApi({
+            url: '/api/blade-manager/exceltab/downloadGongChengExcel',
+            method: 'get',
+            params,
+        })
+    },
 
 }

+ 23 - 4
src/views/data-fill/division.vue

@@ -1027,13 +1027,17 @@
                     :on-exceed="handleExceed"
                     :before-upload="beforeUpload"
                 >
-                    <div class="text-80px text-gray">
-                        <i class="ri-upload-cloud-line" />
-                    </div>
-                    <div class="mt-24px text-black">将文件拖动到此处,或点击上传</div>
+                    <div class="mt-24px text-black">将文件拖动到此处,<span class="text-blue">或点击上传</span></div>
                     <div class="mt-8px text-12px">支持的文件格式:.xls,.xlsx</div>
                 </el-upload>
+                <div class="text-right">
+                    <el-button hc-btn type="success" :loading="downLoadTemplateLoading" @click="downLoadTemplate">
+                        <HcIcon name="download-2" />
+                        导入模板
+                    </el-button>
+                </div>
             </div>
+            
             <template #footer>
                 <el-button @click="divisionImportDialog = false">取消</el-button>
                 <el-button type="primary" :loading="confirmLoading" @click="confirmTap">确认上传</el-button>
@@ -1093,6 +1097,7 @@ import {
     arrIndex,
     arrToId,
     deepClone,
+    downloadBlob,
     formValidate,
     getArrValue,
     getObjValue,
@@ -2687,6 +2692,20 @@ const confirmTap = ()=>{
 
     
 }
+//导入模板
+const downLoadTemplate = async ()=>{
+    downLoadTemplateLoading.value = true
+    const { error, disposition, res, msg } = await divisionApi.downloadGongChengExcel()
+    downLoadTemplateLoading.value = false
+    if (!error) {
+        if (disposition) {
+            downloadBlob(res, disposition)
+        } else {
+            window.$message?.error(msg || '数据异常')
+        }
+    }
+}
+const downLoadTemplateLoading = ref(false)
 //节点命名配置
 const nodeNameDialogShow = ref(false) 
 const editNamingConfigClick = async ()=>{