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.

184 lines
6.5 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>Scan Jobs</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 , url:'/scanning/jobs/all',method:'get',pageSize:20,toolbar:'#tb'">
  13. <thead>
  14. <tr>
  15. <th data-options="field:'jobId',width:100">Scanning machine number</th>
  16. <#--<th data-options="field:'createdBy',width:80,align:'left'">Created By</th>-->
  17. <#--<th data-options="field:'createdDate',width:150,align:'center',formatter:formatDateTime">Created Time</th>-->
  18. <th data-options="field:'jdbcUrl',width:400">Database url</th>
  19. <th data-options="field:'scanType',width:400,formatter:passageway">Scanning channel</th>
  20. <th data-options="field:'id',width:100,editor:'textbox',formatter:formatAction">Actions</th>
  21. </tr>
  22. </thead>
  23. </table>
  24. <div id="tb" style="padding:10px 5px;display: none;">
  25. <div>
  26. <#--任务号: <input class="easyui-textbox" id="jobId" style="width:110px">-->
  27. <#--创建日期: <input class="easyui-datebox" id="createdDateFrom" style="width:100px">-->
  28. <#--到: <input class="easyui-datebox" id="createdDateTo" style="width:100px">-->
  29. <#--<a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>-->
  30. <#--&nbsp;&nbsp;&nbsp;-->
  31. <#if currentUser.isAdmin>
  32. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newJob()">New scanning machine</a>
  33. </#if>
  34. </div>
  35. </div>
  36. <div id="dlg" class="easyui-dialog" style="width:600px;display: none;"
  37. closed="true" buttons="#dlg-buttons">
  38. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  39. <div style="margin-bottom:10px">
  40. <input id="dlgJobId" name="jobId" class="easyui-textbox" required="true" label="Scanning machine number:" style="width:100%">
  41. </div>
  42. <div style="margin-bottom:10px">
  43. <input name="jdbcUrl" class="easyui-textbox" required="true" label="Database url" style="width:100%">
  44. </div>
  45. <div style="margin-bottom:10px">
  46. <input name="jdbcUsername" class="easyui-textbox" required="true" label="数据库用户:" style="width:100%">
  47. </div>
  48. <div style="margin-bottom:10px">
  49. <input name="jdbcPassword" class="easyui-textbox" required="true" label="数据库密码:" style="width:100%">
  50. </div>
  51. <div style="margin-bottom:10px">
  52. <select class="easyui-combobox" name="scanType" required="true" label="Scanning channel" style="width:100%">
  53. <option value="h">High Speed</option>
  54. <option value="l">Low Speed</option>
  55. </select>
  56. </div>
  57. </form>
  58. </div>
  59. <div id="dlg-buttons" style="display: none;">
  60. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveJobInfo()" style="width:90px">Save</a>
  61. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  62. </div>
  63. <script>
  64. $(window).resize(function () {
  65. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  66. });
  67. $(function () {
  68. $(window).resize();
  69. });
  70. $("#queryLink").click(function(){
  71. var dg = $('#dg').datagrid({
  72. queryParams: {
  73. jobId: $("#jobId").val(),
  74. createdDateFrom: $("#createdDateFrom").val(),
  75. createdDateTo: $("#createdDateTo").val()
  76. }
  77. });
  78. });
  79. function passageway(value,row){
  80. if("l"==value){
  81. return "Low Speed";
  82. }else if("h"==value){
  83. return "High Speed";
  84. }
  85. return "";
  86. }
  87. function formatAction(value,row){
  88. var a = "<a href='/scanning/jobdtls/"+row.id+"'>Scanning</a>";
  89. // if(!row.status || row.status == "Created") {
  90. <#if currentUser.isAdmin>
  91. a = a + "&nbsp;|&nbsp;<a href='javascript:editJob("+row.id+");'>Edit</a>";
  92. a = a + "&nbsp;|&nbsp;<a href='javascript:delJob("+row.id+");'>Delete</a>";
  93. </#if>
  94. // }
  95. return a;
  96. }
  97. var url;
  98. function newJob(){
  99. // $.post("/scanning/jobs/add", {}, function (ret) {
  100. // if (ret.success){
  101. // $('#dg').datagrid('reload'); // reload the user data
  102. // }
  103. // })
  104. $('#dlg').dialog('open').dialog('center').dialog('setTitle','New scanning machine');
  105. $('#fm').form('clear');
  106. url = '/scanning/jobs/add';
  107. }
  108. function editJob(){
  109. var row = $('#dg').datagrid('getSelected');
  110. if (row){
  111. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Edit Scanning machine');
  112. $('#fm').form('load',row);
  113. url = '/scanning/jobs/'+row.id+'/update';
  114. }else{
  115. $.messager.alert('Warning','Please select a row.', 'warning');
  116. }
  117. }
  118. function delJob(id) {
  119. $.messager.confirm('Confirm', 'Are you sure to delete the data?', function (r) {
  120. if (r) {
  121. $.post('/scanning/jobs/del', {id: id}, function (result) {
  122. if (result.success) {
  123. $('#dg').datagrid('reload');
  124. $.messager.alert('Success', 'Successfully', 'info');
  125. } else {
  126. $.messager.alert('Error', result.errorMsg, 'error');
  127. }
  128. }, 'json');
  129. }
  130. });
  131. }
  132. var delay = (function(){
  133. var timer = 0;
  134. return function(callback, ms){
  135. clearTimeout (timer);
  136. timer = setTimeout(callback, ms);
  137. };
  138. })();
  139. function saveJobInfo(){
  140. delay(function(){
  141. $('#fm').form('submit',{
  142. url: url,
  143. onSubmit: function(){
  144. return $(this).form('validate');
  145. },
  146. success: function(result){
  147. var result = eval("("+result+")");
  148. if (result.errorMsg){
  149. $.messager.alert('error',result.errorMsg, 'error');
  150. } else {
  151. $('#dlg').dialog('close'); // close the dialog
  152. $('#dg').datagrid('reload'); // reload the user data
  153. }
  154. }
  155. });
  156. }, 500);
  157. }
  158. </script>
  159. </@master.layout>