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.

186 lines
6.1 KiB

1 week 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>机器设置</h3>
  10. </div>
  11. <!-- 机器展示列表 -->
  12. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  13. data-options="pagination: true, showFooter: true, singleSelect:true, fitColumns:true , url:'/base/getVariousMachine',method:'POST',pageSize:20,toolbar:'#tb'">
  14. <thead>
  15. <tr>
  16. <th data-options="field:'machineName',width:100">机器名称</th>
  17. <th data-options="field:'jdbcUrl',width:400">数据库Url</th>
  18. <th data-options="field:'machineType',width:400">机器类型</th>
  19. <th data-options="field:'id',width:100,editor:'textbox',formatter:formatAction">操作</th>
  20. </tr>
  21. </thead>
  22. </table>
  23. <!-- 机器展示列表按钮 -->
  24. <div id="tb" style="padding:10px 5px;display: none;">
  25. <div>
  26. <#if currentUser.isAdmin>
  27. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="addMachineModal()">新增机器</a>
  28. </#if>
  29. </div>
  30. </div>
  31. <!-- 机器新增和修改的按钮 -->
  32. <div id="dlg" class="easyui-dialog" style="width:600px;display: none;"
  33. closed="true" buttons="#dlg-buttons">
  34. <form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
  35. <div style="margin-bottom:10px">
  36. <input id="dlg_machine_id" name="id" class="easyui-textbox">
  37. <input id="dlg_machine_name" name="machineName" class="easyui-textbox" required="true" label="机器名称:" style="width:100%">
  38. </div>
  39. <div style="margin-bottom:10px">
  40. <input id="dlg_jdbc_driver" name="jdbcDriver" class="easyui-textbox" required="true" label="数据库驱动" style="width:100%">
  41. </div>
  42. <div style="margin-bottom:10px">
  43. <input id="dlg_jdbc_name" name="jdbcUrl" class="easyui-textbox" required="true" label="数据库Url" style="width:100%">
  44. </div>
  45. <div style="margin-bottom:10px">
  46. <input id="dlg_jdbc_username" 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" id="dlg_machine_type"name="machineType" required="true" label="机器类型" style="width:100%">
  53. <option value="laser">镭射</option>
  54. <option value="measure">测量机</option>
  55. <option value="scanner">扫描机</option>
  56. </select>
  57. </div>
  58. </form>
  59. </div>
  60. <!-- 模态框功能按钮 -->
  61. <div id="dlg-buttons" style="display: none;">
  62. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveMachineData()" style="width:90px">Save</a>
  63. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  64. </div>
  65. <script>
  66. $(window).resize(function () {
  67. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  68. });
  69. $(function () {
  70. $(window).resize();
  71. });
  72. $("#queryLink").click(function(){
  73. var dg = $('#dg').datagrid({
  74. queryParams: {
  75. jobId: $("#jobId").val(),
  76. createdDateFrom: $("#createdDateFrom").val(),
  77. createdDateTo: $("#createdDateTo").val()
  78. }
  79. });
  80. });
  81. function passageway(value,row){
  82. if("l"==value){
  83. return "低速";
  84. }else if("h"==value){
  85. return "高速";
  86. }
  87. return "";
  88. }
  89. function formatAction(value,row){
  90. let a = '';
  91. <#if currentUser.isAdmin>
  92. a = a + "&nbsp;&nbsp;<a href='javascript:editMachineModal();'>修改</a>";
  93. a = a + "&nbsp;|&nbsp;<a href='javascript:deleteMachineData("+row.id+");'>删除</a>";
  94. </#if>
  95. return a;
  96. }
  97. //新增机器modal
  98. var url;
  99. function addMachineModal(){
  100. $('#dlg').dialog('open').dialog('center').dialog('setTitle','新增机器');
  101. $('#fm').form('clear');
  102. $('#dlg_machine_id').textbox("setValue", 0);
  103. $('#dlg_machine_id').next().hide();
  104. url = '/base/addMachineData';
  105. }
  106. //修改机器的Modal
  107. function editMachineModal(){
  108. var row = $('#dg').datagrid('getSelected');
  109. if (row){
  110. $('#dlg').dialog('open').dialog('center').dialog('setTitle','修改机器');
  111. $('#fm').form('load',row);
  112. $('#dlg_machine_id').next().hide();
  113. url = '/base/updateMachineData';
  114. }else{
  115. $.messager.alert('Warning','Please select a row.', 'warning');
  116. }
  117. }
  118. //删除机器
  119. function deleteMachineData(id) {
  120. $.messager.confirm('Confirm', '确定删除?', function (r) {
  121. if (r) {
  122. $.post('/base/deleteMachineData', {id: id}, function (result) {
  123. if (result.success) {
  124. $('#dg').datagrid('reload');
  125. $.messager.alert('Success', '删除成功', 'info');
  126. } else {
  127. $.messager.alert('Error', result.errorMsg, 'error');
  128. }
  129. }, 'json');
  130. }
  131. });
  132. }
  133. //延时
  134. var delay = (function(){
  135. var timer = 0;
  136. return function(callback, ms){
  137. clearTimeout (timer);
  138. timer = setTimeout(callback, ms);
  139. };
  140. })();
  141. //保存机器的参数
  142. function saveMachineData(){
  143. delay(function(){
  144. $('#fm').form('submit',{
  145. url: url,
  146. onSubmit: function(){
  147. return $(this).form('validate');
  148. },
  149. success: function(result){
  150. var result = eval("("+result+")");
  151. if (result.errorMsg){
  152. $.messager.alert('error',result.errorMsg, 'error');
  153. } else {
  154. $('#dlg').dialog('close'); // close the dialog
  155. $('#dg').datagrid('reload'); // reload the user data
  156. }
  157. }
  158. });
  159. }, 500);
  160. }
  161. </script>
  162. </@master.layout>