| | |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc'; |
| | | |
| | | import { ref } from 'vue'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { MesQcStatusEnum } from '@vben/constants'; |
| | | import { MesQcStatusEnum, MesQcTypeEnum } from '@vben/constants'; |
| | | import { downloadFileFromBlobPart } from '@vben/utils'; |
| | | |
| | | import { Button, message } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { deleteIpqc, exportIpqc, getIpqcPage } from '#/api/mes/qc/ipqc'; |
| | | import { exportProductWord } from '#/api/mes/qc/indicatorresult'; |
| | | import { |
| | | deleteIpqc, |
| | | exportIpqc, |
| | | getIpqcPage, |
| | | importIpqc, |
| | | importIpqcTemplate, |
| | | } from '#/api/mes/qc/ipqc'; |
| | | import { $t } from '#/locales'; |
| | | import QcExportRangeModal from '#/views/mes/qc/components/export-range-modal.vue'; |
| | | import QcImportFormModal from '#/views/mes/qc/components/import-form-modal.vue'; |
| | | import QcReportPrint from '#/views/mes/qc/components/qc-report-print.vue'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const printRef = ref<InstanceType<typeof QcReportPrint> | null>(null); |
| | | |
| | | const [ImportModal, importModalApi] = useVbenModal({ |
| | | connectedComponent: QcImportFormModal, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** 打印检验报告 */ |
| | | async function handlePrint(row: MesQcIpqcApi.Ipqc) { |
| | | await printRef.value?.print(row.id!, MesQcTypeEnum.IPQC); |
| | | } |
| | | |
| | | /** 导出产品检验单 Word(纸质检验单版式,判定结论带出检验结果) */ |
| | | async function handleExportProductWord(row: MesQcIpqcApi.Ipqc) { |
| | | const blob = await exportProductWord(row.id!, MesQcTypeEnum.IPQC); |
| | | downloadFileFromBlobPart({ |
| | | fileName: `产品检验单-${row.code ?? row.id}.docx`, |
| | | source: blob, |
| | | }); |
| | | } |
| | | |
| | | /** 批量导入过程检验单 */ |
| | | function handleImport() { |
| | | importModalApi |
| | | .setData({ |
| | | title: '批量导入过程检验单', |
| | | templateApi: importIpqcTemplate, |
| | | importApi: importIpqc, |
| | | fileName: '过程检验单导入模板.xls', |
| | | hints: [ |
| | | '仅允许导入 xls、xlsx 格式文件;必填列:检验单名称、产品物料编码、批号、合格品数量、不合格品数量。', |
| | | '「产品物料编码」需与「物料管理」中的编码完全一致;「批号」为必填,不允许为空。', |
| | | '「检验类型」按字典名称填写(自制工序检验 / 首检 / 巡检 / 自检 / 成品检验);「检测结果」按字典名称填写(校验通过 / 校验不通过)。', |
| | | '合格品数量 + 不合格品数量 必须等于「检测数量」(留空时自动取两者之和);工废 + 料废 + 其他废品 之和不得超过不合格品数量。', |
| | | '「质检方案」填方案名称,留空则按物料自动匹配 IPQC 方案;「检测人员」留空取当前登录用户;「检测日期」可留空。', |
| | | '逐行导入,失败行不影响成功行;导入后的检验单为「待检验」状态,可在列表中继续编辑、录入检测结果。', |
| | | ], |
| | | }) |
| | | .open(); |
| | | } |
| | | |
| | | /** 创建过程检验单 */ |
| | |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <ExportRangeModal /> |
| | | <QcReportPrint ref="printRef" /> |
| | | <ImportModal @success="handleRefresh" /> |
| | | <Grid table-title="过程检验单列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['mes:qc-ipqc:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: '批量导入', |
| | | type: 'primary', |
| | | icon: ACTION_ICON.UPLOAD, |
| | | auth: ['mes:qc-ipqc:import'], |
| | | onClick: handleImport, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.export'), |
| | |
| | | }, |
| | | }, |
| | | { |
| | | label: '打印报告', |
| | | type: 'link', |
| | | icon: 'ant-design:printer-outlined', |
| | | auth: ['mes:qc-ipqc:query'], |
| | | onClick: handlePrint.bind(null, row), |
| | | }, |
| | | { |
| | | label: '导出产品检验单', |
| | | type: 'link', |
| | | icon: 'ant-design:file-word-outlined', |
| | | auth: ['mes:qc-ipqc:query'], |
| | | onClick: handleExportProductWord.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.detail'), |
| | | type: 'link', |
| | | icon: ACTION_ICON.VIEW, |