From 92f2177d06cc67b2055bac0331a85780a086df0b Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期日, 20 九月 2026 19:51:47 +0800
Subject: [PATCH] feat(order): 优化订单管理功能并增加设备绑定支持 - 修改生产日期字段支持清除和显示默认值 - 在标准库中增加设备绑定功能,支持模板与设备关联 - 新增价格字段用于检验项目定价管理 - 增强模板绑定界面,支持多选和设备分配操作

---
 src/components/Onlyoffice/onlyoffice.vue |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/components/Onlyoffice/onlyoffice.vue b/src/components/Onlyoffice/onlyoffice.vue
index 1c1e261..cfafc9f 100644
--- a/src/components/Onlyoffice/onlyoffice.vue
+++ b/src/components/Onlyoffice/onlyoffice.vue
@@ -1,6 +1,15 @@
 <!--onlyoffice 缂栬緫鍣�-->
 <template>
-  <div id="vabOnlyOffice"></div>
+  <div class="document-preview">
+    <iframe
+      v-if="isPdf"
+      :key="option.url"
+      :src="option.url"
+      class="native-pdf-preview"
+      title="PDF棰勮"
+    ></iframe>
+    <div v-else id="vabOnlyOffice"></div>
+  </div>
 </template>
 
 <script>
@@ -55,6 +64,11 @@
       }
     };
   },
+  computed: {
+    isPdf() {
+      return this.isPdfFile(this.option);
+    }
+  },
   created() {
     if(this.options){
       const option = this.options
@@ -106,10 +120,12 @@
     },
     async setEditor(option) {
       this.destroyEditor();
-      // 娌℃湁鏂囨。鍦板潃灏变笉鍒濆鍖栫紪杈戝櫒锛岄伩鍏嶈闂皻鏈姞杞界殑 DocsAPI
-      if (!option || !option.url) {
+      // PDF 浣跨敤娴忚鍣ㄥ師鐢熼瑙堬紱鍏朵粬鏂囨。鎵嶅垵濮嬪寲 OnlyOffice銆�
+      if (!option || !option.url || this.isPdfFile(option)) {
         return;
       }
+      // 绛夊緟 v-else 涓殑 OnlyOffice 瀹瑰櫒瀹屾垚娓叉煋銆�
+      await this.$nextTick();
       this.doctype = this.getFileType(option.fileType);
       let config = {
         document: {
@@ -162,6 +178,14 @@
         return;
       }
       this.docEditor = new window.DocsAPI.DocEditor("vabOnlyOffice", config);
+    },
+    isPdfFile(option) {
+      if (!option) {
+        return false;
+      }
+      const fileType = String(option.fileType || "").toLowerCase();
+      const url = String(option.url || "").split(/[?#]/)[0].toLowerCase();
+      return fileType === "pdf" || url.endsWith(".pdf");
     },
     getFileType(fileType) {
       let docType = "";
@@ -227,6 +251,16 @@
 </script>
 
 <style scoped>
+.document-preview,
+.native-pdf-preview,
+#vabOnlyOffice {
+  width: 100%;
+  height: 100%;
+}
+.native-pdf-preview {
+  display: block;
+  border: 0;
+}
 html,
 body {
   height: 100%;

--
Gitblit v1.9.3