Commit 3013c3bf authored by XieZhiXiong's avatar XieZhiXiong

fix: 添加内部单据处理逻辑

parent 72e12dba
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47 * @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-04 11:22:36 * @LastEditTime: 2021-01-06 16:18:59
* @Description: 联动逻辑相关 * @Description: 联动逻辑相关
*/ */
import { Modal } from 'antd'; import { Modal } from 'antd';
...@@ -257,6 +257,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -257,6 +257,7 @@ export const useBusinessEffects = (context, actions) => {
break; break;
} }
// 其他的走内部单据
default: { default: {
freeEnumItem(newEnum, 'value', DEPENDENT_DOC_INTERNAL); freeEnumItem(newEnum, 'value', DEPENDENT_DOC_INTERNAL);
break; break;
...@@ -285,6 +286,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -285,6 +286,7 @@ export const useBusinessEffects = (context, actions) => {
if (current) { if (current) {
linkage.value('invoicesTypeCode', current.number); linkage.value('invoicesTypeCode', current.number);
linkage.value('direction', current.direction);
} }
linkage.componentProps('orderNo', params); linkage.componentProps('orderNo', params);
}); });
...@@ -515,7 +517,6 @@ export const useBusinessEffects = (context, actions) => { ...@@ -515,7 +517,6 @@ export const useBusinessEffects = (context, actions) => {
const { name, originAsyncData, value } = fieldState; const { name, originAsyncData, value } = fieldState;
const current = originAsyncData.find(item => item.productId === value); const current = originAsyncData.find(item => item.productId === value);
const invoicesTypeIdVal = getFieldValue('invoicesTypeId'); const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
const relevanceInvoicesVal = getFieldValue('relevanceInvoices');
// 取消选择 // 取消选择
if (!value) { if (!value) {
...@@ -760,7 +761,6 @@ export const useBusinessEffects = (context, actions) => { ...@@ -760,7 +761,6 @@ export const useBusinessEffects = (context, actions) => {
onFieldInputChange$('invoicesDetailsRequests.*.productCount').subscribe(fieldState => { onFieldInputChange$('invoicesDetailsRequests.*.productCount').subscribe(fieldState => {
const { name, value } = fieldState; const { name, value } = fieldState;
const invoicesTypeIdVal = getFieldValue('invoicesTypeId'); const invoicesTypeIdVal = getFieldValue('invoicesTypeId');
const relevanceInvoicesVal = getFieldValue('relevanceInvoices');
const originAsyncData = getFieldState( const originAsyncData = getFieldState(
FormPath.transform(name, /\d/, $1 => { FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.product` return `invoicesDetailsRequests.${$1}.product`
...@@ -876,4 +876,20 @@ export const useBusinessEffects = (context, actions) => { ...@@ -876,4 +876,20 @@ export const useBusinessEffects = (context, actions) => {
} }
); );
}); });
// 对应单据改变
onFieldValueChange$('relevanceInvoices').subscribe(fieldState => {
const { value } = fieldState;
// 对应单据等于内部单据
// formily 的 bug,设置了 display 为 false,该列还是会展示在页面中
// 所以把title设置
if (value === DEPENDENT_DOC_INTERNAL) {
linkage.display('*(orderNo,memberName,address,transport)', false);
linkage.display('invoicesDetailsRequests.*.*(product,productId,price,amount)', false);
} else {
linkage.display('*(orderNo,memberName,address,transport)');
linkage.display('invoicesDetailsRequests.*.*(product,productId,price,amount)');
}
});
} }
\ No newline at end of file
...@@ -33,6 +33,9 @@ import { ...@@ -33,6 +33,9 @@ import {
DOC_TYPE_EXCHANGE_RETURN_RECEIPT, DOC_TYPE_EXCHANGE_RETURN_RECEIPT,
DELIVERY_TYPE, DELIVERY_TYPE,
DEPENDENT_DOC_INTERNAL,
DOC_DIRECTION_WAREHOUSING,
DOC_DIRECTION_OUTGOING,
} from '@/constants'; } from '@/constants';
import { addBillSchema, goodsSearchSchema } from './schema'; import { addBillSchema, goodsSearchSchema } from './schema';
import { createEffects } from './effects'; import { createEffects } from './effects';
...@@ -733,7 +736,8 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -733,7 +736,8 @@ const BillsForm: React.FC<BillsFormProps> = ({
// 弹出单据明细 // 弹出单据明细
const handleAdd = () => { const handleAdd = () => {
const orderNoVal = addSchemaAction.getFieldValue('orderNo'); const orderNoVal = addSchemaAction.getFieldValue('orderNo');
if (!orderNoVal) { const relevanceInvoicesVal = addSchemaAction.getFieldValue('relevanceInvoices');
if (!orderNoVal && relevanceInvoicesVal !== DEPENDENT_DOC_INTERNAL) {
message.warning('请选择对应单据'); message.warning('请选择对应单据');
return; return;
} }
...@@ -765,6 +769,7 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -765,6 +769,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
memberName, memberName,
membersId, membersId,
membersRoleId, membersRoleId,
direction,
...rest ...rest
} = value; } = value;
const newInvoicesDetailsRequests = invoicesDetailsRequests.map(({ const newInvoicesDetailsRequests = invoicesDetailsRequests.map(({
...@@ -820,13 +825,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -820,13 +825,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -867,13 +873,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -867,13 +873,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -923,13 +930,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -923,13 +930,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -970,13 +978,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -970,13 +978,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1016,13 +1025,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1016,13 +1025,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -1064,13 +1074,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1064,13 +1074,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1110,13 +1121,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1110,13 +1121,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -1158,13 +1170,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1158,13 +1170,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1220,13 +1233,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1220,13 +1233,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -1262,13 +1276,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1262,13 +1276,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1324,13 +1339,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1324,13 +1339,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -1366,13 +1382,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1366,13 +1382,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1426,13 +1443,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1426,13 +1443,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -1468,13 +1486,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1468,13 +1486,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1528,13 +1547,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1528,13 +1547,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} else { } else {
...@@ -1570,13 +1590,14 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1570,13 +1590,14 @@ const BillsForm: React.FC<BillsFormProps> = ({
}) })
.then(res => { .then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
setSubmitLoading(false);
return; return;
} }
setUnsaved(false); setUnsaved(false);
setTimeout(() => { setTimeout(() => {
history.goBack(); history.goBack();
}, 800); }, 800);
}).finally(() => { }).catch(() => {
setSubmitLoading(false); setSubmitLoading(false);
}); });
} }
...@@ -1584,7 +1605,105 @@ const BillsForm: React.FC<BillsFormProps> = ({ ...@@ -1584,7 +1605,105 @@ const BillsForm: React.FC<BillsFormProps> = ({
} }
default: { default: {
if (!id) {
if (isEdit) {
return;
}
PublicApi.postWarehouseInvoicesAdd({
invoicesTypeCode: invoicesTypeCode,
invoicesAbstract: rest.invoicesAbstract,
memberName: memberName,
inventoryId: rest.inventoryId,
inventoryRole: rest.inventoryRole,
transactionTime: newTransactionTime,
orderNo: null,
deliveryAddresId: null,
receiverName: null,
fullAddress: null,
phone: null,
deliveryType: null,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => {
const {
extraData = {},
amount,
productCount,
itemName,
...rest
} = item;
return {
...rest,
goodsName: itemName,
productModel: rest.specifications,
productName: extraData.productName,
shipmentQuantity: direction == DOC_DIRECTION_OUTGOING ? productCount : 0,
storageCount: direction === DOC_DIRECTION_WAREHOUSING ? productCount : 0,
productCount: 0,
orderNo: null,
};
}),
relevanceInvoicesId: null,
relevanceInvoices: rest.relevanceInvoices,
supplyMembersName: null,
supplyMembersId: null,
supplyMembersRoleId: null,
invoicesTypeId,
})
.then(res => {
if (res.code !== 1000) {
setSubmitLoading(false);
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).catch(() => {
setSubmitLoading(false);
});
} else {
// update action
if (!isEdit) {
return;
}
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: rest.invoicesAbstract,
inventoryId: rest.inventoryId,
inventoryRole: rest.inventoryRole,
transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests.map(item => {
const {
extraData = {},
amount,
productCount,
itemName,
...rest
} = item;
return {
...rest,
goodsName: itemName,
productModel: rest.specifications,
productName: extraData.productName,
shipmentQuantity: direction == DOC_DIRECTION_OUTGOING ? productCount : 0,
storageCount: direction === DOC_DIRECTION_WAREHOUSING ? productCount : 0,
productCount: 0,
orderNo: null,
};
}),
})
.then(res => {
if (res.code !== 1000) {
setSubmitLoading(false);
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).catch(() => {
setSubmitLoading(false);
});
}
break; break;
} }
} }
......
...@@ -379,12 +379,17 @@ export const addBillSchema: ISchema = { ...@@ -379,12 +379,17 @@ export const addBillSchema: ISchema = {
}, },
// 会员id,可以是采购会员id、销售会员id // 会员id,可以是采购会员id、销售会员id
membersId: { membersId: {
type: 'boolean', type: 'string',
display: false, display: false,
}, },
// 会员角色id,可以是采购会员角色id、销售会员角色id // 会员角色id,可以是采购会员角色id、销售会员角色id
membersRoleId: { membersRoleId: {
type: 'boolean', type: 'string',
display: false,
},
// 单据类型方向
direction: {
type: 'string',
display: false, display: false,
}, },
}, },
...@@ -481,16 +486,19 @@ export const addBillSchema: ISchema = { ...@@ -481,16 +486,19 @@ export const addBillSchema: ISchema = {
message: '请选择商品', message: '请选择商品',
}, },
], ],
display: true,
}, },
productId: { productId: {
type: 'string', type: 'string',
title: '商品ID', title: '商品ID',
'x-component': 'Text', 'x-component': 'Text',
display: true,
}, },
price: { price: {
type: 'string', type: 'string',
title: '单价', title: '单价',
'x-component': 'Text', 'x-component': 'Text',
display: true,
}, },
productCount: { productCount: {
type: 'string', type: 'string',
...@@ -513,6 +521,7 @@ export const addBillSchema: ISchema = { ...@@ -513,6 +521,7 @@ export const addBillSchema: ISchema = {
type: 'string', type: 'string',
title: '金额', title: '金额',
'x-component': 'Text', 'x-component': 'Text',
display: true,
}, },
// 额外的数据,用于收集不需要展示的数据 // 额外的数据,用于收集不需要展示的数据
extraData: { extraData: {
......
...@@ -19,6 +19,7 @@ export const useLinkageUtils = () => { ...@@ -19,6 +19,7 @@ export const useLinkageUtils = () => {
loading: linkage('loading', true), loading: linkage('loading', true),
loaded: linkage('loading', false), loaded: linkage('loading', false),
value: linkage('value'), value: linkage('value'),
componentProps: linkage('props.x-component-props', {}) componentProps: linkage('props.x-component-props', {}),
display: linkage('display', true),
} }
} }
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