Commit 25129ac6 authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加新增单据逻辑

parent dcb5e192
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-08-04 14:43:14
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-04 18:00:12
* @LastEditTime: 2021-08-12 17:08:09
* @Description:
*/
import { FormEffectHooks, FormPath, IFormActions } from '@formily/antd';
......@@ -18,12 +18,32 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
const linkage = useLinkageUtils();
// 对应仓库改变
onFieldInputChange$('inventoryId').subscribe(fieldState => {
onFieldInputChange$('inventoryId').subscribe((fieldState) => {
const current = fieldState.originAsyncData.find(item => item.id === fieldState.value);
if (current) {
linkage.value('inventoryRole', current.principal);
}
if (current) {
setFieldValue('inventoryName', current.name);
}
});
// 相关单据明细 数量 改变计算相关 单据金额
onFieldInputChange$('billDetails.*.count').subscribe((fieldState) => {
const { name, value } = fieldState;
const priceValue = getFieldValue(
FormPath.transform(name, /\d/, $1 => {
return `billDetails.${$1}.price`
})
);
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `billDetails.${$1}.amount`
}),
state => {
state.value = value ? +`${(+value * +priceValue).toFixed(2)}` : undefined;
}
);
});
}
\ No newline at end of file
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