From 30570713bff71874b1de4dc379cfcfc6d803e6e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E5=88=9D?= <3236758982@qq.com>
Date: Sat, 14 Mar 2026 14:13:35 +0800
Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95=E3=80=81?=
=?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93=E3=80=81=E9=94=80=E5=94=AE?=
=?UTF-8?q?=E8=AE=A2=E5=8D=95=E3=80=81=E9=94=80=E5=94=AE=E5=87=BA=E5=BA=93?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=93=E5=8D=B0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/erp/purchase/in/PurchaseInForm.vue | 163 +++++++++++++++++
.../erp/purchase/order/PurchaseOrderForm.vue | 158 ++++++++++++++++
src/views/erp/sale/order/SaleOrderForm.vue | 170 ++++++++++++++++++
src/views/erp/sale/out/SaleOutForm.vue | 162 +++++++++++++++++
4 files changed, 653 insertions(+)
diff --git a/src/views/erp/purchase/in/PurchaseInForm.vue b/src/views/erp/purchase/in/PurchaseInForm.vue
index ef258a2..90321c6 100644
--- a/src/views/erp/purchase/in/PurchaseInForm.vue
+++ b/src/views/erp/purchase/in/PurchaseInForm.vue
@@ -71,6 +71,9 @@
确 定
+
+ 打 印
+
取 消
@@ -292,6 +295,166 @@ const resetForm = () => {
}
formRef.value?.resetFields()
}
+
+
+/** 打印当前页面数据 */
+const handlePrint = () => {
+ // 获取供应商名称
+ const supplier = supplierList.value.find((item) => item.id === formData.value.supplierId)
+ const supplierName = supplier ? supplier.name : ''
+ // 获取结算账户名称
+ const account = accountList.value.find((item) => item.id === formData.value.accountId)
+ const accountName = account ? account.name : ''
+ // 格式化入库时间
+ const inTime = formData.value.inTime
+ ? new Date(formData.value.inTime).toLocaleDateString('zh-CN')
+ : ''
+
+ // 构建产品清单表格
+ let itemsTableHtml = ''
+ if (formData.value.items && formData.value.items.length > 0) {
+ // 计算合计
+ const totalCount = formData.value.items.reduce((sum, item) => sum + (item.count || 0), 0)
+ const totalProductPrice = formData.value.items.reduce((sum, item) => sum + (item.totalProductPrice || 0), 0)
+ const totalTaxPrice = formData.value.items.reduce((sum, item) => sum + (item.taxPrice || 0), 0)
+ const totalPriceSum = formData.value.items.reduce((sum, item) => sum + (item.totalPrice || 0), 0)
+
+ itemsTableHtml = `
+
+
+
+ | 序号 |
+ 产品名称 |
+ 产品分类 |
+ 库存 |
+ 条码 |
+ 单位 |
+ 数量 |
+ 产品单价 |
+ 金额 |
+ 税率(%) |
+ 税额 |
+ 税额合计 |
+ 备注 |
+
+
+
+ ${formData.value.items
+ .map(
+ (item, index) => `
+
+ | ${index + 1} |
+ ${item.productName || ''} |
+ ${item.productCategoryName || ''} |
+ ${item.stockCount || 0} |
+ ${item.productBarCode || ''} |
+ ${item.productUnitName || ''} |
+ ${item.count || 0} |
+ ${item.productPrice || 0} |
+ ${item.totalProductPrice || 0} |
+ ${item.taxPercent || 0} |
+ ${item.taxPrice || 0} |
+ ${item.totalPrice || 0} |
+ ${item.remark || ''} |
+
+ `
+ )
+ .join('')}
+
+
+
+ | 合计 |
+ |
+ |
+ |
+ |
+ |
+ ${totalCount} |
+ |
+ ${totalProductPrice} |
+ |
+ ${totalTaxPrice} |
+ ${totalPriceSum} |
+ |
+
+
+
+ `
+ }
+
+ // 构建打印内容
+ const printContent = `
+
+
+ 采购入库单打印
+
+
+
+ 采购入库单
+
+
入库单号:${formData.value.no || '(保存后生成)'}
+
入库时间:${inTime}
+
关联订单:${formData.value.orderNo || ''}
+
供应商:${supplierName}
+
结算账户:${accountName}
+
+
+
备注:${formData.value.remark || ''}
+
+ 入库产品清单
+ ${itemsTableHtml}
+
+
优惠率(%):${formData.value.discountPercent || 0}
+
付款优惠:${formData.value.discountPrice || 0}
+
优惠后金额:${(formData.value.totalPrice || 0) - (formData.value.otherPrice || 0)}
+
其它费用:${formData.value.otherPrice || 0}
+
应付金额:${formData.value.totalPrice || 0}
+
+
+
+ `
+
+ // 使用iframe打印,避免被浏览器拦截
+ const iframe = document.createElement('iframe')
+ iframe.style.position = 'absolute'
+ iframe.style.width = '0'
+ iframe.style.height = '0'
+ iframe.style.border = 'none'
+ iframe.style.left = '-9999px'
+ document.body.appendChild(iframe)
+
+ const iframeDoc = iframe.contentWindow?.document
+ if (iframeDoc) {
+ iframeDoc.open()
+ iframeDoc.write(printContent)
+ iframeDoc.close()
+
+ // 等待内容加载完成后打印
+ iframe.contentWindow?.focus()
+ setTimeout(() => {
+ iframe.contentWindow?.print()
+ // 打印完成后移除iframe
+ setTimeout(() => {
+ document.body.removeChild(iframe)
+ }, 1000)
+ }, 250)
+ }
+}
+
+
+
+
+ 采购订单
+
+
订单单号:${formData.value.no || '(保存后生成)'}
+
订单时间:${orderTime}
+
关联请购单:${formData.value.purchaseRequisitionNo || ''}
+
供应商:${supplierName}
+
结算账户:${accountName}
+
支付订金:${formData.value.depositPrice || 0}
+
+
+
备注:${formData.value.remark || ''}
+
+ 订单产品清单
+ ${itemsTableHtml}
+
+
优惠率(%):${formData.value.discountPercent || 0}
+
付款优惠:${formData.value.discountPrice || 0}
+
优惠后金额:${formData.value.totalPrice || 0}
+
+
+