Commit 4d3b5581 authored by XieZhiXiong's avatar XieZhiXiong

feat: 售后换货支持积分订单

parent a26d6757
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-04 15:09:09
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-02-09 17:02:36
* @LastEditTime: 2021-02-19 15:03:36
* @Description: 维修商品抽屉组件
*/
import React, { useState, useEffect } from 'react';
......@@ -13,7 +13,13 @@ import BigNumber from 'bignumber.js';
import { ColumnType } from 'antd/lib/table/interface';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PurchaseOrderOutWorkStateTexts, ORDER_TYPE2, PAYWAY, PAY_CHANNEL, PayOutWorkState } from '@/constants';
import {
PurchaseOrderOutWorkStateTexts,
ORDER_TYPE2,
PAYWAY,
PAY_CHANNEL,
PayOutWorkState,
} from '@/constants';
import NiceForm from '@/components/NiceForm';
import NestTable from '@/components/NestTable';
import { goodItem, OrderListParams, OrderListRes } from './interface';
......@@ -23,24 +29,40 @@ import { PublicApi } from '@/services/api';
const formActions = createFormActions();
const PAGE_SIZE = 10;
const PAGE_SIZE = 16;
interface GoodsDrawerProps {
// 选中值(子表格的值)
/**
* 选中值(子表格的值)
*/
checked: number[];
// 抽屉标题
/**
* 抽屉标题
*/
title?: string;
// 是否可见的
/**
* 是否可见的
*/
visible: boolean;
// 关闭事件
/**
* 关闭事件
*/
onClose: () => void;
// 确定事件
/**
* 确定事件
*/
onConfirm: (values: goodItem[]) => void;
// 选项改变事件
/**
* 选项改变事件
*/
onChange: (value: number[]) => void;
// 获取订单列表数据
/**
* 获取订单列表数据
*/
fetchOrderList: (params: any) => Promise<OrderListRes>;
// NestTableProps
/**
* NestTableProps
*/
nestProps?: {
[key: string]: any,
};
......@@ -48,11 +70,10 @@ interface GoodsDrawerProps {
* 是否展示检索框
*/
searchable?: boolean;
/**
* 流程类型:1.订单交易流程 2.售后换货流程 3.售后退货流程 4.售后维修流程
*/
type: 1 | 2 | 3 | 4,
afterType: 1 | 2 | 3 | 4,
};
interface GoodsDrawerState {
......@@ -213,7 +234,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 获取订单列表
getOrderList = async () => {
const { page, size, searchVal } = this.state;
const { fetchOrderList, type } = this.props;
const { fetchOrderList, afterType } = this.props;
if (!fetchOrderList) {
return;
......@@ -229,7 +250,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
let processEnumRes = { data: [], code: 0 };
// 售后退货、换货才涉及工作流相关
if (type === 2 || type === 3) {
if (afterType === 2 || afterType === 3) {
// 获取对应订单列表的工作流类型
const payload = [];
......@@ -241,7 +262,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
memberId: product.memberId,
memberRoleId: product.memberRoleId,
shopId: item.shopId,
type, // 流程类型
type: afterType, // 流程类型
};
payload.push(atom);
});
......@@ -286,6 +307,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
...product,
orderNo: item.orderNo,
payInfoList: item.payInfoList,
orderType: item.type,
});
}
});
......@@ -540,7 +562,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 过滤工作流不同的 商品
filterProductByProcessEnum = (data) => {
// 售后退货、换货才涉及工作流相关
if (this.props.type !== 2 && this.props.type !== 3) {
if (this.props.afterType !== 2 && this.props.afterType !== 3) {
return data;
}
const first = data.length ? data[0] : null;
......@@ -548,9 +570,10 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
if (!first) {
return [];
}
const filtered = data.filter(item => item.processEnum === first.processEnum);
// 过滤工作流不同的的商品,并且 订单类型不同的订单
const filtered = data.filter(item => item.processEnum === first.processEnum && item.orderType === first.orderType);
if (filtered.length !== data.length) {
message.warning('已过滤掉售后工作流不同的商品');
message.warning('已过滤掉 售后工作流不同 / 订单类型不同的 商品');
}
return filtered;
};
......
......@@ -12,7 +12,12 @@ import { createFormActions, FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { GetAsReplaceGoodsPageReturnedGoodsResponseDetail } from '@/services/AfterServiceApi';
import { normalizeFiledata, FileData, isJSONStr } from '@/utils';
import { PurchaseOrderOutWorkStateTexts, ORDER_TYPE2 } from '@/constants';
import {
PurchaseOrderOutWorkStateTexts,
ORDER_TYPE2,
ORDER_TYPE2_POINTS,
ORDER_TYPE2_CHANNEL_POINTS,
} from '@/constants';
import ReutrnEle from '@/components/ReturnEle';
import StatusTag from '@/components/StatusTag';
import NiceForm from '@/components/NiceForm';
......@@ -131,7 +136,9 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
},
];
const childTableColumn: ColumnType<any>[] = [
const childTableColumn = (record): ColumnType<any>[] => {
const isPointsOrder = record.type === ORDER_TYPE2_POINTS || record.type === ORDER_TYPE2_CHANNEL_POINTS;
return [
{
title: '商品ID',
dataIndex: 'productId',
......@@ -158,17 +165,17 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
align: 'center',
},
{
title: '订单数量',
title: !isPointsOrder ? '订单数量' : '兑换数量',
dataIndex: 'purchaseCount',
align: 'center',
},
{
title: '单价',
title: !isPointsOrder ? '单价' : '所需积分',
dataIndex: 'price',
align: 'center',
},
{
title: '采购金额',
title: !isPointsOrder ? '采购金额' : '所需积分小计',
dataIndex: 'amount',
align: 'center',
render: (_, record) => (record.purchaseCount * record.price).toFixed(2),
......@@ -179,6 +186,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
align: 'center',
},
];
};
// 根据供应会员获取订单列表
const getOrderList = (params): Promise<OrderListRes> => {
......@@ -230,6 +238,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
outerTaskList,
replaceBatch,
replaceId,
orderType,
...rest
} = res.data;
......@@ -280,6 +289,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
remaining: item.purchaseCount || 0, // 已换货数量,这里取 采购数量判断即可
id: item.orderRecordId,
taskType,
orderType,
},
})),
...rest,
......@@ -299,6 +309,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
setInfoLoading(true);
PublicApi.getOrderProcurementOrderDetails({
id: `${orderId}`,
orderNo: '',
})
.then(res => {
if (res.code === 1000) {
......@@ -450,6 +461,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
...rest,
})),
taskType: replaceGoodsList[0].extraData.taskType,
orderType: replaceGoodsList[0].extraData.orderType,
};
PublicApi.postAsReplaceGoodsSave(payload)
......@@ -519,6 +531,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
remaining: item.purchaseCount - (item.replaceCount || 0), // 可换货数量
id: item.id,
taskType: item.processEnum,
orderType: item.orderType,
},
};
value.push(atom);
......@@ -621,7 +634,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
<GoodsDrawer
title="选择换货商品"
type={2}
afterType={2}
visible={visibleGoodsDrawer}
fetchOrderList={getOrderList}
onClose={() => setVisibleGoodsDrawer(false)}
......
......@@ -460,7 +460,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
</Card>
<GoodsDrawer
type={4}
afterType={4}
visible={visibleDrawer}
fetchOrderList={getOrderList}
onClose={() => setVisibleDrawer(false)}
......
......@@ -681,7 +681,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
<GoodsDrawer
title="选择退货商品"
type={3}
afterType={3}
visible={visibleGoodsDrawer}
fetchOrderList={getOrderList}
onClose={() => setVisibleGoodsDrawer(false)}
......
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