Commit d1689dec authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加 订单列表 跳转售后相关逻辑

parent bccb17f8
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-04 15:09:09
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-31 14:29:36
* @LastEditTime: 2021-01-07 16:57:04
* @Description: 维修商品抽屉组件
*/
import React, { useState, useEffect } from 'react';
......@@ -43,6 +43,10 @@ interface GoodsDrawerProps {
nestProps?: {
[key: string]: any,
};
/**
* 是否展示检索框
*/
searchable?: boolean;
/**
* 流程类型:1.订单交易流程 2.售后换货流程 3.售后退货流程 4.售后维修流程
......@@ -54,11 +58,11 @@ interface GoodsDrawerState {
page: number;
size: number;
searchVal: {
orderNo: string,
orderThe: string,
startCreateTime: string,
endCreateTime: string,
type: string,
orderNo?: string,
orderThe?: string,
startCreateTime?: string,
endCreateTime?: string,
type?: string,
},
dataSource: OrderListRes;
selectedRowKeys: number[];
......@@ -117,13 +121,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
this.state = {
page: 1,
size: PAGE_SIZE,
searchVal: {
orderNo: '',
orderThe: '',
startCreateTime: undefined,
endCreateTime: undefined,
type: undefined,
},
searchVal: {},
dataSource: {
totalCount: 0,
data: [],
......@@ -565,6 +563,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
title = '选择维修商品',
visible = false,
nestProps = {},
searchable = false,
} = this.props;
return (
......@@ -591,21 +590,23 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
destroyOnClose
>
<div className={styles.order}>
<div className={styles['order-head']}>
<NiceForm
actions={formActions}
onSubmit={this.handleSearch}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'orderNo',
FORM_FILTER_PATH,
);
}}
schema={listSearchSchema}
/>
</div>
{searchable && (
<div className={styles['order-head']}>
<NiceForm
actions={formActions}
onSubmit={this.handleSearch}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'orderNo',
FORM_FILTER_PATH,
);
}}
schema={listSearchSchema}
/>
</div>
)}
<div className={styles['order-body']}>
<NestTable
......@@ -630,15 +631,17 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
/>
</div>
<div className={styles['order-foot']}>
<Pagination
current={page}
pageSize={size}
total={dataSource.totalCount}
onChange={this.handlePaginationChange}
showQuickJumper
/>
</div>
{searchable && (
<div className={styles['order-foot']}>
<Pagination
current={page}
pageSize={size}
total={dataSource.totalCount}
onChange={this.handlePaginationChange}
showQuickJumper
/>
</div>
)}
</div>
</Drawer>
);
......
.desc {
:global {
.ant-descriptions-item-label {
min-width: 176px;
color: #909399;
}
}
......
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import ExchangeForm from './components/ExchangeForm';
const AddExchange: React.FC = () => {
const { orderId } = usePageStatus();
return (
<ExchangeForm isEdit />
<ExchangeForm orderId={orderId} isEdit />
);
};
......
......@@ -10,7 +10,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { GetAsReplaceGoodsPageReturnedGoodsResponse } from '@/services/AfterServiceApi';
import { GetAsReplaceGoodsPageReturnedGoodsResponseDetail } from '@/services/AfterServiceApi';
import { normalizeFiledata, FileData, isJSONStr } from '@/utils';
import { PurchaseOrderOutWorkStateTexts, ORDER_TYPE2 } from '@/constants';
import ReutrnEle from '@/components/ReturnEle';
......@@ -37,6 +37,10 @@ interface BillsFormProps {
id?: string;
// 是否是编辑的
isEdit?: boolean;
/**
* 订单id,从订单列表跳转过来的
*/
orderId?: number,
};
interface DetailInfo {
......@@ -51,16 +55,21 @@ interface DetailInfo {
innerStatus?: number,
innerStatusName?: string,
deliveryType?: number,
replaceGoodsList?: GetAsReplaceGoodsPageReturnedGoodsResponseDetail[],
/**
* 订单编号
*/
orderNo?: string,
}
const ExchangeForm: React.FC<BillsFormProps> = ({
id,
isEdit = false,
orderId,
}) => {
const [detailInfo, setDetailInfo] = useState<DetailInfo>({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
});
const [replaceGoodsList, setReplaceGoodsList] = useState<GetAsReplaceGoodsPageReturnedGoodsResponse>({ data: [], totalCount: 0 });
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [goodsValue, setGoodsValue] = useState([]);
......@@ -158,6 +167,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
return new Promise((resolve, reject) => {
PublicApi.getOrderOneBatchOrderList({
orderNo: detailInfo.orderNo,
...params,
supplyMembersId: supplierMemberValue[0].memberId,
supplyMembersRoleId: supplierMemberValue[0].roleId,
......@@ -172,7 +182,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
});
};
// 获取维修申请详情
// 获取换货申请详情
const getDetailInfo = () => {
if (!id) {
return;
......@@ -245,11 +255,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
] :
[]
,
...rest,
});
setReplaceGoodsList({
data: goodsDetailList.map(item => ({
replaceGoodsList: goodsDetailList.map(item => ({
...item,
extraData: {
remaining: item.purchaseCount || 0, // 已换货数量,这里取 采购数量判断即可
......@@ -257,7 +263,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
taskType,
},
})),
totalCount: goodsDetailList.length,
...rest,
});
setGoodsValue(goodsDetailList.map(item => item.orderRecordId));
}
......@@ -266,8 +272,56 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
});
};
// 获取订单详情
const getOrderDetailInfo = () => {
if (!orderId) {
return;
}
setInfoLoading(true);
PublicApi.getOrderProcurementOrderDetails({
id: `${orderId}`,
})
.then(res => {
if (res.code === 1000) {
const {
supplyMembersName,
supplyMembersId,
supplyMembersRoleId,
orderNo,
} = res.data;
addSchemaAction.setFieldState(
'*(supplierMember)',
state => {
state.props['x-component-props'].disabled = true;
}
);
setDetailInfo({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
supplierMember:
supplyMembersName ?
[
{
name: supplyMembersName,
memberId: supplyMembersId,
roleId: supplyMembersRoleId,
},
] :
[]
,
orderNo,
});
}
})
.finally(() => {
setInfoLoading(false);
});
};
useEffect(() => {
getDetailInfo();
getOrderDetailInfo();
}, []);
const handleAddGoods = () => {
......@@ -308,6 +362,8 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
innerStatusName,
applyNo,
applyTime,
orderNo,
...rest
} = value;
......@@ -449,8 +505,10 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
value.push(atom);
});
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index);
if (preValues.length) {
newData.reverse();
}
addSchemaAction.setFieldValue('replaceGoodsList', newData);
};
......@@ -499,10 +557,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
>
<Card>
<NiceForm
value={{
...detailInfo,
replaceGoodsList: replaceGoodsList.data,
}}
value={detailInfo}
previewPlaceholder=" "
expressionScope={{
TableAddButton,
......@@ -556,6 +611,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
nestProps={{
NestColumns: [tableColumn, childTableColumn],
}}
searchable={!orderId}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
......
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import RepairForm from './components/RepairForm';
const AddRepair: React.FC = () => {
const { orderId } = usePageStatus();
return (
<RepairForm isEdit />
<RepairForm orderId={orderId} isEdit />
);
};
......
......@@ -39,17 +39,26 @@ interface DetailInfo {
outerStatusName?: string,
innerStatus?: number,
innerStatusName?: string,
/**
* 订单编号
*/
orderNo?: string,
}
interface BillsFormProps {
id?: string;
// 是否是编辑的
isEdit?: boolean;
/**
* 订单id,从订单列表跳转过来的
*/
orderId?: number,
};
const RepairForm: React.FC<BillsFormProps> = ({
id,
isEdit = false,
orderId,
}) => {
const [detailInfo, setDetailInfo] = useState<DetailInfo>({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
......@@ -111,6 +120,53 @@ const RepairForm: React.FC<BillsFormProps> = ({
});
};
// 获取订单详情
const getOrderDetailInfo = () => {
if (!orderId) {
return;
}
setInfoLoading(true);
PublicApi.getOrderProcurementOrderDetails({
id: `${orderId}`,
})
.then(res => {
if (res.code === 1000) {
const {
supplyMembersName,
supplyMembersId,
supplyMembersRoleId,
orderNo,
} = res.data;
addSchemaAction.setFieldState(
'*(supplierMember)',
state => {
state.props['x-component-props'].disabled = true;
}
);
setDetailInfo({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
supplierMember:
supplyMembersName ?
[
{
name: supplyMembersName,
memberId: supplyMembersId,
roleId: supplyMembersRoleId,
},
] :
[]
,
orderNo,
});
}
})
.finally(() => {
setInfoLoading(false);
});
};
// 获取维修明细列表
const getRepairGoods = () => {
if (!id) {
......@@ -148,6 +204,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
return new Promise((resolve, reject) => {
PublicApi.getOrderOneBatchOrderList({
orderNo: detailInfo.orderNo,
...params,
supplyMembersId: supplierMemberValue[0].memberId,
supplyMembersRoleId: supplierMemberValue[0].roleId,
......@@ -164,6 +221,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
useEffect(() => {
getDetailInfo();
getOrderDetailInfo();
getRepairGoods();
}, []);
......@@ -195,6 +253,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
faultFileList = [],
repairGoodsList,
repairAddress,
orderNo,
...rest
} = values;
......@@ -292,7 +351,10 @@ const RepairForm: React.FC<BillsFormProps> = ({
value.push(atom);
});
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index);
if (preValues.length) {
newData.reverse();
}
addSchemaAction.setFieldValue('repairGoodsList', newData);
};
......@@ -390,6 +452,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
onConfirm={handleGoodsConfirm}
checked={goodsValue}
onChange={handleGoodsChange}
searchable={!orderId}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-06 16:30:44
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-07 11:12:29
* @LastEditTime: 2021-01-07 16:12:25
* @Description: 待新增退货发货单
*/
import React, { useState, useRef } from 'react';
......
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import ReturnForm from './components/ReturnForm';
const AddReturn: React.FC = () => {
const { orderId } = usePageStatus();
return (
<ReturnForm isEdit />
<ReturnForm orderId={orderId} isEdit />
);
};
......
......@@ -37,6 +37,10 @@ interface BillsFormProps {
id?: string;
// 是否是编辑的
isEdit?: boolean;
/**
* 订单id,从订单列表跳转过来的
*/
orderId?: number,
};
interface DetailInfo {
......@@ -51,11 +55,16 @@ interface DetailInfo {
innerStatus?: number,
innerStatusName?: string,
deliveryType?: number,
/**
* 订单编号
*/
orderNo?: string,
}
const ReturnForm: React.FC<BillsFormProps> = ({
id,
isEdit = false,
orderId,
}) => {
const [detailInfo, setDetailInfo] = useState<DetailInfo>({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
......@@ -165,6 +174,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
return new Promise((resolve, reject) => {
PublicApi.getOrderOneBatchOrderList({
orderNo: detailInfo.orderNo,
...params,
supplyMembersId: supplierMemberValue[0].memberId,
supplyMembersRoleId: supplierMemberValue[0].roleId,
......@@ -179,7 +189,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
});
};
// 获取维修申请详情
// 获取退货申请详情
const getDetailInfo = () => {
if (!id) {
return;
......@@ -270,8 +280,56 @@ const ReturnForm: React.FC<BillsFormProps> = ({
});
};
// 获取订单详情
const getOrderDetailInfo = () => {
if (!orderId) {
return;
}
setInfoLoading(true);
PublicApi.getOrderProcurementOrderDetails({
id: `${orderId}`,
})
.then(res => {
if (res.code === 1000) {
const {
supplyMembersName,
supplyMembersId,
supplyMembersRoleId,
orderNo,
} = res.data;
addSchemaAction.setFieldState(
'*(supplierMember)',
state => {
state.props['x-component-props'].disabled = true;
}
);
setDetailInfo({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
supplierMember:
supplyMembersName ?
[
{
name: supplyMembersName,
memberId: supplyMembersId,
roleId: supplyMembersRoleId,
},
] :
[]
,
orderNo,
});
}
})
.finally(() => {
setInfoLoading(false);
});
};
useEffect(() => {
getDetailInfo();
getOrderDetailInfo();
}, []);
const handleAddGoods = () => {
......@@ -477,8 +535,10 @@ const ReturnForm: React.FC<BillsFormProps> = ({
value.push(atom);
});
const concated = [...value, ...preValues];
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index).reverse();
const newData = concated.filter((item, index) => findLastIndex(concated, val => val.extraData.id === item.extraData.id) === index);
if (preValues.length) {
newData.reverse();
}
addSchemaAction.setFieldValue('returnGoodsList', newData);
};
......@@ -614,6 +674,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
nestProps={{
NestColumns: [tableColumn, childTableColumn],
}}
searchable={!orderId}
/>
<ReturnInfoDrawer
......
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