Commit 5da33494 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复未到账操作失败的问题

parent f6c028ac
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-05 18:02:18
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-22 18:20:27
* @LastEditTime: 2021-01-28 10:22:16
* @Description: 退款明细
*/
import React, { useState } from 'react';
......@@ -78,6 +78,11 @@ interface ReturnDetailInfoProps {
* 供应商角色id
*/
supplierRoleId: number,
/**
* 是否可操作的
*/
isEdit?: boolean,
};
const ReturnDetailInfo: React.FC<ReturnDetailInfoProps> = ({
......@@ -85,12 +90,12 @@ const ReturnDetailInfo: React.FC<ReturnDetailInfoProps> = ({
onRefund,
onConfirm,
isPurchaser = false,
innerStatus,
outerStatus,
purchaserId,
purchaserRoleId,
supplierId,
supplierRoleId,
isEdit = false,
}) => {
const [visibleResult, setVisibleResult] = useState(false);
const [notReceivedLoading, setNotReceivedLoading] = useState(false);
......@@ -235,9 +240,14 @@ const ReturnDetailInfo: React.FC<ReturnDetailInfoProps> = ({
const handleConfirm = (id, flag) => {
if (onConfirm) {
flag === 1 ? setReceivedLoading(true) : setNotReceivedLoading(true);
onConfirm(id, flag).finally(() => {
flag === 1 ? setReceivedLoading(false) : setNotReceivedLoading(false);
});
onConfirm(id, flag)
.then(() => {
setVisibleResult(false);
flag === 1 ? setReceivedLoading(false) : setNotReceivedLoading(false);
})
.catch(() => {
flag === 1 ? setReceivedLoading(false) : setNotReceivedLoading(false);
});
}
};
......@@ -309,6 +319,7 @@ const ReturnDetailInfo: React.FC<ReturnDetailInfoProps> = ({
<div className={styles['deliver-item-actions']}>
{
isEdit &&
!isPurchaser &&
outerStatus === RETURN_OUTER_STATUS_TO_BE_REFUNDED &&
!!item.canRefund && (
......@@ -328,6 +339,7 @@ const ReturnDetailInfo: React.FC<ReturnDetailInfoProps> = ({
{item.channel === PAY_CHANNEL_OFFLINE && (
<>
{
isEdit &&
isPurchaser &&
outerStatus === RETURN_OUTER_STATUS_UNCONFIRMED_REFUNDED && (
item.outerStatus === REFUND_OUTER_STATUS_UNCONFIRMED_REFUND ||
......
......@@ -300,14 +300,21 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
};
// 确认退款到账
const handleConfirm = (id): Promise<any> => {
return PublicApi.postAsReturnGoodsConfirmRefund({
refundId: id,
isReceipt: 1,
}).then(res => {
if (res.code === 1000) {
getDetailInfo();
}
const handleConfirm = (id, flag): Promise<void> => {
return new Promise((resolve, reject) => {
PublicApi.postAsReturnGoodsConfirmRefund({
refundId: id,
isReceipt: flag,
}).then(res => {
if (res.code === 1000) {
getDetailInfo();
resolve();
} else {
reject();
}
}).catch(() => {
reject();
});
});
};
......@@ -430,6 +437,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
purchaserRoleId={detailInfo?.roleId}
supplierId={detailInfo?.parentMemberId}
supplierRoleId={detailInfo?.parentMemberRoleId}
isEdit={isEdit}
isPurchaser
/>
</Suspense>
......
......@@ -476,6 +476,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
purchaserRoleId={detailInfo?.roleId}
supplierId={detailInfo?.parentMemberId}
supplierRoleId={detailInfo?.parentMemberRoleId}
isEdit={isEdit}
/>
</Suspense>
</Col>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment