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
<script lang="ts" setup>
import type { FormType } from '../data';
 
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesQcIpqcLineApi } from '#/api/mes/qc/ipqc/line';
 
import { useVbenModal } from '../../../../../packages/effects/common-ui/src';
import { MesQcTypeEnum } from '../../../../../packages/constants/src';
 
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getIpqcLinePage } from '#/api/mes/qc/ipqc/line';
 
import { DefectRecordInlineList } from '../../defectrecord/components';
import { useLineGridColumns } from '../data';
 
const props = defineProps<{
  formType?: FormType;
  ipqcId: number;
}>();
 
const emit = defineEmits<{ refresh: [] }>();
 
const [DefectModal, defectModalApi] = useVbenModal({
  connectedComponent: DefectRecordInlineList,
  destroyOnClose: true,
});
 
/** 刷新表格 */
function handleRefresh() {
  gridApi.query();
}
 
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
function handleDefectChanged() {
  handleRefresh();
  emit('refresh');
}
 
/** 打开缺陷记录弹窗 */
function handleOpenDefect(row: MesQcIpqcLineApi.IpqcLine) {
  defectModalApi
    .setData({
      formType: props.formType,
      lineId: row.id,
      qcId: props.ipqcId,
      qcType: MesQcTypeEnum.IPQC,
    })
    .open();
}
 
const [Grid, gridApi] = useVbenVxeGrid({
  gridOptions: {
    columns: useLineGridColumns(),
    height: 360,
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }) => {
          if (!props.ipqcId) {
            return { list: [], total: 0 };
          }
          return await getIpqcLinePage({
            ipqcId: props.ipqcId,
            pageNo: page.currentPage,
            pageSize: page.pageSize,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
    },
  } as VxeTableGridOptions<MesQcIpqcLineApi.IpqcLine>,
});
</script>
 
<template>
  <div>
    <DefectModal @success="handleDefectChanged" />
    <Grid table-title="检验项">
      <template #actions="{ row }">
        <TableAction
          :actions="[
            {
              label: '缺陷列表',
              type: 'link',
              icon: ACTION_ICON.VIEW,
              onClick: handleOpenDefect.bind(null, row),
            },
          ]"
        />
      </template>
    </Grid>
  </div>
</template>