From a0e5120c7d4e89443fe2b1c1445744d6fa3c3570 Mon Sep 17 00:00:00 2001 From: wsb1224 Date: Tue, 23 Jun 2026 01:08:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E9=80=9A=E8=BF=87=E5=90=8E=E5=89=AA=E5=88=87?= =?UTF-8?q?=E6=9D=BF=E4=BB=8D=E6=97=A0=E5=86=85=E5=AE=B9=EF=BC=9A=E5=86=85?= =?UTF-8?q?=E8=81=94=E6=9E=84=E5=BB=BA=E9=87=87=E8=B4=AD=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=97=B6=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将采购信息构建逻辑从独立方法移入 _submitApproval 回调内, 直接从 orderInfo.items 原始数据构建,绕过 this.data.products 可能未就绪的时序问题;移除未使用的 _buildProcurementText 方法。 Co-Authored-By: Claude --- .../manager/approve-detail/approve-detail.js | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/frontend/mini-app/pages/manager/approve-detail/approve-detail.js b/frontend/mini-app/pages/manager/approve-detail/approve-detail.js index d869577..f533730 100644 --- a/frontend/mini-app/pages/manager/approve-detail/approve-detail.js +++ b/frontend/mini-app/pages/manager/approve-detail/approve-detail.js @@ -261,23 +261,6 @@ Page({ } }, - _buildProcurementText: function () { - var info = this.data.orderInfo; - var products = this.data.products; - if (!info || !products || !products.length) return ""; - var lines = []; - for (var i = 0; i < products.length; i++) { - var p = products[i]; - lines.push((i + 1) + ". " + (p.name || "")); - if (p.spec) lines.push(" 规格: " + p.spec); - if (p.demandSpec) lines.push(" 需求规格: " + p.demandSpec); - if (p.qty) lines.push(" 数量: " + p.qty + (p.unit || "")); - } - if (info.remark) lines.push("备注: " + info.remark); - if (info.customer_demand) lines.push("客户需求: " + info.customer_demand); - return lines.join("\n"); - }, - _submitApproval: async function (targetUrl, payload) { var that = this; var app = getApp(); @@ -289,16 +272,28 @@ Page({ app.request({ url: targetUrl, method: "POST", data: payload, - }).then(function () { + }).then(function (res) { if (payload.approve_result === "pass") { - var text = that._buildProcurementText(); + // 从原始数据直接构建采购信息,避免 this.data 时序问题 + var orderData = that.data.orderInfo; + var text = ""; + if (orderData) { + var items = orderData.items || []; + var lines = []; + for (var i = 0; i < items.length; i++) { + var ci = items[i]; + if (!ci.product_name) continue; + lines.push((lines.length + 1) + ". " + ci.product_name); + if (ci.specification) lines.push(" 规格: " + ci.specification); + if (ci.demand_specification) lines.push(" 需求规格: " + ci.demand_specification); + if (ci.quantity) lines.push(" 数量: " + ci.quantity + (ci.unit || "")); + } + if (orderData.remark) lines.push("备注: " + orderData.remark); + if (orderData.customer_demand) lines.push("客户需求: " + orderData.customer_demand); + text = lines.join("\n"); + } if (text) { - wx.setClipboardData({ - data: text, - success: function () { - wx.showToast({ title: "审批通过,采购信息已复制", icon: "success" }); - }, - }); + wx.setClipboardData({ data: text }); } else { wx.showToast({ title: "审批通过", icon: "success" }); }