feat(wms): 实现库存选择和调拨任务管理功能

- 新增库存选择对话框,支持选择具体库存信息
- 添加调拨任务创建、编辑、删除功能
- 实现分包打印逻辑,支持单包和多包打印
- 优化子表格数据验证和提交流程
- 修复了一些现有的功能问题,如物料选择和表格更新
master
zangch@mesnac.com 5 months ago
parent 5ff2202546
commit 4d2905788f

@ -7,7 +7,7 @@
<el-form-item label="批次码" prop="batchCode">
<el-input v-model="queryParams.batchCode" placeholder="请输入批次码" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="仓库" prop="warehouseId">
<!-- <el-form-item label="仓库" prop="warehouseId">
<el-select v-model="queryParams.warehouseId" placeholder="请选择所属仓库">
<el-option
v-for="item in baseStoreList"
@ -16,7 +16,7 @@
:value="item.warehouseId"
></el-option>
</el-select>
</el-form-item>
</el-form-item>-->
<el-form-item label="库位编码" prop="locationCode" label-width="120px">
<el-input v-model="queryParams.locationCode" placeholder="请输入库位编码" clearable @keyup.enter="handleQuery" />
</el-form-item>
@ -35,11 +35,11 @@
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="erp同步状态" prop="erpSynchronousStatus" label-width="120px">
<!-- <el-form-item label="erp同步状态" prop="erpSynchronousStatus" label-width="120px">
<el-select v-model="queryParams.erpSynchronousStatus" placeholder="请选择erp同步状态" clearable >
<el-option v-for="dict in sys_common_status" :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
</el-form-item>-->
<!-- <el-form-item label="erp同步数量" prop="erpSynchronousQty">-->
<!-- <el-input v-model="queryParams.erpSynchronousQty" placeholder="请输入erp同步数量" clearable @keyup.enter="handleQuery" />-->
<!-- </el-form-item>-->

