Commit 74d819f7 authored by XieZhiXiong's avatar XieZhiXiong

chore: 完善联动逻辑

parent e6bb5ed2
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-05 18:02:18
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-27 16:09:15
* @LastEditTime: 2021-08-30 19:38:32
* @Description: 退款明细
*/
import React, { useState } from 'react';
......@@ -318,7 +318,7 @@ const ReturnDetailInfo: React.FC<ReturnDetailInfoProps> = ({
const handlePaymentVoucherSubmit = (value) => {
if (onRefund) {
setSubmitLoading(true);
return onRefund({ ...value, id: refundModalValue.id }).finally(() => {
return onRefund({ ...value, id: refundModalValue.id }).finally(() => {
setSubmitLoading(false);
setPaymentVoucherVisible(false);
});
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-05-13 11:43:00
* @LastEditTime: 2021-08-31 10:34:04
* @Description: 联动逻辑相关
*/
import BigNumber from 'bignumber.js';
......@@ -37,7 +37,7 @@ export const useBusinessEffects = (context, actions) => {
const { value } = fieldState;
const purchasePriceValue = await getFieldValue('purchasePrice');
const orderTypeValue = await getFieldValue('orderType');
const payListValue = await getFieldValue('payList');
const payListValue = await getFieldValue('payList') || [];
const isMateriel = (
orderTypeValue === ORDER_TYPE_INQUIRY_CONTRACT
......@@ -45,14 +45,16 @@ export const useBusinessEffects = (context, actions) => {
|| orderTypeValue === ORDER_TYPE_TENDER_CONTRACT
);
const newData = [...payListValue].map(item => {
const refundAmount = item.payTime ? +(new BigNumber(+value).multipliedBy(purchasePriceValue).multipliedBy(new BigNumber(item.payRatio).dividedBy(100))).toFixed(2) : 0;
return {
...item,
refundAmount,
};
});
setFieldValue('payList', newData);
if (!isMateriel) {
const newData = [...payListValue].map(item => {
const refundAmount = item.payTime ? +(new BigNumber(+value).multipliedBy(purchasePriceValue).multipliedBy(new BigNumber(item.payRatio).dividedBy(100))).toFixed(2) : 0;
return {
...item,
refundAmount,
};
});
setFieldValue('payList', newData);
}
if (isMateriel) {
const refundAmount = +(new BigNumber(+value).multipliedBy(purchasePriceValue).toFixed(2));
......@@ -62,7 +64,7 @@ export const useBusinessEffects = (context, actions) => {
// 校验退货数量
onFieldInputChange$('returnCount').subscribe(async (fieldState) => {
const { name, value } = fieldState;
const { value } = fieldState;
// 剩余数量
const remainingValue = await getFieldValue('remaining');
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-05 17:36:45
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-26 19:54:01
* @LastEditTime: 2021-08-31 10:33:36
* @Description: 查看退货数量与退款金额 抽屉
*/
import React, { useEffect, useState } from 'react';
......@@ -22,9 +22,6 @@ import Stamp from '../Stamp';
import SteamerTicket from './components/SteamerTicket';
const schemaAction = createAsyncFormActions();
const {
onFormMount$,
} = FormEffectHooks;
export type PayListItem = {
/**
......@@ -219,7 +216,7 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({
refundAmount: +(new BigNumber(+applyInfo.remaining).multipliedBy(applyInfo.purchasePrice).multipliedBy(new BigNumber(item.payRate * 100).dividedBy(100))).toFixed(2),
payTime: item.payTime,
payRuleId: item.fundMode,
externalState: 3,
externalState: 3, // 这个状态写死了,因为现在只有付款了才会出现这条支付信息
transactionPayId: item.tradeNo, // 微信 或 其他第三方支付返回的 code,原路退款需要
}));
}
......@@ -237,6 +234,7 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({
...applyInfo,
payList,
returnCount: applyInfo.returnCount || applyInfo.remaining, // 默认赋值
refundAmount: applyInfo.refundAmount || +(new BigNumber(+applyInfo.remaining).multipliedBy(applyInfo.purchasePrice)), // 默认赋值
});
};
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-21 16:26:34
* @LastEditTime: 2021-08-31 10:42:22
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -77,7 +77,7 @@ export const useBusinessEffects = (context, actions) => {
});
// 供应会员联动 单据明细
onFieldInputChange$('supplierMember').subscribe(fieldState => {
onFieldInputChange$('*(supplierMember,orderType)').subscribe(fieldState => {
const replaceGoodsListValue = getFieldValue('replaceGoodsList');
if (replaceGoodsListValue && replaceGoodsListValue.length) {
setFieldValue('replaceGoodsList', []);
......
......@@ -2,10 +2,10 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-05 11:40:35
* @LastEditTime: 2021-08-31 10:32:33
* @Description: 联动逻辑相关
*/
import { FormEffectHooks, FormPath } from '@formily/antd';
import { FormEffectHooks } from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils';
const {
......@@ -17,8 +17,6 @@ export const useBusinessEffects = (context, actions) => {
const {
getFieldValue,
setFieldValue,
getFieldState,
setFieldState,
} = actions;
const linkage = useLinkageUtils();
......@@ -49,8 +47,8 @@ export const useBusinessEffects = (context, actions) => {
};
});
// 供应会员联动 单据明细
onFieldInputChange$('supplierMember').subscribe(fieldState => {
// 供应会员、售后订单类型联动 单据明细
onFieldInputChange$('*(supplierMember,orderType)').subscribe(fieldState => {
const replaceGoodsListValue = getFieldValue('returnGoodsList');
if (replaceGoodsListValue && replaceGoodsListValue.length) {
setFieldValue('returnGoodsList', []);
......
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