rules.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>规则管理</title>
  6. <link href="{#helper\globals::getCss("style")#}" rel="stylesheet" type="text/css" />
  7. <link href="{#helper\globals::getCss("select")#}" rel="stylesheet" type="text/css" />
  8. <link href="{#helper\globals::getCss("jquery.multiSelect")#}" rel="stylesheet" type="text/css" />
  9. <script type="text/javascript" src="{#helper\globals::getJs("jquery.min")#}"></script>
  10. <script type="text/javascript" src="{#helper\globals::getJs("jquery.idTabs.min")#}"></script>
  11. <script type="text/javascript" src="{#helper\globals::getJs("select-ui.min")#}"></script>
  12. <script type="text/javascript" src="{#helper\globals::getJs("jquery.bgiframe.min")#}"></script>
  13. <script type="text/javascript" src="{#helper\globals::getJs("jquery.multiSelect")#}"></script>
  14. <script type="text/javascript" src="{#helper\globals::getJs("notify-custom.min")#}"></script>
  15. <script type="text/javascript" src="{#helper\globals::getJs("tips")#}"></script>
  16. <script type="text/javascript">
  17. $(document).ready(function(){
  18. $(".multi").multiSelect({selectAllText: '选择所有', noneSelected: '请选择', oneOrMoreSelected:'共选择%项'}, function(el){
  19. });
  20. $("#creatorForm").submit( function()
  21. {
  22. $.post($(this).attr('action'), $(this).serialize(), function(r)
  23. {
  24. if(typeof r.code != 'undefined' && r.code == 0)
  25. {
  26. $.notify("保存成功", "success");
  27. }
  28. else
  29. {
  30. $.notify("保存失败", "error");
  31. }
  32. }, 'json');
  33. return false;
  34. });
  35. });
  36. </script>
  37. </head>
  38. <body>
  39. {#if $loadDatabase#}
  40. <div class="place">
  41. <span>位置:</span>
  42. <ul class="placeul">
  43. <li><a href="{#$pathes.index#}">首页</a></li>
  44. <li><a href="{#$pathes.creator#}?database={#$database#}&tableName={#$tableName#}">规则管理</a></li>
  45. <li>规则管理</li>
  46. </ul>
  47. </div>
  48. {#/if#}
  49. <div class="rightinfo">
  50. {#if $loadDatabase#}
  51. <div class="tools">
  52. <select id="database" name="database" onchange="if(this.value != ''){window.location.href = '{#helper\globals::getFullUrl("database/rules")#}?database='+ $('#database').val()}">
  53. <option value="">请选择数据库</option>
  54. {#foreach key=key item=item from=$databases#}
  55. <option value="{#$item#}" {#if $database == $item#}selected{#/if#}>{#$item#}</option>
  56. {#/foreach#}
  57. </select>
  58. <select name="tableName" onchange="if(this.value != ''){window.location.href = '{#helper\globals::getFullUrl("database/rules")#}?tableName='+ this.value +'&database='+ $('#database').val() }">
  59. <option value="">请选择数据表</option>
  60. {#foreach key=key item=item from=$tables#}
  61. <option value="{#$item#}" {#if $tableName == $item#}selected{#/if#}>{#$item#}</option>
  62. {#/foreach#}
  63. </select>
  64. {#if $tables|count > 0#}
  65. <a href="{#$pathes.table#}?database={#$database#}&tableName={#$tableName#}">数据管理</a>
  66. {#/if#}
  67. </div>
  68. {#/if#}
  69. {#if $fields#}
  70. <form name="creatorForm" id="creatorForm" action="{#helper\globals::getFullUrl("api/database/rules", ".json")#}?isAjax=1" method="POST">
  71. {#helper\globals::safeForm()#}
  72. <input type="hidden" name="tableName" value="{#$tableName#}" />
  73. <input type="hidden" name="database" value="{#$database#}" />
  74. <ul class="forminfo">
  75. {#foreach key=key item=item from=$validateRules#}
  76. <li>
  77. <label>{#if isset($rules['alias'][$key])#}{#$rules['alias'][$key]#}{#/if#}</label>
  78. {#assign var=item value=$item#}
  79. {#foreach key=k item=it from=$item#}
  80. {#helper\globals::rules($it, $key, $validate, $invalidMessage, $extRules)#}
  81. {#/foreach#}
  82. </li>
  83. {#foreachelse#}
  84. <li><a href="{#$pathes.creator#}?database={#$database#}&tableName={#$tableName#}" class="red bold">请先添加规则,再设置详细规则,点击添加。</a></li>
  85. {#/foreach#}
  86. <li><label>&nbsp;</label><input name="submit" type="submit" class="btn" value="确认保存"/> <input type="button" name="download" value="下载规则" class="btn" /></li>
  87. </ul>
  88. {#/if#}
  89. </form>
  90. </div>
  91. <script type="text/javascript">
  92. $('.tablelist tbody tr:odd').addClass('odd');
  93. $('input[name="download"]').on('click', function(){
  94. var database = '{#$database#}';
  95. var tableName = '{#$tableName#}';
  96. var url = '{#helper\globals::getFullUrl("api/database/downloadConfig", ".json")#}?database='+ database + '&tableName='+ tableName;
  97. window.location.href = url;
  98. });
  99. </script>
  100. </body>
  101. </html>