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.

406 lines
18 KiB

3 days ago
  1. <#import "../master.ftl" as master>
  2. <@master.layout>
  3. <style>
  4. #fm label {
  5. width: 150px;
  6. }
  7. </style>
  8. <div class="page-header">
  9. <h3>Import of Rework Order</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 , onSelect:onTableRowSelect, onLoadSuccess:onTableRowSelect, url:'/prepress/reworkAll',method:'get',pageSize:20,toolbar:'#tb'">
  13. <thead>
  14. <tr>
  15. <th data-options="field:'orderNo',width:100,editor:'textbox'">Order No</th>
  16. <th data-options="field:'partNo',width:100,editor:'textbox'">Part No</th>
  17. <th data-options="field:'partDesc',width:200,editor:'textbox'">Part Description</th>
  18. <th data-options="field:'apn',width:80">APN</th>
  19. <th data-options="field:'customerPartNo',width:80">Customer Part No</th>
  20. <th data-options="field:'project',width:80">Project</th>
  21. <th data-options="field:'revNo',width:50">Rev No</th>
  22. <th data-options="field:'lotSize',width:100,editor:'textbox'">Lot Size</th>
  23. <th data-options="field:'inputLotSize',width:100,editor:'textbox'">Input Lot Size</th>
  24. <th data-options="field:'serialsDate',width:150,align:'left',formatter:formatDate">Serials Date</th>
  25. <th data-options="field:'needDate',width:120,formatter:formatDate">Earliest Start Date</th>
  26. <th data-options="field:'noOfCross',width:100">No of Cross</th>
  27. <th data-options="field:'standardRollQty',width:100,editor:'textbox'">Std. Roll Qty</th>
  28. <th data-options="field:'createdBy',width:80,align:'left'">Created By</th>
  29. <th data-options="field:'createdDate',width:150,align:'center',formatter:formatDateTime">Created Date</th>
  30. <th data-options="field:'status',width:100,editor:'textbox'">Status</th>
  31. <th data-options="field:'id', width:100,formatter:formatDownload">Actions</th>
  32. <#-- <th data-options="field:'serialsGenBy',width:150,align:'left',editor:'textbox'">Serials Generated By</th>-->
  33. <#-- <th data-options="field:'serialsGenDate',width:150,align:'center',editor:'textbox',formatter:formatDateTime">Serials Generated Date</th>-->
  34. </tr>
  35. </thead>
  36. </table>
  37. <div id="tb" style="padding:10px 5px;display: none;">
  38. <div>
  39. Order No: <input class="easyui-textbox" id="orderNo" style="width:110px">
  40. Created Date: <input class="easyui-datebox" id="createdDateFrom" style="width:100px">
  41. to: <input class="easyui-datebox" id="createdDateTo" style="width:100px">
  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="newSoInfo()">New</a>
  45. <a href="javascript:void(0)" id="tbEdit" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-edit" onclick="editSoInfo()">Modify</a>
  46. <a href="javascript:void(0)" id="tbRemove" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-remove" onclick="removeSoInfo()">Delete</a>
  47. </div>
  48. </div>
  49. <div id="dlg" class="easyui-dialog" style="width:750px;display: none;"
  50. closed="true" buttons="#dlg-buttons">
  51. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  52. <div style="margin-bottom:10px">
  53. <input id="dlgOrderNo" name="orderNo" class="easyui-textbox" required="true" data-options="buttonText: 'IFS',onClickButton:getIfsOrderNew" label="Order No:" style="width:100%">
  54. </div>
  55. <div style="margin-bottom:10px">
  56. <input name="partNo" class="easyui-textbox" readonly required="true" label="Part No:" style="width:100%">
  57. </div>
  58. <div style="margin-bottom:10px">
  59. <input name="partDesc" class="easyui-textbox" readonly required="true" label="Part Description:" style="width:100%">
  60. </div>
  61. <div style="margin-bottom:10px">
  62. <input name="apn" class="easyui-textbox" readonly required="true" label="APN:" style="width:100%">
  63. </div>
  64. <div style="margin-bottom:10px">
  65. <input name="customerPartNo" class="easyui-textbox" readonly required="true" label="Customer Part No:" style="width:100%">
  66. </div>
  67. <div style="margin-bottom:10px">
  68. <input name="project" class="easyui-textbox" readonly required="true" label="Project:" style="width:100%">
  69. </div>
  70. <div style="margin-bottom:10px">
  71. <input name="revNo" id="revNo" class="easyui-textbox" readonly required="true" label="Rev No:" style="width:100%">
  72. </div>
  73. <div style="margin-bottom:10px">
  74. <input name="lotSize" class="easyui-numberbox" readonly required="true" label="Lot Size:" style="width:100%">
  75. </div>
  76. <div style="margin-bottom:10px">
  77. <input name="inputLotSize" class="easyui-numberbox" validtype="valueRange[1,1336335]" required="true" label="Input Lot Size:" style="width:100%">
  78. </div>
  79. <div style="margin-bottom:10px">
  80. <input name="serialsDate" class="easyui-datebox" validtype="validDate" required="true" data-options="parser:myparser" label="Serials Date:" style="width:100%">
  81. </div>
  82. <div style="margin-bottom:10px">
  83. <input name="needDate" class="easyui-datebox" validtype="validDate" required="true" label="Earliest Start Date:" style="width:100%">
  84. </div>
  85. <div style="margin-bottom:10px">
  86. <input name="noOfCross" class="easyui-numberbox" readonly required="true" label="No of Cross:" style="width:100%">
  87. </div>
  88. <div style="margin-bottom:10px">
  89. <input name="standardRollQty" class="easyui-numberbox" readonly required="true" label="Standard Roll Qty:" style="width:100%">
  90. </div>
  91. </form>
  92. </div>
  93. <div id="dlg-buttons" style="display: none;">
  94. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveSoInfo()" style="width:90px">Save</a>
  95. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  96. </div>
  97. <div id="dlgDtls" class="easyui-dialog" style="width:600px;display: none;"
  98. closed="true" data-options="modal:true" >
  99. <table id="dgDtls" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  100. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20">
  101. <thead>
  102. <tr>
  103. <th data-options="field:'rollNo',width:100">Roll No</th>
  104. <th data-options="field:'createdBy',width:80">Created By</th>
  105. <th data-options="field:'createdDate',width:150,align:'center',formatter:formatDateTime">Created Time</th>
  106. <th data-options="field:'status',width:80">Status</th>
  107. <th data-options="field:'id', width:150,formatter:formatRollAction"></th>
  108. </tr>
  109. </thead>
  110. </table>
  111. </div>
  112. <div id="dlgRollDtls" class="easyui-dialog" style="width:500px;display: none;"
  113. closed="true" data-options="modal:true,toolbar:'#dlgRollDtlstb'" >
  114. <table id="dgRollDtls" class="easyui-datagrid" style="width:100%;height:400px;display: none;"
  115. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get'">
  116. <thead>
  117. <tr>
  118. <th data-options="field:'finalRollNo',width:100">FG roll number</th>
  119. <th data-options="field:'qty',width:100">Quantity</th>
  120. <th data-options="field:'reworkFlag',width:100">Rework Flag</th>
  121. <#-- <th data-options="field:'id',width:40,formatter:formatBoxRollAction">Actions</th>-->
  122. </tr>
  123. </thead>
  124. </table>
  125. </div>
  126. <div id="dlgRollDtlstb" style="padding:10px 5px;display: none;">
  127. <div>
  128. 扫卷返工:&nbsp;&nbsp;&nbsp;<input id="finalRollNo" name="finalRollNo" class="easyui-textbox" style="width: 120px;text-transform:uppercase;" placeholder="FG roll number" />
  129. &nbsp;&nbsp;&nbsp;
  130. <#-- <a href="javascript:void(0)" id="boxingButton" class="easyui-linkbutton" onclick="doBoxing(nowBoxNo)">Pack</a>-->
  131. </div>
  132. </div>
  133. <script>
  134. var nowOrderNo='';
  135. $(window).resize(function () {
  136. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  137. });
  138. $(function () {
  139. $(window).resize();
  140. });
  141. function onPartDescChange(n,o){
  142. //var p = /Label,([0-9A-Za-z\-]+)-(\S{1})/.exec(n);
  143. var p = n.split(',');
  144. if (p && p.length >= 3){
  145. $("#revNo").textbox("setValue", p[2]);
  146. }
  147. }
  148. $.extend($.fn.validatebox.defaults.rules, {
  149. notRequired: function(value){
  150. return true;
  151. },
  152. validDate: {
  153. validator: function(value){
  154. var date = $.fn.datebox.defaults.parser(value);
  155. var s = $.fn.datebox.defaults.formatter(date);
  156. return s==value;
  157. },
  158. message: 'Please enter a valid date.'
  159. },
  160. valueRange: {
  161. validator: function(value,param){
  162. return value >= param[0] && value <= param[1];
  163. },
  164. message: 'Field do not match.'
  165. }
  166. });
  167. function myparser(s){
  168. if(s) return new Date(s);
  169. }
  170. function onTableRowSelect(index, row) {
  171. var noRowSelect = !!!row;
  172. var generated = row && row.serialsGenDate;
  173. $("#tbEdit").linkbutton({"disabled": noRowSelect || generated});
  174. $("#tbRemove").linkbutton({"disabled": noRowSelect || generated});
  175. $("#tbSnGen").linkbutton({"disabled": noRowSelect || generated});
  176. $("#tbSnRemove").linkbutton({"disabled": noRowSelect || !generated});
  177. }
  178. $("#queryLink").click(function(){
  179. var dg = $('#dg').datagrid({
  180. queryParams: {
  181. orderNo: $("#orderNo").val(),
  182. createdDateFrom: $("#createdDateFrom").val(),
  183. createdDateTo: $("#createdDateTo").val()
  184. }
  185. });
  186. });
  187. function formatRollAction(value, row){
  188. return "<a href='/qrcode/"+row.rollNo+"/' target='_blank'>2D Barcode</a>";
  189. }
  190. function viewRolls(orderNo){
  191. $('#dlgDtls').dialog('open').dialog('center').dialog('setTitle',orderNo+' SFG roll');
  192. $("#dgDtls").datagrid({url: "/prepress/orderrolls/"+orderNo});
  193. }
  194. var url;
  195. function newSoInfo(){
  196. $('#dlg').dialog('open').dialog('center').dialog('setTitle','New Order Info');
  197. $('#fm').form('clear');
  198. url = '/prepress/soinfo/addrework';
  199. }
  200. function editSoInfo(){
  201. var row = $('#dg').datagrid('getSelected');
  202. if (row){
  203. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Edit Order Info');
  204. $('#fm').form('load',row);
  205. url = '/prepress/soinfo/'+row.id+'/update';
  206. }else{
  207. $.messager.alert('Warning','Please select a row.', 'warning');
  208. }
  209. }
  210. var delay = (function(){
  211. var timer = 0;
  212. return function(callback, ms){
  213. clearTimeout (timer);
  214. timer = setTimeout(callback, ms);
  215. };
  216. })();
  217. function saveSoInfo(){
  218. delay(function(){
  219. $('#fm').form('submit',{
  220. url: url,
  221. onSubmit: function(){
  222. return $(this).form('validate');
  223. },
  224. success: function(result){
  225. var result = eval("("+result+")");
  226. if (result.errorMsg){
  227. $.messager.alert('error',result.errorMsg, 'error');
  228. } else {
  229. $('#dlg').dialog('close'); // close the dialog
  230. $('#dg').datagrid('reload'); // reload the user data
  231. }
  232. }
  233. });
  234. }, 500);
  235. }
  236. function removeSoInfo(){
  237. var row = $('#dg').datagrid('getSelected');
  238. if (row){
  239. $.messager.confirm('Confirm','Delete the selected order <b>'+row.orderNo+'</b> ?',function(r){
  240. if (r){
  241. $.post('/prepress/soinfo/'+row.id+'/delete',{},function(result){
  242. if (result.success){
  243. $('#dg').datagrid('reload'); // reload the user data
  244. } else {
  245. $.messager.alert('error',result.errorMsg, 'error');
  246. }
  247. },'json');
  248. }
  249. });
  250. }else{
  251. $.messager.alert('Warning','Please select a row.', 'warning');
  252. }
  253. }
  254. function downloadTrace(orderNo){
  255. $.post("/prepress/downloadTrace", {orderNo: orderNo}, function(ret){
  256. console.log(ret);
  257. if(ret.success){
  258. window.location.href="/prepress/downloadFileZip/"+ret.fileName;
  259. }else{
  260. $.messager.alert('Error',ret.errorMsg, 'error');
  261. }
  262. });
  263. }
  264. function setByInputName(inpt, value){
  265. var $inpt = $("#dlg input[textboxname="+inpt+"]");
  266. $inpt.textbox({"value": value});
  267. }
  268. function getIfsOrder(){
  269. var orderNo = $("#dlgOrderNo").val();
  270. if (orderNo != ""){
  271. $.post("/prepress/ifsOrder", {orderNo: orderNo}, function (data) {
  272. console.log(data);
  273. if(data.success){
  274. var apn = data.ifsOrder.apn;
  275. /* if (apn.length == 9) {
  276. apn = "1P" + apn;
  277. } else if (apn.length == 10) {
  278. apn = "1" + apn;
  279. } */
  280. setByInputName("partNo", data.ifsOrder.part_no);
  281. setByInputName("partDesc", data.ifsOrder.part_description);
  282. setByInputName("apn", apn);
  283. setByInputName("customerPartNo", data.ifsOrder.customer_pn);
  284. setByInputName("project", data.ifsOrder.project_flag);
  285. setByInputName("lotSize", data.ifsOrder.lotsize);
  286. setByInputName("inputLotSize", accMul(data.ifsOrder.lotsize,1));
  287. setByInputName("standardRollQty", data.ifsOrder.qty_per_roll);
  288. setByInputName("noOfCross", data.ifsOrder.cross_number);
  289. setByInputName("needDate", formatDate(data.ifsOrder.need_date));
  290. setByInputName("serialsDate", formatDate(data.ifsOrder.need_date));
  291. //onPartDescChange(data.ifsOrder.part_description, 1);
  292. }
  293. })
  294. }
  295. }
  296. function accMul(num1,num2){
  297. var m=0,s1=num1.toString(),s2=num2.toString();
  298. try{m+=s1.split(".")[1].length}catch(e){};
  299. try{m+=s2.split(".")[1].length}catch(e){};
  300. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
  301. }
  302. function formatDownload(value,row){
  303. var a = "<a href='javascript:viewRolls(\""+row.orderNo+"\")'>Roll detail</a>";
  304. return a;
  305. }
  306. function viewRolls(orderNo){
  307. $('#finalRollNo').textbox("setValue","");
  308. nowOrderNo=orderNo;
  309. $('#dlgRollDtls').dialog('open').dialog('center').dialog('setTitle',orderNo+' SFG roll');
  310. $("#dgRollDtls").datagrid({url: "/rewind/getRewindOrderList/"+orderNo});
  311. $('#finalRollNo').textbox('textbox').focus();
  312. }
  313. $("#finalRollNo").textbox({
  314. inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents,{
  315. keyup:function(event){
  316. if(event.keyCode == 13){
  317. let finalRollNo=$("#finalRollNo").val();
  318. $.post("/rewind/scanReworkRoll", {orderNo: nowOrderNo, finalRollNo: finalRollNo} , function(data){
  319. if (data.success){
  320. $("#dgRollDtls").datagrid({url: "/rewind/getRewindOrderList/"+nowOrderNo});
  321. // $.messager.alert("Info","Received","Info",);
  322. $("#ifmforprint").attr('src', "/print/newlabel/"+data.obj+"/0/");
  323. $("#finalRollNo").textbox('setValue',"").focus();
  324. }else{
  325. $.messager.alert('Error',data.errorMsg, 'error');
  326. $("#finalRollNo").textbox('setValue',"").focus();
  327. }
  328. });
  329. }
  330. }
  331. })
  332. })
  333. function getIfsOrderNew(){
  334. var orderNo = $("#dlgOrderNo").val();
  335. if (orderNo != ""){
  336. $.post("/prepress/ifsOrder", {orderNo: orderNo}, function (data) {
  337. console.log(data);
  338. if(data.success){
  339. var apn = data.ifsOrder.apn;
  340. if (apn.length == 11) {
  341. //正常行为
  342. }else {
  343. //不正常的
  344. $.messager.alert('Error', 'Length of apn does not comply with the rules!', 'error');
  345. return false;
  346. }
  347. setByInputName("partNo", data.ifsOrder.partNo);
  348. setByInputName("partDesc", data.ifsOrder.partDesc);
  349. setByInputName("apn", apn);
  350. setByInputName("revNo", data.ifsOrder.revNo);
  351. setByInputName("customerPartNo", data.ifsOrder.customerPartNo);
  352. setByInputName("project", data.ifsOrder.projectCode);
  353. setByInputName("lotSize", data.ifsOrder.lotsize);
  354. setByInputName("inputLotSize", accMul(data.ifsOrder.lotsize,1.20));
  355. setByInputName("standardRollQty", data.ifsOrder.standardRollQty);
  356. setByInputName("noOfCross", data.ifsOrder.noOfCross);
  357. setByInputName("needDate", formatDate(data.ifsOrder.need_date));
  358. setByInputName("serialsDate", formatDate(data.ifsOrder.need_date));
  359. //onPartDescChange(data.ifsOrder.part_description, 1);
  360. }else{
  361. $.messager.alert('Error', data.msg, 'error');
  362. }
  363. })
  364. }
  365. }
  366. </script>
  367. </@master.layout>