From bab182edef950902191ef2160d7a488dc2aa0b17 Mon Sep 17 00:00:00 2001 From: xs Date: Wed, 10 Jul 2024 17:21:06 +0800 Subject: [PATCH] =?UTF-8?q?2.5.7=20mes:=20=E5=8E=9F=E6=9D=90=E6=96=99?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=EF=BC=9A=E9=87=87=E8=B4=AD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=92=8C=E6=97=A0=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hw/mes/api/domain/MesBaseBarcodeInfo.java | 11 + .../hw/common/core/constant/MesConstants.java | 4 + .../MesBaseBarcodeInfoController.java | 12 + .../impl/MesBaseBarcodeInfoServiceImpl.java | 258 ++++++++++------- hw-ui/src/views/mes/barcode/index.vue | 263 +++++++++++++++--- 5 files changed, 404 insertions(+), 144 deletions(-) diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java index 0ebca48a..f829f6d9 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java @@ -158,6 +158,9 @@ public class MesBaseBarcodeInfo extends BaseEntity private BigDecimal dispatchAmount;//派工数量 + private String barcodeTypeStr;//物料类型多个string,例如 1,9 + + public String getPrintFlag() { return printFlag; } @@ -491,6 +494,14 @@ public class MesBaseBarcodeInfo extends BaseEntity this.dispatchAmount = dispatchAmount; } + public String getBarcodeTypeStr() { + return barcodeTypeStr; + } + + public void setBarcodeTypeStr(String barcodeTypeStr) { + this.barcodeTypeStr = barcodeTypeStr; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java index 51943122..64cbd1f0 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java @@ -28,6 +28,10 @@ public class MesConstants { * 条码类型:背板 */ public static final String MES_BARCODE_TYPE_BACKPLATE = "4"; + /** + * 条码类型:固定原材料条码 + */ + public static final String MES_BARCODE_TYPE_RAW_REGULAR = "9"; /** 条码批次标识;0-否 */ public static final String NOT_IS_BATCH = "0"; diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java index 5b07334c..5976a943 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java @@ -259,4 +259,16 @@ public class MesBaseBarcodeInfoController extends BaseController } + /** + * 新增固定原材料条码信息 + */ + @RequiresPermissions("mes:barcode:regularAdd") + @Log(title = "条码信息", businessType = BusinessType.INSERT) + @PostMapping(value="/addRegularBarcode") + public AjaxResult addRegularBarcode(@RequestBody MesBaseBarcodeInfo mesBaseBarcodeInfo) + { + return toAjax(mesBaseBarcodeInfoService.generateRegularRawBarcode(mesBaseBarcodeInfo)); + } + + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java index 21d32075..2c9534fd 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java @@ -29,6 +29,7 @@ import com.hw.printer.api.domain.vo.PrinterVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.mes.service.IMesBaseBarcodeInfoService; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -216,6 +217,30 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService } + /** + * 生成固定条码信息 + * @param mesBaseBarcodeInfo + */ + @Override + public int generateRegularRawBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + + String barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode); + mesBaseBarcodeInfo.setBarcodeInfo(barcodeInfo); + mesBaseBarcodeInfo.setBatchCode(barcodeInfo); + mesBaseBarcodeInfo.setPrintFlag(MesConstants.MES_BARCODE_PRINT_FLAG_YES); + mesBaseBarcodeInfo.setBatchFlag(MesConstants.IS_BATCH); + mesBaseBarcodeInfo.setBarcodeType(MesConstants.MES_BARCODE_TYPE_RAW_REGULAR); + mesBaseBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES); + mesBaseBarcodeInfo.setCreateBy(userName); + mesBaseBarcodeInfo.setCreateTime(currentDate); + + return mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo); + + } + + public void generateProductBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { String planCode = mesBaseBarcodeInfo.getPlanCode(); String planDetailCode = mesBaseBarcodeInfo.getPlanDetailCode(); @@ -336,147 +361,172 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService * @return */ @Override - @Transactional(rollbackFor = Exception.class) + @Transactional public int printBarcodes(Long[] barcodeIds, String printType) { //获取条码List List> printContents = new ArrayList<>(); List toUpdatedBaseBarcodeInfos = new ArrayList<>(); for (Long barcodeId : barcodeIds) { - MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoJoinByBarcodeId(barcodeId); - String printFlag = mesBaseBarcodeInfo.getPrintFlag(); - if (printFlag.equals(MesConstants.MES_BARCODE_PRINT_FLAG_YES)) { - throw new ServiceException("此物料条码[" + mesBaseBarcodeInfo.getBarcodeInfo() + "]已经打印过,不能重复打印"); - } + printBarcodesByBarcodeId(barcodeId,printType); + } - String materialName = mesBaseBarcodeInfo.getMaterialName(); - List printContentVos = new ArrayList<>(); +// for (MesBaseBarcodeInfo toUpdateMesBaseBarcodeInfo : toUpdatedBaseBarcodeInfos) { +// toUpdateMesBaseBarcodeInfo.setPrintTime(DateUtils.getNowDate()); +// toUpdateMesBaseBarcodeInfo.setPrintPerson(SecurityUtils.getUsername()); +// toUpdateMesBaseBarcodeInfo.setPrintFlag(MesConstants.MES_BARCODE_PRINT_FLAG_YES); +// toUpdateMesBaseBarcodeInfo.setPrintNumber(1L); +// toUpdateMesBaseBarcodeInfo.setAcceptedDate(DateUtils.getNowDate()); +// this.updateMesBaseBarcodeInfo(toUpdateMesBaseBarcodeInfo); +// } +// +// PrinterVo printerVo = new PrinterVo(); +// printerVo.setPrintType(printType); +// printerVo.setPrintContents(printContents); +// +// //调用的打印接口 +// R printResultR = remotePrinterService.printBarcodes(printerVo, SecurityConstants.INNER); +// if (printResultR.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 +// throw new RuntimeException(printResultR.getMsg()); +// } - PrintContentVo printMaterialCode = new PrintContentVo(); - printMaterialCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_CODE); - printMaterialCode.setValue(mesBaseBarcodeInfo.getMaterialCode()); - printMaterialCode.setType(PrintContentVo.TYPE_TEXT); + return toUpdatedBaseBarcodeInfos.size(); - PrintContentVo printPreMaterial = new PrintContentVo(); + } + + + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void printBarcodesByBarcodeId(Long barcodeId,String printType){ + MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoJoinByBarcodeId(barcodeId); + String printFlag = mesBaseBarcodeInfo.getPrintFlag(); + if (printFlag.equals(MesConstants.MES_BARCODE_PRINT_FLAG_YES)) { + throw new ServiceException("此物料条码[" + mesBaseBarcodeInfo.getBarcodeInfo() + "]已经打印过,不能重复打印"); + } + + String materialName = mesBaseBarcodeInfo.getMaterialName(); + List printContentVos = new ArrayList<>(); + + PrintContentVo printMaterialCode = new PrintContentVo(); + printMaterialCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_CODE); + printMaterialCode.setValue(mesBaseBarcodeInfo.getMaterialCode()); + printMaterialCode.setType(PrintContentVo.TYPE_TEXT); + + PrintContentVo printPreMaterial = new PrintContentVo(); // if (mesBaseBarcodeInfo.getBindFlag() == null) { // // } - PrintContentVo printSaleOrderCode = new PrintContentVo(); - printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE); - printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode()); - printSaleOrderCode.setType(PrintContentVo.TYPE_TEXT); + PrintContentVo printSaleOrderCode = new PrintContentVo(); + printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE); + printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode()); + printSaleOrderCode.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printBarCode = new PrintContentVo(); - printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE); - printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo()); - printBarCode.setType(PrintContentVo.TYPE_QRCODE); + PrintContentVo printBarCode = new PrintContentVo(); + printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE); + printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo()); + printBarCode.setType(PrintContentVo.TYPE_QRCODE); - if (printType.equals(PrinterVo.PRINT_TYPE_RAW_LABEL)) { - PrintContentVo printMaterialName = new PrintContentVo(); - printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); - materialName = materialName.length() <= 10 ? "\n" + materialName : materialName; - printMaterialName.setValue(materialName); - printMaterialName.setType(PrintContentVo.TYPE_TEXT); + if (printType.equals(PrinterVo.PRINT_TYPE_RAW_LABEL)) { + PrintContentVo printMaterialName = new PrintContentVo(); + printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); + materialName = materialName.length() <= 10 ? "\n" + materialName : materialName; + printMaterialName.setValue(materialName.replaceAll("[\\x00-\\x1F\\x7F-\\x9F]", "")); + printMaterialName.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printBatchCode = new PrintContentVo(); - printBatchCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_BATCH_CODE); - printBatchCode.setValue(mesBaseBarcodeInfo.getBatchCode()); - printBatchCode.setType(PrintContentVo.TYPE_TEXT); + PrintContentVo printBatchCode = new PrintContentVo(); + printBatchCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_BATCH_CODE); + printBatchCode.setValue(mesBaseBarcodeInfo.getBatchCode()); + printBatchCode.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printPoNo = new PrintContentVo(); - printPoNo.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_PO_NO); - printPoNo.setValue(mesBaseBarcodeInfo.getPoNo()); - printPoNo.setType(PrintContentVo.TYPE_TEXT); + PrintContentVo printPoNo = new PrintContentVo(); + printPoNo.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_PO_NO); + printPoNo.setValue(mesBaseBarcodeInfo.getPoNo()); + printPoNo.setType(PrintContentVo.TYPE_TEXT); - String printPreMaterialKey = mesBaseBarcodeInfo.getBindFlag() != null && mesBaseBarcodeInfo.getBindFlag().equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES) - ? PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_YES : PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_NO; - printPreMaterial.setKey(printPreMaterialKey); - printPreMaterial.setType(PrintContentVo.TYPE_CHECKBOX); + String printPreMaterialKey = mesBaseBarcodeInfo.getBindFlag() != null && mesBaseBarcodeInfo.getBindFlag().equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES) + ? PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_YES : PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_NO; + printPreMaterial.setKey(printPreMaterialKey); + printPreMaterial.setType(PrintContentVo.TYPE_CHECKBOX); - PrintContentVo printMaterialSpec = new PrintContentVo(); - printMaterialSpec.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_SPEC); - printMaterialSpec.setValue(mesBaseBarcodeInfo.getMaterialSpec()); - printMaterialSpec.setType(PrintContentVo.TYPE_TEXT); + PrintContentVo printMaterialSpec = new PrintContentVo(); + printMaterialSpec.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_SPEC); + printMaterialSpec.setValue(mesBaseBarcodeInfo.getMaterialSpec().replaceAll("[\\x00-\\x1F\\x7F-\\x9F]", "")); + printMaterialSpec.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printQty = new PrintContentVo(); - printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); - DecimalFormat df = new DecimalFormat("#.##"); - String formattedNumber = df.format(mesBaseBarcodeInfo.getAmount()); - printQty.setValue(formattedNumber); - printQty.setType(PrintContentVo.TYPE_TEXT); + PrintContentVo printQty = new PrintContentVo(); + printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); + DecimalFormat df = new DecimalFormat("#.##"); + String formattedNumber = df.format(mesBaseBarcodeInfo.getAmount()); + printQty.setValue(formattedNumber); + printQty.setType(PrintContentVo.TYPE_TEXT); - printContentVos.add(printMaterialName); - printContentVos.add(printBatchCode); - printContentVos.add(printPoNo); - printContentVos.add(printMaterialSpec); - printContentVos.add(printQty); + printContentVos.add(printMaterialName); + printContentVos.add(printBatchCode); + printContentVos.add(printPoNo); + printContentVos.add(printMaterialSpec); + printContentVos.add(printQty); - } else if (printType.equals(PrinterVo.PRINT_TYPE_PRODUCT_LABEL)) { - PrintContentVo printMaterialName = new PrintContentVo(); - materialName = materialName.length() <= 8 ? "\n" + materialName : materialName; - printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); - printMaterialName.setValue(materialName); - printMaterialName.setType(PrintContentVo.TYPE_TEXT); + } else if (printType.equals(PrinterVo.PRINT_TYPE_PRODUCT_LABEL)) { + PrintContentVo printMaterialName = new PrintContentVo(); + materialName = materialName.length() <= 8 ? "\n" + materialName : materialName; + printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); + printMaterialName.setValue(materialName); + printMaterialName.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printQty = new PrintContentVo(); - printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); - printQty.setValue("1"); - printQty.setType(PrintContentVo.TYPE_TEXT); + PrintContentVo printQty = new PrintContentVo(); + printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); + printQty.setValue("1"); + printQty.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printPlanCode = new PrintContentVo(); - printPlanCode.setKey(PrintContentVo.PRODUCT_PLAN_CODE); - printPlanCode.setValue(mesBaseBarcodeInfo.getPlanCode()); - printPlanCode.setType(PrintContentVo.TYPE_TEXT); - printContentVos.add(printMaterialName); - printContentVos.add(printQty); - printContentVos.add(printPlanCode); - } - - printContentVos.add(printMaterialCode); - printContentVos.add(printPreMaterial); - printContentVos.add(printSaleOrderCode); - printContentVos.add(printBarCode); - - String checkStatus = mesBaseBarcodeInfo.getCheckStatus() == null ? "" : mesBaseBarcodeInfo.getCheckStatus(); - if (checkStatus.equals(QmsConstants.QMS_CHECK_RESULT_CHECK_STATUS_PASS)) { - PrintContentVo printQcResult = new PrintContentVo(); - printQcResult.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QC_RESULT_YES); - printQcResult.setType(PrintContentVo.TYPE_CHECKBOX); - printContentVos.add(printQcResult); - } else if (checkStatus.equals(QmsConstants.QMS_CHECK_RESULT_CHECK_STATUS_FAIL)) { - PrintContentVo printQcResult = new PrintContentVo(); - printQcResult.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QC_RESULT_NO); - printQcResult.setType(PrintContentVo.TYPE_CHECKBOX); - printContentVos.add(printQcResult); - } - - printContents.add(printContentVos); - toUpdatedBaseBarcodeInfos.add(mesBaseBarcodeInfo); + PrintContentVo printPlanCode = new PrintContentVo(); + printPlanCode.setKey(PrintContentVo.PRODUCT_PLAN_CODE); + printPlanCode.setValue(mesBaseBarcodeInfo.getPlanCode()); + printPlanCode.setType(PrintContentVo.TYPE_TEXT); + printContentVos.add(printMaterialName); + printContentVos.add(printQty); + printContentVos.add(printPlanCode); } - for (MesBaseBarcodeInfo toUpdateMesBaseBarcodeInfo : toUpdatedBaseBarcodeInfos) { - toUpdateMesBaseBarcodeInfo.setPrintTime(DateUtils.getNowDate()); - toUpdateMesBaseBarcodeInfo.setPrintPerson(SecurityUtils.getUsername()); - toUpdateMesBaseBarcodeInfo.setPrintFlag(MesConstants.MES_BARCODE_PRINT_FLAG_YES); - toUpdateMesBaseBarcodeInfo.setPrintNumber(1L); - toUpdateMesBaseBarcodeInfo.setAcceptedDate(DateUtils.getNowDate()); - this.updateMesBaseBarcodeInfo(toUpdateMesBaseBarcodeInfo); + printContentVos.add(printMaterialCode); + printContentVos.add(printPreMaterial); + printContentVos.add(printSaleOrderCode); + printContentVos.add(printBarCode); + + String checkStatus = mesBaseBarcodeInfo.getCheckStatus() == null ? "" : mesBaseBarcodeInfo.getCheckStatus(); + if (checkStatus.equals(QmsConstants.QMS_CHECK_RESULT_CHECK_STATUS_PASS)) { + PrintContentVo printQcResult = new PrintContentVo(); + printQcResult.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QC_RESULT_YES); + printQcResult.setType(PrintContentVo.TYPE_CHECKBOX); + printContentVos.add(printQcResult); + } else if (checkStatus.equals(QmsConstants.QMS_CHECK_RESULT_CHECK_STATUS_FAIL)) { + PrintContentVo printQcResult = new PrintContentVo(); + printQcResult.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QC_RESULT_NO); + printQcResult.setType(PrintContentVo.TYPE_CHECKBOX); + printContentVos.add(printQcResult); } +// printContents.add(printContentVos); +// toUpdatedBaseBarcodeInfos.add(mesBaseBarcodeInfo); + + mesBaseBarcodeInfo.setPrintTime(DateUtils.getNowDate()); + mesBaseBarcodeInfo.setPrintPerson(SecurityUtils.getUsername()); + mesBaseBarcodeInfo.setPrintFlag(MesConstants.MES_BARCODE_PRINT_FLAG_YES); + mesBaseBarcodeInfo.setPrintNumber(1L); + mesBaseBarcodeInfo.setAcceptedDate(DateUtils.getNowDate()); + this.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo); + + PrinterVo printerVo = new PrinterVo(); printerVo.setPrintType(printType); - printerVo.setPrintContents(printContents); + printerVo.setPrintContentVos(printContentVos); //调用的打印接口 R printResultR = remotePrinterService.printBarcodes(printerVo, SecurityConstants.INNER); - if (printResultR.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 + if (printResultR.getCode() != Constants.SUCCESS) { throw new RuntimeException(printResultR.getMsg()); } - return toUpdatedBaseBarcodeInfos.size(); - } diff --git a/hw-ui/src/views/mes/barcode/index.vue b/hw-ui/src/views/mes/barcode/index.vue index 8121bd45..600e6fad 100644 --- a/hw-ui/src/views/mes/barcode/index.vue +++ b/hw-ui/src/views/mes/barcode/index.vue @@ -74,6 +74,18 @@ + + 固定条码新增 + + + - + --> - + 批次数量 - + @@ -403,9 +415,6 @@ - - - @@ -414,7 +423,8 @@ - + @@ -422,7 +432,7 @@ - + --> - + 批次数量 - + @@ -480,11 +490,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -500,7 +557,7 @@ import { listBarcode, getBarcode, delBarcode, addBarcode, updateBarcode, printBarcodes, getMaterialInfoByErpId, selectProductBarcodeInfoByBarcodeInfo, - addInternalBarcode, regenerateBarcode,addNoPurchaseBarcode + addInternalBarcode, regenerateBarcode, addNoPurchaseBarcode, addRegularBarcode } from "@/api/mes/barcode"; import addPurchaseOrder from '@//views/mes/purchaseOrder/addPurchaseOrder.vue'; import selectMaterial from '@//views/mes/materialinfo/selectMaterial.vue'; @@ -525,8 +582,6 @@ export default { multiple: true, // 显示搜索条件 showSearch: true, - //批次显示 - batchVisible: false, // 总条数 total: 0, // 条码信息表格数据 @@ -535,7 +590,7 @@ export default { purchaseOrderOpen: false, //是否显示选择物料弹出层 - selectMaterialVisible:false, + selectMaterialVisible: false, // 弹出层标题 title: "", // 是否显示弹出层 @@ -547,7 +602,7 @@ export default { printTime: null, printPerson: null, batchFlag: null, - barcodeType: '1', + barcodeType: "1", barcodeInfo: null, batchCode: null, palletInfoCode: null, @@ -655,6 +710,11 @@ export default { noPurchaseOpen: false, // 对内条码表单参数 noPurchaseForm: {}, + noPurchaseBatchFlagDisable: true, + noPurchaseBatchAmountDisabled: true, + + saleBatchFlagDisable: true, + saleBatchAmountDisabled: true, // 表单校验 noPurchaseRules: { batchFlag: [ @@ -666,12 +726,30 @@ export default { barcodeAmount: [ {required: true, message: "条码数量不能为空", trigger: "change"} ], - materialCode: [ - {required: true, message: "物料不能为空", trigger: "blur"} + materialCode11: [ + {required: true, message: "物料不能为空", trigger: "change"} ], }, - batchPrintBtnDisabled: false + regularOpen: false, + // 固定条码表单参数 + regularForm: {}, + // 表单校验 + regularRules: { + materialCode2: [ + { + required: true, message: "物料不能为空", trigger: ["blur", "change"] + } + ], + + }, + + batchPrintBtnDisabled: false, + + BATCH_FLAG: { + YES: '1', + NO: '0' + } }; }, created() { @@ -776,24 +854,30 @@ export default { this.form.poNo = selectedRow.poNo; this.form.barcodeAmount = selectedRow.orderAmount; + this.form.batchFlag = null; + this.form.amount = null; + getMaterialInfoByErpId(selectedRow.materialId).then(response => { if (response.data == null) { this.$modal.msgError("物料信息不存在"); return; } + if (response.data.batchFlag != null) { this.form.batchFlag = response.data.batchFlag; this.form.materialId = response.data.materialId; - if (this.form.batchFlag == "0") { - this.batchVisible = false; - } else { + this.saleBatchFlagDisable = true; + if (this.form.batchFlag === this.BATCH_FLAG.YES) { this.form.amount = response.data.batchAmount; - this.batchVisible = true; + } else { + this.form.amount = 1; } } else { - this.batchVisible = true; + this.saleBatchFlagDisable = false; } + this.saleBatchAmountDisabled = this.form.amount != null && this.form.amount > 0; + this.purchaseOrderOpen = false; }); }, @@ -807,7 +891,7 @@ export default { /** 打印条码按钮操作 */ handlePrintBarcodes(row) { const barcodeIds = row.barcodeId || this.ids; - if (barcodeIds == null || barcodeIds == '') { + if (barcodeIds == null || barcodeIds === '') { this.$modal.msgWarning("请选择要打印的物料条码"); return; } @@ -939,7 +1023,7 @@ export default { }, selectProductBarcodeInfoByBarcodeInfo() { - if(this.internalForm.productBarcode == null || this.internalForm.productBarcode === ''){ + if (this.internalForm.productBarcode == null || this.internalForm.productBarcode === '') { return; } @@ -1021,32 +1105,44 @@ export default { /** 无采购订单新增按钮操作 */ handleNoPurchaseAdd() { - this.reset(); + this.resetNoPurchase(); this.noPurchaseOpen = true; this.title = "添加原材料条码信息"; }, - handleSelectMaterial(){ + + handleSelectMaterial() { this.selectMaterialVisible = true; }, /** 提交选择物料按钮 */ submitSelectMaterialForm() { - let selectedRow = this.$refs.selectMaterialRef.selectedRow; - this.noPurchaseForm.barcodeType = '1';//条码类型(1原材料,2半成品,3成品,4背板) - this.noPurchaseForm.materialId = selectedRow.materialId; - this.noPurchaseForm.materialCode = selectedRow.materialCode; - this.noPurchaseForm.materialName = selectedRow.materialName; - this.noPurchaseForm.batchFlag = selectedRow.batchFlag; + if (this.noPurchaseOpen) { + let selectedRow = this.$refs.selectMaterialRef.selectedRow; + this.noPurchaseForm.barcodeType = '1';//条码类型(1原材料,2半成品,3成品,4背板) + this.noPurchaseForm.materialId = selectedRow.materialId; + this.noPurchaseForm.materialCode = selectedRow.materialCode; + this.noPurchaseForm.materialName = selectedRow.materialName; + this.noPurchaseForm.batchFlag = selectedRow.batchFlag; - if (this.noPurchaseForm.batchFlag === "0") { - this.batchVisible = false; - } else { - this.noPurchaseForm.amount = selectedRow.batchAmount; - this.batchVisible = true; + if (this.noPurchaseForm.batchFlag == null || this.noPurchaseForm.batchFlag === '') { + this.noPurchaseBatchFlagDisable = false; + } else { + this.noPurchaseBatchFlagDisable = true; + if (this.noPurchaseForm.batchFlag === this.BATCH_FLAG.NO) { + this.noPurchaseForm.amount = 1; + } else if (this.noPurchaseForm.batchFlag === this.BATCH_FLAG.YES) { + this.noPurchaseForm.amount = selectedRow.batchAmount; + } + } + + this.noPurchaseBatchAmountDisabled = this.noPurchaseForm.amount != null && this.noPurchaseForm.amount > 0; + + this.selectMaterialVisible = false; + } else if (this.regularOpen) { + this.submitRegularSelectMaterialForm(); } - this.selectMaterialVisible = false; }, @@ -1065,6 +1161,93 @@ export default { }); }, + // 取消按钮 + cancelNoPurchase() { + this.noPurchaseOpen = false; + this.resetNoPurchase(); + }, + + + // 表单重置 + resetRegular() { + this.regularForm = { + barcodeId: null, + printTime: null, + printPerson: null, + batchFlag: null, + barcodeType: '1', + barcodeInfo: null, + batchCode: null, + palletInfoCode: null, + materialId: null, + manufacturerId: null, + amount: null, + barcodeAmount: null, + machineName: null, + printNumber: null, + poNo: null, + productionDate: null, + acceptedDate: null, + lastOutstockDate: null, + planCode: null, + planDetailCode: null, + saleOrderId: null, + saleorderCode: null, + projectNo: null, + serialNumber: null, + remark: null, + bindStatus: null, + bindBy: null, + bindTime: null, + updateBy: null, + updateTime: null + }; + this.resetForm("regularForm"); + }, + + /** 固定条码新增按钮操作 */ + handleRegularAdd() { + this.resetRegular(); + this.regularOpen = true; + this.title = "添加原材料条码信息"; + }, + + + /** 提交选择物料按钮 */ + submitRegularSelectMaterialForm() { + let selectedRow = this.$refs.selectMaterialRef.selectedRow; + this.regularForm.barcodeType = '9';//条码类型(1原材料,2半成品,3成品,4背板,9固定条码) + this.regularForm.materialId = selectedRow.materialId; + this.regularForm.materialCode = selectedRow.materialCode; + this.regularForm.materialName = selectedRow.materialName; + this.regularForm.materialSpec = selectedRow.materialSpec; + + this.selectMaterialVisible = false; + + }, + + + /** 固定条码新增提交按钮 */ + submitRegularAddForm() { + this.$refs["regularForm"].validate(valid => { + if (valid) { + addRegularBarcode(this.regularForm).then(response => { + this.$modal.msgSuccess("新增成功"); + this.regularOpen = false; + this.getList(); + }); + + } + }); + }, + + // 取消按钮 + cancelRegular() { + this.regularOpen = false; + this.resetRegular(); + }, + + } };