feat(wms):优化盘库单的实现
parent
eaedb1e0ca
commit
804ad667e0
|
|
@ -15,8 +15,7 @@ export interface CheckOrderDetailVO {
|
||||||
receiptTime?: Date
|
receiptTime?: Date
|
||||||
quantity?: number
|
quantity?: number
|
||||||
checkQuantity?: number
|
checkQuantity?: number
|
||||||
differenceQuantity?: number
|
|
||||||
availableQuantity?: number
|
availableQuantity?: number
|
||||||
amount?: number
|
price?: number
|
||||||
createTime?: Date
|
createTime?: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ export interface CheckOrderVO {
|
||||||
warehouseId?: number
|
warehouseId?: number
|
||||||
warehouseName?: string
|
warehouseName?: string
|
||||||
totalQuantity?: number
|
totalQuantity?: number
|
||||||
totalAmount?: number
|
totalPrice?: number
|
||||||
|
actualPrice?: number
|
||||||
details?: CheckOrderDetailVO[]
|
details?: CheckOrderDetailVO[]
|
||||||
createTime?: Date
|
createTime?: Date
|
||||||
creator?: string
|
creator?: string
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ export enum DICT_TYPE {
|
||||||
|
|
||||||
// ========== WMS - 仓库管理模块 ==========
|
// ========== WMS - 仓库管理模块 ==========
|
||||||
WMS_MERCHANT_TYPE = 'merchant_type', // WMS 往来企业类型
|
WMS_MERCHANT_TYPE = 'merchant_type', // WMS 往来企业类型
|
||||||
WMS_INVENTORY_HISTORY_TYPE = 'wms_inventory_history_type', // WMS 库存记录类型
|
WMS_ORDER_TYPE = 'wms_order_type', // WMS 单据类型
|
||||||
WMS_ORDER_STATUS = 'wms_order_status', // WMS 单据状态
|
WMS_ORDER_STATUS = 'wms_order_status', // WMS 单据状态
|
||||||
WMS_RECEIPT_ORDER_TYPE = 'wms_receipt_order_type', // WMS 入库单类型
|
WMS_RECEIPT_ORDER_TYPE = 'wms_receipt_order_type', // WMS 入库单类型
|
||||||
WMS_SHIPMENT_ORDER_TYPE = 'wms_shipment_order_type', // WMS 出库单类型
|
WMS_SHIPMENT_ORDER_TYPE = 'wms_shipment_order_type', // WMS 出库单类型
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ import { InventoryApi, InventoryVO } from '@/api/wms/inventory'
|
||||||
import { formatQuantity } from '@/views/wms/utils/format'
|
import { formatQuantity } from '@/views/wms/utils/format'
|
||||||
|
|
||||||
export interface InventorySelectRow extends InventoryVO {
|
export interface InventorySelectRow extends InventoryVO {
|
||||||
amount?: number
|
price?: number
|
||||||
availableQuantity?: number
|
availableQuantity?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,28 +9,28 @@
|
||||||
class="-mb-15px"
|
class="-mb-15px"
|
||||||
label-width="68px"
|
label-width="68px"
|
||||||
>
|
>
|
||||||
<el-form-item label="操作类型" prop="orderType">
|
<el-form-item label="单据类型" prop="orderType">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="queryParams.orderType"
|
v-model="queryParams.orderType"
|
||||||
class="!w-240px"
|
class="!w-240px"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择操作类型"
|
placeholder="请选择单据类型"
|
||||||
@change="handleQuery"
|
@change="handleQuery"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getIntDictOptions(DICT_TYPE.WMS_INVENTORY_HISTORY_TYPE)"
|
v-for="dict in getIntDictOptions(DICT_TYPE.WMS_ORDER_TYPE)"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
:value="dict.value"
|
:value="dict.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="操作单号" prop="orderNo">
|
<el-form-item label="单据号" prop="orderNo">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.orderNo"
|
v-model="queryParams.orderNo"
|
||||||
class="!w-240px"
|
class="!w-240px"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请输入操作单号"
|
placeholder="请输入单据号"
|
||||||
@keyup.enter="handleQuery"
|
@keyup.enter="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -107,10 +107,10 @@
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
border
|
border
|
||||||
>
|
>
|
||||||
<el-table-column fixed="left" label="操作单号" prop="orderNo" width="180" />
|
<el-table-column fixed="left" label="单据号" prop="orderNo" width="180" />
|
||||||
<el-table-column align="center" fixed="left" label="操作类型" width="110">
|
<el-table-column align="center" fixed="left" label="单据类型" width="110">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<dict-tag :type="DICT_TYPE.WMS_INVENTORY_HISTORY_TYPE" :value="scope.row.orderType" />
|
<dict-tag :type="DICT_TYPE.WMS_ORDER_TYPE" :value="scope.row.orderType" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="商品信息" min-width="220">
|
<el-table-column label="商品信息" min-width="220">
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,20 @@
|
||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="盈亏数量">
|
<el-descriptions-item label="盈亏数量">
|
||||||
{{ formatQuantity(detailData.totalQuantity) || '-' }}
|
<span :class="getLossClass(detailData.totalQuantity)">
|
||||||
|
{{ formatQuantity(detailData.totalQuantity) || '-' }}
|
||||||
|
</span>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="总金额">
|
<el-descriptions-item label="总金额">
|
||||||
{{ formatPrice(detailData.totalAmount) || '-' }}
|
{{ formatPrice(detailData.totalPrice) || '-' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="实际金额">
|
||||||
|
{{ formatPrice(detailData.actualPrice) || '-' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="实际盈亏金额">
|
||||||
|
<span :class="getLossClass(getOrderDifferencePrice(detailData))">
|
||||||
|
{{ formatPrice(getOrderDifferencePrice(detailData)) || '-' }}
|
||||||
|
</span>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="创建时间">
|
<el-descriptions-item label="创建时间">
|
||||||
{{ formatNullableDate(detailData.createTime) }}
|
{{ formatNullableDate(detailData.createTime) }}
|
||||||
|
|
@ -55,14 +65,26 @@
|
||||||
<el-table-column align="right" label="账面数量" prop="quantity" width="120">
|
<el-table-column align="right" label="账面数量" prop="quantity" width="120">
|
||||||
<template #default="{ row }">{{ formatQuantity(row.quantity) || '-' }}</template>
|
<template #default="{ row }">{{ formatQuantity(row.quantity) || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="单价(元)" prop="price" width="120">
|
||||||
|
<template #default="{ row }">{{ formatPrice(row.price) || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column align="right" label="实盘数量" prop="checkQuantity" width="120">
|
<el-table-column align="right" label="实盘数量" prop="checkQuantity" width="120">
|
||||||
<template #default="{ row }">{{ formatQuantity(row.checkQuantity) || '-' }}</template>
|
<template #default="{ row }">{{ formatQuantity(row.checkQuantity) || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="right" label="盈亏数量" prop="differenceQuantity" width="120">
|
<el-table-column align="right" label="实际金额(元)" prop="actualPrice" width="140">
|
||||||
<template #default="{ row }">{{ formatQuantity(row.differenceQuantity) || '-' }}</template>
|
<template #default="{ row }">{{ formatPrice(getActualPrice(row)) || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="right" label="金额(元)" prop="amount" width="140">
|
<el-table-column align="right" label="盈亏数量" prop="differenceQuantity" width="120">
|
||||||
<template #default="{ row }">{{ formatPrice(row.amount) || '-' }}</template>
|
<template #default="{ row }">
|
||||||
|
<span :class="getLossClass(getDifferenceQuantity(row))">
|
||||||
|
{{ formatQuantity(getDifferenceQuantity(row)) || '-' }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="实际盈亏金额(元)" prop="differencePrice" width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span :class="getLossClass(getDifferencePrice(row))">{{ formatPrice(getDifferencePrice(row)) || '-' }}</span>
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -70,11 +92,21 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { h } from 'vue'
|
||||||
import { formatNullableDate } from '@/utils/formatTime'
|
import { formatNullableDate } from '@/utils/formatTime'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { CheckOrderApi, CheckOrderVO } from '@/api/wms/order/check'
|
import { CheckOrderApi, CheckOrderVO } from '@/api/wms/order/check'
|
||||||
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
||||||
import { formatPrice, formatQuantity, formatSumPrice, formatSumQuantity } from '@/views/wms/utils/format'
|
import {
|
||||||
|
formatPrice,
|
||||||
|
formatQuantity,
|
||||||
|
formatSumPrice,
|
||||||
|
formatSumQuantity,
|
||||||
|
getLossClass,
|
||||||
|
roundPrice,
|
||||||
|
sumPrice,
|
||||||
|
sumQuantity
|
||||||
|
} from '@/views/wms/utils/format'
|
||||||
|
|
||||||
/** WMS 盘库单详情 */
|
/** WMS 盘库单详情 */
|
||||||
defineOptions({ name: 'WmsCheckOrderDetail' })
|
defineOptions({ name: 'WmsCheckOrderDetail' })
|
||||||
|
|
@ -82,14 +114,36 @@ defineOptions({ name: 'WmsCheckOrderDetail' })
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const detailData = ref<CheckOrderVO>({})
|
const detailData = ref<CheckOrderVO>({})
|
||||||
|
const getOrderDifferencePrice = (order: CheckOrderVO) =>
|
||||||
|
roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
|
||||||
|
const getDifferenceQuantity = (detail: CheckOrderDetailVO) => Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
||||||
|
const getActualPrice = (detail: CheckOrderDetailVO) => {
|
||||||
|
if (detail.checkQuantity === undefined || detail.checkQuantity === null || detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
|
||||||
|
}
|
||||||
|
const getDifferencePrice = (detail: CheckOrderDetailVO) => {
|
||||||
|
if (detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
|
||||||
|
}
|
||||||
|
const renderLossText = (value: number | string | null | undefined, formatter: (value?: number | string | null) => string) =>
|
||||||
|
h('span', { class: getLossClass(value) }, formatter(value))
|
||||||
|
|
||||||
const getSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderDetailVO[] }) =>
|
const getSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderDetailVO[] }) =>
|
||||||
columns.map((column, index) => {
|
columns.map((column, index) => {
|
||||||
if (index === 0) return '合计'
|
if (index === 0) return '合计'
|
||||||
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
|
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
|
||||||
if (column.property === 'checkQuantity') return formatSumQuantity(data, (detail) => detail.checkQuantity)
|
if (column.property === 'checkQuantity') return formatSumQuantity(data, (detail) => detail.checkQuantity)
|
||||||
if (column.property === 'differenceQuantity') return formatSumQuantity(data, (detail) => detail.differenceQuantity)
|
if (column.property === 'actualPrice') return formatSumPrice(data, (detail) => getActualPrice(detail))
|
||||||
if (column.property === 'amount') return formatSumPrice(data, (detail) => detail.amount)
|
if (column.property === 'differenceQuantity') {
|
||||||
|
return renderLossText(sumQuantity(data, (detail) => getDifferenceQuantity(detail)), formatQuantity)
|
||||||
|
}
|
||||||
|
if (column.property === 'differencePrice') {
|
||||||
|
return renderLossText(sumPrice(data, (detail) => getDifferencePrice(detail)), formatPrice)
|
||||||
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,23 +25,11 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="盈亏数量" prop="totalQuantity">
|
<el-form-item label="实际金额">
|
||||||
<el-input :model-value="formatQuantity(totalQuantity)" disabled />
|
<el-input :model-value="formatPrice(actualPrice)" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="16">
|
||||||
<el-form-item label="总金额" prop="totalAmount">
|
|
||||||
<el-input-number
|
|
||||||
v-model="formData.totalAmount"
|
|
||||||
:controls="false"
|
|
||||||
:min="0"
|
|
||||||
:precision="PRICE_PRECISION"
|
|
||||||
class="!w-1/1"
|
|
||||||
placeholder="请输入总金额"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input v-model="formData.remark" maxlength="255" placeholder="请输入备注" :rows="3" type="textarea" />
|
<el-input v-model="formData.remark" maxlength="255" placeholder="请输入备注" :rows="3" type="textarea" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -59,7 +47,13 @@
|
||||||
</span>
|
</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="formData.details" border empty-text="暂无商品明细">
|
<el-table
|
||||||
|
:data="formData.details"
|
||||||
|
:summary-method="getDetailSummaries"
|
||||||
|
border
|
||||||
|
empty-text="暂无商品明细"
|
||||||
|
show-summary
|
||||||
|
>
|
||||||
<el-table-column label="商品信息" min-width="210">
|
<el-table-column label="商品信息" min-width="210">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div>{{ row.itemName || '-' }}</div>
|
<div>{{ row.itemName || '-' }}</div>
|
||||||
|
|
@ -72,10 +66,23 @@
|
||||||
<div v-if="row.skuCode" class="text-12px text-gray-500">规格编号:{{ row.skuCode }}</div>
|
<div v-if="row.skuCode" class="text-12px text-gray-500">规格编号:{{ row.skuCode }}</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="right" label="账面数量" width="120">
|
<el-table-column align="right" label="账面库存" prop="quantity" width="120">
|
||||||
<template #default="{ row }">{{ formatQuantity(row.quantity) || '-' }}</template>
|
<template #default="{ row }">{{ formatQuantity(row.quantity) || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="实盘数量" width="160">
|
<el-table-column label="单价(元)" prop="price" width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input-number
|
||||||
|
v-model="row.price"
|
||||||
|
:controls="false"
|
||||||
|
:min="0"
|
||||||
|
:precision="PRICE_PRECISION"
|
||||||
|
class="!w-1/1"
|
||||||
|
placeholder="单价"
|
||||||
|
@change="handleDetailPriceChange(row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="实际库存" prop="checkQuantity" width="160">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="row.checkQuantity"
|
v-model="row.checkQuantity"
|
||||||
|
|
@ -84,25 +91,33 @@
|
||||||
:precision="QUANTITY_PRECISION"
|
:precision="QUANTITY_PRECISION"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
placeholder="数量"
|
placeholder="数量"
|
||||||
|
@change="handleDetailCheckQuantityChange(row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="right" label="盈亏数量" width="120">
|
<el-table-column label="实际金额(元)" prop="actualPrice" width="160">
|
||||||
<template #default="{ row }">{{ formatQuantity(getDifferenceQuantity(row)) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="金额(元)" width="160">
|
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="row.amount"
|
v-model="row.actualPrice"
|
||||||
:controls="false"
|
:controls="false"
|
||||||
:min="0"
|
:min="0"
|
||||||
:precision="PRICE_PRECISION"
|
:precision="PRICE_PRECISION"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
placeholder="金额"
|
placeholder="金额"
|
||||||
@change="refreshTotalAmount"
|
@change="handleDetailActualPriceChange(row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="盈亏数" prop="differenceQuantity" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span :class="getLossClass(getDifferenceQuantity(row))">{{ formatQuantity(getDifferenceQuantity(row)) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="实际盈亏金额(元)" prop="differencePrice" width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span :class="getLossClass(getDifferencePrice(row))">{{ formatPrice(getDifferencePrice(row)) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column align="center" label="操作" width="80">
|
<el-table-column align="center" label="操作" width="80">
|
||||||
<template #default="{ $index }">
|
<template #default="{ $index }">
|
||||||
<el-button link type="danger" @click="handleDeleteDetail($index)">删除</el-button>
|
<el-button link type="danger" @click="handleDeleteDetail($index)">删除</el-button>
|
||||||
|
|
@ -148,12 +163,26 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { FormRules } from 'element-plus'
|
import { FormRules } from 'element-plus'
|
||||||
|
import { h } from 'vue'
|
||||||
import { CheckOrderApi, CheckOrderVO } from '@/api/wms/order/check'
|
import { CheckOrderApi, CheckOrderVO } from '@/api/wms/order/check'
|
||||||
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
||||||
import InventorySelect, { InventorySelectRow } from '@/views/wms/inventory/components/InventorySelect.vue'
|
import InventorySelect, { InventorySelectRow } from '@/views/wms/inventory/components/InventorySelect.vue'
|
||||||
import WarehouseSelect from '@/views/wms/md/warehouse/components/WarehouseSelect.vue'
|
import WarehouseSelect from '@/views/wms/md/warehouse/components/WarehouseSelect.vue'
|
||||||
import { OrderStatusEnum, OrderUpdateStatusList } from '@/views/wms/utils/constants'
|
import { OrderStatusEnum, OrderUpdateStatusList } from '@/views/wms/utils/constants'
|
||||||
import { formatQuantity, PRICE_PRECISION, QUANTITY_PRECISION, sumPrice } from '@/views/wms/utils/format'
|
import {
|
||||||
|
dividePrice,
|
||||||
|
getLossClass,
|
||||||
|
formatPrice,
|
||||||
|
formatQuantity,
|
||||||
|
formatSumPrice,
|
||||||
|
formatSumQuantity,
|
||||||
|
multiplyPrice,
|
||||||
|
PRICE_PRECISION,
|
||||||
|
QUANTITY_PRECISION,
|
||||||
|
roundPrice,
|
||||||
|
sumPrice,
|
||||||
|
sumQuantity
|
||||||
|
} from '@/views/wms/utils/format'
|
||||||
import { generateOrderNo } from '@/views/wms/utils/order'
|
import { generateOrderNo } from '@/views/wms/utils/order'
|
||||||
|
|
||||||
/** WMS 盘库单表单 */
|
/** WMS 盘库单表单 */
|
||||||
|
|
@ -167,32 +196,42 @@ const dialogTitle = ref('')
|
||||||
const formLoading = ref(false)
|
const formLoading = ref(false)
|
||||||
const formType = ref('')
|
const formType = ref('')
|
||||||
const originalFormData = ref('')
|
const originalFormData = ref('')
|
||||||
const formData = ref<CheckOrderVO>({
|
|
||||||
|
type CheckOrderFormDetail = CheckOrderDetailVO & { actualPrice?: number }
|
||||||
|
type CheckOrderFormData = Omit<CheckOrderVO, 'details'> & { details?: CheckOrderFormDetail[] }
|
||||||
|
|
||||||
|
const formData = ref<CheckOrderFormData>({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
no: undefined,
|
no: undefined,
|
||||||
orderTime: undefined,
|
orderTime: undefined,
|
||||||
status: OrderStatusEnum.PREPARE,
|
status: OrderStatusEnum.PREPARE,
|
||||||
warehouseId: undefined,
|
warehouseId: undefined,
|
||||||
totalQuantity: 0,
|
|
||||||
totalAmount: 0,
|
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
details: []
|
details: []
|
||||||
})
|
})
|
||||||
const formRules = reactive<FormRules>({
|
const formRules = reactive<FormRules>({
|
||||||
no: [{ required: true, message: '盘库单号不能为空', trigger: 'blur' }],
|
no: [{ required: true, message: '盘库单号不能为空', trigger: 'blur' }],
|
||||||
orderTime: [{ required: true, message: '单据日期不能为空', trigger: 'change' }],
|
orderTime: [{ required: true, message: '单据日期不能为空', trigger: 'change' }],
|
||||||
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }],
|
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }]
|
||||||
totalQuantity: [{ required: true, message: '盈亏数量不能为空', trigger: 'change' }],
|
|
||||||
totalAmount: [{ required: true, message: '总金额不能为空', trigger: 'blur' }]
|
|
||||||
})
|
})
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
const inventorySelectRef = ref()
|
const inventorySelectRef = ref()
|
||||||
|
|
||||||
const getDifferenceQuantity = (detail: CheckOrderDetailVO) => Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
const getDifferenceQuantity = (detail: CheckOrderFormDetail) => Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
||||||
const totalQuantity = computed(() =>
|
const getBookPrice = (detail: CheckOrderFormDetail) => multiplyPrice(detail.quantity, detail.price)
|
||||||
(formData.value.details || []).reduce((sum, detail) => sum + getDifferenceQuantity(detail), 0)
|
const getActualPrice = (detail: CheckOrderFormDetail) => detail.actualPrice ?? multiplyPrice(detail.checkQuantity, detail.price)
|
||||||
)
|
const getDifferencePrice = (detail: CheckOrderFormDetail) => {
|
||||||
const detailTotalAmount = computed(() => sumPrice(formData.value.details || [], (detail) => detail.amount))
|
if (detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(getDifferenceQuantity(detail) * Number(detail.price))
|
||||||
|
}
|
||||||
|
const renderLossText = (value: number | string | null | undefined, formatter: (value?: number | string | null) => string) =>
|
||||||
|
h('span', { class: getLossClass(value) }, formatter(value))
|
||||||
|
const totalQuantity = computed(() => sumQuantity(formData.value.details || [], (detail) => getDifferenceQuantity(detail)))
|
||||||
|
const totalPrice = computed(() => sumPrice(formData.value.details || [], (detail) => getBookPrice(detail)))
|
||||||
|
const actualPrice = computed(() => sumPrice(formData.value.details || [], (detail) => getActualPrice(detail)))
|
||||||
|
const differencePrice = computed(() => roundPrice(actualPrice.value - totalPrice.value) || 0)
|
||||||
const isPrepareOrder = computed(
|
const isPrepareOrder = computed(
|
||||||
() =>
|
() =>
|
||||||
!formData.value.id ||
|
!formData.value.id ||
|
||||||
|
|
@ -215,7 +254,7 @@ const open = async (type: string, id?: number) => {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const order = await CheckOrderApi.getCheckOrder(id)
|
const order = await CheckOrderApi.getCheckOrder(id)
|
||||||
formData.value = { ...order, details: order.details || [] }
|
formData.value = { ...order, details: normalizeDetails(order.details || []) }
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
|
|
@ -225,7 +264,7 @@ const open = async (type: string, id?: number) => {
|
||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
|
|
||||||
/** 构建盘库明细 */
|
/** 构建盘库明细 */
|
||||||
const buildDetail = (inventory: InventorySelectRow): CheckOrderDetailVO => ({
|
const buildDetail = (inventory: InventorySelectRow): CheckOrderFormDetail => ({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
itemId: inventory.itemId,
|
itemId: inventory.itemId,
|
||||||
itemCode: inventory.itemCode,
|
itemCode: inventory.itemCode,
|
||||||
|
|
@ -240,9 +279,16 @@ const buildDetail = (inventory: InventorySelectRow): CheckOrderDetailVO => ({
|
||||||
quantity: inventory.availableQuantity,
|
quantity: inventory.availableQuantity,
|
||||||
checkQuantity: inventory.availableQuantity,
|
checkQuantity: inventory.availableQuantity,
|
||||||
availableQuantity: inventory.availableQuantity,
|
availableQuantity: inventory.availableQuantity,
|
||||||
amount: inventory.amount
|
price: inventory.price,
|
||||||
|
actualPrice: multiplyPrice(inventory.availableQuantity, inventory.price)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const normalizeDetails = (details: CheckOrderDetailVO[]) =>
|
||||||
|
details.map((detail) => ({
|
||||||
|
...detail,
|
||||||
|
actualPrice: multiplyPrice(detail.checkQuantity, detail.price)
|
||||||
|
}))
|
||||||
|
|
||||||
const handleAddDetail = () => inventorySelectRef.value?.open()
|
const handleAddDetail = () => inventorySelectRef.value?.open()
|
||||||
const handleSelectInventory = (inventories: InventorySelectRow[]) => {
|
const handleSelectInventory = (inventories: InventorySelectRow[]) => {
|
||||||
if (!inventories.length) return
|
if (!inventories.length) return
|
||||||
|
|
@ -251,7 +297,6 @@ const handleSelectInventory = (inventories: InventorySelectRow[]) => {
|
||||||
if (isInventorySelected(inventory)) return
|
if (isInventorySelected(inventory)) return
|
||||||
formData.value.details!.push(buildDetail(inventory))
|
formData.value.details!.push(buildDetail(inventory))
|
||||||
})
|
})
|
||||||
refreshTotalAmount()
|
|
||||||
}
|
}
|
||||||
const isInventorySelected = (inventory: InventorySelectRow) =>
|
const isInventorySelected = (inventory: InventorySelectRow) =>
|
||||||
(formData.value.details || []).some((detail) => {
|
(formData.value.details || []).some((detail) => {
|
||||||
|
|
@ -259,16 +304,38 @@ const isInventorySelected = (inventory: InventorySelectRow) =>
|
||||||
})
|
})
|
||||||
const handleDeleteDetail = (index: number) => {
|
const handleDeleteDetail = (index: number) => {
|
||||||
formData.value.details?.splice(index, 1)
|
formData.value.details?.splice(index, 1)
|
||||||
refreshTotalAmount()
|
|
||||||
}
|
}
|
||||||
const handleWarehouseChange = () => {
|
const handleWarehouseChange = () => {
|
||||||
formData.value.details = []
|
formData.value.details = []
|
||||||
refreshTotalAmount()
|
|
||||||
}
|
}
|
||||||
const refreshTotalAmount = () => {
|
|
||||||
formData.value.totalAmount = detailTotalAmount.value
|
const handleDetailCheckQuantityChange = (detail: CheckOrderFormDetail) => {
|
||||||
|
if (detail.price !== undefined && detail.price !== null) {
|
||||||
|
detail.actualPrice = multiplyPrice(detail.checkQuantity, detail.price)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
detail.price = dividePrice(detail.actualPrice, detail.checkQuantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDetailPriceChange = (detail: CheckOrderFormDetail) => {
|
||||||
|
detail.actualPrice = multiplyPrice(detail.checkQuantity, detail.price)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDetailActualPriceChange = (detail: CheckOrderFormDetail) => {
|
||||||
|
detail.price = dividePrice(detail.actualPrice, detail.checkQuantity)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: CheckOrderFormDetail[] }) =>
|
||||||
|
columns.map((column, index) => {
|
||||||
|
if (index === 0) return '合计'
|
||||||
|
if (column.property === 'quantity') return formatSumQuantity(data, (detail) => detail.quantity)
|
||||||
|
if (column.property === 'checkQuantity') return formatSumQuantity(data, (detail) => detail.checkQuantity)
|
||||||
|
if (column.property === 'actualPrice') return formatSumPrice(data, (detail) => getActualPrice(detail))
|
||||||
|
if (column.property === 'differenceQuantity') return renderLossText(totalQuantity.value, formatQuantity)
|
||||||
|
if (column.property === 'differencePrice') return renderLossText(differencePrice.value, formatPrice)
|
||||||
|
return ''
|
||||||
|
})
|
||||||
|
|
||||||
/** 校验明细 */
|
/** 校验明细 */
|
||||||
const validateDetails = (required: boolean) => {
|
const validateDetails = (required: boolean) => {
|
||||||
if (!formData.value.details?.length) {
|
if (!formData.value.details?.length) {
|
||||||
|
|
@ -289,13 +356,17 @@ const validateDetails = (required: boolean) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 构建提交数据 */
|
/** 构建提交数据 */
|
||||||
const buildSubmitData = () =>
|
const buildSubmitData = () => {
|
||||||
({
|
const { totalQuantity: _totalQuantity, totalPrice: _totalPrice, actualPrice: _actualPrice, details, ...order } = formData.value
|
||||||
...formData.value,
|
return {
|
||||||
totalQuantity: totalQuantity.value,
|
...order,
|
||||||
totalAmount: formData.value.totalAmount,
|
details: (details || []).map(({
|
||||||
details: formData.value.details || []
|
actualPrice: _rowActualPrice,
|
||||||
}) as CheckOrderVO
|
availableQuantity: _availableQuantity,
|
||||||
|
...detail
|
||||||
|
}) => detail)
|
||||||
|
} as CheckOrderVO
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['success'])
|
const emit = defineEmits(['success'])
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
|
|
@ -360,8 +431,6 @@ const resetForm = () => {
|
||||||
orderTime: undefined,
|
orderTime: undefined,
|
||||||
status: OrderStatusEnum.PREPARE,
|
status: OrderStatusEnum.PREPARE,
|
||||||
warehouseId: undefined,
|
warehouseId: undefined,
|
||||||
totalQuantity: 0,
|
|
||||||
totalAmount: 0,
|
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
details: []
|
details: []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,184 @@
|
||||||
|
<!-- WMS 盘库单打印 -->
|
||||||
|
<template>
|
||||||
|
<div class="hidden">
|
||||||
|
<button ref="printButtonRef" v-print="printObj" type="button"></button>
|
||||||
|
<div id="wmsCheckOrderPrint" class="color-#303133">
|
||||||
|
<h2 class="text-center">盘库单</h2>
|
||||||
|
<div class="mb-12px grid grid-cols-3 gap-x-24px gap-y-8px text-14px">
|
||||||
|
<div>盘库单号:{{ printData.no || '-' }}</div>
|
||||||
|
<div>仓库:{{ printData.warehouseName || '-' }}</div>
|
||||||
|
<div>盘库状态:{{ getDictLabel(DICT_TYPE.WMS_ORDER_STATUS, printData.status) || '-' }}</div>
|
||||||
|
<div>单据日期:{{ formatNullableDate(printData.orderTime, 'YYYY-MM-DD') }}</div>
|
||||||
|
<div>
|
||||||
|
盈亏数量:<span :class="getLossClass(printData.totalQuantity)">
|
||||||
|
{{ formatQuantity(printData.totalQuantity) || '-' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>总金额:{{ formatPrice(printData.totalPrice) || '-' }}</div>
|
||||||
|
<div>实际金额:{{ formatPrice(printData.actualPrice) || '-' }}</div>
|
||||||
|
<div>
|
||||||
|
实际盈亏金额:<span :class="getLossClass(getOrderDifferencePrice(printData))">
|
||||||
|
{{ formatPrice(getOrderDifferencePrice(printData)) || '-' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>创建时间:{{ formatNullableDate(printData.createTime) }}</div>
|
||||||
|
<div class="col-span-3">备注:{{ printData.remark || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
<table class="w-full border-collapse text-13px">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">商品信息</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">规格信息</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">账面库存</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">单价(元)</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">实际库存</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">实际金额(元)</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">盈亏数</th>
|
||||||
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">实际盈亏金额(元)</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="detail in printRows" :key="detail.id">
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px">
|
||||||
|
<div>{{ detail.itemName || '-' }}</div>
|
||||||
|
<div v-if="detail.itemCode" class="text-12px">编号:{{ detail.itemCode }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px">
|
||||||
|
<div>{{ detail.skuName || '-' }}</div>
|
||||||
|
<div v-if="detail.skuCode" class="text-12px">编号:{{ detail.skuCode }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
{{ formatQuantity(detail.quantity) || '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
{{ formatPrice(detail.price) || '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
{{ formatQuantity(detail.checkQuantity) || '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
{{ formatPrice(detail.actualPrice) || '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
<span :class="getLossClass(detail.differenceQuantity)">
|
||||||
|
{{ formatQuantity(detail.differenceQuantity) || '-' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
<span :class="getLossClass(detail.differencePrice)">
|
||||||
|
{{ formatPrice(detail.differencePrice) || '-' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-if="printRows.length">
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px" colspan="2">合计</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-right">
|
||||||
|
{{ formatSumQuantity(printRows, (detail) => detail.quantity) }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-right">
|
||||||
|
{{ formatSumPrice(printRows, (detail) => detail.price) }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-right">
|
||||||
|
{{ formatSumQuantity(printRows, (detail) => detail.checkQuantity) }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-right">
|
||||||
|
{{ formatSumPrice(printRows, (detail) => detail.actualPrice) }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-right">
|
||||||
|
<span :class="getLossClass(totalDifferenceQuantity)">
|
||||||
|
{{ formatQuantity(totalDifferenceQuantity) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-right">
|
||||||
|
<span :class="getLossClass(totalDifferencePrice)">
|
||||||
|
{{ formatPrice(totalDifferencePrice) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-if="!printRows.length">
|
||||||
|
<td
|
||||||
|
class="border border-solid border-#dcdfe6 p-8px text-center"
|
||||||
|
:colspan="tableColumnCount"
|
||||||
|
>
|
||||||
|
暂无明细
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { formatNullableDate } from '@/utils/formatTime'
|
||||||
|
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
||||||
|
import { CheckOrderApi, CheckOrderVO } from '@/api/wms/order/check'
|
||||||
|
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
||||||
|
import {
|
||||||
|
formatPrice,
|
||||||
|
formatQuantity,
|
||||||
|
formatSumPrice,
|
||||||
|
formatSumQuantity,
|
||||||
|
getLossClass,
|
||||||
|
roundPrice,
|
||||||
|
sumPrice,
|
||||||
|
sumQuantity
|
||||||
|
} from '@/views/wms/utils/format'
|
||||||
|
|
||||||
|
/** WMS 盘库单打印 */
|
||||||
|
defineOptions({ name: 'WmsCheckOrderPrint' })
|
||||||
|
|
||||||
|
const printData = ref<CheckOrderVO>({}) // 打印数据
|
||||||
|
const printButtonRef = ref<HTMLButtonElement>() // 打印按钮
|
||||||
|
const tableColumnCount = 8
|
||||||
|
const printObj = ref({
|
||||||
|
id: 'wmsCheckOrderPrint',
|
||||||
|
popTitle: ' ',
|
||||||
|
extraCss: '/print.css',
|
||||||
|
extraHead: '',
|
||||||
|
zIndex: 20003
|
||||||
|
})
|
||||||
|
|
||||||
|
interface PrintRow extends CheckOrderDetailVO {
|
||||||
|
actualPrice?: number
|
||||||
|
differenceQuantity?: number
|
||||||
|
differencePrice?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDifferenceQuantity = (detail: CheckOrderDetailVO) => Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
||||||
|
const getActualPrice = (detail: CheckOrderDetailVO) => {
|
||||||
|
if (detail.checkQuantity === undefined || detail.checkQuantity === null || detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
|
||||||
|
}
|
||||||
|
const getDifferencePrice = (detail: CheckOrderDetailVO, differenceQuantity: number) => {
|
||||||
|
if (detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(differenceQuantity * Number(detail.price))
|
||||||
|
}
|
||||||
|
const getOrderDifferencePrice = (order: CheckOrderVO) =>
|
||||||
|
roundPrice(Number(order.actualPrice || 0) - Number(order.totalPrice || 0))
|
||||||
|
const printRows = computed<PrintRow[]>(() =>
|
||||||
|
(printData.value.details || []).map((detail) => {
|
||||||
|
const differenceQuantity = getDifferenceQuantity(detail)
|
||||||
|
return {
|
||||||
|
...detail,
|
||||||
|
actualPrice: getActualPrice(detail),
|
||||||
|
differenceQuantity,
|
||||||
|
differencePrice: getDifferencePrice(detail, differenceQuantity)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
const totalDifferenceQuantity = computed(() => sumQuantity(printRows.value, (detail) => detail.differenceQuantity))
|
||||||
|
const totalDifferencePrice = computed(() => sumPrice(printRows.value, (detail) => detail.differencePrice))
|
||||||
|
|
||||||
|
/** 打印盘库单 */
|
||||||
|
const print = async (id: number) => {
|
||||||
|
printData.value = await CheckOrderApi.getCheckOrder(id)
|
||||||
|
await nextTick()
|
||||||
|
printButtonRef.value?.click()
|
||||||
|
}
|
||||||
|
defineExpose({ print })
|
||||||
|
</script>
|
||||||
|
|
@ -48,10 +48,10 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="总金额" prop="totalAmountMin">
|
<el-form-item label="总金额" prop="totalPriceMin">
|
||||||
<div class="flex w-240px items-center gap-8px">
|
<div class="flex w-240px items-center gap-8px">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="queryParams.totalAmountMin"
|
v-model="queryParams.totalPriceMin"
|
||||||
:controls="false"
|
:controls="false"
|
||||||
:min="0"
|
:min="0"
|
||||||
:precision="PRICE_PRECISION"
|
:precision="PRICE_PRECISION"
|
||||||
|
|
@ -60,7 +60,28 @@
|
||||||
/>
|
/>
|
||||||
<span>至</span>
|
<span>至</span>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="queryParams.totalAmountMax"
|
v-model="queryParams.totalPriceMax"
|
||||||
|
:controls="false"
|
||||||
|
:min="0"
|
||||||
|
:precision="PRICE_PRECISION"
|
||||||
|
class="!w-105px"
|
||||||
|
placeholder="最大值"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="实际金额" prop="actualPriceMin">
|
||||||
|
<div class="flex w-240px items-center gap-8px">
|
||||||
|
<el-input-number
|
||||||
|
v-model="queryParams.actualPriceMin"
|
||||||
|
:controls="false"
|
||||||
|
:min="0"
|
||||||
|
:precision="PRICE_PRECISION"
|
||||||
|
class="!w-105px"
|
||||||
|
placeholder="最小值"
|
||||||
|
/>
|
||||||
|
<span>至</span>
|
||||||
|
<el-input-number
|
||||||
|
v-model="queryParams.actualPriceMax"
|
||||||
:controls="false"
|
:controls="false"
|
||||||
:min="0"
|
:min="0"
|
||||||
:precision="PRICE_PRECISION"
|
:precision="PRICE_PRECISION"
|
||||||
|
|
@ -170,8 +191,25 @@
|
||||||
<el-table-column align="right" label="实盘数量" width="120">
|
<el-table-column align="right" label="实盘数量" width="120">
|
||||||
<template #default="{ row: detail }">{{ formatQuantity(detail.checkQuantity) }}</template>
|
<template #default="{ row: detail }">{{ formatQuantity(detail.checkQuantity) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="单价(元)" width="120">
|
||||||
|
<template #default="{ row: detail }">{{ formatPrice(detail.price) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="实际金额(元)" width="140">
|
||||||
|
<template #default="{ row: detail }">{{ formatPrice(getDetailActualPrice(detail)) }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column align="right" label="盈亏数量" width="120">
|
<el-table-column align="right" label="盈亏数量" width="120">
|
||||||
<template #default="{ row: detail }">{{ formatQuantity(detail.differenceQuantity) }}</template>
|
<template #default="{ row: detail }">
|
||||||
|
<span :class="getLossClass(getDetailDifferenceQuantity(detail))">
|
||||||
|
{{ formatQuantity(getDetailDifferenceQuantity(detail)) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="实际盈亏金额(元)" width="160">
|
||||||
|
<template #default="{ row: detail }">
|
||||||
|
<span :class="getLossClass(getDetailDifferencePrice(detail))">
|
||||||
|
{{ formatPrice(getDetailDifferencePrice(detail)) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -202,15 +240,23 @@
|
||||||
{{ row.warehouseName || '-' }}
|
{{ row.warehouseName || '-' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column v-if="isTableColumnVisible('quantityAmount')" label="盈亏数量/总金额(元)" min-width="180">
|
<el-table-column v-if="isTableColumnVisible('quantityAmount')" label="盈亏/金额(元)" min-width="200">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span>盈亏:</span>
|
<span>盈亏数:</span>
|
||||||
<span>{{ formatQuantity(row.totalQuantity) }}</span>
|
<span :class="getLossClass(row.totalQuantity)">{{ formatQuantity(row.totalQuantity) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span>金额:</span>
|
<span>总金额:</span>
|
||||||
<span>{{ formatPrice(row.totalAmount) }}</span>
|
<span>{{ formatPrice(row.totalPrice) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<span>实际金额:</span>
|
||||||
|
<span>{{ formatPrice(row.actualPrice) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<span>盈亏金额:</span>
|
||||||
|
<span :class="getLossClass(getDifferencePrice(row))">{{ formatPrice(getDifferencePrice(row)) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -249,6 +295,14 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
<el-button
|
||||||
|
v-hasPermi="['wms:check-order:query']"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="handlePrint(row.id)"
|
||||||
|
>
|
||||||
|
打印
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -257,6 +311,7 @@
|
||||||
|
|
||||||
<CheckOrderForm ref="formRef" @success="getList" />
|
<CheckOrderForm ref="formRef" @success="getList" />
|
||||||
<CheckOrderDetail ref="detailRef" />
|
<CheckOrderDetail ref="detailRef" />
|
||||||
|
<CheckOrderPrint ref="printRef" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
@ -266,10 +321,18 @@ import { CheckOrderApi, CheckOrderVO } from '@/api/wms/order/check'
|
||||||
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
import { CheckOrderDetailVO } from '@/api/wms/order/check/detail'
|
||||||
import WarehouseSelect from '@/views/wms/md/warehouse/components/WarehouseSelect.vue'
|
import WarehouseSelect from '@/views/wms/md/warehouse/components/WarehouseSelect.vue'
|
||||||
import { OrderDeleteStatusList, OrderStatusEnum, OrderUpdateStatusList } from '@/views/wms/utils/constants'
|
import { OrderDeleteStatusList, OrderStatusEnum, OrderUpdateStatusList } from '@/views/wms/utils/constants'
|
||||||
import { formatPrice, formatQuantity, PRICE_PRECISION, QUANTITY_PRECISION } from '@/views/wms/utils/format'
|
import {
|
||||||
|
formatPrice,
|
||||||
|
formatQuantity,
|
||||||
|
getLossClass,
|
||||||
|
PRICE_PRECISION,
|
||||||
|
QUANTITY_PRECISION,
|
||||||
|
roundPrice
|
||||||
|
} from '@/views/wms/utils/format'
|
||||||
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
||||||
import CheckOrderDetail from './CheckOrderDetail.vue'
|
import CheckOrderDetail from './CheckOrderDetail.vue'
|
||||||
import CheckOrderForm from './CheckOrderForm.vue'
|
import CheckOrderForm from './CheckOrderForm.vue'
|
||||||
|
import CheckOrderPrint from './CheckOrderPrint.vue'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
|
|
||||||
/** WMS 盘库单 */
|
/** WMS 盘库单 */
|
||||||
|
|
@ -284,7 +347,7 @@ const tableColumnOptions: Array<{ label: string; value: TableColumnKey }> = [
|
||||||
{ label: '单号', value: 'no' },
|
{ label: '单号', value: 'no' },
|
||||||
{ label: '盘库状态', value: 'status' },
|
{ label: '盘库状态', value: 'status' },
|
||||||
{ label: '仓库', value: 'warehouse' },
|
{ label: '仓库', value: 'warehouse' },
|
||||||
{ label: '盈亏/金额(元)', value: 'quantityAmount' },
|
{ label: '盈亏/金额', value: 'quantityAmount' },
|
||||||
{ label: '操作信息', value: 'operateInfo' },
|
{ label: '操作信息', value: 'operateInfo' },
|
||||||
{ label: '备注', value: 'remark' }
|
{ label: '备注', value: 'remark' }
|
||||||
]
|
]
|
||||||
|
|
@ -310,8 +373,10 @@ const getDefaultQueryParams = () => ({
|
||||||
orderTime: undefined as string[] | undefined,
|
orderTime: undefined as string[] | undefined,
|
||||||
totalQuantityMin: undefined as number | undefined,
|
totalQuantityMin: undefined as number | undefined,
|
||||||
totalQuantityMax: undefined as number | undefined,
|
totalQuantityMax: undefined as number | undefined,
|
||||||
totalAmountMin: undefined as number | undefined,
|
totalPriceMin: undefined as number | undefined,
|
||||||
totalAmountMax: undefined as number | undefined,
|
totalPriceMax: undefined as number | undefined,
|
||||||
|
actualPriceMin: undefined as number | undefined,
|
||||||
|
actualPriceMax: undefined as number | undefined,
|
||||||
creator: undefined as number | undefined,
|
creator: undefined as number | undefined,
|
||||||
updater: undefined as number | undefined,
|
updater: undefined as number | undefined,
|
||||||
createTime: undefined as string[] | undefined,
|
createTime: undefined as string[] | undefined,
|
||||||
|
|
@ -333,6 +398,21 @@ const getDeleteTip = (status?: number) => {
|
||||||
if (status === OrderStatusEnum.FINISHED) return '已盘库,无法删除'
|
if (status === OrderStatusEnum.FINISHED) return '已盘库,无法删除'
|
||||||
return '当前状态无法删除'
|
return '当前状态无法删除'
|
||||||
}
|
}
|
||||||
|
const getDifferencePrice = (row: CheckOrderVO) => roundPrice(Number(row.actualPrice || 0) - Number(row.totalPrice || 0))
|
||||||
|
const getDetailDifferenceQuantity = (detail: CheckOrderDetailVO) =>
|
||||||
|
Number(detail.checkQuantity || 0) - Number(detail.quantity || 0)
|
||||||
|
const getDetailActualPrice = (detail: CheckOrderDetailVO) => {
|
||||||
|
if (detail.checkQuantity === undefined || detail.checkQuantity === null || detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(Number(detail.checkQuantity) * Number(detail.price))
|
||||||
|
}
|
||||||
|
const getDetailDifferencePrice = (detail: CheckOrderDetailVO) => {
|
||||||
|
if (detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(getDetailDifferenceQuantity(detail) * Number(detail.price))
|
||||||
|
}
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
@ -361,6 +441,8 @@ const formRef = ref()
|
||||||
const openForm = (type: string, id?: number) => formRef.value.open(type, id)
|
const openForm = (type: string, id?: number) => formRef.value.open(type, id)
|
||||||
const detailRef = ref()
|
const detailRef = ref()
|
||||||
const openDetail = (id: number) => detailRef.value.open(id)
|
const openDetail = (id: number) => detailRef.value.open(id)
|
||||||
|
const printRef = ref()
|
||||||
|
const handlePrint = (id: number) => printRef.value.print(id)
|
||||||
|
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,15 @@ export const roundPrice = (value: number) => {
|
||||||
return Number.isFinite(value) ? Number(value.toFixed(PRICE_PRECISION)) : undefined
|
return Number.isFinite(value) ? Number(value.toFixed(PRICE_PRECISION)) : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 亏损数字样式 */
|
||||||
|
export const getLossClass = (value?: number | string | null) => {
|
||||||
|
const decimalValue = toFiniteDecimal(value)
|
||||||
|
return decimalValue !== undefined && decimalValue < 0 ? 'text-red-500' : ''
|
||||||
|
}
|
||||||
|
|
||||||
/** 数量 * 单价,计算金额 */
|
/** 数量 * 单价,计算金额 */
|
||||||
export const multiplyPrice = (quantity?: number, price?: number) => {
|
export const multiplyPrice = (quantity?: number, price?: number) => {
|
||||||
if (!quantity || price === undefined || price === null) {
|
if (quantity === undefined || quantity === null || price === undefined || price === null) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return roundPrice(Number(quantity) * Number(price))
|
return roundPrice(Number(quantity) * Number(price))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue