123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- $(function(){
-
- var focusId;
- $("input").focus(function(){
- //记住焦点位置
- focusId = this.id;
- //this.scrollIntoView(true);//回到顶部
- //window.setTimeout("myScrollIntoView()",100);
- });
-
- setTimeout(function() {
- $('#orderNo').focus();
- }, 1000);
- //同步手工改数量
- var last_qty = $("#_quantity").val();
- function setQuantity(){
- var _qty = $("#_quantity").val();
- if(_qty < 0){
- $("#_quantity").val(0);
- return;
- }
- if(_qty == last_qty){
- return;
- }
- last_qty = _qty;
- $("#quantity").val(_qty);
- }
- window.setInterval(setQuantity,500);
-
- //当失去焦点按回车时,焦点回到之前焦点位置
- $(window).keydown(function(event){
- if((event.keyCode==13)) {
- if(document.activeElement.id == null || document.activeElement.id ==''){
- //回到上次焦点地方
- //$("#"+focusId).focus();
- }
- }
- });
- $('#orderNo').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#orderNo").val(trimStr($("#orderNo").val()));
- if($('#orderNo').val()!=''){
- //播放扫描声音
- playSound('../raw/scan.wav');
- //player('../raw/scan.wav');
- submitOrderNo();
- }
- });
-
- $('#barcode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#barcode").val(trimStr($("#barcode").val()));
- if($("#barcode").val() !='' ){
- //播放扫描声音
- playSound('../raw/scan.wav');
-
- submitBarcode();
- }
- });
-
- $('#locationCode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#locationCode").val(trimStr($("#locationCode").val()));
- if($("#locationCode").val() !='' ){
- //播放扫描声音
- playSound('../raw/scan.wav');
-
- setFocus('quantity');
- }
- });
-
- $('#quantity').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- if($("#quantity").val() !='' ){
- //提交上架
- submitInShelf();
- }
- });
- });
- //提交入库单号
- function submitOrderNo(){
- var orderNo = $('#orderNo').val();
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.IN_SHELF_1;
- appRequest.msg = orderNo;//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('orderNo'); });
- return;
- }
-
- mui.toast(appResponse.msg);
-
- var order = appResponse.extend;
-
- $("#inOrderId").val(order.id);
- $("#inOrderType").val(order.typeCode);
-
- $("#warehouseCode").val(order.warehouseCode);
- $("#customerCode").val(order.customerCode);
- $("#customerId").val(order.customerId);
-
-
- next();
- },
- error: function () {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- //提交商品条码
- function submitBarcode(){
- var inOrderId = $('#inOrderId').val();
-
- var orderNo = $('#orderNo').val();
- var barcode = $('#barcode').val();
- var formData = {inOrderId:inOrderId,orderNo:orderNo,barcode:barcode};
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.IN_SHELF_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() { setFocus('barcode'); });
- return;
- }
-
- mui.toast(appResponse.msg);
- //返回收货记录 可能是多条
- var list = appResponse.extend;
- if(list.length == 0 ){
- playSound('../raw/error.wav');
- mui.alert('后台返回list长度为0', '警告', function() { setFocus('barcode'); });
- return;
- }
- //暂先只处理第一条.. 后续可改为界面选择一条
- var inReceipt = list[0];
- $("#inReceiptId").val(inReceipt.id);//收货记录id
- $("#batchNo").val(inReceipt.batchNo);//批次号码
- $("#receiptQuantity").val(inReceipt.quantity);//收货数量
- $('#receiptQualityCode').val(inReceipt.qualityName);//选中收货品质
- $('#shelfQualityCode').val(inReceipt.qualityCode);
-
- //获取推荐库位
- getRecommendLocationCode();
-
- //跳到库位
- $('#locationCode').focus();
- },
- error: function () {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- //获取推荐库位
- function getRecommendLocationCode(){
- var recommendRuleCode = $("#recommendRuleCode").val();
- var warehouseCode = $("#warehouseCode").val();
- var barcode = $("#barcode").val();
- var qualityCode = $("#shelfQualityCode").val();
- var customerId = $("#customerId").val();
- var inOrderId = $("#inOrderId").val();
- var inOrderType = $("#inOrderType").val();
-
-
- var _inReceipt ={};//只取部分参数
- _inReceipt.recommendRuleCode = recommendRuleCode;
- _inReceipt.warehouseCode = warehouseCode;
- _inReceipt.barcode = barcode;
- _inReceipt.qualityCode = qualityCode;
- _inReceipt.customerId = customerId;
- _inReceipt.inOrderId = inOrderId;
- _inReceipt.inOrderType = inOrderType;
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.GetRecommendLocationCode;
- appRequest.msg = JSON.stringify(_inReceipt);//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;
- $("#recommendLocationCode").val(locationCode);//推荐库位
- }
- });
- return locationCode;
- }
- //提交上架
- var isSubmintIng = false;//是否正在提交. 防止按回车太快
- function submitInShelf(){
- if(isSubmintIng){return;}
- isSubmintIng = true;
-
- var inOrderId = $("#inOrderId").val()+'';
- var orderNo = $("#orderNo").val();
-
- var barcode = $("#barcode").val();
- var inReceiptId = $("#inReceiptId").val();
-
- var qualityCode = $("#shelfQualityCode").val();//上架品质 -- 已控制跟收货品质相同
- var quantity = $("#quantity").val();
-
- var locationCode = $("#locationCode").val();//实际上架库位
-
- var customerCode = $("#customerCode").val();
- var warehouseCode = $("#warehouseCode").val();
-
- if(inReceiptId == ''){
- mui.toast('请先提交商品条码');
- isSubmintIng = false;
- return;
- }
-
- if(inOrderId == '' || locationCode == '' || barcode == ''){
- isSubmintIng = false;
- return;
- }
-
- var formData = {
- inOrderId:inOrderId,
- orderNo:orderNo,
- barcode:barcode,
- inReceiptId:inReceiptId,
- locationCode:locationCode,
- qualityCode:qualityCode,
- quantity:quantity
- };
-
- var appRequest = $appRequest;//复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.IN_SHELF_3;
- 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');
-
- //下一个条码
- next();
-
- //整单完成. 下一个入库单
- if(appResponse.extend){cleanAll();}
- },
- error: function () {
- isSubmintIng = false;
- nwaiting.close();
-
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- //下一个条码
- function next(){
- $("#barcode").val("");
- $("#inReceiptId").val("");
-
- $("#batchNo").val("");//批次号码
- $("#receiptQuantity").val("");//收货数量
-
- $("#quantity").val("");
- $("#_quantity").val("0");
-
- $("#recommendLocationCode").val("");
- $("#locationCode").val("");
-
- $("#receiptQualityCode").val('');
- $("#shelfQualityCode").val("");
-
- $("#barcode").focus();
- }
- //下一个订单
- function cleanAll(){
- $("#inOrderId").val("");
- $("#inOrderType").val("");
-
- $("#orderNo").val("");
-
- $("#warehouseCode").val("");
- $("#customerCode").val("");
-
- $("#barcode").val("");
- $("#inReceiptId").val("");
-
- $("#batchNo").val("");//批次号码
- $("#receiptQuantity").val("");//收货数量
-
- $("#quantity").val("");
- $("#_quantity").val("0");
- $("#recommendLocationCode").val("");
- $("#locationCode").val("");
- $("#receiptQualityCode").val('');
- $("#shelfQualityCode").val("");
-
- $("#orderNo").focus();
- playSound('../raw/ok.wav');
- mui.toast('入库单上架成功,请录入下一单。');
- }
|