库存盘点
This commit is contained in:
1 parent
cdc44f8284
commit
89516f2da2
2 files changed
+57
-73
No files matched your search
@@ -1,17 +0,0 @@
|
||||
import { computed } from "vue"
|
||||
|
||||
const useComputed = (fn: Function) => {
|
||||
const map = new Map()
|
||||
|
||||
return (...args: any[]) => {
|
||||
const key = JSON.stringify(args)
|
||||
|
||||
if (map.has(key)) return map.get(key)
|
||||
|
||||
const comput = computed(() => fn(...args))
|
||||
map.set(key, comput)
|
||||
return comput
|
||||
}
|
||||
}
|
||||
|
||||
export default useComputed
|
||||
@@ -49,7 +49,6 @@
|
||||
ref="vxeTableRef"
|
||||
border
|
||||
:loading="loading"
|
||||
show-overflow
|
||||
max-height="410"
|
||||
:edit-config="{
|
||||
trigger: 'click',
|
||||
@@ -93,9 +92,11 @@
|
||||
<span v-else>{{ row.erpSpuId && erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="unitId" title="包装单位" min-width="60">
|
||||
<vxe-column field="unitId" title="包装单位" min-width="60" width="auto">
|
||||
<template #default="{ row }">
|
||||
<div v-for="(item, index) in row.erpUnitVos" :key="index">单位:{{ item.unit }} 装数:{{ item.packageNum }}</div>
|
||||
<div v-for="(item, index) in row.erpUnitVos" :key="index">
|
||||
单位:{{ item.unit }} 装数:{{ item.packageNum }} 进价:{{ displayPrice(item.purchasePrice, "元") }}
|
||||
</div>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="accountNumber" title="账面数量">
|
||||
@@ -105,6 +106,16 @@
|
||||
</div>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="unitPrice" title="账面总进价">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
displayPrice(
|
||||
row.erpUnitVos.reduce((pre: any, cur: any) => pre + cur.purchasePrice * Number(cur.accountNumber), 0),
|
||||
"",
|
||||
)
|
||||
}}
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="realNumber" title="实际数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }" min-width="30">
|
||||
<template #edit="{ row }">
|
||||
<el-input
|
||||
@@ -133,14 +144,9 @@
|
||||
{{ computeLoss(row) }}
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="unitPrice" title="账面进价">
|
||||
<vxe-column field="pdTotalNum" title="盘后总数">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
displayPrice(
|
||||
row.erpUnitVos.reduce((pre: any, cur: any) => pre + cur.purchasePrice * Number(cur.accountNumber), 0),
|
||||
"",
|
||||
)
|
||||
}}
|
||||
{{ row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0) || 0 }}
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="pdPrice" title="盘点单价" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
@@ -148,16 +154,11 @@
|
||||
<el-input v-model="row.pdPrice" />
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="pdTotalNum" title="盘后总数">
|
||||
<template #default="{ row }">
|
||||
{{ row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0) || 0 }}
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="pdTotalAmount" title="盘后总金额">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
(
|
||||
parseFloat(row.pdPrice || 0) *
|
||||
Number(row.pdPrice || 0) *
|
||||
(row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0) || 0)
|
||||
).toFixed(2) || 0
|
||||
}}
|
||||
@@ -340,7 +341,7 @@ const computeProfit = (row: any) => {
|
||||
|
||||
row._cachedProfit = diff > 0 ? diff : 0
|
||||
}
|
||||
return row._cachedProfit
|
||||
return row._cachedProfit.toFixed(2)
|
||||
}
|
||||
// 计算亏
|
||||
const computeLoss = (row: any) => {
|
||||
@@ -355,7 +356,7 @@ const computeLoss = (row: any) => {
|
||||
|
||||
row._cachedLoss = diff > 0 ? diff : 0
|
||||
}
|
||||
return row._cachedLoss
|
||||
return row._cachedLoss.toFixed(2)
|
||||
}
|
||||
|
||||
// 当编辑实际数量时清除缓存使其重新计算
|
||||
@@ -364,6 +365,43 @@ const handleRealNumberChange = (row: any) => {
|
||||
row._cachedLoss = null
|
||||
}
|
||||
|
||||
// 计算行数据
|
||||
// const computeRowData = (row: any) => {
|
||||
// // 计算盘点总数
|
||||
// const pdTotalNum = row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0)
|
||||
|
||||
// // 计算盈亏
|
||||
// const diff = pdTotalNum - (Number(row.stock) || 0)
|
||||
// const profit = diff > 0 ? diff : 0
|
||||
// const loss = diff < 0 ? Math.abs(diff) : 0
|
||||
|
||||
// // 计算总金额
|
||||
// const pdTotalAmount = Number(row.pdPrice) * pdTotalNum
|
||||
|
||||
// return {
|
||||
// pdTotalNum,
|
||||
// profit,
|
||||
// loss,
|
||||
// pdTotalAmount,
|
||||
// }
|
||||
// }
|
||||
|
||||
// 可编辑表格变化
|
||||
const handleEditChange = ({ row, column }: any) => {
|
||||
// if (column.field === "realNumber") {
|
||||
// // 更新盈亏数据
|
||||
// row._cachedProfit = null
|
||||
// row._cachedLoss = null
|
||||
// // 更新盘点总数和总金额
|
||||
// row.pdTotalNum = row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0)
|
||||
// row.pdTotalAmount = Number(row.pdPrice) * row.pdTotalNum
|
||||
// }
|
||||
// if (column.field === "pdPrice") {
|
||||
// // 更新盘点总金额
|
||||
// row.pdTotalAmount = Number(row.pdPrice) * row.pdTotalNum
|
||||
// }
|
||||
}
|
||||
|
||||
// 整理数据
|
||||
const settledTableItems = computed(() => {
|
||||
return vxeTableData.value.map((item: any) => {
|
||||
@@ -386,7 +424,7 @@ const settledTableItems = computed(() => {
|
||||
totalNumber: item.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0) || 0,
|
||||
totalAmount: Number(
|
||||
(
|
||||
parseFloat(item.pdPrice || 0) *
|
||||
Number(item.pdPrice || 0) *
|
||||
(item.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0) || 0)
|
||||
).toFixed(2) || 0,
|
||||
),
|
||||
@@ -427,43 +465,6 @@ const clearData = () => {
|
||||
return true
|
||||
}
|
||||
|
||||
// 计算行数据
|
||||
// const computeRowData = (row: any) => {
|
||||
// // 计算盘点总数
|
||||
// const pdTotalNum = row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0)
|
||||
|
||||
// // 计算盈亏
|
||||
// const diff = pdTotalNum - (Number(row.stock) || 0)
|
||||
// const profit = diff > 0 ? diff : 0
|
||||
// const loss = diff < 0 ? Math.abs(diff) : 0
|
||||
|
||||
// // 计算总金额
|
||||
// const pdTotalAmount = parseFloat(row.pdPrice) * pdTotalNum
|
||||
|
||||
// return {
|
||||
// pdTotalNum,
|
||||
// profit,
|
||||
// loss,
|
||||
// pdTotalAmount,
|
||||
// }
|
||||
// }
|
||||
|
||||
// 可编辑表格变化
|
||||
const handleEditChange = ({ row, column }: any) => {
|
||||
// if (column.field === "realNumber") {
|
||||
// // 更新盈亏数据
|
||||
// row._cachedProfit = null
|
||||
// row._cachedLoss = null
|
||||
// // 更新盘点总数和总金额
|
||||
// row.pdTotalNum = row.erpUnitVos.reduce((pre: any, cur: any) => pre + Number(cur.realNumber) * cur.packageNum, 0)
|
||||
// row.pdTotalAmount = parseFloat(row.pdPrice) * row.pdTotalNum
|
||||
// }
|
||||
// if (column.field === "pdPrice") {
|
||||
// // 更新盘点总金额
|
||||
// row.pdTotalAmount = parseFloat(row.pdPrice) * row.pdTotalNum
|
||||
// }
|
||||
}
|
||||
|
||||
// 点击打印
|
||||
// const printEvent = () => {
|
||||
// tablePrint(vxeTableRef.value, baseInfoRef.value, vxeTableData.value, 23, "库存盘点")
|
||||
|
||||
Reference in new issue
Block a user