admin
2024-01-12 3cc468703cb525bfcb1d9a1089c8e8c335e66487
guns-vip-main/src/main/webapp/assets/modular/kb/materialRegistration/materialRegistration.js
@@ -31,11 +31,12 @@
    async function initPageInfo() {
        await initKanBanConfInfo();//初始化配置信息
        await initOrderInfo();
        initBomTable();
       // initBomTable();
        initMaterialShortage();
     /*   xR();
        xa();*/
    }
@@ -87,7 +88,7 @@
    function initBomTable(){
        var queryData = {};
        queryData['loadingCode'] = $("#locationCode").val();
        // queryData['loadingCode'] = $("#locationCode").val();
        // queryData['workOrderNo'] = $("#workOrderNo").val();
        // 渲染表格
@@ -115,7 +116,7 @@
            // {field: 'workorderNo', sort: true, title: '工单编号'},
            // {field: 'productCode', sort: true, title: '产品编号'},
            {field: 'locationCode', sort: true, title: '工位编号'},
            {field: 'loadingCode', sort: true, title: '上料工位编号'},
           // {field: 'loadingCode', sort: true, title: '上料工位编号'},
            // {field: 'state', sort: true, title: '是否扫码'},
            // {field: 'batchCode', sort: true, title: '批次码'},
        ]];
@@ -126,22 +127,28 @@
     */
    MaterialShortage.initColumn = function () {
        return [[
            {type: 'numbers'},
            {type: 'checkbox', fixed: 'left'},
            {field: 'id', hide: true, title: 'ID'},
            {field: 'workOrderNo', sort: true, title: '工单号', width: 165},
          /*  {field: 'workOrderNo', sort: true, title: '工单号', width: 150},*/
            // {field: 'loadingCode', sort: true, title: '上料工位', width: 105},
            {field: 'locationCode', sort: true, title: '工位编号', width: 105},
            {field: 'loadingCode', sort: true, title: '扫码工位编号', width: 105},
            {field: 'materialCode', sort: true, title: '物料编码'},
            {field: 'barCode', sort: true, title: '扫码编号'},
            {field: 'state', sort: true, title: '是否扫码', width: 105},
            {field: 'locationCode', sort: true, title: '工位编号', width: 100},
            //{field: 'loadingCode', sort: true, title: '扫码工位编号', width: 105},
            {field: 'materialCode', sort: true, title: '物料编码', width: 170},
            {field: 'batch', sort: true, title: '物料批次',width: 120},
            {field: 'quantity', sort: true, title: '上料数量',width: 120},
            {field: 'residueQuantity', sort: true, title: '剩余数量',width: 120},
            {field: 'unit', sort: true, title: '单位'},
            {field: 'status', sort: true, title: '是否上料', width: 105,templet: '#stateTpl'},
            // {field: 'orderStatus', sort: true, title: '状态',align:'center',width:80,templet: '#orderStatusTpl'},
        ]];
    };
    function initMaterialShortage(){
        var queryData = {};
        queryData['workOrderNo'] = $("#workOrderNo").val();
        queryData['loadingCode'] = $("#locationCode").val();
        // queryData['loadingCode'] = $("#locationCode").val();
        // 渲染表格
        var tableResult = table.render({
@@ -149,10 +156,36 @@
            url: Feng.ctxPath + '/productionOrderBatchInfo/boardList',
            // page: true,
            height: 345,
            toolbar: '#toolbarDemo',
            cellMinWidth: 80,
            where:queryData,
            cols: MaterialShortage.initColumn()
        });
    }
    // 工具栏事件
    table.on('toolbar(materialShortageTable)', function(obj){
        var id = obj.config.id;
        var checkStatus = table.checkStatus(id);
        switch(obj.event){
            case 'getCheckData':
                var data = checkStatus.data;
                console.log(data.length)
                console.log(data)
                if(data.length!==1){
                    Feng.error("请正确选择一条数据")
                    return
                }
                resetting(data[0].id)
                break;
        };
    });
    function resetting(data){
        var resetting = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/resetting?id=" + data);
        var resettingResult = resetting.start();
        initMaterialShortage()
        Feng.success("重置成功")
    }
    // 生产工单设置按钮点击事件
