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

@@ -20,9 +20,9 @@ export namespace ErpFinancePaymentApi {
export interface FinancePayment { export interface FinancePayment {
id?: number; // 付款单编号 id?: number; // 付款单编号
no: string; // 付款单号 no: string; // 付款单号
supplierId: number; // 供应商编号 supplierId?: number; // 供应商编号
supplierName?: string; // 供应商名称 supplierName?: string; // 供应商名称
paymentTime: Date; // 付款时间 paymentTime?: Date; // 付款时间
totalPrice: number; // 合计金额,单位:元 totalPrice: number; // 合计金额,单位:元
discountPrice: number; // 优惠金额 discountPrice: number; // 优惠金额
paymentPrice: number; // 实际付款金额 paymentPrice: number; // 实际付款金额

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -49,14 +49,15 @@ const formData = ref<
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['采购入库']);
? $t('ui.actionTitle.create', ['采购入库']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['采购入库']);
? $t('ui.actionTitle.edit', ['采购入库']) } else {
: '采购入库详情', return '采购入库详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -170,7 +171,7 @@ const [Modal, modalApi] = useVbenModal({
}, },
async onOpenChange(isOpen: boolean) { async onOpenChange(isOpen: boolean) {
if (!isOpen) { if (!isOpen) {
formData.value = undefined; formData.value = {} as ErpPurchaseInApi.PurchaseIn;
return; return;
} }
// 加载数据 // 加载数据

View File

@@ -96,7 +96,7 @@ watch(
await gridApi.grid.reloadData(tableData.value); await gridApi.grid.reloadData(tableData.value);
// 更新表格列配置(目的:原数量、已入库动态列) // 更新表格列配置(目的:原数量、已入库动态列)
const columns = useFormItemColumns(tableData.value); const columns = useFormItemColumns(tableData.value);
await gridApi.grid.reloadColumn(columns); await gridApi.grid.reloadColumn(columns || []);
}, },
{ {
immediate: true, immediate: true,
@@ -140,14 +140,14 @@ function handleDelete(row: ErpPurchaseInApi.PurchaseInItem) {
} }
/** 处理仓库变更 */ /** 处理仓库变更 */
const handleWarehouseChange = async (row: ErpPurchaseInApi.PurchaseInItem) => { async function handleWarehouseChange(row: ErpPurchaseInApi.PurchaseInItem) {
const stockCount = await getWarehouseStockCount({ const stockCount = await getWarehouseStockCount({
productId: row.productId!, productId: row.productId!,
warehouseId: row.warehouseId!, warehouseId: row.warehouseId!,
}); });
row.stockCount = stockCount || 0; row.stockCount = stockCount || 0;
handleRowChange(row); handleRowChange(row);
}; }
/** 处理行数据变更 */ /** 处理行数据变更 */
function handleRowChange(row: any) { function handleRowChange(row: any) {
@@ -161,14 +161,14 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpPurchaseInApi.PurchaseInItem): void => { function initRow(row: ErpPurchaseInApi.PurchaseInItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
row.taxPrice = row.taxPrice =
erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
row.totalPrice = row.totalProductPrice + row.taxPrice; row.totalPrice = row.totalProductPrice + row.taxPrice;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -78,40 +78,42 @@ function handleSelectOrder(selectOrder: ErpPurchaseOrderApi.PurchaseOrder) {
} }
/** 确认选择采购订单 */ /** 确认选择采购订单 */
const handleOk = () => { function handleOk() {
if (!order.value) { if (!order.value) {
message.warning('请选择一个采购订单'); message.warning('请选择一个采购订单');
return; return;
} }
emit('update:order', order.value); emit('update:order', order.value);
open.value = false; open.value = false;
}; }
</script> </script>
<template> <template>
<Input <div>
readonly <Input
:value="orderNo" readonly
:disabled="disabled" :value="orderNo"
@click="() => !disabled && (open = true)" :disabled="disabled"
> @click="() => !disabled && (open = true)"
<template #addonAfter> >
<div> <template #addonAfter>
<IconifyIcon <div>
class="h-full w-6 cursor-pointer" <IconifyIcon
icon="ant-design:setting-outlined" class="h-full w-6 cursor-pointer"
:style="{ cursor: disabled ? 'not-allowed' : 'pointer' }" icon="ant-design:setting-outlined"
@click="() => !disabled && (open = true)" :style="{ cursor: disabled ? 'not-allowed' : 'pointer' }"
/> @click="() => !disabled && (open = true)"
</div> />
</template> </div>
</Input> </template>
<Modal </Input>
class="!w-[50vw]" <Modal
v-model:open="open" class="!w-[50vw]"
title="选择关联订单" v-model:open="open"
@ok="handleOk" title="选择关联订单"
> @ok="handleOk"
<Grid class="max-h-[600px]" table-title="采购订单列表(仅展示可退货)" /> >
</Modal> <Grid class="max-h-[600px]" table-title="采购订单列表(仅展示可退货)" />
</Modal>
</div>
</template> </template>

View File

@@ -24,14 +24,15 @@ const formData = ref<ErpPurchaseOrderApi.PurchaseOrder>();
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof PurchaseOrderItemForm>>(); const itemFormRef = ref<InstanceType<typeof PurchaseOrderItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['采购订单']);
? $t('ui.actionTitle.create', ['采购订单']) } else if (formType.value === 'edit') {
: formType.value === 'update' return $t('ui.actionTitle.edit', ['采购订单']);
? $t('ui.actionTitle.edit', ['采购订单']) } else {
: '采购订单详情', return '采购订单详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -53,27 +54,27 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新采购订单项 */ /** 更新采购订单项 */
const handleUpdateItems = (items: ErpPurchaseOrderApi.PurchaseOrderItem[]) => { function handleUpdateItems(items: ErpPurchaseOrderApi.PurchaseOrderItem[]) {
formData.value = modalApi.getData<ErpPurchaseOrderApi.PurchaseOrder>(); formData.value = modalApi.getData<ErpPurchaseOrderApi.PurchaseOrder>();
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 更新优惠金额 */ /** 更新优惠金额 */
const handleUpdateDiscountPrice = (discountPrice: number) => { function handleUpdateDiscountPrice(discountPrice: number) {
formApi.setValues({ formApi.setValues({
discountPrice, discountPrice,
}); });
}; }
/** 更新总金额 */ /** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => { function handleUpdateTotalPrice(totalPrice: number) {
formApi.setValues({ formApi.setValues({
totalPrice, totalPrice,
}); });
}; }
/** 创建或更新采购订单 */ /** 创建或更新采购订单 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({

View File

@@ -179,14 +179,14 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpPurchaseOrderApi.PurchaseOrderItem): void => { function initRow(row: ErpPurchaseOrderApi.PurchaseOrderItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
row.taxPrice = row.taxPrice =
erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
row.totalPrice = row.totalProductPrice + row.taxPrice; row.totalPrice = row.totalProductPrice + row.taxPrice;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -83,38 +83,36 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新采购退货项 */ /** 更新采购退货项 */
const handleUpdateItems = ( function handleUpdateItems(items: ErpPurchaseReturnApi.PurchaseReturnItem[]) {
items: ErpPurchaseReturnApi.PurchaseReturnItem[],
) => {
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 更新其他费用 */ /** 更新其他费用 */
const handleUpdateOtherPrice = (otherPrice: number) => { function handleUpdateOtherPrice(otherPrice: number) {
formApi.setValues({ formApi.setValues({
otherPrice, otherPrice,
}); });
}; }
/** 更新优惠金额 */ /** 更新优惠金额 */
const handleUpdateDiscountPrice = (discountPrice: number) => { function handleUpdateDiscountPrice(discountPrice: number) {
formApi.setValues({ formApi.setValues({
discountPrice, discountPrice,
}); });
}; }
/** 更新总金额 */ /** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => { function handleUpdateTotalPrice(totalPrice: number) {
formApi.setValues({ formApi.setValues({
totalPrice, totalPrice,
}); });
}; }
/** 选择采购订单 */ /** 选择采购订单 */
const handleUpdateOrder = (order: ErpPurchaseOrderApi.PurchaseOrder) => { function handleUpdateOrder(order: ErpPurchaseOrderApi.PurchaseOrder) {
formData.value = { formData.value = {
...formData.value, ...formData.value,
orderId: order.id, orderId: order.id,
@@ -136,7 +134,7 @@ const handleUpdateOrder = (order: ErpPurchaseOrderApi.PurchaseOrder) => {
(item) => item.count && item.count > 0, (item) => item.count && item.count > 0,
) as ErpPurchaseReturnApi.PurchaseReturnItem[]; ) as ErpPurchaseReturnApi.PurchaseReturnItem[];
formApi.setValues(formData.value, false); formApi.setValues(formData.value, false);
}; }
/** 创建或更新采购退货 */ /** 创建或更新采购退货 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
@@ -173,7 +171,7 @@ const [Modal, modalApi] = useVbenModal({
}, },
async onOpenChange(isOpen: boolean) { async onOpenChange(isOpen: boolean) {
if (!isOpen) { if (!isOpen) {
formData.value = undefined; formData.value = {} as ErpPurchaseReturnApi.PurchaseReturn;
return; return;
} }
// 加载数据 // 加载数据

View File

@@ -96,7 +96,7 @@ watch(
await gridApi.grid.reloadData(tableData.value); await gridApi.grid.reloadData(tableData.value);
// 更新表格列配置(目的:已入库、已退货动态列) // 更新表格列配置(目的:已入库、已退货动态列)
const columns = useFormItemColumns(tableData.value); const columns = useFormItemColumns(tableData.value);
await gridApi.grid.reloadColumn(columns); await gridApi.grid.reloadColumn(columns || []);
}, },
{ {
immediate: true, immediate: true,
@@ -140,16 +140,16 @@ function handleDelete(row: ErpPurchaseReturnApi.PurchaseReturnItem) {
} }
/** 处理仓库变更 */ /** 处理仓库变更 */
const handleWarehouseChange = async ( async function handleWarehouseChange(
row: ErpPurchaseReturnApi.PurchaseReturnItem, row: ErpPurchaseReturnApi.PurchaseReturnItem,
) => { ) {
const stockCount = await getWarehouseStockCount({ const stockCount = await getWarehouseStockCount({
productId: row.productId!, productId: row.productId!,
warehouseId: row.warehouseId!, warehouseId: row.warehouseId!,
}); });
row.stockCount = stockCount || 0; row.stockCount = stockCount || 0;
handleRowChange(row); handleRowChange(row);
}; }
/** 处理行数据变更 */ /** 处理行数据变更 */
function handleRowChange(row: any) { function handleRowChange(row: any) {
@@ -163,14 +163,14 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpPurchaseReturnApi.PurchaseReturnItem): void => { function initRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
row.taxPrice = row.taxPrice =
erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
row.totalPrice = row.totalProductPrice + row.taxPrice; row.totalPrice = row.totalProductPrice + row.taxPrice;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -78,40 +78,42 @@ function handleSelectOrder(selectOrder: ErpPurchaseOrderApi.PurchaseOrder) {
} }
/** 确认选择采购订单 */ /** 确认选择采购订单 */
const handleOk = () => { function handleOk() {
if (!order.value) { if (!order.value) {
message.warning('请选择一个采购订单'); message.warning('请选择一个采购订单');
return; return;
} }
emit('update:order', order.value); emit('update:order', order.value);
open.value = false; open.value = false;
}; }
</script> </script>
<template> <template>
<Input <div>
readonly <Input
:value="orderNo" readonly
:disabled="disabled" :value="orderNo"
@click="() => !disabled && (open = true)" :disabled="disabled"
> @click="() => !disabled && (open = true)"
<template #addonAfter> >
<div> <template #addonAfter>
<IconifyIcon <div>
class="h-full w-6 cursor-pointer" <IconifyIcon
icon="ant-design:setting-outlined" class="h-full w-6 cursor-pointer"
:style="{ cursor: disabled ? 'not-allowed' : 'pointer' }" icon="ant-design:setting-outlined"
@click="() => !disabled && (open = true)" :style="{ cursor: disabled ? 'not-allowed' : 'pointer' }"
/> @click="() => !disabled && (open = true)"
</div> />
</template> </div>
</Input> </template>
<Modal </Input>
class="!w-[50vw]" <Modal
v-model:open="open" class="!w-[50vw]"
title="选择关联订单" v-model:open="open"
@ok="handleOk" title="选择关联订单"
> @ok="handleOk"
<Grid class="max-h-[600px]" table-title="采购订单列表(仅展示可退货)" /> >
</Modal> <Grid class="max-h-[600px]" table-title="采购订单列表(仅展示可退货)" />
</Modal>
</div>
</template> </template>

View File

@@ -24,14 +24,15 @@ const formData = ref<ErpSaleOrderApi.SaleOrder>();
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['销售订单']);
? $t('ui.actionTitle.create', ['销售订单']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['销售订单']);
? $t('ui.actionTitle.edit', ['销售订单']) } else {
: '销售订单详情', return '销售订单详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -53,27 +54,27 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新销售订单项 */ /** 更新销售订单项 */
const handleUpdateItems = (items: ErpSaleOrderApi.SaleOrderItem[]) => { function handleUpdateItems(items: ErpSaleOrderApi.SaleOrderItem[]) {
formData.value = modalApi.getData<ErpSaleOrderApi.SaleOrder>(); formData.value = modalApi.getData<ErpSaleOrderApi.SaleOrder>();
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 更新优惠金额 */ /** 更新优惠金额 */
const handleUpdateDiscountPrice = (discountPrice: number) => { function handleUpdateDiscountPrice(discountPrice: number) {
formApi.setValues({ formApi.setValues({
discountPrice, discountPrice,
}); });
}; }
/** 更新总金额 */ /** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => { function handleUpdateTotalPrice(totalPrice: number) {
formApi.setValues({ formApi.setValues({
totalPrice, totalPrice,
}); });
}; }
/** 创建或更新销售订单 */ /** 创建或更新销售订单 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({

View File

@@ -179,14 +179,14 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpSaleOrderApi.SaleOrderItem): void => { function initRow(row: ErpSaleOrderApi.SaleOrderItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
row.taxPrice = row.taxPrice =
erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
row.totalPrice = row.totalProductPrice + row.taxPrice; row.totalPrice = row.totalProductPrice + row.taxPrice;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -79,36 +79,36 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新销售出库项 */ /** 更新销售出库项 */
const handleUpdateItems = (items: ErpSaleOutApi.SaleOutItem[]) => { function handleUpdateItems(items: ErpSaleOutApi.SaleOutItem[]) {
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 更新其他费用 */ /** 更新其他费用 */
const handleUpdateOtherPrice = (otherPrice: number) => { function handleUpdateOtherPrice(otherPrice: number) {
formApi.setValues({ formApi.setValues({
otherPrice, otherPrice,
}); });
}; }
/** 更新优惠金额 */ /** 更新优惠金额 */
const handleUpdateDiscountPrice = (discountPrice: number) => { function handleUpdateDiscountPrice(discountPrice: number) {
formApi.setValues({ formApi.setValues({
discountPrice, discountPrice,
}); });
}; }
/** 更新总金额 */ /** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => { function handleUpdateTotalPrice(totalPrice: number) {
formApi.setValues({ formApi.setValues({
totalPrice, totalPrice,
}); });
}; }
/** 选择销售订单 */ /** 选择销售订单 */
const handleUpdateOrder = (order: ErpSaleOrderApi.SaleOrder) => { function handleUpdateOrder(order: ErpSaleOrderApi.SaleOrder) {
formData.value = { formData.value = {
...formData.value, ...formData.value,
orderId: order.id, orderId: order.id,
@@ -130,7 +130,7 @@ const handleUpdateOrder = (order: ErpSaleOrderApi.SaleOrder) => {
(item) => item.count && item.count > 0, (item) => item.count && item.count > 0,
) as ErpSaleOutApi.SaleOutItem[]; ) as ErpSaleOutApi.SaleOutItem[];
formApi.setValues(formData.value, false); formApi.setValues(formData.value, false);
}; }
/** 创建或更新销售出库 */ /** 创建或更新销售出库 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
@@ -166,7 +166,7 @@ const [Modal, modalApi] = useVbenModal({
}, },
async onOpenChange(isOpen: boolean) { async onOpenChange(isOpen: boolean) {
if (!isOpen) { if (!isOpen) {
formData.value = undefined; formData.value = {} as ErpSaleOutApi.SaleOut;
return; return;
} }
// 加载数据 // 加载数据

View File

@@ -96,7 +96,7 @@ watch(
await gridApi.grid.reloadData(tableData.value); await gridApi.grid.reloadData(tableData.value);
// 更新表格列配置(目的:原数量、已出库动态列) // 更新表格列配置(目的:原数量、已出库动态列)
const columns = useFormItemColumns(tableData.value); const columns = useFormItemColumns(tableData.value);
await gridApi.grid.reloadColumn(columns); await gridApi.grid.reloadColumn(columns || []);
}, },
{ {
immediate: true, immediate: true,
@@ -140,14 +140,14 @@ function handleDelete(row: ErpSaleOutApi.SaleOutItem) {
} }
/** 处理仓库变更 */ /** 处理仓库变更 */
const handleWarehouseChange = async (row: ErpSaleOutApi.SaleOutItem) => { async function handleWarehouseChange(row: ErpSaleOutApi.SaleOutItem) {
const stockCount = await getWarehouseStockCount({ const stockCount = await getWarehouseStockCount({
productId: row.productId!, productId: row.productId!,
warehouseId: row.warehouseId!, warehouseId: row.warehouseId!,
}); });
row.stockCount = stockCount || 0; row.stockCount = stockCount || 0;
handleRowChange(row); handleRowChange(row);
}; }
/** 处理行数据变更 */ /** 处理行数据变更 */
function handleRowChange(row: any) { function handleRowChange(row: any) {
@@ -161,14 +161,14 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpSaleOutApi.SaleOutItem): void => { function initRow(row: ErpSaleOutApi.SaleOutItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
row.taxPrice = row.taxPrice =
erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
row.totalPrice = row.totalProductPrice + row.taxPrice; row.totalPrice = row.totalProductPrice + row.taxPrice;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -78,40 +78,42 @@ function handleSelectOrder(selectOrder: ErpSaleOrderApi.SaleOrder) {
} }
/** 确认选择销售订单 */ /** 确认选择销售订单 */
const handleOk = () => { function handleOk() {
if (!order.value) { if (!order.value) {
message.warning('请选择一个销售订单'); message.warning('请选择一个销售订单');
return; return;
} }
emit('update:order', order.value); emit('update:order', order.value);
open.value = false; open.value = false;
}; }
</script> </script>
<template> <template>
<Input <div>
readonly <Input
:value="orderNo" readonly
:disabled="disabled" :value="orderNo"
@click="() => !disabled && (open = true)" :disabled="disabled"
> @click="() => !disabled && (open = true)"
<template #addonAfter> >
<div> <template #addonAfter>
<IconifyIcon <div>
class="h-full w-6 cursor-pointer" <IconifyIcon
icon="ant-design:setting-outlined" class="h-full w-6 cursor-pointer"
:style="{ cursor: disabled ? 'not-allowed' : 'pointer' }" icon="ant-design:setting-outlined"
@click="() => !disabled && (open = true)" :style="{ cursor: disabled ? 'not-allowed' : 'pointer' }"
/> @click="() => !disabled && (open = true)"
</div> />
</template> </div>
</Input> </template>
<Modal </Input>
class="!w-[50vw]" <Modal
v-model:open="open" class="!w-[50vw]"
title="选择关联订单" v-model:open="open"
@ok="handleOk" title="选择关联订单"
> @ok="handleOk"
<Grid class="max-h-[600px]" table-title="销售订单列表(仅展示可出库)" /> >
</Modal> <Grid class="max-h-[600px]" table-title="销售订单列表(仅展示可出库)" />
</Modal>
</div>
</template> </template>

View File

@@ -49,14 +49,15 @@ const formData = ref<
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['销售退货']);
? $t('ui.actionTitle.create', ['销售退货']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['销售退货']);
? $t('ui.actionTitle.edit', ['销售退货']) } else {
: '销售退货详情', return '销售退货详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -83,36 +84,36 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新销售退货项 */ /** 更新销售退货项 */
const handleUpdateItems = (items: ErpSaleReturnApi.SaleReturnItem[]) => { function handleUpdateItems(items: ErpSaleReturnApi.SaleReturnItem[]) {
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 更新其他费用 */ /** 更新其他费用 */
const handleUpdateOtherPrice = (otherPrice: number) => { function handleUpdateOtherPrice(otherPrice: number) {
formApi.setValues({ formApi.setValues({
otherPrice, otherPrice,
}); });
}; }
/** 更新优惠金额 */ /** 更新优惠金额 */
const handleUpdateDiscountPrice = (discountPrice: number) => { function handleUpdateDiscountPrice(discountPrice: number) {
formApi.setValues({ formApi.setValues({
discountPrice, discountPrice,
}); });
}; }
/** 更新总金额 */ /** 更新总金额 */
const handleUpdateTotalPrice = (totalPrice: number) => { function handleUpdateTotalPrice(totalPrice: number) {
formApi.setValues({ formApi.setValues({
totalPrice, totalPrice,
}); });
}; }
/** 选择销售订单 */ /** 选择销售订单 */
const handleUpdateOrder = (order: ErpSaleOrderApi.SaleOrder) => { function handleUpdateOrder(order: ErpSaleOrderApi.SaleOrder) {
formData.value = { formData.value = {
...formData.value, ...formData.value,
orderId: order.id, orderId: order.id,
@@ -134,7 +135,7 @@ const handleUpdateOrder = (order: ErpSaleOrderApi.SaleOrder) => {
(item) => item.count && item.count > 0, (item) => item.count && item.count > 0,
) as ErpSaleReturnApi.SaleReturnItem[]; ) as ErpSaleReturnApi.SaleReturnItem[];
formApi.setValues(formData.value, false); formApi.setValues(formData.value, false);
}; }
/** 创建或更新销售退货 */ /** 创建或更新销售退货 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
@@ -170,7 +171,7 @@ const [Modal, modalApi] = useVbenModal({
}, },
async onOpenChange(isOpen: boolean) { async onOpenChange(isOpen: boolean) {
if (!isOpen) { if (!isOpen) {
formData.value = undefined; formData.value = {} as ErpSaleReturnApi.SaleReturn;
return; return;
} }
// 加载数据 // 加载数据

View File

@@ -96,7 +96,7 @@ watch(
await gridApi.grid.reloadData(tableData.value); await gridApi.grid.reloadData(tableData.value);
// 更新表格列配置(目的:已出库、已出库动态列) // 更新表格列配置(目的:已出库、已出库动态列)
const columns = useFormItemColumns(tableData.value); const columns = useFormItemColumns(tableData.value);
await gridApi.grid.reloadColumn(columns); await gridApi.grid.reloadColumn(columns || []);
}, },
{ {
immediate: true, immediate: true,
@@ -140,14 +140,14 @@ function handleDelete(row: ErpSaleReturnApi.SaleReturnItem) {
} }
/** 处理仓库变更 */ /** 处理仓库变更 */
const handleWarehouseChange = async (row: ErpSaleReturnApi.SaleReturnItem) => { async function handleWarehouseChange(row: ErpSaleReturnApi.SaleReturnItem) {
const stockCount = await getWarehouseStockCount({ const stockCount = await getWarehouseStockCount({
productId: row.productId!, productId: row.productId!,
warehouseId: row.warehouseId!, warehouseId: row.warehouseId!,
}); });
row.stockCount = stockCount || 0; row.stockCount = stockCount || 0;
handleRowChange(row); handleRowChange(row);
}; }
/** 处理行数据变更 */ /** 处理行数据变更 */
function handleRowChange(row: any) { function handleRowChange(row: any) {
@@ -161,14 +161,14 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpSaleReturnApi.SaleReturnItem): void => { function initRow(row: ErpSaleReturnApi.SaleReturnItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
row.taxPrice = row.taxPrice =
erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
row.totalPrice = row.totalProductPrice + row.taxPrice; row.totalPrice = row.totalProductPrice + row.taxPrice;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -78,40 +78,42 @@ function handleSelectOrder(selectOrder: ErpSaleOrderApi.SaleOrder) {
} }
/** 确认选择销售订单 */ /** 确认选择销售订单 */
const handleOk = () => { function handleOk() {
if (!order.value) { if (!order.value) {
message.warning('请选择一个销售订单'); message.warning('请选择一个销售订单');
return; return;
} }
emit('update:order', order.value); emit('update:order', order.value);
open.value = false; open.value = false;
}; }
</script> </script>
<template> <template>
<Input <div>
readonly <Input
:value="orderNo" readonly
:disabled="disabled" :value="orderNo"
@click="() => !disabled && (open = true)" :disabled="disabled"
> @click="() => !disabled && (open = true)"
<template #addonAfter> >
<div> <template #addonAfter>
<IconifyIcon <div>
class="h-full w-6 cursor-pointer" <IconifyIcon
icon="ant-design:setting-outlined" class="h-full w-6 cursor-pointer"
:style="{ cursor: disabled ? 'not-allowed' : 'pointer' }" icon="ant-design:setting-outlined"
@click="() => !disabled && (open = true)" :style="{ cursor: disabled ? 'not-allowed' : 'pointer' }"
/> @click="() => !disabled && (open = true)"
</div> />
</template> </div>
</Input> </template>
<Modal </Input>
class="!w-[50vw]" <Modal
v-model:open="open" class="!w-[50vw]"
title="选择关联订单" v-model:open="open"
@ok="handleOk" title="选择关联订单"
> @ok="handleOk"
<Grid class="max-h-[600px]" table-title="销售订单列表(仅展示可退货)" /> >
</Modal> <Grid class="max-h-[600px]" table-title="销售订单列表(仅展示可退货)" />
</Modal>
</div>
</template> </template>

View File

@@ -23,14 +23,15 @@ const formData = ref<ErpStockCheckApi.StockCheck>();
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['库存盘点单']);
? $t('ui.actionTitle.create', ['库存盘点单']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['库存盘点单']);
? $t('ui.actionTitle.edit', ['库存盘点单']) } else {
: '库存盘点单详情', return '库存盘点单详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -46,13 +47,13 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新盘点单项 */ /** 更新盘点单项 */
const handleUpdateItems = (items: ErpStockCheckApi.StockCheckItem[]) => { function handleUpdateItems(items: ErpStockCheckApi.StockCheckItem[]) {
formData.value = modalApi.getData<ErpStockCheckApi.StockCheck>(); formData.value = modalApi.getData<ErpStockCheckApi.StockCheck>();
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 创建或更新库存盘点单 */ /** 创建或更新库存盘点单 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({

View File

@@ -174,11 +174,11 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpStockCheckApi.StockCheckItem): void => { function initRow(row: ErpStockCheckApi.StockCheckItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -19,14 +19,15 @@ const formData = ref<ErpStockInApi.StockIn>();
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['其它入库单']);
? $t('ui.actionTitle.create', ['其它入库单']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['其它入库单']);
? $t('ui.actionTitle.edit', ['其它入库单']) } else {
: '其它入库单详情', return '其它入库单详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -42,13 +43,13 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新入库单项 */ /** 更新入库单项 */
const handleUpdateItems = (items: ErpStockInApi.StockInItem[]) => { function handleUpdateItems(items: ErpStockInApi.StockInItem[]) {
formData.value = modalApi.getData<ErpStockInApi.StockIn>(); formData.value = modalApi.getData<ErpStockInApi.StockIn>();
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 创建或更新其它入库单 */ /** 创建或更新其它入库单 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({

View File

@@ -160,11 +160,11 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpStockInApi.StockInItem): void => { function initRow(row: ErpStockInApi.StockInItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -23,14 +23,15 @@ const formData = ref<ErpStockMoveApi.StockMove>();
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['库存调拨单']);
? $t('ui.actionTitle.create', ['库存调拨单']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['库存调拨单']);
? $t('ui.actionTitle.edit', ['库存调拨单']) } else {
: '库存调拨单详情', return '库存调拨单详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -46,13 +47,13 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新调拨单项 */ /** 更新调拨单项 */
const handleUpdateItems = (items: ErpStockMoveApi.StockMoveItem[]) => { function handleUpdateItems(items: ErpStockMoveApi.StockMoveItem[]) {
formData.value = modalApi.getData<ErpStockMoveApi.StockMove>(); formData.value = modalApi.getData<ErpStockMoveApi.StockMove>();
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 创建或更新库存调拨单 */ /** 创建或更新库存调拨单 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({

View File

@@ -99,7 +99,7 @@ function handleAdd() {
totalPrice: undefined, totalPrice: undefined,
remark: undefined, remark: undefined,
}; };
tableData.value.push(newRow); tableData.value.push(newRow as any);
// 通知父组件更新 // 通知父组件更新
emit('update:items', [...tableData.value]); emit('update:items', [...tableData.value]);
} }
@@ -169,11 +169,11 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpStockMoveApi.StockMoveItem): void => { function initRow(row: ErpStockMoveApi.StockMoveItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {

View File

@@ -23,14 +23,15 @@ const formData = ref<ErpStockOutApi.StockOut>();
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail' const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>(); const itemFormRef = ref<InstanceType<typeof ItemForm>>();
/* eslint-disable unicorn/no-nested-ternary */ const getTitle = computed(() => {
const getTitle = computed(() => if (formType.value === 'create') {
formType.value === 'create' return $t('ui.actionTitle.create', ['其它出库单']);
? $t('ui.actionTitle.create', ['其它出库单']) } else if (formType.value === 'edit') {
: formType.value === 'edit' return $t('ui.actionTitle.edit', ['其它出库单']);
? $t('ui.actionTitle.edit', ['其它出库单']) } else {
: '其它出库单详情', return '其它出库单详情';
); }
});
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -46,13 +47,13 @@ const [Form, formApi] = useVbenForm({
}); });
/** 更新出库单项 */ /** 更新出库单项 */
const handleUpdateItems = (items: ErpStockOutApi.StockOutItem[]) => { function handleUpdateItems(items: ErpStockOutApi.StockOutItem[]) {
formData.value = modalApi.getData<ErpStockOutApi.StockOut>(); formData.value = modalApi.getData<ErpStockOutApi.StockOut>();
formData.value.items = items; formData.value.items = items;
formApi.setValues({ formApi.setValues({
items, items,
}); });
}; }
/** 创建或更新其它出库单 */ /** 创建或更新其它出库单 */
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({

View File

@@ -158,11 +158,11 @@ function handleRowChange(row: any) {
} }
/** 初始化行数据 */ /** 初始化行数据 */
const initRow = (row: ErpStockOutApi.StockOutItem): void => { function initRow(row: ErpStockOutApi.StockOutItem) {
if (row.productPrice && row.count) { if (row.productPrice && row.count) {
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
} }
}; }
/** 表单校验 */ /** 表单校验 */
function validate() { function validate() {