index.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <table id="dg" class="easyui-datagrid"
  2. url="/index.php?r=urlConfig/list"
  3. toolbar="#toolbar"
  4. rownumbers="true" fitColumns="true" singleSelect="true">
  5. <thead>
  6. <tr>
  7. <th field="key" 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. <textarea name="value" class="textbox-text" autocomplete="off" placeholder="" style="width:300px;height:100px" required="true"></textarea>
  27. <!-- <input name="value" class="easyui-textbox" data-options="multiline:true" style="width:300px;height:100px" required="true"> -->
  28. </div>
  29. </form>
  30. </div>
  31. <div id="dlg-buttons">
  32. <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveRule()" style="width:90px">Save</a>
  33. <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  34. </div>
  35. <script type="text/javascript">
  36. function newRule(){
  37. $('#dlg').dialog('open').dialog('setTitle','新建配置');
  38. $('#fm').form('clear');
  39. url = '/index.php?r=urlConfig/edit';
  40. }
  41. function editRule(){
  42. var row = $('#dg').datagrid('getSelected');
  43. if (row){
  44. $('#dlg').dialog('open').dialog('setTitle','编辑配置');
  45. $('#fm').form('load',row);
  46. url = '/index.php?r=urlConfig/edit';
  47. }
  48. }
  49. function saveRule(){
  50. $('#fm').form('submit',{
  51. url: url,
  52. onSubmit: function(){
  53. var isValid = $(this).form('validate');
  54. if (!isValid){
  55. $.messager.progress('close');
  56. }
  57. return isValid;
  58. },
  59. success: function(res){
  60. $.messager.progress('close');
  61. var res = JSON.parse(res);
  62. if (res.success) {
  63. $.messager.show({
  64. title : '提示',
  65. msg : '操作成功',
  66. timeout : 3500,
  67. showType : 'slide'
  68. });
  69. $('#dlg').dialog('close');
  70. $('#dg').datagrid('reload');
  71. } else {
  72. $.messager.show({
  73. title : '提示',
  74. msg : res.message,
  75. timeoutout : 3500,
  76. showType : 'slide'
  77. });
  78. };
  79. }
  80. });
  81. }
  82. </script>