fix(delivery): 修复Excel下载逻辑并优化UI组件样式
- 移除Taro.downloadFile调用,直接使用URL设置临时文件路径 - 调整PDF查看按钮的图标颜色和类型样式 - 调整Excel查看按钮的图标颜色和类型样式 - 修复采购订单暂存跳转路径使用动态配置 - 添加空值检查避免访问undefined属性导致错误 - 移除档口信息中的冗余提示文本 - 更新Excel文件名格式化方式,移除分隔符 - 添加文件路径日志输出便于调试
This commit is contained in:
parent
b46137d0c3
commit
e6855dba63
@ -190,29 +190,13 @@ export default function Step3Success(props: Step3SuccessProps) {
|
||||
icon: "success",
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
// 下载文件
|
||||
const downloadRes = await Taro.downloadFile({
|
||||
url: profitExcelUrl!,
|
||||
});
|
||||
|
||||
if (downloadRes.tempFilePath) {
|
||||
setExcelTempFilePath(downloadRes.tempFilePath);
|
||||
setExcelTempFilePath(profitExcelUrl);
|
||||
Taro.showToast({
|
||||
title: "Excel下载成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("下载Excel失败:", error);
|
||||
Taro.showToast({
|
||||
title: "下载Excel失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 查看Excel文档
|
||||
@ -405,15 +389,15 @@ export default function Step3Success(props: Step3SuccessProps) {
|
||||
{tempFilePath && (
|
||||
<View className="flex-1">
|
||||
<Button
|
||||
icon={<Icon name="eye" size={16} />}
|
||||
type="primary"
|
||||
icon={<Icon name="eye" size={16} color={"orange"} />}
|
||||
type="default"
|
||||
color="orange"
|
||||
fill={"outline"}
|
||||
size={"large"}
|
||||
block
|
||||
onClick={handleViewPDF}
|
||||
>
|
||||
<Text className="font-medium">查看PDF</Text>
|
||||
<Text className="text-orange font-medium">查看PDF</Text>
|
||||
</Button>
|
||||
</View>
|
||||
)}
|
||||
@ -495,8 +479,8 @@ export default function Step3Success(props: Step3SuccessProps) {
|
||||
{excelTempFilePath && (
|
||||
<View className="flex-1">
|
||||
<Button
|
||||
icon={<Icon name="eye" size={16} />}
|
||||
type="primary"
|
||||
icon={<Icon name="eye" size={16} color={"orange"} />}
|
||||
type="default"
|
||||
color="orange"
|
||||
fill={"outline"}
|
||||
size={"large"}
|
||||
|
||||
@ -316,7 +316,7 @@ export default forwardRef<MadeOptionRef, IMadeOptionProps>(function MadeOption(
|
||||
content: "当前采购订单已暂存成功",
|
||||
});
|
||||
Taro.redirectTo({
|
||||
url: "/pages/purchase/made/drafts",
|
||||
url: purchase.path[orderVO.type].drafts,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@ -190,7 +190,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
return false;
|
||||
}
|
||||
// 银行名称至少2个字符
|
||||
return bankName.length >= 2;
|
||||
return bankName?.length >= 2;
|
||||
};
|
||||
|
||||
// 校验手机号函数
|
||||
@ -955,7 +955,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
clearable
|
||||
type="text"
|
||||
placeholder="请输入档口名称"
|
||||
value={supplierVO.name}
|
||||
value={supplierVO?.name || ""}
|
||||
onChange={(value) => handleNameChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handleNameBlur(
|
||||
@ -982,7 +982,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
clearable
|
||||
type="text"
|
||||
placeholder="请输入收款人姓名"
|
||||
value={supplierVO.payeeName}
|
||||
value={supplierVO?.payeeName || ""}
|
||||
onChange={(value) =>
|
||||
handlePayeeNameChange(value, supplierVO)
|
||||
}
|
||||
@ -1016,7 +1016,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
clearable
|
||||
type="text"
|
||||
placeholder="请输入银行名称"
|
||||
value={supplierVO.bankName}
|
||||
value={supplierVO?.bankName || ""}
|
||||
onChange={(value) =>
|
||||
handleBankNameChange(value, supplierVO)
|
||||
}
|
||||
@ -1050,7 +1050,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
clearable
|
||||
type="digit"
|
||||
placeholder="请输入银行卡号"
|
||||
value={supplierVO.bankCard}
|
||||
value={supplierVO?.bankCard || ""}
|
||||
onChange={(value) =>
|
||||
handleBankCardChange(value, supplierVO)
|
||||
}
|
||||
@ -1079,7 +1079,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
clearable
|
||||
type="tel"
|
||||
placeholder="请输入手机号码"
|
||||
value={supplierVO.phone}
|
||||
value={supplierVO?.phone || ""}
|
||||
onChange={(value) => handlePhoneChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handlePhoneBlur(
|
||||
@ -1121,9 +1121,6 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
微信收款码
|
||||
</View>
|
||||
<View className="text-sm text-green-600">已上传完成</View>
|
||||
<View className="text-neutral-darker mt-1 text-xs">
|
||||
若档口无法开发票,则可打款到微信
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex flex-row gap-2.5">
|
||||
@ -1176,9 +1173,6 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
|
||||
<View className="text-neutral-darker mt-1 text-xs">
|
||||
支持从相册选择或拍照
|
||||
</View>
|
||||
<View className="mt-2 text-center text-xs text-gray-400">
|
||||
若档口无法开发票,则可打款到微信
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@ -869,7 +869,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
|
||||
clearable
|
||||
type="text"
|
||||
placeholder="请输入姓名"
|
||||
value={supplierVO.name}
|
||||
value={supplierVO?.name || ""}
|
||||
onChange={(value) => handleNameChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handleNameBlur(
|
||||
@ -896,7 +896,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
|
||||
clearable
|
||||
type="idcard"
|
||||
placeholder="请输入身份证号"
|
||||
value={supplierVO.idCard || ""}
|
||||
value={supplierVO?.idCard || ""}
|
||||
onChange={(value) => handleIdCardChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handleIdCardBlur(
|
||||
@ -921,7 +921,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
|
||||
clearable
|
||||
type="text"
|
||||
placeholder="请输入银行名称"
|
||||
value={supplierVO.bankName || ""}
|
||||
value={supplierVO?.bankName || ""}
|
||||
onChange={(value) => handleBankNameChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handleBankNameBlur(
|
||||
@ -953,7 +953,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
|
||||
clearable
|
||||
type="digit"
|
||||
placeholder="请输入银行卡号"
|
||||
value={supplierVO.bankCard || ""}
|
||||
value={supplierVO?.bankCard || ""}
|
||||
onChange={(value) => handleBankCardChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handleBankCardBlur(
|
||||
@ -978,7 +978,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
|
||||
clearable
|
||||
type="tel"
|
||||
placeholder="请输入手机号码"
|
||||
value={supplierVO.phone}
|
||||
value={supplierVO?.phone || ""}
|
||||
onChange={(value) => handlePhoneChange(value, supplierVO)}
|
||||
onBlur={() =>
|
||||
handlePhoneBlur(
|
||||
|
||||
@ -57,11 +57,13 @@ const path = {
|
||||
create: "/pages/purchase/made/create",
|
||||
preview: "/pages/purchase/made/preview",
|
||||
result: "/pages/purchase/made/result",
|
||||
drafts: "/pages/purchase/made/drafts",
|
||||
},
|
||||
MARKET_PURCHASE: {
|
||||
create: "/pages/purchase/market/create",
|
||||
preview: "/pages/purchase/market/preview",
|
||||
result: "/pages/purchase/market/result",
|
||||
drafts: "/pages/purchase/market/drafts",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -605,9 +605,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
微信收款码
|
||||
</View>
|
||||
<View className="text-sm text-green-600">已上传完成</View>
|
||||
<View className="text-neutral-darker mt-1 text-xs">
|
||||
若档口无法开发票,则可打款到微信
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex flex-row gap-2.5">
|
||||
@ -660,9 +657,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
<View className="text-neutral-darker mt-1 text-xs">
|
||||
支持从相册选择或拍照
|
||||
</View>
|
||||
<View className="mt-2 text-center text-xs text-gray-400">
|
||||
若档口无法开发票,则可打款到微信
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
import dayjs from "dayjs";
|
||||
import {utils, write} from "xlsx";
|
||||
import { utils, write } from "xlsx";
|
||||
|
||||
// 利润表行数据接口
|
||||
export interface ProfitTableRow {
|
||||
@ -411,7 +411,7 @@ export const exportProfitTableExcel = async (
|
||||
utils.book_append_sheet(wb, ws, "诚信志远利润明细");
|
||||
|
||||
// 生成文件名
|
||||
const fileName = `诚信志远利润明细_${month}_${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xlsx`;
|
||||
const fileName = `诚信志远利润明细_${month}_${dayjs().format("YYYYMMDDHHmmss")}.xlsx`;
|
||||
|
||||
// 根据环境选择不同的导出方式
|
||||
const processEnv = process.env.TARO_ENV;
|
||||
@ -431,6 +431,7 @@ export const exportProfitTableExcel = async (
|
||||
|
||||
// 将文件保存到本地
|
||||
const filePath = `${Taro.env.USER_DATA_PATH}/${fileName}`;
|
||||
console.log("filePath", filePath);
|
||||
Taro.getFileSystemManager().writeFile({
|
||||
filePath,
|
||||
data: excelBuffer,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user