Commit 05dc8b11 authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加新增退货发货单据逻辑

parent 25129ac6
......@@ -2,36 +2,104 @@
* @Author: XieZhiXiong
* @Date: 2021-08-04 15:53:06
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-04 16:49:47
* @LastEditTime: 2021-08-12 16:28:45
* @Description: 新增退货发货单
*/
import React from 'react';
import React, { useState } from 'react';
import { FormEffectHooks } from '@formily/antd';
import { history, Prompt } from 'umi';
import moment from 'moment';
import { DOC_TYPE_RETURN_INVOICE } from '@/constants/commodity';
import BillsFormPage, { RelatedInfoType } from '@/pages/transaction/stockSellStorage/bills/components/BillsFormPage';
import { PATTERN_MAPS } from '@/constants/regExp';
import BillsFormPage, { RelatedInfoDataType, BillSubmitValuesType } from '@/pages/transaction/stockSellStorage/bills/components/BillsFormPage';
import { usePageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api';
const {
onFormInputChange$,
} = FormEffectHooks;
const ReturnAddDeliverBill = () => {
const { id } = usePageStatus();
const { applyId } = usePageStatus();
const [unsaved, setUnsaved] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const fetchRelatedInfo = (): Promise<RelatedInfoType> => {
const fetchRelatedInfo = (): Promise<RelatedInfoDataType> => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
relatedNo: 'FPTY12',
memberName: '温州龙昌手袋有限公司',
address: '张三 / 185 2929 6758 广东省广州市海珠区新港东路1068号中洲中心北塔6楼',
logisticsTypeName: '物流',
});
}, 2000);
PublicApi.getAsReturnGoodsGetDetailByConsumer({
returnId: applyId,
}).then((res) => {
if (res.code === 1000) {
resolve({
relatedNo: res.data.applyNo,
memberName: res.data.supplierName,
address: `${res.data.returnGoodsAddress?.receiveUserName || ''} / ${res.data.returnGoodsAddress?.receiveUserTel || ''} ${res.data.returnGoodsAddress?.receiveAddress || ''}`,
logisticsType: res.data.returnGoodsAddress?.deliveryType,
billDetails: res.data.goodsDetailList.map((item) => ({
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.category,
price: item.purchasePrice,
relatedCount: item.returnCount,
})),
});
}
reject();
}).catch((err) => {
reject(err);
});
});
};
const handleSubmit = (values: BillSubmitValuesType) => {
PublicApi.postAsReturnGoodsAddReturnDeliveryGoods({
returnId: applyId,
deliveryTime: values.createTime ? moment(values.createTime).valueOf() : 0,
orderAbstract: values.digest,
remark: '',
inventoryName: values.inventoryName,
inventoryRole: values.inventoryRole,
detailList: values.billDetails.map((item) => ({
orderNo: item.orderNo,
productId: item.productId,
productName: item.productName,
category: item.category,
brand: item.brand,
unit: item.unit,
count: item.count,
})),
}).then((res) => {
if (res.code === 1000) {
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
} else {
setSubmitLoading(false);
}
});
};
return (
<BillsFormPage
billType={DOC_TYPE_RETURN_INVOICE}
fetchRelatedInfo={fetchRelatedInfo}
/>
<>
<BillsFormPage
billType={DOC_TYPE_RETURN_INVOICE}
fetchRelatedInfo={fetchRelatedInfo}
submitLoading={submitLoading}
onSubmit={handleSubmit}
customEffects={() => {
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</>
);
};
......
......@@ -2,13 +2,12 @@
* @Author: XieZhiXiong
* @Date: 2020-11-06 16:30:44
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-08 15:56:51
* @LastEditTime: 2021-08-12 18:02:29
* @Description: 待新增退货发货单
*/
import React, { useState, useRef } from 'react';
import { Card, Badge, Progress, Button, Modal } from 'antd';
import { Card, Badge, Button, Modal } from 'antd';
import {
ClockCircleOutlined,
ExclamationCircleOutlined,
} from '@ant-design/icons';
import { history, Link } from 'umi';
......@@ -22,10 +21,6 @@ import {
RETURN_INNER_STATUS_NOT_ADDED_RETURN_DELIVERY,
RETURN_INNER_STATUS_UNREVIEWED_RETURN_DELIVERY,
} from '@/constants/afterService';
import {
DOC_TYPE_RETURN_INVOICE,
DEPENDENT_DOC_RETURN,
} from '@/constants/commodity';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import EyePreview from '@/components/EyePreview';
......@@ -112,13 +107,13 @@ const ReturnPrAddDeliver: React.FC = () => {
title: '退货发货单号',
dataIndex: 'returnDeliveryNo',
align: 'center',
render: (text, record) => (
<Link
to={`/memberCenter/tranactionAbility/stockSellStorage/bills/detail?id=${record.returnDeliveryId}`}
>
{text}
</Link>
),
// render: (text, record) => (
// <Link
// to={`/memberCenter/tranactionAbility/stockSellStorage/bills/detail?id=${record.returnDeliveryId}`}
// >
// {text}
// </Link>
// ),
},
{
title: '外部状态',
......@@ -145,7 +140,7 @@ const ReturnPrAddDeliver: React.FC = () => {
type="link"
onClick={
() =>
history.push(`/memberCenter/tranactionAbility/stockSellStorage/bills/add?relevanceInvoicesId=${record.returnId}&invoicesTypeId=${DOC_TYPE_RETURN_INVOICE}&relevanceInvoices=${DEPENDENT_DOC_RETURN}`)
history.push(`/memberCenter/afterService/returnApplication/returnPrAddDeliver/add?applyId=${record.returnId}`)
}
>
新增
......
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