From 6f1b2cf3dc89059104ca0eedebf5f3ec4d1147f0 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 26 十一月 2025 11:08:17 +0800
Subject: [PATCH] 打印
---
src/views/ecg/doctor/components/RoutinePanel.vue | 45 +++++++++++++++++++++++++++++++++++++++++++--
vite.config.ts | 2 +-
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/views/ecg/doctor/components/RoutinePanel.vue b/src/views/ecg/doctor/components/RoutinePanel.vue
index 9b31f4a..076ce48 100644
--- a/src/views/ecg/doctor/components/RoutinePanel.vue
+++ b/src/views/ecg/doctor/components/RoutinePanel.vue
@@ -266,10 +266,51 @@
formRef.value?.resetFields()
}
const yddownload = async () => {
- await DoctorApi.yddownload(props.setappointmentId)
+ const obj = await DoctorApi.yddownload(props.setappointmentId)
+ console.log(obj,'xml');
+
+ downloadWordFile(obj, '骞虫澘杩愬姩蹇冪數鍥剧煡鎯呭悓鎰忎功.doc');
}
const sgdownload = async () => {
- await DoctorApi.sgdownload(props.setappointmentId)
+ const obj = await DoctorApi.sgdownload(props.setappointmentId)
+ downloadWordFile(obj, '椋熺蹇冭剰鐢电敓鐞嗚瘖鐤楃煡鎯呭悓鎰忎功.doc');
+}
+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
diff --git a/vite.config.ts b/vite.config.ts
index e64a8ba..b924e33 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -33,7 +33,7 @@
['/admin-api']: {
// target: 'http://192.168.100.120:48080',
target: 'http://localhost:8095',
- // target: 'http://192.168.100.194:48080',
+ // target: 'http://192.168.100.141:48080',
ws: false,
changeOrigin: true,
// rewrite: (path) => path.replace(new RegExp(`^/admin-api`), ''),
--
Gitblit v1.9.3