Browse Source

打印优化

xiaochan 2 months ago
parent
commit
27739960ac

+ 9 - 6
src/components/print-poisonous-hemp/PrintPoisonousHempTemplate.vue

@@ -71,7 +71,7 @@ const [PrintTemplate, printFunc] = useVuePrint({
   `,
 });
 
-async function printPrescription(red: boolean) {
+function printPrescription(red: boolean): any[] {
   const tmp = [];
   state.currentDrugData = [];
   const canvas = document.createElement("canvas");
@@ -79,9 +79,9 @@ async function printPrescription(red: boolean) {
 
   drugFlag.forEach(item => {
     let tmpDrug = [];
-    if (red && item.code !== "6") {
+    if (red && ["1", "2", "3"].includes(item.code)) {
       tmpDrug = state.data?.data?.["drug" + item.code]?.data || [];
-    } else if (!red && item.code === "6") {
+    } else if (!red && ["4", "5", "6"].includes(item.code)) {
       tmpDrug = state.data?.data?.["drug" + item.code]?.data || [];
     }
 
@@ -101,12 +101,15 @@ async function printPrescription(red: boolean) {
   });
   if (tmp.length > 0) {
     state.currentDrugData = tmp;
-    await nextTick();
   }
+  return tmp;
 }
 
 onMounted(() => {
   state.data = props.data;
+  if (printPrescription(true).length === 0) {
+    printPrescription(false);
+  }
 });
 
 defineExpose({
@@ -137,8 +140,8 @@ defineExpose({
       <header>
         诊断:
         <el-input v-model="state.data.diagnose" style="width: 120px" />
-        <el-button @click="printPrescription(true)">红色处方</el-button>
-        <el-button @click="printPrescription(false)">终止妊娠</el-button>
+        <el-button @click="printPrescription(true)">毒、麻、精一</el-button>
+        <el-button @click="printPrescription(false)">精二、终止妊娠</el-button>
         <el-button
           @click="
             () => {