ソースを参照

feat(ledger): 添加水项目内页下载功能

duy 5 ヶ月 前
コミット
adf92ed172

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

@@ -82,6 +82,14 @@ export default {
             responseType: 'blob',
         })
     },
+    async downloadNeiYe(form) {
+        return HcApi({
+            url: '/api/blade-business/neiYeController/downloadNeiYe',
+            method: 'post',
+            params: form,
+            responseType: 'blob',
+        })
+    },
     //批量打印
     async batchPrint(form) {
         return HcApi({

+ 30 - 6
src/views/ledger/components/internal.vue

@@ -48,16 +48,16 @@
             </div>
         </template>
         <template #extra>
-            <HcTooltip keys="write_industry_download">
+            <HcTooltip v-if="!isWaterProject" keys="write_industry_download">
                 <el-button :disabled="tableInternalKeys.length <= 0" :loading="downloadLoading" hc-btn type="primary" @click="batchDownload">
                     <HcIcon name="download" />
                     <span>下载</span>
                 </el-button>
             </HcTooltip>
-            <HcTooltip keys="write_industry_print">
-                <el-button :disabled="tableInternalKeys.length <= 0" :loading="printLoading" hc-btn @click="batchPrint">
-                    <HcIcon name="printer" />
-                    <span>打印</span>
+            <HcTooltip v-if="isWaterProject" keys="write_industry_download">
+                <el-button :disabled="tableWaterKeys.length <= 0" :loading="waterDownloadLoading" hc-btn type="primary" @click="waterBatchDownload">
+                    <HcIcon name="download" />
+                    <span>下载</span>
                 </el-button>
             </HcTooltip>
         </template>
@@ -91,7 +91,7 @@
 
         <HcTable
             v-if="isWaterProject" :column="tableWaterColumn" :datas="tableWaterData"
-            :loading="tableWaterLoading" is-new :index-style="{ width: 60 }"
+            :loading="tableWaterLoading" is-new :index-style="{ width: 60 }" is-check @selection-change="tableWaterSelection"
         />
     </HcNewCard>
 </template>
@@ -318,7 +318,31 @@ const batchDownload = async () => {
         }
     }
 }
+const waterDownloadLoading = ref(false)
+const tableWaterKeys = ref([])
+const tableWaterSelection = (rows) => {
+    tableWaterKeys.value = rows.filter((item) => {
+        return (item ?? '') !== ''
+    })
+}
 
+const waterBatchDownload = async () => {
+    const rows = tableWaterKeys.value
+  
+    const ids = arrToId(rows)
+    //批量下载
+    waterDownloadLoading.value = true
+    const { error, disposition, res } = await queryApi.downloadNeiYe({ ids: ids })
+    //处理数据
+    waterDownloadLoading.value = false
+    if (!error) {
+        if (disposition) {
+            downloadBlob(res, disposition)
+        } else {
+            window.$message?.error('选择的资料未生成文件')
+        }
+    }
+}
 //打印
 const printLoading = ref(false)
 const batchPrint = async () => {