zhangwencui
7 天以前 f35825c1922149df154e3913d6dfebee57ee8cee
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
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
 
import { watch } from 'vue';
 
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getBackwardBatchList, getForwardBatchList } from '#/api/mes/wm/batch';
 
import { useTraceGridColumns } from '../data';
 
const props = defineProps<{
  batchCode?: string;
  direction: 'backward' | 'forward'; // 追溯方向:forward=向前,backward=向后
}>();
 
const [Grid, gridApi] = useVbenVxeGrid({
  gridOptions: {
    columns: useTraceGridColumns(),
    minHeight: 240,
    pagerConfig: {
      enabled: false,
    },
    rowConfig: {
      isHover: true,
      keyField: 'id',
    },
    showOverflow: true,
    toolbarConfig: {
      enabled: false,
    },
  } as VxeTableGridOptions<MesWmBatchApi.Batch>,
});
 
/** 加载追溯列表 */
async function getList() {
  if (!props.batchCode) {
    await gridApi.grid?.loadData([]);
    return;
  }
  gridApi.setLoading(true);
  try {
    const list =
      props.direction === 'forward'
        ? await getForwardBatchList(props.batchCode)
        : await getBackwardBatchList(props.batchCode);
    await gridApi.grid?.loadData(list);
  } finally {
    gridApi.setLoading(false);
  }
}
 
watch(
  () => props.batchCode,
  () => {
    getList();
  },
  { immediate: true },
);
</script>
 
<template>
  <Grid class="w-full" />
</template>