Commit 968311d7 authored by 前端-许佳敏's avatar 前端-许佳敏
parents 1b64ae16 ee9e16ad
......@@ -42,7 +42,7 @@ const Relevance = props => {
fetchTableData,
title = '选择',
tip = '', // 点击按钮前的提示,用于前提需要提示的场景
disabled = false,
disabled = false,
} = props.props['x-component-props'];
const tableRowKey = tableProps.rowKey || 'id';
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-23 19:14:12
* @LastEditTime: 2020-11-24 17:17:13
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -36,6 +36,8 @@ import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PublicApi } from '@/services/api';
import {
purchaseOrderBillSchema,
machiningWarehousingBillSchema,
machiningDeliveryBillSchema,
} from '../schema';
const {
......@@ -116,22 +118,22 @@ const salesOrderColumns: any[] = [
},
];
// 生成通知单列表
const productionColumns = [
// 加工入库单列表
const machiningWarehousingColumns = [
{
title: '通知单号',
align: 'center',
dataIndex: 'orderNo',
dataIndex: 'noticeNo',
},
{
title: '通知单摘要',
align: 'center',
dataIndex: 'invoicesAbstract',
dataIndex: 'summary',
},
{
title: '加工企业名称',
align: 'center',
dataIndex: 'memberName',
dataIndex: 'processName',
},
{
title: '单据时间',
......@@ -141,7 +143,36 @@ const productionColumns = [
{
title: '申请单状态',
align: 'center',
dataIndex: 'state',
dataIndex: 'outerStatusName',
},
];
// 加工发货单列表
const machiningDeliveryColumns = [
{
title: '通知单号',
align: 'center',
dataIndex: 'noticeNo',
},
{
title: '通知单摘要',
align: 'center',
dataIndex: 'summary',
},
{
title: '供应会员',
align: 'center',
dataIndex: 'supplierName',
},
{
title: '单据时间',
align: 'center',
dataIndex: 'createTime',
},
{
title: '申请单状态',
align: 'center',
dataIndex: 'outerStatusName',
},
];
......@@ -180,7 +211,13 @@ const fetchOrderPurchaseReceiptAddList = async (params: any) => {
...params,
})
if (res.code === 1000) {
return res.data;
return {
data: res.data.data.map(item => ({
...item,
memberName: item.supplyMembersName,
})),
total: res.data.totalCount,
};
}
return [];
};
......@@ -191,7 +228,59 @@ const getOrderSalesInvoiceOrderList = async (params: any) => {
...params,
})
if (res.code === 1000) {
return res.data;
return {
data: res.data.data.map(item => ({
...item,
memberName: item.memberName,
})),
total: res.data.totalCount,
};
}
return [];
};
// 获取加工入库单单相关数据
const getMachiningWarehousingList = async (params: any) => {
const { search, ...rest } = params;
const res = await PublicApi.getEnhanceSupplierToBeAddStorageList({
noticeNo: search,
...rest,
})
if (res.code === 1000) {
return {
data: res.data.data.map(item => ({
...item,
memberName: item.processName,
deliveryAddresId: +item.receiverAddressId,
fullAddress: item.receiveAddress || '',
receiverName: item.receiveUserName || '',
phone: item.receiveUserTel || '',
})),
total: res.data.totalCount,
};
}
return [];
};
// 获取加工发货单单相关数据
const getMachiningDeliveryList = async (params: any) => {
const { search, ...rest } = params;
const res = await PublicApi.getEnhanceProcessToBeAddDeliveryList({
noticeNo: search,
...rest,
})
if (res.code === 1000) {
return {
data: res.data.data.map(item => ({
...item,
memberName: item.supplierName,
deliveryAddresId: +item.receiverAddressId,
fullAddress: item.receiveAddress || '',
receiverName: item.receiveUserName || '',
phone: item.receiveUserTel || '',
})),
total: res.data.totalCount,
};;
}
return [];
};
......@@ -249,14 +338,24 @@ const getParams = type => {
basicParams.tableProps.lableKey = 'orderNo';
break;
}
// 加工入库单
case DOC_TYPE_PROCESS_RECEIPT: {
basicParams.modalProps.title = '选择生产通知单';
basicParams.columns = machiningWarehousingColumns;
basicParams.fetchTableData = getMachiningWarehousingList;
basicParams.formilyProps.ctx.schema = machiningWarehousingBillSchema;
basicParams.tableProps.lableKey = 'noticeNo';
break;
}
// 加工发货单
case DOC_TYPE_PROCESS_INVOICE: {
basicParams.modalProps.title = '选择生产通知单';
basicParams.columns = productionColumns;
basicParams.fetchTableData = getOrderSalesInvoiceOrderList;
basicParams.formilyProps.ctx.schema = {}; // 缺
basicParams.tableProps.lableKey = 'orderNo';
basicParams.columns = machiningDeliveryColumns;
basicParams.fetchTableData = getMachiningDeliveryList;
basicParams.formilyProps.ctx.schema = machiningDeliveryBillSchema;
basicParams.tableProps.lableKey = 'noticeNo';
break;
}
......@@ -329,8 +428,12 @@ export const useBusinessEffects = (context, actions) => {
}
linkage.value('relevanceInvoices', undefined);
linkage.value('invoicesDetailsRequests', []);
linkage.enum('relevanceInvoices', newEnum);
const invoicesDetailsRequestsVal = getFieldValue('invoicesDetailsRequests');
if (invoicesDetailsRequestsVal && invoicesDetailsRequestsVal.length) {
linkage.value('invoicesDetailsRequests', []);
}
const orderNoVal = getFieldValue('orderNo');
if (orderNoVal && orderNoVal.length) {
......@@ -354,58 +457,11 @@ export const useBusinessEffects = (context, actions) => {
// 关联单据改变
onFieldValueChange$('orderNo').subscribe(fieldState => {
const relevanceInvoicesVal = getFieldValue('relevanceInvoices');
const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
const first = fieldState.value && fieldState.value[0];
console.log('first', first)
switch (invoicesTypeIdVal) {
// 采购入库单
case DOC_TYPE_PURCHASE_RECEIPT: {
setFieldValue('memberName', first ? first.supplyMembersName : '');
break;
}
// 销售发货单
case DOC_TYPE_SALES_INVOICE: {
setFieldValue('memberName', first ? first.createMemberName : '');
break;
}
// 加工入库单
case DOC_TYPE_PROCESS_RECEIPT: {
break;
}
// 加工发货单
case DOC_TYPE_PROCESS_INVOICE: {
setFieldValue('memberName', first ? first.supplierName : '');
break;
}
// 退货发货单、退货入库单
case DOC_TYPE_RETURN_INVOICE:
case DOC_TYPE_RETURN_RECEIPT: {
break;
}
// 换货发货单、换货入库单
case DOC_TYPE_EXCHANGE_INVOICE:
case DOC_TYPE_EXCHANGE_RECEIPT: {
break;
}
default: {
break;
}
}
// 设置单据公用的数据相关
setFieldValue('memberName', first ? first.memberName : '');
setFieldValue('address', first ? `${first.fullAddress} ${first.receiverName}/${first.phone}` : '');
// 以下数据只用于收集,不用于展示
......@@ -440,10 +496,35 @@ export const useBusinessEffects = (context, actions) => {
break;
}
// 加工入库单
case DOC_TYPE_PROCESS_RECEIPT: {
// 从加工单详情获取 商品 数据
PublicApi.getEnhanceSupplierToBeAddStorageDetails({
id: first.id,
}).then(res => {
if (res.code !== 1000) {
return;
}
const {
details = [],
deliveryType,
} = res.data;
const goodOptions = details.map(item => ({
label: `${item.productName}${item.orderNo ? '---' + item.orderNo : ''}`,
value: item.productId,
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', details.map(item => ({
...item,
// 这里的数据以采购、销售订单的为准
logistics: {
deliveryType, // 手动赋值配送方式,同一个通知单下的所有商品都是统一的配送方式
},
})));
FormPath.setIn(state, 'props.enum', goodOptions);
});
});
break;
break;
}
......@@ -457,14 +538,21 @@ export const useBusinessEffects = (context, actions) => {
return;
}
const {
details,
details = [],
deliveryType,
} = res.data;
const goodOptions = details.map(item => ({
label: `${item.productName}${item.orderNo ? '---' + item.orderNo : ''}`,
value: item.productId,
}));
setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', details);
FormPath.setIn(state, 'originAsyncData', details.map(item => ({
...item,
// 这里的数据以采购、销售订单的为准
logistics: {
deliveryType, // 手动赋值配送方式,同一个通知单下的所有商品都是统一的配送方式
},
})));
FormPath.setIn(state, 'props.enum', goodOptions);
});
});
......@@ -494,7 +582,10 @@ export const useBusinessEffects = (context, actions) => {
// 关联单据改变
onFieldInputChange$('orderNo').subscribe(fieldState => {
setFieldValue('invoicesDetailsRequests', []);
const invoicesDetailsRequestsVal = getFieldValue('invoicesDetailsRequests');
if (invoicesDetailsRequestsVal && invoicesDetailsRequestsVal.length) {
linkage.value('invoicesDetailsRequests', []);
}
});
// 关联明细
......@@ -513,6 +604,8 @@ export const useBusinessEffects = (context, actions) => {
const { name, originAsyncData, value } = fieldState;
const current = originAsyncData.find(item => item.productId === value);
console.log('current', current)
// 取消选择
if (!value) {
setFieldState(
......@@ -536,7 +629,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.price`
}),
state => {
state.value = '';
state.value = null;
}
);
setFieldState(
......@@ -552,7 +645,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.amount`
}),
state => {
state.value = `¥0.00`;
state.value = null;
}
);
// 配送方式,一个单据只能有一个配送方式
......@@ -574,6 +667,25 @@ export const useBusinessEffects = (context, actions) => {
setFieldValue('transport', '');
setFieldValue('deliveryType', null);
}
// 加工发货单
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.orderNo`
}),
state => {
state.value = '';
}
);
// 加工发货单
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.id`
}),
state => {
state.value = '';
}
);
}
if (!current) {
......@@ -601,7 +713,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.price`
}),
state => {
state.value = current.price ? current.price.toFixed(2) : '';
state.value = current.price ? current.price.toFixed(2) : null;
}
);
setFieldState(
......@@ -617,7 +729,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.amount`
}),
state => {
state.value = current.price ? `¥${(current.purchaseCount * current.price).toFixed(2)}` : '';
state.value = current.price ? `¥${(current.purchaseCount * current.price).toFixed(2)}` : null;
}
);
// 配送方式,一个单据只能有一个配送方式
......@@ -629,6 +741,24 @@ export const useBusinessEffects = (context, actions) => {
state.value = current.logistics && current.logistics.deliveryType ? current.logistics.deliveryType : undefined;
}
);
// 加工发货单
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.orderNo`
}),
state => {
state.value = current.orderNo;
}
);
// 加工发货单
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.id`
}),
state => {
state.value = current.id;
}
);
setTimeout(() => {
const invoicesDetailsRequestsValue = getFieldValue('invoicesDetailsRequests');
......@@ -678,13 +808,13 @@ export const useBusinessEffects = (context, actions) => {
state => state.value,
);
const current = originAsyncData ? originAsyncData.find(item => item.productId === goodId) : null;
const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
if (!current) {
return;
}
if (+value > current.purchaseCount) {
Modal.destroyAll();
Modal.confirm({
title: '提示',
content: '单据数量已超过商品数量',
......@@ -698,7 +828,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.amount`
}),
state => {
state.value = current.price ? `¥${(+value * current.price).toFixed(2)}` : '';
state.value = current.price ? `¥${(+value * current.price).toFixed(2)}` : null;
}
);
});
......
......@@ -274,7 +274,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
orderNo,
id: +relevanceInvoicesId,
deliveryAddresId: +deliveryAddresId,
createMemberName,
memberName: createMemberName,
fullAddress: deliveryAddressInfo.fullAddress || '',
receiverName: deliveryAddressInfo.receiverName || '',
phone: deliveryAddressInfo.phone || '',
......@@ -292,7 +292,45 @@ const BillsForm: React.FC<BillsFormProps> = ({
// 加工入库单
case DOC_TYPE_PROCESS_RECEIPT: {
setInfoLoading(true);
PublicApi.getEnhanceSupplierToBeAddStorageDetails({
id: relevanceInvoicesId,
}).then(res => {
if (res.code !== 1000) {
return;
}
const {
processName,
receiverAddressId,
noticeNo,
receiveAddress,
receiveUserName,
receiveUserTel,
deliveryType,
} = res.data;
setBillInfo({
invoicesTypeId: intInvoicesTypeId,
relevanceInvoices: +relevanceInvoices,
orderNo:
relevanceInvoicesId ?
[
{
orderNo: noticeNo,
id: +relevanceInvoicesId,
deliveryAddresId: +receiverAddressId,
memberName: processName,
fullAddress: receiveAddress || '',
receiverName: receiveUserName || '',
phone: receiveUserTel || '',
}
] :
[]
,
});
}).finally(() => {
setInfoLoading(false);
});
break;
}
......@@ -325,11 +363,10 @@ const BillsForm: React.FC<BillsFormProps> = ({
orderNo: noticeNo,
id: +relevanceInvoicesId,
deliveryAddresId: +receiverAddressId,
supplierName,
memberName: supplierName,
fullAddress: receiveAddress || '',
receiverName: receiveUserName || '',
phone: receiveUserTel || '',
// isDefault: deliveryAddressInfo.isDefault,
}
] :
[]
......@@ -399,6 +436,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
</Button>
) : null;
// 提交
const handleSubmit = value => {
const {
invoicesTypeId,
......@@ -421,14 +459,6 @@ const BillsForm: React.FC<BillsFormProps> = ({
}));
const newTransactionTime = transactionTime ? moment(transactionTime).valueOf() : null;
const payload = {
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests,
...rest,
};
setSubmitLoading(true);
switch (invoicesTypeId) {
// 采购入库单
......@@ -438,7 +468,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
return;
}
PublicApi.postOrderPurchaseReceiptAdd({
...payload,
...rest,
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
supplyMembersName: memberName,
})
.then(res => {
......@@ -459,11 +496,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: payload.invoicesAbstract,
inventoryId: payload.inventoryId,
inventoryRole: payload.inventoryRole,
transactionTime: payload.transactionTime,
invoicesDetailsRequests: payload.invoicesDetailsRequests,
invoicesAbstract: rest.invoicesAbstract,
inventoryId: rest.inventoryId,
inventoryRole: rest.inventoryRole,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
})
.then(res => {
if (res.code !== 1000) {
......@@ -487,7 +527,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
return;
}
PublicApi.postOrderSalesInvoiceOrder({
...payload,
...rest,
orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
createMemberName: memberName,
})
.then(res => {
......@@ -508,11 +555,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: payload.invoicesAbstract,
inventoryId: payload.inventoryId,
inventoryRole: payload.inventoryRole,
transactionTime: payload.transactionTime,
invoicesDetailsRequests: payload.invoicesDetailsRequests,
invoicesAbstract: rest.invoicesAbstract,
inventoryId: rest.inventoryId,
inventoryRole: rest.inventoryRole,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => ({
...item,
itemNmae: item.itemName,
})),
})
.then(res => {
if (res.code !== 1000) {
......@@ -531,13 +581,79 @@ const BillsForm: React.FC<BillsFormProps> = ({
// 加工入库单
case DOC_TYPE_PROCESS_RECEIPT: {
if (!id) {
if (isEdit) {
return;
}
PublicApi.postEnhanceSupplierToBeAddStorageSubmit({
produceNoticeOrderId: orderNo[0].id,
warehouseId: rest.inventoryId,
warehouseRole: rest.inventoryRole,
storageSummary: rest.invoicesAbstract,
storageTime: newTransactionTime,
storageDetailsDTOList: newInvoicesDetailsRequests.map(item => ({
...item,
produceNoticeOrderDetailId: item.id,
storageCount: item.productCount,
})),
})
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
} else {
// update action
if (!isEdit) {
return;
}
}
break;
}
// 加工发货单
case DOC_TYPE_PROCESS_INVOICE: {
if (!id) {
if (isEdit) {
return;
}
PublicApi.postEnhanceProcessToBeAddDeliverySubmit({
produceNoticeOrderId: orderNo[0].id,
warehouseId: rest.inventoryId,
warehouseRole: rest.inventoryRole,
invoiceSummary: rest.invoicesAbstract,
invoiceTime: newTransactionTime,
invoiceDetailsDTOList: newInvoicesDetailsRequests.map(item => ({
...item,
produceNoticeOrderDetailId: item.id,
shipmentQuantity: item.productCount,
})),
})
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
} else {
// update action
if (!isEdit) {
return;
}
}
break;
}
......@@ -582,7 +698,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
const atom = {
itemNo: item.code,
goodsId: item.id,
itemNmae: item.name,
itemName: item.name,
specifications: item.type,
category: item.customerCategory ? item.customerCategory.name : '',
brand: item.brand ? item.brand.name : '',
......
......@@ -419,7 +419,7 @@ export const addBillSchema: ISchema = {
title: '货号',
'x-component': 'Text',
},
itemNmae: {
itemName: {
type: 'string',
title: '货品名称',
'x-component': 'Text',
......@@ -508,6 +508,16 @@ export const addBillSchema: ISchema = {
type: 'string',
display: false,
},
// 明细 商品记录id(加工发货单需要),不用于展示,只收集值
id: {
type: 'string',
display: false,
},
// 订单号(加工发货单需要),不用于展示,只收集值
orderNo: {
type: 'string',
display: false,
},
},
}
},
......@@ -520,6 +530,7 @@ export const addBillSchema: ISchema = {
},
};
// 采购入库单、销售发货单订单 弹窗 search schema
export const purchaseOrderBillSchema: ISchema = {
type: 'object',
properties: {
......@@ -608,6 +619,138 @@ export const purchaseOrderBillSchema: ISchema = {
},
};
// 加工入库单 弹窗 search schema
export const machiningWarehousingBillSchema: 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: {
summary: {
type: 'string',
'x-component-props': {
placeholder: '通知单摘要',
allowClear: true,
},
},
processName: {
type: 'string',
'x-component-props': {
placeholder: '加工企业',
allowClear: true,
},
},
'[startTime, endTime]': {
type: 'string',
'x-component': 'DateSelect',
'x-component-props': {
placeholder: '单据时间',
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
}
}
},
},
},
},
},
};
// 加工发货单 弹窗 search schema
export const machiningDeliveryBillSchema: 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: {
summary: {
type: 'string',
'x-component-props': {
placeholder: '通知单摘要',
allowClear: true,
},
},
supplierName: {
type: 'string',
'x-component-props': {
placeholder: '供应会员',
allowClear: true,
},
},
'[startTime, endTime]': {
type: 'string',
'x-component': 'DateSelect',
'x-component-props': {
placeholder: '单据时间',
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
}
}
},
},
},
},
},
};
export const goodsSearchSchema: ISchema = {
type: 'object',
properties: {
......
......@@ -42,13 +42,7 @@ const Inventory: React.FC<{}> = () => {
title: '商品名称',
dataIndex: 'goodsName',
align: 'center',
render: (text: any, record: any) => (
<EyePreview
url={`/repositories/viewRepository?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
),
render: (text: any, record: any) => text,
},
{
title: '规格型号',
......
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