Commit 1b7cd0b6 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复 合同订单 退款金额为0的问题

parent 1f578402
...@@ -6,11 +6,7 @@ ...@@ -6,11 +6,7 @@
* @Description: * @Description:
*/ */
import { useBusinessEffects } from './useBusinessEffects'; import { useBusinessEffects } from './useBusinessEffects';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { PublicApi } from '@/services/api';
export const createEffects = (context, actions) => { export const createEffects = (context, actions) => {
const { setFieldState } = actions;
useBusinessEffects(context, actions); useBusinessEffects(context, actions);
}; };
\ No newline at end of file
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-11-03 18:30:47 * @Date: 2020-11-03 18:30:47
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-02-24 17:25:15 * @LastEditTime: 2021-05-13 11:43:00
* @Description: 联动逻辑相关 * @Description: 联动逻辑相关
*/ */
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { FormEffectHooks, FormPath } from '@formily/antd'; import { FormEffectHooks } from '@formily/antd';
import { useLinkageUtils } from '@/utils/formEffectUtils'; import {
ORDER_TYPE_INQUIRY_CONTRACT,
ORDER_TYPE_BIDDING_CONTRACT,
ORDER_TYPE_TENDER_CONTRACT,
} from '@/constants/order';
const { const {
onFieldInputChange$, onFieldInputChange$,
...@@ -18,36 +22,49 @@ export const useBusinessEffects = (context, actions) => { ...@@ -18,36 +22,49 @@ export const useBusinessEffects = (context, actions) => {
const { const {
getFieldValue, getFieldValue,
setFieldValue, setFieldValue,
getFieldState,
setFieldState, setFieldState,
} = actions; } = actions;
const linkage = useLinkageUtils();
// 联动退款金额 // 联动退款金额
onFieldValueChange$('payList.*.refundAmount').subscribe(fieldState => { onFieldValueChange$('payList.*.refundAmount').subscribe(async () => {
const payListValue = getFieldValue('payList'); const payListValue = await getFieldValue('payList');
const amount = payListValue.reduce((pre, now) => new BigNumber(+now.refundAmount).plus(pre).toNumber(), 0); const amount = payListValue.reduce((pre, now) => new BigNumber(+now.refundAmount).plus(pre).toNumber(), 0);
setFieldValue('refundAmount', amount); setFieldValue('refundAmount', amount);
}); });
// 退款数量 联动,支付信息里边的 退款金额 // 退款数量 联动,支付信息里边的 退款金额
onFieldInputChange$('returnCount').subscribe(fieldState => { onFieldInputChange$('returnCount').subscribe(async (fieldState) => {
const { value } = fieldState; const { value } = fieldState;
const purchasePriceValue = getFieldValue('purchasePrice'); const purchasePriceValue = await getFieldValue('purchasePrice');
const newData = [...getFieldValue('payList')].map(item => { const orderTypeValue = await getFieldValue('orderType');
const payListValue = await getFieldValue('payList');
const isMateriel = (
orderTypeValue === ORDER_TYPE_INQUIRY_CONTRACT
|| orderTypeValue === ORDER_TYPE_BIDDING_CONTRACT
|| 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 { return {
...item, ...item,
refundAmount: item.payTime ? +(new BigNumber(+value).multipliedBy(purchasePriceValue).multipliedBy(new BigNumber(item.payRatio).dividedBy(100))).toFixed(2) : 0, refundAmount,
}; };
}); });
setFieldValue('payList', newData); setFieldValue('payList', newData);
if (isMateriel) {
const refundAmount = +(new BigNumber(+value).multipliedBy(purchasePriceValue).toFixed(2));
setFieldValue('refundAmount', refundAmount);
}
}); });
// 校验退货数量 // 校验退货数量
onFieldInputChange$('returnCount').subscribe(fieldState => { onFieldInputChange$('returnCount').subscribe(async (fieldState) => {
const { name, value } = fieldState; const { name, value } = fieldState;
// 采购数量 // 剩余数量
const remainingValue = getFieldValue('remaining'); const remainingValue = await getFieldValue('remaining');
setFieldState( setFieldState(
'returnCount', 'returnCount',
......
.paneTitle {
padding-left: 6px;
margin-bottom: 24px;
line-height: 14px;
font-size: 14px;
font-weight: 400;
color: #606266;
border-left: 2px solid #00B37A;
}
.payInfo {
&-item {
margin-bottom: 16px;
}
}
\ No newline at end of file
...@@ -2,20 +2,25 @@ ...@@ -2,20 +2,25 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-11-05 17:36:45 * @Date: 2020-11-05 17:36:45
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-22 11:07:42 * @LastEditTime: 2021-05-13 11:46:56
* @Description: 查看退货数量与退款金额 抽屉 * @Description: 查看退货数量与退款金额 抽屉
*/ */
import React from 'react'; import React from 'react';
import { Drawer, Button } from 'antd'; import { Drawer, Button } from 'antd';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { createFormActions } from '@formily/antd'; import { createAsyncFormActions } from '@formily/antd';
import {
ORDER_TYPE_INQUIRY_CONTRACT,
ORDER_TYPE_BIDDING_CONTRACT,
ORDER_TYPE_TENDER_CONTRACT,
} from '@/constants/order';
import schema from './schema'; import schema from './schema';
import { createEffects } from './effects'; import { createEffects } from './effects';
import Stamp from '../Stamp'; import Stamp from '../Stamp';
import SteamerTicket from './components/SteamerTicket'; import SteamerTicket from './components/SteamerTicket';
import styles from './index.less'; import styles from './index.less';
const schemaAction = createFormActions(); const schemaAction = createAsyncFormActions();
export interface PayListItem { export interface PayListItem {
/** /**
...@@ -62,6 +67,10 @@ export interface OrderInfo { ...@@ -62,6 +67,10 @@ export interface OrderInfo {
*/ */
orderNo: string; orderNo: string;
/** /**
* 订单类型
*/
orderType: number;
/**
* 商品名称 * 商品名称
*/ */
productName: string; productName: string;
...@@ -108,9 +117,21 @@ export interface OrderInfo { ...@@ -108,9 +117,21 @@ export interface OrderInfo {
}; };
interface ReturnInfoDrawerProps { interface ReturnInfoDrawerProps {
/**
* 是否可见
*/
visible: boolean; visible: boolean;
/**
* 订单信息
*/
orderInfo: OrderInfo; orderInfo: OrderInfo;
/**
* 关闭触发事件
*/
onClose: () => void; onClose: () => void;
/**
* form 提交触发事件
*/
onSubmit?: (values: { [key: string]: any }) => void; onSubmit?: (values: { [key: string]: any }) => void;
/** /**
* 是否是编辑的 * 是否是编辑的
...@@ -134,7 +155,7 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({ ...@@ -134,7 +155,7 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({
const handleSubmit = values => { const handleSubmit = values => {
if (onSubmit) { if (onSubmit) {
const { remaining, ...rest } = values; const { remaining, orderType, ...rest } = values;
onSubmit(rest); onSubmit(rest);
} else { } else {
onClose(); onClose();
...@@ -182,7 +203,20 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({ ...@@ -182,7 +203,20 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({
}} }}
editable={isEdit} editable={isEdit}
effects={($, actions) => { effects={($, actions) => {
const { setFieldState } = actions;
const { orderType } = orderInfo;
const isMateriel = (
orderType === ORDER_TYPE_INQUIRY_CONTRACT
|| orderType === ORDER_TYPE_BIDDING_CONTRACT
|| orderType === ORDER_TYPE_TENDER_CONTRACT
);
createEffects($, actions); createEffects($, actions);
if (isMateriel) {
setFieldState('REPOSIT_TABS', state => {
state.props['x-component-props'].hiddenKeys = ['tab-2']
});
}
}} }}
onSubmit={handleSubmit} onSubmit={handleSubmit}
actions={schemaAction} actions={schemaAction}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-11-06 14:20:17 * @Date: 2020-11-06 14:20:17
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-05-07 16:44:47 * @LastEditTime: 2021-05-13 11:23:45
* @Description: * @Description:
*/ */
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
...@@ -79,10 +79,6 @@ const schema: ISchema = { ...@@ -79,10 +79,6 @@ const schema: ISchema = {
addonBefore: '¥ ' addonBefore: '¥ '
}, },
}, },
remaining: {
type: 'string',
display: false,
},
returnCount: { returnCount: {
type: 'string', type: 'string',
title: '退货数量', title: '退货数量',
...@@ -103,6 +99,14 @@ const schema: ISchema = { ...@@ -103,6 +99,14 @@ const schema: ISchema = {
}, },
], ],
}, },
remaining: {
type: 'string',
display: false,
},
orderType: {
type: 'string',
display: false,
},
}, },
}, },
}, },
......
...@@ -269,6 +269,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({ ...@@ -269,6 +269,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
} }
); );
setOrderTypeValue(rest.orderType);
setDetailInfo({ setDetailInfo({
proofFileList: faultFileList.map(item => normalizeFiledata(item.filePath)), proofFileList: faultFileList.map(item => normalizeFiledata(item.filePath)),
deliveryAddress: { deliveryAddress: {
...@@ -315,7 +316,6 @@ const ExchangeForm: React.FC<BillsFormProps> = ({ ...@@ -315,7 +316,6 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
})), })),
...rest, ...rest,
}); });
setOrderTypeValue(rest.orderType);
setGoodsValue(goodsDetailList.map(item => item.orderRecordId)); setGoodsValue(goodsDetailList.map(item => item.orderRecordId));
} }
}).finally(() => { }).finally(() => {
......
...@@ -254,6 +254,7 @@ const RepairForm: React.FC<BillsFormProps> = ({ ...@@ -254,6 +254,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
} }
); );
setOrderTypeValue(rest.orderType);
setDetailInfo({ setDetailInfo({
...detailInfo, ...detailInfo,
faultFileList: faultFileList.map(item => normalizeFiledata(item.filePath)), faultFileList: faultFileList.map(item => normalizeFiledata(item.filePath)),
...@@ -271,7 +272,6 @@ const RepairForm: React.FC<BillsFormProps> = ({ ...@@ -271,7 +272,6 @@ const RepairForm: React.FC<BillsFormProps> = ({
, ,
...rest, ...rest,
}); });
setOrderTypeValue(rest.orderType);
} }
}).finally(() => { }).finally(() => {
setInfoLoading(false); setInfoLoading(false);
......
...@@ -118,6 +118,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({ ...@@ -118,6 +118,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
payWayTxt: item.payWayName, payWayTxt: item.payWayName,
channelTxt: item.channelName, channelTxt: item.channelName,
})), })),
orderType: detailInfo?.orderType,
}); });
setVisibleReturnInfo(true); setVisibleReturnInfo(true);
}; };
......
...@@ -262,6 +262,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({ ...@@ -262,6 +262,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
returnBatch, returnBatch,
returnId, returnId,
roleId, roleId,
refundList,
...rest ...rest
} = res.data; } = res.data;
...@@ -303,6 +304,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({ ...@@ -303,6 +304,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
...rest, ...rest,
}); });
setOrderTypeValue(rest.orderType);
setReturnGoodsList(goodsDetailList.map(item => ({ setReturnGoodsList(goodsDetailList.map(item => ({
...item, ...item,
remaining: item.purchaseCount || 0, // 可退货数量,这里取 采购数量判断即可 remaining: item.purchaseCount || 0, // 可退货数量,这里取 采购数量判断即可
...@@ -315,7 +317,6 @@ const ReturnForm: React.FC<BillsFormProps> = ({ ...@@ -315,7 +317,6 @@ const ReturnForm: React.FC<BillsFormProps> = ({
associated: !item.materielId ? '' : `${item.productId}/${item.productName}/${item.category}/${item.brand}`, associated: !item.materielId ? '' : `${item.productId}/${item.productName}/${item.category}/${item.brand}`,
materielNameAndType: `${item.materielName || ''}${item.materielType ? '/' + item.materielType : ''}`, materielNameAndType: `${item.materielName || ''}${item.materielType ? '/' + item.materielType : ''}`,
}))); })));
setOrderTypeValue(rest.orderType);
setGoodsValue(goodsDetailList.map(item => item.orderRecordId)); setGoodsValue(goodsDetailList.map(item => item.orderRecordId));
} }
}).finally(() => { }).finally(() => {
...@@ -473,7 +474,6 @@ const ReturnForm: React.FC<BillsFormProps> = ({ ...@@ -473,7 +474,6 @@ const ReturnForm: React.FC<BillsFormProps> = ({
extraData, extraData,
needReturnName, needReturnName,
isNeedReturn, isNeedReturn,
refundAmount,
associated, associated,
materielNameAndType, materielNameAndType,
...rest ...rest
...@@ -623,6 +623,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({ ...@@ -623,6 +623,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
payList: item.extraData.payList, payList: item.extraData.payList,
remaining: item.extraData.remaining, remaining: item.extraData.remaining,
returnReason: item.extraData.returnReason, returnReason: item.extraData.returnReason,
orderType: orderTypeValue,
}); });
setVisibleReturnInfoDrawer(true) setVisibleReturnInfoDrawer(true)
}; };
......
...@@ -123,6 +123,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({ ...@@ -123,6 +123,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
payWayTxt: item.payWayName, payWayTxt: item.payWayName,
channelTxt: item.channelName, channelTxt: item.channelName,
})), })),
orderType: detailInfo?.orderType,
}); });
setVisibleReturnInfo(true); setVisibleReturnInfo(true);
}; };
......
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