/** * 作者:G98138 黎锋 * 时间:2018-09-04 * 描述:库位 绑定 * * 业务思路: * 1. 扫描条码 * 1.1 非条码库存表的条码, 提示( OK) * * 1.2 非待入库条码, 提示( OK) * * 1.3 通过条码找到上一次该物料的库位, 作为推荐库位( OK) * 注意: 如果勾选了“默认库位”, 且在上一次绑定的库位和当前界面显示的库位一致 , 则直接绑定库位, 不需要再扫描库位 * * 2. 扫描库位条码 * * 2.1 非库位条码, 提示( OK) * * 2.2 非该仓库的库位, 提示( OK) * */ // 全局变量 var billNo = ''; var i = 0; //计算扫描条码数量 var WLBM = ""; //物料编码 var matterTable = null; var pickerData = [{ 'value': 'v2', 'text': '测试2' }, { 'value': 'v3', 'text': '测试3' }, { 'value': 'v5', 'text': '测试5' }, { 'value': 'v6', 'text': '测试6' }, { 'value': 'v7', 'text': '测试7' }, ]; //初始化,默认焦点 mui.plusReady(function() { mui.init(); app.init(); GetGYS(); GetDHNO(); initBluetooth(); // app.init(); mui("#MBA001")[0].focus(); $('#info').height($(window).height() - $("#row001").height() - $("#div001").height() - $("#div002") .height() - 70); // document.getElementById('check').addEventListener('tap', function() { // console.log(12); // var url = 'getScanCode1.html'; // mui.openWindow({ // url: url, // extras: {}, // waiting: { // autoShow: true, // title: '加载中' // } // }); // // createWithoutTitle('getScanCode.html', { // // titleNView: { // // type: 'float', // // backgroundColor: '#009DE2', // // titleText: '扫一扫', // // titleColor: '#FFFFFF', // // autoBackButton: true // // } // // }); // }, false) }) function scaned(t, r, f) { console.log(r); $("#searchInput").val(r); // setSeanCode({keyCode:123},file71, str1, findId, file91, file101); } // function Sopennew() { // console.log(12); // createWithoutTitle('getScanCode.html', { // titleNView: { // type: 'float', // backgroundColor: '#009DE2', // titleText: '扫一扫', // titleColor: '#FFFFFF', // autoBackButton: true // } // }); // } function SetBillNo() { $("#txtBillNo").click(function() { GetBillList(); PopPicker.show(function(items) { var billNo = items[0].text; $("#txtBillNo").val(billNo); }); }); } document.getElementById('stype').addEventListener('change', function() { console.log(1); var selectedValue = this.value; var elementToHideId = ''; var elementToHideId2 = ''; if (selectedValue === '1') { document.getElementById('row002').style.display = 'none'; // document.getElementById('row004').style.display = ''; document.getElementById('row0022').style.display = ''; document.getElementById('row003').style.display = ''; document.getElementById('row0033').style.display = 'none'; } else if (selectedValue === '2') { document.getElementById('row002').style.display = ''; document.getElementById('row0022').style.display = 'none'; // document.getElementById('row004').style.display = 'none'; document.getElementById('row003').style.display = 'none'; document.getElementById('row0033').style.display = ''; } ///切换清除所有元素 document.getElementById("searchInput").value = ""; document.getElementById("DAB001B").value = ""; document.getElementById("MBA002").value = ""; document.getElementById("DAB002").value = ""; document.getElementById("DAB003").value = ""; document.getElementById("DAB004").value = ""; document.getElementById('ulId').innerHTML = "" }); ///查询所有携客云未做的送货单 function GetDHNO() { $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_GETDHNO", DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { //console.log(response); /// console.log(JSON.stringify(response)); var selectElementD = document.getElementById('MBA001'); selectElementD.innerHTML = ""; matterTable = data.data.matterTable; var option = document.createElement("option"); option.value = ""; option.text = "请选择送货单号"; selectElementD.appendChild(option); for (var i = 0; i < matterTable.length; i++) { var option = document.createElement("option"); option.value = matterTable[i]["送货单号"]; option.text = matterTable[i]["送货单号"]; selectElementD.appendChild(option); } } else { alert("获取数据异常:" + response.message); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } //查询供应商 function GetGYS() { $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_GETGYS", DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { //console.log(response); /// console.log(JSON.stringify(response)); var selectElementD = document.getElementById('DAB001'); selectElementD.innerHTML = ""; matterTable = data.data.matterTable; var option = document.createElement("option"); option.value = ""; option.text = "请选择供应商"; selectElementD.appendChild(option); for (var i = 0; i < matterTable.length; i++) { var option = document.createElement("option"); option.value = matterTable[i]["供应商名称"]; option.text = matterTable[i]["供应商名称"]; selectElementD.appendChild(option); } } else { alert("获取数据异常:" + response.message); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } //修改数量 function AlterNUM(itemid) { console.log(2); var userInput = prompt("请输入收货数量:", ""); if (userInput != null) { $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_UPDATENUM", data: { ID: itemid, userInput: userInput }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { if (document.getElementById("stype").value === '1') { GetInfoGYS() } if (document.getElementById("stype").value === '2') { GetInfoXKYDHNO() } mui.toast("修改成功") } else { alert("获取数据异常:" + data.message); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } else { } console.log(itemid); } //选供应商带出送货单 function GetInfoGYS() { console.log($("#DAB001").val()); $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_GetInfoGYS", data: { DAB001: $("#DAB001").val(), STYPE: '1' }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { var lstb = data.data.matterTable; var cursor2 = data.data.matterTable2; $("#MBA002").val(lstb[0]["DHA001"]); $("#DAB002").val(lstb[0]["DHA005"]); $("#DAB003A").val(lstb[0]["DHA006B"]); $("#DAB003").val(lstb[0]["DHA006"]); $("#DAB004").val(lstb[0]["DHA030"]); matterTable = data.data.matterTable3; console.log(data.data.matterTable3); pickerData.length = 0; for (let item of matterTable) { console.log('value:', item.物料编码, 'text:', item.物料编码 + " " + item.采购订单 + " " + item .剩余数量); pickerData.push({ value: item.ID, text: item.物料编码 + " | " + item.采购订单 + " | " + item.剩余数量 }); } console.log(pickerData); document.getElementById('ulId').innerHTML = template('ui-template', { "record": cursor2 }); } else { alert("获取数据异常:" + data.message); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } //携客云带出信息 function GetInfoXKYDHNO() { console.log($("#MBA002").val()); $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_GetInfoXKYDH", data: { DAB001: $("#MBA002").val(), STYPE: '1' }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { var lstb = data.data.matterTable; var cursor2 = data.data.matterTable2; $("#MBA002").val(lstb[0]["DHA001"]); $("#DAB002").val(lstb[0]["DHA005"]); $("#DAB003A").val(lstb[0]["DHA006B"]); $("#DAB003").val(lstb[0]["DHA006"]); $("#DAB004").val(lstb[0]["DHA030"]); // matterTable = data.data.matterTable3; // console.log(data.data.matterTable3); // pickerData.length = 0; // for (let item of matterTable) { // console.log('value:', item.物料编码, 'text:', item.物料编码 + " " + item.采购订单 + " " + item // .剩余数量); // pickerData.push({ // value: item.ID, // text: item.物料编码 + " | " + item.采购订单 + " | " + item.剩余数量 // }); // } // console.log(pickerData); document.getElementById('ulId').innerHTML = template('ui-template', { "record": cursor2 }); } else { alert("获取数据异常:" + data.message); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } var valstring; function ADDCGLINE() { console.log(17); $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_ADDLINE", data: { DAB001: $("#MBA002").val(), VARSTRING: valstring }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { GetInfoXKYDHNO() } else { alert("获取数据异常:" + response.message); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } ///新增明细按钮 调用重写的picker document.getElementById('add').addEventListener('tap', function() { if ($("#DAB003A").val() == "未保存") { mui.alert("请先保存单据", "", "", function() { }); return; } if ($("#DAB003A").val() == "已审核") { mui.alert("已审核单据无法修改", "", "", function() { }); return; } if ($("#MBA002").val() == "") { mui.alert("到货单号不能为空", "", "", function() { }); return; } var picker = new mui.PopPicker(); picker.setData(pickerData) picker.show(function() { var vals = [] // 获取复选框选中的值 mui.each(document.querySelectorAll('input[name=pickerCheckbox]'), function(i, ele) { if (ele.checked) { vals[i] = ele.value } }) if (!vals || vals.length <= 0) { mui.toast('请选择') return false; // return false 可阻止弹出层关闭 } valstring = vals.join(","); ADDCGLINE(); picker.dispose(); // 关闭并销毁picker实例 GetInfoGYS() // valstring=vals.join(","); // ADDCGLINE(); }) }, false) document.getElementById('check').addEventListener('tap', function() { if ($("#DAB003A").val() == "未保存") { mui.alert("请先保存再审核", "", "", function() { }); return; } if ($("#DAB003A").val() == "已审核") { mui.alert("无法重复审核", "", "", function() { }); return; } if ($("#MBA002").val() == "") { mui.alert("到货单号不能为空", "", "", function() { }); return; } console.log(3333); var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION); var user_id = currentSession.user_id; console.log($("#MBA001").val()); // var user_id = "admin"; $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_DHSH", data: { DAB001: $("#MBA002").val(), logID: user_id //user_id,//Admin //先写死,便于调试 }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { console.log(data); if (data.status != 0) { playerAudio("NG"); console.log(data.message); mui.alert(data.message, "", "", function() { }); return; } else { document.getElementById("DAB003A").value = "已审核"; mui.toast("审核成功") } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); }, false) document.getElementById('save').addEventListener('tap', function() { if ($("#MBA002").val() == "") { mui.alert("到货单号不能为空", "", "", function() { }); return; } if ($("#DAB003A").val() == "已审核") { mui.alert("已审核无法修改", "", "", function() { }); return; } console.log(3333); var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION); var user_id = currentSession.user_id; console.log($("#MBA001").val()); // var user_id = "admin"; $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_SAVEDH", data: { MBA002: $("#MBA002").val(), DAB001: $("#DAB001").val(), DAB004: $("#DAB004").val(), logID: user_id //user_id,//Admin //先写死,便于调试 }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { console.log(data); if (data.status != 0) { playerAudio("NG"); console.log(data.message); mui.alert(data.message, "", "", function() { }); return; } else { GetInfoXKYDHNO() mui.toast("保存成功") } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); }, false) document.getElementById('printbtnn').addEventListener('tap', function() { if ($("#DAB003A").val() != "已审核") { mui.alert("未审核无法打印", "", "", function() { }); return; } if ($("#MBA002").val() == "") { mui.alert("到货单号不能为空", "", "", function() { }); return; } console.log(33313); var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION); var user_id = currentSession.user_id; // var user_id = "admin"; $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_PRINTBAR", data: { MBA002: $("#MBA002").val(), logID: user_id //user_id,//Admin //先写死,便于调试 }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { console.log(data); if (data.status != '0') { playerAudio("NG"); console.log(data.message); mui.alert(data.message, "", "", function() { }); return; } else { console.log(11); var lstb = data.data.matterTable; console.log(data.data.matterTable); var str = lstb[0]["ID"].toString(); mui.toast("开始打印"); console.log(12); printByIds(str); console.log(13); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); }, false) let startX = 0; let endX = 0; function touchStart(event, itemid) { startX = event.touches[0].clientX; } function touchMove(event, itemid) { endX = event.touches[0].clientX; if (endX - startX < -50) { // 设置滑动距离阈值,这里设置为80像素 // alert('左滑事件触发'); if (confirm("您确定要删除该条明细吗?")) { // 用户点击了“确定”按钮,执行相应操作 DELETELINE(itemid) } else { // 用户点击了“取消”按钮,不执行操作 } console.log(itemid); } if (endX - startX > 50) { // 设置滑动距离阈值,这里设置为80像素 // alert('右滑事件触发'); if (confirm("您确定要删除该条明细吗?")) { // 用户点击了“确定”按钮,执行相应操作 DELETELINE(itemid) } else { // 用户点击了“取消”按钮,不执行操作 } console.log(itemid); } } function DELETELINE(itemid) { $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/CG_DELETELINE", data: { ID: itemid }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { if (data.status == 0) { mui.toast("删除成功!"); GetInfoXKYDHNO() } else { alert("删除失败!"); } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); } window.addEventListener('refresh', function(e) { //监听页面返回事件 GetInfoXKYDHNO() }); function GetInfoXKYDH() { //用户ID var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION); var user_id = currentSession.user_id; console.log($("#MBA001").val()); // var user_id = "admin"; $.ajax({ url: app.API_URL_HEADER + "/XKYDHD/GetBarInfo", data: { DAB001: $("#MBA001").val(), logID: user_id //user_id,//Admin //先写死,便于调试 }, DataType: "json", type: "post", async: false, //timeout: 15000, success: function(data) { console.log(data); if (data.status != 0) { console.log(data); playerAudio("NG"); mui.alert(data.message, "", "", function() { mui("#DAB001")[0].focus(); $("#DAB001").val(""); }); return; } else { console.log(data); matterTable = data.data.matterTable; $("#DAB001B").val(matterTable[0]["DHA003"]); $("#MBA002").val(matterTable[0]["DHA001"]); // $("#MBA002").val(matterTable[0]["DHA001"]); GetInfoXKYDHNO() } }, error: function(xhr, type, errorThrown) { alert("获取数据异常:" + JSON.stringify(errorThrown)); } }); }; //扫描库位处理方法 /* 当页面的文本失去焦点时,让其再次获取焦点 */ /** * @param {出发DOM控件:this} e */ //function SetInputFoucs(codeID) { // var itemTag = document.activeElement.tagName; //获取元素的标签名 // var name = document.activeElement.name; //获取元素的名称 // //如果控件不是文本 // //如果控件是文本,Name非空时(如checkbox) // //条码获取焦点 // if ((itemTag != 'INPUT') || // (itemTag == 'INPUT' && name != '')) { // $(codeID).focus(); // } //}