采购入库修改实际进价的计算

This commit is contained in:
weiwei committed 2025-04-27 17:33:24 +08:00
1 parent 1b6d271296
commit 17373dea34
2 files changed
+28 -29

No files matched your search

@@ -88,7 +88,7 @@
</el-button> -->
<el-button type="primary" plain @click="handleClickSpuSelect">商品选择</el-button>
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpSpuIds.length <= 0">删除选中</el-button>
<el-button type="danger" @click="clearData">清空数据</el-button>
<el-button type="danger" plain @click="clearData">清空数据</el-button>
</el-row>
<vxe-table
@@ -150,32 +150,28 @@
<el-input v-model="row.quantity" />
</template>
</vxe-column>
<vxe-column field="unitPrice" title="原进价">
<template #default="{ row }">
{{
row.purchasePrice
? displayPrice(row.purchasePrice)
: displayPrice(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice)
}}
</template>
</vxe-column>
<vxe-column field="realPrice" title="实际进价">
<template #default="{ row }">
{{
row.real_price
? displayPrice(row.real_price)
: displayPrice(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice)
}}
</template>
</vxe-column>
<vxe-column field="unitPrice" title="原进价">
<template #default="{ row }">
{{
row.purchasePrice
? displayPrice(row.purchasePrice)
: displayPrice(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice)
}}
</template>
</vxe-column>
<vxe-column field="realPrice" title="实际进价" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #default="{ row }">{{ row.realPrice }}</template>
<template #edit="{ row }">
<el-input v-model="row.realPrice" />
</template>
</vxe-column>
<vxe-column field="totalAmount" title="累计总金额">
<template #default="{ row }">
<span v-if="row.unitId && row.quantity && row.unit && !row.erpUnitVos">
{{ displayPrice(row.quantity * parseFloat(row.purchasePrice)) }}
{{ Number(row.quantity * parseFloat(row.realPrice)).toFixed(2) }}
</span>
<span v-if="row.unitId && row.quantity && row.erpUnitVos">
{{ displayPrice(Number(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice) * row.quantity) }}
{{ Number(Number(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.realPrice) * row.quantity).toFixed(2) }}
</span>
</template>
</vxe-column>
@@ -229,7 +225,7 @@ import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-ta
import { formatDate } from "/@/utils/formatTime"
import { Search } from "@element-plus/icons-vue"
import linkCodeDialog from "/@/views/supermarketerp/components/linkCodeDialog.vue"
import { displayPrice } from "/@/utils/formatMoney"
import { displayPrice, storePrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketUtils"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -309,6 +305,7 @@ const dataRules = ref({
const validRules = ref<VxeTablePropTypes.EditRules<any>>({
unitId: [{ required: true, message: "必须选择" }],
quantity: [{ required: true, type: "number", min: 1, message: "必需大于等于0" }],
realPrice: [{ required: true, type: "number", min: 0, message: "必填" }],
})
// 初始化数据
@@ -325,8 +322,8 @@ const getInitData = async () => {
if (cgPlanData && cgPlanData.code === 0) {
Object.assign(baseDataForm, cgPlanData.data)
state.editableTableData = cgPlanData.data.items
state.erpSpuItemsMemo = cgPlanData.data.items
state.editableTableData = cgPlanData.data.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.realPrice, "") }))
state.erpSpuItemsMemo = cgPlanData.data.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.realPrice, "") }))
}
} else {
loading.value = true
@@ -353,8 +350,8 @@ const getSelectedLinkCode = (selectionRows: any) => {
console.log("被选择的关联数据", selectionRows)
baseDataForm.linkCode = selectionRows.code
state.editableTableData = selectionRows.items
state.erpSpuItemsMemo = selectionRows.items
state.editableTableData = selectionRows.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") }))
state.erpSpuItemsMemo = selectionRows.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") }))
state.linkCgPlanDialogVisible = false
}
@@ -486,7 +483,8 @@ const cgPlanSpuItems = computed(() => {
erpSpuId: item.erpSpuId,
quantity: item.quantity,
unitPrice: unit.purchasePrice ? Number(unit?.purchasePrice) : 0,
totalAmount: Number(unit?.purchasePrice || 0) * item.quantity,
realPrice: unit.realPrice ? storePrice(unit?.realPrice) : 0,
totalAmount: storePrice(Number(unit?.realPrice || 0) * item.quantity),
remark: item.remark,
unitId: item.unitId,
}
@@ -496,7 +494,8 @@ const cgPlanSpuItems = computed(() => {
erpSpuId: item.erpSpuId,
quantity: item.quantity,
unitPrice: item.purchasePrice ? Number(item.purchasePrice) : 0,
totalAmount: item?.purchasePrice && item.quantity ? Number(item.purchasePrice) * item.quantity : 0,
realPrice: item.realPrice ? storePrice(item.realPrice) : 0,
totalAmount: item?.realPrice && item.quantity ? storePrice(Number(item.realPrice) * item.quantity) : 0,
remark: item.remark,
unitId: item.unitId,
}