From 0ba8ef0a83c57fb3409f8ec8181b737ce874e67a Mon Sep 17 00:00:00 2001 From: shenyifei Date: Sat, 8 Nov 2025 17:16:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(ship):=20=E4=BF=AE=E6=94=B9=E5=8F=91?= =?UTF-8?q?=E8=B4=A7=E5=8D=95=E6=8D=AE=E4=B8=8B=E8=BD=BD=E4=B8=8E=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将保存到相册改为下载文件并打开文档预览 - 增加分享时的文件名设置 - 注释掉原有的文件系统保存逻辑 --- .../src/pages/ship/document/create.tsx | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/packages/app-client/src/pages/ship/document/create.tsx b/packages/app-client/src/pages/ship/document/create.tsx index fcd71a4..c856124 100644 --- a/packages/app-client/src/pages/ship/document/create.tsx +++ b/packages/app-client/src/pages/ship/document/create.tsx @@ -1269,32 +1269,47 @@ export default hocAuth(function Page(props: CommonComponent) { if (data && data.path) { setShipDocument(data.path); - // 保存到系统相册 + // 下载文件 Taro.downloadFile({ url: data.path, }).then((downloadRes) => { if (downloadRes.tempFilePath) { - Taro.saveImageToPhotosAlbum({ + Taro.openDocument({ filePath: downloadRes.tempFilePath, - complete: (res) => { - console.log("saveImageToPhotosAlbum", res); - }, + showMenu: true, + success: function () { + Taro.showToast({ + title: "发货单据已下载成功,您可以将生成的PDF发送给好友", + icon: "none", + duration: 3000, + }); + } }) - .then(() => { - Taro.showToast({ - title: "发货单据已保存到相册,您可以将生成的PDF发送给好友", - icon: "none", - duration: 3000, - }); - }) - .catch((e) => { - console.log("e", e); - Taro.showToast({ - title: "保存失败", - icon: "none", - duration: 3000, - }); - }); + // Taro.getFileSystemManager().mkdir({ + // dirPath: `${Taro.env.USER_DATA_PATH}/${shipOrderVO?.dealerName}/发货单据`, + // recursive: true, + // }); + // + // // 保存到文件系统 + // Taro.getFileSystemManager().saveFile({ + // tempFilePath: downloadRes.tempFilePath, + // filePath: `${Taro.env.USER_DATA_PATH}/${shipOrderVO?.dealerName}/发货单据/${shipOrderVO?.vehicleNo}_${shipOrderVO?.dealerName}_发货单据_${shipOrderVO?.orderSn}.pdf`, + // success: function () { + // Taro.showToast({ + // title: "发货单据已保存到本地,您可以将生成的PDF发送给好友", + // icon: "none", + // duration: 3000, + // }); + // }, + // fail: function (err) { + // console.log("保存失败", err); + // Taro.showToast({ + // title: "保存失败", + // icon: "none", + // duration: 3000, + // }); + // } + // }); } }); } @@ -1426,6 +1441,7 @@ export default hocAuth(function Page(props: CommonComponent) { // 下载完成后转发 Taro.shareFileMessage({ filePath: downloadRes.tempFilePath, + fileName: `${shipOrderVO?.vehicleNo}_${shipOrderVO?.dealerName}_发货单据_${shipOrderVO?.orderSn}.pdf`, complete: (res) => { console.log("complete", res); },