| | |
| | | <script lang="ts" setup> |
| | | import { ref } from 'vue'; |
| | | import type { VxeTableGridOptions } from "#/adapter/vxe-table"; |
| | | import type { MesProBagCodeApi } from "#/api/mes/pro/bagCode"; |
| | | |
| | |
| | | unbindBagCodePallet, |
| | | } from "#/api/mes/pro/bagCode"; |
| | | import { IconifyIcon } from "@vben/icons"; |
| | | import { countQrExport, submitQrExport } from '#/api/mes/pro/qrExport'; |
| | | import { $t } from "#/locales"; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from "./data"; |
| | |
| | | import ReplaceModal from "./modules/replace-form.vue"; |
| | | import QrTraceModal from "../components/qr-trace-modal.vue"; |
| | | import BusinessQrModal from "../components/business-qr.vue"; |
| | | import QrExportTaskModal from '../components/qr-export-task-modal.vue'; |
| | | |
| | | defineOptions({ name: "MesProBagCode" }); |
| | | |
| | | const qrExportTaskModal = ref<InstanceType<typeof QrExportTaskModal>>(); |
| | | |
| | | const [GenerateFormModal, generateFormModalApi] = useVbenModal({ |
| | | connectedComponent: GenerateModal, |
| | |
| | | } |
| | | if (!params.uuid && !params.batchId) { |
| | | message.warning("请先按生成组或批次筛选后再导出二维码"); |
| | | return; |
| | | } |
| | | const bizType = kind === 'business' ? 'BAG_BUSINESS' : 'BAG_LABEL'; |
| | | const count = await countQrExport({ bizType, ...params }); |
| | | if (count.mode === 'ASYNC') { |
| | | const task = await submitQrExport({ bizType, ...params }); |
| | | qrExportTaskModal.value?.show(task); |
| | | message.success(`已提交 ${count.totalCount} 张二维码的后台导出任务`); |
| | | return; |
| | | } |
| | | const data = await (kind === 'business' ? exportBagBusinessQr : exportBagQr)(params); |
| | |
| | | function handleBindPallet() { |
| | | const records = getSelectedRecords(); |
| | | if (!records) return; |
| | | if (records.some((record) => !record.batchId)) { |
| | | message.warning("请先录入生产批次,再绑定托盘"); |
| | | return; |
| | | } |
| | | const batchIds = new Set(records.map((record) => record.batchId)); |
| | | if (batchIds.size > 1) { |
| | | message.warning("请选择同一批次下的袋码进行绑定"); |
| | | return; |
| | | } |
| | | if (records.some((record) => record.palletId)) { |
| | | message.warning("所选袋码中存在已绑定托盘的记录,请先解绑"); |
| | | return; |
| | |
| | | message.warning("已作废的袋码不允许绑定托盘"); |
| | | return; |
| | | } |
| | | const withBatch = records.filter((record) => record.batchId); |
| | | // 已录批次与未录批次混选时可选托盘范围不一致,要求分开操作 |
| | | if (withBatch.length > 0 && withBatch.length < records.length) { |
| | | message.warning("所选袋码部分已录入批次,请分开选择后再绑定托盘"); |
| | | return; |
| | | } |
| | | const first = records[0]!; |
| | | if (withBatch.length > 0) { |
| | | const batchIds = new Set(records.map((record) => record.batchId)); |
| | | if (batchIds.size > 1) { |
| | | message.warning("请选择同一批次下的袋码进行绑定"); |
| | | return; |
| | | } |
| | | } else { |
| | | const itemIds = new Set(records.map((record) => record.itemId)); |
| | | if (itemIds.size > 1) { |
| | | message.warning("请选择同一品种下的袋码进行绑定"); |
| | | return; |
| | | } |
| | | } |
| | | bindPalletFormModalApi |
| | | .setData({ |
| | | batchId: first.batchId, |
| | | batchCode: first.batchCode, |
| | | itemId: first.itemId, |
| | | ids: records.map((record) => record.id!), |
| | | }) |
| | | .open(); |
| | |
| | | <ReplaceFormModal @success="handleReplaceSuccess" /> |
| | | <QrTraceQueryModal /> |
| | | <BusinessQrViewModal /> |
| | | <QrExportTaskModal ref="qrExportTaskModal" /> |
| | | <Grid table-title="袋码列表(一袋一码)"> |
| | | <template #table-title><span class="text-[1rem] font-bold" style="white-space:nowrap">袋码列表(一袋一码)</span></template> |
| | | <template #toolbar-tools> |
| | |
| | | { label: 'Excel 数据包', auth: ['mes:pro-bag-code:export'], onClick: handleExport }]"> |
| | | <template #more><Button>导出 <IconifyIcon icon="lucide:chevron-down" /></Button></template> |
| | | </TableAction> |
| | | <Button @click="qrExportTaskModal?.showLast()">后台导出任务</Button> |
| | | <TableAction :dropdown-trigger="['click']" :drop-down-actions="[{ label: '生成原始袋码', auth: ['mes:pro-bag-code:create'], onClick: handleRawGenerate }, |
| | | { label: '补生成业务码', auth: ['mes:pro-bag-code:create'], onClick: handleGenerateBusinessCodes }, |
| | | { label: '破损替换', auth: ['mes:pro-bag-code:replace'], onClick: handleReplace }, |