@ -19,11 +19,11 @@
<el-button type="primary" plain icon="Plus" @click="parentTableAdd"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="ids.length !== 1" @click="parentTableUpdate()">
<el-button type="success" plain icon="Edit" :disabled="ids.length !== 1" @click="parentTableUpdate(null)">
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="ids.length < 1" @click="parentTableDelete()">
<el-button type="danger" plain icon="Delete" :disabled="ids.length < 1" @click="parentTableDelete(null)">
</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
@ -39,8 +39,8 @@
<el-table-column type="selection" width="55"/>
<el-table-column label="表主键" align="center" prop="aoId" v-if="false"/>
<el-table-column label="调拨单号" align="center" prop="allocateOrderCode"/>
<el-table-column label="物料大类" align="center" prop="materialCategoryName">
</el-table-column>
<!-- <el-table-column label="物料大类" align="center" prop="materialCategoryName">
</el-table-column>-->
<el-table-column label="出库仓库" align="center" prop="planWarehouseCode"/>
<el-table-column label="工单状态" align="center" prop="orderStatus">
<template #default="scope">
@ -111,11 +111,27 @@
</template>
</el-table-column>
<el-table-column label="erp同步数量" align="center" prop="erpSynchronousQty"/>
<el-table-column label="操作" fixed="right" width="200">
<el-table-column label="已分包数量" align="center" prop="printedQty" />
<el-table-column label="操作" fixed="right" width="400">
<template #default="scope">
<!-- <el-button size="small" @click="childrenTableUpdate( scope.row)">-->
<!-- 修改-->
<!-- </el-button>-->
<el-button size="small" @click="childrenTablePrint(scope.row)"
v-if="partntTableSelectCell && partntTableSelectCell.auditStatus == '1' && !hasExistingTasks(scope.row)"
type="primary">
创建任务
</el-button>
<el-button size="small" @click="recreateTasks(scope.row)"
v-if="hasExistingTasks(scope.row)"
type="warning">
重新创建
</el-button>
<el-button size="small" @click="deleteAllTasks(scope.row)"
v-if="hasExistingTasks(scope.row)"
type="danger">
删除任务
</el-button>
<el-button size="small" @click="viewPrintTasks(scope.row)">
查看任务
</el-button>
<el-button
size="small"
type="danger"
@ -131,21 +147,21 @@
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="80%">
<el-card shadow="never">
<el-form :model="dialogForm" :inline="true" label-width="120px" :disabled="isView">
<el-form-item label="物料大类" prop="materialCategoryId">
<!-- <el-form-item label="物料大类" prop="materialCategoryId">-->
<el-select
v-model="dialogForm.materialCategoryId"
placeholder="选择物料大类"
@change="setMaterialList"
>
<el-option
v-for="item in mategoryOptions"
:label="item.materialCategoryName"
:value="item.materialCategoryId"
:key="item.materialCategoryId"
/>
</el-select>
</el-form-item>
<!-- <el-select-->
<!-- v-model="dialogForm.materialCategoryId"-->
<!-- placeholder="选择物料大类"-->
<!-- @change="setMaterialList"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in mategoryOptions"-->
<!-- :label="item.materialCategoryName"-->
<!-- :value="item.materialCategoryId"-->
<!-- :key="item.materialCategoryId"-->
<!-- />-->
<!-- </el-select>
</el-form-item>-->
<el-form-item label="出库仓库" prop="planWarehouseId">
<el-select v-model="dialogForm.planWarehouseId" placeholder="请选择所属仓库" @change="setMaterialList">
<el-option
@ -166,7 +182,7 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="审核人" prop="auditBy">
<!-- <el-form-item label="审核人" prop="auditBy">
<el-select v-model="dialogForm.auditBy" placeholder="请选择审核人">
<el-option
v-for="item in userList"
@ -175,7 +191,7 @@
:value="item.userName"
/>
</el-select>
</el-form-item>
</el-form-item>-->
<el-form-item label="入库方式" prop="inMethod">
<el-select v-model="dialogForm.inMethod" placeholder="请选择入库方式">
<el-option
@ -213,25 +229,11 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="物料编码" prop="materialId">
<!-- <template #default="scope">
<el-select
v-model="scope.row.materialId"
placeholder="选择物料"
style="width: 240px"
>
<el-option
v-for="i in materialList"
:label="i.materialCode+'('+i.materialName+')'"
:value="i.materialId"
:key="i.materialId"
/>
</el-select>
</template>-->
<el-table-column label="物料编码" prop="materialCode">
<template #default="scope">
<el-input
v-model="scope.row.materialCode"
placeholder="请点击检索物料"
placeholder="请点击检索库存"
@click="handleMaterialAdd('material', scope.$index)" >
<template #append>
<el-icon class="el-input__icon"><search/></el-icon>
@ -239,26 +241,55 @@
</el-input>
</template>
</el-table-column>
<el-table-column label="物料名称">
<el-table-column label="物料名称" prop="materialName">
<template #default="scope">
<el-select
v-model="scope.row.materialId"
placeholder="选择物料"
style="width: 240px"
<el-input
v-model="scope.row.materialName"
placeholder="物料名称"
:disabled="true"
>
<el-option
v-for="i in materialList"
:label="i.materialName"
:value="i.materialId"
:key="i.materialId"
/>
</el-select>
/>
</template>
</el-table-column>
<el-table-column label="批次码" prop="batchCode">
<template #default="scope">
<el-input
v-model="scope.row.batchCode"
placeholder="批次码"
:disabled="true"
/>
</template>
</el-table-column>
<el-table-column label="库位编码" prop="locationCode">
<template #default="scope">
<el-input
v-model="scope.row.locationCode"
placeholder="库位编码"
:disabled="true"
/>
</template>
</el-table-column>
<el-table-column label="库存数量" prop="inventoryQty">
<template #default="scope">
<el-input
v-model="scope.row.inventoryQty"
placeholder="库存数量"
:disabled="true"
/>
</template>
</el-table-column>
<el-table-column label="调拨数量" prop="allocateOrderQty">
<template #default="scope">
<el-input v-model="scope.row.allocateOrderQty" style="width: 240px" placeholder="输入调拨数量"/>
<el-input
v-model="scope.row.allocateOrderQty"
style="width: 240px"
placeholder="输入调拨数量"
type="number"
@blur="validateRowAllocateQty(scope.row)"
:class="{ 'error-input': Number(scope.row.allocateOrderQty) > Number(scope.row.inventoryQty) }"
/>
<span v-if="Number(scope.row.allocateOrderQty) > Number(scope.row.inventoryQty)" style="color: red; font-size: 12px;">
超出库存数量
</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="200">
@ -304,23 +335,23 @@
<el-dialog v-model="parentTableInfoVisible" title="修改父表格" width="40%">
<el-form :model="parentTableInfoForm" label-width="120px">
<el-form-item label="id" prop="planWarehouseId"v-if="false">
<el-input v-model="parentTableInfoForm.aoid"></el-input>
</el-form-item>
<el-form-item label="物料大类" prop="materialCategoryId">
<el-select
v-model="parentTableInfoForm.materialCategoryId"
placeholder="选择物料大类"
:disabled="updateDialog"
@change="setMaterialList"
>
<el-option
v-for="i in material_mategoryId"
:label="i.label"
:value="i.value"
:key="i.value"
/>
</el-select>
<el-input v-model="parentTableInfoForm.aoId"></el-input>
</el-form-item>
<!-- <el-form-item label="物料大类" prop="materialCategoryId">-->
<!-- <el-select-->
<!-- v-model="parentTableInfoForm.materialCategoryId"-->
<!-- placeholder="选择物料大类"-->
<!-- :disabled="updateDialog"-->
<!-- @change="setMaterialList"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="i in material_mategoryId"-->
<!-- :label="i.label"-->
<!-- :value="i.value"-->
<!-- :key="i.value"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="出库仓库" prop="planWarehouseId">
<el-select v-model="parentTableInfoForm.planWarehouseId" placeholder="请选择所属仓库" :disabled="updateDialog">
<el-option
@ -341,7 +372,7 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="审核人" prop="auditBy">
<!-- <el-form-item label="审核人" prop="auditBy">
<el-select v-model="parentTableInfoForm.auditBy" placeholder="请选择审核人">
<el-option
v-for="item in userList"
@ -350,7 +381,7 @@
:value="item.userName"
/>
</el-select>
</el-form-item>
</el-form-item>-->
</el-form>
<template #footer>
<div class="dialog-footer">
@ -364,7 +395,7 @@
<el-dialog v-model="childrenTableInfoVisible" title="修改子表格" width="40%">
<el-form :model="childrenTableInfoForm" label-width="120px">
<el-form-item label="物料大类" prop="materialCategoryId">
<!-- <el-form-item label="物料大类" prop="materialCategoryId">
<el-select
v-model="childrenTableInfoForm.materialCategoryId"
placeholder="选择物料大类"
@ -377,7 +408,7 @@
:key="i.value"
/>
</el-select>
</el-form-item>
</el-form-item>-->
<el-form-item label="出库仓库" prop="planWarehouseId">
<el-select v-model="childrenTableInfoForm.planWarehouseId" placeholder="请选择所属仓库">
<el-option
@ -398,7 +429,7 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="审核人" prop="auditBy">
<!-- <el-form-item label="审核人" prop="auditBy">
<el-select v-model="childrenTableInfoForm.auditBy" placeholder="请选择审核人">
<el-option
v-for="item in userList"
@ -407,7 +438,7 @@
:value="item.userName"
/>
</el-select>
</el-form-item>
</el-form-item>-->
</el-form>
<template #footer>
<div class="dialog-footer">
@ -419,20 +450,119 @@
</template>
</el-dialog>
<!-- 添加物料信息对话框 -->
<el-dialog title="选择物料信息" v-model="materialOpen" width='1200px' append-to-body>
<MaterialSelectInWMS
@selection="handleSelection"
ref="materialSelectRef"
<!-- 添加库存信息对话框 -->
<el-dialog title="选择库存信息" v-model="materialOpen" width='1200px' append-to-body>
<SelectInventoryInWMS
@selection="handleInventorySelection"
ref="inventorySelectRef"
v-if="materialOpen"
:materialCategories="dialogForm.materialCategories"
></MaterialSelectInWMS>
:materialCategoryId="dialogForm.materialCategoryId"
:warehouseId="dialogForm.planWarehouseId"
></SelectInventoryInWMS>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitMaterialForm"> </el-button>
<el-button type="primary" @click="submitInventoryForm"> </el-button>
<el-button @click="materialOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 分包打印对话框 -->
<el-dialog title="调拨分包打印" v-model="printDialogVisible" width="600px" append-to-body>
<el-form :model="printForm" label-width="120px">
<el-form-item label="物料编码">
<el-input v-model="printForm.materialCode" readonly />
</el-form-item>
<el-form-item label="物料名称">
<el-input v-model="printForm.materialName" readonly />
</el-form-item>
<el-form-item label="调拨数量">
<el-input v-model="printForm.allocateOrderQty" readonly />
</el-form-item>
<el-form-item label="打印模式" required>
<el-radio-group v-model="printForm.printMode" @change="onPrintModeChange">
<el-radio value="single">单包打印</el-radio>
<el-radio value="package">分包打印</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="分包数量" v-if="printForm.printMode === 'package'">
<el-input-number v-model="printForm.splitPackageCount" :min="2" :max="100" @change="onSplitCountChange" />
</el-form-item>
<el-form-item label="打印份数" v-if="printForm.printMode === 'single'">
<el-input-number v-model="printForm.printCopies" :min="1" :max="10" />
</el-form-item>
<el-form-item label="每包数量" v-if="printForm.printMode === 'package' && printForm.splitPackageCount > 1">
<div v-for="(qty, index) in printForm.packageQtyList" :key="index" style="margin-bottom: 10px">
<span style="width: 80px; display: inline-block">{{index + 1}}</span>
<el-input-number v-model="printForm.packageQtyList[index]" :min="1" :max="printForm.allocateOrderQty" @change="validatePackageTotal" style="width: 150px" />
</div>
<div style="margin-top: 10px; color: #909399">
总计{{ packageTotal }} / {{ printForm.allocateOrderQty }}
</div>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="printDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handlePrintSubmit" :disabled="!isValidPackage">确定打印</el-button>
</div>
</template>
</el-dialog>
<!-- 任务查看对话框 -->
<el-dialog title="调拨任务列表" v-model="taskDialogVisible" width="1000px" append-to-body>
<el-table :data="taskList" style="width: 100%">
<el-table-column label="批次码" align="center" prop="batchCode" />
<el-table-column label="每包数量" align="center" prop="materialQty" />
<el-table-column label="条码数量" align="center" prop="apportionQty" />
<el-table-column label="入库状态" align="center" prop="inboundStatus">
<template #default="scope">
<el-tag :type="scope.row.inboundStatus === '0' ? 'warning' : scope.row.inboundStatus === '1' ? 'success' : 'info'">
{{ scope.row.inboundStatus === '0' ? '待入库' : scope.row.inboundStatus === '1' ? '已入库' : '入库中' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="200">
<template #default="scope">
<el-button size="small" type="primary" @click="handleTaskPrint(scope.row)"
:disabled="scope.row.inboundStatus !== '0'">
打印
</el-button>
<el-button size="small" type="warning" @click="handleTaskEdit(scope.row)"
:disabled="scope.row.inboundStatus !== '0'">
编辑
</el-button>
</template>
</el-table-column>
</el-table>
<template #footer>
<div class="dialog-footer">
<el-button @click="taskDialogVisible = false">关闭</el-button>
</div>
</template>
</el-dialog>
<!-- 编辑任务对话框 -->
<el-dialog title="编辑调拨任务" v-model="editTaskDialogVisible" width="500px" append-to-body>
<el-form :model="editTaskForm" label-width="120px">
<el-form-item label="批次码" required>
<el-input v-model="editTaskForm.batchCode" placeholder="请输入批次码" />
</el-form-item>
<el-form-item label="每包数量" required>
<el-input-number v-model="editTaskForm.materialQty" :min="1" :max="10000" style="width: 100%" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="editTaskDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleTaskUpdate"></el-button>
</div>
</template>
</el-dialog>
</div>
</template>
@ -444,10 +574,23 @@ import {
viewAllocateOrder,
addAllocateOrder,
addAllocateOrderDetail,
getMaterialList, viewAllocateOrderDetail, delAllocateOrderDetail, allocateOrderUpdate
getMaterialList,
viewAllocateOrderDetail,
delAllocateOrderDetail,
allocateOrderUpdate,
allocatePackagePrint,
queryTasksByDetailId,
validatePrintable,
triggerPrint,
recreateAllocateTasks,
updateTaskBarcode,
deleteTasksByDetailId
} from '@/api/wms/linkage'
import MaterialSelectInWMS from "@/views/wms/baseMaterialInfo/addMaterialInWMS.vue";
import SelectInventoryInWMS from "@/views/wms/inventory/selectInventoryInWMS.vue";
import {AllocateOrderForm} from '@/api/wms/allocateOrder/types';
import {AllocateOrderDetailForm} from '@/api/wms/allocateOrderDetail/types';
import {reactive} from 'vue'
import {ElMessage, ElMessageBox} from 'element-plus'
@ -481,15 +624,17 @@ interface User {
const parentTableTotal = ref(0)
const dialogVisible = ref(false)
const parentTableInfoVisible = ref(false)
const childrenTableInfoSubmit = ref(false)
const childrenTableInfoVisible = ref(false)
const showSearch = ref(true)
const columns = ref([])
const updateDialog = ref(false)
const dialogTitle = ref('添加')
const dialogForm = ref({})
const parentTableInfoForm = ref({})
const childrenTableInfoForm = ref({})
const dialogForm = ref<AllocateOrderForm>({})
const parentTableInfoForm = ref<AllocateOrderForm>({})
const childrenTableInfoForm = ref<AllocateOrderForm>({})
const queryForm = ref({
allocateCode: '',
allocateOrderCode: '',
pageNum: 1,
pageSize: 10
})
@ -497,28 +642,60 @@ const parentTableRef = ref()
const parentTableData = ref([])
const ids = ref([])
const childrenTableData = ref([])
const dialogtable = ref([])
const baseStoreList = ref([]);
const dialogtable = ref<AllocateOrderDetailForm[]>([])
const userList = ref([]);
const materialList = ref([]);
const parentTableLoad = ref(false)
const childrenTableLoad = ref(false)
const isView = ref(false)
const partntTableSelectCell = ref({})
const partntTableSelectCell = ref<any>({})
//
const printDialogVisible = ref(false)
const taskDialogVisible = ref(false)
const editTaskDialogVisible = ref(false)
const taskList = ref([])
const currentTasksMap = ref(new Map()) //
const printForm = ref({
aoDId: null,
allocateCode: '',
materialCode: '',
materialName: '',
allocateOrderQty: 0,
printMode: 'single', // single: , package:
splitPackageCount: 2,
printCopies: 1,
packageQtyList: []
})
const editTaskForm = ref({
allocateTaskId: null,
batchCode: '',
materialQty: 1
})
//
getBaseWarehouseList().then(e => {
let baseStoreList = ref([]);
getBaseWarehouseList(null).then(e => {
baseStoreList.value = e.data
})
listUser().then(e => {
listUser({pageNum: 1, pageSize: 100}).then(e => {
userList.value = e.rows;
})
//
let mategoryOptions = ref([]);
let material_mategoryId = ref([]); //
const getMaterialCategorySelect = async () => {
const res = await getBaseMaterialCategoryListInWMS(null);
mategoryOptions.value = res.data;
//
material_mategoryId.value = res.data.map(item => ({
label: item.materialCategoryName,
value: item.materialCategoryId
}));
};
//
@ -543,10 +720,11 @@ const getParentTable = async () => {
//
const getChildrenTable = async (form) => {
childrenTableLoad.value = true
await allocateOrderDetailList(form).then(e => {
await allocateOrderDetailList(form).then(async e => {
childrenTableLoad.value = false
childrenTableData.value = e.rows
// parentTableTotal.value = e.total
//
await loadAllTasks()
})
}
@ -560,7 +738,9 @@ const query = async () => {
}
const reset = () => {
queryForm.value = {
allocateOrderCode: ''
allocateOrderCode: '',
pageNum: 1,
pageSize: 10
}
getParentTable();
}
@ -652,6 +832,38 @@ const addDialogTableCell = () => {
//
const dialogSubmit = () => {
//
let hasError = false;
for (let i = 0; i < dialogtable.value.length; i++) {
const row = dialogtable.value[i];
if (!row.materialId) {
ElMessage({
type: 'error',
message: `${i + 1}行请选择库存信息`
});
hasError = true;
continue;
}
if (!row.allocateOrderQty || row.allocateOrderQty <= 0) {
ElMessage({
type: 'error',
message: `${i + 1}行调拨数量必须大于0`
});
hasError = true;
continue;
}
if (Number(row.allocateOrderQty) > Number(row.inventoryQty)) {
ElMessage({
type: 'error',
message: `${i + 1}行调拨数量(${row.allocateOrderQty})不能超过库存数量(${row.inventoryQty})`
});
hasError = true;
}
}
if (hasError) {
return;
}
addAllocateOrder(dialogForm.value).then(e => {
addAllocateOrderDetail(dialogtable.value.map(item => {
@ -677,6 +889,15 @@ const parentTableInfoSubmit = () =>{
})
}
const childrenTableInfoSubmit = () =>{
// TODO:
ElMessage({
type: 'success',
message: '修改完成',
})
childrenTableInfoVisible.value = false
}
//
const childrenTableUpdate = async (e) => {
childrenTableInfoForm.value = (await viewAllocateOrderDetail(e.aoDId)).data
@ -732,11 +953,13 @@ const childrenTableUDelete = (e) => {
}
/* 以下为添加物料信息对话框相关方法 */
let materialSelectRef = ref();//
const materialOpen = ref(false);//
/* 以下为添加库存信息对话框相关方法 */
let inventorySelectRef = ref();//
let materialSelectRef = ref();//
const materialOpen = ref(false);//
const selectType = ref(''); //
const selectedMaterial = ref(null); //
const selectedInventory = ref(null); //
const selectedMaterial = ref(null); //
const currentRowIndex = ref(-1); //
/** 处理从MaterialSelect组件接收到的选择 */
@ -744,6 +967,87 @@ const handleSelection = (row) => {
selectedMaterial.value = row;
};
/** 处理从库存选择组件接收到的选择 */
const handleInventorySelection = (row) => {
console.log('库存选择数据:', row);
console.log('库存数量类型:', typeof row?.inventoryQty, '值:', row?.inventoryQty);
selectedInventory.value = row;
};
/** 验证调拨数量是否超过库存数量 */
const validateAllocateQty = (allocateQty, inventoryQty) => {
if (allocateQty > inventoryQty) {
ElMessage({
type: 'error',
message: `调拨数量(${allocateQty})不能超过库存数量(${inventoryQty})`
});
return false;
}
return true;
};
/** 行级数量验证 */
const validateRowAllocateQty = (row) => {
if (row.allocateOrderQty && row.inventoryQty) {
const allocateQty = Number(row.allocateOrderQty);
const inventoryQty = Number(row.inventoryQty);
console.log(`验证数量: 调拨数量=${allocateQty}, 库存数量=${inventoryQty}`);
if (allocateQty > inventoryQty) {
ElMessage({
type: 'warning',
message: `${dialogtable.value.indexOf(row) + 1}行调拨数量(${allocateQty})不能超过库存数量(${inventoryQty})`
});
}
}
};
/** 提交库存信息按钮 */
const submitInventoryForm = () => {
if (!selectedInventory.value) {
//
selectedInventory.value = inventorySelectRef.value?.tableRef?.store?.states?.currentRow?.value;
}
if (!selectedInventory.value) {
ElMessage({
type: 'warning',
message: '请选择库存信息'
});
return;
}
console.log('提交库存信息:', selectedInventory.value);
console.log('库存数量:', selectedInventory.value.inventoryQty, '类型:', typeof selectedInventory.value.inventoryQty);
if (selectType.value === 'material') {
//
if (currentRowIndex.value >= 0 && dialogtable.value[currentRowIndex.value]) {
dialogtable.value[currentRowIndex.value].materialId = Number(selectedInventory.value.materialId);
dialogtable.value[currentRowIndex.value].materialName = selectedInventory.value.materialName;
dialogtable.value[currentRowIndex.value].materialCode = selectedInventory.value.materialCode;
dialogtable.value[currentRowIndex.value].batchCode = selectedInventory.value.batchCode;
dialogtable.value[currentRowIndex.value].locationCode = selectedInventory.value.locationCode;
dialogtable.value[currentRowIndex.value].storeId = selectedInventory.value.storeId;
//
dialogtable.value[currentRowIndex.value].inventoryQty = Number(selectedInventory.value.inventoryQty);
console.log('赋值后的行数据:', dialogtable.value[currentRowIndex.value]);
console.log('赋值后的库存数量:', dialogtable.value[currentRowIndex.value].inventoryQty, '类型:', typeof dialogtable.value[currentRowIndex.value].inventoryQty);
// 0
if (!dialogtable.value[currentRowIndex.value].allocateOrderQty) {
dialogtable.value[currentRowIndex.value].allocateOrderQty = 0;
}
}
}
//
selectedInventory.value = null;
materialOpen.value = false;
};
/** 提交物料BOM信息按钮 */
const submitMaterialForm = () => {
if (!selectedMaterial.value) {
@ -758,8 +1062,6 @@ const submitMaterialForm = () => {
dialogtable.value[currentRowIndex.value].materialId = Number(selectedMaterial.value.materialId);
dialogtable.value[currentRowIndex.value].materialName = selectedMaterial.value.materialName;
dialogtable.value[currentRowIndex.value].materialCode = selectedMaterial.value.materialCode;
dialogtable.value[currentRowIndex.value].unitName = selectedMaterial.value.materialUnit;
dialogtable.value[currentRowIndex.value].materialSpe = selectedMaterial.value.materialSpec;
//
}
}
@ -777,6 +1079,264 @@ const handleMaterialAdd = (type, index) => {
materialOpen.value = true;
}
/** 判断调拨明细是否可以打印 */
const isPrintable = (row) => {
//
return row.allocateOrderQty && row.allocateOrderQty > 0;
}
/** 判断是否存在任务 */
const hasExistingTasks = (row) => {
const tasks = currentTasksMap.value.get(row.aoDId);
return tasks && tasks.length > 0;
}
/** 加载调拨明细的任务列表 */
const loadTasksForDetail = async (aoDId) => {
try {
const result = await queryTasksByDetailId(aoDId);
currentTasksMap.value.set(aoDId, result.data || []);
return result.data || [];
} catch (error) {
console.error('查询任务错误:', error);
return [];
}
}
/** 初始化加载所有调拨明细的任务 */
const loadAllTasks = async () => {
for (const detail of childrenTableData.value) {
await loadTasksForDetail(detail.aoDId);
}
}
/** 打印按钮点击事件 */
const childrenTablePrint = async (row) => {
try {
//
const result = await validatePrintable(row.aoDId);
if (!result.data) {
ElMessage.warning('该调拨明细已经打印过,不允许重复打印');
return;
}
//
printForm.value = {
aoDId: row.aoDId,
allocateCode: row.allocateCode,
materialCode: row.materialCode,
materialName: row.materialName || '',
allocateOrderQty: Number(row.allocateOrderQty),
printMode: 'single',
splitPackageCount: 2,
printCopies: 1,
packageQtyList: []
};
printDialogVisible.value = true;
} catch (error) {
console.error('打印验证错误:', error);
ElMessage.error('打印验证失败');
}
}
/** 查看任务按钮点击事件 */
const viewPrintTasks = async (row) => {
try {
const result = await queryTasksByDetailId(row.aoDId);
taskList.value = result.data || [];
taskDialogVisible.value = true;
} catch (error) {
console.error('查询任务错误:', error);
ElMessage.error('查询任务失败');
}
}
/** 打印模式变化事件 */
const onPrintModeChange = () => {
if (printForm.value.printMode === 'package') {
onSplitCountChange();
} else {
printForm.value.packageQtyList = [];
}
}
/** 分包数量变化事件 */
const onSplitCountChange = () => {
const count = printForm.value.splitPackageCount;
const avgQty = Math.floor(printForm.value.allocateOrderQty / count);
const remainder = printForm.value.allocateOrderQty % count;
printForm.value.packageQtyList = [];
for (let i = 0; i < count; i++) {
//
const qty = i < remainder ? avgQty + 1 : avgQty;
printForm.value.packageQtyList.push(qty);
}
}
/** 验证分包总数 */
const validatePackageTotal = () => {
//
console.log('当前分包总计:', packageTotal.value);
}
/** 计算属性:分包总数 */
const packageTotal = computed(() => {
return printForm.value.packageQtyList.reduce((sum, qty) => sum + (Number(qty) || 0), 0);
})
/** 计算属性:验证分包是否有效 */
const isValidPackage = computed(() => {
if (printForm.value.printMode === 'single') {
return printForm.value.printCopies > 0;
} else {
return packageTotal.value === printForm.value.allocateOrderQty &&
printForm.value.packageQtyList.every(qty => Number(qty) > 0);
}
})
/** 重新创建任务 */
const recreateTasks = async (row) => {
try {
//
printForm.value = {
aoDId: row.aoDId,
allocateCode: row.allocateCode,
materialCode: row.materialCode,
materialName: row.materialName || '',
allocateOrderQty: Number(row.allocateOrderQty),
printMode: 'single',
splitPackageCount: 2,
printCopies: 1,
packageQtyList: []
};
printDialogVisible.value = true;
} catch (error) {
console.error('重新创建错误:', error);
ElMessage.error('重新创建失败');
}
}
/** 删除所有任务 */
const deleteAllTasks = async (row) => {
try {
await ElMessageBox.confirm('确定要删除该调拨明细的所有任务吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
});
await deleteTasksByDetailId(row.aoDId);
ElMessage.success('删除成功');
//
await loadTasksForDetail(row.aoDId);
//
if (partntTableSelectCell.value.allocateOrderCode) {
await getChildrenTable({allocateCode: partntTableSelectCell.value.allocateOrderCode});
}
} catch (error) {
if (error !== 'cancel') {
console.error('删除任务错误:', error);
ElMessage.error('删除任务失败:' + ((error as any).response?.data?.msg || (error as any).message || '未知错误'));
}
}
}
/** 任务打印按钮点击 */
const handleTaskPrint = async (task) => {
try {
await triggerPrint(task.allocateTaskId);
ElMessage.success('打印成功');
} catch (error) {
console.error('打印错误:', error);
ElMessage.error('打印失败:' + ((error as any).response?.data?.msg || (error as any).message || '未知错误'));
}
}
/** 任务编辑按钮点击 */
const handleTaskEdit = (task) => {
editTaskForm.value = {
allocateTaskId: task.allocateTaskId,
batchCode: task.batchCode,
materialQty: task.materialQty
};
editTaskDialogVisible.value = true;
}
/** 任务更新 */
const handleTaskUpdate = async () => {
try {
if (!editTaskForm.value.batchCode) {
ElMessage.error('请输入批次码');
return;
}
if (!editTaskForm.value.materialQty || editTaskForm.value.materialQty <= 0) {
ElMessage.error('请输入正确的数量');
return;
}
await updateTaskBarcode(editTaskForm.value);
ElMessage.success('修改成功');
editTaskDialogVisible.value = false;
//
const currentDetailId = taskList.value[0]?.aoDId;
if (currentDetailId) {
const result = await queryTasksByDetailId(currentDetailId);
taskList.value = result.data || [];
}
} catch (error) {
console.error('修改任务错误:', error);
ElMessage.error('修改失败:' + ((error as any).response?.data?.msg || (error as any).message || '未知错误'));
}
}
const handlePrintSubmit = async () => {
try {
if (!isValidPackage.value) {
ElMessage.error('请正确设置打印参数');
return;
}
//
const hasExisting = hasExistingTasks({ aoDId: printForm.value.aoDId });
const params = {
aoDId: printForm.value.aoDId,
splitPackageCount: printForm.value.printMode === 'package' ? printForm.value.splitPackageCount : 1,
packageQtyList: printForm.value.printMode === 'package' ? printForm.value.packageQtyList : null
};
if (hasExisting) {
//
await recreateAllocateTasks(params);
ElMessage.success('重新创建任务成功');
} else {
//
const createParams = {
...params,
allocateCode: printForm.value.allocateCode,
printCopies: printForm.value.printMode === 'single' ? printForm.value.printCopies : 1
};
await allocatePackagePrint(createParams);
ElMessage.success('创建任务成功');
}
printDialogVisible.value = false;
//
await loadTasksForDetail(printForm.value.aoDId);
if (partntTableSelectCell.value.allocateOrderCode) {
await getChildrenTable({allocateCode: partntTableSelectCell.value.allocateOrderCode});
}
} catch (error) {
console.error('操作错误:', error);
ElMessage.error('操作失败:' + ((error as any).response?.data?.msg || (error as any).message || '未知错误'));
}
}
</script>
<style>
.demo-form-inline .el-input {
@ -786,4 +1346,9 @@ const handleMaterialAdd = (type, index) => {
.demo-form-inline .el-select {
--el-select-width: 220px;
}
.error-input .el-input__wrapper {
border-color: #f56c6c !important;
box-shadow: 0 0 0 1px #f56c6c inset !important;
}
</style>

@ -60,8 +60,8 @@
<!-- <el-input v-model="queryParams.aoDId" placeholder="请输入子表id" clearable @keyup.enter="handleQuery" />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<!-- <el-button icon="Refresh" @click="resetQuery"></el-button>-->
</el-form-item>
</el-form>
</el-card>
@ -69,7 +69,7 @@
</transition>
<el-card shadow="never">
<template #header>
<!-- <template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['wms:wmsAllocateTask:add']"></el-button>
@ -85,7 +85,7 @@
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
</template>-->
<el-table v-loading="loading" :data="wmsAllocateTaskList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
@ -102,7 +102,7 @@
<el-table-column label="是否有条码" align="center" prop="codeYesNo" v-if="columns[11].visible"/>
<el-table-column label="物料大类" align="center" prop="materialCategories" v-if="columns[12].visible"/>
<el-table-column label="推荐库位id" align="center" prop="locationId" v-if="columns[17].visible"/>
<el-table-column label="入库状态(0-待入库,1-已入库,2-入库中)" align="center" prop="inboundStatus" v-if="columns[18].visible">
<el-table-column label="入库状态" align="center" prop="inboundStatus" v-if="columns[18].visible">
<template #default="scope">
<dict-tag :options="wms_inbound_status" :value="scope.row.inboundStatus"/>
</template>
@ -115,12 +115,12 @@
<el-table-column label="子表id" align="center" prop="aoDId" v-if="columns[20].visible"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<!-- <el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['wms:wmsAllocateTask:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['wms:wmsAllocateTask:remove']"></el-button>
</el-tooltip>
</el-tooltip>-->
</template>
</el-table-column>
</el-table>
@ -238,8 +238,8 @@ const columns = ref<FieldOption[]>([
{ key: 8, label: `物料名称`, visible: true },
{ key: 9, label: `物料规格`, visible: true },
{ key: 10, label: `计量单位名称`, visible: true },
{ key: 11, label: `是否有条码`, visible: true },
{ key: 12, label: `物料大类`, visible: true },
{ key: 11, label: `是否有条码`, visible: false },
{ key: 12, label: `物料大类`, visible: false },
{ key: 13, label: `租户`, visible: false }, //
{ key: 14, label: `创建者`, visible: false }, //
{ key: 15, label: `更新时间`, visible: false }, //

Loading…
Cancel
Save