|
|
|
@ -62,13 +62,6 @@
|
|
|
|
|
width="120"
|
|
|
|
|
>
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
|
@click="print(scope.row)"
|
|
|
|
|
>
|
|
|
|
|
条码打印
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
@ -173,6 +166,7 @@
|
|
|
|
|
@click="handleMaterialConfirmForm(scope)"
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
|
v-if="scope.row.planDetailStatus === PLAN_DETAIL_STATUS.STARTED"
|
|
|
|
|
>
|
|
|
|
|
扫描
|
|
|
|
|
</el-button>
|
|
|
|
@ -180,9 +174,19 @@
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
|
@click="returnMaterial(scope)"
|
|
|
|
|
v-if="scope.row.planDetailStatus !== PLAN_DETAIL_STATUS.TO_START"
|
|
|
|
|
>
|
|
|
|
|
退料
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
|
@click="print(scope.row)"
|
|
|
|
|
v-if="scope.row.planDetailStatus === PLAN_DETAIL_STATUS.FINISHED || scope.row.planDetailStatus === PLAN_DETAIL_STATUS.ABNORMAL_FINISHED"
|
|
|
|
|
>
|
|
|
|
|
条码
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
@ -209,7 +213,7 @@
|
|
|
|
|
<el-row>
|
|
|
|
|
<el-button type="primary">首页</el-button>
|
|
|
|
|
<el-button type="success" @click="handleProductInstock">成品入库</el-button>
|
|
|
|
|
<el-button type="warning" @click="connectSerial">连接条码枪</el-button>
|
|
|
|
|
<!--el-button type="warning" @click="connectSerialPort" ref="connectSerialBtn">连接条码枪</el-button-->
|
|
|
|
|
<!--el-button type="info">最小化</el-button-->
|
|
|
|
|
<el-button type="danger" @click="logout">退出</el-button>
|
|
|
|
|
</el-row>
|
|
|
|
@ -339,14 +343,14 @@
|
|
|
|
|
<el-form-item label="计划ID" prop="planId" v-if="false">
|
|
|
|
|
<el-input v-model="materialConfirmForm.planId"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="明细ID" prop="planDetailId" v-if="false">
|
|
|
|
|
<el-input v-model="materialConfirmForm.planDetailId"></el-input>
|
|
|
|
|
<el-form-item label="明细编号" prop="planDetailCode">
|
|
|
|
|
<el-input v-model="materialConfirmForm.planDetailCode" disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="物料条码" prop="materialBarcode">
|
|
|
|
|
<el-input v-model="materialConfirmForm.materialBarcode"></el-input>
|
|
|
|
|
<el-input v-model="materialConfirmForm.materialBarcode" suffix-icon="el-icon-scan"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="数量" prop="checkAmount">
|
|
|
|
|
<el-input v-model="materialConfirmForm.checkAmount"></el-input>
|
|
|
|
|
<el-input v-model="materialConfirmForm.checkAmount" disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
@ -366,12 +370,14 @@
|
|
|
|
|
<el-input v-model="returnModelForm.materialName" autocomplete="off" disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="物料条码">
|
|
|
|
|
<el-input placeholder="请输入内容" v-model="returnModelForm.materialBarcode" class="input-with-select" @blur="setReturnModelForm">
|
|
|
|
|
<el-input placeholder="请输入内容" v-model="returnModelForm.materialBarcode" class="input-with-select"
|
|
|
|
|
@blur="setReturnModelForm">
|
|
|
|
|
<el-button slot="append" icon="el-icon-search"></el-button>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="仓库">
|
|
|
|
|
<el-select v-model="returnModelForm.warehouseId" placeholder="请选择仓库" :disabled="!returnModelForm.materialBarcode">
|
|
|
|
|
<el-select v-model="returnModelForm.warehouseId" placeholder="请选择仓库"
|
|
|
|
|
:disabled="!returnModelForm.materialBarcode">
|
|
|
|
|
<el-option :label="i.label" :key="i.value" :value="i.value" v-for="i in WarehousesList"></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
@ -380,7 +386,8 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="退库类型" prop="taskType">
|
|
|
|
|
<el-select v-model="returnModelForm.taskType" placeholder="请选择退库类型">
|
|
|
|
|
<el-option :label="i.label" :key="i.value" :value="i.value" v-for="i in dict.type.wms_raw_return_task_type"></el-option>
|
|
|
|
|
<el-option :label="i.label" :key="i.value" :value="i.value"
|
|
|
|
|
v-for="i in dict.type.wms_raw_return_task_type"></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="申请原因">
|
|
|
|
@ -410,23 +417,23 @@ import {
|
|
|
|
|
fourthFloorProduceInstock,
|
|
|
|
|
scanMaterial2Confirm, applyRawReturn
|
|
|
|
|
} from "@/api/board";
|
|
|
|
|
import {monitorSerialData} from "@/utils/serial"
|
|
|
|
|
|
|
|
|
|
const vw = (document.documentElement.clientWidth || document.body.clientWidth) / 100
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Board1',
|
|
|
|
|
dicts: ['mes_plan_detail_status', 'wms_raw_return_task_type', 'mes_safe_flag'],
|
|
|
|
|
mixins: [monitorSerialData],
|
|
|
|
|
components: {
|
|
|
|
|
Chart,
|
|
|
|
|
PrintPage
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
serialPort: null,
|
|
|
|
|
reader: null,
|
|
|
|
|
lastScannedBarcode: '',
|
|
|
|
|
decoder: new TextDecoder(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// serialPort: null,
|
|
|
|
|
// reader: null,
|
|
|
|
|
// decoder: new TextDecoder(),
|
|
|
|
|
// barcode: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
returnModelVisible: false,
|
|
|
|
@ -463,7 +470,8 @@ export default {
|
|
|
|
|
materialBarcode: null,
|
|
|
|
|
planId: null,
|
|
|
|
|
planDetailId: null,
|
|
|
|
|
checkAmount:null
|
|
|
|
|
planDetailCode: null,
|
|
|
|
|
checkAmount: 1
|
|
|
|
|
},
|
|
|
|
|
materialConfirmRules: {
|
|
|
|
|
materialBarcode: [
|
|
|
|
@ -479,9 +487,21 @@ export default {
|
|
|
|
|
{required: true, message: '请选择退库类型', trigger: 'change'}
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
PLAN_DETAIL_STATUS:{
|
|
|
|
|
TO_START : '1',
|
|
|
|
|
STARTED : '2',
|
|
|
|
|
FINISHED : '3',
|
|
|
|
|
ABNORMAL_FINISHED : '9'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
this.firstConnectSerial();
|
|
|
|
|
// setInterval(() => {
|
|
|
|
|
// this.$notify.info({
|
|
|
|
|
// title: '通知',
|
|
|
|
@ -676,56 +696,63 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
checkPortConnection(){
|
|
|
|
|
checkPortConnection(portName).then((isConnected) => {
|
|
|
|
|
if (isConnected) {
|
|
|
|
|
console.log('串口已连接并可用.');
|
|
|
|
|
} else {
|
|
|
|
|
console.log('串口未连接或不可用.');
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.error('检查串口连接时发生错误:', error);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async connectSerial() {
|
|
|
|
|
try {
|
|
|
|
|
// 请求串口访问权限
|
|
|
|
|
this.serialPort = await navigator.serial.requestPort();
|
|
|
|
|
await this.serialPort.open({ baudRate: 9600 }); // 假设条码枪的波特率为9600
|
|
|
|
|
|
|
|
|
|
// 设置数据流解码
|
|
|
|
|
this.decoder = new TextDecoderStream();
|
|
|
|
|
const readableStreamClosed = this.serialPort.readable.pipeTo(this.decoder.writable);
|
|
|
|
|
this.reader = this.decoder.readable.getReader();
|
|
|
|
|
|
|
|
|
|
// 监听串口数据
|
|
|
|
|
while (true) {
|
|
|
|
|
const { value, done } = await this.reader.read();
|
|
|
|
|
if (done) {
|
|
|
|
|
this.reader.releaseLock();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// console.log("---"+value);
|
|
|
|
|
// const data = this.decoder.decode(value);
|
|
|
|
|
this.processReceivedData(value);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('连接或读取串口时发生错误:', error);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
processReceivedData(data) {
|
|
|
|
|
// 假设条码数据以回车符或换行符结束
|
|
|
|
|
const barcodeEnd = /\r|\n/;
|
|
|
|
|
if (barcodeEnd.test(data)) {
|
|
|
|
|
const barcode = data.split(barcodeEnd)[0].trim(); // 获取并清理条码数据
|
|
|
|
|
this.lastScannedBarcode = barcode; // 更新最后一次扫描的条码
|
|
|
|
|
console.log('扫描到的条码:', barcode);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// triggerButtonClick() {
|
|
|
|
|
// // 确保DOM已更新
|
|
|
|
|
// this.$nextTick(() => {
|
|
|
|
|
// if (this.$refs.connectSerialBtn) {
|
|
|
|
|
// // 直接调用DOM元素的click方法
|
|
|
|
|
// this.$refs.connectSerialBtn.handleClick();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
// async connectSerial() {
|
|
|
|
|
// this.checkPortConnection();
|
|
|
|
|
// try {
|
|
|
|
|
// // 请求串口访问权限
|
|
|
|
|
// this.serialPort = await navigator.serial.requestPort();
|
|
|
|
|
// await this.serialPort.open({baudRate: 9600}); // 假设条码枪的波特率为9600
|
|
|
|
|
//
|
|
|
|
|
// // 设置数据流解码
|
|
|
|
|
// this.decoder = new TextDecoderStream();
|
|
|
|
|
// const readableStreamClosed = this.serialPort.readable.pipeTo(this.decoder.writable);
|
|
|
|
|
// this.reader = this.decoder.readable.getReader();
|
|
|
|
|
//
|
|
|
|
|
// // 监听串口数据
|
|
|
|
|
// while (true) {
|
|
|
|
|
// const {value, done} = await this.reader.read();
|
|
|
|
|
// if (done) {
|
|
|
|
|
// this.reader.releaseLock();
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // console.log("---v" + value);
|
|
|
|
|
// // console.log("---d:" + done);
|
|
|
|
|
// // const data = this.decoder.decode(value);
|
|
|
|
|
// this.processReceivedData(value);
|
|
|
|
|
// }
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// console.error('连接或读取串口时发生错误:', error);
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// processReceivedData(data) {
|
|
|
|
|
// // 假设条码数据以回车符或换行符结束
|
|
|
|
|
// const barcodeEnd = /\r|\n/;
|
|
|
|
|
// // console.log("---:" + data)
|
|
|
|
|
// if (barcodeEnd.test(data)) {
|
|
|
|
|
// const barcode = data.split(barcodeEnd)[0].trim(); // 获取并清理条码数据
|
|
|
|
|
// // console.log('扫描到的条码:', this.barcode + barcode);
|
|
|
|
|
// if (this.materialConfirmVisible) {
|
|
|
|
|
// this.materialConfirmForm.materialBarcode = this.barcode + barcode;
|
|
|
|
|
// } else if (this.productInstockVisible) {
|
|
|
|
|
// this.productInstockForm.materialBarcode = this.barcode + barcode;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// this.barcode = '';
|
|
|
|
|
// } else {
|
|
|
|
|
// this.barcode += data;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -739,7 +766,8 @@ export default {
|
|
|
|
|
this.$store.dispatch('LogOut').then(() => {
|
|
|
|
|
location.href = '/login?isStationId=true';
|
|
|
|
|
})
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
next1() {
|
|
|
|
|
this.nowNum1 += 1
|
|
|
|
@ -941,6 +969,26 @@ export default {
|
|
|
|
|
handleProductInstock() {
|
|
|
|
|
this.resetProductInstock();
|
|
|
|
|
this.productInstockVisible = true;
|
|
|
|
|
if (!this.checkSerialConnected()) {
|
|
|
|
|
this.$confirm('请连接条码枪', '提示', {
|
|
|
|
|
confirmButtonText: '连接',
|
|
|
|
|
showClose: true,
|
|
|
|
|
// beforeClose:async(action,instance,done)=>{
|
|
|
|
|
// if(action==='confirm'){
|
|
|
|
|
// }else{
|
|
|
|
|
// this.connectSerialPort();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// },
|
|
|
|
|
showCancelButton: true,
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
console.log("dddd")
|
|
|
|
|
this.connectSerial(this.setSerialData);
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -961,28 +1009,43 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 表单重置
|
|
|
|
|
resetMaterialConfirm() {
|
|
|
|
|
this.materialConfirmForm = {
|
|
|
|
|
materialBarcode: null,
|
|
|
|
|
planId: null,
|
|
|
|
|
planDetailId: null,
|
|
|
|
|
checkAmount:null
|
|
|
|
|
planDetailCode: null,
|
|
|
|
|
checkAmount: 1
|
|
|
|
|
};
|
|
|
|
|
this.resetForm("materialConfirmForm");
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/** 成品入库按钮操作 */
|
|
|
|
|
/** 物料扫描按钮操作 */
|
|
|
|
|
handleMaterialConfirmForm(scope) {
|
|
|
|
|
this.materialConfirmForm = {
|
|
|
|
|
materialBarcode: null,
|
|
|
|
|
planId: scope.row.planId,
|
|
|
|
|
planDetailId: scope.row.planDetailId,
|
|
|
|
|
checkAmount:null
|
|
|
|
|
planDetailCode: scope.row.planDetailCode,
|
|
|
|
|
checkAmount: 1
|
|
|
|
|
};
|
|
|
|
|
this.materialConfirmVisible = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.checkSerialConnected()) {
|
|
|
|
|
this.$confirm('请连接条码枪', '提示', {
|
|
|
|
|
confirmButtonText: '连接',
|
|
|
|
|
showClose: true,
|
|
|
|
|
showCancelButton: true,
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
console.log("dddd")
|
|
|
|
|
this.connectSerial(this.setSerialData);
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1040,7 +1103,43 @@ export default {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
firstConnectSerial() {
|
|
|
|
|
if (!this.checkSerialConnected()) {
|
|
|
|
|
this.$confirm('请连接条码枪', '提示', {
|
|
|
|
|
confirmButtonText: '连接',
|
|
|
|
|
showClose: true,
|
|
|
|
|
// beforeClose:async(action,instance,done)=>{
|
|
|
|
|
// if(action==='confirm'){
|
|
|
|
|
// }else{
|
|
|
|
|
// this.connectSerialPort();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// },
|
|
|
|
|
showCancelButton: true,
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.connectSerial(this.setSerialData);
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setSerialData() {
|
|
|
|
|
// if (!this.checkSerialConnected()) {//判断是否已连接,如果没有连接则需要连接
|
|
|
|
|
// }
|
|
|
|
|
if (this.materialConfirmVisible) {
|
|
|
|
|
this.materialConfirmForm.materialBarcode = this.serialData;
|
|
|
|
|
} else if (this.productInstockVisible) {
|
|
|
|
|
this.productInstockForm.materialBarcode = this.serialData;
|
|
|
|
|
}
|
|
|
|
|
// console.log(this.serialData)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|