@@ -239,56 +272,114 @@
        });
    };
    $("#barCode").bind("keydown",function(e){
        // 兼容FF和IE和Opera
        var theEvent = e || window.event;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code === 13) {
            var ajax1 = new $ax(Feng.ctxPath + "/bomInfo/bomCheck?materialCode=" +$('#barCode').val()+"&loadingCode="+$('#locationCode').val());
            var result1 = ajax1.start();
            console.log(result1.data);
            if(result1.data!==0) {
                //回车执行查询
                var ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/barCodeCheck?materialCode=" + $('#barCode').val() + "&workOrderNo=" + $('#workOrderNo').val());
                var result = ajax.start();
                console.log(result.data);
                if (result.data === 0) {
                    let ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/updateState", function (data) {
                    }, function (data) {
                        Feng.error("添加失败!" + data.responseJSON.message)
                    });
                    ajax.set("materialCode", $('#barCode').val());
                    ajax.set("workOrderNo", $('#workOrderNo').val());
                    ajax.set("state", "是");
                    ajax.start();
                    // initBomTable();
                    initMaterialShortage();
                } else {
                    layer.open({
                        title: "操作提示",
                        icon: 0,
                        closeBtn: 2,
                        area: ['450px', '160px'],
                        time: 5000,
                        content: '<span style="font-size: 30px;color: red">该标签已被扫描!!!</span>'
                    });
                }
            }else {
                layer.open({
                    title: "操作提示",
                    icon: 0,
                    closeBtn: 2,
                    area: ['450px', '160px'],
                    time: 5000,
                    content: '<span style="font-size: 30px;color: red">BOM校验错误请重新扫码!!!</span>'
                });
            }
        }
    });
    // $("#barCode").bind("keydown",function(e){
    //     // 兼容FF和IE和Opera
    //     var theEvent = e || window.event;
    //     var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
    //     if (code === 13) {
    //         var ajax1 = new $ax(Feng.ctxPath + "/bomInfo/bomCheck?materialCode=" +$('#barCode').val()+"&loadingCode="+$('#locationCode').val());
    //         var result1 = ajax1.start();
    //         console.log(result1.data);
    //         if(result1.data!==0) {
    //             //回车执行查询
    //             var ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/barCodeCheck?materialCode=" + $('#barCode').val() + "&workOrderNo=" + $('#workOrderNo').val());
    //             var result = ajax.start();
    //             console.log(result.data);
    //             if (result.data === 0) {
    //                 let ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/updateState", function (data) {
    //                 }, function (data) {
    //                     Feng.error("添加失败!" + data.responseJSON.message)
    //                 });
    //                 ajax.set("materialCode", $('#barCode').val());
    //                 ajax.set("workOrderNo", $('#workOrderNo').val());
    //                 ajax.set("state", "是");
    //                 ajax.start();
    //                 // initBomTable();
    //                 initMaterialShortage();
    //             } else {
    //                 layer.open({
    //                     title: "操作提示",
    //                     icon: 0,
    //                     closeBtn: 2,
    //                     area: ['450px', '160px'],
    //                     time: 5000,
    //                     content: '<span style="font-size: 30px;color: red">该标签已被扫描!!!</span>'
    //                 });
    //             }
    //         }else {
    //             layer.open({
    //                 title: "操作提示",
    //                 icon: 0,
    //                 closeBtn: 2,
    //                 area: ['450px', '160px'],
    //                 time: 5000,
    //                 content: '<span style="font-size: 30px;color: red">BOM校验错误请重新扫码!!!</span>'
    //             });
    //         }
    //     }
    // });
    $('#btnClean').click(function (){
        $('#barCode').val("");
        clean()
    });
    function clean(){
        $('#barCode').val("");
        $('#number').val("");
    }
    $('#confirm').click(function (){
        inputMethod($('#barCode').val());
       // let barCode = $('#barCode').val();
       // let batch = barCode.substring(14,25);
       // let number = $('#number').val();
       // if(barCode === '' || number === ''){
       //     Feng.error("请输入条码和数量的完整信息");
       //     return
       // }else if(barCode.length!==25){
       //     Feng.error("请输入完整长度信息");
       //     return
       // }
       // var checkLocationCode = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/checkLocationCode?materialCode=" + barCode.substring(0, 14) + "&workOrderNo="+ $('#workOrderNo').val());
       // var checkLocationCodeResult = checkLocationCode.start();
       // if(checkLocationCodeResult.data === 0){
       //     Feng.error("条码信息异常")
       //     return
       // }
       //  var updateOrderBatchInfo = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/updateOrderBatchInfo?materialCode=" + barCode.substring(0, 14) + "&workOrderNo="+ $('#workOrderNo').val()+ "&spareField1="+ number + "&loadingCode="+ batch);
       //  var updateOrderBatchInfoResult = updateOrderBatchInfo.start();
       //  Feng.success("录入成功")
       //  clean()
       //  initMaterialShortage()
    });
    function inputMethod(inBarCode){
        let barCode = inBarCode;
        let batch = barCode.substring(14,25);
        let number = $('#number').val();
        if(barCode === '' || number === ''){
            Feng.error("请输入条码和数量的完整信息");
            return
        }else if(barCode.length!==25){
            Feng.error("请输入完整长度信息");
            return
        }
        // var checkLocationCode = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/checkLocationCode?materialCode=" + barCode.substring(0, 14) + "&workOrderNo="+ $('#workOrderNo').val());
        // var checkLocationCodeResult = checkLocationCode.start();
        // if(checkLocationCodeResult.data === 0){
        //     Feng.error("条码信息异常")
        //     return
        // }
        var updateOrderBatchInfo = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/updateOrderBatchInfo?materialCode=" + barCode.substring(0, 14) + "&workOrderNo="+ $('#workOrderNo').val()+ "&quantity="+ number + "&batch="+ batch+ "&residueQuantity="+ number);
        var updateOrderBatchInfoResult = updateOrderBatchInfo.start();
        if(updateOrderBatchInfoResult.data === "0"){
            Feng.error("批次不同无法录入");
            return;
        }
        Feng.success("录入成功")
        clean()
        initMaterialShortage()
    }
    var websocket = null;
    //判断当前浏览器是否支持WebSocket
