gaoluyang
昨天 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
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
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmTransactionApi } from '#/api/mes/wm/transaction';
 
import { Page } from '@vben/common-ui';
 
import { Tag } from 'ant-design-vue';
 
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getTransactionPage } from '#/api/mes/wm/transaction';
 
import { useGridColumns, useGridFormSchema } from './data';
 
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>
    <Grid table-title="库存事务流水">
      <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>