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) {
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);
},