You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

839 lines
33 KiB

3 days ago
3 days ago
3 days ago
3 days ago
  1. <#import "../master.ftl" as master>
  2. <@master.layout>
  3. <style>
  4. #fm label {
  5. width: 150px;
  6. }
  7. #addFm label {
  8. width: 150px;
  9. }
  10. #importDlgFm label {
  11. width: 150px;
  12. }
  13. </style>
  14. <div class="page-header">
  15. <h2>Delivery</h2>
  16. </div>
  17. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  18. data-options="pagination: true, showFooter: true, singleSelect:true, fitColumns:true , url:'/shipment/all',method:'get',pageSize:20,toolbar:'#tb'">
  19. <thead>
  20. <tr>
  21. <th data-options="field:'shipNo',width:60">Delivery No</th>
  22. <th data-options="field:'shippedBy',width:60,align:'left'">Created By</th>
  23. <th data-options="field:'shippedDate',width:130,align:'center',formatter:formatDateTime">Create Date</th>
  24. <th data-options="field:'customerConfirmedFlag',width:120,align:'center',formatter:formatConfirmedFlag">Customer Confirm Status</th>
  25. <th data-options="field:'ftpPath',width:160,editor:'textbox'">FTP Path</th>
  26. <th data-options="field:'ifsDeliveryNoteNo',width:120,editor:'text'">IFS Delivery Note No</th>
  27. <th data-options="field:'remark',width:60,editor:'textbox'">Remark</th>
  28. <th data-options="field:'id',width:200, formatter:formatAction">Actions</th>
  29. </tr>
  30. </thead>
  31. </table>
  32. <div id="tb" style="padding:10px 5px;display: none;">
  33. <div>
  34. Create Date: <input class="easyui-datebox" id="shippedDateFrom" style="width:100px">
  35. 到: <input class="easyui-datebox" id="shippedDateTo" style="width:100px">
  36. 客户确认:
  37. <select class="easyui-combobox" panelHeight="auto" id="confirmedFlag" style="width:100px">
  38. <option value="">All</option>
  39. <option value="0">To be Confirm</option>
  40. <option value="1">Confirmed</option>
  41. </select>
  42. <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  43. &nbsp;&nbsp;&nbsp;
  44. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="addInfo()">New Shipment</a>
  45. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" onclick="doUpdateConfirmedFlag()">CS confirm</a>
  46. </div>
  47. </div>
  48. <div id="dlg" class="easyui-dialog" style="width:500px;display: none;"
  49. closed="true" buttons="#dlg-buttons">
  50. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  51. <div style="margin-bottom:10px">
  52. <input name="ifsDeliveryNoteNo" class="easyui-textbox" required="true" label="IFS Delivery Note No:" style="width:100%">
  53. </div>
  54. </form>
  55. </div>
  56. <div id="dlg-buttons" style="display: none;">
  57. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveShipInfo()" style="width:90px">Save</a>
  58. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  59. </div>
  60. <div id="addDlg" class="easyui-dialog" style="width:500px;display: none;"
  61. closed="true" buttons="#addDlg-buttons">
  62. <form id="addFm" method="post" novalidate style="margin:0;padding:20px 20px">
  63. <div style="margin-bottom:10px">
  64. <input name="addIfsDeliveryNoteNo" id="addIfsDeliveryNoteNo" class="easyui-textbox" required="true" label="IFS Delivery Note No:" style="width:100%">
  65. <br/><br>
  66. <input id="addRemark" class="easyui-textbox" label="Remark:" style="width:100%">
  67. </div>
  68. </form>
  69. </div>
  70. <div id="addDlg-buttons" style="display: none;">
  71. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveShipment()" style="width:90px">Save</a>
  72. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#addDlg').dialog('close')" style="width:90px">Cancel</a>
  73. </div>
  74. <div id="dlgPlan" class="easyui-dialog" style="width:500px;display: none;"
  75. closed="true" buttons="#plan-buttons">
  76. <div style="margin-bottom:10px;padding:20px 20px">
  77. <input id="partNo" class="easyui-textbox" required="true" label="Part no:" style="width:100%">
  78. <br/><br>
  79. <input id="toShipQty" class="easyui-textbox" required="true" label="Quantity:" style="width:100%">
  80. </div>
  81. </div>
  82. <div id="dlgUPlan" class="easyui-dialog" style="width:500px;display: none;"
  83. closed="true" buttons="#uplan-buttons">
  84. <div style="margin-bottom:10px;padding:20px 20px">
  85. <input id="planId" type="hidden" value="">
  86. <input id="upartNo" class="easyui-textbox" required="true" label="Part no:" style="width:100%">
  87. <br/><br>
  88. <input id="utoShipQty" class="easyui-textbox" required="true" label="Quantity:" style="width:100%">
  89. </div>
  90. </div>
  91. <!-- 导入数据条件 -->
  92. <div id="importDlg" class="easyui-dialog" style="width:500px;display: none;"
  93. closed="true" buttons="#ImportDelivery-buttons">
  94. <form id="importDlgFm" method="post" novalidate style="margin:0;padding:20px 20px">
  95. <div style="margin-bottom:10px">
  96. <input id="ifsDNoteNo" name="ifsDeliveryNoteNo" class="easyui-textbox" required="true" label="IFS Delivery Note No:" style="width:100%">
  97. </div>
  98. </form>
  99. </div>
  100. <div id="ImportDelivery-buttons" style="display: none;">
  101. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="ImportDelivery()" style="width:90px">OK</a>
  102. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#importDlg').dialog('close')" style="width:90px">Cancel</a>
  103. </div>
  104. <div id="plan-buttons" style="display: none;">
  105. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveDelivery()" style="width:90px">Save</a>
  106. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgPlan').dialog('close')" style="width:90px">Cancel</a>
  107. </div>
  108. <div id="uplan-buttons" style="display: none;">
  109. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="updateDelivery()" style="width:90px">Save</a>
  110. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgUPlan').dialog('close')" style="width:90px">Cancel</a>
  111. </div>
  112. <div id="dlgDtls" class="easyui-dialog" style="width:600px;display: none;"
  113. closed="true" data-options="modal:true" >
  114. <table id="dgDtls" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  115. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20,toolbar:'#tbDtls'">
  116. <thead>
  117. <tr>
  118. <th data-options="field:'boxNo',width:60,formatter:formatPrintBoxNo">Box No</th>
  119. <th data-options="field:'partNo',width:60,editor:'textbox'">Part No</th>
  120. <th data-options="field:'id',width:60,formatter:formatDtlAction">Actions</th>
  121. </tr>
  122. </thead>
  123. </table>
  124. </div>
  125. <!-- 发货计划 -->
  126. <div id="delivery" class="easyui-dialog" style="width:700px;display: none;"
  127. closed="true" data-options="modal:true" >
  128. <table id="deliverys" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  129. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20,toolbar:'#tdDelivery'">
  130. <thead>
  131. <tr>
  132. <th data-options="field:'partNo',width:60">Part No</th>
  133. <th data-options="field:'toShipQty',width:40">Qty to Ship</th>
  134. <th data-options="field:'rollActualQty',width:50">实际数量(按卷标)</th>
  135. <th data-options="field:'actualQty',width:40">Actual Qty Shipped</th>
  136. <th data-options="field:'id',width:120,formatter:planAction">Actions</th>
  137. </tr>
  138. </thead>
  139. </table>
  140. </div>
  141. <div id="tbDtls" style="padding:10px 5px;display: none;">
  142. <div>
  143. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newBox()">New Box</a>
  144. 扫箱出库:&nbsp;&nbsp;&nbsp;<input id="scanBoxNo" name="scanBoxNo" class="easyui-textbox" style="width: 120px;text-transform:uppercase;" placeholder="FG roll no" />
  145. &nbsp;&nbsp;&nbsp;
  146. <#-- <a href="javascript:void(0)" id="forceClosed" class="easyui-linkbutton" onclick="shipBox()">出库</a>-->
  147. </div>
  148. </div>
  149. <div id="tdDelivery" style="padding:10px 5px;display: none;">
  150. <div>
  151. <a href="javascript:void(0)" id="planAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newDelivery()">Create shipment plan</a>
  152. <a href="javascript:void(0)" id="planImport" class="easyui-linkbutton" iconCls="icon-add" onclick="importDlg()">Import Shipment Plan</a>
  153. </div>
  154. </div>
  155. <div id="dlgRollDtls" class="easyui-dialog" style="width:500px;display: none;"
  156. closed="true" data-options="modal:true,toolbar:'#dlgRollDtlstb'" >
  157. <table id="dgRollDtls" class="easyui-datagrid" style="width:100%;height:400px;display: none;"
  158. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get'">
  159. <thead>
  160. <tr>
  161. <th data-options="field:'finalRollNo',width:100">FG roll number</th>
  162. <th data-options="field:'id',width:40,formatter:formatBoxRollAction">Actions</th>
  163. </tr>
  164. </thead>
  165. </table>
  166. </div>
  167. <div id="dlgRollDtlstb" style="padding:10px 5px;display: none;">
  168. <div>
  169. 扫卷出库:&nbsp;&nbsp;&nbsp;<input id="finalRollNo" name="finalRollNo" class="easyui-textbox" style="width: 120px;text-transform:uppercase;" placeholder="FG roll no" />
  170. &nbsp;&nbsp;&nbsp;
  171. <#-- <a href="javascript:void(0)" id="forceClosed" class="easyui-linkbutton" onclick="warehouse()">Receive</a>-->
  172. <a href="javascript:void(0)" id="boxingButton" class="easyui-linkbutton" onclick="doBoxing(nowBoxNo)">Pack</a>
  173. <#-- <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newReceive()">New Box</a>-->
  174. </div>
  175. </div>
  176. <div id="planList" class="easyui-dialog" style="width:500px;display: none;"
  177. closed="true" data-options="modal:true" >
  178. <table id="planLists" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  179. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20,">
  180. <thead>
  181. <tr>
  182. <th data-options="field:'date',width:60,formatter:formatDate">日期</th>
  183. <th data-options="field:'boxQty',width:60">Count of Boxes</th>
  184. <th data-options="field:'snQty',width:60">Qty Counted By Rolls</th>
  185. <th data-options="field:'locationNo',width:60">Location No</th>
  186. </tr>
  187. </thead>
  188. </table>
  189. </div>
  190. <script>
  191. var uploadFlag=false;
  192. var rollActualQtyRow
  193. $(window).resize(function () {
  194. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  195. });
  196. $(function () {
  197. $(window).resize();
  198. });
  199. var nowBoxNo='';
  200. var boxStatus='';
  201. $("#queryLink").click(function(){
  202. var dg = $('#dg').datagrid({
  203. queryParams: {
  204. confirmedFlag: $("#confirmedFlag").val(),
  205. shippedDateFrom: $("#shippedDateFrom").val(),
  206. shippedDateTo: $("#shippedDateTo").val()
  207. }
  208. });
  209. });
  210. function formatPrintBoxNo(value, row){
  211. if (row.status == "Packed") {
  212. return "<a target='forprint' href='/print/"+ "box" + "/" +value+"/'>"+value+"</a>";
  213. }else{
  214. return value;
  215. }
  216. }
  217. function formatConfirmedFlag(value,row) {
  218. return value == 1 ? "<font color='green'>Confirmed</font>" : "To be Confirm";
  219. }
  220. function formatAction(value, row){
  221. var str = "<a href='javascript:editInfo()'>Edit</a>" + "&nbsp;|&nbsp;<a href='javascript:delShip(\""+row.shipNo+"\")'>Delete</a>";
  222. str += "&nbsp;|&nbsp;<a href='javascript:viewBoxes(\""+row.shipNo+"\")'>Box View</a>"
  223. + "&nbsp;|&nbsp;<a href='javascript:downloadList(\""+row.shipNo+"\")'>Delivery List</a>"
  224. + "&nbsp;|&nbsp;<a href='javascript:uploadFTP(\""+row.shipNo+"\")'>Upload to FTP</a>"
  225. + "&nbsp;|&nbsp;<a href='javascript:deliveryPlan(\""+row.shipNo+"\")'>Shipment Plan</a>";
  226. return str;
  227. }
  228. function formatDtlAction(value, row){
  229. var action = "";
  230. if (row.status != "Packed"){
  231. // action = "<a href='/shipment/boxes/scan/" + value + "'>Scan and delivery</a>";
  232. // action = "<a href='/shipment/boxes/scan/" + value + "'>扫描合箱出库</a>";
  233. action = "Unpacked";
  234. action += "&nbsp;|&nbsp;<a href='javascript:delBox(\"" + row.boxNo + "\");'>Delete</a>";
  235. } else {
  236. action = "Packed";
  237. action += "&nbsp;|&nbsp;<a href='javascript:unPackBox(\"" + row.boxNo + "\");'>UnPack</a>";
  238. }
  239. action += "&nbsp;|&nbsp;<a href='javascript:viewBoxRolls(\"" + row.boxNo+"\",\"" + row.status + "\");'>View</a>";
  240. return action;
  241. }
  242. //发话计划的操作
  243. function planAction(value, row){
  244. var action = "";
  245. if(row.id==0){
  246. action = "&nbsp;no shipment plan";
  247. }else{
  248. action="&nbsp;<a href='javascript:shipPlanList(\"" + row.partNo +"\",\"" + currentShipNo + "\");'>Delivery List</a>"
  249. +"&nbsp;|&nbsp;<a href='javascript:downPlanList(\"" + row.partNo +"\",\"" + currentShipNo + "\");'>Download</a>"
  250. <#if currentUser.isAdmin || (currentUser.authorities?contains("shipPlan_update"))>
  251. action += "&nbsp;|&nbsp;<a href='javascript:delPlan(\"" + value +"\",\"" + row.rollActualQty+ "\");'>Delete</a>"
  252. </#if>
  253. <#if currentUser.isAdmin>
  254. action+="&nbsp;|&nbsp;<a href='javascript:uPlan(\"" + row.id + "\",\"" + row.partNo + "\",\"" + row.toShipQty +"\",\"" + row.rollActualQty + "\");'>Edit</a>";
  255. </#if>
  256. }
  257. return action;
  258. }
  259. //数量不对警告
  260. $('#deliverys').datagrid({
  261. rowStyler:function(index,row){
  262. if (Number(row.rollActualQty)!=Number(row.toShipQty)){
  263. return 'background-color:#ff534d;font-weight:bold;';
  264. }
  265. }
  266. });
  267. function formatBoxRollAction(value, row){
  268. var action = "";
  269. //获取当前的箱
  270. if('Unpacked' == boxStatus){
  271. action += "<a href='javascript:delBoxRoll(\"" + row.id + "\");'>Delete</a>";
  272. }else{
  273. return '';
  274. }
  275. return action;
  276. }
  277. var postUrl = "";
  278. function editInfo(){
  279. var row = $('#dg').datagrid('getSelected');
  280. if (row) {
  281. $('#dlg').dialog('open').dialog('center').dialog('setTitle', 'Edit');
  282. $('#fm').form('load', row);
  283. postUrl="/shipment/"+row.id+"/update";
  284. }
  285. }
  286. function addInfo(){
  287. $('#addDlg').dialog('open').dialog('center').dialog('setTitle', 'New');
  288. $('#addFm').form('clear');
  289. }
  290. function doUpdateConfirmedFlag(){
  291. var row = $('#dg').datagrid('getSelected');
  292. if (row) {
  293. $.messager.confirm('Confirm','将发货单 <b>'+row.shipNo+'</b> 标记为已确认?',function(r){
  294. if (r){
  295. $.post('/shipment/'+row.id+'/updateConfirmFlag',{},function(result){
  296. if (result.success){
  297. $('#dg').datagrid('reload'); // reload the user data
  298. } else {
  299. $.messager.alert('error',result.errorMsg, 'error');
  300. }
  301. },'json');
  302. }
  303. });
  304. }else{
  305. $.messager.alert("Warning", "Select shipment", "warning");
  306. }
  307. }
  308. function saveShipInfo(){
  309. $('#fm').form('submit',{
  310. url: postUrl,
  311. onSubmit: function(){
  312. return $(this).form('validate');
  313. },
  314. success: function(result){
  315. var result = eval("("+result+")");
  316. if (result.errorMsg){
  317. $.messager.alert("Info",result.error,"Info",);
  318. //$('#dlg').dialog('close');
  319. //$('#dg').datagrid('reload');
  320. } else {
  321. $('#dlg').dialog('close'); // close the dialog
  322. $('#dg').datagrid('reload'); // reload the user data
  323. }
  324. }
  325. });
  326. }
  327. var currentShipNo = "";
  328. function viewBoxes(shipNo){
  329. currentShipNo = shipNo;
  330. $('#dlgDtls').dialog('open').dialog('center').dialog('setTitle',shipNo+' Box List');
  331. $("#dgDtls").datagrid({url: "/shipment/boxes/"+shipNo});
  332. }
  333. //发货计划
  334. function deliveryPlan(shipNo){
  335. currentShipNo = shipNo;
  336. $('#delivery').dialog('open').dialog('center').dialog('setTitle',shipNo+' Box List');
  337. $("#deliverys").datagrid({url: "/shipment/delPlan/"+shipNo});
  338. }
  339. //出货清单
  340. function shipPlanList(partNo,shipNo){
  341. $('#planList').dialog('open').dialog('center').dialog('setTitle','Delivery List');
  342. $("#planLists").datagrid({url: "/shipment/shipPlanList/"+shipNo+"/"+partNo});
  343. }
  344. function downPlanList(partNo,shipNo){
  345. $.messager.confirm('Confirm','Are you sure to export the list?',function(r){
  346. if (r){
  347. window.location.href = '/export/laser/downPlanList?shipNo='+shipNo+"&partNo="+partNo;
  348. }
  349. });
  350. }
  351. function viewBoxRolls(boxNo,status){
  352. nowBoxNo=boxNo;
  353. boxStatus=status;
  354. if(status=='Unpacked'){
  355. $("#finalRollNo").textbox({disabled:false});
  356. // enableEl("#boxingButton",true);
  357. $("#boxingButton").linkbutton({"disabled": false});
  358. }else {
  359. $("#finalRollNo").textbox({disabled:true});
  360. // enableEl("#boxingButton",false);
  361. $("#boxingButton").linkbutton({"disabled": true});
  362. }
  363. console.log(nowBoxNo)
  364. $('#dlgRollDtls').dialog('open').dialog('center').dialog('setTitle',nowBoxNo+' SFG roll');
  365. $("#dgRollDtls").datagrid({url: "/shipment/box/"+boxNo+"/rolls"});
  366. $("#finalRollNo").focus();
  367. }
  368. function downloadList(shipNo){
  369. $.post("/shipment/downloadList", {shipNo: shipNo}, function(ret){
  370. if(ret.success){
  371. window.location.href="/prepress/download/"+ret.fileName;
  372. }else{
  373. $.messager.alert('Error',ret.errorMsg, 'error');
  374. }
  375. });
  376. }
  377. //上传至FTP
  378. function uploadFTP(shipNo){
  379. if(uploadFlag){
  380. $.messager.alert('Error','Please wait till the previous upload finished!', 'error');
  381. return false;
  382. }
  383. uploadFlag=true
  384. $.post("/shipment/downloadListForFTP", {shipNo: shipNo}, function(ret){
  385. if(ret.success){
  386. var fileNameList = ret.fileNameList;
  387. if(ret.flag=='Y'){
  388. uploadFlag=false
  389. $.messager.alert('Error','File uploaded!', 'error');
  390. }else{
  391. var fileName = ret.fileName;
  392. $.ajax({
  393. url : "/prepress/uploadFTP",
  394. type : "POST",
  395. data : {"fileName" : fileNameList,
  396. "shipNo":shipNo
  397. },
  398. dataType : "json",
  399. success : function(result) {
  400. uploadFlag=false
  401. console.log(result);
  402. if(result.success){
  403. alert("Uploaded!"+result.msg);
  404. //saveFTPRecord(result.data,shipNo);
  405. $('#dg').datagrid('reload');
  406. }else{
  407. alert("Fail to upload!");
  408. $.messager.alert('Error',result.data, 'error');
  409. }
  410. },
  411. error : function() {
  412. uploadFlag=false
  413. }
  414. });
  415. }
  416. }else{
  417. uploadFlag=false
  418. $.messager.alert('Error',ret.errorMsg, 'error');
  419. }
  420. });
  421. }
  422. //保存FTP上传的记录
  423. function saveFTPRecord(path,shipNo){
  424. $.ajax({
  425. type: 'GET',
  426. url: "/shipment/ftp/addFlag",
  427. dataType: "json",
  428. data: {"shipNo": shipNo,
  429. "ftpPath":path
  430. },
  431. success: function(result){
  432. console.log(result);
  433. if(result.success){
  434. alert("Uploaded!");
  435. }
  436. /* $('#dlgPlan').dialog('close');
  437. $('#deliverys').datagrid('reload'); */
  438. },
  439. error : function() {
  440. }
  441. });
  442. }
  443. function newShipment(){
  444. $.post("/shipment/add", {} , function(data){
  445. if (data.success){
  446. $('#dg').datagrid('reload');
  447. }else{
  448. }
  449. });
  450. }
  451. function saveShipment(){
  452. let addNo = $("#addIfsDeliveryNoteNo").val();
  453. let remark=$("#addRemark").val();
  454. if(addNo==null||addNo==''){
  455. $.messager.alert('Error',"Please input IFS Shipment No", 'error');
  456. return false
  457. }
  458. $.post("/shipment/addShipment", {ifsDNoteNo: addNo,remark:remark} , function(data){
  459. if (data.success){
  460. $('#dg').datagrid('reload');
  461. $('#addDlg').dialog('close')
  462. }else{
  463. $.messager.alert('Error',data.errorMsg, 'error');
  464. }
  465. });
  466. }
  467. function newBox(){
  468. $.post("/shipment/boxes/add", {shipNo: currentShipNo} , function(data){
  469. if (data.success){
  470. $('#dgDtls').datagrid('reload');
  471. viewBoxRolls(data.boxNo,data.box.status);
  472. }else{
  473. }
  474. });
  475. }
  476. //编辑
  477. function uPlan(id,partNo,toShipQty,rollActualQty){
  478. rollActualQtyRow=rollActualQty;
  479. $('#dlgUPlan').dialog('open').dialog('center').dialog('setTitle', 'Modify shipment plan');
  480. $('#dlgUPlan form').form('clear');
  481. $("#planId").val(id);
  482. $("#upartNo").textbox('setValue', partNo);
  483. $("#utoShipQty").textbox('setValue', toShipQty);
  484. }
  485. //新增发货计划
  486. function newDelivery(){
  487. $('#dlgPlan').dialog('open').dialog('center').dialog('setTitle', 'Create shipment plan');
  488. $('#dlgPlan form').form('clear');
  489. }
  490. //新增
  491. function saveDelivery(){
  492. var partNo = $("#partNo").val();
  493. var toShipQty = $("#toShipQty").val();
  494. $.ajax({
  495. type: 'GET',
  496. url: "/shipment/Delivery/add",
  497. dataType: "json",
  498. data: {"shipNo": currentShipNo,
  499. "partNo":partNo,
  500. "qty":toShipQty
  501. },
  502. success: function(data){
  503. $('#dlgPlan').dialog('close');
  504. $('#deliverys').datagrid('reload');
  505. },
  506. error : function() {
  507. }
  508. });
  509. }
  510. //导入发货计划条件
  511. function importDlg(){
  512. $('#importDlg').dialog('open').dialog('center').dialog('setTitle', 'ifsDeliveryNoteNo');
  513. $('#importDlgFm form').form('clear');
  514. }
  515. //导入发货计划
  516. function ImportDelivery(){
  517. var IfsDNoteNo = $("#ifsDNoteNo").val();
  518. console.log(IfsDNoteNo);
  519. $.post('/shipment/importDelivery',{ifsDNoteNo:IfsDNoteNo,shipNo: currentShipNo},function(result){
  520. if (result.success){
  521. $('#importDlg').dialog('close');
  522. $('#deliverys').datagrid('reload');
  523. } else {
  524. $.messager.alert('Error',result.errorMsg, 'error');
  525. }
  526. },'json');
  527. }
  528. //修改发货计划
  529. function updateDelivery(){
  530. var planId = $("#planId").val();
  531. var partNo = $("#upartNo").val();
  532. var toShipQty = $("#utoShipQty").val();
  533. if(toShipQty<rollActualQtyRow){
  534. $.messager.alert('Error','The qty to ship can not be less than the qty shipped, if you want to change, you need to cancel the shipment first!!', 'error');
  535. return false
  536. }
  537. console.log(planId);
  538. $.ajax({
  539. type: 'GET',
  540. url: "/shipment/Delivery/update",
  541. dataType: "json",
  542. data: {"pId":planId,
  543. "partNo":partNo,
  544. "qty":toShipQty
  545. },
  546. success: function(data){
  547. $('#dlgUPlan').dialog('close');
  548. $('#deliverys').datagrid('reload');
  549. },
  550. error : function() {
  551. }
  552. });
  553. }
  554. function delBoxRoll(boxRollId){
  555. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(r){
  556. if (r){
  557. $.post('/shipment/boxroll/'+boxRollId+'/del',{},function(result){
  558. if (result.success){
  559. $('#dgRollDtls').datagrid('reload');
  560. } else {
  561. $.messager.alert('Error',result.errorMsg, 'error');
  562. }
  563. },'json');
  564. }
  565. });
  566. }
  567. //删除出库单号
  568. function delShip(shipNo){
  569. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){
  570. if (status){
  571. $.ajax({
  572. url : "/shipment/delShip",
  573. type : "POST",
  574. data : {shipNo: shipNo},
  575. dataType : "json",
  576. success : function(data) {
  577. var code = data.code;
  578. if(code=='0'){
  579. $('#dg').datagrid('reload');
  580. $.messager.alert("Info",data.msg,"Info");
  581. }else{
  582. $.messager.alert('Error',data.msg, 'error');
  583. }
  584. },
  585. error : function(data) {
  586. $.messager.alert('Error',data.msg, 'error');
  587. }
  588. });
  589. }
  590. });
  591. }
  592. //删除出库下的箱子
  593. function delBox(boxNo){
  594. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){
  595. if (status){
  596. $.ajax({
  597. url : "/shipment/delBox",
  598. type : "POST",
  599. data : {boxNo: boxNo},
  600. dataType : "json",
  601. success : function(data) {
  602. var code = data.code;
  603. if(code=='0'){
  604. $('#dgDtls').datagrid('reload');
  605. $.messager.alert("Info",data.msg,"Info",);
  606. }else{
  607. $.messager.alert('Error',data.msg, 'error');
  608. }
  609. },
  610. error : function(data) {
  611. $.messager.alert('Error',data.msg, 'error');
  612. }
  613. });
  614. }
  615. });
  616. }
  617. //拆封
  618. function unPackBox(boxNo){
  619. $.messager.confirm('Confirm','Are you sure unpack the box:'+boxNo+' ?',function(status){
  620. if (status){
  621. $.ajax({
  622. // url : "/shipment/unPackBox",
  623. url : "/receive/boxes/unBoxingShip",
  624. type : "POST",
  625. data : {boxNo: boxNo},
  626. dataType : "json",
  627. success : function(data) {
  628. if(data.success){
  629. $('#dgDtls').datagrid('reload');
  630. $.messager.alert("Info",data.msg,"Info",);
  631. }else{
  632. $.messager.alert('Error',data.msg, 'error');
  633. }
  634. },
  635. error : function(data) {
  636. $.messager.alert('Error',data.msg, 'error');
  637. }
  638. });
  639. }
  640. });
  641. }
  642. //删除发货计划
  643. function delPlan(id,rollActualQty){
  644. if(rollActualQty>0){
  645. $.messager.alert('Error','Delete is not allowed because it has been deliveryed already', 'error');
  646. return false;
  647. }
  648. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){
  649. if (status){
  650. $.ajax({
  651. url : "/shipment/delPlan",
  652. type : "POST",
  653. data : {id: id},
  654. dataType : "json",
  655. success : function(data) {
  656. var code = data.code;
  657. if(code=='0'){
  658. $('#deliverys').datagrid('reload');
  659. $.messager.alert("Info",data.msg,"Info",);
  660. }else{
  661. $.messager.alert('Error',data.msg, 'error');
  662. }
  663. },
  664. error : function(data) {
  665. $.messager.alert('Error',data.msg, 'error');
  666. }
  667. });
  668. }
  669. });
  670. }
  671. //2023 0528 RQ 新增
  672. // $("#scanBoxNo").on("keydown", function(event){
  673. // console.log("回车拉")
  674. // var scanBoxNo = $(this).val();
  675. // if(event.keyCode == 13){
  676. // $.post("/receive/scan/add", {shipNo:currentShipNo, finalRollNo: scanBoxNo} , function(data){
  677. // if (data.success){
  678. // $("#ifmforprint").attr('src', "/print/box/" + scanBoxNo + "/");
  679. // $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo});
  680. // $.messager.alert("Info","Shipped","Info",);
  681. // $("#finalRollNo").textbox('setValue',"").focus();
  682. // }else{
  683. // $.messager.alert('Error',data.errorMsg, 'error');
  684. // $("#finalRollNo").textbox('setValue',"").focus();
  685. // }
  686. //
  687. // });
  688. // }
  689. // }).on("blur", function() {
  690. // $(this).textbox('setValue',$(this).val().trim().toUpperCase());
  691. // })
  692. $("#scanBoxNo").textbox({
  693. inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents,{
  694. keyup:function(event){
  695. if(event.keyCode == 13){
  696. console.log("回车");
  697. let scanBoxNo=$("#scanBoxNo").val();
  698. $.post("/shipment/boxes/shipBox", {shipNo:currentShipNo, scanBoxNo: scanBoxNo} , function(data){
  699. if (data.success){
  700. $("#ifmforprint").attr('src', "/print/box/" + scanBoxNo + "/");
  701. $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo});
  702. $.messager.alert("Info","Shipped","Info",);
  703. $("#scanBoxNo").textbox('setValue',"").focus();
  704. }else{
  705. $.messager.alert('Error',data.errorMsg, 'error');
  706. $("#scanBoxNo").textbox('setValue',"").focus();
  707. }
  708. });
  709. }
  710. }
  711. })
  712. })
  713. function shipBox(){
  714. var scanBoxNo = $("#scanBoxNo").val();
  715. $.post("/shipment/boxes/shipBox", {shipNo:currentShipNo, scanBoxNo: scanBoxNo} , function(data){
  716. if (data.success){
  717. $("#ifmforprint").attr('src', "/print/box/" + scanBoxNo + "/");
  718. $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo});
  719. $.messager.alert("Info","Shipped","Info",);
  720. $("#scanBoxNo").textbox('setValue',"").focus();
  721. }else{
  722. $.messager.alert('Error',data.errorMsg, 'error');
  723. $("#scanBoxNo").textbox('setValue',"").focus();
  724. }
  725. });
  726. }
  727. $("#finalRollNo").textbox({
  728. inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents,{
  729. keyup:function(event){
  730. if(event.keyCode == 13){
  731. var finalRollNo = $("#finalRollNo").val();
  732. $.post("/shipment/boxes/scan/addNew", {boxNo: nowBoxNo, finalRollNo: finalRollNo} , function(data){
  733. console.log(data);
  734. if (data.success){
  735. $("#dgRollDtls").datagrid({url: "/shipment/box/"+nowBoxNo+"/rolls"});
  736. $("#finalRollNo").textbox('setValue',"").focus();
  737. }else{
  738. //$("#tblInfo").append("<p>" + finalRollNo + data.errorMsg + "</p>");
  739. $("#finalRollNo").textbox('setValue',"");
  740. $.messager.alert('Error',data.errorMsg, 'error');
  741. }
  742. });
  743. }
  744. }
  745. })
  746. })
  747. function doBoxing(boxNo){
  748. if(boxStatus!='Unpacked'){
  749. $.messager.alert("Error", "The box can be packed only when unpacked.", "error");
  750. return false;
  751. }
  752. $.messager.confirm("Confirm","Submit", function(cr){
  753. if (cr){
  754. $.post("/shipment/boxes/finishByboxNo", {boxNo: boxNo}, function(ret){
  755. if (ret.success){
  756. $("#ifmforprint").attr('src', "/print/box/" + ret.box.boxNo + "/");
  757. $('#dlgRollDtls').dialog('close');
  758. $("#dgDtls").datagrid({url: "/shipment/boxes/"+currentShipNo});
  759. }else{
  760. $.messager.alert("Error", ret.errorMsg, "error");
  761. }
  762. })
  763. }
  764. })
  765. }
  766. function delPlanList() {
  767. }
  768. </script>
  769. </@master.layout>