123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- $(function(){
-
- var focusId;
- $('#locationCode').focus();
- //如不使用延迟执行, 有时候会无效
- setTimeout(function() {
- var $warehouseCode = localStorage.getItem('$warehouseCode');
- $("#warehouseCode").val($warehouseCode);
-
- $('#locationCode').focus();
- }, 1000);
- //提交库位号
- $('#locationCode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#locationCode").val(trimStr($("#locationCode").val()));
- if($('#locationCode').val()!=''){
- //播放扫描声音
- playSound('../raw/scan.wav');
- console.log('locationCode:')
- setFocus("barcode")
- }
- });
-
- //提交商品条码
- $('#barcode').keyup(function (event) {
- if (event.keyCode != "13") {return false;}
- $("#barcode").val(trimStr($("#barcode").val()));
- if($("#barcode").val() !='' ){
- //播放扫描声音
- playSound('../raw/scan.wav');
- console.log('barcode:')
- submitBarcode();
- }
- });
- });
-
- //提交商品条码
- var inventoryMap = {};
- var outShelfInventoryId = -1;
- function submitBarcode() {
- outShelfInventoryId = -1;
-
- var locationCode = $("#locationCode").val();
- var barcode = $("#barcode").val();
- var msgBody = {};
- msgBody.locationCode = locationCode;
- msgBody.warehouseCode = $("#warehouseCode").val();
- msgBody.barcode = barcode;
- //序列化成字符串
- var msgBodyStr = JSON.stringify(msgBody)
- var appRequest = $appRequest; //复制请求封装对象
- appRequest.opType = OP_TYPE_MENU.LOCATION_INVENTORY;
- appRequest.msg = msgBodyStr; //msg是消息内容主体
- $.ajax({
- type: 'POST',
- url: $appRequestUrl,
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(appRequest),
- success: function(appResponse) {
- if(!appResponse.success || appResponse.extend.length==0) {
- playSound('../raw/error.wav');
- mui.toast("该库位和商品条码未查到库存");
- return;
- }
- $("#barcodeShow").val(barcode);
-
- console.log('respnse:'+appResponse)
- var listInventory = appResponse.extend;
- if(listInventory.length > 1) { //出现多条记录时选择
- var listLi = [];
- for(var i = 0; i < listInventory.length; i++) {
- var inventorySingle = listInventory[i];
- inventoryMap[inventorySingle.id] = inventorySingle;
- listLi.push('<li class="mui-table-view-cell" onclick="selectInventory(\'' + inventorySingle.id + '\')">批次:' + inventorySingle.batchNo + '; 商品品质:' + inventorySingle.qualityName + '; 溯源:' + inventorySingle.inOrderNo1 + '; 可用数量:' + inventorySingle.qtyAvail + ' </li>');
- }
- var listLiStr = listLi.join('')
- $("#inventoryListDetail").html(listLiStr);
- mui("#inventoryListShow").popover('show'); //show hide toggle
- return
- }
- var inventorySingle = listInventory[0];
- $("#inOrderNo").val(inventorySingle.inOrderNo1);
- $("#batchNo").val(inventorySingle.batchNo)
- $("#qualityName").val(inventorySingle.qualityName)
- $("#sysQty").val(inventorySingle.qtyAvail)
- $("#qtyTotal").val(inventorySingle.qtyTotal)
- $("#expiryDate").val(fmtDate(inventorySingle.expiryDate))
- outShelfInventoryId = inventorySingle.id;
- console.log("outShelfInventoryId:" + outShelfInventoryId)
- },
- error: function() {
- playSound('../raw/error.wav');
- mui.toast('网络断开或服务器发生异常');
- }
- });
- }
- //选择一个库存
- function selectInventory(inventoryId){
- outShelfInventoryId = inventoryId;
-
- var inventorySingle=inventoryMap[outShelfInventoryId]
- $("#inOrderNo").val(inventorySingle.inOrderNo1);
- $("#batchNo").val(inventorySingle.batchNo)
- $("#qualityName").val(inventorySingle.qualityName)
- $("#sysQty").val(inventorySingle.qtyAvail)
- $("#qtyTotal").val(inventorySingle.qtyTotal)
- $("#expiryDate").val(fmtDate(inventorySingle.expiryDate))
-
- mui('#inventoryListShow').popover('toggle');
- setFocus('qty');
- }
- //下一个转移任务
- function cleanAll() {
- $(".allowClear").each(function() {
- $(this).val("")
- })
- $("#locationCode").focus();
- }
|