Commit c2546718 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

feat: 物流能力地址修改成四级联动

parent 16adb735
......@@ -41,18 +41,21 @@ const {
onFormInit$,
} = FormEffectHooks;
const useFetchAreaEnumLinkageEffect = () => {
export const useFetchAreaEnumLinkageEffect = () => {
useValueLinkageEffect({
type: 'value:areaEnum',
resolve: async ({ origin, target }, { getFieldValue, setFieldState }) => {
resolve: async ({ origin, target }, { getFieldValue, setFieldState, getFieldState }) => {
const parentValue = getFieldValue(origin);
if (!parentValue) {
setFieldState(target, innerState => {
FormPath.setIn(innerState, 'value', undefined);
FormPath.setIn(innerState, 'props.enum', []);
});
return;
}
getFieldState(origin, (innerState) => {
if (innerState.modified) {
setFieldState(target, innerState => {
FormPath.setIn(innerState, 'value', undefined);
FormPath.setIn(innerState, 'props.enum', []);
});
return;
}
});
// loading start
setFieldState(
target,
......@@ -486,7 +489,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
flag: visible,
};
});
// 先获取地区信息
formActions.setFieldState('provinceCode', targetState => {
FormPath.setIn(targetState, 'props.x-props.hasFeedback', true);
......@@ -607,7 +610,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
<div>{full || (!isStr ? `${value?.name || ''} ${value?.fullAddress || ''} ${value?.phone || ''}` : value)}</div>
);
};
if (!editable) {
return renderAddressStr();
}
......
import React from 'react';
import { receiverAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { postLogisticsReceiverAddressAdd } from '@/services/LogisticsV2Api';
import AddedAddressLayout from './form';
const ReceivingAddressAdded = () => {
return (
<AddressForm
title='收货地区'
schema={receiverAddress}
fetch={postLogisticsReceiverAddressAdd}
isEdit
/>
<AddedAddressLayout mode='add' />
)
}
export default ReceivingAddressAdded
import React from 'react';
import { history } from 'umi';
import { receiverAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { getLogisticsReceiverAddressGet, postLogisticsReceiverAddressUpdate } from '@/services/LogisticsV2Api';
import AddedAddressLayout from './form';
const ReceivingAddressEdit = () => {
const {
......@@ -11,14 +9,7 @@ const ReceivingAddressEdit = () => {
},
} = history.location;
return (
<AddressForm
id={id}
title='收货地区'
schema={receiverAddress}
fetch={postLogisticsReceiverAddressUpdate}
detail={getLogisticsReceiverAddressGet}
isEdit
/>
<AddedAddressLayout mode='edit' id={id as any} />
)
}
export default ReceivingAddressEdit
import React from 'react';
import { shipperAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { postLogisticsShipperAddressAdd } from '@/services/LogisticsV2Api';
import AddedAddressLayout from './form';
const ShipperAddressAdded = () => {
return (
<AddressForm
title='发货地区'
schema={shipperAddress}
fetch={postLogisticsShipperAddressAdd}
isEdit
/>
<AddedAddressLayout mode='add' />
)
}
export default ShipperAddressAdded
import React from 'react';
import { history } from 'umi';
import { shipperAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { getLogisticsShipperAddressGet, postLogisticsShipperAddressUpdate } from '@/services/LogisticsV2Api';
import AddedAddressLayout from './form';
const ShipperAddressEdit = () => {
const {
......@@ -10,15 +8,9 @@ const ShipperAddressEdit = () => {
id
},
} = history.location;
return (
<AddressForm
id={id}
title='发货地区'
schema={shipperAddress}
fetch={postLogisticsShipperAddressUpdate}
detail={getLogisticsShipperAddressGet}
isEdit
/>
<AddedAddressLayout mode='edit' id={id as any} />
)
}
export default ShipperAddressEdit
......@@ -131,6 +131,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
effects={($, ctx) => {
$('onFormMount').subscribe(() => {
// 四级联动
console.log($, ctx, 1)
useChainEffects($, ctx)
})
......
......@@ -51,7 +51,7 @@ const addressSchema: ISchema = {
'x-linkages': [
{
type: 'value:linkage',
condition: '{{!!$value}}',
condition: '{{!!$value}}111',
origin: 'provinceCode',
target: 'cityCode',
},
......
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