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.

464 lines
20 KiB

3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
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. </style>
  8. <div class="page-header">
  9. <h3>Import Shop 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,
  13. onSelect:onTableRowSelect, onLoadSuccess:onTableRowSelect, url:'/prepress/all',method:'get',pageSize:20,toolbar:'#tb'">
  14. <thead>
  15. <tr>
  16. <th data-options="field:'orderNo',width:100,editor:'textbox'">Order No</th>
  17. <th data-options="field:'partNo',width:100,editor:'textbox'">Part No</th>
  18. <th data-options="field:'partDesc',width:200,editor:'textbox'">Part Description</th>
  19. <th data-options="field:'apn',width:80">APN</th>
  20. <th data-options="field:'customerPartNo',width:160">Customer Part No</th>
  21. <th data-options="field:'project',width:80">Project</th>
  22. <th data-options="field:'revNo',width:80">Rev No</th>
  23. <th data-options="field:'lotSize',width:100,editor:'textbox'">Lot Size</th>
  24. <th data-options="field:'inputLotSize',width:140,editor:'textbox'">Input Lot Size</th>
  25. <th data-options="field:'serialsDate',width:150,align:'left',formatter:formatDate">Serials Date</th>
  26. <th data-options="field:'needDate',width:160,formatter:formatStringTime">Earliest Start Date</th>
  27. <th data-options="field:'noOfCross',width:120">No of Cross</th>
  28. <th data-options="field:'standardRollQty',width:120,editor:'textbox'">Std. Roll Qty</th>
  29. <th data-options="field:'createdBy',width:100,align:'left'">Created By</th>
  30. <th data-options="field:'createdDate',width:150,align:'center',formatter:formatDateTime">Created Date</th>
  31. <th data-options="field:'status',width:100,editor:'textbox'">Status</th>
  32. <th data-options="field:'serialsGenBy',width:180,align:'left',editor:'textbox'">Serials Generated By</th>
  33. <th data-options="field:'serialsGenDate',width:180,align:'center',editor:'textbox',formatter:formatDateTime">Serials Generated Date</th>
  34. <th data-options="field:'id', width:230,formatter:formatOrderAction">Actions</th>
  35. </tr>
  36. </thead>
  37. </table>
  38. <div id="tb" style="padding:10px 5px;display: none;">
  39. <div>
  40. Order No: <input class="easyui-textbox" id="orderNo" style="width:110px">
  41. Created Date: <input class="easyui-datebox" id="createdDateFrom" style="width:100px">
  42. to: <input class="easyui-datebox" id="createdDateTo" style="width:100px">
  43. <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  44. &nbsp;&nbsp;&nbsp;
  45. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newSoInfo()">New</a>
  46. <a href="javascript:void(0)" id="tbEdit" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-edit" onclick="editSoInfo()">Modify</a>
  47. <a href="javascript:void(0)" id="tbRemove" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-remove" onclick="removeSoInfo()">Delete</a>
  48. &nbsp;&nbsp;&nbsp;
  49. <a href="javascript:void(0)" id="tbSnGen" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-add" onclick="genSerials()">Generate Serials</a>
  50. <#if currentUser.isAdmin || currentUser.authorities?contains("delete-serials")>
  51. <a href="javascript:void(0)" id="tbSnRemove" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-remove" onclick="removeSerials()">Delete Serials</a>
  52. </#if>
  53. <a href="javascript:void(0)" id="tbSnRefresh" data-options="disabled:true" class="easyui-linkbutton" iconCls="icon-remove" onclick="refreshSerials()">Refresh Serials</a>
  54. </div>
  55. </div>
  56. <div id="dlg" class="easyui-dialog" style="width:750px;display: none;"
  57. closed="true" buttons="#dlg-buttons">
  58. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  59. <div style="margin-bottom:10px; display: none;">
  60. <input name="createdBy" class="easyui-textbox" label="Created By:" style="width:100%">
  61. <input name="updatedBy" class="easyui-textbox" label="updated By:" style="width:100%">
  62. </div>
  63. <div style="margin-bottom:10px">
  64. <input id="dlgOrderNo" name="orderNo" class="easyui-textbox" required="true" data-options="buttonText: 'IFS',onClickButton:getIfsOrder" label="Order No:" style="width:100%">
  65. </div>
  66. <div style="margin-bottom:10px">
  67. <input name="partNo" class="easyui-textbox" readonly required="true" label="Part No:" style="width:100%">
  68. </div>
  69. <div style="margin-bottom:10px">
  70. <input name="partDesc" class="easyui-textbox" readonly required="true" label="Part Description:" style="width:100%">
  71. </div>
  72. <div style="margin-bottom:10px">
  73. <input name="apn" id="apn" class="easyui-textbox" readonly required="true" label="APN:" style="width:100%">
  74. </div>
  75. <div style="margin-bottom:10px">
  76. <input name="customerPartNo" class="easyui-textbox" readonly required="true" label="Customer Part No:" style="width:100%">
  77. </div>
  78. <div style="margin-bottom:10px">
  79. <input name="project" class="easyui-textbox" readonly required="true" label="Project:" style="width:100%">
  80. </div>
  81. <div style="margin-bottom:10px">
  82. <input name="revNo" id="revNo" class="easyui-textbox" readonly required="true" label="Rev No:" style="width:100%">
  83. </div>
  84. <div style="margin-bottom:10px">
  85. <input name="lotSize" class="easyui-numberbox" readonly required="true" label="Lot Size:" style="width:100%">
  86. </div>
  87. <div style="margin-bottom:10px">
  88. <input name="inputLotSize" id = "input_lot_size" class="easyui-numberbox" validtype="valueRange[1,1336335]" required="true" label="Input Lot Size:" style="width:100%">
  89. </div>
  90. <div style="margin-bottom:10px">
  91. <input name="serialsDate" class="easyui-datebox" validtype="validDate" required="true" data-options="parser:myparser" label="Serials Date:" style="width:100%">
  92. </div>
  93. <div style="margin-bottom:10px">
  94. <input name="needDate" class="easyui-datebox" required="true" readonly label="Earliest Start Date:" style="width:100%">
  95. </div>
  96. <div style="margin-bottom:10px">
  97. <input name="noOfCross" class="easyui-numberbox" readonly required="true" label="No of Cross:" style="width:100%">
  98. </div>
  99. <div style="margin-bottom:10px">
  100. <input name="standardRollQty" class="easyui-numberbox" readonly required="true" label="Standard Roll Qty:" style="width:100%">
  101. </div>
  102. </form>
  103. </div>
  104. <div id="dlg-buttons" style="display: none;">
  105. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveSoInfo()" style="width:90px">Save</a>
  106. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  107. </div>
  108. <div id="dlgDtls" class="easyui-dialog" style="width:600px;display: none;"
  109. closed="true" data-options="modal:true" >
  110. <table id="dgDtls" class="easyui-datagrid" style="width:100%;height:300px;display: none;"
  111. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , method:'get', pageSize:20">
  112. <thead>
  113. <tr>
  114. <th data-options="field:'rollNo',width:100">Roll No</th>
  115. <th data-options="field:'createdBy',width:80">Created By</th>
  116. <th data-options="field:'createdDate',width:150,align:'center',formatter:formatDateTime">Created Time</th>
  117. <th data-options="field:'status',width:80">Status</th>
  118. <th data-options="field:'id', width:150,formatter:formatRollAction"></th>
  119. </tr>
  120. </thead>
  121. </table>
  122. </div>
  123. <script>
  124. //公共参数LR 添加
  125. var site = '${currentUser.site}'
  126. var username = '${currentUser.username}';
  127. $(window).resize(function () {
  128. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  129. });
  130. $(function () {
  131. $(window).resize();
  132. });
  133. function onPartDescChange(n,o){
  134. //var p = /Label,([0-9A-Za-z\-]+)-(\S{1})/.exec(n);
  135. var p = n.split(',');
  136. if (p && p.length >= 3){
  137. //判断长度是否符合规则
  138. if(p[2].length != 1){
  139. return false;
  140. }
  141. $("#revNo").textbox("setValue", p[2]);
  142. }else{
  143. //$.messager.alert('error', 'revNo不符合规则', 'error');
  144. return false;
  145. }
  146. }
  147. $.extend($.fn.validatebox.defaults.rules, {
  148. notRequired: function(value){
  149. return true;
  150. },
  151. validDate: {
  152. validator: function(value){
  153. var date = $.fn.datebox.defaults.parser(value);
  154. var s = $.fn.datebox.defaults.formatter(date);
  155. return s==value;
  156. },
  157. message: 'Please enter a valid date.'
  158. },
  159. valueRange: {
  160. validator: function(value,param){
  161. return value >= param[0] && value <= param[1];
  162. },
  163. message: 'Field do not match.'
  164. }
  165. });
  166. function myparser(s){
  167. if(s) return new Date(s);
  168. }
  169. function onTableRowSelect(index, row) {
  170. var noRowSelect = !!!row;
  171. var generated = row && row.serialsGenDate;
  172. $("#tbEdit").linkbutton({"disabled": noRowSelect || generated});
  173. $("#tbRemove").linkbutton({"disabled": noRowSelect || generated});
  174. $("#tbSnGen").linkbutton({"disabled": noRowSelect || generated});
  175. $("#tbSnRefresh").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. //格式化工单的功能 LR 2024-06-19
  188. function formatOrderAction(value, row){
  189. //关闭开放再打开功能
  190. let funTags = '';
  191. let status = row.status;
  192. if('Generated' == status){
  193. funTags += '<a style="text-decoration:none;" href="/export/soOrder/downloadSingleFileZip?orderNo='+row.orderNo+'">Singe Cross</a>';
  194. funTags += '&nbsp;|&nbsp;<a style="text-decoration:none;" href="/export/soOrder/downloadMultiFileZip?orderNo='+row.orderNo+'">Multiple Cross</a>';
  195. return funTags;
  196. }
  197. }
  198. function formatDownload(value,row){
  199. if(row.serialsGenDate){
  200. var a = "<a href='/prepress/downloadFileZip/"+row.orderNo+"'>Download</a>";
  201. a = a + "&nbsp;|&nbsp;<a href='/prepress/downloadFileZipMulit/"+row.orderNo+"'>MulitDownload</a>";
  202. // a = a + "&nbsp;|&nbsp;<a href='javascript:downloadTrace(\""+row.orderNo+"\")'>Trace</a>";
  203. return a;
  204. }
  205. return "";
  206. }
  207. function formatRollAction(value, row){
  208. return "<a href='/qrcode/"+row.rollNo+"/' target='_blank'>2D Barcode</a>";
  209. }
  210. function viewRolls(orderNo){
  211. $('#dlgDtls').dialog('open').dialog('center').dialog('setTitle',orderNo+' SFG roll');
  212. $("#dgDtls").datagrid({url: "/prepress/orderrolls/"+orderNo});
  213. }
  214. var url;
  215. function newSoInfo(){
  216. $('#dlg').dialog('open').dialog('center').dialog('setTitle','New Order Info');
  217. $('#fm').form('clear');
  218. //设置创建人
  219. setByInputName("createdBy", username);
  220. setByInputName("updatedBy", username);
  221. url = '/prepress/soinfo/addSoInfo';
  222. }
  223. function editSoInfo(){
  224. var row = $('#dg').datagrid('getSelected');
  225. if (row){
  226. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Edit Order Info');
  227. //设置创建人设置修改人
  228. $('#fm').form('load',row);
  229. setByInputName("createdBy", username);
  230. setByInputName("updatedBy", username);
  231. url = '/prepress/soinfo/'+row.id+'/update';
  232. }else{
  233. $.messager.alert('Warning','Please select a row.', 'warning');
  234. }
  235. }
  236. var delay = (function(){
  237. var timer = 0;
  238. return function(callback, ms){
  239. clearTimeout (timer);
  240. timer = setTimeout(callback, ms);
  241. };
  242. })();
  243. function saveSoInfo(){
  244. //获取字符串 判断是否符合规则
  245. let revNo = $("#revNo").textbox("getValue");
  246. if(revNo.length != 1){
  247. $.messager.alert('error', 'RevNo does not comply with the rules!', 'error');
  248. return false;
  249. }
  250. let apn = $("#apn").textbox("getValue");
  251. if(apn.length != 11){
  252. $.messager.alert('error', 'Apn does not comply with the rules!', 'error');
  253. return false;
  254. }
  255. //判断是否数量大于5000
  256. let lotSize = $('#input_lot_size').val();
  257. if(lotSize < 5000){
  258. $.messager.confirm('continue', 'Serial number is less than 5000, continue!', function (status) {
  259. if (status) {
  260. saveSoInfoData();
  261. }
  262. });
  263. }else{
  264. saveSoInfoData();
  265. }
  266. }
  267. //保存工单的信息(新增和修改)
  268. function saveSoInfoData(){
  269. $('#fm').form('submit',{
  270. url: url,
  271. onSubmit: function(){
  272. return $(this).form('validate');
  273. },
  274. success: function(result){
  275. var result = eval("("+result+")");
  276. if (!result.success){
  277. $.messager.alert('error',result.msg, 'error');
  278. } else {
  279. $('#dlg').dialog('close'); // close the dialog
  280. $('#dg').datagrid('reload'); // reload the user data
  281. }
  282. }
  283. });
  284. }
  285. function removeSoInfo(){
  286. var row = $('#dg').datagrid('getSelected');
  287. if (row){
  288. $.messager.confirm('Confirm','Delete the selected order <b>'+row.orderNo+'</b> ?',function(r){
  289. if (r){
  290. $.post('/prepress/soinfo/'+row.id+'/delete',{},function(result){
  291. if (result.success){
  292. $('#dg').datagrid('reload'); // reload the user data
  293. } else {
  294. $.messager.alert('error',result.errorMsg, 'error');
  295. }
  296. },'json');
  297. }
  298. });
  299. }else{
  300. $.messager.alert('Warning','Please select a row.', 'warning');
  301. }
  302. }
  303. function genSerials(){
  304. var row = $('#dg').datagrid('getSelected');
  305. if (row){
  306. $.messager.confirm('Confirm','Generate serial numbers for selected order <b>'+row.orderNo+'</b> ?',function(r){
  307. if (r){
  308. $.post('/prepress/soinfo/'+row.id+'/genSerials',{},function(result){
  309. if (result.success){
  310. $('#dg').datagrid('reload');
  311. $.messager.alert('Success','Serial numbers generated successfully', 'info');
  312. } else {
  313. $.messager.alert('Error',result.errorMsg, 'error');
  314. }
  315. },'json');
  316. }
  317. });
  318. }else{
  319. $.messager.alert('Warning','Please select a row.', 'warning');
  320. }
  321. }
  322. function refreshSerials() {
  323. var row = $('#dg').datagrid('getSelected');
  324. if (row){
  325. if (row.serialsGenDate){
  326. $.messager.alert('Warning','do not need refresh', 'warning');
  327. return;
  328. }
  329. $.post('/prepress/soinfo/'+row.id+'/refreshSerials',{},function(result){
  330. if (result.success){
  331. $('#dg').datagrid('reload');
  332. $.messager.alert('Success','successfully', 'info');
  333. } else {
  334. $.messager.alert('Error',result.errorMsg, 'error');
  335. }
  336. },'json');
  337. }else{
  338. $.messager.alert('Warning','Please select a row.', 'warning');
  339. }
  340. }
  341. function removeSerials(){
  342. var row = $('#dg').datagrid('getSelected');
  343. if (row){
  344. if (!row.serialsGenDate){
  345. $.messager.alert('Warning','Not yet generated', 'warning');
  346. return;
  347. }
  348. $.messager.confirm('Confirm','Remove generated serial numbers for selected order <b>'+row.orderNo+'</b> ?',function(r){
  349. if (r){
  350. $.post('/prepress/soinfo/'+row.id+'/delsn',{},function(result){
  351. if (result.success){
  352. $('#dg').datagrid('reload');
  353. $.messager.alert('Success','Serial numbers deleted successfully', 'info');
  354. } else {
  355. $.messager.alert('Error',result.errorMsg, 'error');
  356. }
  357. },'json');
  358. }
  359. });
  360. }else{
  361. $.messager.alert('Warning','Please select a row.', 'warning');
  362. }
  363. }
  364. function downloadTrace(orderNo){
  365. $.post("/prepress/downloadTrace", {orderNo: orderNo}, function(ret){
  366. console.log(ret);
  367. if(ret.success){
  368. window.location.href="/prepress/downloadFileZip/"+ret.fileName;
  369. }else{
  370. $.messager.alert('Error',ret.errorMsg, 'error');
  371. }
  372. });
  373. }
  374. function setByInputName(inpt, value){
  375. var $inpt = $("#dlg input[textboxname="+inpt+"]");
  376. $inpt.textbox({"value": value});
  377. }
  378. function getIfsOrder(){
  379. var orderNo = $("#dlgOrderNo").val();
  380. if (orderNo != ""){
  381. $.post("/prepress/ifsOrder", {orderNo: orderNo}, function (data) {
  382. console.log(data);
  383. if(data.success){
  384. var apn = data.ifsOrder.apn;
  385. if (apn.length == 11) {
  386. //正常行为
  387. }else {
  388. //不正常的
  389. $.messager.alert('Error', 'Length of apn does not comply with the rules!', 'error');
  390. return false;
  391. }
  392. setByInputName("partNo", data.ifsOrder.partNo);
  393. setByInputName("partDesc", data.ifsOrder.partDesc);
  394. setByInputName("apn", apn);
  395. setByInputName("revNo", data.ifsOrder.revNo);
  396. setByInputName("customerPartNo", data.ifsOrder.customerPartNo);
  397. setByInputName("project", data.ifsOrder.projectCode);
  398. setByInputName("lotSize", data.ifsOrder.lotsize);
  399. setByInputName("inputLotSize", accMul(data.ifsOrder.lotsize,1.20));
  400. setByInputName("standardRollQty", data.ifsOrder.standardRollQty);
  401. setByInputName("noOfCross", data.ifsOrder.noOfCross);
  402. setByInputName("needDate", formatDate(data.ifsOrder.need_date));
  403. setByInputName("serialsDate", formatDate(data.ifsOrder.serials_date));
  404. //onPartDescChange(data.ifsOrder.part_description, 1);
  405. }else{
  406. $.messager.alert('Error', data.msg, 'error');
  407. }
  408. })
  409. }
  410. }
  411. function accMul(num1,num2){
  412. var m=0,s1=num1.toString(),s2=num2.toString();
  413. try{m+=s1.split(".")[1].length}catch(e){};
  414. try{m+=s2.split(".")[1].length}catch(e){};
  415. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
  416. }
  417. </script>
  418. </@master.layout>