云
8 天以前 c86b74b36c264da2acaae22aeb3ba08bb25562c0
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
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmTransactionApi } from '#/api/mes/wm/transaction';
 
import { Page, useVbenModal } from '@vben/common-ui';
 
import { Button, Tag } from 'ant-design-vue';
 
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getTransactionPage } from '#/api/mes/wm/transaction';
 
import QrTraceModal from '#/views/mes/pro/components/qr-trace-modal.vue';
 
import { useGridColumns, useGridFormSchema } from './data';
 
const [QrTraceQueryModal, qrTraceQueryModalApi] = useVbenModal({
  connectedComponent: QrTraceModal,
  destroyOnClose: true,
});
 
function handleBatchClick(row: MesWmTransactionApi.Transaction) {
  if (!row.batchCode) {
    return;
  }
  qrTraceQueryModalApi.setData({ code: row.batchCode }).open();
}
 
const [Grid, gridApi] = useVbenVxeGrid({
  formOptions: {
    schema: useGridFormSchema(),
  },
  gridOptions: {
    columns: useGridColumns(),
    height: 'auto',
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          const params: MesWmTransactionApi.PageParams = {
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            ...formValues,
          };
          if (formValues.transactionTime?.length === 2) {
            params.startTime = formValues.transactionTime[0];
            params.endTime = formValues.transactionTime[1];
          }
          delete (params as any).transactionTime;
          return await getTransactionPage(params);
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<MesWmTransactionApi.Transaction>,
});
</script>
 
<template>
  <Page auto-content-height>
    <QrTraceQueryModal />
    <Grid table-title="库存事务流水">
      <template #batchCode="{ row }">
        <Button
          v-if="row.batchCode"
          type="link"
          class="!px-0"
          @click="handleBatchClick(row)"
        >
          {{ row.batchCode }}
        </Button>
        <span v-else>-</span>
      </template>
      <template #typeName="{ row }">
        <Tag :color="row.type === 1 ? 'green' : 'red'">
          {{ row.typeName || '-' }}
        </Tag>
      </template>
      <template #quantity="{ row }">
        <span
          :class="{
            'text-green-600 font-bold': (row.quantity ?? 0) > 0,
            'text-red-600 font-bold': (row.quantity ?? 0) < 0,
          }"
        >
          {{ (row.quantity ?? 0).toFixed(2) }}
        </span>
      </template>
    </Grid>
  </Page>
</template>