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.

229 lines
7.8 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>User Management</h3>
  10. </div>
  11. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  12. data-options="pagination: false, showFooter: true, singleSelect:true, fitColumns:true , url:'/user/json',method:'get',pageSize:20,toolbar:'#tb'">
  13. <thead>
  14. <tr>
  15. <th data-options="field:'username', width:100">User ID</th>
  16. <th data-options="field:'display', width:100">User Name</th>
  17. <th data-options="field:'authorities', width:150">Permission Set</th>
  18. <th data-options="field:'scanMachine', width:100">Scanning Machine</th>
  19. <th data-options="field:'enabled', width:50,formatter:formatStatus">User Status</th>
  20. <th data-options="field:'id',width:60,align:'center',formatter:formatAction">Actions</th>
  21. </tr>
  22. </thead>
  23. </table>
  24. <div id="tb" style="padding:10px 5px;display: none;">
  25. <div>
  26. User ID: <input class="easyui-textbox" id="username" style="width:110px">
  27. <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  28. &nbsp;&nbsp;&nbsp;
  29. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="newUser()">New</a>
  30. </div>
  31. </div>
  32. <div id="dlg" class="easyui-dialog" style="width:500px;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="txtUsername" name="username" class="easyui-textbox" required="true" label="User ID:" style="width:100%">
  37. </div>
  38. <div style="margin-bottom:10px">
  39. <input name="display" class="easyui-textbox" required="true" label="Name:" style="width:100%">
  40. </div>
  41. <div style="margin-bottom:10px">
  42. <input id="pwd" name="password" class="easyui-passwordbox" required="true" label="Password:" style="width:100%">
  43. </div>
  44. <div style="margin-bottom:10px">
  45. <select id="selEnabled" class="easyui-combobox" name="enabled" label="Active status:" style="width:100%">
  46. <option value="1">Activate</option>
  47. <option value="0">Disabled</option>
  48. </select>
  49. </div>
  50. <div style="margin-bottom:10px">
  51. <select class="easyui-combobox" name="authorities" required multiple="true" label="Access right:" style="width:100%;">
  52. <option>prepress</option>
  53. <option>indigo</option>
  54. <option>thermal</option>
  55. <option>cut</option>
  56. <option>abg</option>
  57. <option>aoi</option>
  58. <option>rewind</option>
  59. <option>scanning</option>
  60. <option>cqc</option>
  61. <option>receiving</option>
  62. <option>dispatch</option>
  63. <option>query</option>
  64. <option>counting</option>
  65. <option>switch_order</option>
  66. <option>super_leader</option>
  67. <option>deleteFinalRoll</option>
  68. <option>closeorder</option>
  69. <option>freezeAndThaw</option>
  70. <option>printer</option>
  71. <option>boxManage</option>
  72. <option>shipPlan_update</option>
  73. <option>emailConfig</option>
  74. <option>refreshRollStatus</option>
  75. <option>printer_roll</option>
  76. <option>basic_info</option>
  77. <!-- <option>delete-serials</option> -->
  78. </select>
  79. </div>
  80. <div style="margin-bottom:10px">
  81. <input id="scanMachine" class="easyui-combobox" name="scanMachine" label="Scanning machine:" style="width:100%" data-options="
  82. valueField: 'jobId',
  83. textField: 'jobId',
  84. url: '/user/scanMachine'
  85. ">
  86. </div>
  87. </form>
  88. </div>
  89. <div id="dlg-buttons" style="display: none;">
  90. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
  91. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  92. </div>
  93. <script>
  94. $(window).resize(function () {
  95. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  96. });
  97. $(function () {
  98. $(window).resize();
  99. });
  100. function formatAction(value, row){
  101. return "<a href='javascript:editUser()'>Edit</a>&nbsp;|&nbsp<a href='javascript:removeUser()'>Delete</a>";
  102. }
  103. function formatStatus(value, row){
  104. return value == 1 ? "Activate" : "Disabled";
  105. }
  106. $("#queryLink").click(function(){
  107. var dg = $('#dg').datagrid({
  108. queryParams: {
  109. username: $.trim($("#username").val())
  110. }
  111. });
  112. });
  113. var url;
  114. function newUser(){
  115. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Create a new user');
  116. $("#txtUsername").textbox({"disabled" : false});
  117. $("#pwd").passwordbox({
  118. prompt: '',
  119. required: true
  120. });
  121. $('#fm').form('clear');
  122. $('#selEnabled').combobox('setValue', '1');
  123. url = '/user/add';
  124. }
  125. function editUser(){
  126. var row = $('#dg').datagrid('getSelected');
  127. if (row){
  128. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Modify User Info.');
  129. $('#fm').form('load',row);
  130. $("#txtUsername").textbox({"disabled" : true});
  131. $("#pwd").passwordbox({
  132. prompt: 'Keep null if don\'t modify password',
  133. required: false
  134. });
  135. url = '/user/'+row.id+'/update';
  136. }else{
  137. $.messager.alert('Warning','Please select user.', 'warning');
  138. }
  139. }
  140. var delay = (function(){
  141. var timer = 0;
  142. return function(callback, ms){
  143. clearTimeout (timer);
  144. timer = setTimeout(callback, ms);
  145. };
  146. })();
  147. function saveUser(){
  148. delay(function(){
  149. $('#fm').form('submit',{
  150. url: url,
  151. onSubmit: function(){
  152. return $(this).form('validate');
  153. },
  154. success: function(result){
  155. var result = eval("("+result+")");
  156. if (result.errorMsg){
  157. $.messager.alert('error',result.errorMsg, 'error');
  158. } else {
  159. $('#dlg').dialog('close'); // close the dialog
  160. $('#dg').datagrid('reload'); // reload the user data
  161. }
  162. }
  163. });
  164. }, 500);
  165. }
  166. function removeUser(){
  167. var row = $('#dg').datagrid('getSelected');
  168. if (row){
  169. $.messager.confirm('Confirm','Are you sure to delete user <b>'+row.username+'</b> ?',function(r){
  170. if (r){
  171. $.post('/user/'+row.id+'/delete',{},function(result){
  172. if (result.success){
  173. $('#dg').datagrid('reload'); // reload the user data
  174. } else {
  175. $.messager.alert('error',result.errorMsg, 'error');
  176. }
  177. },'json');
  178. }
  179. });
  180. }else{
  181. $.messager.alert('Warning','Please select user', 'warning');
  182. }
  183. }
  184. function setupAuthorities(){
  185. var row = $('#dg').datagrid('getSelected');
  186. if (row) {
  187. alert(row.username);
  188. }
  189. }
  190. function setupScan(){
  191. var row = $('#dg').datagrid('getSelected');
  192. if (row) {
  193. alert(row.username);
  194. }
  195. }
  196. </script>
  197. </@master.layout>