| | |
| | | import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail'; |
| | | import type { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/line'; |
| | | |
| | | import type { TraceResult } from '#/utils/traceLookup'; |
| | | |
| | | import { computed, reactive } from 'vue'; |
| | | |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getReturnSalesDetailListByLineId } from '#/api/mes/wm/returnsales/detail'; |
| | | import { getBatchPage } from '#/api/mes/wm/batch'; |
| | | import { getReturnableProductSalesLineList } from '#/api/mes/wm/returnsales'; |
| | | import { |
| | | deleteReturnSalesLine, |
| | | getReturnSalesLinePage, |
| | | } from '#/api/mes/wm/returnsales/line'; |
| | | import TraceScanPanel from '#/components/TraceScanPanel.vue'; |
| | | import { $t } from '#/locales'; |
| | | import { traceQuantity } from '#/utils/traceLookup'; |
| | | import { PrinterLabel } from '#/views/wls/barcode/components'; |
| | | |
| | | import { useLineGridColumns } from '../data'; |
| | |
| | | returnId: props.returnId, |
| | | }) |
| | | .open(); |
| | | } |
| | | |
| | | /** 扫码带出:关联出库单时匹配可退出库行,否则按批次带出物料与数量 */ |
| | | async function handleTraceConfirm(trace: TraceResult) { |
| | | const { batchCode, itemId } = trace.data; |
| | | if (!itemId || !batchCode) { |
| | | message.warning('该追溯码未绑定物料或批次'); |
| | | return; |
| | | } |
| | | try { |
| | | if (props.productSalesId) { |
| | | const lines = await getReturnableProductSalesLineList( |
| | | props.productSalesId, |
| | | ); |
| | | const matched = lines.find( |
| | | (line) => line.itemId === itemId && line.batchCode === batchCode, |
| | | ); |
| | | if (!matched) { |
| | | message.warning('该追溯码对应的批次不在本单可退范围内'); |
| | | return; |
| | | } |
| | | const returnable = Number(matched.returnableQuantity ?? 0); |
| | | const quantity = Math.min(traceQuantity(trace) ?? returnable, returnable); |
| | | lineFormModalApi |
| | | .setData({ |
| | | clientId: props.clientId, |
| | | defaults: { |
| | | batchCode: matched.batchCode, |
| | | itemId: matched.itemId, |
| | | productSalesLineId: matched.productSalesLineId, |
| | | quantity, |
| | | returnableQuantity: returnable, |
| | | }, |
| | | productSalesId: props.productSalesId, |
| | | returnId: props.returnId, |
| | | }) |
| | | .open(); |
| | | return; |
| | | } |
| | | const batches = await getBatchPage({ |
| | | code: batchCode, |
| | | itemId, |
| | | pageNo: 1, |
| | | pageSize: 20, |
| | | }); |
| | | const batch = batches.list.find((item) => item.code === batchCode); |
| | | if (!batch?.id) { |
| | | message.warning('未找到该追溯码对应的入库批次'); |
| | | return; |
| | | } |
| | | lineFormModalApi |
| | | .setData({ |
| | | clientId: props.clientId, |
| | | defaults: { |
| | | batchCode, |
| | | batchId: batch.id, |
| | | itemId, |
| | | quantity: traceQuantity(trace), |
| | | }, |
| | | productSalesId: props.productSalesId, |
| | | returnId: props.returnId, |
| | | }) |
| | | .open(); |
| | | } catch (e) { |
| | | message.error(e instanceof Error ? e.message : '扫码带出失败'); |
| | | } |
| | | } |
| | | |
| | | /** 编辑物料 */ |
| | |
| | | <div> |
| | | <LineFormModal @success="handleRefresh" /> |
| | | <DetailFormModal @success="handleDetailSuccess" /> |
| | | <TraceScanPanel |
| | | v-if="isEditable" |
| | | title="扫码带出退货明细" |
| | | @confirm="handleTraceConfirm" |
| | | /> |
| | | <Grid table-title="物料信息"> |
| | | <template v-if="isEditable" #toolbar-tools> |
| | | <TableAction |