|
@@ -270,6 +270,7 @@
|
|
|
clearable
|
|
|
filterable
|
|
|
size="mini"
|
|
|
+ @change="levelChangeHandler"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in dropDownData.level"
|
|
@@ -491,6 +492,7 @@ import {
|
|
|
import codeListPrint from "@/utils/print/codeListPrint";
|
|
|
import { getServerPrintData } from "@/utils/print/printUtils";
|
|
|
import { v4 as uuidv4 } from "uuid";
|
|
|
+import moment from "moment";
|
|
|
|
|
|
export default {
|
|
|
name: "ProductCodeList",
|
|
@@ -690,10 +692,26 @@ export default {
|
|
|
deep: true,
|
|
|
immediate: true,
|
|
|
},
|
|
|
+ "dict.type.packaging_type": {
|
|
|
+ handler(newValue, oldValue) {
|
|
|
+ if (newValue?.length > 0 && this.excuteType == 1) {
|
|
|
+ this.form.packaging = newValue[0].value;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ immediate: true,
|
|
|
+ },
|
|
|
+ "dict.type.coding_list_format": {
|
|
|
+ handler(newValue, oldValue) {
|
|
|
+ if (newValue?.length > 0 && this.excuteType == 1) {
|
|
|
+ this.form.printFormat = newValue[0].value;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ immediate: true,
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
- // console.log(this.dict.type.packaging_type);
|
|
|
- console.log("mounted");
|
|
|
let { excuteType, qrCode } = this.$route.query;
|
|
|
if (excuteType == 2) {
|
|
|
//修改
|
|
@@ -717,6 +735,16 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ // 等级改变回调
|
|
|
+ async levelChangeHandler() {
|
|
|
+ // 等级发生变化,重新获取码单号
|
|
|
+ let res = await getQrCode();
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.qrCode = res.msg;
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
// 机台改变回调
|
|
|
machineToolChange(id) {
|
|
|
if (id) {
|
|
@@ -735,7 +763,6 @@ export default {
|
|
|
},
|
|
|
async readStateChange() {
|
|
|
if (this.isStartReadNum) {
|
|
|
- console.log("当前等待次数:", this.waiting);
|
|
|
//正在读
|
|
|
this.closeWebSocket();
|
|
|
this.isStartReadNum = false;
|
|
@@ -756,7 +783,12 @@ export default {
|
|
|
this.initWebSocket();
|
|
|
}
|
|
|
},
|
|
|
- initWebSocket() {
|
|
|
+ async initWebSocket() {
|
|
|
+ // let res = await this.addIsValidate();
|
|
|
+ // if (!res) {
|
|
|
+ // this.$message.warning("请完善表单数据");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
const getConfigValue = (label, defaultValue) => {
|
|
|
let value = this.dict.type.automatic_printing.find(
|
|
|
(item) => item.label === label
|
|
@@ -771,7 +803,6 @@ export default {
|
|
|
const wsUrl = `ws:${process.env.VUE_APP_BASE_WS_API}/currentWeight`;
|
|
|
this.websocket = new WebSocket(wsUrl);
|
|
|
this.websocket.addEventListener("open", (event) => {
|
|
|
- console.log("建立WebSocket连接");
|
|
|
this.isStartReadNum = true;
|
|
|
this.$message.success("已开启读数");
|
|
|
});
|
|
@@ -781,7 +812,6 @@ export default {
|
|
|
let shouldPrint = false; // 用于控制是否应该打印
|
|
|
|
|
|
this.websocket.addEventListener("message", async (event) => {
|
|
|
- console.log(event);
|
|
|
if (!this.printAuto) return;
|
|
|
|
|
|
const weightData = JSON.parse(event.data);
|
|
@@ -828,17 +858,12 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- this.websocket.addEventListener("on", (e) => {
|
|
|
- console.log(e, "连接已建立");
|
|
|
- });
|
|
|
+ this.websocket.addEventListener("on", (e) => {});
|
|
|
this.websocket.addEventListener("error", (event) => {
|
|
|
- console.error("WebSocket错误:", event);
|
|
|
this.$message.error("WebSocket错误,请重试");
|
|
|
});
|
|
|
|
|
|
- this.websocket.addEventListener("close", () => {
|
|
|
- console.log("关闭WebSocket连接");
|
|
|
- });
|
|
|
+ this.websocket.addEventListener("close", () => {});
|
|
|
},
|
|
|
// 用于重置与重量相关的状态
|
|
|
resetWeightStatus() {
|
|
@@ -858,12 +883,10 @@ export default {
|
|
|
|
|
|
// 表单重量改变回调
|
|
|
changeGrossWeightForm(val) {
|
|
|
- // console.log(val);
|
|
|
this.nowWeight = val;
|
|
|
},
|
|
|
// 开始设置新的重量
|
|
|
async setWeight(weight) {
|
|
|
- console.log("设置新的重量", weight);
|
|
|
let newData = {};
|
|
|
let {
|
|
|
machineTool,
|
|
@@ -881,7 +904,6 @@ export default {
|
|
|
remark,
|
|
|
machineToolNo,
|
|
|
} = this.form;
|
|
|
- console.log(this.currentRow);
|
|
|
let {
|
|
|
productName,
|
|
|
productSpecifications,
|
|
@@ -942,7 +964,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
(error) => {
|
|
|
- console.log(error);
|
|
|
this.$message.warning("请完善表单数据");
|
|
|
resolve(false);
|
|
|
}
|
|
@@ -951,7 +972,6 @@ export default {
|
|
|
},
|
|
|
// 新的后端打印逻辑
|
|
|
async newPrintHandler() {
|
|
|
- console.log("newPrintHandler");
|
|
|
let printRow = this.printTableData[0];
|
|
|
let payload = {
|
|
|
qrCodeVal: "",
|
|
@@ -983,13 +1003,11 @@ export default {
|
|
|
qrCode;
|
|
|
// payload.qrCodeVal = encodeURIComponent(temp);
|
|
|
payload.qrCodeVal = temp;
|
|
|
- console.log("二维码数据", temp);
|
|
|
payload.remark = remark || "注:不同批号,请勿混用";
|
|
|
payload.mapList = getServerPrintData(printRow);
|
|
|
payload.printType = printFormat == 3 ? "export" : "normal";
|
|
|
try {
|
|
|
let res = await AutoPrinting(payload);
|
|
|
- console.log(res);
|
|
|
if (res.code == 200 && res.status == "success") {
|
|
|
this.$message.success(res.msg);
|
|
|
if (this.excuteType == 1) {
|
|
@@ -999,7 +1017,6 @@ export default {
|
|
|
this.$message.error(res.msg);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.log(error);
|
|
|
this.$message.error(error);
|
|
|
}
|
|
|
},
|
|
@@ -1014,27 +1031,19 @@ export default {
|
|
|
},
|
|
|
// 毛重改变回调
|
|
|
changeGrossWeight(row) {
|
|
|
- console.log(row);
|
|
|
let { boxWeight, grossWeight, canisterWeight, canisterNum } = row;
|
|
|
if (!Number(grossWeight)) {
|
|
|
row.suttle = 0;
|
|
|
return;
|
|
|
}
|
|
|
- console.log(
|
|
|
- Number(grossWeight),
|
|
|
- Number(boxWeight),
|
|
|
- Number(canisterWeight) * Number(canisterNum)
|
|
|
- );
|
|
|
row.suttle = (
|
|
|
Number(grossWeight) -
|
|
|
Number(boxWeight) -
|
|
|
Number(canisterWeight) * Number(canisterNum)
|
|
|
).toFixed(2);
|
|
|
- console.log(row);
|
|
|
},
|
|
|
// 删除表格一条数据回调
|
|
|
async handleDeleteOne(index, row) {
|
|
|
- console.log(row);
|
|
|
this.$modal
|
|
|
.confirm("是否确认该条打印记录?")
|
|
|
.then(function () {
|
|
@@ -1078,12 +1087,9 @@ export default {
|
|
|
// this.printShow = false;
|
|
|
// this.getList();
|
|
|
} else {
|
|
|
- console.log(res);
|
|
|
this.$message.error(`${msg}失败`);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
},
|
|
|
// 确认打印回调
|
|
|
printConfirmHandler(printData) {
|
|
@@ -1092,7 +1098,6 @@ export default {
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
- console.log("打印", this.printTableData);
|
|
|
this.printTableData.forEach((item) => {
|
|
|
item.qrCodeData = printData + "-" + item.boxNum;
|
|
|
});
|
|
@@ -1104,7 +1109,6 @@ export default {
|
|
|
this.tableData.push(this.printTableData[0]);
|
|
|
}
|
|
|
// 后端打印
|
|
|
- console.log("newPrintHandler");
|
|
|
// this.newPrintHandler();
|
|
|
},
|
|
|
// 获取机台选项数据
|
|
@@ -1116,13 +1120,13 @@ export default {
|
|
|
let res = await getLineOptionLsit(payLoad);
|
|
|
if (res.code == 200) {
|
|
|
this.lineOptions = res.rows;
|
|
|
- console.log(this.lineOptions);
|
|
|
+ if (this.lineOptions.length > 0 && this.excuteType == 1) {
|
|
|
+ this.form.machineTool = this.lineOptions[0].id;
|
|
|
+ this.machineToolChange(this.form.machineTool);
|
|
|
+ }
|
|
|
} else {
|
|
|
- console.log(res);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
},
|
|
|
// 补码打印回调
|
|
|
handleSuppleOne(row) {
|
|
@@ -1139,10 +1143,22 @@ export default {
|
|
|
let rowData = newData.machineTool
|
|
|
? JSON.parse(JSON.stringify(newData))
|
|
|
: this.tableData[0];
|
|
|
- console.log(rowData);
|
|
|
+ let timeStemp = new Date().getTime();
|
|
|
this.printTableData = [rowData];
|
|
|
+ this.printTableData[0].id = timeStemp;
|
|
|
+ // 先打印
|
|
|
+ this.changeGrossWeight(this.printTableData[0]);
|
|
|
+ // 后端打印
|
|
|
+ // await this.newPrintHandler();
|
|
|
+ // 前端打印
|
|
|
+ codeListPrint(this.printTableData, "printDom");
|
|
|
+ if (this.excuteType == 1) {
|
|
|
+ this.tableData.push(this.printTableData[0]);
|
|
|
+ }
|
|
|
+ // 后保存数据
|
|
|
let payLoad = {
|
|
|
...this.form,
|
|
|
+ id: timeStemp, //前端生成id
|
|
|
qrCodeId: rowData.qrCodeId,
|
|
|
qrCode: rowData.qrCode,
|
|
|
lotNum: rowData.lotNum,
|
|
@@ -1161,7 +1177,7 @@ export default {
|
|
|
let tempApiFun = productCodeList;
|
|
|
if (this.excuteType == 3 || this.excuteType == 2) {
|
|
|
//补码||修改
|
|
|
- this.printConfirmHandler(this.tableData[0].id);
|
|
|
+ // this.printConfirmHandler(this.tableData[0].id);
|
|
|
return;
|
|
|
}
|
|
|
this.changeGrossWeight(payLoad);
|
|
@@ -1174,16 +1190,12 @@ export default {
|
|
|
// return;
|
|
|
// }
|
|
|
// this.tableData[0].id = res.data;
|
|
|
- this.printTableData[0].id = res.data;
|
|
|
- console.log("printConfirmHandler");
|
|
|
- this.printConfirmHandler(res.data);
|
|
|
+ // this.printTableData[0].id = res.data;
|
|
|
+ // this.printConfirmHandler(res.data);
|
|
|
} else {
|
|
|
- console.log(res);
|
|
|
this.$message.error(`${msg}箱单失败`);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -1219,12 +1231,9 @@ export default {
|
|
|
this.printShow = false;
|
|
|
this.getList();
|
|
|
} else {
|
|
|
- console.log(res);
|
|
|
this.$message.error(`${msg}箱单失败`);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -1238,7 +1247,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
supplementCodeHandler() {
|
|
|
- console.log(this.form.id);
|
|
|
this.printConfirmHandler(this.form.id);
|
|
|
},
|
|
|
// 箱单号生成函数
|
|
@@ -1283,7 +1291,6 @@ export default {
|
|
|
levels,
|
|
|
remark,
|
|
|
} = this.form;
|
|
|
- console.log(this.currentRow);
|
|
|
let {
|
|
|
productName,
|
|
|
productSpecifications,
|
|
@@ -1330,7 +1337,6 @@ export default {
|
|
|
productId,
|
|
|
});
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
@@ -1342,7 +1348,6 @@ export default {
|
|
|
},
|
|
|
// 表格点击回调
|
|
|
async handleCurrentChange(val) {
|
|
|
- console.log("row", val);
|
|
|
if (!val) return;
|
|
|
if (this.isStartReadNum || this.excuteType != 1) {
|
|
|
this.$refs.proTableRef.setCurrentRow(this.currentRow);
|
|
@@ -1370,7 +1375,6 @@ export default {
|
|
|
},
|
|
|
// 选择打印数据回调
|
|
|
handlePrintOneChange(row) {
|
|
|
- console.log(row);
|
|
|
if (!this.chooseState) return;
|
|
|
this.$alert("是否确定打印该数据", "确认打印", {
|
|
|
confirmButtonText: "确定",
|
|
@@ -1417,12 +1421,9 @@ export default {
|
|
|
row.id = res.data;
|
|
|
this.printConfirmHandler(res.data);
|
|
|
} else {
|
|
|
- console.log(res);
|
|
|
this.$message.error(`${msg}箱单失败`);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -1438,11 +1439,8 @@ export default {
|
|
|
this.batchData = res.data;
|
|
|
this.batchTableData = res.data;
|
|
|
} else {
|
|
|
- console.log(res);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(res);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
},
|
|
|
// 批号查询接口
|
|
|
batchNumChange() {
|
|
@@ -1459,13 +1457,40 @@ export default {
|
|
|
try {
|
|
|
let res = await getOptionLsit();
|
|
|
if (res.code == 200) {
|
|
|
- this.dropDownData = res.data;
|
|
|
+ this.dropDownData = res.data || {};
|
|
|
+ // 初始化默认值
|
|
|
+ if (
|
|
|
+ this.dropDownData.work_shifts?.length > 0 &&
|
|
|
+ this.excuteType == 1
|
|
|
+ ) {
|
|
|
+ this.form.workShifts = this.dropDownData.work_shifts[0].codeName;
|
|
|
+ }
|
|
|
+ if (this.dropDownData.level?.length > 0 && this.excuteType == 1) {
|
|
|
+ this.form.levels = this.dropDownData.level[0].codeName;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ this.dropDownData.drum_weight?.length > 0 &&
|
|
|
+ this.excuteType == 1
|
|
|
+ ) {
|
|
|
+ this.form.canisterWeight =
|
|
|
+ this.dropDownData.drum_weight[0].codeName;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ this.dropDownData.box_weight?.length > 0 &&
|
|
|
+ this.excuteType == 1
|
|
|
+ ) {
|
|
|
+ this.form.boxWeight = this.dropDownData.box_weight[0].codeName;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ this.dropDownData.tube_color?.length > 0 &&
|
|
|
+ this.excuteType == 1
|
|
|
+ ) {
|
|
|
+ this.form.tubeColor = this.dropDownData.tube_color[0].codeName;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$message.error("网络异常!");
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.log(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
},
|
|
|
/** 查询产品码单列表 */
|
|
|
getList() {
|
|
@@ -1548,6 +1573,8 @@ export default {
|
|
|
this.excuteType = 1;
|
|
|
this.reset();
|
|
|
|
|
|
+ this.form.productionDate = new Date();
|
|
|
+
|
|
|
await this.getAllBatchData(); //获取所有产品数据
|
|
|
await this.getLineOptionLsit(); //获取机台选项数据
|
|
|
await this.getSelectOptions();
|
|
@@ -1555,7 +1582,6 @@ export default {
|
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(qrCode) {
|
|
|
- console.log(qrCode);
|
|
|
this.reset();
|
|
|
const id = qrCode;
|
|
|
getPrintDataNew(id).then(async (response) => {
|
|
@@ -1570,7 +1596,6 @@ export default {
|
|
|
this.initProductData();
|
|
|
this.printShow = true;
|
|
|
} else {
|
|
|
- console.log(response);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -1596,7 +1621,6 @@ export default {
|
|
|
initProductData() {
|
|
|
this.batchNum = this.form.lotNum;
|
|
|
this.batchNumChange();
|
|
|
- console.log(this.batchTableData);
|
|
|
if (this.batchTableData.length) {
|
|
|
let {
|
|
|
machineTool,
|