|  |  |  | 
|---|
|  |  |  | <head> | 
|---|
|  |  |  | <meta charset="UTF-8"> | 
|---|
|  |  |  | <meta name="viewport" content="width=device-width, target-densitydpi=high-dpi, initial-scale=1.0, user-scalable=no"/> | 
|---|
|  |  |  | <title>中扬物流</title> | 
|---|
|  |  |  | <title>浙江中扬储存设备有限公司</title> | 
|---|
|  |  |  | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> | 
|---|
|  |  |  | <style> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | * { | 
|---|
|  |  |  | font-size: 12px; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | html { | 
|---|
|  |  |  | background-color: #fff; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .mat-msg { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #tips { | 
|---|
|  |  |  | font-size: 12px; | 
|---|
|  |  |  | margin-top: 2px; | 
|---|
|  |  |  | margin-left: 10px; | 
|---|
|  |  |  | display: inline-block; | 
|---|
|  |  |  | vertical-align: middle; | 
|---|
|  |  |  | 
|---|
|  |  |  | </style> | 
|---|
|  |  |  | </head> | 
|---|
|  |  |  | <body> | 
|---|
|  |  |  | <button onclick="help()" style="padding: 0 3px; position: absolute; top: 0%; right: 0%">?</button> | 
|---|
|  |  |  | <div> | 
|---|
|  |  |  | <span>条码</span> | 
|---|
|  |  |  | <input type="text" id="code"> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div> | 
|---|
|  |  |  | <span>物料</span> | 
|---|
|  |  |  | <input type="text" id="matnr" onkeyup="find(this)" autocomplete="off"> | 
|---|
|  |  |  | <input type="text" id="matNo" onkeyup="find(this)" autocomplete="off"> | 
|---|
|  |  |  | <button onclick="find()">查询</button> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="mat-msg" id="mat-msg-id"> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div id="btn-con"> | 
|---|
|  |  |  | <button style="margin-right: 20px" onclick="reset()">重置</button> | 
|---|
|  |  |  | <button onclick="comb()">组托</button> | 
|---|
|  |  |  | <button id="comb" onclick="comb()">组托</button> | 
|---|
|  |  |  | <span id="tips"></span> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 详情 --> | 
|---|
|  |  |  | <div class="form-box" id="mat-detail"> | 
|---|
|  |  |  | <div class="form-item form-count"> | 
|---|
|  |  |  | <span style="margin-right: 10px">数量</span> | 
|---|
|  |  |  | <button onclick="reduce()">-</button><input id="count" type="number" style="text-align: center"><button onclick="add()">+</button> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="form-item"> | 
|---|
|  |  |  | <span>名称</span> | 
|---|
|  |  |  | <input id="matName" type="text" disabled="disabled" style="background-color: #ececec;color: #000"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <div class="form-item"> | 
|---|
|  |  |  | <span>单位</span> | 
|---|
|  |  |  | <input id="str1" type="text" disabled="disabled" style="background-color: #ececec;color: #000; text-align: center;"> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="form-item form-count"> | 
|---|
|  |  |  | <span style="margin-right: 10px">数量</span> | 
|---|
|  |  |  | <button onclick="reduce()">-</button><input id="count" type="number" style="text-align: center"><button onclick="add()">+</button> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="form-item form-btn-con"> | 
|---|
|  |  |  | <button id="confirm" onclick="confirm()">提取</button> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </body> | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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"); | 
|---|
|  |  |  | var ttbody = document.getElementById("ttbody"); | 
|---|
|  |  |  | var btnCon = document.getElementById("btn-con"); | 
|---|
|  |  |  | var tipDom = document.getElementById("tips"); | 
|---|
|  |  |  | var combBtn = document.getElementById("comb"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var matDetail = document.getElementById("mat-detail"); | 
|---|
|  |  |  | var matName = document.getElementById("matName"); | 
|---|
|  |  |  | var str1 = document.getElementById("str1"); | 
|---|
|  |  |  | var count = document.getElementById("count"); | 
|---|
|  |  |  | var confirmBtn = document.getElementById("confirm"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | matDetail.style.display = 'none'; | 
|---|
|  |  |  | var initMatCount = 1; | 
|---|
|  |  |  | window.onload = function(){matMsg.focus();} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 查询物流 | 
|---|
|  |  |  | function find(el) { | 
|---|
|  |  |  | httpRequest({ | 
|---|
|  |  |  | httpUrl: baseUrl + "/matCode/auth", | 
|---|
|  |  |  | type: 'post', | 
|---|
|  |  |  | headers: [{token: getCookie('token')}], | 
|---|
|  |  |  | data: { | 
|---|
|  |  |  | id: el.value | 
|---|
|  |  |  | id: matNo.value | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, function (res) { | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | 
|---|
|  |  |  | // 填充数据 | 
|---|
|  |  |  | matName.value = res.data.matName; | 
|---|
|  |  |  | str1.value = res.data.str1; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // count.focus(); | 
|---|
|  |  |  | count.value = initMatCount; | 
|---|
|  |  |  | confirmBtn.focus(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | matMsg.style.display = 'block'; | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | tips("请输入托盘条码", true); | 
|---|
|  |  |  | // document.getElementById("code").focus(); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (barcode.length !== 8) { | 
|---|
|  |  |  | tips("条码必须为8位", true); | 
|---|
|  |  |  | // document.getElementById("code").focus(); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | httpRequest({ | 
|---|
|  |  |  | httpUrl: baseUrl+"/mobile/comb/auth", | 
|---|
|  |  |  | type: 'post', | 
|---|
|  |  |  | headers: [ | 
|---|
|  |  |  | {token: getCookie('token')} | 
|---|
|  |  |  | ,{'Content-type':'application/json;charset=UTF-8',} | 
|---|
|  |  |  | ], | 
|---|
|  |  |  | data: JSON.stringify({ | 
|---|
|  |  |  | barcode: barcode, | 
|---|
|  |  |  | combMats: matData | 
|---|
|  |  |  | }), | 
|---|
|  |  |  | }) , | 
|---|
|  |  |  | }, function (res) { | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | if (res.data != null) { | 
|---|
|  |  |  | // 样式 | 
|---|
|  |  |  | matMsg.style.display = 'none'; | 
|---|
|  |  |  | btnCon.style.display = 'none'; | 
|---|
|  |  |  | matDetail.style.display = 'block'; | 
|---|
|  |  |  | // 填充数据 | 
|---|
|  |  |  | matName.value = res.data.matName; | 
|---|
|  |  |  | str1.value = res.data.str1; | 
|---|
|  |  |  | count.value = initMatCount; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | matMsg.style.display = 'block'; | 
|---|
|  |  |  | btnCon.style.display = 'block'; | 
|---|
|  |  |  | matDetail.style.display = 'none'; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | reset(); | 
|---|
|  |  |  | tips("组托成功") | 
|---|
|  |  |  | } else if (res.code === 403) { | 
|---|
|  |  |  | window.location.href = baseUrl + "/pda/ce"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | alert(res.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl+"/mobile/comb/auth", | 
|---|
|  |  |  | headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | data: JSON.stringify({ | 
|---|
|  |  |  | barcode: barcode, | 
|---|
|  |  |  | combMats: matData | 
|---|
|  |  |  | }), | 
|---|
|  |  |  | contentType:'application/json;charset=UTF-8', | 
|---|
|  |  |  | method: 'POST', | 
|---|
|  |  |  | async: false, | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | reset(); | 
|---|
|  |  |  | tips("组托成功") | 
|---|
|  |  |  | } else if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl + "/pda"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | tips(res.msg, true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | tips(res.msg, true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | initCrnMsgTable(); | 
|---|
|  |  |  | // initCrnMsgTable(); | 
|---|
|  |  |  | function initCrnMsgTable(row) { | 
|---|
|  |  |  | var line; | 
|---|
|  |  |  | if (row === undefined){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | var html = ""; | 
|---|
|  |  |  | for (var i=0;i<matData.length;i++) { | 
|---|
|  |  |  | html += " <div class='table-data'>\n" + | 
|---|
|  |  |  | "       <span>" + matData[i].matnr + "</span>\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" + | 
|---|
|  |  |  | 
|---|
|  |  |  | // 重置 | 
|---|
|  |  |  | function reset() { | 
|---|
|  |  |  | code.value = ""; | 
|---|
|  |  |  | matnr.value = ""; | 
|---|
|  |  |  | matNo.value = ""; | 
|---|
|  |  |  | cancel(); | 
|---|
|  |  |  | while(ttbody.hasChildNodes()) { | 
|---|
|  |  |  | ttbody.removeChild(ttbody.firstChild); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 提取 | 
|---|
|  |  |  | function confirm() { | 
|---|
|  |  |  | addTableData({ | 
|---|
|  |  |  | matnr: matnr.value, | 
|---|
|  |  |  | matNo: matNo.value, | 
|---|
|  |  |  | matName: matName.value, | 
|---|
|  |  |  | str1: str1.value, | 
|---|
|  |  |  | count: count.value | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 取消 | 
|---|
|  |  |  | function cancel() { | 
|---|
|  |  |  | matnr.value = ""; | 
|---|
|  |  |  | matNo.value = ""; | 
|---|
|  |  |  | matName.value = ""; | 
|---|
|  |  |  | str1.value = ""; | 
|---|
|  |  |  | count.value = initMatCount; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | 
|---|
|  |  |  | var httpUrl = paramObj.httpUrl || ''; | 
|---|
|  |  |  | /*是否异步请求*/ | 
|---|
|  |  |  | var async = paramObj.async || true; | 
|---|
|  |  |  | /*请求头参数*/ | 
|---|
|  |  |  | var headerData = paramObj.headers || []; | 
|---|
|  |  |  | /*请求参数--post请求参数格式为:foo=bar&lorem=ipsum*/ | 
|---|
|  |  |  | var paramData = paramObj.data || []; | 
|---|
|  |  |  | var requestData = ''; | 
|---|
|  |  |  | 
|---|
|  |  |  | requestData += name + '='+ paramData[name] + '&'; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | requestData = requestData === '' ? '' : requestData.substring(0,requestData.length - 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*请求接收*/ | 
|---|
|  |  |  | xmlhttp.onreadystatechange = function() { | 
|---|
|  |  |  | if(xmlhttp.readyState === 4 && xmlhttp.status === 200) { | 
|---|
|  |  |  | 
|---|
|  |  |  | }else if(httpType === 'POST'){ | 
|---|
|  |  |  | xmlhttp.open("POST",httpUrl,async); | 
|---|
|  |  |  | //发送合适的请求头信息 | 
|---|
|  |  |  | xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | 
|---|
|  |  |  | xmlhttp.send(requestData); | 
|---|
|  |  |  | 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(defaultContentType?requestData:paramData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | document.onkeyup = function (e) { | 
|---|
|  |  |  | if (window.event)//如果window.event对象存在,就以此事件对象为准 | 
|---|
|  |  |  | e = window.event; | 
|---|
|  |  |  | var key = e.charCode || e.keyCode; | 
|---|
|  |  |  | if (key === 112) { | 
|---|
|  |  |  | code.focus(); | 
|---|
|  |  |  | } else if (key === 113) { | 
|---|
|  |  |  | matNo.focus(); | 
|---|
|  |  |  | } else if (key === 114) { | 
|---|
|  |  |  | combBtn.focus(); | 
|---|
|  |  |  | } else if (key === 13) { | 
|---|
|  |  |  | confirmBtn.focus(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | document.onkeydown = function (e) { | 
|---|
|  |  |  | if (window.event)//如果window.event对象存在,就以此事件对象为准 | 
|---|
|  |  |  | e = window.event; | 
|---|
|  |  |  | var key = e.charCode || e.keyCode; | 
|---|
|  |  |  | if (key === 114) { | 
|---|
|  |  |  | comb() | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function help() { | 
|---|
|  |  |  | window.alert("① 按F1输入条码\n" + | 
|---|
|  |  |  | "② 按F2输入物料号,按ENTER查询,选择数量后提取\n" + | 
|---|
|  |  |  | "③ 按F3开始组托\n" + | 
|---|
|  |  |  | "其它:按F5刷新页面"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  | </html> | 
|---|