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) => ` + + + + + + + + + + + + + + + + ` + ) + .join('')} + + + + + + + + + + + + + + + + + + +
序号产品名称产品分类库存条码单位数量产品单价金额税率(%)税额税额合计备注
${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 || ''}
合计${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}
+
+ + + ` + + // 使用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}
+
客户:${customerName}
+
销售人员:${saleUserName}
+
结算账户:${accountName}
+
收取订金:${formData.value.depositPrice || 0}
+
+
+
备注:${formData.value.remark || ''}
+
+
订单产品清单
+ ${itemsTableHtml} +
+
优惠率(%):${formData.value.discountPercent || 0}
+
收款优惠:${formData.value.discountPrice || 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 || '(保存后生成)'}
+
出库时间:${outTime}
+
关联订单:${formData.value.orderNo || ''}
+
客户:${customerName}
+
销售人员:${saleUserName}
+
结算账户:${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) + } +}