gaoluyang
2026-06-29 27cd042df9aca0383a49f3514bc21958dd890912
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { WmsInventoryHistoryApi } from '#/api/wms/inventory/history';
 
import { Page } from '../../../../packages/effects/common-ui/src';
 
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getInventoryHistoryPage } from '#/api/wms/inventory/history';
import { formatPrice, formatQuantity } from '#/views/wms/utils/format';
 
import { useGridColumns, useGridFormSchema } from './data';
 
defineOptions({ name: 'WmsInventoryHistory' });
 
function hasValue(value: unknown) {
  return value !== undefined && value !== null;
}
 
const [Grid] = useVbenVxeGrid({
  formOptions: {
    schema: useGridFormSchema(),
  },
  gridOptions: {
    columns: useGridColumns(),
    height: 'auto',
    keepSource: true,
    showOverflow: false,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getInventoryHistoryPage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<WmsInventoryHistoryApi.InventoryHistory>,
});
</script>
 
<template>
  <Page auto-content-height><Grid table-title="库存流水">
      <template #itemInfo="{ row }">
        <div class="flex flex-col gap-1 py-1 leading-5">
          <div class="text-sm">{{ row.itemName || '-' }}</div>
          <div v-if="row.itemCode" class="break-all text-xs text-gray-500">
            商品编号:{{ row.itemCode }}
          </div>
        </div>
      </template>
      <template #skuInfo="{ row }">
        <div class="flex flex-col gap-1 py-1 leading-5">
          <div class="text-sm">{{ row.skuName || '-' }}</div>
          <div v-if="row.skuCode" class="break-all text-xs text-gray-500">
            规格编号:{{ row.skuCode }}
          </div>
        </div>
      </template>
      <template #beforeQuantity="{ row }">
        {{ formatQuantity(row.beforeQuantity) || '-' }}
      </template>
      <template #afterQuantity="{ row }">
        {{ formatQuantity(row.afterQuantity) || '-' }}
      </template>
      <template #quantityPrice="{ row }">
        <div class="flex flex-col gap-1 py-1 leading-5">
          <div class="flex justify-between gap-2">
            <span class="shrink-0">数量:</span>
            <span>{{ formatQuantity(row.quantity) }}</span>
          </div>
          <div v-if="hasValue(row.price)" class="flex justify-between gap-2">
            <span class="shrink-0">单价:</span>
            <span>{{ formatPrice(row.price) }}</span>
          </div>
          <div
            v-if="hasValue(row.totalPrice)"
            class="flex justify-between gap-2"
          >
            <span class="shrink-0">金额:</span>
            <span>{{ formatPrice(row.totalPrice) }}</span>
          </div>
        </div>
      </template>
    </Grid>
  </Page>
</template>