From 78a3c898908bbb8827d1c2aa6299f92ff03f5847 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 21 十月 2026 15:06:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/components/UpPdfStamp/index.vue |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/components/UpPdfStamp/index.vue b/src/components/UpPdfStamp/index.vue
index 0c6088e..fd92a4e 100644
--- a/src/components/UpPdfStamp/index.vue
+++ b/src/components/UpPdfStamp/index.vue
@@ -1,7 +1,10 @@
 <template>
   <div class="up-pdf-stamp">
     <div v-if="isUpFile" class="work" style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 10px;">
-      <input ref="fileInput" type="file" accept="application/pdf" @change="handleFileUpload" />
+      <input ref="fileInput" type="file" accept=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.wps,.et,.dps,.txt,.jpg,.jpeg,.png" @change="handleFileUpload" />
+      <span v-if="fileName !== '鏂囦欢鍚�'" style="margin-left: 10px;font-size: 12px;color: var(--el-text-color-secondary);">
+        宸查�夋嫨锛歿{ fileName }}<template v-if="!isPdfFile">锛堥潪 PDF 鏂囦欢鎸夊師鏂囦欢涓婁紶锛屼笉鏀寔鐩栫珷锛�</template>
+      </span>
     </div>
     <div v-if="canvasNumPages > 0" style="color: red;font-size: 12px;margin: 16px 0;">鎻愮ず锛氬湪鏂囦欢鑼冨洿鍐咃紝鍗曞嚮榧犳爣鐩栫珷锛屽弻鍑婚紶鏍囧凡鐩栧ソ绔犲鍙垹闄ゅ綋鍓嶇珷</div>
     <canvas
@@ -35,7 +38,9 @@
       stampHeight: 80, // 鐩栫珷楂樺害
       stampsName: '',
       stampsList: ['涓讳换', '璐ㄩ噺璐熻矗浜�', '鎶�鏈礋璐d汉'],
-      fileName: '鏂囦欢鍚�'
+      fileName: '鏂囦欢鍚�',
+      selectedFile: null, // 闈� PDF 鏂囦欢锛氫繚鐣欏師濮� File锛岀洿鎺ヤ笂浼�
+      isPdfFile: false
     }
   },
   methods: {
@@ -49,6 +54,9 @@
       const file = event.target.files[0]
       if (file.size > 20 * 1024 * 1024) {
         this.$refs.fileInput.value = '' // 娓呯┖鏂囦欢杈撳叆妗嗗唴瀹�
+        this.selectedFile = null
+        this.isPdfFile = false
+        this.fileName = '鏂囦欢鍚�'
         return this.$message.error('鏂囦欢澶у皬涓嶈兘瓒呰繃20M')
       }
       this.lookFile(file)
@@ -67,14 +75,25 @@
           this.stampsName = '缁煎悎瀹�'
         }
       }
-      if (file && file.type === 'application/pdf') {
+      this.isPdfFile = !!file && (file.type === 'application/pdf' || /\.pdf$/i.test(file.name || ''))
+      if (this.isPdfFile) {
+        this.selectedFile = file
         const reader = new FileReader()
         reader.onload = e => {
           const typedArray = new Uint8Array(e.target.result)
           this.loadPDF(typedArray)
         }
         reader.readAsArrayBuffer(file)
+      } else if (this.isUpFile) {
+        // 鏂囦欢娓呭崟涓婁紶鏀寔 Word/Excel/鍥剧墖绛夋牸寮忥紝涓嶅仛鐩栫珷锛岄�変腑鍚庢寜鍘熸枃浠朵笂浼�
+        this.selectedFile = file
+        this.pdfDoc = null
+        this.canvasNumPages = 0
+        this.stamps = []
+        this.contextList = []
       } else {
+        // 鍏朵粬娴佺▼锛堟枃浠剁敵璇枫�佸彉鏇寸敵璇风瓑锛変粛鍙鐞� PDF
+        this.selectedFile = null
         this.$message.error('璇烽�夋嫨 PDF 鏂囦欢')
       }
     },
@@ -167,8 +186,12 @@
     },
     // 鐢熸垚 PDF 鐨勫嚱鏁�
     async generatePDF() {
+      // 闈� PDF锛氫笉鐩栫珷锛屽師鏂囦欢鐩存帴涓婁紶
+      if (this.selectedFile && !this.isPdfFile) {
+        return this.$emit('uploadPDF', this.selectedFile, this.fileName)
+      }
       if (this.contextList.length === 0) {
-        this.$message({ message: '璇峰厛涓婁紶PDF鏂囦欢', type: 'error' })
+        this.$message({ message: '璇峰厛閫夋嫨鏂囦欢', type: 'error' })
         this.$emit('uploadPDFErr')
         return false
       }

--
Gitblit v1.9.3