|
|
<#import "../master.ftl" as master><@master.layout><style> #fm label { width: 150px; } #importDlgFm label { width: 150px; }</style>
<div class="page-header"> <h2>Delivery</h2></div>
<table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;" data-options="pagination: true, showFooter: true, singleSelect:true, fitColumns:true , url:'/shipment/all',method:'get',pageSize:20,toolbar:'#tb'"> <thead> <tr> <th data-options="field:'shipNo',width:60">Delivery No</th> <th data-options="field:'shippedBy',width:60,align:'left'">Created By</th> <th data-options="field:'shippedDate',width:130,align:'center',formatter:formatDateTime">Create Date</th> <th data-options="field:'customerConfirmedFlag',width:60,align:'center',formatter:formatConfirmedFlag">Customer Confirm Status</th> <th data-options="field:'ftpPath',width:160,editor:'textbox'">FTP Path</th> <th data-options="field:'ifsDeliveryNoteNo',width:60,editor:'text'">IFS Delivery Note No</th> <th data-options="field:'remark',width:60,editor:'textbox'">Remark</th> <th data-options="field:'id',width:200, formatter:formatAction">Actions</th>
</tr> </thead></table>
<div id="tb" style="padding:10px 5px;display: none;"> <div> Create Date: <input class="easyui-datebox" id="shippedDateFrom" style="width:100px"> 到: <input class="easyui-datebox" id="shippedDateTo" style="width:100px"> 客户确认: <select class="easyui-combobox" panelHeight="auto" id="confirmedFlag" style="width:100px"> <option value="">All</option> <option value="0">To be Confirm</option> <option value="1">Confirmed</option> </select> <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a> <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newShipment()">New Shipment</a> <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" onclick="doUpdateConfirmedFlag()">CS confirm</a> </div></div>
<div id="dlg" class="easyui-dialog" style="width:500px;display: none;" closed="true" buttons="#dlg-buttons"> <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px"> <div style="margin-bottom:10px"> <input name="ifsDeliveryNoteNo" class="easyui-textbox" required="true" label="IFS Delivery Note No:" style="width:100%"> </div> </form></div>
<div id="dlgPlan" class="easyui-dialog" style="width:500px;display: none;" closed="true" buttons="#plan-buttons"> <div style="margin-bottom:10px;padding:20px 20px"> <input id="partNo" class="easyui-textbox" required="true" label="Part no:" style="width:100%"> <br/><br> <input id="toShipQty" class="easyui-textbox" required="true" label="Quantity:" style="width:100%"> </div></div>
<div id="dlgUPlan" class="easyui-dialog" style="width:500px;display: none;" closed="true" buttons="#uplan-buttons"> <div style="margin-bottom:10px;padding:20px 20px"> <input id="planId" type="hidden" value=""> <input id="upartNo" class="easyui-textbox" required="true" label="Part no:" style="width:100%"> <br/><br> <input id="utoShipQty" class="easyui-textbox" required="true" label="Quantity:" style="width:100%"> </div></div>
<div id="dlg-buttons" style="display: none;"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveShipInfo()" style="width:90px">Save</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a></div><!-- 导入数据条件 --><div id="importDlg" class="easyui-dialog" style="width:500px;display: none;" closed="true" buttons="#ImportDelivery-buttons"> <form id="importDlgFm" method="post" novalidate style="margin:0;padding:20px 20px"> <div style="margin-bottom:10px"> <input id="ifsDNoteNo" name="ifsDeliveryNoteNo" class="easyui-textbox" required="true" label="IFS Delivery Note No:" style="width:100%"> </div> </form></div>
<div id="ImportDelivery-buttons" style="display: none;"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="ImportDelivery()" style="width:90px">OK</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#importDlg').dialog('close')" style="width:90px">Cancel</a></div>
<div id="plan-buttons" style="display: none;"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveDelivery()" style="width:90px">Save</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgPlan').dialog('close')" style="width:90px">Cancel</a></div>
<div id="uplan-buttons" style="display: none;"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="updateDelivery()" style="width:90px">Save</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgUPlan').dialog('close')" style="width:90px">Cancel</a></div>
<div id="dlgDtls" class="easyui-dialog" style="width:600px;display: none;" closed="true" data-options="modal:true" > <table id="dgDtls" class="easyui-datagrid" style="width:100%;height:300px;display: none;" data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20,toolbar:'#tbDtls'"> <thead> <tr> <th data-options="field:'boxNo',width:100,formatter:formatPrintBoxNo">Box No</th> <th data-options="field:'id',width:60,formatter:formatDtlAction">Actions</th> </tr> </thead> </table></div><!-- 发货计划 --><div id="delivery" class="easyui-dialog" style="width:600px;display: none;" closed="true" data-options="modal:true" > <table id="deliverys" class="easyui-datagrid" style="width:100%;height:300px;display: none;" data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20,toolbar:'#tdDelivery'"> <thead> <tr> <th data-options="field:'partNo',width:60">Part No</th> <th data-options="field:'toShipQty',width:60">Qty to Ship</th> <th data-options="field:'rollActualQty',width:60">实际数量(按卷标)</th> <th data-options="field:'actualQty',width:60">Actual Qty Shipped</th> <th data-options="field:'id',width:60,formatter:planAction">Actions</th> </tr> </thead> </table></div>
<div id="tbDtls" style="padding:10px 5px;display: none;"> <div> <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newBox()">New Box</a> 扫箱出库: <input id="scanBoxNo" name="scanBoxNo" class="easyui-textbox" style="width: 120px;text-transform:uppercase;" placeholder="FG roll no" /> <#-- <a href="javascript:void(0)" id="forceClosed" class="easyui-linkbutton" onclick="shipBox()">出库</a>--> </div></div>
<div id="tdDelivery" style="padding:10px 5px;display: none;"> <div> <a href="javascript:void(0)" id="planAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newDelivery()">Create shipment plan</a> <a href="javascript:void(0)" id="planImport" class="easyui-linkbutton" iconCls="icon-add" onclick="importDlg()">Import Shipment Plan</a> </div></div>
<div id="dlgRollDtls" class="easyui-dialog" style="width:500px;display: none;" closed="true" data-options="modal:true" > <table id="dgRollDtls" class="easyui-datagrid" style="width:100%;height:400px;display: none;" data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get'"> <thead> <tr> <th data-options="field:'finalRollNo',width:100">FG roll number</th> <th data-options="field:'id',width:40,formatter:formatBoxRollAction">Actions</th> </tr> </thead> </table></div>
<script>
$(window).resize(function () { $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20}); });
$(function () { $(window).resize(); });
$("#queryLink").click(function(){ var dg = $('#dg').datagrid({ queryParams: { confirmedFlag: $("#confirmedFlag").val(), shippedDateFrom: $("#shippedDateFrom").val(), shippedDateTo: $("#shippedDateTo").val() } }); });
function formatPrintBoxNo(value, row){ if (row.status == "Packed") { return "<a target='forprint' href='/print/"+ "box" + "/" +value+"/'>"+value+"</a>"; }else{ return value; } }
function formatConfirmedFlag(value,row) { return value == 1 ? "<font color='green'>Confirmed</font>" : "To be Confirm"; }
function formatAction(value, row){ var str = "<a href='javascript:editInfo()'>Edit</a>" + " | <a href='javascript:delShip(\""+row.shipNo+"\")'>Delete</a>"; str += " | <a href='javascript:viewBoxes(\""+row.shipNo+"\")'>Box View</a>" + " | <a href='javascript:downloadList(\""+row.shipNo+"\")'>Delivery List</a>" + " | <a href='javascript:uploadFTP(\""+row.shipNo+"\")'>Upload to FTP</a>" + " | <a href='javascript:deliveryPlan(\""+row.shipNo+"\")'>Shipment Plan</a>"; return str; }
function formatDtlAction(value, row){ var action = ""; if (row.status != "Packed"){ // action = "<a href='/shipment/boxes/scan/" + value + "'>Scan and delivery</a>"; action = "<a href='/shipment/boxes/scan/" + value + "'>扫描合箱出库</a>"; // action += " | <a href='javascript:delBox(\"" + row.boxNo + "\");'>Delete</a>"; } else { action = "Packed"; // action += " | <a href='javascript:unPackBox(\"" + row.boxNo + "\");'>UnPack</a>"; } action += " | <a href='javascript:viewBoxRolls(\"" + row.boxNo + "\");'>View</a>";
return action; }
//发话计划的操作 function planAction(value, row){ var action = ""; if(row.id==0){ action = " no shipment plan"; }else{ action = " <a href='javascript:delPlan(\"" + value + "\");'>Delete</a>" +" | <a href='javascript:uPlan(\"" + row.id + "\",\"" + row.partNo + "\",\"" + row.toShipQty + "\");'>Edit</a>"; } return action; } //数量不对警告 $('#deliverys').datagrid({ rowStyler:function(index,row){ if (Number(row.rollActualQty)!=Number(row.toShipQty)){ return 'background-color:#ff534d;font-weight:bold;'; } } }); function formatBoxRollAction(value, row){ var action = ""; //获取当前的箱 let currentBox = $('#dgDtls').datagrid('getSelected'); <#if currentUser.isAdmin || (currentUser.authorities?contains("switch_order") && currentUser.authorities?contains("dispatch"))> //判断是否已封箱的 let boxStatus = currentBox.status; if('Packed' == boxStatus){ return ''; }else{ action += "<a href='javascript:delBoxRoll(\"" + row.id + "\");'>Delete</a>"; } </#if> return action; }
var postUrl = ""; function editInfo(){ var row = $('#dg').datagrid('getSelected'); if (row) { $('#dlg').dialog('open').dialog('center').dialog('setTitle', 'Edit'); $('#fm').form('load', row); postUrl="/shipment/"+row.id+"/update"; } }
function doUpdateConfirmedFlag(){ var row = $('#dg').datagrid('getSelected'); if (row) { $.messager.confirm('Confirm','将发货单 <b>'+row.shipNo+'</b> 标记为已确认?',function(r){ if (r){ $.post('/shipment/'+row.id+'/updateConfirmFlag',{},function(result){ if (result.success){ $('#dg').datagrid('reload'); // reload the user data } else { $.messager.alert('error',result.errorMsg, 'error'); } },'json'); } });
}else{ $.messager.alert("Warning", "Select shipment", "warning"); } }
function saveShipInfo(){ $('#fm').form('submit',{ url: postUrl, onSubmit: function(){ return $(this).form('validate'); }, success: function(result){ var result = eval("("+result+")"); if (result.errorMsg){ $.messager.alert("Info",result.error,"Info",); //$('#dlg').dialog('close'); //$('#dg').datagrid('reload'); } else { $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } } }); }
var currentShipNo = ""; function viewBoxes(shipNo){ currentShipNo = shipNo; $('#dlgDtls').dialog('open').dialog('center').dialog('setTitle',shipNo+' Box List'); $("#dgDtls").datagrid({url: "/shipment/boxes/"+shipNo}); } //发货计划 function deliveryPlan(shipNo){ currentShipNo = shipNo; $('#delivery').dialog('open').dialog('center').dialog('setTitle',shipNo+' Box List'); $("#deliverys").datagrid({url: "/shipment/delPlan/"+shipNo}); }
function viewBoxRolls(boxNo){ $('#dlgRollDtls').dialog('open').dialog('center').dialog('setTitle',boxNo+' SFG roll'); $("#dgRollDtls").datagrid({url: "/shipment/box/"+boxNo+"/rolls"}); }
function downloadList(shipNo){ $.post("/shipment/downloadList", {shipNo: shipNo}, function(ret){ if(ret.success){ window.location.href="/prepress/download/"+ret.fileName; }else{ $.messager.alert('Error',ret.errorMsg, 'error'); } }); } //上传至FTP function uploadFTP(shipNo){ $.post("/shipment/downloadListForFTP", {shipNo: shipNo}, function(ret){ if(ret.success){ var fileNameList = ret.fileNameList; if(ret.flag=='Y'){ $.messager.alert('Error','File uploaded!', 'error'); }else{ var fileName = ret.fileName; $.ajax({ url : "/prepress/uploadFTP", type : "POST", data : {"fileName" : fileNameList, "shipNo":shipNo }, dataType : "json", success : function(result) { console.log(result); if(result.success){ alert("Uploaded!"); //saveFTPRecord(result.data,shipNo); $('#dg').datagrid('reload'); }else{ alert("Fail to upload!"); $.messager.alert('Error',result.data, 'error'); } }, error : function() { } }); } }else{ $.messager.alert('Error',ret.errorMsg, 'error'); } }); } //保存FTP上传的记录 function saveFTPRecord(path,shipNo){ $.ajax({ type: 'GET', url: "/shipment/ftp/addFlag", dataType: "json", data: {"shipNo": shipNo, "ftpPath":path }, success: function(result){ console.log(result); if(result.success){ alert("Uploaded!"); } /* $('#dlgPlan').dialog('close'); $('#deliverys').datagrid('reload'); */ }, error : function() { } }); }
function newShipment(){ $.post("/shipment/add", {} , function(data){ if (data.success){ $('#dg').datagrid('reload'); }else{ } }); }
function newBox(){ $.post("/shipment/boxes/add", {shipNo: currentShipNo} , function(data){ if (data.success){ $('#dgDtls').datagrid('reload'); }else{ } }); } //编辑 function uPlan(id,partNo,toShipQty){ $('#dlgUPlan').dialog('open').dialog('center').dialog('setTitle', 'Modify shipment plan'); $('#dlgUPlan form').form('clear'); $("#planId").val(id); $("#upartNo").textbox('setValue', partNo); $("#utoShipQty").textbox('setValue', toShipQty); } //新增发货计划 function newDelivery(){ $('#dlgPlan').dialog('open').dialog('center').dialog('setTitle', 'Create shipment plan'); $('#dlgPlan form').form('clear'); } //新增 function saveDelivery(){ var partNo = $("#partNo").val(); var toShipQty = $("#toShipQty").val(); $.ajax({ type: 'GET', url: "/shipment/Delivery/add", dataType: "json", data: {"shipNo": currentShipNo, "partNo":partNo, "qty":toShipQty }, success: function(data){ $('#dlgPlan').dialog('close'); $('#deliverys').datagrid('reload'); }, error : function() { } }); } //导入发货计划条件 function importDlg(){ $('#importDlg').dialog('open').dialog('center').dialog('setTitle', 'ifsDeliveryNoteNo'); $('#importDlgFm form').form('clear'); } //导入发货计划 function ImportDelivery(){ var IfsDNoteNo = $("#ifsDNoteNo").val(); console.log(IfsDNoteNo); $.post('/shipment/importDelivery',{ifsDNoteNo:IfsDNoteNo,shipNo: currentShipNo},function(result){ if (result.success){ $('#importDlg').dialog('close'); $('#deliverys').datagrid('reload'); } else { $.messager.alert('Error',result.errorMsg, 'error'); } },'json'); } //修改发货计划 function updateDelivery(){ var planId = $("#planId").val(); var partNo = $("#upartNo").val(); var toShipQty = $("#utoShipQty").val(); console.log(planId); $.ajax({ type: 'GET', url: "/shipment/Delivery/update", dataType: "json", data: {"pId":planId, "partNo":partNo, "qty":toShipQty }, success: function(data){ $('#dlgUPlan').dialog('close'); $('#deliverys').datagrid('reload'); }, error : function() { } }); }
function delBoxRoll(boxRollId){ $.messager.confirm('Confirm','Are you sure to delete the data ?',function(r){ if (r){ $.post('/shipment/boxroll/'+boxRollId+'/del',{},function(result){ if (result.success){ $('#dgRollDtls').datagrid('reload'); } else { $.messager.alert('Error',result.errorMsg, 'error'); } },'json'); } }); }
//删除出库单号 function delShip(shipNo){ $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){ if (status){ $.ajax({ url : "/shipment/delShip", type : "POST", data : {shipNo: shipNo}, dataType : "json", success : function(data) { var code = data.code; if(code=='0'){ $('#dg').datagrid('reload'); $.messager.alert("Info",data.msg,"Info"); }else{ $.messager.alert('Error',data.msg, 'error'); } }, error : function(data) { $.messager.alert('Error',data.msg, 'error'); } }); } }); } //删除出库下的箱子 function delBox(boxNo){ $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){ if (status){ $.ajax({ url : "/shipment/delBox", type : "POST", data : {boxNo: boxNo}, dataType : "json", success : function(data) { var code = data.code; if(code=='0'){ $('#dgDtls').datagrid('reload'); $.messager.alert("Info",data.msg,"Info",); }else{ $.messager.alert('Error',data.msg, 'error'); } }, error : function(data) { $.messager.alert('Error',data.msg, 'error'); } }); } }); } //拆封 function unPackBox(boxNo){ $.messager.confirm('Confirm','Are you sure unpack the box:'+boxNo+' ?',function(status){ if (status){ $.ajax({ url : "/shipment/unPackBox", type : "POST", data : {boxNo: boxNo}, dataType : "json", success : function(data) { if(data.success){ $('#dgDtls').datagrid('reload'); $.messager.alert("Info",data.msg,"Info",); }else{ $.messager.alert('Error',data.msg, 'error'); } }, error : function(data) { $.messager.alert('Error',data.msg, 'error'); } }); } }); } //删除发货计划 function delPlan(id){ console.log(id); $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){ if (status){ $.ajax({ url : "/shipment/delPlan", type : "POST", data : {id: id}, dataType : "json", success : function(data) { var code = data.code; if(code=='0'){ $('#deliverys').datagrid('reload'); $.messager.alert("Info",data.msg,"Info",); }else{ $.messager.alert('Error',data.msg, 'error'); } }, error : function(data) { $.messager.alert('Error',data.msg, 'error'); } }); } }); }
//2023 0528 RQ 新增
// $("#scanBoxNo").on("keydown", function(event){ // console.log("回车拉") // var scanBoxNo = $(this).val(); // if(event.keyCode == 13){ // $.post("/receive/scan/add", {shipNo:currentShipNo, finalRollNo: scanBoxNo} , function(data){ // if (data.success){ // $("#ifmforprint").attr('src', "/print/box/" + scanBoxNo + "/"); // $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo}); // $.messager.alert("Info","Shipped","Info",); // $("#finalRollNo").textbox('setValue',"").focus(); // }else{ // $.messager.alert('Error',data.errorMsg, 'error'); // $("#finalRollNo").textbox('setValue',"").focus(); // } // // }); // } // }).on("blur", function() { // $(this).textbox('setValue',$(this).val().trim().toUpperCase()); // }) $("#scanBoxNo").textbox({ inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents,{ keyup:function(event){ if(event.keyCode == 13){ console.log("回车"); let scanBoxNo=$("#scanBoxNo").val(); $.post("/shipment/boxes/shipBox", {shipNo:currentShipNo, scanBoxNo: scanBoxNo} , function(data){ if (data.success){ $("#ifmforprint").attr('src', "/print/box/" + scanBoxNo + "/"); $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo}); $.messager.alert("Info","Shipped","Info",); $("#scanBoxNo").textbox('setValue',"").focus(); }else{ $.messager.alert('Error',data.errorMsg, 'error'); $("#scanBoxNo").textbox('setValue',"").focus(); }
}); } } }) })
function shipBox(){ var scanBoxNo = $("#scanBoxNo").val(); $.post("/shipment/boxes/shipBox", {shipNo:currentShipNo, scanBoxNo: scanBoxNo} , function(data){ if (data.success){ $("#ifmforprint").attr('src', "/print/box/" + scanBoxNo + "/"); $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo}); $.messager.alert("Info","Shipped","Info",); $("#scanBoxNo").textbox('setValue',"").focus(); }else{ $.messager.alert('Error',data.errorMsg, 'error'); $("#scanBoxNo").textbox('setValue',"").focus(); }
}); }
</script>
</@master.layout>
|