creator.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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="{#_link("static/css/style.css")#}" rel="stylesheet" type="text/css" />
  7. <link href="{#_link("static/css/select.css")#}" rel="stylesheet" type="text/css" />
  8. <link href="{#_link("static/css/jquery.multiSelect.css")#}" rel="stylesheet" type="text/css" />
  9. <script type="text/javascript" src="{#_link("static/js/jquery.min.js")#}"></script>
  10. <script type="text/javascript" src="{#_link("static/js/jquery.idTabs.min.js")#}"></script>
  11. <script type="text/javascript" src="{#_link("static/js/select-ui.min.js")#}"></script>
  12. <script type="text/javascript" src="{#_link("static/js/jquery.bgiframe.min.js")#}"></script>
  13. <script type="text/javascript" src="{#_link("static/js/jquery.multiSelect.js")#}"></script>
  14. <script type="text/javascript" src="{#_link("static/js/tips.js")#}"></script>
  15. <script type="text/javascript" src="{#_link("static/js/notify-custom.min.js")#}"></script>
  16. <script type="text/javascript">
  17. $(document).ready(function(){
  18. $(".multi").multiSelect({selectAllText: '选择所有', noneSelected: '请选择', oneOrMoreSelected:'共选择%项'});
  19. $("#creatorForm").submit( function()
  20. {
  21. $.post($(this).attr('action'), $(this).serialize(), function(r)
  22. {
  23. if(typeof r.code != 'undefined' && r.code == 0)
  24. {
  25. $.notify("保存成功", "success");
  26. }
  27. else
  28. {
  29. $.notify("保存失败", "error");
  30. }
  31. }, 'json');
  32. return false;
  33. });
  34. $('input[name="download"]').on('click', function(){
  35. var database = $('input[name="database"]').val();
  36. var tableName = $('input[name="tableName"]').val();
  37. var url = '{#_link("api/database/downloadConfig.json")#}?database='+ database + '&tableName='+ tableName;
  38. window.location.href = url;
  39. });
  40. $('input[name="creatBasicCode"]').on('click', function(){
  41. var database = $('input[name="database"]').val();
  42. var tableName = $('input[name="tableName"]').val();
  43. var url = '{#_link("api/database/creatBasicCode.json")#}?database='+ database + '&tableName='+ tableName;
  44. window.location.href = url;
  45. });
  46. });
  47. </script>
  48. </head>
  49. <body>
  50. {#if $loadDatabase#}
  51. <div class="place">
  52. <span>位置:</span>
  53. <ul class="placeul">
  54. <li><a href="{#$pathes.index#}">首页</a></li>
  55. <li><a href="{#$pathes.creator#}?database={#$database#}&tableName={#$tableName#}">规则管理</a></li>
  56. <li>规则生成器</a></li>
  57. </ul>
  58. </div>
  59. {#/if#}
  60. <div class="rightinfo">
  61. {#if $loadDatabase#}
  62. <div class="tools">
  63. <select id="database" name="database" onchange="if(this.value != ''){window.location.href = '{#_link("database/creator")#}?database='+ $('#database').val()}">
  64. <option value="">请选择数据库</option>
  65. {#foreach key=key item=item from=$databases#}
  66. <option value="{#$item#}" {#if $database == $item#}selected{#/if#}>{#$item#}</option>
  67. {#/foreach#}
  68. </select>
  69. <select name="tableName" onchange="if(this.value != ''){window.location.href = '{#_link("database/creator")#}?tableName='+ this.value +'&database='+ $('#database').val() }">
  70. <option>请选择数据表</option>
  71. {#foreach key=key item=item from=$tables#}
  72. <option value="{#$item#}" {#if $tableName == $item#}selected{#/if#}>{#$item#}</option>
  73. {#/foreach#}
  74. </select>
  75. {#if $tables|count > 0#}
  76. <a href="{#_link("database/table")#}?database={#$database#}&tableName={#$tableName#}">数据管理</a>
  77. {#/if#}
  78. </div>
  79. {#/if#}
  80. {#if $fields#}
  81. <form name="creatorForm" id="creatorForm" action="{#_link("api/database/creator.json")#}?isAjax=1" method="POST">
  82. <input type="hidden" name="tableName" value="{#$tableName#}" />
  83. <input type="hidden" name="database" value="{#$database#}" />
  84. <table class="tablelist">
  85. <thead>
  86. <tr>
  87. <th>字段名</th>
  88. <th>显示名</th>
  89. <th><input type="checkbox" name="selectFrontAll">前端使用</th>
  90. <th><input type="checkbox" name="selectEndAll">后端使用</th>
  91. <th>默认值</th>
  92. <th>验证类型</th>
  93. <th><input type="checkbox" name="selectSaveAll">保存验证</th>
  94. <th><input type="checkbox" name="selectSaveAllValid">保存查询字段</th>
  95. <th><input type="checkbox" name="selectUpdateAll">更新验证</th>
  96. <th><input type="checkbox" name="selectUpdateAllValid">更新查询字段</th>
  97. <th><input type="checkbox" name="selectRemoveAll">删除验证</th>
  98. <th><input type="checkbox" name="selectRemoveAllValid">删除查询字段</th>
  99. </tr>
  100. </thead>
  101. <tbody>
  102. {#foreach item=item key=key from=$fields#}
  103. <input type="hidden" name="{#$tableName#}[length][{#$key#}]" value="{#$item.length#}" />
  104. <input type="hidden" name="{#$tableName#}[type][{#$key#}]" value="{#$item.type#}" />
  105. <input type="hidden" name="{#$tableName#}[fields][]" value="{#$key#}" />
  106. {#if isset($item.pri)#}<input type="hidden" name="{#$tableName#}[pri][{#$key#}]" value="{#$item.pri#}" />{#/if#}
  107. {#if isset($item.uni)#}<input type="hidden" name="{#$tableName#}[uni][{#$key#}]" value="{#$item.uni#}" />{#/if#}
  108. <tr>
  109. <td>{#$key#}</td>
  110. <td><input type="text" name="{#$tableName#}[alias][{#$key#}]" class="dfinputmin" value="{#if isset($rules['alias'][$key])#}{#$rules['alias'][$key]#}{#/if#}" /></td>
  111. <td><input class="selectFrontFields" type="checkbox" name="{#$tableName#}[front][{#$key#}]" value="1" {#if isset($rules['front'][$key])#} checked="checked"{#/if#} /></td>
  112. <td><input class="selectEndFields" type="checkbox" name="{#$tableName#}[end][{#$key#}]" value="1" {#if isset($rules['end'][$key])#} checked="checked"{#/if#} /></td>
  113. <td><input type="text" name="{#$tableName#}[default][{#$key#}]" class="dfinputmin" value="{#if isset($rules['default'][$key])#}{#$rules['default'][$key]#}{#elseif isset($item.default)#}{#$item.default#}{#/if#}" /></td>
  114. <td>
  115. <select id="{#$tableName#}[validate][{#$key#}]" name="{#$tableName#}[validate][{#$key#}]" class="multi" multiple="multiple" size="1">
  116. <option value=""></option>
  117. {#foreach from=$validate key=k item=v#}
  118. <option value="{#$k#}"{#if isset($validateRules[$key]) && ($k|in_array:$validateRules[$key])#} selected{#/if#}>{#$v#}</option>
  119. {#/foreach#}
  120. </select>
  121. </td>
  122. <td><input class="selectSaveFields" type="checkbox" name="{#$tableName#}[save][{#$key#}]" value="1" {#if isset($rules['save'][$key])#} checked="checked"{#/if#} /></td>
  123. <td><input class="selectSaveFieldsValid" type="checkbox" name="{#$tableName#}[saveValid][{#$key#}]" value="1" {#if isset($rules['saveValid'][$key])#} checked="checked"{#/if#} /></td>
  124. <td><input class="selectUpdateFields" type="checkbox" name="{#$tableName#}[update][{#$key#}]" value="1" {#if isset($rules['update'][$key])#} checked="checked"{#/if#} /></td>
  125. <td><input class="selectUpdateFieldsValid" type="checkbox" name="{#$tableName#}[updateValid][{#$key#}]" value="1" {#if isset($rules['updateValid'][$key])#} checked="checked"{#/if#} /></td>
  126. <td><input class="selectRemoveFields" type="checkbox" name="{#$tableName#}[remove][{#$key#}]" value="1" {#if isset($rules['remove'][$key])#} checked="checked"{#/if#} /></td>
  127. <td><input class="selectRemoveFieldsValid" type="checkbox" name="{#$tableName#}[removeValid][{#$key#}]" value="1" {#if isset($rules['removeValid'][$key])#} checked="checked"{#/if#} /></td>
  128. </tr>
  129. {#/foreach#}
  130. </tbody>
  131. </table>
  132. <div class="pagin">
  133. <div class="message">&nbsp;</div>
  134. <ul class="paginList">
  135. <li><input type="button" name="rulesManager" value="详细规则管理" class="btn" /> <input type="submit" name="submit" value="保存规则" class="btn" /> <input type="button" name="download" value="下载规则" class="btn" /> <input type="button" name="creatBasicCode" value="生成基础代码" class="btn" /></li>
  136. </ul>
  137. </div>
  138. {#/if#}
  139. </form>
  140. </div>
  141. <script type="text/javascript">
  142. $('.tablelist tbody tr:odd').addClass('odd');
  143. $('input[name="rulesManager"]').on('click', function(){
  144. window.location.href = '{#_link("database/rules")#}?database={#$database#}&tableName={#$tableName#}';
  145. });
  146. $('input[name="selectFrontAll"]').on('click', function(){
  147. $('.selectFrontFields').prop('checked', $('input[name="selectFrontAll"]').prop('checked'));
  148. });
  149. $('input[name="selectEndAll"]').on('click', function(){
  150. $('.selectEndFields').prop('checked', $('input[name="selectEndAll"]').prop('checked'));
  151. });
  152. $('input[name="selectSaveAll"]').on('click', function(){
  153. $('.selectSaveFields').prop('checked', $('input[name="selectSaveAll"]').prop('checked'));
  154. });
  155. $('input[name="selectSaveAllValid"]').on('click', function(){
  156. $('.selectSaveFieldsValid').prop('checked', $('input[name="selectSaveAllValid"]').prop('checked'));
  157. });
  158. $('input[name="selectUpdateAll"]').on('click', function(){
  159. $('.selectUpdateFields').prop('checked', $('input[name="selectUpdateAll"]').prop('checked'));
  160. });
  161. $('input[name="selectUpdateAllValid"]').on('click', function(){
  162. $('.selectUpdateFieldsValid').prop('checked', $('input[name="selectUpdateAllValid"]').prop('checked'));
  163. });
  164. $('input[name="selectRemoveAll"]').on('click', function(){
  165. $('.selectRemoveFields').prop('checked', $('input[name="selectRemoveAll"]').prop('checked'));
  166. });
  167. $('input[name="selectRemoveAllValid"]').on('click', function(){
  168. $('.selectRemoveFieldsValid').prop('checked', $('input[name="selectRemoveAllValid"]').prop('checked'));
  169. });
  170. </script>
  171. </body>
  172. </html>