提交 db9c4851 作者: 龚洪江

修复:租赁地址回显

上级 366f4a76
...@@ -340,3 +340,16 @@ export type editAddressType = InterFunction< ...@@ -340,3 +340,16 @@ export type editAddressType = InterFunction<
>; >;
//地址管理-删除地址 //地址管理-删除地址
export type deleteAddressType = InterFunction<{ id: number }, any>; export type deleteAddressType = InterFunction<{ id: number }, any>;
// 地址管理-根据id查找
export type getUserAddressInfoType = InterFunction<
{ userAddressId: number },
{
takeAddress: string;
takeName: string;
takePhone: string;
takeRegion: string;
type: number;
districtCode: string;
id: number;
}
>;
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
editAddressType, editAddressType,
getCompanyInfoByIdType, getCompanyInfoByIdType,
getSecondDistrictInfo, getSecondDistrictInfo,
getUserAddressInfoType,
insertBAccountType, insertBAccountType,
insertRoleInfoType, insertRoleInfoType,
listBAccountPageType, listBAccountPageType,
...@@ -119,4 +120,7 @@ export class SystemManageAPI { ...@@ -119,4 +120,7 @@ export class SystemManageAPI {
// 地址管理-删除 // 地址管理-删除
static deleteAddress: deleteAddressType = (params) => static deleteAddress: deleteAddressType = (params) =>
axios.get('/oms/user-address/deleteById', { params }); axios.get('/oms/user-address/deleteById', { params });
// 地址管理-根据地址id查找
static getUserAddressInfo: getUserAddressInfoType = (params) =>
axios.get('/oms/user-address/getUserAddressInfo', { params });
} }
...@@ -104,6 +104,17 @@ const AddressInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -104,6 +104,17 @@ const AddressInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
const addOrEditAddressModalCancel = () => { const addOrEditAddressModalCancel = () => {
setAddOrEditAddressModalShow(false); setAddOrEditAddressModalShow(false);
}; };
// 获取地址
const getUserAddressInfo = (userAddressId: number, key: string) => {
SystemManageAPI.getUserAddressInfo({ userAddressId }).then(({ result }) => {
addressInfoForm.setFieldValue(
key,
result.takeName +
result.takePhone +
`(${result.takeRegion.split('/').join('') + result.takeAddress})`,
);
});
};
useEffect(() => { useEffect(() => {
getAddressList(); getAddressList();
...@@ -113,9 +124,9 @@ const AddressInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -113,9 +124,9 @@ const AddressInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
useEffect(() => { useEffect(() => {
if (rentGoodsDetails) { if (rentGoodsDetails) {
getUserAddressInfo(rentGoodsDetails.shipAddress, 'shipAddress');
getUserAddressInfo(rentGoodsDetails.returnAddress, 'returnAddress');
addressInfoForm.setFieldsValue({ addressInfoForm.setFieldsValue({
shipAddress: rentGoodsDetails.shipAddress,
returnAddress: rentGoodsDetails.returnAddress,
logisticsCompany: rentGoodsDetails.logisticsCompany, logisticsCompany: rentGoodsDetails.logisticsCompany,
modeOfDelivery: rentGoodsDetails.modeOfDelivery, modeOfDelivery: rentGoodsDetails.modeOfDelivery,
}); });
......
...@@ -68,7 +68,7 @@ const GoodsInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -68,7 +68,7 @@ const GoodsInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
<Input placeholder='请输入商品标题' maxLength={30} /> <Input placeholder='请输入商品标题' maxLength={30} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label='商品卖点' label='营销短语'
name='sellingPoint' name='sellingPoint'
rules={[{ required: true, message: '请输入商品卖点' }]} rules={[{ required: true, message: '请输入商品卖点' }]}
> >
......
...@@ -59,17 +59,21 @@ const RentDetail = () => { ...@@ -59,17 +59,21 @@ const RentDetail = () => {
key: string; key: string;
}[] }[]
>([]); >([]);
const [addressOptionList, setAddressOptionList] = useState<
{ label: string; value: number; districtCode: string }[]
>([]);
const [expressOptionList, setExpressOptionList] = useState<{ label: string; value: string }[]>( const [expressOptionList, setExpressOptionList] = useState<{ label: string; value: string }[]>(
[], [],
); );
// 寄出地址跟归还地址str
const [addressStr, setAddressStr] = useState<any>({
shipAddress: '',
returnAddress: '',
});
//获取租赁商品详情 //获取租赁商品详情
const getRentGoodsDetail = (id: number) => { const getRentGoodsDetail = (id: number) => {
RentManageAPI.getLeaseGoodsDetails({ id }).then(({ result }) => { RentManageAPI.getLeaseGoodsDetails({ id }).then(({ result }) => {
if (result) { if (result) {
getAddressStr(result.shipAddress, 'shipAddress');
getAddressStr(result.returnAddress, 'returnAddress');
setRentGoodsDetails({ ...result }); setRentGoodsDetails({ ...result });
//转化数据 //转化数据
const covertSpecAttrList = result.specAttrList.map((v, index) => ({ const covertSpecAttrList = result.specAttrList.map((v, index) => ({
...@@ -174,19 +178,6 @@ const RentDetail = () => { ...@@ -174,19 +178,6 @@ const RentDetail = () => {
} }
}); });
}; };
//地址列表
const getAddressList = () => {
SystemManageAPI.getAddressList({}).then(({ result }) => {
if (result) {
const optionList = result.map((v) => ({
label: v.takeName + v.takePhone + `(${v.takeRegion.split('/').join('') + v.takeAddress})`,
value: v.id,
districtCode: v.districtCode,
}));
setAddressOptionList(optionList);
}
});
};
//物流公司列表 //物流公司列表
const getListExpressInfo = () => { const getListExpressInfo = () => {
OrderManageAPI.listExpressInfo().then(({ result }) => { OrderManageAPI.listExpressInfo().then(({ result }) => {
...@@ -199,6 +190,16 @@ const RentDetail = () => { ...@@ -199,6 +190,16 @@ const RentDetail = () => {
} }
}); });
}; };
// 地址名称
const getAddressStr = (userAddressId: number, key: string) => {
SystemManageAPI.getUserAddressInfo({ userAddressId }).then(({ result }) => {
addressStr[key] =
result.takeName +
result.takePhone +
`(${result.takeRegion.split('/').join('') + result.takeAddress})`;
setAddressStr({ ...addressStr });
});
};
//返回 //返回
const backRoute = () => { const backRoute = () => {
...@@ -207,7 +208,6 @@ const RentDetail = () => { ...@@ -207,7 +208,6 @@ const RentDetail = () => {
useEffect(() => { useEffect(() => {
getLeaseTermInfo(); getLeaseTermInfo();
getAddressList();
getListExpressInfo(); getListExpressInfo();
}, []); }, []);
...@@ -327,12 +327,8 @@ const RentDetail = () => { ...@@ -327,12 +327,8 @@ const RentDetail = () => {
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
<Descriptions title='物流信息' bordered column={2} style={{ marginTop: '10px' }}> <Descriptions title='物流信息' bordered column={2} style={{ marginTop: '10px' }}>
<Descriptions.Item label='发货地址'> <Descriptions.Item label='发货地址'>{addressStr.shipAddress}</Descriptions.Item>
{addressOptionList.find((v) => v.value === rentGoodsDetails?.shipAddress)?.label} <Descriptions.Item label='归还地址'>{addressStr.returnAddress}</Descriptions.Item>
</Descriptions.Item>
<Descriptions.Item label='归还地址'>
{addressOptionList.find((v) => v.value === rentGoodsDetails?.returnAddress)?.label}
</Descriptions.Item>
<Descriptions.Item label='寄出物流'> <Descriptions.Item label='寄出物流'>
{expressOptionList.find((v) => v.value === rentGoodsDetails?.logisticsCompany)?.label} {expressOptionList.find((v) => v.value === rentGoodsDetails?.logisticsCompany)?.label}
</Descriptions.Item> </Descriptions.Item>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论