|
@@ -125,9 +125,9 @@
|
|
|
<el-table-column label="色泽" align="center" prop="productColor" />
|
|
|
<!-- <el-table-column label="货品编号" align="center" prop="productId" /> -->
|
|
|
<el-table-column label="等级" align="center" prop="levels" />
|
|
|
- <el-table-column label="筒数" align="center" prop="canisterNum" />
|
|
|
- <el-table-column label="箱数" align="center" prop="boxNum" />
|
|
|
- <el-table-column label="净重" align="center" prop="suttle" />
|
|
|
+ <el-table-column label="筒数" align="center" prop="totalCanisterNum" />
|
|
|
+ <el-table-column label="箱数" align="center" prop="totalBoxNum" />
|
|
|
+ <el-table-column label="净重" align="center" prop="totalSuttle" />
|
|
|
<el-table-column label="备注" align="center" prop="remark" />
|
|
|
<el-table-column
|
|
|
label="操作"
|
|
@@ -297,12 +297,28 @@
|
|
|
>打印</el-button
|
|
|
> -->
|
|
|
<el-button
|
|
|
+ v-if="!isDisabled"
|
|
|
:disabled="tableData.length != 1"
|
|
|
type="primary"
|
|
|
size="mini"
|
|
|
@click="getOrderData"
|
|
|
>{{ excuteType == 1 ? "箱单" : "保存修改" }}</el-button
|
|
|
>
|
|
|
+ <el-button
|
|
|
+ :disabled="tableData.length < 2"
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ @click="chooseOneToPrint"
|
|
|
+ >{{ chooseState ? "退出批箱单" : "批箱单" }}</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ :disabled="tableData.length != 1"
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ v-if="excuteType == 3"
|
|
|
+ @click="supplementCodeHandler"
|
|
|
+ >补码</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
<div class="msg" v-if="orderData.boxNo">
|
|
|
<div class="msg-item">
|
|
@@ -318,6 +334,7 @@
|
|
|
border
|
|
|
stripe
|
|
|
style="width: 100%; margin-bottom: 5px"
|
|
|
+ @cell-click="handlePrintOneChange"
|
|
|
>
|
|
|
<el-table-column
|
|
|
type="index"
|
|
@@ -341,7 +358,9 @@
|
|
|
<el-table-column prop="grossWeight" label="毛重">
|
|
|
<template slot-scope="scope">
|
|
|
<el-input
|
|
|
+ :disabled="isDisabled"
|
|
|
v-model="scope.row.grossWeight"
|
|
|
+ @input="changeGrossWeight(scope.row)"
|
|
|
size="mini"
|
|
|
clearable
|
|
|
></el-input>
|
|
@@ -356,6 +375,7 @@
|
|
|
<el-button
|
|
|
type="danger"
|
|
|
size="mini"
|
|
|
+ :disabled="chooseState"
|
|
|
@click="handleDeleteOne(scope.$index)"
|
|
|
>删除</el-button
|
|
|
>
|
|
@@ -406,6 +426,7 @@
|
|
|
label-width="80px"
|
|
|
:inline="false"
|
|
|
size="normal"
|
|
|
+ :disabled="isDisabled"
|
|
|
>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item prop="packaging" label="包装">
|
|
@@ -627,14 +648,15 @@
|
|
|
placeholder="请输入批号"
|
|
|
size="mini"
|
|
|
clearable
|
|
|
- @change="batchNumChange"
|
|
|
+ @input="batchNumChange"
|
|
|
@keyup.enter.native="batchNumChange"
|
|
|
+ :disabled="isDisabled"
|
|
|
></el-input>
|
|
|
<el-button
|
|
|
class="ml10"
|
|
|
type="primary"
|
|
|
size="mini"
|
|
|
- :disabled="!currentRow.lotNum"
|
|
|
+ :disabled="!currentRow.lotNum || isDisabled"
|
|
|
@click="addProductHandler"
|
|
|
>添加</el-button
|
|
|
>
|
|
@@ -682,15 +704,18 @@ import {
|
|
|
productCodeList,
|
|
|
getPrintData,
|
|
|
updateProductCodeList,
|
|
|
+ getQrCode,
|
|
|
} from "@/api/codeListManage/productCodeList";
|
|
|
import codeListPrint from "@/utils/print/codeListPrint";
|
|
|
-import { async } from "@/components/updateModule/k-form-design/lib/k-form-design.common";
|
|
|
+
|
|
|
export default {
|
|
|
name: "ProductCodeList",
|
|
|
dicts: ["packaging_type", "port", "coding_list_format"],
|
|
|
data() {
|
|
|
return {
|
|
|
// 自定义数据 start
|
|
|
+ printTableData: [], //需要打印的数据
|
|
|
+ chooseState: false, //批箱单打印状态
|
|
|
excuteType: false, //1:新增 2:编辑 3:补码
|
|
|
lineOptions: [], //机台选项数据
|
|
|
orderData: {
|
|
@@ -860,7 +885,23 @@ export default {
|
|
|
immediate: true,
|
|
|
},
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ isDisabled() {
|
|
|
+ return this.excuteType == 3;
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ // 毛重改变回调
|
|
|
+ changeGrossWeight(row) {
|
|
|
+ console.log(row);
|
|
|
+ let { boxWeight, grossWeight, canisterWeight, canisterNum } = row;
|
|
|
+ if (!Number(grossWeight)) return;
|
|
|
+ row.suttle = (
|
|
|
+ Number(grossWeight) -
|
|
|
+ Number(boxWeight) -
|
|
|
+ Number(canisterWeight) * Number(canisterNum)
|
|
|
+ ).toFixed(2);
|
|
|
+ },
|
|
|
// 删除表格一条数据回调
|
|
|
handleDeleteOne(index) {
|
|
|
this.tableData.splice(index, 1);
|
|
@@ -872,11 +913,11 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- console.log("打印", this.tableData);
|
|
|
- this.tableData.forEach((item) => {
|
|
|
+ console.log("打印", this.printTableData);
|
|
|
+ this.printTableData.forEach((item) => {
|
|
|
item.qrCodeData = printData + "-" + item.boxNumber;
|
|
|
});
|
|
|
- codeListPrint(this.tableData, "printDom");
|
|
|
+ codeListPrint(this.printTableData, "printDom");
|
|
|
},
|
|
|
// 获取机台选项数据
|
|
|
async getLineOptionLsit() {
|
|
@@ -913,18 +954,23 @@ export default {
|
|
|
try {
|
|
|
let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
|
|
|
this.count;
|
|
|
- let rowData = this.tableData[0];
|
|
|
+ let rowData = JSON.parse(JSON.stringify(this.tableData[0]));
|
|
|
+ this.printTableData = [rowData];
|
|
|
let payLoad = {
|
|
|
...this.form,
|
|
|
qrCode: rowData.qrCode,
|
|
|
lotNum: rowData.lotNum,
|
|
|
- boxNum: sumBoxNum,
|
|
|
+ // boxNum: sumBoxNum,
|
|
|
+ boxNum: rowData.boxNumber,
|
|
|
productId: rowData.productId,
|
|
|
- cartonNumber: sumCanisterNum,
|
|
|
- suttle: sumSuttle,
|
|
|
- grossWeight: sumGrossWeight,
|
|
|
+ // cartonNumber: rowData.canisterWeight,
|
|
|
+ suttle: rowData.suttle,
|
|
|
+ grossWeight: rowData.grossWeight,
|
|
|
productCodeListInfoList: this.tableData,
|
|
|
};
|
|
|
+ if (rowData.id) {
|
|
|
+ payLoad.id = rowData.id;
|
|
|
+ }
|
|
|
let tempApiFun = productCodeList;
|
|
|
if (this.excuteType == 1) {
|
|
|
tempApiFun = productCodeList;
|
|
@@ -937,8 +983,10 @@ export default {
|
|
|
this.$message.success(`${msg}箱单成功`);
|
|
|
if (this.excuteType != 1) {
|
|
|
this.printShow = false;
|
|
|
+ this.getList();
|
|
|
return;
|
|
|
}
|
|
|
+ this.tableData[0].id = res.data;
|
|
|
this.printConfirmHandler(res.data);
|
|
|
} else {
|
|
|
console.log(res);
|
|
@@ -950,6 +998,19 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 选择一个打印
|
|
|
+ chooseOneToPrint() {
|
|
|
+ this.chooseState = !this.chooseState; //开启选择状态
|
|
|
+ if (this.chooseState) {
|
|
|
+ this.$message.info("请选择打印的箱单");
|
|
|
+ } else {
|
|
|
+ this.$message.info("退出批箱单状态");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ supplementCodeHandler() {
|
|
|
+ console.log(this.form.id);
|
|
|
+ this.printConfirmHandler(this.form.id);
|
|
|
+ },
|
|
|
// 箱单号生成函数
|
|
|
getBoxOrderNum() {
|
|
|
let year = (new Date().getFullYear() + "").slice(-2);
|
|
@@ -975,10 +1036,11 @@ export default {
|
|
|
},
|
|
|
// 添加按钮回调
|
|
|
addProductHandler() {
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
+ this.$refs.form.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
let {
|
|
|
machineTool,
|
|
|
+ packaging,
|
|
|
boxWeight,
|
|
|
canisterWeight,
|
|
|
canisterNum,
|
|
@@ -1000,8 +1062,17 @@ export default {
|
|
|
directionOfTwist,
|
|
|
productId,
|
|
|
} = this.currentRow;
|
|
|
+ let res = await getQrCode();
|
|
|
+ let qrCode = "";
|
|
|
+ if (res.code == 200) {
|
|
|
+ qrCode = res.msg;
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.msg);
|
|
|
+ }
|
|
|
this.tableData.push({
|
|
|
- qrCode: this.getBoxOrderNum(), //箱单号
|
|
|
+ // qrCode: this.getBoxOrderNum(), //箱单号
|
|
|
+ packaging, //包装方式 1:车丝 2:小包装 3:大包装
|
|
|
+ qrCode, //箱单号
|
|
|
levels,
|
|
|
machineTool,
|
|
|
boxWeight,
|
|
@@ -1010,7 +1081,8 @@ export default {
|
|
|
workShifts,
|
|
|
tubeColor,
|
|
|
grossWeight: 0, //毛重
|
|
|
- suttle: this.getSuttle(), //净重
|
|
|
+ // suttle: this.getSuttle(), //净重
|
|
|
+ suttle: 0, //净重
|
|
|
boxNumber: this.tableData.length + 1, //序号
|
|
|
productionDate, //日期
|
|
|
printFormat, //格式
|
|
@@ -1034,10 +1106,70 @@ export default {
|
|
|
return (Number(boxWeight) - canisterWeight * canisterNum).toFixed(2);
|
|
|
},
|
|
|
// 表格点击回调
|
|
|
- handleCurrentChange(val) {
|
|
|
+ async handleCurrentChange(val) {
|
|
|
console.log("row", val);
|
|
|
this.currentRow = JSON.parse(JSON.stringify(val));
|
|
|
},
|
|
|
+ // 选择打印数据回调
|
|
|
+ handlePrintOneChange(row) {
|
|
|
+ console.log(row);
|
|
|
+ if (!this.chooseState) return;
|
|
|
+ this.$alert("是否确定打印该数据", "确认打印", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ callback: (action) => {
|
|
|
+ if (action === "confirm") {
|
|
|
+ this.$refs.form.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ try {
|
|
|
+ let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
|
|
|
+ this.count;
|
|
|
+ let rowData = JSON.parse(JSON.stringify(row));
|
|
|
+ this.printTableData = [rowData];
|
|
|
+ let payLoad = {
|
|
|
+ ...this.form,
|
|
|
+ qrCode: rowData.qrCode,
|
|
|
+ lotNum: rowData.lotNum,
|
|
|
+ boxNum: rowData.boxNumber,
|
|
|
+ productId: rowData.productId,
|
|
|
+ // cartonNumber: rowData.canisterWeight,
|
|
|
+ suttle: rowData.suttle,
|
|
|
+ grossWeight: rowData.grossWeight,
|
|
|
+ productCodeListInfoList: this.tableData,
|
|
|
+ };
|
|
|
+ if (rowData.id) {
|
|
|
+ payLoad.id = rowData.id;
|
|
|
+ }
|
|
|
+ let tempApiFun = productCodeList;
|
|
|
+ if (this.excuteType == 1) {
|
|
|
+ tempApiFun = productCodeList;
|
|
|
+ } else if (this.excuteType == 2) {
|
|
|
+ tempApiFun = updateProductCodeList;
|
|
|
+ }
|
|
|
+ let res = await tempApiFun(payLoad);
|
|
|
+ let msg = this.isEdit ? "编辑" : "新增";
|
|
|
+ if (res.code == 200) {
|
|
|
+ // this.$message.success(`${msg}箱单成功`);
|
|
|
+ if (this.excuteType != 1) {
|
|
|
+ this.printShow = false;
|
|
|
+ this.getList();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ row.id = res.data;
|
|
|
+ this.printConfirmHandler(res.data);
|
|
|
+ } else {
|
|
|
+ console.log(res);
|
|
|
+ this.$message.error(`${msg}箱单失败`);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
// 获取所有批次数据
|
|
|
async getAllBatchData() {
|
|
|
try {
|
|
@@ -1157,10 +1289,9 @@ export default {
|
|
|
this.reset();
|
|
|
const id = row.id || this.ids;
|
|
|
getPrintData(id).then(async (response) => {
|
|
|
- console.log(response);
|
|
|
- this.isEdit = 2;
|
|
|
+ this.excuteType = 2;
|
|
|
this.form = response.data;
|
|
|
- this.tableData = response.data.productCodeListInfoList;
|
|
|
+ this.tableData = response.data.productCodeListInfoList || [];
|
|
|
await this.getAllBatchData(); //获取所有产品数据
|
|
|
await this.getLineOptionLsit(); //获取机台选项数据
|
|
|
await this.getSelectOptions();
|
|
@@ -1168,7 +1299,49 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 补码回调
|
|
|
- supplementCode() {},
|
|
|
+ supplementCode(row) {
|
|
|
+ this.reset();
|
|
|
+ const id = row.id || this.ids;
|
|
|
+ getPrintData(id).then(async (response) => {
|
|
|
+ this.excuteType = 3; //补码
|
|
|
+ this.form = response.data;
|
|
|
+ this.tableData = response.data.productCodeListInfoList;
|
|
|
+ await this.getAllBatchData(); //获取所有产品数据
|
|
|
+ await this.getLineOptionLsit(); //获取机台选项数据
|
|
|
+ await this.getSelectOptions();
|
|
|
+ this.initProductData();
|
|
|
+ this.printShow = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 初始化产品相关数据
|
|
|
+ initProductData() {
|
|
|
+ this.batchNum = this.form.lotNum;
|
|
|
+ this.batchNumChange();
|
|
|
+ if (Object.keys(this.currentRow).length) {
|
|
|
+ let {
|
|
|
+ machineTool,
|
|
|
+ boxWeight,
|
|
|
+ canisterWeight,
|
|
|
+ canisterNum,
|
|
|
+ grossWeight,
|
|
|
+ suttle, //净重
|
|
|
+ workShifts, //班次
|
|
|
+ tubeColor,
|
|
|
+ productionDate,
|
|
|
+ printFormat,
|
|
|
+ levels,
|
|
|
+ remark,
|
|
|
+ } = this.form;
|
|
|
+ let {
|
|
|
+ productName,
|
|
|
+ productSpecifications,
|
|
|
+ productColor,
|
|
|
+ lotNum,
|
|
|
+ directionOfTwist,
|
|
|
+ productId,
|
|
|
+ } = this.currentRow;
|
|
|
+ }
|
|
|
+ },
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
this.$refs["form"].validate((valid) => {
|