修复:
生产领料后的退料应该是选择领料的记录,不是选择库存的记录(同时库存数据需要根据领料退料变动,比如库存100,领用80,然后领用80中退料30,库存应由原来的20变成50)
| | |
| | | { params: { issueId } }, |
| | | ); |
| | | } |
| | | |
| | | /** 查询可退料的领料单行列表(按生产订单过滤,仅返回已完成领料的记录) */ |
| | | export function getReturnableIssueLines(workOrderId: number) { |
| | | return requestClient.get<MesWmProductIssueLineApi.ProductIssueLine[]>( |
| | | '/mes/wm/product-issue-line/returnable-list', |
| | | { params: { workOrderId } }, |
| | | ); |
| | | } |
| | |
| | | export interface ReturnIssueLine { |
| | | id?: number; // 行编号 |
| | | issueId?: number; // 退料单编号 |
| | | issueLineId?: number; // 领料单行编号(关联来源领料记录) |
| | | itemId?: number; // 物料编号 |
| | | itemCode?: string; // 物料编码 |
| | | itemName?: string; // 物料名称 |
| | |
| | | import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock'; |
| | | import type { MesWmProductIssueLineApi } from '#/api/mes/wm/productissue/line'; |
| | | import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue'; |
| | | import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail'; |
| | | import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line'; |
| | |
| | | import { generateAutoCode } from '#/api/mes/md/autocode/record'; |
| | | import { MdWorkstationSelect } from '#/views/mes/md/workstation/components'; |
| | | import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components'; |
| | | import { WmProductIssueLineSelect } from '#/views/wls/productissue/components'; |
| | | import { WmMaterialStockSelect } from '#/views/wls/materialstock/components'; |
| | | import { |
| | | WmWarehouseAreaSelect, |
| | |
| | | } |
| | | |
| | | /** 退料单行新增/修改的表单 */ |
| | | export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { |
| | | export function useLineFormSchema( |
| | | formApi?: VbenFormApi, |
| | | workOrderId?: number, |
| | | ): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'materialStockId', |
| | | label: '库存记录', |
| | | component: markRaw(WmMaterialStockSelect), |
| | | fieldName: 'issueLineId', |
| | | label: '领料记录', |
| | | component: markRaw(WmProductIssueLineSelect), |
| | | componentProps: { |
| | | // 选择库存记录后,自动回填物料/批次/数量 |
| | | onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => { |
| | | workOrderId, |
| | | onChange: async (line?: MesWmProductIssueLineApi.ProductIssueLine) => { |
| | | await formApi?.setValues({ |
| | | batchCode: stock?.batchCode, |
| | | batchId: stock?.batchId, |
| | | itemId: stock?.itemId, |
| | | materialDisplayName: stock |
| | | ? [stock.itemName, stock.specification].filter(Boolean).join(' | ') |
| | | batchCode: line?.batchCode, |
| | | batchId: line?.batchId, |
| | | itemId: line?.itemId, |
| | | materialDisplayName: line |
| | | ? [line.itemName, line.specification].filter(Boolean).join(' | ') |
| | | : undefined, |
| | | quantity: stock?.quantity, |
| | | quantityMax: stock?.quantity, |
| | | quantity: line?.quantity, |
| | | quantityMax: line?.quantity, |
| | | }); |
| | | }, |
| | | virtualFilter: 'only', |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | placeholder: '选择库存后自动带出', |
| | | placeholder: '选择领料记录后自动带出', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: true, |
| | | placeholder: '选择库存后自动带出', |
| | | placeholder: '选择领料记录后自动带出', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | <template v-if="formData?.id"> |
| | | <Divider>物料信息</Divider> |
| | | <div class="mx-4"> |
| | | <LineList :form-type="formType" :issue-id="formData.id" /> |
| | | <LineList :form-type="formType" :issue-id="formData.id" :work-order-id="formData.workOrderId" /> |
| | | </div> |
| | | </template> |
| | | <template #prepend-footer> |
| | |
| | | |
| | | const emit = defineEmits(['success']); |
| | | const formData = ref<MesWmReturnIssueLineApi.ReturnIssueLine>(); |
| | | const issueId = ref<number>(); // 所属退料单编号 |
| | | const issueId = ref<number>(); |
| | | const workOrderId = ref<number>(); |
| | | |
| | | const getTitle = computed(() => { |
| | | return formData.value?.id |
| | |
| | | formData.value = undefined; |
| | | return; |
| | | } |
| | | formApi.setState({ schema: useLineFormSchema(formApi) }); |
| | | // 加载数据 |
| | | const data = modalApi.getData<{ id?: number; issueId: number }>(); |
| | | const data = modalApi.getData<{ id?: number; issueId: number; workOrderId?: number }>(); |
| | | issueId.value = data.issueId; |
| | | workOrderId.value = data.workOrderId; |
| | | formApi.setState({ schema: useLineFormSchema(formApi, workOrderId.value) }); |
| | | if (!data.id) { |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | | try { |
| | | formData.value = await getReturnIssueLine(data.id); |
| | | // 设置到 values,并构建物料展示名 |
| | | await formApi.setValues({ |
| | | ...formData.value, |
| | | materialDisplayName: [formData.value.itemName, formData.value.specification] |
| | |
| | | const props = defineProps<{ |
| | | formType: FormType; |
| | | issueId: number; |
| | | workOrderId?: number; |
| | | }>(); |
| | | |
| | | const isEditable = computed(() => |
| | |
| | | |
| | | /** 添加物料 */ |
| | | function handleCreate() { |
| | | lineFormModalApi.setData({ issueId: props.issueId }).open(); |
| | | lineFormModalApi.setData({ issueId: props.issueId, workOrderId: props.workOrderId }).open(); |
| | | } |
| | | |
| | | /** 编辑物料 */ |
| | | function handleEdit(row: MesWmReturnIssueLineApi.ReturnIssueLine) { |
| | | lineFormModalApi.setData({ id: row.id, issueId: props.issueId }).open(); |
| | | lineFormModalApi.setData({ id: row.id, issueId: props.issueId, workOrderId: props.workOrderId }).open(); |
| | | } |
| | | |
| | | /** 删除物料 */ |