index.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <table id="dg" class="easyui-datagrid"
  2. url="/index.php?r=userConfig/list"
  3. toolbar="#toolbar"
  4. rownumbers="true" fitColumns="true" singleSelect="true">
  5. <thead>
  6. <tr>
  7. <th field="name" width="150">配置名</th>
  8. <th field="value" width="150">配置值</th>
  9. </tr>
  10. </thead>
  11. </table>
  12. <div id="toolbar">
  13. <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newRule()">创建新配置</a> -->
  14. <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editRule()">编辑配置</a>
  15. <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="delRule()">删除配置</a> -->
  16. </div>
  17. <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
  18. closed="true" buttons="#dlg-buttons">
  19. <form id="fm" method="post" novalidate>
  20. <div class="fitem">
  21. <label>配置名:</label>
  22. <input name="key" class="easyui-textbox" required="true">
  23. </div>
  24. <div class="fitem">
  25. <label>配置值:</label>
  26. <input name="value" class="easyui-textbox" required="true">
  27. </div>
  28. </form>
  29. </div>
  30. <div id="dlg-buttons">
  31. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
  32. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  33. </div>
  34. <script type="text/javascript">
  35. function newRule(){
  36. $('#dlg').dialog('open').dialog('setTitle','New Rule');
  37. $('#fm').form('clear');
  38. url = '/index.php?r=sysConfig/set';
  39. }
  40. function saveUser(){
  41. $('#fm').form('submit',{
  42. url: url,
  43. onSubmit: function(){
  44. return true;
  45. },
  46. success: function(result){
  47. var result = eval('('+result+')');
  48. if (result.errorMsg){
  49. $.messager.show({
  50. title: 'Error',
  51. msg: result.errorMsg
  52. });
  53. } else {
  54. $('#dlg').dialog('close'); // close the dialog
  55. $('#dg').datagrid('reload'); // reload the user data
  56. }
  57. }
  58. });
  59. }
  60. function editRule(){
  61. var row = $('#dg').datagrid('getSelected');
  62. if (row){
  63. $('#dlg').dialog('open').dialog('setTitle','编辑配置');
  64. $('#fm').form('load',row);
  65. url = '/index.php?r=sysConfig/set';
  66. }
  67. }
  68. </script>