Commit 879ebcb1 authored by XieZhiXiong's avatar XieZhiXiong

feat: 内部单据 单据金额 = 货品成本价 * 单据数量

parent 54909672
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-18 14:11:18
* @LastEditTime: 2021-01-26 19:31:37
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......@@ -788,15 +788,11 @@ export const useBusinessEffects = (context, actions) => {
);
const current = originAsyncData ? originAsyncData.find(item => item.id === goodId) : null;
if (!current) {
return;
}
switch (invoicesTypeIdVal) {
// 采购入库单、销售发货单
case DOC_TYPE_PURCHASE_RECEIPT:
case DOC_TYPE_SALES_INVOICE: {
if (+value > current.purchaseCount) {
if (current && +value > current.purchaseCount) {
Modal.destroyAll();
Modal.confirm({
title: '提示',
......@@ -811,7 +807,7 @@ export const useBusinessEffects = (context, actions) => {
// 加工入库单、加工发货单
case DOC_TYPE_PROCESS_RECEIPT:
case DOC_TYPE_PROCESS_INVOICE: {
if (+value > current.processNum) {
if (current && +value > current.processNum) {
Modal.destroyAll();
Modal.confirm({
title: '提示',
......@@ -836,7 +832,7 @@ export const useBusinessEffects = (context, actions) => {
case DOC_TYPE_EXCHANGE_INVOICE:
// 换货入库单
case DOC_TYPE_EXCHANGE_RECEIPT: {
if (+value > current.replaceCount) {
if (current && +value > current.replaceCount) {
Modal.destroyAll();
Modal.confirm({
title: '提示',
......@@ -857,7 +853,7 @@ export const useBusinessEffects = (context, actions) => {
case DOC_TYPE_RETURN_INVOICE:
// 退货入库单
case DOC_TYPE_RETURN_RECEIPT: {
if (+value > current.returnCount) {
if (current && +value > current.returnCount) {
Modal.destroyAll();
Modal.confirm({
title: '提示',
......@@ -874,12 +870,29 @@ export const useBusinessEffects = (context, actions) => {
break;
}
// 内部单据
default: {
// 成本价
const costPriceValue = getFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.costPrice`
}),
state => state.value,
);
// 内部单据 单据金额为 成本价 * 单据数量
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.amount`
}),
state => {
state.value = costPriceValue ? `¥${(+value * costPriceValue).toFixed(2)}` : null;
}
);
break;
}
}
if (current) {
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.amount`
......@@ -888,6 +901,7 @@ export const useBusinessEffects = (context, actions) => {
state.value = current.price ? `¥${(+value * current.price).toFixed(2)}` : null;
}
);
}
});
// 对应单据改变
......@@ -899,10 +913,10 @@ export const useBusinessEffects = (context, actions) => {
// 所以把title设置
if (value === DEPENDENT_DOC_INTERNAL) {
linkage.display('*(orderNo,memberName,address,transport)', false);
linkage.display('invoicesDetailsRequests.*.*(product,productId,price,amount)', false);
linkage.display('invoicesDetailsRequests.*.*(product,productId,price)', false);
} else {
linkage.display('*(orderNo,memberName,address,transport)');
linkage.display('invoicesDetailsRequests.*.*(product,productId,price,amount)');
linkage.display('invoicesDetailsRequests.*.*(product,productId,price)');
}
});
}
\ No newline at end of file
......@@ -196,7 +196,8 @@ const BillsForm: React.FC<BillsFormProps> = ({
productCount: item.storageCount || item.shipmentQuantity || 0,
// 生成通知单字段不同,做兼容
product: item.produceNoticeOrderDetailId || item.relationInvoicesId,
amount: `¥${((transforDirection(rest.invoicesTypeId) ? item.storageCount : item.shipmentQuantity) * item.price).toFixed(2)}`,
// 没有 单价price,取 成本价costPrice,兼顾内部单据的场景
amount: `¥${((item.storageCount || item.shipmentQuantity || 0) * (item.price || item.costPrice || 0)).toFixed(2)}`,
extraData: {
productName: item.productName,
deliveryType,
......
......@@ -520,7 +520,6 @@ export const addBillSchema: ISchema = {
type: 'string',
title: '金额',
'x-component': 'Text',
display: true,
},
// 额外的数据,用于收集不需要展示的数据
extraData: {
......
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