fix: erp warn

This commit is contained in:
xingyu4j
2025-10-22 15:32:50 +08:00
parent 66647802af
commit 2884ca72f7
33 changed files with 499 additions and 473 deletions

View File

@@ -26,30 +26,32 @@ const formData = ref<
}
>({
id: undefined,
no: undefined,
no: '',
supplierId: undefined,
accountId: undefined,
financeUserId: undefined,
paymentTime: undefined,
remark: undefined,
remark: '',
fileUrl: undefined,
totalPrice: 0,
discountPrice: 0,
paymentPrice: 0,
items: [],
status: 0,
});
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */
const getTitle = computed(() =>
formType.value === 'create'
? $t('ui.actionTitle.create', ['付款单'])
: formType.value === 'edit'
? $t('ui.actionTitle.edit', ['付款单'])
: '付款单详情',
);
const getTitle = computed(() => {
if (formType.value === 'create') {
return $t('ui.actionTitle.create', ['付款单']);
} else if (formType.value === 'edit') {
return $t('ui.actionTitle.edit', ['付款单']);
} else {
return '付款单详情';
}
});
const [Form, formApi] = useVbenForm({
commonConfig: {
@@ -81,30 +83,28 @@ const [Form, formApi] = useVbenForm({
});
/** 更新付款项 */
const handleUpdateItems = (
items: ErpFinancePaymentApi.FinancePaymentItem[],
) => {
function handleUpdateItems(items: ErpFinancePaymentApi.FinancePaymentItem[]) {
formData.value.items = items;
formApi.setValues({
items,
});
};
}
/** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => {
function handleUpdateTotalPrice(totalPrice: number) {
formData.value.totalPrice = totalPrice;
formApi.setValues({
totalPrice: formData.value.totalPrice,
});
};
}
/** 更新付款金额 */
const handleUpdatePaymentPrice = (paymentPrice: number) => {
function handleUpdatePaymentPrice(paymentPrice: number) {
formData.value.paymentPrice = paymentPrice;
formApi.setValues({
paymentPrice: formData.value.paymentPrice,
});
};
}
/** 创建或更新付款单 */
const [Modal, modalApi] = useVbenModal({
@@ -141,7 +141,7 @@ const [Modal, modalApi] = useVbenModal({
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
formData.value = {} as ErpFinancePaymentApi.FinancePayment;
return;
}
// 加载数据

View File

@@ -212,81 +212,89 @@ defineExpose({ validate });
</script>
<template>
<Grid class="w-full">
<template #paymentPrice="{ row }">
<InputNumber
v-model:value="row.paymentPrice"
:precision="2"
:disabled="disabled"
:formatter="erpPriceInputFormatter"
placeholder="请输入本次付款"
@change="handleRowChange(row)"
/>
</template>
<template #remark="{ row }">
<Input
v-model:value="row.remark"
:disabled="disabled"
placeholder="请输入备注"
@change="handleRowChange(row)"
/>
</template>
<template #actions="{ row }">
<TableAction
v-if="!disabled"
:actions="[
{
label: '删除',
type: 'link',
danger: true,
popConfirm: {
title: '确认删除该付款明细吗?',
confirm: handleDelete.bind(null, row),
<div>
<Grid class="w-full">
<template #paymentPrice="{ row }">
<InputNumber
v-model:value="row.paymentPrice"
:precision="2"
:disabled="disabled"
:formatter="erpPriceInputFormatter"
placeholder="请输入本次付款"
@change="handleRowChange(row)"
/>
</template>
<template #remark="{ row }">
<Input
v-model:value="row.remark"
:disabled="disabled"
placeholder="请输入备注"
@change="handleRowChange(row)"
/>
</template>
<template #actions="{ row }">
<TableAction
v-if="!disabled"
:actions="[
{
label: '删除',
type: 'link',
danger: true,
popConfirm: {
title: '确认删除该付款明细吗?',
confirm: handleDelete.bind(null, row),
},
},
},
]"
/>
</template>
]"
/>
</template>
<template #bottom>
<div class="border-border bg-muted mt-2 rounded border p-2">
<div class="text-muted-foreground flex justify-between text-sm">
<span class="text-foreground font-medium">合计</span>
<div class="flex space-x-4">
<span>
合计付款{{ erpPriceInputFormatter(summaries.totalPrice) }}
</span>
<span>
已付金额{{ erpPriceInputFormatter(summaries.paidPrice) }}
</span>
<span>
本次付款
{{ erpPriceInputFormatter(summaries.paymentPrice) }}
</span>
<template #bottom>
<div class="border-border bg-muted mt-2 rounded border p-2">
<div class="text-muted-foreground flex justify-between text-sm">
<span class="text-foreground font-medium">合计</span>
<div class="flex space-x-4">
<span>
合计付款{{ erpPriceInputFormatter(summaries.totalPrice) }}
</span>
<span>
已付金额{{ erpPriceInputFormatter(summaries.paidPrice) }}
</span>
<span>
本次付款
{{ erpPriceInputFormatter(summaries.paymentPrice) }}
</span>
</div>
</div>
</div>
</div>
<TableAction
v-if="!disabled"
class="mt-2 flex justify-center"
:actions="[
{
label: '添加采购入库单',
type: 'default',
onClick: handleOpenPurchaseIn,
},
{
label: '添加采购退货单',
type: 'default',
onClick: handleOpenSaleReturn,
},
]"
/>
</template>
</Grid>
<TableAction
v-if="!disabled"
class="mt-2 flex justify-center"
:actions="[
{
label: '添加采购入库单',
type: 'default',
onClick: handleOpenPurchaseIn,
},
{
label: '添加采购退货单',
type: 'default',
onClick: handleOpenSaleReturn,
},
]"
/>
</template>
</Grid>
<!-- 采购入库单选择组件 -->
<PurchaseInSelect ref="purchaseInSelectRef" @success="handleAddPurchaseIn" />
<!-- 采购退货单选择组件 -->
<SaleReturnSelect ref="saleReturnSelectRef" @success="handleAddSaleReturn" />
<!-- 采购入库单选择组件 -->
<PurchaseInSelect
ref="purchaseInSelectRef"
@success="handleAddPurchaseIn"
/>
<!-- 采购退货单选择组件 -->
<SaleReturnSelect
ref="saleReturnSelectRef"
@success="handleAddSaleReturn"
/>
</div>
</template>

View File

@@ -69,7 +69,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
/** 打开弹窗 */
const openModal = (id: number) => {
function openModal(id: number) {
// 重置数据
supplierId.value = id;
open.value = true;
@@ -78,17 +78,17 @@ const openModal = (id: number) => {
gridApi.formApi?.resetForm();
gridApi.formApi?.setValues({ supplierId: id });
gridApi.query();
};
}
/** 确认选择采购入库单 */
const handleOk = () => {
function handleOk() {
if (selectedRows.value.length === 0) {
message.warning('请选择要添加的采购入库单');
return;
}
emit('success', selectedRows.value);
open.value = false;
};
}
defineExpose({ open: openModal });
</script>

View File

@@ -73,7 +73,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
/** 打开弹窗 */
const openModal = (id: number) => {
function openModal(id: number) {
// 重置数据
supplierId.value = id;
open.value = true;
@@ -82,17 +82,17 @@ const openModal = (id: number) => {
gridApi.formApi?.resetForm();
gridApi.formApi?.setValues({ supplierId: id });
gridApi.query();
};
}
/** 确认选择 */
const handleOk = () => {
function handleOk() {
if (selectedRows.value.length === 0) {
message.warning('请选择要添加的采购退货单');
return;
}
emit('success', selectedRows.value);
open.value = false;
};
}
defineExpose({ open: openModal });
</script>

View File

@@ -43,14 +43,15 @@ const formData = ref<
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */
const getTitle = computed(() =>
formType.value === 'create'
? $t('ui.actionTitle.create', ['收款单'])
: formType.value === 'edit'
? $t('ui.actionTitle.edit', ['收款单'])
: '收款单详情',
);
const getTitle = computed(() => {
if (formType.value === 'create') {
return $t('ui.actionTitle.create', ['收款单']);
} else if (formType.value === 'edit') {
return $t('ui.actionTitle.edit', ['收款单']);
} else {
return '收款单详情';
}
});
const [Form, formApi] = useVbenForm({
commonConfig: {
@@ -82,30 +83,28 @@ const [Form, formApi] = useVbenForm({
});
/** 更新收款项 */
const handleUpdateItems = (
items: ErpFinanceReceiptApi.FinanceReceiptItem[],
) => {
function handleUpdateItems(items: ErpFinanceReceiptApi.FinanceReceiptItem[]) {
formData.value.items = items;
formApi.setValues({
items,
});
};
}
/** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => {
function handleUpdateTotalPrice(totalPrice: number) {
formData.value.totalPrice = totalPrice;
formApi.setValues({
totalPrice: formData.value.totalPrice,
});
};
}
/** 更新收款金额 */
const handleUpdateReceiptPrice = (receiptPrice: number) => {
function handleUpdateReceiptPrice(receiptPrice: number) {
formData.value.receiptPrice = receiptPrice;
formApi.setValues({
receiptPrice: formData.value.receiptPrice,
});
};
}
/** 创建或更新收款单 */
const [Modal, modalApi] = useVbenModal({

View File

@@ -118,15 +118,15 @@ watch(
/** 添加销售出库单 */
const saleOutSelectRef = ref();
const handleOpenSaleOut = () => {
function handleOpenSaleOut() {
if (!props.customerId) {
message.error('请选择客户');
return;
}
saleOutSelectRef.value?.open(props.customerId);
};
}
const handleAddSaleOut = (rows: ErpSaleOutApi.SaleOut[]) => {
function handleAddSaleOut(rows: ErpSaleOutApi.SaleOut[]) {
rows.forEach((row) => {
const newItem: ErpFinanceReceiptApi.FinanceReceiptItem = {
bizId: row.id,
@@ -140,19 +140,19 @@ const handleAddSaleOut = (rows: ErpSaleOutApi.SaleOut[]) => {
tableData.value.push(newItem);
});
emit('update:items', [...tableData.value]);
};
}
/** 添加销售退货单 */
const saleReturnSelectRef = ref();
const handleOpenSaleReturn = () => {
function handleOpenSaleReturn() {
if (!props.customerId) {
message.error('请选择客户');
return;
}
saleReturnSelectRef.value?.open(props.customerId);
};
}
const handleAddSaleReturn = (rows: ErpSaleReturnApi.SaleReturn[]) => {
function handleAddSaleReturn(rows: ErpSaleReturnApi.SaleReturn[]) {
rows.forEach((row) => {
const newItem: ErpFinanceReceiptApi.FinanceReceiptItem = {
bizId: row.id,
@@ -166,10 +166,10 @@ const handleAddSaleReturn = (rows: ErpSaleReturnApi.SaleReturn[]) => {
tableData.value.push(newItem);
});
emit('update:items', [...tableData.value]);
};
}
/** 删除行 */
const handleDelete = async (row: any) => {
function handleDelete(row: any) {
const index = tableData.value.findIndex(
(item) => item.bizId === row.bizId && item.bizType === row.bizType,
);
@@ -178,10 +178,10 @@ const handleDelete = async (row: any) => {
}
// 通知父组件更新
emit('update:items', [...tableData.value]);
};
}
/** 处理行数据变更 */
const handleRowChange = (row: any) => {
function handleRowChange(row: any) {
const index = tableData.value.findIndex(
(item) => item.bizId === row.bizId && item.bizType === row.bizType,
);
@@ -191,10 +191,10 @@ const handleRowChange = (row: any) => {
tableData.value[index] = row;
}
emit('update:items', [...tableData.value]);
};
}
/** 表单校验 */
const validate = () => {
function validate() {
// 检查是否有明细
if (tableData.value.length === 0) {
throw new Error('请添加收款明细');
@@ -206,87 +206,92 @@ const validate = () => {
throw new Error(`${i + 1}本次收款必须大于0`);
}
}
};
}
defineExpose({ validate });
</script>
<template>
<Grid class="w-full">
<template #receiptPrice="{ row }">
<InputNumber
v-model:value="row.receiptPrice"
:precision="2"
:disabled="disabled"
:formatter="erpPriceInputFormatter"
placeholder="请输入本次收款"
@change="handleRowChange(row)"
/>
</template>
<template #remark="{ row }">
<Input
v-model:value="row.remark"
:disabled="disabled"
placeholder="请输入备注"
@change="handleRowChange(row)"
/>
</template>
<template #actions="{ row }">
<TableAction
v-if="!disabled"
:actions="[
{
label: '删除',
type: 'link',
danger: true,
popConfirm: {
title: '确认删除该收款明细吗?',
confirm: handleDelete.bind(null, row),
<div>
<Grid class="w-full">
<template #receiptPrice="{ row }">
<InputNumber
v-model:value="row.receiptPrice"
:precision="2"
:disabled="disabled"
:formatter="erpPriceInputFormatter"
placeholder="请输入本次收款"
@change="handleRowChange(row)"
/>
</template>
<template #remark="{ row }">
<Input
v-model:value="row.remark"
:disabled="disabled"
placeholder="请输入备注"
@change="handleRowChange(row)"
/>
</template>
<template #actions="{ row }">
<TableAction
v-if="!disabled"
:actions="[
{
label: '删除',
type: 'link',
danger: true,
popConfirm: {
title: '确认删除该收款明细吗?',
confirm: handleDelete.bind(null, row),
},
},
},
]"
/>
</template>
]"
/>
</template>
<template #bottom>
<div class="border-border bg-muted mt-2 rounded border p-2">
<div class="text-muted-foreground flex justify-between text-sm">
<span class="text-foreground font-medium">合计</span>
<div class="flex space-x-4">
<span>
合计收款{{ erpPriceInputFormatter(summaries.totalPrice) }}
</span>
<span>
已收金额{{ erpPriceInputFormatter(summaries.receiptedPrice) }}
</span>
<span>
本次收款
{{ erpPriceInputFormatter(summaries.receiptPrice) }}
</span>
<template #bottom>
<div class="border-border bg-muted mt-2 rounded border p-2">
<div class="text-muted-foreground flex justify-between text-sm">
<span class="text-foreground font-medium">合计</span>
<div class="flex space-x-4">
<span>
合计收款{{ erpPriceInputFormatter(summaries.totalPrice) }}
</span>
<span>
已收金额{{ erpPriceInputFormatter(summaries.receiptedPrice) }}
</span>
<span>
本次收款
{{ erpPriceInputFormatter(summaries.receiptPrice) }}
</span>
</div>
</div>
</div>
</div>
<TableAction
v-if="!disabled"
class="mt-2 flex justify-center"
:actions="[
{
label: '添加销售出库单',
type: 'default',
onClick: handleOpenSaleOut,
},
{
label: '添加销售退货单',
type: 'default',
onClick: handleOpenSaleReturn,
},
]"
/>
</template>
</Grid>
<TableAction
v-if="!disabled"
class="mt-2 flex justify-center"
:actions="[
{
label: '添加销售出库单',
type: 'default',
onClick: handleOpenSaleOut,
},
{
label: '添加销售退货单',
type: 'default',
onClick: handleOpenSaleReturn,
},
]"
/>
</template>
</Grid>
<!-- 销售出库单选择组件 -->
<SaleOutSelect ref="saleOutSelectRef" @success="handleAddSaleOut" />
<!-- 销售退货单选择组件 -->
<SaleReturnSelect ref="saleReturnSelectRef" @success="handleAddSaleReturn" />
<!-- 销售出库单选择组件 -->
<SaleOutSelect ref="saleOutSelectRef" @success="handleAddSaleOut" />
<!-- 销售退货单选择组件 -->
<SaleReturnSelect
ref="saleReturnSelectRef"
@success="handleAddSaleReturn"
/>
</div>
</template>

View File

@@ -65,7 +65,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
/** 打开弹窗 */
const openModal = (id: number) => {
function openModal(id: number) {
// 重置数据
customerId.value = id;
open.value = true;
@@ -74,17 +74,17 @@ const openModal = (id: number) => {
gridApi.formApi?.resetForm();
gridApi.formApi?.setValues({ customerId: id });
gridApi.query();
};
}
/** 确认选择销售出库单 */
const handleOk = () => {
function handleOk() {
if (selectedRows.value.length === 0) {
message.warning('请选择要添加的销售出库单');
return;
}
emit('success', selectedRows.value);
open.value = false;
};
}
defineExpose({ open: openModal });
</script>

View File

@@ -69,7 +69,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
/** 打开弹窗 */
const openModal = (id: number) => {
function openModal(id: number) {
// 重置数据
customerId.value = id;
open.value = true;
@@ -78,17 +78,17 @@ const openModal = (id: number) => {
gridApi.formApi?.resetForm();
gridApi.formApi?.setValues({ customerId: id });
gridApi.query();
};
}
/** 确认选择销售退货单 */
const handleOk = () => {
function handleOk() {
if (selectedRows.value.length === 0) {
message.warning('请选择要添加的销售退货单');
return;
}
emit('success', selectedRows.value);
open.value = false;
};
}
defineExpose({ open: openModal });
</script>