فهرست منبع

台账管理下载打印功能提交

duy 2 سال پیش
والد
کامیت
089b393782
2فایلهای تغییر یافته به همراه75 افزوده شده و 4 حذف شده
  1. 44 2
      src/views/ledger/components/internal.vue
  2. 31 2
      src/views/ledger/components/weather.vue

+ 44 - 2
src/views/ledger/components/internal.vue

@@ -33,13 +33,13 @@
         </template>
         <template #extra>
             <HcTooltip keys="write_industry_download">
-                <el-button type="primary" hc-btn :disabled="tableInternalKeys.length <= 0">
+                <el-button type="primary" hc-btn :disabled="tableInternalKeys.length <= 0"  @click="batchDownload"  :loading="downloadLoading">
                     <HcIcon name="download"/>
                     <span>下载</span>
                 </el-button>
             </HcTooltip>
             <HcTooltip keys="write_industry_print">
-                <el-button hc-btn :disabled="tableInternalKeys.length <= 0">
+                <el-button hc-btn :disabled="tableInternalKeys.length <= 0" :loading="printLoading" @click="batchPrint">
                     <HcIcon name="printer"/>
                     <span>打印</span>
                 </el-button>
@@ -244,4 +244,46 @@ const tableInternalSelection = (rows) => {
         return (item??'') !== '';
     })
 }
+//拼接ID
+const rowsToId = (rows) => {
+    return rows.map((obj) => {
+        return obj.id;
+    }).join(",")
+}
+//下载
+const downloadLoading = ref(false)
+const batchDownload = async () => {
+    const rows = tableInternalKeys.value;
+    console.log(rows,'rows');
+    const ids = rowsToId(rows)
+    //批量下载
+    downloadLoading.value = true
+    const {error, disposition, res} = await queryApi.batchDownloadFileToZip({ids: ids})
+    //处理数据
+    downloadLoading.value = false
+    if (!error) {
+        if (disposition) {
+            downloadBlob(res, disposition)
+        } else {
+            window.$message?.error('数据异常')
+        }
+    }
+}
+
+//打印
+const printLoading = ref(false)
+const batchPrint = async () => {
+    const rows = tableInternalKeys.value;
+    const ids = rowsToId(rows)
+    //批量下载
+    printLoading.value = true
+    const {error, code, data} = await queryApi.batchPrint({ids: ids})
+    //处理数据
+    printLoading.value = false
+    const res = isString(data) ? data ?? '' : ''
+    if (!error && code === 200 && res) {
+        window.open(res, '_blank')
+    }
+}
+
 </script>

+ 31 - 2
src/views/ledger/components/weather.vue

@@ -10,13 +10,13 @@
         </template>
         <template #extra>
             <HcTooltip keys="write_weather_print">
-                <el-button hc-btn>
+                <el-button hc-btn  :loading="printLoading" @click="batchPrint">
                     <HcIcon name="printer"/>
                     <span>打印</span>
                 </el-button>
             </HcTooltip>
         </template>
-        <HcTable :column="tableWeatherColumn" :datas="tableWeatherData" :loading="tableWeatherLoading">
+        <HcTable :column="tableWeatherColumn" :datas="tableWeatherData" :loading="tableWeatherLoading" isCheck  @selection-change="tableWeatherSelection">
             <template #tempLow="{row}">{{ row['tempLow'] }} ~ {{ row['tempHigh'] }}</template>
             <template #action="{row}">
                 <HcTooltip keys="write_weather_edit">
@@ -72,6 +72,7 @@
 import {ref, nextTick} from "vue";
 import {deepClone, formValidate, getArrValue} from "vue-utils-plus"
 import weatherApi from '~api/ledger/weather';
+import queryApi from '~api/data-fill/query';
 
 //参数
 const props = defineProps({
@@ -231,4 +232,32 @@ const saveWeatherClick = async () => {
         }
     }
 }
+//多选
+const tableweatherKeys = ref([]);
+const tableWeatherSelection = (rows) => {
+    tableweatherKeys.value = rows.filter((item) => {
+        return (item??'') !== '';
+    })
+}
+//拼接ID
+const rowsToId = (rows) => {
+    return rows.map((obj) => {
+        return obj.id;
+    }).join(",")
+}
+//打印
+const printLoading = ref(false)
+const batchPrint = async () => {
+    const rows = tableweatherKeys.value;
+    const ids = rowsToId(rows)
+    //批量下载
+    printLoading.value = true
+    const {error, code, data} = await queryApi.batchPrint({ids: ids})
+    //处理数据
+    printLoading.value = false
+    const res = isString(data) ? data ?? '' : ''
+    if (!error && code === 200 && res) {
+        window.open(res, '_blank')
+    }
+}
 </script>