Commit 9cdcfbc3 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复换货地址不显示的问题

parent c6d4c7fb
......@@ -2,12 +2,12 @@
* @Author: XieZhiXiong
* @Date: 2020-11-06 09:54:04
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-29 14:09:18
* @LastEditTime: 2021-02-09 18:02:56
* @Description: 换货收货地址
*/
import React from 'react';
import React, { useEffect } from 'react';
import MellowCard from '@/components/MellowCard';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { createAsyncFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { useLinkageUtils } from '@/utils/formEffectUtils';
......@@ -15,7 +15,7 @@ import NiceForm from '@/components/NiceForm';
import { schema } from './schema';
import styles from './index.less';
const modalFormActions = createFormActions();
const modalFormActions = createAsyncFormActions();
const {
onFieldValueChange$,
onFieldInputChange$,
......@@ -74,6 +74,83 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
onSubmit,
}) => {
useEffect(() => {
const { setFieldState } = modalFormActions;
// if (isEdit) {
// setFieldState('*(shippingAddress,pickupAddress)', state => {
// state.visible = true;
// });
// setFieldState('shippingAddressShow', state => {
// state.visible = false;
// });
// } else {
// setFieldState('*(shippingAddress,pickupAddress)', state => {
// state.visible = false;
// });
// setFieldState('shippingAddressShow', state => {
// state.visible = true;
// });
// }
switch (shippingAddress.deliveryType) {
// 物流
case 1: {
if (isEdit) {
setFieldState('shippingAddress', state => {
state.visible = true;
});
setFieldState('pickupAddress', state => {
state.visible = false;
});
} else {
setFieldState('*(shippingAddress,pickupAddress)', state => {
state.visible = false;
});
setFieldState('shippingAddressShow', state => {
state.visible = true;
});
}
break;
};
// 自提
case 2: {
if (isEdit) {
setFieldState('shippingAddress', state => {
state.visible = false;
});
setFieldState('pickupAddress', state => {
state.visible = true;
});
} else {
setFieldState('shippingAddressShow', state => {
state.title = '换货自提地址';
});
setFieldState('pickupAddress', state => {
state.visible = true;
});
setFieldState('shippingAddressShow', fieldState => {
fieldState.title = '换货自提地址'
});
setFieldState('*(shippingAddress,pickupAddress)', state => {
state.visible = false;
});
setFieldState('shippingAddressShow', state => {
state.visible = true;
});
}
break;
};
// 无需物流
case 3: {
setFieldState('*(shippingAddress,pickupAddress,shippingAddressShow)', state => {
state.visible = false;
});
break;
};
default:
break
};
}, [shippingAddress.deliveryType, isEdit]);
const handleSubmit = values => {
};
......@@ -136,33 +213,20 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
const linkage = useLinkageUtils();
// 联动配送方式
onFieldValueChange$('deliveryType').subscribe(fieldState => {
onFieldInputChange$('deliveryType').subscribe(fieldState => {
const { value } = fieldState;
switch (value) {
// 物流
case 1: {
if (isEdit) {
linkage.show('shippingAddress');
linkage.hide('pickupAddress');
} else {
linkage.hide('*(shippingAddress,pickupAddress)');
linkage.show('shippingAddressShow');
}
linkage.show('shippingAddress');
linkage.hide('pickupAddress');
break;
};
// 自提
case 2: {
if (isEdit) {
linkage.hide('shippingAddress');
linkage.show('pickupAddress');
} else {
setFieldState('shippingAddressShow', fieldState => {
fieldState.title = '换货自提地址'
});
linkage.hide('*(shippingAddress,pickupAddress)');
linkage.show('shippingAddressShow');
}
linkage.hide('shippingAddress');
linkage.show('pickupAddress');
break;
};
// 无需物流
......
......@@ -9,7 +9,7 @@ import DetailInfo from '../components/DetailInfo';
const { confirm } = Modal;
const ExchangePrConfirmBackVerify: React.FC = () => {
const { id, creditId } = usePageStatus();
const { id } = usePageStatus();
const [submitLoading, setSubmitLoading] = useState(false);
const handleSubmit = (info) => {
......@@ -31,12 +31,12 @@ const ExchangePrConfirmBackVerify: React.FC = () => {
const handleDeliverAgain = (info) => {
if (
info &&
info.returnDeliveryGoodsList &&
info.returnDeliveryGoodsList.length
info.replaceDeliveryGoodsList &&
info.replaceDeliveryGoodsList.length
) {
// 未换货发货数量全部小于或等于 0 时
if (
info.returnDeliveryGoodsList.every(item => {
info.replaceDeliveryGoodsList.every(item => {
return item.detailList.every(good => good.count - good.deliveryCount <= 0)
})
) {
......@@ -53,7 +53,7 @@ const ExchangePrConfirmBackVerify: React.FC = () => {
}
// 未换货发货数量有大于 0 时
if (
info.returnDeliveryGoodsList.some(item => {
info.replaceDeliveryGoodsList.some(item => {
return item.detailList.some(good => good.count - good.deliveryCount > 0)
})
) {
......@@ -81,6 +81,7 @@ const ExchangePrConfirmBackVerify: React.FC = () => {
type="default"
icon={<SettingOutlined />}
onClick={() => handleSubmit(detailInfo)}
loading={submitLoading}
>
确认全部换货发货单已收到回单
</Button>
......
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