Commit 84b9e6c0 authored by XieZhiXiong's avatar XieZhiXiong

feat: 新增单据 退货入库单 相关逻辑

parent 928a8162
This diff is collapsed.
import React, { useState, useEffect } from 'react';
import { Input, Button, message } from 'antd';
import { LinkOutlined } from '@ant-design/icons';
import styled from 'styled-components';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import ModalTable from '@/components/ModalTable';
const RowStyleLayout = styled(props => <div {...props} />)`
width: 100%;
.relevance {
height: 100%;
background: #909399;
border-radius: 0;
&[disabled] {
background: #F4F5F7;
}
}
.ant-input-group-addon {
padding: 0;
border: none;
}
`;
const Relevance = props => {
const {
editable,
value = [],
} = props;
const {
modalProps = {
title: '标题',
width: 960,
},
selectionType = 'radio',
columns,
formilyProps,
tableProps = {},
fetchTableData,
title = '选择',
tip = '', // 点击按钮前的提示,用于前提需要提示的场景
disabled = false,
} = props.props['x-component-props'];
const tableRowKey = tableProps.rowKey || 'id';
const tableRowLableKey = tableProps.lableKey || ''; // Input展示用的 key val
const [visible, setVisible] = useState(false);
const [rowSelection, rowCtl] = useRowSelectionTable({ type: selectionType, customKey: tableRowKey });
useEffect(() => {
// Table 只能缓存 keys
const rowKeys = value.map(item => item[tableRowKey]);
rowCtl.setSelectedRowKeys(rowKeys);
rowCtl.setSelectRow(value);
}, [props.value, tableProps.rowKey]);
const handleConfirm = () => {
const rows = rowCtl.selectRow;
const keys = rows.map(item => item[tableRowKey]);
if (props.mutators) {
if (rows && rows.length) {
props.mutators.change(rows);
}
setVisible(false);
return;
}
rowCtl.setSelectedRowKeys(keys);
setVisible(false);
};
const handleModalVisible = () => {
if (!fetchTableData) {
message.warning(tip || '请传入 fetchTableData 属性,否则Table 将无法发起请求');
return;
}
setVisible(true);
};
return (
<RowStyleLayout>
<Input
value={
tableRowLableKey ?
value.map(item => item[tableRowLableKey]).join(',') :
''
}
addonAfter={(
<>
{editable && (
<Button
type="primary"
className="relevance"
icon={<LinkOutlined />}
onClick={handleModalVisible}
disabled={disabled}
block
>
{title}
</Button>
)}
</>
)}
disabled
/>
<ModalTable
confirm={handleConfirm}
cancel={() => setVisible(false)}
visible={visible}
width={960}
{...modalProps}
modalTitle={modalProps.title}
rowSelection={rowSelection}
columns={columns}
fetchTableData={fetchTableData}
formilyProps={formilyProps}
tableProps={tableProps}
/>
</RowStyleLayout>
);
};
Relevance.defaultProps = {};
Relevance.isFieldComponent = true;
export default Relevance;
import React, { useState, useEffect } from 'react';
import { Input, Button, message } from 'antd';
import { LinkOutlined } from '@ant-design/icons';
import styled from 'styled-components';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import ModalTable from '@/components/ModalTable';
const RowStyleLayout = styled(props => <div {...props} />)`
width: 100%;
.relevance {
height: 100%;
background: #909399;
border-radius: 0;
&[disabled] {
background: #F4F5F7;
}
}
.ant-input-group-addon {
padding: 0;
border: none;
}
`;
const Relevance = props => {
const {
editable,
value = [],
} = props;
const {
modalProps = {
title: '标题',
width: 960,
},
selectionType = 'radio',
columns,
formilyProps,
tableProps = {},
fetchTableData,
title = '选择',
tip = '', // 点击按钮前的提示,用于前提需要提示的场景
disabled = false,
} = props.props['x-component-props'];
const tableRowKey = tableProps.rowKey || 'id';
const tableRowLableKey = tableProps.lableKey || ''; // Input展示用的 key val
const [visible, setVisible] = useState(false);
const [rowSelection, rowCtl] = useRowSelectionTable({ type: selectionType, customKey: tableRowKey });
useEffect(() => {
// Table 只能缓存 keys
const rowKeys = value.map(item => item[tableRowKey]);
rowCtl.setSelectedRowKeys(rowKeys);
rowCtl.setSelectRow(value);
}, [props.value, tableProps.rowKey]);
const handleConfirm = () => {
const rows = rowCtl.selectRow;
const keys = rows.map(item => item[tableRowKey]);
if (props.mutators) {
if (rows && rows.length) {
props.mutators.change(rows);
}
setVisible(false);
return;
}
rowCtl.setSelectedRowKeys(keys);
setVisible(false);
};
const handleModalVisible = () => {
if (!fetchTableData) {
message.warning(tip || '请传入 fetchTableData 属性,否则Table 将无法发起请求');
return;
}
setVisible(true);
};
return (
<RowStyleLayout>
<Input
value={
tableRowLableKey ?
value.map(item => item[tableRowLableKey]).join(',') :
''
}
addonAfter={(
<>
{editable && (
<Button
type="primary"
className="relevance"
icon={<LinkOutlined />}
onClick={handleModalVisible}
disabled={disabled}
block
>
{title}
</Button>
)}
</>
)}
disabled
/>
<ModalTable
confirm={handleConfirm}
cancel={() => setVisible(false)}
visible={visible}
width={960}
{...modalProps}
modalTitle={modalProps.title}
rowSelection={rowSelection}
columns={columns}
fetchTableData={fetchTableData}
formilyProps={formilyProps}
tableProps={tableProps}
resetModal={{
destroyOnClose: true,
}}
/>
</RowStyleLayout>
);
};
Relevance.defaultProps = {};
Relevance.isFieldComponent = true;
export default Relevance;
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-22 16:57:28
* @LastEditTime: 2020-12-22 17:34:41
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -42,6 +42,7 @@ import {
machiningWarehousingBillSchema,
machiningDeliveryBillSchema,
refundDeliveryBillSchema,
afterSaleBillSchema,
} from '../schema';
const {
......@@ -180,34 +181,40 @@ const machiningDeliveryColumns = [
},
];
// 售后退货发货订单列表
const afterSaleRefundDeliveryColumns = [
{
title: '申请单号',
align: 'center',
dataIndex: 'applyNo',
},
{
title: '申请单摘要',
align: 'center',
dataIndex: 'applyAbstract',
},
{
title: '供应会员',
align: 'center',
dataIndex: 'supplierName',
},
{
title: '单据时间',
align: 'center',
dataIndex: 'applyTime',
},
{
title: '申请单状态',
align: 'center',
dataIndex: 'outerStatusName',
},
];
// 售后发货、入库订单列表
const getAfterSaleColumns = (isPurchaser?: boolean) => {
return [
{
title: '申请单号',
align: 'center',
dataIndex: 'applyNo',
},
{
title: '申请单摘要',
align: 'center',
dataIndex: 'applyAbstract',
},
isPurchaser ? {
title: '供应会员',
align: 'center',
dataIndex: 'supplierName',
} : {
title: '采购会员',
align: 'center',
dataIndex: 'consumerName',
},
{
title: '单据时间',
align: 'center',
dataIndex: 'applyTime',
},
{
title: '申请单状态',
align: 'center',
dataIndex: 'outerStatusName',
},
];
};
// 获取采购入库单相关数据
const fetchOrderPurchaseReceiptAddList = async (params: any) => {
......@@ -322,6 +329,64 @@ const getRefundDeliveryList = async (params: any) => {
return [];
};
// 获取售后退货入库单单相关数据
const getRefundWarehousingList = async (params: any) => {
const { search, startTime, endTime, ...rest } = params;
const res = await PublicApi.getAsReturnGoodsPageToBeAddReturnGoodsStorage({
applyNo: search,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD HH:mm:ss') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD HH:mm:ss') : null,
...rest,
})
if (res.code === 1000) {
return {
data: res.data.data.map(item => ({
...item,
id: item.returnId,
memberName: item.consumerName,
membersId: item.parentMemberId,
membersRoleId: item.parentMemberRoleId,
deliveryAddresId: item.returnGoodsAddress.sendId,
fullAddress: item.returnGoodsAddress.sendAddress || '',
receiverName: item.returnGoodsAddress.sendUserName || '',
phone: item.returnGoodsAddress.sendUserTel || '',
deliveryType: item.returnGoodsAddress.deliveryType || '',
})),
total: res.data.totalCount,
};
}
return [];
};
// 获取售后换货退货发货单单相关数据
const getExchangeDeliveryList = async (params: any) => {
const { search, startTime, endTime, ...rest } = params;
const res = await PublicApi.getAsReplaceGoodsPageToBeAddReturnDeliveryGoods({
applyNo: search,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD HH:mm:ss') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD HH:mm:ss') : null,
...rest,
})
if (res.code === 1000) {
return {
data: res.data.data.map(item => ({
...item,
id: item.replaceId,
memberName: item.supplierName,
membersId: item.parentMemberId,
membersRoleId: item.parentMemberRoleId,
deliveryAddresId: item.returnGoodsAddress.receiveId,
fullAddress: item.returnGoodsAddress.receiveAddress || '',
receiverName: item.returnGoodsAddress.receiveUserName || '',
phone: item.returnGoodsAddress.receiveUserTel || '',
deliveryType: item.returnGoodsAddress.deliveryType || '',
})),
total: res.data.totalCount,
};
}
return [];
};
// 获取关联组件对应的 params
const getParams = type => {
const basicParams = {
......@@ -395,9 +460,9 @@ const getParams = type => {
// 退货发货单
case DOC_TYPE_RETURN_INVOICE: {
basicParams.modalProps.title = '选择售后单';
basicParams.columns = afterSaleRefundDeliveryColumns;
basicParams.columns = getAfterSaleColumns(true);
basicParams.fetchTableData = getRefundDeliveryList;
basicParams.formilyProps.ctx.schema = refundDeliveryBillSchema;
basicParams.formilyProps.ctx.schema = afterSaleBillSchema(true);
basicParams.tableProps.rowKey = 'applyNo';
basicParams.tableProps.lableKey = 'applyNo';
break;
......@@ -405,6 +470,28 @@ const getParams = type => {
// 退货入库单
case DOC_TYPE_RETURN_RECEIPT: {
basicParams.modalProps.title = '选择售后单';
basicParams.columns = getAfterSaleColumns(false);
basicParams.fetchTableData = getRefundWarehousingList;
basicParams.formilyProps.ctx.schema = afterSaleBillSchema(false);
basicParams.tableProps.rowKey = 'applyNo';
basicParams.tableProps.lableKey = 'applyNo';
break;
}
// 换货退货发货单
case DOC_TYPE_EXCHANGE_RETURN_INVOICE: {
basicParams.modalProps.title = '选择售后单';
basicParams.columns = getAfterSaleColumns(false);
basicParams.fetchTableData = getExchangeDeliveryList;
basicParams.formilyProps.ctx.schema = afterSaleBillSchema(false);
basicParams.tableProps.rowKey = 'applyNo';
basicParams.tableProps.lableKey = 'applyNo';
break;
}
// 换货退货入库单
case DOC_TYPE_EXCHANGE_RETURN_RECEIPT: {
break;
}
......@@ -420,12 +507,6 @@ const getParams = type => {
break;
}
// 换货退货发货单
case DOC_TYPE_EXCHANGE_RETURN_INVOICE: {
break;
}
default:
break;
......@@ -657,6 +738,10 @@ export const useBusinessEffects = (context, actions) => {
case DOC_TYPE_EXCHANGE_INVOICE:
// 换货入库单
case DOC_TYPE_EXCHANGE_RECEIPT: {
// 设置配送方式相关字段数据
setFieldValue('transport', DELIVERY_TYPE[first.deliveryType]);
setFieldValue('deliveryType', first.deliveryType);
// 获取明细数据 商品 数据
PublicApi.getAsReplaceGoodsPageReturnedGoods({
replaceId: first.id,
......
......@@ -445,15 +445,15 @@ const BillsForm: React.FC<BillsFormProps> = ({
fullAddress: returnGoodsAddress.receiveAddress || '',
receiverName: returnGoodsAddress.receiveUserName || '',
phone: returnGoodsAddress.receiveUserTel || '',
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
}
] :
[]
,
deliveryType: returnGoodsAddress.deliveryType,
transport: DELIVERY_TYPE[returnGoodsAddress.deliveryType],
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
});
}).finally(() => {
setInfoLoading(false);
......@@ -492,15 +492,15 @@ const BillsForm: React.FC<BillsFormProps> = ({
fullAddress: returnGoodsAddress.receiveAddress || '',
receiverName: returnGoodsAddress.receiveUserName || '',
phone: returnGoodsAddress.receiveUserTel || '',
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
}
] :
[]
,
deliveryType: returnGoodsAddress.deliveryType,
transport: DELIVERY_TYPE[returnGoodsAddress.deliveryType],
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
});
}).finally(() => {
setInfoLoading(false);
......@@ -540,15 +540,15 @@ const BillsForm: React.FC<BillsFormProps> = ({
fullAddress: returnGoodsAddress.receiveAddress || '',
receiverName: returnGoodsAddress.receiveUserName || '',
phone: returnGoodsAddress.receiveUserTel || '',
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
}
] :
[]
,
deliveryType: returnGoodsAddress.deliveryType,
transport: DELIVERY_TYPE[returnGoodsAddress.deliveryType],
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
});
}).finally(() => {
setInfoLoading(false);
......@@ -587,15 +587,15 @@ const BillsForm: React.FC<BillsFormProps> = ({
fullAddress: returnGoodsAddress.receiveAddress || '',
receiverName: returnGoodsAddress.receiveUserName || '',
phone: returnGoodsAddress.receiveUserTel || '',
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
}
] :
[]
,
deliveryType: returnGoodsAddress.deliveryType,
transport: DELIVERY_TYPE[returnGoodsAddress.deliveryType],
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
});
}).finally(() => {
setInfoLoading(false);
......@@ -635,15 +635,15 @@ const BillsForm: React.FC<BillsFormProps> = ({
fullAddress: returnGoodsAddress.receiveAddress || '',
receiverName: returnGoodsAddress.receiveUserName || '',
phone: returnGoodsAddress.receiveUserTel || '',
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
}
] :
[]
,
deliveryType: returnGoodsAddress.deliveryType,
transport: DELIVERY_TYPE[returnGoodsAddress.deliveryType],
supplyMembersName: supplierName,
supplyMembersId: parentMemberId,
supplyMembersRoleId: parentMemberRoleId,
transport: DELIVERY_TYPE[returnGoodsAddress.deliveryType],
});
}).finally(() => {
setInfoLoading(false);
......@@ -1193,9 +1193,9 @@ const BillsForm: React.FC<BillsFormProps> = ({
}),
relevanceInvoicesId: orderNo[0].id,
relevanceInvoices: rest.relevanceInvoices,
supplyMembersName: billInfo.supplyMembersName,
supplyMembersId: billInfo.supplyMembersId,
supplyMembersRoleId: billInfo.supplyMembersRoleId,
supplyMembersName: orderNo[0].supplyMembersName,
supplyMembersId: orderNo[0].supplyMembersId,
supplyMembersRoleId: orderNo[0].supplyMembersRoleId,
invoicesTypeId,
})
.then(res => {
......@@ -1501,9 +1501,9 @@ const BillsForm: React.FC<BillsFormProps> = ({
}),
relevanceInvoicesId: orderNo[0].id,
relevanceInvoices: rest.relevanceInvoices,
supplyMembersName: billInfo.supplyMembersName,
supplyMembersId: billInfo.supplyMembersId,
supplyMembersRoleId: billInfo.supplyMembersRoleId,
supplyMembersName: orderNo[0].supplyMembersName,
supplyMembersId: orderNo[0].supplyMembersId,
supplyMembersRoleId: orderNo[0].supplyMembersRoleId,
invoicesTypeId,
})
.then(res => {
......
......@@ -752,70 +752,82 @@ export const machiningDeliveryBillSchema: ISchema = {
},
};
// 售后退货发货 弹窗 search schema
export const refundDeliveryBillSchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'Mega-Layout',
properties: {
search: {
type: 'string',
'x-component': 'Search',
'x-mega-props': {},
'x-component-props': {
placeholder: '搜索',
align: 'flex-start',
tip: '输入 通知单号 进行搜索',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 3,
},
properties: {
applyAbstract: {
type: 'string',
'x-component-props': {
placeholder: '申请单摘要',
allowClear: true,
},
},
supplierName: {
type: 'string',
'x-component-props': {
placeholder: '供应会员',
allowClear: true,
},
// 售后发货、入库 弹窗 search schema
export const afterSaleBillSchema = (isPurchaser: boolean): ISchema => {
return {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'Mega-Layout',
properties: {
search: {
type: 'string',
'x-component': 'Search',
'x-mega-props': {},
'x-component-props': {
placeholder: '搜索',
align: 'flex-start',
tip: '输入 通知单号 进行搜索',
},
'[startTime, endTime]': {
type: 'string',
'x-component': 'DateSelect',
'x-component-props': {
placeholder: '单据时间',
allowClear: true,
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 3,
},
properties: {
applyAbstract: {
type: 'string',
'x-component-props': {
placeholder: '申请单摘要',
allowClear: true,
},
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
...(isPurchaser ? {
supplierName: {
type: 'string',
'x-component-props': {
placeholder: '供应会员',
allowClear: true,
},
},
} : {
consumerName: {
type: 'string',
'x-component-props': {
placeholder: '采购会员',
allowClear: true,
},
},
}),
'[startTime, endTime]': {
type: 'string',
'x-component': 'DateSelect',
'x-component-props': {
placeholder: '单据时间',
allowClear: true,
},
},
'x-component-props': {
children: '查询',
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
}
}
}
},
},
},
},
},
},
}
};
export const goodsSearchSchema: ISchema = {
......
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