feat(wms):入库管理,调整合计金额、数量的字段与交互。(前端负责展示,后端负责计算)
parent
44808eb3f4
commit
6f96d004a9
|
|
@ -15,7 +15,7 @@ export interface InventoryHistoryVO {
|
||||||
quantity?: number
|
quantity?: number
|
||||||
beforeQuantity?: number
|
beforeQuantity?: number
|
||||||
afterQuantity?: number
|
afterQuantity?: number
|
||||||
amount?: number
|
price?: number
|
||||||
remark?: string
|
remark?: string
|
||||||
orderId?: number
|
orderId?: number
|
||||||
orderNo?: string
|
orderNo?: string
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ export interface ReceiptOrderDetailVO {
|
||||||
warehouseId?: number
|
warehouseId?: number
|
||||||
warehouseName?: string
|
warehouseName?: string
|
||||||
quantity?: number
|
quantity?: number
|
||||||
amount?: number
|
price?: number
|
||||||
|
totalPrice?: number
|
||||||
createTime?: Date
|
createTime?: Date
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export interface ReceiptOrderVO {
|
||||||
warehouseId?: number
|
warehouseId?: number
|
||||||
warehouseName?: string
|
warehouseName?: string
|
||||||
totalQuantity?: number
|
totalQuantity?: number
|
||||||
totalAmount?: number
|
totalPrice?: number
|
||||||
details?: ReceiptOrderDetailVO[]
|
details?: ReceiptOrderDetailVO[]
|
||||||
createTime?: Date
|
createTime?: Date
|
||||||
creator?: string
|
creator?: string
|
||||||
|
|
|
||||||
|
|
@ -144,15 +144,15 @@
|
||||||
{{ formatQuantity(scope.row.afterQuantity) || '-' }}
|
{{ formatQuantity(scope.row.afterQuantity) || '-' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="数量/金额(元)" min-width="150">
|
<el-table-column label="数量/单价(元)" min-width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span>数量:</span>
|
<span>数量:</span>
|
||||||
<span>{{ formatQuantity(scope.row.quantity) }}</span>
|
<span>{{ formatQuantity(scope.row.quantity) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="scope.row.amount || scope.row.amount === 0" class="flex justify-between">
|
<div v-if="scope.row.price || scope.row.price === 0" class="flex justify-between">
|
||||||
<span>金额:</span>
|
<span>单价:</span>
|
||||||
<span>{{ formatPrice(scope.row.amount) }}</span>
|
<span>{{ formatPrice(scope.row.price) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
{{ formatQuantity(detailData.totalQuantity) || '-' }}
|
{{ formatQuantity(detailData.totalQuantity) || '-' }}
|
||||||
</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>
|
||||||
<el-descriptions-item label="创建时间">
|
<el-descriptions-item label="创建时间">
|
||||||
{{ formatNullableDate(detailData.createTime) }}
|
{{ formatNullableDate(detailData.createTime) }}
|
||||||
|
|
@ -80,14 +80,14 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="center" label="单位" prop="unit" width="100" />
|
<el-table-column align="center" label="单位" prop="unit" width="100" />
|
||||||
<el-table-column align="right" label="单价" prop="unitPrice" width="140">
|
<el-table-column align="right" label="单价" prop="price" width="140">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
{{ formatPrice(scope.row.unitPrice) || '-' }}
|
{{ formatPrice(scope.row.price) || '-' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="right" label="总价" prop="amount" width="140">
|
<el-table-column align="right" label="总价" prop="totalPrice" width="140">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
{{ formatPrice(scope.row.amount) || '-' }}
|
{{ formatPrice(scope.row.totalPrice) || '-' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -111,7 +111,7 @@ import {
|
||||||
defineOptions({ name: 'WmsReceiptOrderDetail' })
|
defineOptions({ name: 'WmsReceiptOrderDetail' })
|
||||||
|
|
||||||
interface DetailRow extends ReceiptOrderDetailVO {
|
interface DetailRow extends ReceiptOrderDetailVO {
|
||||||
unitPrice?: number
|
totalPrice?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const loading = ref(false) // 加载中
|
const loading = ref(false) // 加载中
|
||||||
|
|
@ -120,9 +120,9 @@ const detailData = ref<ReceiptOrderVO>({}) // 详情数据
|
||||||
const detailRows = computed<DetailRow[]>(() =>
|
const detailRows = computed<DetailRow[]>(() =>
|
||||||
(detailData.value.details || []).map((detail) => ({
|
(detailData.value.details || []).map((detail) => ({
|
||||||
...detail,
|
...detail,
|
||||||
unitPrice:
|
totalPrice:
|
||||||
detail.amount != null && detail.quantity
|
detail.price != null && detail.quantity
|
||||||
? Number(detail.amount) / Number(detail.quantity)
|
? Number(detail.price) * Number(detail.quantity)
|
||||||
: undefined
|
: undefined
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
@ -135,8 +135,11 @@ const getSummaries = ({ columns, data }: { columns: any[]; data: DetailRow[] })
|
||||||
if (column.property === 'quantity') {
|
if (column.property === 'quantity') {
|
||||||
return formatSumQuantity(data, (detail) => detail.quantity)
|
return formatSumQuantity(data, (detail) => detail.quantity)
|
||||||
}
|
}
|
||||||
if (column.property === 'amount') {
|
if (column.property === 'price') {
|
||||||
return formatSumPrice(data, (detail) => detail.amount)
|
return formatSumPrice(data, (detail) => detail.price)
|
||||||
|
}
|
||||||
|
if (column.property === 'totalPrice') {
|
||||||
|
return formatSumPrice(data, (detail) => detail.totalPrice)
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
<el-input v-model="formData.bizOrderNo" maxlength="64" placeholder="请输入业务单号" />
|
<el-input v-model="formData.bizOrderNo" maxlength="64" placeholder="请输入业务单号" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="16">
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="formData.remark"
|
v-model="formData.remark"
|
||||||
|
|
@ -67,23 +67,6 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
|
||||||
<el-form-item label="总数量" prop="totalQuantity">
|
|
||||||
<el-input :model-value="formatQuantity(totalQuantity)" disabled />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
<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-row>
|
</el-row>
|
||||||
|
|
||||||
<div class="mb-12px flex items-center justify-between">
|
<div class="mb-12px flex items-center justify-between">
|
||||||
|
|
@ -101,7 +84,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="220">
|
<el-table-column label="商品信息" min-width="220">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div>{{ scope.row.itemName || '-' }}</div>
|
<div>{{ scope.row.itemName || '-' }}</div>
|
||||||
|
|
@ -118,7 +107,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="入库数量" width="160">
|
<el-table-column label="入库数量" prop="quantity" width="160">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="scope.row.quantity"
|
v-model="scope.row.quantity"
|
||||||
|
|
@ -127,19 +116,33 @@
|
||||||
:precision="QUANTITY_PRECISION"
|
:precision="QUANTITY_PRECISION"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
placeholder="数量"
|
placeholder="数量"
|
||||||
|
@change="handleDetailQuantityChange(scope.row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="金额(元)" width="160">
|
<el-table-column label="单价(元)" prop="price" width="160">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="scope.row.amount"
|
v-model="scope.row.price"
|
||||||
|
:controls="false"
|
||||||
|
:min="0"
|
||||||
|
:precision="PRICE_PRECISION"
|
||||||
|
class="!w-1/1"
|
||||||
|
placeholder="单价"
|
||||||
|
@change="handleDetailPriceChange(scope.row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="金额(元)" prop="totalPrice" width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input-number
|
||||||
|
v-model="scope.row.totalPrice"
|
||||||
: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="handleDetailAmountChange"
|
@change="handleDetailTotalPriceChange(scope.row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -195,11 +198,12 @@ import MerchantSelect from '@/views/wms/md/merchant/components/MerchantSelect.vu
|
||||||
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 {
|
import {
|
||||||
formatQuantity,
|
formatPrice,
|
||||||
|
formatSumPrice,
|
||||||
|
formatSumQuantity,
|
||||||
PRICE_PRECISION,
|
PRICE_PRECISION,
|
||||||
QUANTITY_PRECISION,
|
QUANTITY_PRECISION,
|
||||||
sumPrice,
|
sumPrice
|
||||||
sumQuantity
|
|
||||||
} from '@/views/wms/utils/format'
|
} from '@/views/wms/utils/format'
|
||||||
import { generateOrderNo } from '@/views/wms/utils/order'
|
import { generateOrderNo } from '@/views/wms/utils/order'
|
||||||
|
|
||||||
|
|
@ -223,8 +227,6 @@ const formData = ref<ReceiptOrderVO>({
|
||||||
bizOrderNo: undefined,
|
bizOrderNo: undefined,
|
||||||
merchantId: undefined,
|
merchantId: undefined,
|
||||||
warehouseId: undefined,
|
warehouseId: undefined,
|
||||||
totalQuantity: 0,
|
|
||||||
totalAmount: 0,
|
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
details: []
|
details: []
|
||||||
})
|
})
|
||||||
|
|
@ -232,15 +234,12 @@ const formRules = reactive<FormRules>({
|
||||||
no: [{ required: true, message: '入库单号不能为空', trigger: 'blur' }],
|
no: [{ required: true, message: '入库单号不能为空', trigger: 'blur' }],
|
||||||
type: [{ required: true, message: '入库类型不能为空', trigger: 'change' }],
|
type: [{ required: true, message: '入库类型不能为空', trigger: 'change' }],
|
||||||
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() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
const skuSelectRef = ref() // 商品 SKU 选择弹窗 Ref
|
const skuSelectRef = ref() // 商品 SKU 选择弹窗 Ref
|
||||||
|
|
||||||
const totalQuantity = computed(() => sumQuantity(formData.value.details || [], (detail) => detail.quantity))
|
const detailPriceSum = computed(() => sumPrice(formData.value.details || [], (detail) => detail.price))
|
||||||
const detailTotalAmount = computed(() => sumPrice(formData.value.details || [], (detail) => detail.amount))
|
|
||||||
const isPrepareOrder = computed(
|
const isPrepareOrder = computed(
|
||||||
() =>
|
() =>
|
||||||
!formData.value.id ||
|
!formData.value.id ||
|
||||||
|
|
@ -266,7 +265,7 @@ const open = async (type: string, id?: number) => {
|
||||||
const order = await ReceiptOrderApi.getReceiptOrder(id)
|
const order = await ReceiptOrderApi.getReceiptOrder(id)
|
||||||
formData.value = {
|
formData.value = {
|
||||||
...order,
|
...order,
|
||||||
details: order.details || []
|
details: normalizeDetails(order.details || [])
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
|
|
@ -287,9 +286,34 @@ const buildDetail = (sku: ItemSkuVO): ReceiptOrderDetailVO => ({
|
||||||
skuCode: sku.code,
|
skuCode: sku.code,
|
||||||
skuName: sku.name,
|
skuName: sku.name,
|
||||||
quantity: undefined,
|
quantity: undefined,
|
||||||
amount: undefined
|
price: undefined,
|
||||||
|
totalPrice: undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const normalizeDetails = (details: ReceiptOrderDetailVO[]) =>
|
||||||
|
details.map((detail) => ({
|
||||||
|
...detail,
|
||||||
|
totalPrice: detail.totalPrice ?? multiplyPrice(detail.quantity, detail.price)
|
||||||
|
}))
|
||||||
|
|
||||||
|
const roundPrice = (value: number) => {
|
||||||
|
return Number.isFinite(value) ? Number(value.toFixed(PRICE_PRECISION)) : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const multiplyPrice = (quantity?: number, price?: number) => {
|
||||||
|
if (!quantity || price === undefined || price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(Number(quantity) * Number(price))
|
||||||
|
}
|
||||||
|
|
||||||
|
const dividePrice = (totalPrice?: number, quantity?: number) => {
|
||||||
|
if (totalPrice === undefined || totalPrice === null || !quantity) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return roundPrice(Number(totalPrice) / Number(quantity))
|
||||||
|
}
|
||||||
|
|
||||||
/** 添加商品 */
|
/** 添加商品 */
|
||||||
const handleAddDetail = () => {
|
const handleAddDetail = () => {
|
||||||
skuSelectRef.value?.open(getSelectedSkuIds())
|
skuSelectRef.value?.open(getSelectedSkuIds())
|
||||||
|
|
@ -309,7 +333,6 @@ const handleSelectSku = (skus: ItemSkuVO[]) => {
|
||||||
formData.value.details!.push(buildDetail(sku))
|
formData.value.details!.push(buildDetail(sku))
|
||||||
selectedSkuIds.add(sku.id)
|
selectedSkuIds.add(sku.id)
|
||||||
})
|
})
|
||||||
refreshTotalAmount()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获得已选 SKU 编号 */
|
/** 获得已选 SKU 编号 */
|
||||||
|
|
@ -322,18 +345,44 @@ const getSelectedSkuIds = () => {
|
||||||
/** 删除明细 */
|
/** 删除明细 */
|
||||||
const handleDeleteDetail = (index: number) => {
|
const handleDeleteDetail = (index: number) => {
|
||||||
formData.value.details?.splice(index, 1)
|
formData.value.details?.splice(index, 1)
|
||||||
refreshTotalAmount()
|
}
|
||||||
|
|
||||||
|
/** 明细数量变化 */
|
||||||
|
const handleDetailQuantityChange = (detail: ReceiptOrderDetailVO) => {
|
||||||
|
if (detail.price !== undefined && detail.price !== null) {
|
||||||
|
detail.totalPrice = multiplyPrice(detail.quantity, detail.price)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 明细单价变化 */
|
||||||
|
const handleDetailPriceChange = (detail: ReceiptOrderDetailVO) => {
|
||||||
|
detail.totalPrice = multiplyPrice(detail.quantity, detail.price)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 明细金额变化 */
|
/** 明细金额变化 */
|
||||||
const handleDetailAmountChange = () => {
|
const handleDetailTotalPriceChange = (detail: ReceiptOrderDetailVO) => {
|
||||||
refreshTotalAmount()
|
detail.price = dividePrice(detail.totalPrice, detail.quantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 汇总明细金额 */
|
/** 明细合计 */
|
||||||
const refreshTotalAmount = () => {
|
const getDetailSummaries = ({ columns, data }: { columns: any[]; data: ReceiptOrderDetailVO[] }) =>
|
||||||
formData.value.totalAmount = detailTotalAmount.value
|
columns.map((column, index) => {
|
||||||
}
|
if (index === 0) {
|
||||||
|
return '合计'
|
||||||
|
}
|
||||||
|
if (column.property === 'quantity') {
|
||||||
|
return formatSumQuantity(data, (detail) => detail.quantity)
|
||||||
|
}
|
||||||
|
if (column.property === 'price') {
|
||||||
|
return formatPrice(detailPriceSum.value)
|
||||||
|
}
|
||||||
|
if (column.property === 'totalPrice') {
|
||||||
|
return formatSumPrice(data, (detail) => detail.totalPrice)
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
})
|
||||||
|
|
||||||
/** 校验明细 */
|
/** 校验明细 */
|
||||||
const validateDetails = (required: boolean) => {
|
const validateDetails = (required: boolean) => {
|
||||||
|
|
@ -359,13 +408,13 @@ const validateDetails = (required: boolean) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 构建提交数据 */
|
/** 构建提交数据 */
|
||||||
const buildSubmitData = () =>
|
const buildSubmitData = () => {
|
||||||
({
|
const { totalQuantity: _totalQuantity, totalPrice: _totalPrice, details, ...order } = formData.value
|
||||||
...formData.value,
|
return {
|
||||||
totalQuantity: totalQuantity.value,
|
...order,
|
||||||
totalAmount: formData.value.totalAmount,
|
details: (details || []).map(({ totalPrice: _rowTotalPrice, ...detail }) => detail)
|
||||||
details: formData.value.details || []
|
} as ReceiptOrderVO
|
||||||
}) as ReceiptOrderVO
|
}
|
||||||
|
|
||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
|
@ -443,8 +492,6 @@ const resetForm = () => {
|
||||||
bizOrderNo: undefined,
|
bizOrderNo: undefined,
|
||||||
merchantId: undefined,
|
merchantId: undefined,
|
||||||
warehouseId: undefined,
|
warehouseId: undefined,
|
||||||
totalQuantity: 0,
|
|
||||||
totalAmount: 0,
|
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
details: []
|
details: []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
<div>供应商:{{ printData.merchantName || '-' }}</div>
|
<div>供应商:{{ printData.merchantName || '-' }}</div>
|
||||||
<div>业务单号:{{ printData.bizOrderNo || '-' }}</div>
|
<div>业务单号:{{ printData.bizOrderNo || '-' }}</div>
|
||||||
<div>总数量:{{ formatQuantity(printData.totalQuantity) || '-' }}</div>
|
<div>总数量:{{ formatQuantity(printData.totalQuantity) || '-' }}</div>
|
||||||
<div>总金额:{{ formatPrice(printData.totalAmount) || '-' }}</div>
|
<div>总金额:{{ formatPrice(printData.totalPrice) || '-' }}</div>
|
||||||
<div>创建时间:{{ formatNullableDate(printData.createTime) }}</div>
|
<div>创建时间:{{ formatNullableDate(printData.createTime) }}</div>
|
||||||
<div class="col-span-3">备注:{{ printData.remark || '-' }}</div>
|
<div class="col-span-3">备注:{{ printData.remark || '-' }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -25,11 +25,12 @@
|
||||||
<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>
|
<th class="border border-solid border-#dcdfe6 bg-#f5f7fa p-8px text-left">金额(元)</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="detail in printData.details || []" :key="detail.id">
|
<tr v-for="detail in printRows" :key="detail.id">
|
||||||
<td class="border border-solid border-#dcdfe6 p-8px">
|
<td class="border border-solid border-#dcdfe6 p-8px">
|
||||||
<div>{{ detail.itemName || '-' }}</div>
|
<div>{{ detail.itemName || '-' }}</div>
|
||||||
<div v-if="detail.itemCode" class="text-12px">编号:{{ detail.itemCode }}</div>
|
<div v-if="detail.itemCode" class="text-12px">编号:{{ detail.itemCode }}</div>
|
||||||
|
|
@ -42,10 +43,25 @@
|
||||||
{{ formatQuantity(detail.quantity) || '-' }}
|
{{ formatQuantity(detail.quantity) || '-' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
{{ formatPrice(detail.amount) || '-' }}
|
{{ formatPrice(detail.price) || '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-solid border-#dcdfe6 p-8px text-right">
|
||||||
|
{{ formatPrice(detail.totalPrice) || '-' }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="!printData.details?.length">
|
<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">
|
||||||
|
{{ formatSumPrice(printRows, (detail) => detail.totalPrice) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-if="!printRows.length">
|
||||||
<td
|
<td
|
||||||
class="border border-solid border-#dcdfe6 p-8px text-center"
|
class="border border-solid border-#dcdfe6 p-8px text-center"
|
||||||
:colspan="tableColumnCount"
|
:colspan="tableColumnCount"
|
||||||
|
|
@ -63,14 +79,15 @@
|
||||||
import { formatNullableDate } from '@/utils/formatTime'
|
import { formatNullableDate } from '@/utils/formatTime'
|
||||||
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
||||||
import { ReceiptOrderApi, ReceiptOrderVO } from '@/api/wms/order/receipt'
|
import { ReceiptOrderApi, ReceiptOrderVO } from '@/api/wms/order/receipt'
|
||||||
import { formatPrice, formatQuantity } from '@/views/wms/utils/format'
|
import { ReceiptOrderDetailVO } from '@/api/wms/order/receipt/detail'
|
||||||
|
import { formatPrice, formatQuantity, formatSumPrice, formatSumQuantity } from '@/views/wms/utils/format'
|
||||||
|
|
||||||
/** WMS 入库单打印 */
|
/** WMS 入库单打印 */
|
||||||
defineOptions({ name: 'WmsReceiptOrderPrint' })
|
defineOptions({ name: 'WmsReceiptOrderPrint' })
|
||||||
|
|
||||||
const printData = ref<ReceiptOrderVO>({}) // 打印数据
|
const printData = ref<ReceiptOrderVO>({}) // 打印数据
|
||||||
const printButtonRef = ref<HTMLButtonElement>() // 打印按钮
|
const printButtonRef = ref<HTMLButtonElement>() // 打印按钮
|
||||||
const tableColumnCount = 4
|
const tableColumnCount = 5
|
||||||
const printObj = ref({
|
const printObj = ref({
|
||||||
id: 'wmsReceiptOrderPrint',
|
id: 'wmsReceiptOrderPrint',
|
||||||
popTitle: ' ',
|
popTitle: ' ',
|
||||||
|
|
@ -79,6 +96,20 @@ const printObj = ref({
|
||||||
zIndex: 20003
|
zIndex: 20003
|
||||||
})
|
})
|
||||||
|
|
||||||
|
interface PrintRow extends ReceiptOrderDetailVO {
|
||||||
|
totalPrice?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const printRows = computed<PrintRow[]>(() =>
|
||||||
|
(printData.value.details || []).map((detail) => ({
|
||||||
|
...detail,
|
||||||
|
totalPrice:
|
||||||
|
detail.price != null && detail.quantity
|
||||||
|
? Number((Number(detail.price) * Number(detail.quantity)).toFixed(2))
|
||||||
|
: undefined
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
|
||||||
/** 打印入库单 */
|
/** 打印入库单 */
|
||||||
const print = async (id: number) => {
|
const print = async (id: number) => {
|
||||||
printData.value = await ReceiptOrderApi.getReceiptOrder(id)
|
printData.value = await ReceiptOrderApi.getReceiptOrder(id)
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,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"
|
||||||
|
|
@ -92,7 +92,7 @@
|
||||||
/>
|
/>
|
||||||
<span>至</span>
|
<span>至</span>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="queryParams.totalAmountMax"
|
v-model="queryParams.totalPriceMax"
|
||||||
:controls="false"
|
:controls="false"
|
||||||
:min="0"
|
:min="0"
|
||||||
:precision="PRICE_PRECISION"
|
:precision="PRICE_PRECISION"
|
||||||
|
|
@ -242,9 +242,14 @@
|
||||||
{{ formatQuantity(detailScope.row.quantity) }}
|
{{ formatQuantity(detailScope.row.quantity) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="right" label="单价(元)" width="120">
|
||||||
|
<template #default="detailScope">
|
||||||
|
{{ formatPrice(detailScope.row.price) || '-' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column align="right" label="金额(元)" width="120">
|
<el-table-column align="right" label="金额(元)" width="120">
|
||||||
<template #default="detailScope">
|
<template #default="detailScope">
|
||||||
{{ formatPrice(detailScope.row.amount) || '-' }}
|
{{ formatPrice(getDetailTotalPrice(detailScope.row)) || '-' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -305,7 +310,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<span>金额:</span>
|
<span>金额:</span>
|
||||||
<span>{{ formatPrice(scope.row.totalAmount) }}</span>
|
<span>{{ formatPrice(scope.row.totalPrice) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -460,8 +465,8 @@ 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,
|
||||||
type: undefined as number | undefined,
|
type: undefined as number | undefined,
|
||||||
bizOrderNo: undefined as string | undefined,
|
bizOrderNo: undefined as string | undefined,
|
||||||
creator: undefined as number | undefined,
|
creator: undefined as number | undefined,
|
||||||
|
|
@ -532,6 +537,14 @@ const handleWarehouseChange = () => {
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 计算明细金额 */
|
||||||
|
const getDetailTotalPrice = (detail: ReceiptOrderDetailVO) => {
|
||||||
|
if (!detail.quantity || detail.price === undefined || detail.price === null) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
return Number(detail.quantity) * Number(detail.price)
|
||||||
|
}
|
||||||
|
|
||||||
/** 展开明细 */
|
/** 展开明细 */
|
||||||
const handleExpandChange = async (row: ReceiptOrderVO) => {
|
const handleExpandChange = async (row: ReceiptOrderVO) => {
|
||||||
if (!row.id || detailMap[row.id]) {
|
if (!row.id || detailMap[row.id]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue