From 956c83afe2c0f4b63753dcecd58ce552afcdd252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=92?= Date: Sat, 13 Sep 2025 20:16:40 +0800 Subject: [PATCH] 1 --- src/views/system/jdorder/orderList.vue | 57 ++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/src/views/system/jdorder/orderList.vue b/src/views/system/jdorder/orderList.vue index fcd5dcb..f652e37 100644 --- a/src/views/system/jdorder/orderList.vue +++ b/src/views/system/jdorder/orderList.vue @@ -41,9 +41,9 @@ - + - + @@ -59,9 +59,20 @@ - + proPriceAmount @@ -166,6 +177,44 @@ export default { /** 导出按钮操作 */ handleExport() { this.download('/system/jdorder/export', this.queryParams, `京东订单数据_${new Date().getTime()}.xlsx`) + }, + /** 复制到剪贴板 */ + copyToClipboard(text) { + if (navigator.clipboard && window.isSecureContext) { + // 使用现代 Clipboard API + navigator.clipboard.writeText(text).then(() => { + this.$message.success('物流链接已复制到剪贴板') + }).catch(() => { + this.fallbackCopyTextToClipboard(text) + }) + } else { + // 降级方案 + this.fallbackCopyTextToClipboard(text) + } + }, + /** 降级复制方案 */ + fallbackCopyTextToClipboard(text) { + const textArea = document.createElement('textarea') + textArea.value = text + textArea.style.position = 'fixed' + textArea.style.left = '-999999px' + textArea.style.top = '-999999px' + document.body.appendChild(textArea) + textArea.focus() + textArea.select() + + try { + const successful = document.execCommand('copy') + if (successful) { + this.$message.success('物流链接已复制到剪贴板') + } else { + this.$message.error('复制失败,请手动复制') + } + } catch (err) { + this.$message.error('复制失败,请手动复制') + } + + document.body.removeChild(textArea) } } }