Commit 4d3b5581 authored by XieZhiXiong's avatar XieZhiXiong

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

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