123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589 |
- $(function(){
-
- var focusId;
- $("input").focus(function(){
- //记住焦点位置
- focusId = this.id;
- //this.scrollIntoView(true);//回到顶部
- //window.setTimeout("myScrollIntoView()",100);
- });
-
- setTimeout(function() {
- $('#inventoryCheckCode').focus();
- }, 1000);
- //当失去焦点按回车时,焦点回到之前焦点位置
- $(window).keydown(function(event){
- if((event.keyCode==13)) {
- if(document.activeElement.id == null || document.activeElement.id ==''){
- //回到上次焦点地方
- //$("#"+focusId).focus();
- }
- }
- });
- $('#inventoryCheckCode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#inventoryCheckCode").val(trimStr($("#inventoryCheckCode").val()));
- if($('#inventoryCheckCode').val()!=''){
- //播放扫描声音
- playSound('../raw/scan.wav');
- submitCheckCode();
- }
- });
-
- $('#locationCode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#locationCode").val(trimStr($("#locationCode").val()));
- if($("#locationCode").val() !='' ){
- //播放扫描声音
- playSound('../raw/scan.wav');
-
- submitLocationCode();
- }
- });
-
- $('#barcode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#barcode").val(trimStr($("#barcode").val()));
- if($("#barcode").val() !='' ){
- //播放扫描声音
- playSound('../raw/scan.wav');
-
- submitBarcode();
- }
- });
-
- $('#batchNo').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#batchNo").val(trimStr($("#batchNo").val()));
- if($("#batchNo").val() !='' ){
- var a = $("#batchNo").val();
- var b = a.toUpperCase();
- $("#batchNo").val(b);
-
- //播放扫描声音
- playSound('../raw/scan.wav');
-
- submitBatchNo();
- }
- });
-
- $('#checkQty').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- if($("#checkQty").val() !='' ){
- //提交上架
- submitInventoryCheck();
- }
- });
- });
- //提交入库单号
- function submitCheckCode(){
- var inventoryCheckCode = $('#inventoryCheckCode').val();
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.INVENTORY_PLAN_CHECK_1;
- appRequest.msg = inventoryCheckCode;//msg是消息内容主体
-
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- success: function (appResponse) {
- if(!appResponse.success){
- playSound('../raw/error.wav');
- mui.alert(appResponse.msg, '警告', function() { setFocus('inventoryCheckCode'); });
- return;
- }
-
- mui.toast(appResponse.msg);
-
- var check = appResponse.extend;
-
- $("#inventoryCheckId").val(check.id);
- $("#warehouseCode").val(check.warehouseCode);
- $("#customerCode").val(check.customerCode);
- $("#customerId").val(check.customerId);
-
- nextLocation();
-
- getNextLocationCode();
- },
- error: function () {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- function submitLocationCode(){
- var inventoryCheckId = $("#inventoryCheckId").val();
- var warehouseCode = $("#warehouseCode").val();
- var customerCode = $("#customerCode").val();
- var customerId = $("#customerId").val();
- var locationCode = $("#locationCode").val();
-
- var formData = {
- inventoryCheckId:inventoryCheckId,
- warehouseCode:warehouseCode,
- customerCode:customerCode,
- customerId:customerId,
- locationCode:locationCode
- };
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.INVENTORY_PLAN_CHECK_2;
- appRequest.msg = JSON.stringify(formData);//msg是消息内容主体
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- success: function (appResponse) {
- if(!appResponse.success){
- playSound('../raw/error.wav');
- mui.alert(appResponse.msg, '警告', function() { setSelect('locationCode'); });
- return;
- }
- //mui.toast(appResponse.msg);
-
- //返回收货记录 可能是多条
- var list = appResponse.extend;
- if(list.length == 0 ){
- //2019-05-10改为库位只要存在就行
-
- $('#barcode').val("");
- $('#barcode').focus();
-
- //playSound('../raw/error.wav');
- //mui.alert('后台返回list长度为0', '警告', function() { setSelect('locationCode'); });
- return;
- }
-
- refreshItems();
-
- //默认显示第一个商品条码
- //var checkDetail = list[0];
- //$("#barcode").val(checkDetail.barcode);//条码
-
- $('#barcode').val("");
- $('#barcode').focus();
-
- //跳到条码并选中
- //setSelect('barcode');
- },
- error: function () {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- //提交商品条码
- function submitBarcode(){
- var inventoryId = $("#inventoryId").val();//库存记录id
- var barcodeShow = $("#barcodeShow").val();
- var barcode = $('#barcode').val();
-
- if(barcodeShow != barcode){
- //展示条码和当前扫描的条码不一样,说明换商品了.要不要提交展示条码的盘点数量submitInventoryCheck?
- //若自动提交,适合拿一件扫一件的情况,需考虑叠加的问题
- exeSubmitBarcode();
- return;
- }
-
- var checkQty = $("#checkQty").val();
- if(checkQty == null || checkQty == ''){checkQty = 0;}
- $("#checkQty").val((parseInt(checkQty)+1));
-
- //回到条码输入框,用户应当继续扫描条码
- $("#barcode").val('');//清空条码,用户只需要看展示条码,最后手工点击提交
- setSelect('barcode');
- }
- function exeSubmitBarcode(){
- var inventoryCheckId = $("#inventoryCheckId").val();
- var warehouseCode = $("#warehouseCode").val();
- var customerCode = $("#customerCode").val();
- var customerId = $("#customerId").val();
- var locationCode = $("#locationCode").val();
- var barcode = $("#barcode").val();
- if(barcode == ''){
- return;
- }
- var formData = {
- inventoryCheckId:inventoryCheckId,
- warehouseCode:warehouseCode,
- customerCode:customerCode,
- customerId:customerId,
- locationCode:locationCode,
- barcode:barcode
- };
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.INVENTORY_PLAN_CHECK_3;
- appRequest.msg = JSON.stringify(formData);//msg是消息内容主体
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- success: function (appResponse) {
- if(!appResponse.success){
- playSound('../raw/error.wav');
- mui.alert(appResponse.msg, '警告', function() { setFocus('barcode'); });
- return;
- }
-
- $("#barcodeShow").val(barcode);
- $("#barcode").val("");
- $('#checkQty').val(1);//盘点数量
-
- //mui.toast(appResponse.msg);
- //返回收货记录 可能是多条
- var list = appResponse.extend;
-
- //2019-05-09改为可以输入该库位原本没有的商品条码
- if(list.length == 0 ){
- //去输入批次号码
- mui.toast("该库位,商品条码未找到现有库存,请手工输入批次号码");
- $('#sysQty').val("0");//系统数量
- $("#batchNo").val("");
- $("#batchNo").removeAttr("readonly");
- $("#batchNo").focus();
-
- //系统自动输入批次?
- $("#qualityName").val("");
- $("#qualityCode").val("0");
- $('#qualityName').hide();//隐藏原品质
- $('#qualityCode').show();//显示可选批次
-
- //playSound('../raw/error.wav');
- //mui.alert('后台返回list长度为0', '警告', function() { setFocus('barcode'); });
- return;
- }
-
-
- //暂先只处理第一条.. 后续可改为界面选择一条
- //提醒客户这个条码有几个批次
- mui.toast("该库位,条码下有"+list.length+"个批次待盘点,请注意分批次盘点");
-
- var checkDetail = list[0];
- $("#inventoryCheckDetailId").val(checkDetail.id);//
- $("#inventoryId").val(checkDetail.inventoryId);//库存记录id
- $("#inOrderNo").val(checkDetail.inOrderNo);
- $("#batchNo").val(checkDetail.batchNo);//批次号码
-
- $('#qualityName').val(checkDetail.qualityName);//品质
- $('#qualityCode').val(checkDetail.qualityCode);//品质
- $('#qualityCode').hide();//隐藏可选批次
- $('#qualityName').show();//显示原品质
- $("#batchNo").attr("readonly","readonly");
-
- $('#sysQty').val(checkDetail.sysQty);//系统数量
- },
- error: function () {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- //提交批次号码
- function submitBatchNo(){
- var barcodeShow = $("#barcodeShow").val();
- if(barcodeShow == ''){
- return;
- }
- //提示选择库存品质
- //setSelect('qualityCode');
- $("#qualityCode").focus();
-
- //去条码输入框
- //setSelect('barcode');
- }
- var isSubmintIng = false;//是否正在提交. 防止按回车太快
- function submitInventoryCheck(){
- if(isSubmintIng){return;}
- isSubmintIng = true;
-
- var inventoryCheckCode = $("#inventoryCheckCode").val();
- var inventoryCheckId = $("#inventoryCheckId").val();
-
- var warehouseCode = $("#warehouseCode").val();
-
- var customerCode = $("#customerCode").val();
- var customerId = $("#customerId").val();
-
- var inventoryCheckDetailId = $("#inventoryCheckDetailId").val();
- var inventoryId = $("#inventoryId").val();
- var locationCode = $("#locationCode").val();
- var barcode = $("#barcode").val();
- var barcodeShow = $("#barcodeShow").val();
- barcode = barcodeShow;
-
- var inOrderNo = $("#inOrderNo").val();
- var batchNo = $("#batchNo").val();//批次号码
- var qualityName = $("#qualityName").val();
- var qualityCode = $("#qualityCode").val();
-
- var sysQty = $("#sysQty").val();
- var checkQty = $("#checkQty").val();
-
- if(inventoryCheckId == ''){
- mui.toast('请先提交盘点单号');
- isSubmintIng = false;
- return;
- }
- if(locationCode == ''){
- mui.toast('库位不能为空');
- isSubmintIng = false;
- return;
- }
- if(checkQty == '' || checkQty < 0){
- mui.toast('盘点数量不能小于0');
- isSubmintIng = false;
- return;
- }
- if(barcodeShow == ''){
- mui.toast('请先在商品条码输入框按回车');
- isSubmintIng = false;
- return;
- }
-
- var formData = {
- inventoryCheckCode:inventoryCheckCode,
- inventoryCheckId:inventoryCheckId,
- barcode:barcode,
- inventoryCheckDetailId:inventoryCheckDetailId,
- inventoryId:inventoryId,
- locationCode:locationCode,
- sysQty:sysQty,
- checkQty:checkQty,
- inOrderNo:inOrderNo,
- batchNo:batchNo,
- qualityName:qualityName,
- qualityCode:qualityCode
- };
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.INVENTORY_PLAN_CHECK_4;
- appRequest.msg = JSON.stringify(formData);//msg是消息内容主体
-
- var nwaiting = plus.nativeUI.showWaiting('正在提交中...');
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- success: function (appResponse) {
- isSubmintIng = false;
- nwaiting.close();
-
- if(!appResponse.success){
- playSound('../raw/error.wav');
- mui.alert(appResponse.msg, '警告', function() { setFocus('locationCode'); });
- return;
- }
-
- mui.toast(appResponse.msg);
-
- //播放成功声音
- playSound('../raw/ok.wav');
-
- //下一个库位
- nextLocation();
-
- //获取下一个库位
- getNextLocationCode();
-
- //整单完成. 下一个盘点单
- if(appResponse.extend){cleanAll();}
- },
- error: function () {
- isSubmintIng = false;
- nwaiting.close();
-
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- function getNextLocationCode(){
- var inventoryCheckId = $("#inventoryCheckId").val();
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.INVENTORY_PLAN_CHECK_NEXT_LOCATION;
- appRequest.msg = inventoryCheckId;//msg是消息内容主体
-
- var locationCode = "";
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- async:false,
- success: function (appResponse) {
- if(!appResponse.success){
- return;
- }
- locationCode = appResponse.msg;
-
- $("#prosess").html(appResponse.extend);
- //$("#nextLocation").val(locationCode);//推荐库位
- $("#nextLocation").html(locationCode);
- }
- });
- return locationCode;
- }
- //下一个条码
- function nextLocation(){
-
- $("#inventoryCheckDetailId").val("");
- $("#inventoryId").val("");
-
- $("#locationCode").val("");
- $("#barcode").val("");
- $("#barcodeShow").val("");
-
- $("#inOrderNo").val("");
- $("#barcode").val("");
- $("#batchNo").val("");//批次号码
-
- $("#qualityName").val("");
- $("#qualityCode").val("0");
- $('#qualityCode').hide();//隐藏可选批次
- $('#qualityName').show();//显示原品质
- $("#batchNo").attr("readonly","readonly");
-
- $("#sysQty").val("");
- $("#checkQty").val("");
-
- $("#locationCode").focus();
- }
- //下一个订单
- function cleanAll(){
- $("#inventoryCheckCode").val("");
- $("#inventoryCheckId").val("");
-
- $("#warehouseCode").val("");
-
- $("#customerCode").val("");
- $("#customerId").val("");
-
- $("#inventoryCheckDetailId").val("");
- $("#inventoryId").val("");
- $("#locationCode").val("");
- $("#barcode").val("");
- $("#barcodeShow").val("");
-
- $("#inOrderNo").val("");
- $("#barcode").val("");
- $("#batchNo").val("");//批次号码
-
- $("#qualityName").val("");
- $("#qualityCode").val("0");
- $('#qualityCode').hide();//隐藏可选批次
- $('#qualityName').show();//显示原品质
- $("#batchNo").attr("readonly","readonly");
-
- $("#sysQty").val("");
- $("#checkQty").val("0");
-
- $("#prosess").html("");
- //$("#nextLocation").val("");//推荐库位
- $("#nextLocation").html("");//推荐库位
-
- $("#inventoryCheckCode").focus();
- }
- //打开和关闭待盘点明细展示
- var isShowDetails = false;
- function showDetails(){
- if(!isShowDetails){
- $("#showDetails").show();
- isShowDetails = true;
- $("#showIco").attr("class", "fa fa-angle-double-up");
-
- //刷新明细
- refreshItems();
- }else{
- $("#showDetails").hide();
- isShowDetails = false;
- $("#showIco").attr("class", "fa fa-angle-double-down");
- }
- //回到上次焦点地方
- if(focusId!=null && focusId != ''){
- $("#"+focusId).focus();
- }
- }
- function refreshItems(){
- var inventoryCheckId = $("#inventoryCheckId").val();
- var warehouseCode = $("#warehouseCode").val();
- var customerCode = $("#customerCode").val();
- var customerId = $("#customerId").val();
- var locationCode = $("#locationCode").val();
- if(inventoryCheckId == '' || locationCode == ''){return;}
-
-
- $("#itemList").empty();
-
- var formData = {
- inventoryCheckId:inventoryCheckId,
- warehouseCode:warehouseCode,
- customerCode:customerCode,
- customerId:customerId,
- locationCode:locationCode
- };
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.INVENTORY_PLAN_CHECK_2;
- appRequest.msg = JSON.stringify(formData);//msg是消息内容主体
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- success: function (appResponse) {
- if(!appResponse.success){
- playSound('../raw/error.wav');
- return;
- }
- var list = appResponse.extend;
- if(list.length == 0 ){
- playSound('../raw/error.wav');
- return;
- }
- for(var index = 0; index < list.length; index ++){
- var item = list[index];
- handleNullFiled(item);
-
- var tr = "<tr id='item_"+item.id+"'>";
- tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+item.barcode+"</div></th>";
- tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+item.batchNo+"</div></th>";
- tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+item.sysQty+"</div></th>";
- tr += "</tr>";
-
- $("#itemList").append(tr);
- }
- },
- error: function () {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- function selectQuality(){
- var qualityCode = $("#qualityCode").val();
- if(qualityCode != '0'){
- //去条码输入框
- setSelect('barcode');
- }
- }
|