@@ -301,48 +392,49 @@
    }
    //接收到消息的回调方法
    websocket.onmessage = function(event) {
        console.log(event);
        console.log(event.data)
        $('#barCode').val(event.data);
            var ajax1 = new $ax(Feng.ctxPath + "/bomInfo/bomCheck?materialCode=" +$('#barCode').val()+"&loadingCode="+$('#locationCode').val());
            var result1 = ajax1.start();
            console.log(result1.data);
            if(result1.data!==0) {
                //回车执行查询
                var ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/barCodeCheck?materialCode=" + $('#barCode').val() + "&workOrderNo=" + $('#workOrderNo').val());
                var result = ajax.start();
                console.log(result.data);
                if (result.data === 0) {
                    let ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/updateState", function (data) {
                    }, function (data) {
                        Feng.error("添加失败!" + data.responseJSON.message)
                    });
                    ajax.set("materialCode", $('#barCode').val());
                    ajax.set("workOrderNo", $('#workOrderNo').val());
                    ajax.set("state", "是");
                    ajax.start();
                    // initBomTable();
                    initMaterialShortage();
                } else {
                    layer.open({
                        title: "操作提示",
                        icon: 0,
                        closeBtn: 2,
                        area: ['450px', '160px'],
                        time: 5000,
                        content: '<span style="font-size: 30px;color: red">该标签已被扫描!!!</span>'
                    });
                }
            }else {
                layer.open({
                    title: "操作提示",
                    icon: 0,
                    closeBtn: 2,
                    area: ['450px', '160px'],
                    time: 5000,
                    content: '<span style="font-size: 30px;color: red">BOM校验错误请重新扫码!!!</span>'
                });
            }
        inputMethod(event.data);
        // console.log(event);
        // console.log(event.data)
        // $('#barCode').val(event.data);
        //     var ajax1 = new $ax(Feng.ctxPath + "/bomInfo/bomCheck?materialCode=" +$('#barCode').val()+"&loadingCode="+$('#locationCode').val());
        //     var result1 = ajax1.start();
        //     console.log(result1.data);
        //     if(result1.data!==0) {
        //         //回车执行查询
        //         var ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/barCodeCheck?materialCode=" + $('#barCode').val() + "&workOrderNo=" + $('#workOrderNo').val());
        //         var result = ajax.start();
        //         console.log(result.data);
        //         if (result.data === 0) {
        //             let ajax = new $ax(Feng.ctxPath + "/productionOrderBatchInfo/updateState", function (data) {
        //             }, function (data) {
        //                 Feng.error("添加失败!" + data.responseJSON.message)
        //             });
        //             ajax.set("materialCode", $('#barCode').val());
        //             ajax.set("workOrderNo", $('#workOrderNo').val());
        //             ajax.set("state", "是");
        //             ajax.start();
        //             // initBomTable();
        //             initMaterialShortage();
        //         } else {
        //             layer.open({
        //                 title: "操作提示",
        //                 icon: 0,
        //                 closeBtn: 2,
        //                 area: ['450px', '160px'],
        //                 time: 5000,
        //                 content: '<span style="font-size: 30px;color: red">该标签已被扫描!!!</span>'
        //             });
        //         }
        //     }else {
        //         layer.open({
        //             title: "操作提示",
        //             icon: 0,
        //             closeBtn: 2,
        //             area: ['450px', '160px'],
        //             time: 5000,
        //             content: '<span style="font-size: 30px;color: red">BOM校验错误请重新扫码!!!</span>'
        //         });
        //     }
    }
    //连接成功建立的回调方法