Commit 0c072309 authored by XieZhiXiong's avatar XieZhiXiong

添加退货申请手工发货相关、添加采购入库单单据编号字段

parent 83e99a23
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-04 15:09:09
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-14 09:42:05
* @LastEditTime: 2020-12-14 15:33:42
* @Description: 维修商品抽屉组件
*/
import React, { useState, useEffect } from 'react';
......@@ -135,6 +135,8 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
};
};
flattened = [];
tableColumn: ColumnType<any>[] = [
{
title: '订单号',
......@@ -222,42 +224,59 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
current: `${page}`,
pageSize: `${size}`,
...searchVal,
})
});
if (orderListRes) {
// 获取对应订单列表的工作流类型
// const payload = [];
// orderListRes.data.forEach(item => {
// item.productDateilss.forEach(product => {
// const atom = {
// productId: product.productId,
// memberId: product.memberId,
// memberRoleId: product.memberRoleId,
// shopId: item.shopId,
// type, // 流程类型
const payload = [];
orderListRes.data.forEach(item => {
item.productDateilss.forEach(product => {
const atom = {
productId: product.productId,
memberId: product.memberId,
memberRoleId: product.memberRoleId,
shopId: item.shopId,
type, // 流程类型
};
payload.push(atom);
});
});
const processEnumRes: any = await PublicApi.postOrderGetProcessEnum({
list: payload,
}, {
ctlType: 'none',
});
if (processEnumRes.code !== 1000) {
message.error('获取工作流枚举失败,请稍候再试');
return;
}
// const mockMap = {
// 1: 18,
// 2: 25,
// };
// payload.push(atom);
// });
// });
// const processEnumRes: any = await PublicApi.postOrderGetProcessEnum({
// list: payload,
// }, {
// ctlType: 'none',
// });
// console.log('processEnumRes', processEnumRes)
// if (processEnumRes.code !== 1000) {
// message.error('获取工作流枚举失败,请稍候再试');
// return;
// }
// 组装数据
let i = 0;
orderListRes.data.forEach(item => {
item.productDateilss.forEach(product => {
product.processEnum = processEnumRes.data[i].processEnum;
// product.processEnum = mockMap[Math.floor(Math.random()*2 + 1)];
i++;
// 防止重复添加数据
if (!this.flattened.find(flat => flat.id === product.id)) {
this.flattened.push({
...product,
orderNo: item.orderNo,
payInfoList: item.payInfoList,
});
}
});
});
this.setState({
dataSource: {
data: orderListRes.data.map((item, index) => ({
...item,
// processEnum: processEnumRes.data[index].processEnum,
})),
totalCount: orderListRes.totalCount,
},
dataSource: orderListRes,
});
}
this.setState({ loading: false });
......@@ -299,7 +318,6 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 子表格选中行
handleChildSelectChange = (record: any, selected: any, selectedRows: any) => {
console.log('selectedRows', selectedRows)
const {
childSelectedRowKeys,
dataSource: {
......@@ -314,11 +332,14 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
childArr.splice(childArr.findIndex((item: any) => item === record.id), 1);
}
// const filtered = this.filterProductByProcessEnum(childArr, data);
const fullData = this.findFullProductArr(childArr, this.flattened);
const filtered = this.filterProductByProcessEnum(fullData);
const filteredKeys = filtered.map(item => item.id);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr });
this.setState({ childSelectedRowKeys: filteredKeys });
}
this.triggerChange(childArr);
this.triggerChange(filteredKeys);
};
// 子表格选中所有行
......@@ -340,11 +361,14 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
childArr = childArr.filter((item: any) => !changeRows.some((e: any) => e.id === item));
}
// const filtered = this.filterProductByProcessEnum(childArr, data);
const fullData = this.findFullProductArr(childArr, this.flattened);
const filtered = this.filterProductByProcessEnum(fullData);
const filteredKeys = filtered.map(item => item.id);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr });
this.setState({ childSelectedRowKeys: filteredKeys });
}
this.triggerChange(childArr);
this.triggerChange(filteredKeys);
};
// 表格选中行
......@@ -362,17 +386,20 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 第一步 判断selected true:选中,false,取消选中
if (selected) {
// 第二步,父Table选中,子Table全选中(全部整合到一起,然后去重)
childArr = Array.from(new Set([...setChildArr, ...childArr]));
childArr = Array.from(new Set([...childArr, ...setChildArr]));
} else {
// 第二步,父Table取消选中,子Table全取消选中(针对childArr,过滤掉取消选中的父Table下的所有子Table的 id)
childArr = childArr.filter((item: any) => !setChildArr.some((e: any) => e === item));
}
// const filtered = this.filterProductByProcessEnum(childArr, data);
const fullData = this.findFullProductArr(childArr, this.flattened);
const filtered = this.filterProductByProcessEnum(fullData);
const filteredKeys = filtered.map(item => item.id);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr });
this.setState({ childSelectedRowKeys: filteredKeys });
}
this.triggerChange(childArr);
this.triggerChange(filteredKeys);
};
// 表格选中所有行
......@@ -390,14 +417,17 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
setChildArr = [...setChildArr, ...item.productDateilss.map((item: any) => item.id)];
});
// const filtered = this.filterProductByProcessEnum(setChildArr, data);
// 第一步判断 selected true:全选,false:取消全选
if (selected) {
// 第二步:父Table选中,子Table全选中,设置子Table 的 SelectedRowKeys
const fullData = this.findFullProductArr(setChildArr, this.flattened);
const filtered = this.filterProductByProcessEnum(fullData);
const filteredKeys = filtered.map(item => item.id);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: setChildArr });
this.setState({ childSelectedRowKeys: filteredKeys });
}
this.triggerChange(setChildArr);
this.triggerChange(filteredKeys);
} else {
// 第二步:父Table取消选中,子Table 全取消选中,设置子 Table 的 SelectedRowKeys
if (!('checked' in this.props)) {
......@@ -419,15 +449,15 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
if (onConfirm) {
// 从选中的子表格行 key,找到完整的信息
const fullDate = [];
data.forEach(item => {
item.productDateilss.forEach(product => {
this.flattened.forEach(product => {
if (childSelectedRowKeys.find(key => key === product.id)) {
fullDate.push({
...product,
orderNo: item.orderNo, // 手动补全订单单号
orderNo: product.orderNo, // 手动补全订单单号
payList:
item.payInfoList ?
item.payInfoList.map(item => {
product.payInfoList ?
product.payInfoList.map(item => {
const { payPrice, payTime, payWay, channel, ...rest } = item;
return {
payAmount: payPrice,
......@@ -443,15 +473,14 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
,
// 计算已支付金额,采购单价 * 支付比例 累加
payAmount:
item.payInfoList ?
item.payInfoList.reduce((prev, now) => {
product.payInfoList ?
product.payInfoList.reduce((prev, now) => {
return +((product.price * product.purchaseCount * (now.payRatio / 100)).toFixed(2)) + prev;
}, 0) :
0
});
}
});
});
onConfirm(fullDate);
}
this.handleClose();
......@@ -470,8 +499,19 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
}
};
findFullProductArr = (selectKeys, data) => {
const ret = [];
selectKeys.forEach(item => {
const current = data.find(dataItem => dataItem.id === item);
if (current) {
ret.push(current);
}
});
return ret;
};
// 过滤工作流不同的 商品
filterProductByProcessEnum = (selectKeys, data) => {
filterProductByProcessEnum = (data) => {
const first = data.length ? data[0] : null;
if (!first) {
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-09 10:48:12
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-18 17:31:42
* @LastEditTime: 2020-12-14 16:38:53
* @Description: 手动发货弹窗
*/
import React from 'react';
......@@ -10,6 +10,8 @@ import { Modal } from 'antd';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd';
import { DatePicker } from '@formily/antd-components'
import NiceForm from '@/components/NiceForm';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { PublicApi } from '@/services/api';
import { schema } from './schema';
const modalFormActions = createFormActions();
......@@ -43,6 +45,51 @@ const VerifyModal: React.FC<VerifyModalProps> = ({
}
};
// 获取发货地址
const fetchShipperAddress = (): Promise<any[]> => {
return new Promise((resolve, reject) => {
PublicApi.getLogisticsSelectListShipperAddress().then(res => {
if (res.code === 1000) {
const options =
res.data ?
res.data.map(item => ({
label: `${item.fullAddress}/${item.shipperName}/${item.phone}`,
value: item.id,
...item,
})) :
[];
resolve(options);
}
reject();
}).catch(() => {
reject();
});
});
};
// 获取物流公司
const fetchLogisticsCompany = (): Promise<any[]> => {
return new Promise((resolve, reject) => {
PublicApi.getLogisticsSelectListCompany({
cooperateType: '2', // 1-平台物流服务商,2-商户合作物流公司
}).then(res => {
if (res.code === 1000) {
const options =
res.data ?
res.data.map(item => ({
label: item.name,
value: item.id,
})) :
[];
resolve(options);
}
reject();
}).catch(() => {
reject();
});
});
};
return (
<Modal
title={title}
......@@ -54,7 +101,8 @@ const VerifyModal: React.FC<VerifyModalProps> = ({
>
<NiceForm
effects={($, { setFieldState }) => {
useAsyncSelect('deliveryAddress', fetchShipperAddress, ['label', 'value']);
useAsyncSelect('logisticsName', fetchLogisticsCompany, ['label', 'value']);
}}
components={{
DatePicker,
......
......@@ -17,17 +17,15 @@ export const schema: ISchema = {
labelAlign: 'top',
},
properties: {
address: {
deliveryAddress: {
type: 'string',
title: '发货地址',
enum: [
],
enum: [],
'x-component-props': {
placeholder: '请选择',
},
},
sendTime: {
deliveryTime: {
type: 'string',
title: '发货时间',
'x-component': 'DatePicker',
......@@ -38,7 +36,7 @@ export const schema: ISchema = {
style: { width: '100%' },
},
},
codeNo: {
logisticsOrderNo: {
type: 'string',
title: '发货单号',
required: true,
......@@ -46,13 +44,11 @@ export const schema: ISchema = {
placeholder: '请选择',
},
},
company: {
logisticsName: {
type: 'string',
title: '物流公司',
required: true,
enum: [
],
enum: [],
'x-component-props': {
placeholder: '请选择',
},
......
......@@ -277,3 +277,22 @@ export const REFUND_OUTER_STATUS_TAG_MAP = {
[REFUND_OUTER_STATUS_NOT_RECEIVED]: 'warning',
[REFUND_OUTER_STATUS_RECEIVED]: 'success',
};
// 工作流相关
/**
* 售后退货外部流转
*/
export const RETURN_GOODS_OUTER_DELIVERY = 18;
/**
* 售后换货外部流转
*/
export const EXCHANGE_GOODS_OUTER_DELIVERY = 20;
/**
* 售后换货手工发货
*/
export const EXCHANGE_GOODS_MANUAL_DELIVERY = 30;
/**
* 售后退货手工发货
*/
export const RETURN_GOODS_MANUAL_DELIVERY = 31;
\ No newline at end of file
......@@ -541,6 +541,7 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
<GoodsDrawer
title="选择换货商品"
type={2}
visible={visibleGoodsDrawer}
fetchOrderList={getOrderList}
onClose={() => setVisibleGoodsDrawer(false)}
......
......@@ -370,6 +370,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
</Card>
<GoodsDrawer
type={4}
visible={visibleDrawer}
fetchOrderList={getOrderList}
onClose={() => setVisibleDrawer(false)}
......
......@@ -6,6 +6,7 @@ import { SettingOutlined } from '@ant-design/icons';
import { usePageStatus } from '@/hooks/usePageStatus';
import ManualDeliveryModal from '../../components/ManualDeliveryModal';
import DetailInfo from '../components/DetailInfo';
import { RETURN_GOODS_MANUAL_DELIVERY } from '../../constants';
const ReturnPrDeliverVerify: React.FC = () => {
const { id } = usePageStatus();
......@@ -36,7 +37,9 @@ const ReturnPrDeliverVerify: React.FC = () => {
<>
<DetailInfo
id={id}
headExtra={() => (
headExtra={info => (
<>
{(info && info.taskType === RETURN_GOODS_MANUAL_DELIVERY) && (
<Button
type="default"
icon={<SettingOutlined />}
......@@ -45,6 +48,8 @@ const ReturnPrDeliverVerify: React.FC = () => {
手工退货发货
</Button>
)}
</>
)}
/>
<ManualDeliveryModal
......
......@@ -63,7 +63,6 @@ const ReturnForm: React.FC<BillsFormProps> = ({
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const [returnGoodsLoading, setReturnGoodsLoading] = useState(false);
const [orderInfo, setOrderInfo] = useState<OrderInfo>(null);
const [visibleGoodsDrawer, setVisibleGoodsDrawer] = useState(false);
const [visibleReturnInfoDrawer, setVisibleReturnInfoDrawer] = useState(false);
......@@ -153,7 +152,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
// 缺
{
title: '已退款金额',
dataIndex: 'returnCount2',
dataIndex: 'refunded',
align: 'center',
},
];
......@@ -248,47 +247,29 @@ const ReturnForm: React.FC<BillsFormProps> = ({
,
...rest,
});
}
}).finally(() => {
setInfoLoading(false);
});
};
// 获取退货明细列表
const getReturnGoods = () => {
if (!id) {
return;
}
setReturnGoodsLoading(true);
PublicApi.getAsReturnGoodsPageReturnedGoods({
returnId: id,
current: `${1}`,
pageSize: `${99999}`,
}).then(res => {
if (res.code === 1000) {
setReturnGoodsList(res.data);
setReturnGoodsList({
data: res.data.data.map(item => ({
data: goodsDetailList.map(item => ({
...item,
returnedCount:item.purchaseCount || 0, // 已退货数量,这里取 采购数量判断即可
returnedCount: item.purchaseCount || 0, // 已退货数量,这里取 采购数量判断即可
extraData: {
id: item.orderRecordId,
returnReason: item.returnReason,
payList: item.payList,
payList: item.payList || [],
id: item.orderRecordId || [],
taskType,
},
})),
totalCount: res.data.totalCount,
totalCount: goodsDetailList.length,
});
setGoodsValue(res.data && res.data.data ? res.data.data.map(item => item.orderRecordId) : []);
setGoodsValue(goodsDetailList.map(item => item.orderRecordId));
}
}).finally(() => {
setReturnGoodsLoading(false);
setInfoLoading(false);
});
};
useEffect(() => {
getDetailInfo();
getReturnGoods();
}, []);
const handleAddGoods = () => {
......@@ -405,7 +386,8 @@ const ReturnForm: React.FC<BillsFormProps> = ({
}),
isNeedReturn: 1,
})),
taskType: 18,
// taskType: returnGoodsList[0].taskType,
taskType: 31,
};
PublicApi.postAsReturnGoodsSave(payload)
......@@ -490,6 +472,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
id: item.id,
returnReason: '',
payList: item.payList,
taskType: item.processEnum,
},
};
value.push(atom);
......@@ -541,7 +524,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
);
return (
<Spin spinning={infoLoading || returnGoodsLoading}>
<Spin spinning={infoLoading}>
<PageHeaderWrapper
style={{
padding: 24,
......@@ -575,14 +558,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
<NiceForm
initialValues={{
...detailInfo,
returnGoodsList: returnGoodsList.data.map(item => ({
...item,
extraData: {
returnReason: item.returnReason,
payList: item.payList || [],
id: item.orderRecordId || [],
},
})),
returnGoodsList: returnGoodsList.data,
}}
expressionScope={{
TableAddButton,
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-14 11:26:50
* @LastEditTime: 2020-12-14 16:55:09
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -497,8 +497,11 @@ export const useBusinessEffects = (context, actions) => {
if (fieldState.name === 'invoicesTypeId') {
const invoicesTypeIdState = getFieldState('invoicesTypeId');
console.log('invoicesTypeIdState2', invoicesTypeIdState)
if (invoicesTypeIdState.value) {
const current = invoicesTypeIdState.originAsyncData.find(item => item.id === invoicesTypeIdState.value);
if (current) {
linkage.value('invoicesTypeCode', current.number);
}
......
......@@ -748,6 +748,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
}
PublicApi.postOrderPurchaseReceiptAdd({
...rest,
invoicesTypeCode: invoicesTypeCode,
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
......@@ -849,6 +850,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
}
PublicApi.postOrderSalesInvoiceOrder({
...rest,
invoicesTypeCode: invoicesTypeCode,
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
......
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