feat:【antd】【erp 系统】sale 重构代码风格(修复“优惠后金额”未计算的问题)

This commit is contained in:
YunaiV
2025-10-04 16:48:03 +08:00
parent 888a6d9ec8
commit dd9fd6e284
4 changed files with 20 additions and 32 deletions

View File

@@ -162,6 +162,15 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
formatter: erpPriceInputFormatter,
disabled: true,
},
dependencies: {
triggerFields: ['totalPrice', 'otherPrice'],
componentProps: (values) => {
const totalPrice = values.totalPrice || 0;
const otherPrice = values.otherPrice || 0;
values.discountedPrice = totalPrice - otherPrice;
return {};
},
},
},
{
fieldName: 'otherPrice',

View File

@@ -21,7 +21,6 @@ const formData = ref<
ErpSaleOutApi.SaleOut & {
accountId?: number;
customerId?: number;
discountedPrice?: number;
discountPercent?: number;
fileUrl?: string;
order?: ErpSaleOrderApi.SaleOrder;
@@ -40,7 +39,6 @@ const formData = ref<
discountPrice: 0,
totalPrice: 0,
otherPrice: 0,
discountedPrice: 0,
items: [],
});
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
@@ -167,20 +165,7 @@ const [Modal, modalApi] = useVbenModal({
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = {
id: undefined,
no: undefined,
accountId: undefined,
outTime: undefined,
remark: undefined,
fileUrl: undefined,
discountPercent: 0,
customerId: undefined,
discountPrice: 0,
totalPrice: 0,
otherPrice: 0,
items: [],
};
formData.value = undefined;
return;
}
// 加载数据

View File

@@ -161,6 +161,15 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
formatter: erpPriceInputFormatter,
disabled: true,
},
dependencies: {
triggerFields: ['totalPrice', 'otherPrice'],
componentProps: (values) => {
const totalPrice = values.totalPrice || 0;
const otherPrice = values.otherPrice || 0;
values.discountedPrice = totalPrice - otherPrice;
return {};
},
},
},
{
fieldName: 'otherPrice',

View File

@@ -25,7 +25,6 @@ const formData = ref<
ErpSaleReturnApi.SaleReturn & {
accountId?: number;
customerId?: number;
discountedPrice?: number;
discountPercent?: number;
fileUrl?: string;
order?: ErpSaleOrderApi.SaleOrder;
@@ -44,7 +43,6 @@ const formData = ref<
discountPrice: 0,
totalPrice: 0,
otherPrice: 0,
discountedPrice: 0,
items: [],
});
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
@@ -171,20 +169,7 @@ const [Modal, modalApi] = useVbenModal({
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = {
id: undefined,
no: undefined,
accountId: undefined,
returnTime: undefined,
remark: undefined,
fileUrl: undefined,
discountPercent: 0,
customerId: undefined,
discountPrice: 0,
totalPrice: 0,
otherPrice: 0,
items: [],
};
formData.value = undefined;
return;
}
// 加载数据