7-15 修复小程序中审批复制功能

This commit is contained in:
taiyi 2026-07-15 11:16:27 +08:00
parent a9b3d4198e
commit 02eedfcea9

View File

@ -1,4 +1,4 @@
/**
/**
* 订单详情页面审批 + 完整信息展示
* 职责展示订单完整信息基础信息费用明细产品列表收货信息审批记录
* 支持审批通过/退回待审批状态下可选择下发工厂
@ -398,14 +398,14 @@ Page({
var app = getApp();
that.setData({ actionLoading: true, message: "" });
// 在 API 调用前捕获当前订单信息,用于审批通过后复制到剪贴板
// 审批通过且非自发订单时,先将收货/需求信息复制到剪贴板(必须在同步上下文中调用)
var clipboardText = "";
if (payload.approve_result === "pass" && !payload.factory_id) {
if (payload.approve_result === "pass") {
var orderData = that.data.orderInfo;
if (orderData) {
var lines = [];
var isPickup = orderData.delivery_type === "自提";
if (!isPickup) {
if (orderData.order_no) lines.push("订单号:" + orderData.order_no);
if (orderData.customer_name || orderData.customer_mobile || orderData.customer_address) {
var contactParts = [orderData.customer_name, orderData.customer_mobile, orderData.customer_address].filter(function(v) { return v; });
if (contactParts.length) lines.push("收货信息:" + contactParts.join(" "));
}
@ -414,6 +414,19 @@ Page({
}
}
// 先复制到剪贴板(在同步上下文中确保系统剪贴板可用)
if (clipboardText) {
wx.setClipboardData({
data: clipboardText,
success: function () {
wx.showToast({ title: "已复制到剪贴板", icon: "success", duration: 2000 });
},
fail: function () {
wx.showToast({ title: "复制失败,请手动复制", icon: "none", duration: 2000 });
},
});
}
// 请求订阅消息授权
await subscribe.ensureSubscribePermission("approve");
@ -427,21 +440,6 @@ Page({
wx.showToast({ title: "审批通过,已下发工厂并分配司机", icon: "success" });
} else if (payload.factory_id) {
wx.showToast({ title: "审批通过,已下发工厂,待后续分配司机", icon: "success" });
} else if (clipboardText) {
// 使用预先捕获的文本复制到剪贴板
wx.setClipboardData({
data: clipboardText,
success: function () {
wx.showToast({ title: "内容已复制到剪贴板", icon: "none", duration: 2000 });
},
fail: function () {
wx.showToast({ title: "复制失败,请手动复制", icon: "none", duration: 2000 });
},
complete: function () {
that.loadDetail();
},
});
return;
} else {
wx.showToast({ title: "审批通过", icon: "success" });
}
@ -957,4 +955,4 @@ Page({
query: "id=" + this.data.taskId,
};
},
});
});