duy преди 2 години
родител
ревизия
f055e2bb59
променени са 1 файла, в които са добавени 20 реда и са изтрити 5 реда
  1. 20 5
      src/views/tentative/laboratory/print.vue

+ 20 - 5
src/views/tentative/laboratory/print.vue

@@ -29,14 +29,14 @@
             <HcCard :scrollbar="false" actionSize="lg">
                 <template #header>
                     <HcTooltip keys="tentative_laboratory_print_print">
-                        <el-button hc-btn>
-                            <HcIcon name="printer"/>
+                        <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>
-                            <HcIcon name="printer" fill/>
+                        <el-button hc-btn :loading="printLoading" @click="batchPrint">
+                            <HcIcon name="printer" fill />
                             <span>全部打印</span>
                         </el-button>
                     </HcTooltip>
@@ -156,7 +156,7 @@ const tableSelection = (rows) => {
 //拼接ID
 const rowsToId = (rows) => {
     return rows.map((obj) => {
-        return obj.id;
+        return obj.pkeyId;
     }).join(",")
 }
 
@@ -175,6 +175,21 @@ const onmousedown = () => {
         document.onmouseup = null;
     }
 }
+//打印
+const printLoading = ref(false)
+const batchPrint = async () => {
+    const rows = tableCheckedKeys.value;
+    const ids = rowsToId(rows)
+    //批量下载
+    printLoading.value = true
+    const {error, code, data} = await dataApi.batchPrint({pKeyIds: ids})
+    //处理数据
+    printLoading.value = false
+    const res = isString(data) ? data ?? '' : ''
+    if (!error && code === 200 && res) {
+        window.open(res, '_blank')
+    }
+}
 </script>
 
 <style lang="scss" scoped>