Commit 3013c3bf authored by XieZhiXiong's avatar XieZhiXiong

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

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