From be6093e57d06d943d233002f2349b321673c6bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Mon, 25 Aug 2025 13:34:13 +0800 Subject: [PATCH] =?UTF-8?q?crm=20=E5=AE=A2=E6=88=B7=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=88=97=20=20=E8=B7=9F=E8=BF=9B?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E7=89=87=E7=B2=98=E8=B4=B4=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/crmpc/customer/Followadd.vue | 159 ++++++++++++++++-- src/views/crmpc/customer/index.vue | 215 ++++++++++++++++++++++--- 2 files changed, 342 insertions(+), 32 deletions(-) diff --git a/src/views/crmpc/customer/Followadd.vue b/src/views/crmpc/customer/Followadd.vue index df33770..3c37d1c 100644 --- a/src/views/crmpc/customer/Followadd.vue +++ b/src/views/crmpc/customer/Followadd.vue @@ -70,15 +70,21 @@
上传跟进截图/聊天截图 - - - +
+ +
+ +

点击上传或直接粘贴截图

+
+
+ +
@@ -383,6 +389,72 @@ // 如需同步到 form.picture form.value.picture = response.url || (response.data && response.data.file_name) || '' } + + // 处理粘贴上传 + const handlePaste = async (event: ClipboardEvent) => { + event.preventDefault() + const items = event.clipboardData?.items + if (!items) return + + for (let i = 0; i < items.length; i++) { + const item = items[i] + if (item.type.indexOf('image') !== -1) { + const file = item.getAsFile() + if (file) { + await uploadImageFile(file) + } + break + } + } + } + + // 触发文件选择 + const triggerFileInput = () => { + const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement + if (fileInput) { + fileInput.click() + } + } + + // 处理文件选择 + const handleFileChange = async (event: Event) => { + const target = event.target as HTMLInputElement + const file = target.files?.[0] + if (file) { + await uploadImageFile(file) + } + // 清空input值,允许重复选择同一文件 + target.value = '' + } + + // 上传图片文件 + const uploadImageFile = async (file: File) => { + try { + // 创建FormData + const formData = new FormData() + formData.append('file', file) + + // 使用fetch上传到服务器 + const response = await fetch(actionImageUplode, { + method: 'POST', + headers: uploadHeaders.value, + body: formData + }) + + const result = await response.json() + + if (response.ok) { + // 上传成功,调用原有的成功处理逻辑 + handleUploadSuccess(result) + ElMessage.success('图片上传成功') + } else { + ElMessage.error(result.message || '图片上传失败') + } + } catch (error) { + console.error('上传失败:', error) + ElMessage.error('图片上传失败') + } + } diff --git a/src/views/crmpc/customer/index.vue b/src/views/crmpc/customer/index.vue index d48e4d9..b7535c0 100644 --- a/src/views/crmpc/customer/index.vue +++ b/src/views/crmpc/customer/index.vue @@ -96,14 +96,41 @@ -
- - - +
+ + + + +
+ +
+ + {{ col.label }} + +
+
+
+
+ 保存 +
+
+
+
@@ -122,20 +149,47 @@ >