feat(wms): 修改扫描器页面的记录类型选项

- 注释掉字典类型的记录类型选项- 手动添加"入库"和"出库"两个记录类型选项
- 优化了代码格式,调整了部分缩进和空格
This commit is contained in:
JR
2025-08-16 10:08:38 +08:00
parent aa8328c5d3
commit 7c4cea9c14

View File

@@ -41,12 +41,14 @@
</el-form-item> </el-form-item>
<el-form-item label="记录类型" class="form-item"> <el-form-item label="记录类型" class="form-item">
<el-select v-model="defaultForm.ioType" placeholder="请选择操作类型" clearable class="form-input"> <el-select v-model="defaultForm.ioType" placeholder="请选择操作类型" clearable class="form-input">
<el-option <!-- <el-option-->
v-for="dict in dict.type.stock_io_type" <!-- v-for="dict in dict.type.stock_io_type"-->
:key="dict.value" <!-- :key="dict.value"-->
:label="dict.label" <!-- :label="dict.label"-->
:value="dict.value" <!-- :value="dict.value"-->
/> <!-- />-->
<el-option label="入库" value="in" />
<el-option label="出库" value="out" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="批次号" class="form-item"> <el-form-item label="批次号" class="form-item">
@@ -99,7 +101,7 @@
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="batchNo" label="批次号" align="center"> <el-table-column prop="batchNo" label="批次号" align="center">
<template #default="scope"> <template #default="scope">
<el-input v-model="scope.row.batchNo" class="table-input" /> <el-input v-model="scope.row.batchNo" class="table-input" />
</template> </template>
@@ -164,15 +166,15 @@ export default {
initSocket() { initSocket() {
// 处理WebSocket连接 // 处理WebSocket连接
this.socket = new WebSocket("ws://localhost:9000/ws"); this.socket = new WebSocket("ws://localhost:9000/ws");
this.socket.onopen = () => { this.socket.onopen = () => {
console.log("Socket 连接已建立"); console.log("Socket 连接已建立");
}; };
this.socket.onmessage = (event) => { this.socket.onmessage = (event) => {
try { try {
const data = JSON.parse(event.data); const data = JSON.parse(event.data);
// 处理设备列表数据 // 处理设备列表数据
if (data.type === "allDevices") { if (data.type === "allDevices") {
console.log("获取设备列表", data); console.log("获取设备列表", data);
@@ -181,7 +183,7 @@ export default {
totalCount: data.totalCount || 0, totalCount: data.totalCount || 0,
activeCount: data.activeCount || 0 activeCount: data.activeCount || 0
}; };
} }
// 处理扫描消息 // 处理扫描消息
else if (data.type === "scanMessage") { else if (data.type === "scanMessage") {
console.log("获取扫描消息", data); console.log("获取扫描消息", data);
@@ -201,7 +203,7 @@ export default {
console.error("解析WebSocket消息失败", error); console.error("解析WebSocket消息失败", error);
} }
}; };
this.socket.onclose = () => { this.socket.onclose = () => {
console.log("Socket 连接已关闭"); console.log("Socket 连接已关闭");
// 连接关闭后尝试重连 // 连接关闭后尝试重连
@@ -209,12 +211,12 @@ export default {
this.initSocket(); this.initSocket();
}, 5000); }, 5000);
}; };
this.socket.onerror = (error) => { this.socket.onerror = (error) => {
console.error("Socket 错误", error); console.error("Socket 错误", error);
}; };
}, },
// 刷新设备列表 // 刷新设备列表
refreshDevices() { refreshDevices() {
if (this.socket && this.socket.readyState === WebSocket.OPEN) { if (this.socket && this.socket.readyState === WebSocket.OPEN) {
@@ -225,7 +227,7 @@ export default {
this.initSocket(); this.initSocket();
} }
}, },
fetchMaster() { fetchMaster() {
listStockIo({ pageSize: 9999, pageNum: 1 }).then(res => { listStockIo({ pageSize: 9999, pageNum: 1 }).then(res => {
console.log("获取挂载单据", res); console.log("获取挂载单据", res);
@@ -235,7 +237,7 @@ export default {
this.$message.error("获取挂载单据失败"); this.$message.error("获取挂载单据失败");
}); });
}, },
handleDeviceChange(item) { handleDeviceChange(item) {
this.socket.send( this.socket.send(
JSON.stringify({ JSON.stringify({
@@ -244,7 +246,7 @@ export default {
}) })
); );
}, },
handleBatchConfirm() { handleBatchConfirm() {
// 汇总会导致的库存变更,需要确认 // 汇总会导致的库存变更,需要确认
console.log("批量确认", this.selectedList); console.log("批量确认", this.selectedList);
@@ -252,7 +254,7 @@ export default {
this.$message.warning("请选择需要确认的记录"); this.$message.warning("请选择需要确认的记录");
return; return;
} }
// 批量处理逻辑 // 批量处理逻辑
Promise.all(this.selectedList.map(item => this.processRecord(item))) Promise.all(this.selectedList.map(item => this.processRecord(item)))
.then(() => { .then(() => {
@@ -268,15 +270,15 @@ export default {
this.$message.error("批量确认失败"); this.$message.error("批量确认失败");
}); });
}, },
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.selectedList = selection; this.selectedList = selection;
}, },
handleDelete(row) { handleDelete(row) {
this.messageList = this.messageList.filter(item => item.time !== row.time); this.messageList = this.messageList.filter(item => item.time !== row.time);
}, },
async handleConfirm(row) { async handleConfirm(row) {
try { try {
await this.processRecord(row); await this.processRecord(row);
@@ -287,7 +289,7 @@ export default {
this.$message.error('确认失败'); this.$message.error('确认失败');
} }
}, },
// 处理单条记录的确认逻辑 // 处理单条记录的确认逻辑
async processRecord(row) { async processRecord(row) {
// 插入记录 // 插入记录
@@ -295,11 +297,11 @@ export default {
// 更新库存 // 更新库存
await this.updateStock(row); await this.updateStock(row);
}, },
insertRecord(row) { insertRecord(row) {
return addStockIoDetail(row); return addStockIoDetail(row);
}, },
updateStock(row) { updateStock(row) {
if (row.ioType === 'in') { if (row.ioType === 'in') {
return scanInStock(row); return scanInStock(row);
@@ -483,4 +485,4 @@ export default {
.el-table td, .el-table th { .el-table td, .el-table th {
padding: 12px 0; padding: 12px 0;
} }
</style> </style>