Commit 24e3ad17 authored by FE-安焕焕's avatar FE-安焕焕 👣

Merge branch 'logistics' into 'master'

Logistics

See merge request !3
parents eef6204f 95f2ba4a
/* eslint-disable no-restricted-syntax */ /* eslint-disable no-restricted-syntax */
/* eslint-disable guard-for-in */ /* eslint-disable guard-for-in */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Modal, Timeline, Tabs } from 'antd'; import { Modal, Timeline } from 'antd';
import style from '../index.less';
import { getLogisticsInfo } from '../service';
const { TabPane } = Tabs;
const LogisticsCom = props => { const LogisticsCom = props => {
const { modalVisible, onCancel } = props; const { modalVisible, onCancel } = props;
const [result, setResult] = useState({}); const [result, setResult] = useState({});
const getInfo = async (companyCode, logisticsNo) => {
const data = await getLogisticsInfo(companyCode, logisticsNo);
return data;
};
useEffect(() => { useEffect(() => {
setResult(props.value); setResult(props.value);
}); });
const callback = async key => {
const params = key.split('+');
if (result[params[1]]?.detailList) {
return;
}
const data = getInfo(params[0], params[1]);
result[params[1]].detailList = data?.logisticsList?.[0]?.detailList ?? [];
};
const render = () => {
const dom = [];
// eslint-disable-next-line guard-for-in
// eslint-disable-next-line no-restricted-syntax
for (const key in result) {
const value = result[key];
dom.push(
<TabPane
className={style.tabpane}
tab={value?.expressCompanyName + value?.deliveryNo}
key={`${value?.expressCompanyCode} + ${key}`}
tabBarStyle={{ height: '200px' }}
>
{value?.detailList?.length ? (
<Timeline>
{value?.detailList?.map((item, index) => (
<Timeline.Item color={index > 0 ? 'gray' : 'blue'}>
<p>{item.desc}</p>
<p>{item.logisticsTime}</p>
</Timeline.Item>
))}
</Timeline>
) : (
'暂无物流信息'
)}
</TabPane>,
);
}
return dom;
};
return ( return (
<Modal <Modal
destroyOnClose destroyOnClose
title="物流信息" title={`${result?.expressCompanyName}-${result?.deliveryNo}`}
visible={modalVisible} visible={modalVisible}
onCancel={() => onCancel()} onCancel={() => onCancel()}
onOk={() => onCancel()} onOk={() => onCancel()}
afterClose={() => setResult({})} afterClose={() => setResult({})}
bodyStyle={{ maxHeight: '600px', minHeight: '200px', overflow: 'auto' }} bodyStyle={{ maxHeight: '600px', minHeight: '200px', overflow: 'auto' }}
footer={[]}
> >
<Tabs defaultActiveKey="1" onChange={callback}> {result?.detailList?.length ? (
{render()} <Timeline>
</Tabs> {result?.detailList?.map((item, index) => (
// eslint-disable-next-line react/no-array-index-key
<Timeline.Item color={index > 0 ? 'gray' : 'blue'} key={index}>
<p>{item.desc}</p>
<p>{item.logisticsTime}</p>
</Timeline.Item>
))}
</Timeline>
) : (
'暂无物流信息'
)}
</Modal> </Modal>
); );
}; };
......
import { Button, notification } from 'antd'; import { Button } from 'antd';
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
getLogistics, getLogistics,
downOrder, downOrder,
getLogisticsInfo, getLogisticsInfo,
getJDLogisticsInfo,
} from './service'; } from './service';
const TableList = props => { const TableList = props => {
...@@ -27,6 +28,34 @@ const TableList = props => { ...@@ -27,6 +28,34 @@ const TableList = props => {
const actionRef = useRef(); const actionRef = useRef();
const ref = useRef(FormInstance); const ref = useRef(FormInstance);
const handleCom = async (record, skuItem) => {
const tempObj = {
expressCompanyCode: skuItem?.expressCompanyCode ?? '',
expressCompanyName: skuItem.expressCompanyName ?? '',
deliveryNo: skuItem?.deliveryNo ?? '',
detailList: [],
key: Date.now(),
};
const skuSource = record.skuSource?.value ?? null;
const sourceItem = [2, 5]; // 2:京东企业购;5:京东开普勒;
const isJD = sourceItem.includes(skuSource);
const data = isJD
? await getJDLogisticsInfo(skuItem.orderSkuId)
: await getLogisticsInfo(skuItem?.expressCompanyCode, skuItem?.deliveryNo);
if (!data) {
return;
}
tempObj.expressCompanyName = data?.logisticsName || tempObj.expressCompanyName;
tempObj.deliveryNo = data?.logisticsBillNo || tempObj.deliveryNo;
if (data.logisticsList?.length) {
data.logisticsList.forEach(v => {
tempObj.detailList = [...tempObj.detailList, ...v.detailList];
});
}
handleComModalVisible(true);
setLogisticsComList(tempObj);
};
const renderContent = (record, key) => const renderContent = (record, key) =>
record.mchOrderSkuVoList.map((item, index) => ( record.mchOrderSkuVoList.map((item, index) => (
<p <p
...@@ -34,34 +63,25 @@ const TableList = props => { ...@@ -34,34 +63,25 @@ const TableList = props => {
'tableContent', 'tableContent',
index < record?.mchOrderSkuVoList?.length - 1 ? 'border' : null, index < record?.mchOrderSkuVoList?.length - 1 ? 'border' : null,
].join(' ')} ].join(' ')}
key={item.orderSkuId}
> >
{key === 'skuName' ? <PopoverDom name={item[key]} url={item.imageUrl} /> : ''} {key === 'skuName' ? <PopoverDom name={item[key]} url={item.imageUrl} /> : ''}
{item[key]} {key === 'action' && props.type === 2 ? (
<Button
size="small"
type="primary"
onClick={() => {
handleCom(record, item);
}}
>
查看物流
</Button>
) : (
item[key]
)}
</p> </p>
)); ));
const handleCom = async record => {
const tempObj = {};
// eslint-disable-next-line no-unused-expressions
record?.mchOrderSkuVoList?.forEach(item => {
if (item.deliveryNo && !(item.deliveryNo in tempObj)) {
tempObj[item.deliveryNo] = {
deliveryNo: item.deliveryNo,
expressCompanyCode: item.expressCompanyCode,
expressCompanyName: item.expressCompanyName,
};
}
});
const keys = Object.keys(tempObj);
if (!keys.length) {
notification.warning({ message: '暂无物流信息' });
return;
}
const firstObj = tempObj[keys[0]];
const data = await getLogisticsInfo(firstObj?.expressCompanyCode, firstObj?.deliveryNo);
tempObj[keys[0]].detailList = data?.logisticsList?.[0]?.detailList || [];
setLogisticsComList(tempObj);
handleComModalVisible(true);
};
const columns = [ const columns = [
{ {
title: '订单ID', title: '订单ID',
...@@ -121,7 +141,6 @@ const TableList = props => { ...@@ -121,7 +141,6 @@ const TableList = props => {
className: 'colStyle', className: 'colStyle',
render: (_, record) => renderContent(record, 'thirdSpuNo'), render: (_, record) => renderContent(record, 'thirdSpuNo'),
}, },
{ {
title: '收货人手机', title: '收货人手机',
dataIndex: 'receiverPhone', dataIndex: 'receiverPhone',
...@@ -161,6 +180,15 @@ const TableList = props => { ...@@ -161,6 +180,15 @@ const TableList = props => {
hideInSearch: true, hideInSearch: true,
render: (_, record) => renderContent(record, 'deliveryNo'), render: (_, record) => renderContent(record, 'deliveryNo'),
}, },
{
title: '物流信息',
dataIndex: 'action',
key: 'action',
width: 150,
hideInSearch: true,
className: 'colStyle',
render: (_, record) => renderContent(record, 'action'),
},
{ {
title: '订单状态', title: '订单状态',
dataIndex: 'orderStatus', dataIndex: 'orderStatus',
...@@ -221,21 +249,6 @@ const TableList = props => { ...@@ -221,21 +249,6 @@ const TableList = props => {
{props.type === 2 ? '更新物流信息' : '填写物流信息'} {props.type === 2 ? '更新物流信息' : '填写物流信息'}
</Button> </Button>
)} )}
{props.type === 2 ? (
<Button
type="primary"
style={{
marginBottom: '10px',
}}
onClick={() => {
handleCom(record);
}}
>
查询物流信息
</Button>
) : (
''
)}
</React.Fragment> </React.Fragment>
), ),
}, },
...@@ -287,7 +300,6 @@ const TableList = props => { ...@@ -287,7 +300,6 @@ const TableList = props => {
> >
{resetText} {resetText}
</Button>, </Button>,
// props.type === 2 ? null : [...exportBtn],
]; ];
const toolBarRenderFn = () => [ const toolBarRenderFn = () => [
...@@ -310,7 +322,7 @@ const TableList = props => { ...@@ -310,7 +322,7 @@ const TableList = props => {
actionRef={actionRef} actionRef={actionRef}
request={params => queryToSendFn({ ...params })} request={params => queryToSendFn({ ...params })}
columns={columns} columns={columns}
rowKey={r => r.orderId} rowKey={r => r.orderNo}
formRef={ref} formRef={ref}
toolBarRender={toolBarRenderFn} toolBarRender={toolBarRenderFn}
search={{ search={{
...@@ -333,6 +345,7 @@ const TableList = props => { ...@@ -333,6 +345,7 @@ const TableList = props => {
onCancel={() => handleComModalVisible(false)} onCancel={() => handleComModalVisible(false)}
modalVisible={LogisticsComModalVisible} modalVisible={LogisticsComModalVisible}
value={LogisticsComList} value={LogisticsComList}
key={LogisticsComList.key}
/> />
</PageHeaderWrapper> </PageHeaderWrapper>
); );
......
...@@ -7,29 +7,37 @@ import config from '../../../../config/env.config'; ...@@ -7,29 +7,37 @@ import config from '../../../../config/env.config';
// 待发货订单 // 待发货订单
export async function queryToSend(params) { export async function queryToSend(params) {
const { try {
data: { current, records, total, size }, const {
} = await request.post('/api/kdsp/op/mch-order/list-v2', { data: { current, records, total, size },
prefix: config.kdspApi, } = await request.post('/api/kdsp/op/mch-order/list-v2', {
data: stringify(_.omitBy(params, v => !v)), prefix: config.kdspApi,
headers: { data: stringify(_.omitBy(params, v => !v)),
'Content-Type': 'application/x-www-form-urlencoded', headers: {
}, 'Content-Type': 'application/x-www-form-urlencoded',
}); },
return { });
current, return {
data: records.map(v => ({ ...v, logisticsStatus: `_${v.logisticsStatus}` })), current,
total, data: records.map(v => ({ ...v, logisticsStatus: `_${v.logisticsStatus}` })),
pageSize: size, total,
}; pageSize: size,
};
} catch (error) {
return {};
}
} }
// 快递公司 // 快递公司
export async function queryExpress() { export async function queryExpress() {
const { data } = await request.get('/api/kdsp/op/express/list', { try {
prefix: config.kdspApi, const { data } = await request.get('/api/kdsp/op/express/list', {
}); prefix: config.kdspApi,
return data; });
return data;
} catch (error) {
return {};
}
} }
export async function updateExpress(params) { export async function updateExpress(params) {
...@@ -85,7 +93,13 @@ export async function getLogisticsInfo(companyCode, logisticsNo) { ...@@ -85,7 +93,13 @@ export async function getLogisticsInfo(companyCode, logisticsNo) {
); );
return data; return data;
} }
// 京东企业购和京东开普勒物流信息
export async function getJDLogisticsInfo(orderSkuId) {
const { data } = await request.get(`/api/kdsp/op/logistics/track-list?orderSkuId=${orderSkuId}`, {
prefix: config.kdspApi,
});
return data;
}
// 批量发货订单 // 批量发货订单
export async function queryToBatchSend(params) { export async function queryToBatchSend(params) {
const transformedParam = { const transformedParam = {
......
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