Prechádzať zdrojové kódy

下载表格调接口

duy 2 rokov pred
rodič
commit
90122656fe

+ 9 - 0
src/api/modules/data-fill/wbs.js

@@ -323,4 +323,13 @@ export default {
             params: form,
         }, msg)
     },
+    //下载模板
+    async downloadExcel(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-manager/wbsTreeContract/download-excel',
+            method: 'get',
+            responseType: 'blob',
+            params: form,
+        }, msg)
+    },
 }

+ 43 - 5
src/views/data-fill/collapse-form/index.vue

@@ -156,13 +156,13 @@
                         <div class="table-tip-foot">
                             <div class="tip-left-btn">
                                 <HcTooltip keys="wbs_import_table">
-                                    <div class="text-gray-400 dow-text">
+                                    <div class="text-gray-400 dow-text" @click="importModal">
                                         <HcIcon name="publish" ui="text-lg" />
                                         <span class="ml-1">导入列表数据</span>
                                     </div>
                                 </HcTooltip>
                                 <HcTooltip keys="wbs_download_table">
-                                    <div class="text-main dow-text">
+                                    <div class="text-main dow-text" @click="downModal(item)">
                                         <HcIcon name="file_download" ui="text-lg" />
                                         <span class="ml-1">下载导入模板</span>
                                     </div>
@@ -401,8 +401,8 @@ import HcFormula from './formula.vue'
 import HcCopy from './test-copy.vue'
 import NoDataSvg from '~src/assets/view/no-data.svg'
 import {
-    arrIndex, deepClone, getArrValue,
-    getObjVal, getObjValue, isNullES, setPosRange,
+    arrIndex, deepClone, downloadBlob,
+    getArrValue, getObjVal, getObjValue, isNullES, setPosRange,
 } from 'js-fast-way'
 import { delMessageV2 } from '~com/message/index.js'
 //参数
@@ -642,7 +642,7 @@ const setTableFormMenu = (info) => {
     newArr.push({ label: '关联试验数据', key: 'test' })
     newArr.push({ label: '关联试验文件', key: 'file' })
     newArr.push({ label: '公式参数', key: 'formula' })
-    if (isStatus.value === 1 || isStatus.value === '' || isStatus.value === null || isStatus.value === 2) {
+    if (isStatus.value !== 3) {
         newArr.push({ label: '清除数据', key: 'clear' })
     }
     
@@ -1502,7 +1502,45 @@ const getActiveKey = () => {
 const setActiveKey = (key) => {
     return ActiveKey.value = key
 }
+//导入模板
+const importModal = ()=>{
 
+}
+const downloadLoading = ref(false)
+const getdownloadExcel = async (pKeyId)=>{
+    downloadLoading.value = true
+    const { error, disposition, res } = await wbsApi.downloadExcel({ pKeyId: pKeyId })
+      //处理数据
+      downloadLoading.value = false
+    if (!error) {
+        if (disposition) {
+            downloadBlob(res, disposition)
+        } else {
+            window.$message?.error('数据异常')
+        }
+    }
+}
+//下载模板
+const downModal = (item)=>{
+    const { pkeyId } = item
+    if (isStatus.value === 3) {
+        window?.$messageBox?.alert('是否选择把数据一起导出?', '下载模板', {
+            showCancelButton: true,
+            confirmButtonText: '是',
+            cancelButtonText: '否',
+            callback: (action) => {
+                if (action === 'confirm') {
+                    console.log('数据')
+                } else if ( action === 'cancel') {
+                    console.log('清表')
+                    getdownloadExcel(pkeyId)
+                }
+            },
+        })
+    } else {
+        console.log('清表')
+    }
+}
 // 暴露出去
 defineExpose({
     getFormData,