From 3f49860639e6d5245f1e011fbe3b3aaff70dbb6c Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 26 十一月 2025 13:36:24 +0800
Subject: [PATCH] 打印

---
 src/views/ecg/doctor/components/RoutinePanel.vue |   72 ++++++++++++++++++++++++++++++------
 1 files changed, 60 insertions(+), 12 deletions(-)

diff --git a/src/views/ecg/doctor/components/RoutinePanel.vue b/src/views/ecg/doctor/components/RoutinePanel.vue
index 908f54e..204b1e9 100644
--- a/src/views/ecg/doctor/components/RoutinePanel.vue
+++ b/src/views/ecg/doctor/components/RoutinePanel.vue
@@ -39,7 +39,6 @@
             placeholder="閫夋嫨瑁呮満鏃堕棿"
           />
         </el-form-item>
-        
       </el-col>
       <el-col :span="12">
         <el-form-item label="妫�鏌ラ」鐩�" prop="">
@@ -49,15 +48,8 @@
           <el-input v-model="formData.remark" placeholder="璇疯緭鍏ュ娉�" />
         </el-form-item>
         <el-form-item label="鏄惁澶氳��" prop="tolerance">
-          <el-radio-group v-model="formData.tolerance" readonly>
-            <el-radio
-              v-for="dict in getIntDictOptions(DICT_TYPE.ecg_tolerance)"
-              :key="dict.value"
-              :value="dict.value"
-            >
-              {{ dict.label }}
-            </el-radio>
-          </el-radio-group>
+          <el-tag type="info" v-if="formData.tolerance == 0">鍚�</el-tag>
+          <el-tag type="danger" v-else>鏄�</el-tag>
         </el-form-item>
       </el-col>
     </el-row>
@@ -65,6 +57,10 @@
   <el-button @click="submitForm" type="primary" :disabled="formLoading">妫�鏌ュ畬鎴�</el-button>
   <el-button @click="cancelInstall" :disabled="formLoading">鏀惧純妫�鏌�</el-button>
   <el-button @click="resetForm()">閲� 缃�</el-button>
+  <el-button @click="yddownload()" :loading="yddownloadLoading"
+    :disabled="yddownloadLoading">骞虫澘杩愬姩蹇冪數鍥剧煡鎯呭悓鎰忎功</el-button>
+  <el-button @click="sgdownload()" :loading="sgdownloadLoading"
+    :disabled="sgdownloadLoading">椋熺蹇冭剰鐢电敓鐞嗚瘖鐤楃煡鎯呭悓鎰忎功</el-button>
   <el-button
     v-if="needAutoFeeConfirm(formData.checkType)"
     @click="feeConfirm"
@@ -158,7 +154,7 @@
 import { isStringEmpty } from '@/utils/stringUtil'
 import { curDayEnd, curDayStart } from '@/utils/dateUtil'
 import { QueueVO } from '@/api/ecg/queue'
-import { RoomBedVO } from '@/api/ecg/doctor'
+import { RoomBedVO, DoctorApi } from '@/api/ecg/doctor'
 import { Barcode } from '@/components/Barcode'
 import { useCheckTypeStore } from '@/store/modules/checkType'
 import { getCheckTypeName, needAutoFeeConfirm } from '../../../../utils/checkTypeFormatter'
@@ -170,6 +166,11 @@
   room: {
     type: Object as PropType<RoomBedVO>,
     required: true
+  },
+  setappointmentId: {
+    type: [String, Number],
+    required: false,
+    default: null
   }
 })
 
@@ -193,7 +194,8 @@
 const message = useMessage() // 娑堟伅寮圭獥
 
 const dialogVisible = ref(false) // 寮圭獥鐨勬槸鍚﹀睍绀�
-
+const yddownloadLoading = ref(false);
+const sgdownloadLoading = ref(false);
 const formLoading = ref(false) // 琛ㄥ崟鐨勫姞杞戒腑锛�1锛変慨鏀规椂鐨勬暟鎹姞杞斤紱2锛夋彁浜ょ殑鎸夐挳绂佺敤
 
 const formData = ref<Partial<DevRentVO>>({
@@ -266,7 +268,53 @@
   }
   formRef.value?.resetFields()
 }
+const yddownload = async () => {
+  const response = await DoctorApi.yddownload(props.setappointmentId)
+  console.log(response, 'xml1')
+  console.log(response.fileContent, 'xml2')
+  downloadWordFile(response.fileContent, response.fileName)
+}
+const sgdownload = async () => {
+  const response = await DoctorApi.sgdownload(props.setappointmentId)
+  downloadWordFile(response.fileContent, response.fileName)
+}
+const downloadWordFile = (data, filename = 'document') => {
+  try {
+    // 1. 纭繚鏂囦欢鍚嶄互.doc缁撳熬
+    if (!filename.endsWith('.doc')) {
+      filename += '.doc'
+    }
 
+    // 2. 鍒涘缓Blob瀵硅薄锛屾寚瀹歁IME绫诲瀷涓篧ord鏂囨。[9,10](@ref)
+    // 瀵逛簬Word 2003 XML鏍煎紡锛屼娇鐢�'application/msword'
+    const blob = new Blob([data], { type: 'application/msword' })
+
+    // 3. 涓築lob瀵硅薄鍒涘缓涓�涓复鏃剁殑涓嬭浇URL[8,10](@ref)
+    const url = URL.createObjectURL(blob)
+
+    // 4. 鍒涘缓涓�涓殣钘忕殑涓嶅彲瑙佺殑<a>閾炬帴鍏冪礌[10](@ref)
+    const link = document.createElement('a')
+    link.style.display = 'none' // 闅愯棌閾炬帴
+    link.href = url
+    link.download = filename // 璁剧疆涓嬭浇鐨勬枃浠跺悕
+
+    // 5. 灏嗛摼鎺ユ坊鍔犲埌DOM涓紝妯℃嫙鐐瑰嚮锛岀劧鍚庣Щ闄ゅ畠[10](@ref)
+    document.body.appendChild(link)
+    link.click()
+    document.body.removeChild(link)
+
+    // 6. 閲婃斁URL瀵硅薄浠ラ噴鏀惧唴瀛榌9,10](@ref)
+    // 浣跨敤setTimeout纭繚涓嬭浇瑙﹀彂鍚庡啀閲婃斁
+    setTimeout(() => {
+      URL.revokeObjectURL(url)
+    }, 100)
+
+    console.log('鏂囦欢涓嬭浇宸茶Е鍙戯紒')
+  } catch (error) {
+    console.error('涓嬭浇鏂囦欢鏃跺彂鐢熼敊璇�:', error)
+    // 杩欓噷鍙互娣诲姞鏇村弸濂界殑鐢ㄦ埛閿欒鎻愮ず锛屼緥濡備娇鐢╝lert鎴栭〉闈㈠脊绐�
+  }
+}
 const getRentInfoByPatId = () => {
   const tempPatId = formData.value.patId
   resetForm()

--
Gitblit v1.9.3