Commit 691c8f14 authored by XieZhiXiong's avatar XieZhiXiong

feat: 对接新增售后换货简单流程

parent 424ede16
......@@ -7,7 +7,7 @@ import moment from 'moment';
import { findLastIndex } from 'lodash';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { GetAsReplaceGoodsPageReturnedGoodsResponseDetail } from '@/services/AfterServiceV2Api';
import { normalizeFiledata, FileData } from '@/utils';
......@@ -49,7 +49,82 @@ interface BillsFormProps {
* 订单id,从订单列表跳转过来的
*/
orderId?: number,
};
}
type ReplaceGoodsListItemType = {
/**
* 订单号
*/
orderNo: string,
/**
* 商品id
*/
productId: string,
/**
* 商品名称
*/
productName: string,
/**
* 品类
*/
category: string,
/**
* 品牌
*/
brand: string,
/**
* 单位
*/
unit: string,
/**
* 采购数量
*/
purchaseCount: number,
/**
* 物料编号
*/
associatedProductId: string,
/**
* 物料名称、规格
*/
associatedProductName: string,
/**
* 物料品类
*/
associatedCategory: string,
/**
* 物料品牌
*/
associatedBrand: string,
/**
* 物料单位
*/
associatedUnit: string,
/**
* 关联报价商品ID、名称、规格、品类、品牌
*/
associated: string,
/**
* 采购单价
*/
purchasePrice: number,
/**
* 采购金额
*/
purchaseAmount: number,
/**
* 换货数量
*/
replaceCount: number,
/**
* 换货理由
*/
replaceReason: string,
/**
* 额外的数据
*/
extraData: { [key: string]: any },
}
interface DetailInfo {
applyTime: string;
......@@ -63,22 +138,29 @@ interface DetailInfo {
innerStatus?: number,
innerStatusName?: string,
deliveryType?: number,
replaceGoodsList?: GetAsReplaceGoodsPageReturnedGoodsResponseDetail[],
/**
* 订单编号
*/
orderNo?: string,
/**
* 商品数据
*/
replaceGoodsList?: ReplaceGoodsListItemType[],
}
interface OrderNoProps {
value: any,
name: string,
}
const OrderNo = (props: OrderNoProps) => {
const { value } = props;
const { value, name } = props;
const extraData = addSchemaAction.getFieldValue(FormPath.transform(name, /\d/, $1 => {
return `replaceGoodsList.${$1}.extraData`;
}));
return (
<a
href={`/memberCenter/afterService/exchangeApplication/exchangePrSubmit/orderDetail?orderNo=${value}`}
href={`/memberCenter/afterService/returnApplication/returnPrSubmit/orderDetail?id=${extraData?.orderId}`}
target="_blank"
>
{value}
......@@ -113,10 +195,9 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
{
title: '订单号',
dataIndex: 'orderNo',
align: 'center',
render: (text, record) => (
<a
href={`/memberCenter/afterService/exchangeApplication/exchangePrSubmit/orderDetail?id=${record.id}`}
href={`/memberCenter/afterService/exchangeApplication/exchangePrSubmit/orderDetail?id=${record.orderId}`}
target="_blank"
        >
{text}
......@@ -125,30 +206,24 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
},
{
title: '订单摘要',
dataIndex: 'orderThe',
align: 'center',
dataIndex: 'digest',
ellipsis: true,
},
{
title: '供应会员',
dataIndex: 'supplyMembersName',
align: 'center',
dataIndex: 'vendorMemberName',
},
{
title: '下单时间',
dataIndex: 'createTime',
align: 'center',
render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
},
{
title: '订单状态',
dataIndex: 'outerStatusName',
align: 'center',
},
{
title: '订单类型',
dataIndex: 'type',
align: 'center',
render: text => ORDER_TYPE2[text],
dataIndex: 'orderTypeName',
},
isMateriel ? {
title: '合同编号',
......@@ -166,74 +241,73 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
].filter(Boolean) as ColumnType<any>[];
const childTableColumn: ColumnType<any>[] = ([
!isMateriel ?{
!isMateriel ? {
title: '商品ID',
dataIndex: 'productId',
align: 'center',
dataIndex: 'productNo',
} : {
title: '物料编号',
dataIndex: 'materialCode',
align: 'center',
dataIndex: 'productNo',
},
!isMateriel ? {
title: '商品名称',
dataIndex: 'productName',
align: 'center',
dataIndex: 'name',
ellipsis: true,
} : {
title: '物料名称、规格',
dataIndex: 'materialName',
align: 'center',
render: (text, record) => `${text}/${record.materialType}`,
dataIndex: 'name',
render: (text, record) => `${text}/${record.quotedSpec}`,
},
{
title: '品类',
dataIndex: !isMateriel ? 'category' : 'materialCategory',
align: 'center',
dataIndex: !isMateriel ? 'category' : 'quotedCategory',
},
{
title: '品牌',
dataIndex: !isMateriel ? 'brand' : 'materialBrand',
align: 'center',
dataIndex: !isMateriel ? 'brand' : 'quotedBrand',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
},
{
title: !isPointsOrder ? '订单数量' : '兑换数量',
dataIndex: 'purchaseCount',
align: 'center',
dataIndex: 'quantity',
},
{
title: !isPointsOrder ? '单价' : '所需积分',
dataIndex: 'price',
align: 'center',
},
{
title: !isPointsOrder ? '采购金额' : '所需积分小计',
dataIndex: 'amount',
align: 'center',
render: (_, record) => (record.purchaseCount * record.price).toFixed(2),
dataIndex: 'paidAmount',
},
{
title: '已换货数量',
dataIndex: 'replaceCount',
align: 'center',
dataIndex: 'exchangeCount',
},
]);
// 根据供应会员获取订单列表
const getOrderList = (params): Promise<OrderListRes> => {
const supplierMemberValue = addSchemaAction.getFieldValue('supplierMember');
const { startDate = null, endDate = null } = params;
const payload = { ...params };
if (startDate) {
payload.startDate = moment(+startDate).format('YYYY-MM-DD');
}
if (endDate) {
payload.endDate = moment(+endDate).format('YYYY-MM-DD');
}
return new Promise((resolve, reject) => {
PublicApi.getOrderOneBatchOrderList({
orderNo: detailInfo.orderNo,
PublicApi.getOrderCommonAfterSalePage({
...params,
supplyMembersId: supplierMemberValue[0].memberId,
supplyMembersRoleId: supplierMemberValue[0].roleId,
type: orderTypeValue,
vendorMemberId: supplierMemberValue[0].memberId,
vendorRoleId: supplierMemberValue[0].roleId,
orderType: orderTypeValue,
afterSalesType: 2, // 退货
orderNo: detailInfo.orderNo ? detailInfo.orderNo : params.orderNo || undefined,
}).then(res => {
if (res.code === 1000) {
resolve(res.data);
......@@ -269,7 +343,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
manualReturnGoodsAddress,
replaceDeliveryGoodsList,
replaceStatisticsList,
taskType,
taskTypeKey,
consumerName,
outerTaskList,
replaceBatch,
......@@ -326,10 +400,9 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
extraData: {
remaining: item.purchaseCount || 0, // 已换货数量,这里取 采购数量判断即可
id: item.orderRecordId,
taskType,
taskTypeKey,
},
associated: !item.materielId ? '' : `${item.productId}/${item.productName}/${item.category}/${item.brand}`,
materielNameAndType: `${item.materielName || ''}${item.materielType ? '/' + item.materielType : ''}`,
associated: !item.associatedProductId ? '' : `${item.associatedProductName}/${item.associatedType}/${item.associatedCategory}/${item.associatedBrand}`,
})),
...rest,
});
......@@ -503,13 +576,13 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
materielNameAndType,
...rest
}) => ({
orderRecordId: extraData.id,
replaceCount: +replaceCount,
...rest,
brand: brand || '',
unit: unit || '',
...rest,
orderRecordId: extraData.id,
replaceCount: +replaceCount,
})),
taskType: replaceGoodsList[0].extraData.taskType,
taskTypeKey: replaceGoodsList[0].extraData.taskTypeKey,
};
PublicApi.postAsReplaceGoodsSave(payload)
......@@ -566,34 +639,35 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
values.forEach(item => {
const atom = {
orderId: item.orderId,
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
productId: item.productNo,
productName: item.name,
category: item.category,
brand: item.brand,
unit: item.unit,
purchasePrice: item.price,
purchaseCount: item.purchaseCount,
purchaseAmount: +(item.price * item.purchaseCount).toFixed(2),
purchaseCount: item.quantity,
purchaseAmount: +(item.price * item.quantity).toFixed(2),
replaceCount: '',
replaceReason: '',
extraData: {
remaining: item.purchaseCount - (item.replaceCount || 0), // 可换货数量
remaining: item.quantity - (item.exchangeCount || 0), // 可换货数量
id: item.id,
taskType: item.processEnum,
taskTypeKey: item.processKey,
orderId: item.orderId,
},
isHasTax: item.tax,
taxRate: item.taxRate,
contractId: item.contractId,
contractNo: item.contractNo,
associated: !isMateriel ? '' : `${item.productId}/${item.productName}/${item.category}/${item.brand}`,
materielId: item.materialId,
materielNo: item.materialCode,
materielNameAndType: `${item.materialName || ''}${item.materialType ? '/' + item.materialType : ''}`,
materielName: item.materialName,
materielType: item.materialType,
materielCategory: item.materialCategory,
materielBrand: item.materialBrand,
materielUnit: item.materialUnit,
associated: !isMateriel ? '' : `${item.quotedProductNo}/${item.quotedName}/${item.quotedSpec}/${item.quotedCategory}/${item.quotedBrand}`,
associatedProductId: item.quotedProductNo || '',
associatedProductName: `${item.quotedName || ''}`,
associatedType: `${item.quotedSpec || ''}`,
associatedCategory: item.quotedCategory || '',
associatedBrand: item.quotedBrand || '',
associatedUnit: item.unit || '',
};
value.push(atom);
});
......
......@@ -305,32 +305,27 @@ export const addSchema = (orderType: number): ISchema => {
title: '订单号',
'x-component': 'OrderNo',
},
materielNo: {
associatedProductId: {
type: 'string',
title: '物料编号',
'x-component': 'Text',
},
materielNameAndType: {
associatedProductName: {
type: 'string',
title: '物料名称、规格',
'x-component': 'Text',
},
materielType: {
type: 'string',
title: '规格',
'x-component': 'Text',
},
materielCategory: {
associatedCategory: {
type: 'string',
title: '品类',
'x-component': 'Text',
},
materielBrand: {
associatedBrand: {
type: 'string',
title: '品牌',
'x-component': 'Text',
},
materielUnit: {
associatedUnit: {
type: 'string',
title: '单位',
'x-component': 'Text',
......@@ -397,11 +392,6 @@ export const addSchema = (orderType: number): ISchema => {
}
],
},
// 不用于展示,只用于收集值
id: {
type: 'string',
display: false,
},
// 其他数据,不用于展示,只用于收集值
extraData: {
type: 'string',
......@@ -488,9 +478,9 @@ export const addSchema = (orderType: number): ISchema => {
title: '退货发货地址',
type: 'string',
visible: false,
'x-component': 'AddressFormItem',
'x-component': 'CustomAddressSelect',
'x-component-props': {
dataSource: [],
isDefaultAddress: true,
},
'x-rules': [
{
......@@ -504,9 +494,9 @@ export const addSchema = (orderType: number): ISchema => {
title: '退货自提地址',
type: 'string',
visible: false,
'x-component': 'AddressFormItem',
'x-component': 'CustomAddressSelect',
'x-component-props': {
dataSource: [],
isDefaultAddress: true,
},
'x-rules': [
{
......@@ -519,9 +509,10 @@ export const addSchema = (orderType: number): ISchema => {
deliveryAddress: {
title: '换货收货地址',
type: 'string',
'x-component': 'AddressFormItem',
'x-component': 'CustomAddressSelect',
'x-component-props': {
dataSource: [],
isDefaultAddress: true,
addressType: 1,
},
'x-rules': [
{
......
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