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.

433 lines
16 KiB

3 days ago
  1. <#import "../master.ftl" as master>
  2. <@master.layout>
  3. <style>
  4. #fm label {
  5. width: 100px;
  6. }
  7. </style>
  8. <div class="page-header">
  9. <h3>Receipt</h3>
  10. </div>
  11. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  12. data-options="pagination: true, showFooter: true, singleSelect:true, fitColumns:true ,
  13. queryParams:{'receivedType': 'R'},
  14. url:'/receive/all',method:'get',pageSize:20,toolbar:'#tb'">
  15. <thead>
  16. <tr>
  17. <th data-options="field:'orderNo',width:100,editor:'textbox'">SO No</th>
  18. <th data-options="field:'receiveNo',width:100,editor:'textbox'">Receiving No</th>
  19. <th data-options="field:'receivedBy',width:80,align:'left'">Created By</th>
  20. <th data-options="field:'receivedDate',width:150,align:'center',formatter:formatDateTime">Create Date</th>
  21. <th data-options="field:'id',width:150,align:'center',formatter:formatAction">Actions</th>
  22. </tr>
  23. </thead>
  24. </table>
  25. <div id="tb" style="padding:10px 5px;display: none;">
  26. <div>
  27. SO No: <input class="easyui-textbox" id="orderNo" style="width:110px">
  28. Create Date: <input class="easyui-datebox" id="receivedDateFrom" style="width:100px">
  29. 到: <input class="easyui-datebox" id="receivedDateTo" style="width:100px">
  30. <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  31. &nbsp;&nbsp;&nbsp;
  32. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newReceive()">Create receipt form</a>
  33. </div>
  34. </div>
  35. <div id="dlg" class="easyui-dialog" style="width:500px;display: none;"
  36. closed="true" buttons="#dlg-buttons">
  37. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  38. <div style="margin-bottom:10px" style="display: none;">
  39. <input id="received_type" name="receivedType" type="hidden" value="R">
  40. </div>
  41. <div style="margin-bottom:10px">
  42. <input id="order_no" name="orderNo" class="easyui-textbox" required="true" data-options="buttonText: 'query',onClickButton:getOrderNo" label="SO No:" style="width:100%">
  43. </div>
  44. </form>
  45. </div>
  46. <div id="dlg-buttons" style="display: none;">
  47. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveReceive()" style="width:90px">Save</a>
  48. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  49. </div>
  50. <div id="dlgDtls" class="easyui-dialog" style="width:600px;display: none;"
  51. closed="true" data-options="modal:true" >
  52. <table id="dgDtls" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  53. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:50, toolbar:'#tbDtls', onLoadSuccess: onDtlsLoadSuccess">
  54. <thead>
  55. <tr>
  56. <th data-options="field:'finalRollNo',width:100, formatter:formatPrintRoll">FG roll number</th>
  57. <th data-options="field:'boxNo',width:100, formatter:formatPrintRoll">Box No</th>
  58. <th data-options="field:'boxtype',width:100, formatter:formatFindType">Box Type</th>
  59. </tr>
  60. </thead>
  61. </table>
  62. </div>
  63. <div id="tbDtl" style="padding:10px 5px;display: none;">
  64. <div>
  65. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newBox()">New Box</a>
  66. <a href="javascript:void(0)" id="downBoxExcel" class="easyui-linkbutton" iconCls="icon-add" onclick="downBoxExcel()">Export to Excel</a>
  67. </div>
  68. </div>
  69. <div id="tbDtls" style="padding:10px 5px;display: none;">
  70. <div id="btn_Excel">
  71. <a href="javascript:void(0)" id="downExcel" class="easyui-linkbutton" iconCls="icon-add" onclick="downExcel()">Export to Excel</a>
  72. </div>
  73. </div>
  74. <div id="dlgDtl" class="easyui-dialog" style="width:600px;display: none;"
  75. closed="true" data-options="modal:true" >
  76. <table id="dgDtl" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  77. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20,toolbar:'#tbDtl'">
  78. <thead>
  79. <input type="hidden" id="Rid" value=""/>
  80. <input type="hidden" id="ReceiveNo" value=""/>
  81. <input type="hidden" id="boxType" value=""/>
  82. <tr>
  83. <th data-options="field:'boxNo',width:40,formatter:formatPrintBoxNo">Box No</th>
  84. <th data-options="field:'boxType',width:30">Type</th>
  85. <th data-options="field:'status',width:30">Status</th>
  86. <th data-options="field:'rollQty',width:30">Roll Qty</th>
  87. <th data-options="field:'id',width:80,formatter:formatDtlAction">Actions</th>
  88. </tr>
  89. </thead>
  90. </table>
  91. </div>
  92. <div id="dlgRollDtls" class="easyui-dialog" style="width:500px;display: none;"
  93. closed="true" data-options="modal:true" >
  94. <table id="dgRollDtls" class="easyui-datagrid" style="width:100%;height:400px;display: none;"
  95. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get'">
  96. <thead>
  97. <tr>
  98. <th data-options="field:'finalRollNo',width:100">FG roll number</th>
  99. <th data-options="field:'id',width:40,formatter:formatBoxRollAction">Actions</th>
  100. </tr>
  101. </thead>
  102. </table>
  103. </div>
  104. <script>
  105. function getOrderNo(){
  106. var orderNo = $("#order_no").val();
  107. if (orderNo != ""){
  108. $.post("/receive/getOrderNo", {finalRollNo: orderNo}, function (data) {
  109. if(data.success){
  110. $("#order_no").textbox("setValue", data.orderNo);
  111. }
  112. })
  113. }
  114. }
  115. var currentOrder='';
  116. var currentShipNo='';
  117. $(window).resize(function () {
  118. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  119. });
  120. $(function () {
  121. $(window).resize();
  122. });
  123. $.extend($.fn.validatebox.defaults.rules, {
  124. validDate: {
  125. validator: function(value){
  126. var date = $.fn.datebox.defaults.parser(value);
  127. var s = $.fn.datebox.defaults.formatter(date);
  128. return s==value;
  129. },
  130. message: 'Please enter a valid date.'
  131. },
  132. valueRange: {
  133. validator: function(value,param){
  134. return value >= param[0] && value <= param[1];
  135. },
  136. message: 'Field do not match.'
  137. }
  138. });
  139. function myparser(s){
  140. if(s) return new Date(s);
  141. }
  142. function onTableRowSelect(index, row) {
  143. }
  144. function formatPrintRoll(value, row){
  145. if (value.indexOf("-Q") > 0 || value.indexOf("-S") > 0) {
  146. return "<a href='/print/finalroll/"+value+"/' target='forprint'>"+value+"</a>"
  147. }
  148. return value;
  149. }
  150. //获取箱子的类型
  151. function formatFindType(value,row){
  152. var boxNo = row.boxNo;
  153. console.log(boxNo);
  154. var boxtype;
  155. $.ajax({
  156. url : "/receive/findBoxType",
  157. type : "POST",
  158. async : false,
  159. data : {boxNo: boxNo},
  160. dataType : "json",
  161. success : function(data) {
  162. boxtype= data.boxType;
  163. }
  164. });
  165. return boxtype;
  166. }
  167. $("#queryLink").click(function(){
  168. var dg = $('#dg').datagrid({
  169. queryParams: {
  170. orderNo: $("#orderNo").val(),
  171. receivedType: 'R',
  172. receivedDateFrom: $("#receivedDateFrom").val(),
  173. receivedDateTo: $("#receivedDateTo").val()
  174. }
  175. });
  176. });
  177. function formatAction(value, row){
  178. let action= "<a href='javascript:viewBoxes(\""+row.receiveNo+"\",\""+'Passed'+"\",\""+row.id+"\",\""+row.orderNo+"\")'>Good Box List</a>"
  179. if(row.orderNo!='*'){
  180. action=action+ "&nbsp;|&nbsp;" + "<a href='javascript:viewBoxes(\""+row.receiveNo+"\",\""+'Defective'+"\",\""+row.id+"\",\""+row.orderNo+"\")'>Defect Box List</a>"
  181. }
  182. action=action + "&nbsp;|&nbsp;<a href='javascript:viewRolls(\"" + row.receiveNo + "\")'>Received Rolls</a>"
  183. + "&nbsp;|&nbsp;<a href='javascript:delReceive(\"" + row.receiveNo + "\",\""+row.orderNo+"\")'>Delete</a>"
  184. return action;
  185. }
  186. //箱子
  187. function viewBoxes(receiveNo,type,rid,orderNo){
  188. currentOrder=orderNo;
  189. currentShipNo = receiveNo;
  190. boxType = type;
  191. $("#Rid").val(rid);
  192. $("#boxType").val(type);
  193. $("#ReceiveNo").val(receiveNo)
  194. $('#dlgDtl').dialog('open').dialog('center').dialog('setTitle',receiveNo+' Box List');
  195. $("#dgDtl").datagrid({url: "/receive/boxes/"+receiveNo+"/"+type,
  196. onLoadSuccess: function(data) {
  197. var rolls = data.rows;
  198. if(rolls==null ||rolls==""){
  199. $("#downBoxExcel").hide();
  200. }else{
  201. $("#downBoxExcel").show();
  202. }
  203. }
  204. });
  205. }
  206. var currentTitle = "";
  207. function viewRolls(receiveNo){
  208. $("#ReceiveNo").val(receiveNo);
  209. $("#dgDtls").datagrid({url: "/receive/finalrolls/"+receiveNo,
  210.   onLoadSuccess: function(data) {
  211. currentTitle = receiveNo+'中已入库的卷'+" 共计"+data.total+"";
  212. $('#dlgDtls').dialog('open').dialog('center').dialog('setTitle',currentTitle);
  213. var rolls = data.rows;
  214. if(rolls==null ||rolls==""){
  215. $("#btn_Excel").hide();
  216. }else{
  217. $("#btn_Excel").show();
  218. }
  219. }
  220. });
  221. }
  222. function onDtlsLoadSuccess(){
  223. $('#dlgDtls').dialog('setTitle',currentTitle + ': 共计' + $('#dgDtls').datagrid('getRows').length + "");
  224. }
  225. var url;
  226. function newReceive(){
  227. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Create receipt form');
  228. $('#fm').form('clear');
  229. $("#received_type").val("R");
  230. url = '/prepress/soinfo/add';
  231. }
  232. function saveReceive(){
  233. $('#fm').form('submit',{
  234. url: "/receive/add",
  235. onSubmit: function(){
  236. return $(this).form('validate');
  237. },
  238. success: function(result){
  239. var result = eval("("+result+")");
  240. if (result.errorMsg){
  241. $.messager.alert('error',result.errorMsg, 'error');
  242. } else {
  243. $('#dlg').dialog('close'); // close the dialog
  244. $('#dg').datagrid('reload'); // reload the user data
  245. }
  246. }
  247. });
  248. }
  249. function formatPrintBoxNo(value, row){
  250. if (row.status == "Packed"||row.status == "Received") {
  251. //return "<a target='forprint' href='/print/"+ "receiveBox" + "/" +value+"/'>"+value+"</a>";
  252. return "<a onclick='getInnerBoxPrintCacheData(\""+value+"\")'>"+value+"</a>";
  253. }else{
  254. return value;
  255. }
  256. }
  257. function formatDtlAction(value, row){
  258. var action = "";
  259. var id = $("#Rid").val();
  260. if (row.status == "Unpacked"&&currentOrder!="*"){
  261. action = "<a href='/receive/scan/" + id + "?type="+row.boxType+"&boxNo="+row.boxNo+"'>扫描入库</a>&nbsp;|&nbsp;";
  262. }
  263. if (row.status == "Unpacked"&&currentOrder=="*"){
  264. action = "<a href='/receive/scanPlus/" + id + "?type="+row.boxType+"&boxNo="+row.boxNo+"'>合箱入库</a>&nbsp;|&nbsp;";
  265. }
  266. if (row.status == "Packed"||row.status == "Received"){
  267. action = "<a href='javascript:doUnBoxing(\""+row.boxNo+"\")'>Unfrozen</a>&nbsp;|&nbsp;";
  268. }
  269. action += "<a href='javascript:delBox(\"" + row.boxNo + "\");'>Delete</a>";
  270. action += "&nbsp;|&nbsp;<a href='javascript:viewBoxRolls(\"" + row.boxNo + "\");'>Received Rolls</a>";
  271. return action;
  272. }
  273. function newBox(){
  274. $.post("/receive/boxes/add", {receiveNo: currentShipNo,type:boxType, receivedType: 'R'} , function(data){
  275. console.log(data);
  276. if (data.success){
  277. $('#dgDtl').datagrid('reload');
  278. }else{
  279. }
  280. });
  281. }
  282. //删除出库下的箱子
  283. function delBox(boxNo){
  284. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){
  285. if (status){
  286. $.ajax({
  287. url : "/receive/delBox",
  288. type : "POST",
  289. data : {boxNo: boxNo},
  290. dataType : "json",
  291. success : function(data) {
  292. var code = data.code;
  293. if(code=='0'){
  294. $('#dgDtl').datagrid('reload');
  295. $.messager.alert("Info",data.msg,"Info",);
  296. }else{
  297. $.messager.alert('Error',data.msg, 'error');
  298. }
  299. },
  300. error : function(data) {
  301. $.messager.alert('Error',data.msg, 'error');
  302. }
  303. });
  304. }
  305. });
  306. }
  307. function doUnBoxing(boxNo){
  308. $.messager.confirm("Confirm","Submit", function(cr){
  309. if (cr){
  310. $.post("/receive/boxes/unBoxing", {boxNo: boxNo}, function(ret){
  311. if (ret.success){
  312. $('#dgDtl').datagrid('reload');
  313. }else{
  314. $.messager.alert("Error", ret.errorMsg, "error");
  315. }
  316. })
  317. }
  318. })
  319. }
  320. //查看
  321. function viewBoxRolls(boxNo){
  322. $('#dlgRollDtls').dialog('open').dialog('center').dialog('setTitle',boxNo+' SFG roll');
  323. $("#dgRollDtls").datagrid({url: "/receive/box/"+boxNo+"/rolls"});
  324. }
  325. //查看页面
  326. function formatBoxRollAction(value, row){
  327. var action = "";
  328. <#if currentUser.isAdmin || (currentUser.authorities?contains("switch_order") && currentUser.authorities?contains("dispatch"))>
  329. action += "<a href='javascript:delBoxRoll(\"" + row.id + "\");'>Delete</a>";
  330. </#if>
  331. return action;
  332. }
  333. function delBoxRoll(boxRollId){
  334. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(r){
  335. if (r){
  336. $.post('/receive/boxroll/'+boxRollId+'/del',{},function(result){
  337. if (result.success){
  338. $('#dgRollDtls').datagrid('reload');
  339. } else {
  340. $.messager.alert('Error',result.errorMsg, 'error');
  341. }
  342. },'json');
  343. }
  344. });
  345. }
  346. //删除出库单号
  347. function delReceive(receiveNo,orderNo){
  348. $.messager.confirm('Confirm','Are you sure to delete the data ?',function(status){
  349. if (status){
  350. console.log("-=-");
  351. console.log(status);
  352. $.ajax({
  353. url : "/receive/delReceive",
  354. type : "POST",
  355. data : {receiveNo: receiveNo,orderNo:orderNo},
  356. dataType : "json",
  357. success : function(data) {
  358. console.log(data);
  359. var code = data.code;
  360. if(code=='0'){
  361. $('#dg').datagrid('reload');
  362. $.messager.alert("Info",data.msg,"Info",);
  363. }else{
  364. $.messager.alert('Error',data.msg, 'error');
  365. }
  366. },
  367. error : function(data) {
  368. console.log(data);
  369. $.messager.alert('Error',data.msg, 'error');
  370. }
  371. });
  372. }
  373. });
  374. }
  375. //导出EXCEl
  376. function downExcel() {
  377. //拼接url
  378. var url = "/scanning/down/SoReceiveBoxRollsList?ReceiveNo="+$("#ReceiveNo").val();
  379. //设置href
  380. $("#downExcel").attr("href", url);
  381. }
  382. //导出
  383. function downBoxExcel(){
  384. //拼接url
  385. var url = "/scanning/down/SoReceiveBoxList?ReceiveNo="+$("#ReceiveNo").val()+"&type="+$("#boxType").val();
  386. //设置href
  387. $("#downBoxExcel").attr("href", url);
  388. }
  389. </script>
  390. </@master.layout>