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.

238 lines
7.7 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>User Management</h3>
  10. </div>
  11. <!-- 用户的主页面 -->
  12. <table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
  13. data-options="pagination: false, showFooter: true, singleSelect:true,
  14. fitColumns:true , url:'/user/getUserDataByCon',method:'POST',pageSize:20,toolbar:'#tb'">
  15. <thead>
  16. <tr>
  17. <th data-options="field:'username', width:100">User ID</th>
  18. <th data-options="field:'display', width:100">User Name</th>
  19. <th data-options="field:'authorities', width:150">Permission Set</th>
  20. <th data-options="field:'machineName', width:100">Linked Scanning Machine</th>
  21. <th data-options="field:'status', width:50,formatter:formatStatus">User Status</th>
  22. <th data-options="field:'id',width:60,align:'center',formatter:formatAction">Actions</th>
  23. </tr>
  24. </thead>
  25. </table>
  26. <!-- 页面对应的功能 -->
  27. <div id="tb" style="padding:10px 5px;display: none;">
  28. <div>
  29. User ID: <input class="easyui-textbox" id="username" style="width:110px">
  30. <a href="#nowhere" id="queryLink" class="easyui-linkbutton" iconCls="icon-search">Search</a>
  31. &nbsp;&nbsp;&nbsp;
  32. <a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="addUserModal()">New</a>
  33. </div>
  34. </div>
  35. <!-- 用户修改和新增 -->
  36. <div id="dlg" class="easyui-dialog" style="width:500px;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="user_id" name="id" class="easyui-textbox">
  41. <input id="txtUsername" name="username" class="easyui-textbox" required="true" label="User ID:" style="width:100%">
  42. </div>
  43. <div style="margin-bottom:10px">
  44. <input name="display" class="easyui-textbox" required="true" label="User Name:" style="width:100%">
  45. </div>
  46. <div style="margin-bottom:10px">
  47. <input id="pwd" name="password" class="easyui-passwordbox" required="true" label="Password:" style="width:100%">
  48. </div>
  49. <div style="margin-bottom:10px">
  50. <select id="user_status" class="easyui-combobox" name="status" label="Active:" style="width:100%">
  51. <option value="Y">Activate</option>
  52. <option value="N">Disabled</option>
  53. </select>
  54. </div>
  55. <div style="margin-bottom:10px">
  56. <select class="easyui-combobox" name="authorities" required multiple="true" label="Authority:" style="width:100%;">
  57. <option>prepress</option>
  58. <option>basic_info</option>
  59. <option>indigo</option>
  60. <option>AOI</option>
  61. <option>scan_stock</option>
  62. <option>Query</option>
  63. <option>inventoryTasks</option>
  64. <option>delivery</option>
  65. <option>team_auth</option>
  66. <option>switch_order</option>
  67. <option>inventoryTasks</option>
  68. </select>
  69. </div>
  70. <#-- <div style="margin-bottom:10px">-->
  71. <#-- <input id="user_machine_name" class="easyui-combobox" name="machineName" label="Linked Scaning Machine:" style="width:100%" data-options="-->
  72. <#-- valueField: 'machineName',-->
  73. <#-- textField: 'machineName',-->
  74. <#-- url: '/user/getVariousMachine',-->
  75. <#-- onLoadSuccess: function(data) {-->
  76. <#-- if(data.success){-->
  77. <#-- let machines = data.rows; -->
  78. <#-- $('#user_machine_name').combobox('loadData', data.rows);-->
  79. <#-- }-->
  80. <#-- }-->
  81. <#-- ">-->
  82. <#-- </div>-->
  83. </form>
  84. </div>
  85. <div id="dlg-buttons" style="display: none;">
  86. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
  87. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  88. </div>
  89. <script>
  90. $(window).resize(function () {
  91. $("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
  92. });
  93. $(function () {
  94. $(window).resize();
  95. });
  96. //首页查询
  97. $("#queryLink").click(function(){
  98. var dg = $('#dg').datagrid({
  99. queryParams: {
  100. username: $("#username").val()
  101. }
  102. });
  103. });
  104. //功能菜单
  105. function formatAction(value, row){
  106. return "<a href='javascript:editUserModal()'>修改</a>&nbsp;|&nbsp<a href='javascript:deleteUser()'>Delete</a>";
  107. }
  108. //用户信息状态设置
  109. function formatStatus(value, row){
  110. if('Y' == value){
  111. return "Activate";
  112. }else{
  113. return "Disabled";
  114. }
  115. }
  116. //新增用户modal
  117. var url;
  118. function addUserModal(){
  119. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Create a new user');
  120. $("#txtUsername").textbox({"disabled" : false});
  121. $("#pwd").passwordbox({
  122. prompt: '',
  123. required: true
  124. });
  125. $('#fm').form('clear');
  126. $("#user_id").textbox("setValue", 0);
  127. $('#user_id').next().hide();
  128. $('#user_status').combobox('setValue', 'Y');
  129. url = '/user/addUser';
  130. }
  131. //修改用户modal
  132. function editUserModal(){
  133. var row = $('#dg').datagrid('getSelected');
  134. if (row){
  135. $('#dlg').dialog('open').dialog('center').dialog('setTitle','Modify User Info.');
  136. $('#fm').form('load',row);
  137. $("#txtUsername").textbox({"disabled" : true});
  138. $("#pwd").passwordbox({
  139. prompt: 'Keep null if don\'t modify password',
  140. required: false
  141. });
  142. $('#user_id').next().hide();
  143. url = '/user/updateUser';
  144. }else{
  145. $.messager.alert('Warning','Please select user.', 'warning');
  146. }
  147. }
  148. //延时操作
  149. var delay = (function(){
  150. var timer = 0;
  151. return function(callback, ms){
  152. clearTimeout (timer);
  153. timer = setTimeout(callback, ms);
  154. };
  155. })();
  156. //保存用户信息
  157. function saveUser(){
  158. delay(function(){
  159. $('#fm').form('submit',{
  160. url: url,
  161. onSubmit: function(){
  162. return $(this).form('validate');
  163. },
  164. success: function(result){
  165. var result = eval("("+result+")");
  166. if (result.errorMsg){
  167. $.messager.alert('error',result.errorMsg, 'error');
  168. } else {
  169. $('#dlg').dialog('close'); // close the dialog
  170. $('#dg').datagrid('reload'); // reload the user data
  171. }
  172. }
  173. });
  174. }, 500);
  175. }
  176. //删除用户
  177. function deleteUser(){
  178. var row = $('#dg').datagrid('getSelected');
  179. if (row){
  180. $.messager.confirm('Confirm','Are you sure to delete user <b>'+row.username+'</b> ?',function(r){
  181. if (r){
  182. $.post('/user/deleteUserById',{'userId': row.id},function(result){
  183. if (result.success){
  184. $('#dg').datagrid('reload'); // reload the user data
  185. } else {
  186. $.messager.alert('error',result.errorMsg, 'error');
  187. }
  188. },'json');
  189. }
  190. });
  191. }else{
  192. $.messager.alert('Warning','Please select user', 'warning');
  193. }
  194. }
  195. function setupAuthorities(){
  196. var row = $('#dg').datagrid('getSelected');
  197. if (row) {
  198. alert(row.username);
  199. }
  200. }
  201. function setupScan(){
  202. var row = $('#dg').datagrid('getSelected');
  203. if (row) {
  204. alert(row.username);
  205. }
  206. }
  207. </script>
  208. </@master.layout>