自动化立体仓库 - WMS系统
#
luxiaotao1123
2020-07-10 c1d296c4ed6a669c29b848bdee3f9b8001f58ddc
src/main/webapp/views/pdaCe/index.html
@@ -116,7 +116,7 @@
</div>
<div>
    <span>物料</span>
    <input type="text" id="matnr" onkeyup="find(this)" autocomplete="off">
    <input type="text" id="matNo" onkeyup="find(this)" autocomplete="off">
</div>
<div class="mat-msg" id="mat-msg-id">
@@ -134,7 +134,7 @@
<div id="btn-con">
    <button style="margin-right: 20px" onclick="reset()">重置</button>
    <button >组托</button>
    <button onclick="comb()">组托</button>
    <span id="tips"></span>
</div>
@@ -164,7 +164,7 @@
    var matMsgTableBlankRows = 0;   // 空白行数
    var matData = []; // 表格数据
    var code = document.getElementById("code")
    var matnr = document.getElementById("matnr")
    var matNo = document.getElementById("matNo")
    var matMsg = document.getElementById("mat-msg-id");
    var matMsgTable = document.getElementById("mat-msg-table");
    var tthead = document.getElementById("tthead");
@@ -185,6 +185,7 @@
        httpRequest({
            httpUrl: baseUrl + "/matCode/auth",
            type: 'post',
            headers: [{token: getCookie('token')}],
            data: {
                id: el.value
            },
@@ -204,10 +205,47 @@
                    btnCon.style.display = 'block';
                    matDetail.style.display = 'none';
                }
            } else if (res.code === 403) {
                window.location.href = baseUrl + "/pda/ce";
            } else {
                alert(res.msg);
                tips(res.msg, true)
            }
        })
    }
    // 组托
    function comb() {
        var barcode = code.value;
        if (isEmpty(barcode)) {
            tips("托盘条码为空", true);
            // document.getElementById("code").focus();
            return;
        }
        if (matData.length === 0) {
            tips("请提取物料", true);
            return;
        }
        console.log(JSON.stringify({
            barcode: barcode,
            combMats: matData
        }))
        httpRequest({
            httpUrl: baseUrl+"/mobile/comb/form",
            type: 'post',
            headers: [{token: getCookie('token')}],
            data: {
                barcode: barcode,
                combMats: matData
            },
        }, function (res) {
            if (res.code === 200) {
                reset();
                tips("组托成功")
            } else if (res.code === 403) {
                window.location.href = baseUrl + "/pda/ce";
            } else {
                tips(res.msg, true)
            }
        })
    }
@@ -244,31 +282,36 @@
        }
        var toPush = true;
        for (var j=0;j<matData.length;j++){
            if (data.matnr === matData[j].matnr) {
            if (data.matNo === matData[j].matNo) {
                matData[j].count = Number(matData[j].count) + Number(data.count);
                toPush  = false;
            }
        }
        if (toPush) {
            matData.push(data);
            var html = "";
            for (var i=0;i<matData.length;i++) {
                html += " <div>\n" +
                    "       <span>" + matData[i].matnr + "</span>\n" +
                    "       <span>" + matData[i].matName + "</span>\n" +
                    "       <span>" + matData[i].str1 + "</span>\n" +
                    "       <span>" + matData[i].count + "</span>\n" +
                    "     </div>\n";
            }
            ttbody.innerHTML = html;
        }
        var html = "";
        for (var i=0;i<matData.length;i++) {
            html += " <div class='table-data'>\n" +
                "       <span>" + matData[i].matNo + "</span>\n" +
                "       <span>" + matData[i].matName + "</span>\n" +
                "       <span>" + matData[i].str1 + "</span>\n" +
                "       <span>" + matData[i].count + "</span>\n" +
                "     </div>\n";
        }
        ttbody.innerHTML = html;
    }
    // 重置
    function reset() {
        code.value = "";
        matnr.value = "";
        matNo.value = "";
        cancel();
        while(ttbody.hasChildNodes()) {
            ttbody.removeChild(ttbody.firstChild);
        }
    }
    /**
@@ -291,7 +334,7 @@
    // 提取
    function confirm() {
        addTableData({
            matnr: matnr.value,
            matNo: matNo.value,
            matName: matName.value,
            str1: str1.value,
            count: count.value
@@ -301,7 +344,7 @@
    }
    // 取消
    function cancel() {
        matnr.value = "";
        matNo.value = "";
        matName.value = "";
        str1.value = "";
        count.value = initMatCount;
@@ -319,6 +362,21 @@
            return;
        }
        count.value = count.value - 1;
    }
    //获取 cookie
    function getCookie(objName){//获取指定名称的cookie的值
        //多个cookie 保存的时候是以 ;空格  分开的
        var arrStr = document.cookie.split("; ");
        for (var i = 0; i < arrStr.length; i++) {
            var temp = arrStr[i].split("=");
            if (temp[0] === objName){
                return decodeURIComponent(temp[1]);
            }else{
                return "";
            }
        }
    }
    function httpRequest(paramObj,fun,errFun) {
@@ -344,6 +402,8 @@
        var httpUrl = paramObj.httpUrl || '';
        /*是否异步请求*/
        var async = paramObj.async || true;
        /*请求头参数*/
        var headerData = paramObj.headers || [];
        /*请求参数--post请求参数格式为:foo=bar&lorem=ipsum*/
        var paramData = paramObj.data || [];
        var requestData = '';
@@ -370,9 +430,31 @@
        }else if(httpType === 'POST'){
            xmlhttp.open("POST",httpUrl,async);
            //发送合适的请求头信息
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            var defaultContentType = true;
            for (var i=0;i<headerData.length;i++) {
                for(var key in headerData[i]) {
                    if (key === "Content-type") {
                        defaultContentType = false;
                    }
                    xmlhttp.setRequestHeader(key, headerData[i][key]);
                }
            }
            if (defaultContentType) {
                xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            }
            xmlhttp.send(requestData);
        }
    }
    // todo
    setTimeout(function () {
        code.value = "888"
        addTableData({
            matNo: "1902980-11/14",
            matName: "铝带|1100-O|0.33*475|",
            str1: "件",
            count: 1
        })
    }, 200)
</script>
</html>