Commit 04ca069a authored by XieZhiXiong's avatar XieZhiXiong

chore: 去掉PublicApi

parent 20665f90
......@@ -2,19 +2,30 @@
* @Author: XieZhiXiong
* @Date: 2021-08-05 10:28:06
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-17 15:48:16
* @LastEditTime: 2021-11-18 11:14:29
* @Description: 地址选择 FormItem
*/
import React, { useState, useEffect, useMemo, useRef } from 'react';
import { Select, Button, Drawer, Divider, message } from 'antd';
import { PublicApi } from '@/services/api';
import { GetLogisticsShipperAddressGetResponse, GetLogisticsReceiverAddressGetResponse } from '@/services/LogisticsApi';
import {
createFormActions,
FormEffectHooks,
FormPath,
} from '@formily/antd';
import { IRequestSuccess } from '@/index';
import {
getLogisticsReceiverAddressGet,
GetLogisticsReceiverAddressGetResponse,
getLogisticsSelectListReceiverAddress,
getLogisticsSelectListShipperAddress,
getLogisticsShipperAddressGet,
GetLogisticsShipperAddressGetResponse,
postLogisticsReceiverAddressAdd,
postLogisticsReceiverAddressUpdate,
postLogisticsShipperAddressAdd,
postLogisticsShipperAddressUpdate,
} from '@/services/LogisticsV2Api';
import { getManageCountryAreaGetTelCode, getManageAreaAll } from '@/services/ManageV2Api';
import { useLinkEnumEffect } from '@/components/NiceForm/linkages/linkEnum';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import NiceForm from '@/components/NiceForm';
......@@ -24,6 +35,7 @@ import { AddressItemType, AddressValueType } from './components/AddressRadioGrou
import AddressRadioGroup from './components/AddressRadioGroupFormilyItem';
import styles from './index.less';
const formActions = createFormActions();
const {
onFormInit$,
......@@ -140,7 +152,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
};
const getAddressList = () => {
const fetchAction = addressType === 2 ? PublicApi.getLogisticsSelectListShipperAddress() : PublicApi.getLogisticsSelectListReceiverAddress();
const fetchAction = addressType === 2 ? getLogisticsSelectListShipperAddress() : getLogisticsSelectListReceiverAddress();
fetchAction.then((res: IRequestSuccess<AddressItemType[]>) => {
if (res.code === 1000) {
......@@ -186,7 +198,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
// 获取手机code
const fetchTelCode = async () => {
const { data, code } = await PublicApi.getManageCountryAreaGetTelCode();
const { data, code } = await getManageCountryAreaGetTelCode();
if (code === 1000) {
return data;
}
......@@ -255,11 +267,11 @@ const AddressSelect: React.FC<IProps> = (props) => {
try {
setSubmitLoading(true);
const addRes = addressType === 2
? await PublicApi.postLogisticsShipperAddressAdd({
? await postLogisticsShipperAddressAdd({
...commonPayload,
shipperName: name,
})
: await PublicApi.postLogisticsReceiverAddressAdd({
: await postLogisticsReceiverAddressAdd({
...commonPayload,
receiverName: name,
});
......@@ -300,12 +312,12 @@ const AddressSelect: React.FC<IProps> = (props) => {
try {
setSubmitLoading(true);
const addRes = addressType === 2
? await PublicApi.postLogisticsShipperAddressUpdate({
? await postLogisticsShipperAddressUpdate({
...commonPayload,
id: editAddressId.current,
shipperName: name,
})
: await PublicApi.postLogisticsReceiverAddressUpdate({
: await postLogisticsReceiverAddressUpdate({
...commonPayload,
id: editAddressId.current,
receiverName: name,
......@@ -383,7 +395,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
FormPath.setIn(targetState, 'props.x-props.hasFeedback', true);
FormPath.setIn(targetState, 'loading', true);
});
const areaRes = await PublicApi.getManageAreaAll();
const areaRes = await getManageAreaAll();
formActions.setFieldState('provinceCode', targetState => {
FormPath.setIn(targetState, 'loading', false);
......@@ -424,7 +436,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
FormPath.setIn(targetState, 'props.x-props.hasFeedback', true);
FormPath.setIn(targetState, 'loading', true);
});
const areaRes = await PublicApi.getManageAreaAll();
const areaRes = await getManageAreaAll();
formActions.setFieldState('provinceCode', targetState => {
FormPath.setIn(targetState, 'loading', false);
......@@ -442,7 +454,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
value: v.code,
})));
});
const res = addressType === 2 ? await PublicApi.getLogisticsShipperAddressGet({ id: `${id}` }) : await PublicApi.getLogisticsReceiverAddressGet({ id: `${id}` });
const res = addressType === 2 ? await getLogisticsShipperAddressGet({ id: `${id}` }) : await getLogisticsReceiverAddressGet({ id: `${id}` });
if (res.code === 1000) {
formActions.setFieldValue('name', addressType === 2 ? (res.data as GetLogisticsShipperAddressGetResponse).shipperName : (res.data as GetLogisticsReceiverAddressGetResponse).receiverName);
formActions.setFieldValue('provinceCode', res.data.provinceCode, 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