|
{{ detail.itemName || '-' }}
编号:{{ detail.itemCode }}
@@ -42,10 +43,25 @@
{{ formatQuantity(detail.quantity) || '-' }}
|
- {{ formatPrice(detail.amount) || '-' }}
+ {{ formatPrice(detail.price) || '-' }}
+ |
+
+ {{ formatPrice(detail.totalPrice) || '-' }}
|
-
+ | 合计 |
+
+ {{ formatSumQuantity(printRows, (detail) => detail.quantity) }}
+ |
+
+ {{ formatSumPrice(printRows, (detail) => detail.price) }}
+ |
+
+ {{ formatSumPrice(printRows, (detail) => detail.totalPrice) }}
+ |
+
+
| ({}) // 打印数据
const printButtonRef = ref() // 打印按钮
-const tableColumnCount = 4
+const tableColumnCount = 5
const printObj = ref({
id: 'wmsShipmentOrderPrint',
popTitle: ' ',
@@ -79,6 +96,20 @@ const printObj = ref({
zIndex: 20003
})
+interface PrintRow extends ShipmentOrderDetailVO {
+ totalPrice?: number
+}
+
+const printRows = computed(() =>
+ (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) => {
printData.value = await ShipmentOrderApi.getShipmentOrder(id)
diff --git a/src/views/wms/order/shipment/index.vue b/src/views/wms/order/shipment/index.vue
index 74a88ed0c..1b4af26f4 100644
--- a/src/views/wms/order/shipment/index.vue
+++ b/src/views/wms/order/shipment/index.vue
@@ -80,10 +80,10 @@
/>
-
+
至
+
+
+ {{ formatPrice(detailScope.row.price) || '-' }}
+
+
- {{ formatPrice(detailScope.row.amount) || '-' }}
+ {{ formatPrice(getDetailTotalPrice(detailScope.row)) || '-' }}
@@ -305,7 +310,7 @@
金额:
- {{ formatPrice(scope.row.totalAmount) }}
+ {{ formatPrice(scope.row.totalPrice) }}
@@ -460,8 +465,8 @@ const getDefaultQueryParams = () => ({
orderTime: undefined as string[] | undefined,
totalQuantityMin: undefined as number | undefined,
totalQuantityMax: undefined as number | undefined,
- totalAmountMin: undefined as number | undefined,
- totalAmountMax: undefined as number | undefined,
+ totalPriceMin: undefined as number | undefined,
+ totalPriceMax: undefined as number | undefined,
type: undefined as number | undefined,
bizOrderNo: undefined as string | undefined,
creator: undefined as number | undefined,
@@ -532,6 +537,14 @@ const handleWarehouseChange = () => {
handleQuery()
}
+/** 计算明细金额 */
+const getDetailTotalPrice = (detail: ShipmentOrderDetailVO) => {
+ if (!detail.quantity || detail.price === undefined || detail.price === null) {
+ return undefined
+ }
+ return Number(detail.quantity) * Number(detail.price)
+}
+
/** 展开明细 */
const handleExpandChange = async (row: ShipmentOrderVO) => {
if (!row.id || detailMap[row.id]) {
diff --git a/src/views/wms/utils/format.ts b/src/views/wms/utils/format.ts
index 4f2a3b338..b5dd5d780 100644
--- a/src/views/wms/utils/format.ts
+++ b/src/views/wms/utils/format.ts
@@ -48,6 +48,27 @@ export const formatPrice = (value?: number | string | null) => {
return decimalValue === undefined ? '' : decimalValue.toFixed(PRICE_PRECISION)
}
+/** 金额四舍五入 */
+export const roundPrice = (value: number) => {
+ return Number.isFinite(value) ? Number(value.toFixed(PRICE_PRECISION)) : undefined
+}
+
+/** 数量 * 单价,计算金额 */
+export const multiplyPrice = (quantity?: number, price?: number) => {
+ if (!quantity || price === undefined || price === null) {
+ return undefined
+ }
+ return roundPrice(Number(quantity) * Number(price))
+}
+
+/** 金额 / 数量,反算单价 */
+export const dividePrice = (totalPrice?: number, quantity?: number) => {
+ if (totalPrice === undefined || totalPrice === null || !quantity) {
+ return undefined
+ }
+ return roundPrice(Number(totalPrice) / Number(quantity))
+}
+
/** 汇总数量 */
export const sumQuantity = (list: T[], getter: (item: T) => DecimalValue) => {
return sumDecimal(list, getter)
|