feat(ship): 修改发货单据下载与分享逻辑

- 将保存到相册改为下载文件并打开文档预览
- 增加分享时的文件名设置
- 注释掉原有的文件系统保存逻辑
This commit is contained in:
shenyifei 2025-11-08 17:16:07 +08:00
parent 835cc21315
commit 0ba8ef0a83

View File

@ -1269,32 +1269,47 @@ export default hocAuth(function Page(props: CommonComponent) {
if (data && data.path) { if (data && data.path) {
setShipDocument(data.path); setShipDocument(data.path);
// 保存到系统相册 // 下载文件
Taro.downloadFile({ Taro.downloadFile({
url: data.path, url: data.path,
}).then((downloadRes) => { }).then((downloadRes) => {
if (downloadRes.tempFilePath) { if (downloadRes.tempFilePath) {
Taro.saveImageToPhotosAlbum({ Taro.openDocument({
filePath: downloadRes.tempFilePath, filePath: downloadRes.tempFilePath,
complete: (res) => { showMenu: true,
console.log("saveImageToPhotosAlbum", res); success: function () {
}, Taro.showToast({
title: "发货单据已下载成功您可以将生成的PDF发送给好友",
icon: "none",
duration: 3000,
});
}
}) })
.then(() => { // Taro.getFileSystemManager().mkdir({
Taro.showToast({ // dirPath: `${Taro.env.USER_DATA_PATH}/${shipOrderVO?.dealerName}/发货单据`,
title: "发货单据已保存到相册您可以将生成的PDF发送给好友", // recursive: true,
icon: "none", // });
duration: 3000, //
}); // // 保存到文件系统
}) // Taro.getFileSystemManager().saveFile({
.catch((e) => { // tempFilePath: downloadRes.tempFilePath,
console.log("e", e); // filePath: `${Taro.env.USER_DATA_PATH}/${shipOrderVO?.dealerName}/发货单据/${shipOrderVO?.vehicleNo}_${shipOrderVO?.dealerName}_发货单据_${shipOrderVO?.orderSn}.pdf`,
Taro.showToast({ // success: function () {
title: "保存失败", // Taro.showToast({
icon: "none", // title: "发货单据已保存到本地您可以将生成的PDF发送给好友",
duration: 3000, // 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({ Taro.shareFileMessage({
filePath: downloadRes.tempFilePath, filePath: downloadRes.tempFilePath,
fileName: `${shipOrderVO?.vehicleNo}_${shipOrderVO?.dealerName}_发货单据_${shipOrderVO?.orderSn}.pdf`,
complete: (res) => { complete: (res) => {
console.log("complete", res); console.log("complete", res);
}, },