Browse Source

打印空表全部打印

duy 2 years ago
parent
commit
b063a34ce3
1 changed files with 17 additions and 3 deletions
  1. 17 3
      src/views/tentative/laboratory/print.vue

+ 17 - 3
src/views/tentative/laboratory/print.vue

@@ -29,13 +29,13 @@
             <HcCard :scrollbar="false" actionSize="lg">
                 <template #header>
                     <HcTooltip keys="tentative_laboratory_print_print">
-                        <el-button hc-btn :loading="printLoading" @click="batchPrint">
+                        <el-button hc-btn :loading="printLoading" @click="batchPrint()">
                             <HcIcon name="printer" />
                             <span>打印</span>
                         </el-button>
                     </HcTooltip>
                     <HcTooltip keys="tentative_laboratory_print_print_all">
-                        <el-button hc-btn :loading="printLoading" @click="batchPrint">
+                        <el-button hc-btn :loading="allprintLoading" @click="batchPrintall()">
                             <HcIcon name="printer" fill />
                             <span>全部打印</span>
                         </el-button>
@@ -57,7 +57,7 @@ import WbsTree from "../../data-fill/components/WbsTree.vue"
 import TestTree from "../material/components/TestTree.vue"
 import {getStoreData, setStoreData} from '~src/utils/storage'
 import dataApi from "~api/tentative/laboratory/print"
-import {getArrValue, getArrKeyValue, isIdCard, formValidate} from "vue-utils-plus"
+import {getArrValue, getArrKeyValue, isIdCard, formValidate,isString} from "vue-utils-plus"
 
 //变量
 const useAppState = useAppStore()
@@ -177,6 +177,7 @@ const onmousedown = () => {
 }
 //打印
 const printLoading = ref(false)
+const allprintLoading=ref(false)
 const batchPrint = async () => {
     const rows = tableCheckedKeys.value;
     const ids = rowsToId(rows)
@@ -190,6 +191,19 @@ const batchPrint = async () => {
         window.open(res, '_blank')
     }
 }
+const batchPrintall=async()=>{
+    const rows = tableData.value;
+    const ids = rowsToId(rows)
+    //批量下载
+    allprintLoading.value = true
+    const {error, code, data} = await dataApi.batchPrint({pKeyIds: ids})
+    //处理数据
+    allprintLoading.value = false
+    const res = isString(data) ? data ?? '' : ''
+    if (!error && code === 200 && res) {
+        window.open(res, '_blank')
+    }
+}
 </script>
 
 <style lang="scss" scoped>