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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmItemReceiptApi } from '#/api/mes/wm/itemreceipt';
import type { MesWmItemReceiptLineApi } from '#/api/mes/wm/itemreceipt/line';
 
import { nextTick, ref } from 'vue';
 
import { useVbenModal } from '../../../../../packages/effects/common-ui/src';
import { formatDateTime } from '../../../../../packages/utils/src';
 
import { Descriptions, Spin } from 'ant-design-vue';
 
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getItemReceipt } from '#/api/mes/wm/itemreceipt';
import { getItemReceiptLinePage } from '#/api/mes/wm/itemreceipt/line';
 
const loading = ref(false); // 详情加载状态
const receiptId = ref<number>(); // 当前采购入库单编号
const receipt = ref<MesWmItemReceiptApi.ItemReceipt>(); // 当前采购入库单详情
 
/** 格式化空值 */
function formatEmpty(value: null | number | string | undefined) {
  return value ?? '-';
}
 
/** 格式化日期 */
function formatDate(value: Date | number | string | undefined) {
  return value ? (formatDateTime(value) as string) : '-';
}
 
const [Grid, gridApi] = useVbenVxeGrid({
  gridOptions: {
    columns: [
      {
        field: 'itemCode',
        title: '物料编码',
        width: 140,
      },
      {
        field: 'itemName',
        title: '物料名称',
        minWidth: 150,
      },
      {
        field: 'specification',
        title: '规格型号',
        minWidth: 140,
      },
      {
        field: 'unitMeasureName',
        title: '单位',
        width: 100,
      },
      {
        field: 'receivedQuantity',
        title: '入库数量',
        width: 120,
      },
      {
        field: 'batchCode',
        title: '批次号',
        minWidth: 140,
      },
    ],
    height: 280,
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }) => {
          if (!receiptId.value) {
            return { list: [], total: 0 };
          }
          return await getItemReceiptLinePage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            receiptId: receiptId.value,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
    },
  } as VxeTableGridOptions<MesWmItemReceiptLineApi.ItemReceiptLine>,
});
 
const [Modal, modalApi] = useVbenModal({
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      receiptId.value = undefined;
      receipt.value = undefined;
      return;
    }
    const data = modalApi.getData<{ id?: number }>();
    if (!data?.id) {
      return;
    }
    receiptId.value = data.id;
    loading.value = true;
    modalApi.lock();
    try {
      receipt.value = await getItemReceipt(data.id);
      await nextTick();
      await gridApi.query();
    } finally {
      loading.value = false;
      modalApi.unlock();
    }
  },
});
</script>
 
<template>
  <Modal
    title="采购入库单详情"
    class="w-[900px]"
    :show-cancel-button="false"
    :show-confirm-button="false"
  >
    <Spin :spinning="loading">
      <Descriptions bordered size="small" :column="3">
        <Descriptions.Item label="入库单编号">
          {{ formatEmpty(receipt?.code) }}
        </Descriptions.Item>
        <Descriptions.Item label="入库单名称">
          {{ formatEmpty(receipt?.name) }}
        </Descriptions.Item>
        <Descriptions.Item label="入库日期">
          {{ formatDate(receipt?.receiptDate) }}
        </Descriptions.Item>
        <Descriptions.Item label="到货通知单">
          {{ formatEmpty(receipt?.noticeCode) }}
        </Descriptions.Item>
        <Descriptions.Item label="供应商">
          {{ formatEmpty(receipt?.vendorName) }}
        </Descriptions.Item>
        <Descriptions.Item label="采购订单号">
          {{ formatEmpty(receipt?.purchaseOrderCode) }}
        </Descriptions.Item>
        <Descriptions.Item label="仓库">
          {{ formatEmpty(receipt?.warehouseName) }}
        </Descriptions.Item>
        <Descriptions.Item label="库区">
          {{ formatEmpty(receipt?.locationName) }}
        </Descriptions.Item>
        <Descriptions.Item label="库位">
          {{ formatEmpty(receipt?.areaName) }}
        </Descriptions.Item>
        <Descriptions.Item label="备注" :span="3">
          {{ formatEmpty(receipt?.remark) }}
        </Descriptions.Item>
      </Descriptions>
      <div class="mt-4">
        <Grid table-title="入库物料" />
      </div>
    </Spin>
  </Modal>
</template>