table.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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("ajaxfileupload")#}"></script>
  11. <script type="text/javascript" src="{#helper\globals::getJs("jquery.idTabs.min")#}"></script>
  12. <script type="text/javascript" src="{#helper\globals::getJs("select-ui.min")#}"></script>
  13. <script type="text/javascript" src="{#helper\globals::getJs("jquery.bgiframe.min")#}"></script>
  14. <script type="text/javascript" src="{#helper\globals::getJs("jquery.multiSelect")#}"></script>
  15. <script type="text/javascript" src="{#helper\globals::getJs("notify-custom.min")#}"></script>
  16. <script type="text/javascript" src="{#helper\globals::getJs("tips")#}"></script>
  17. <script type="text/javascript" src="{#helper\globals::getSourceFullUrl("static/layer/layer.js")#}"></script>
  18. </head>
  19. <body>
  20. {#if $loadDatabase#}
  21. <div class="place">
  22. <span>位置:</span>
  23. <ul class="placeul">
  24. <li><a href="{#$pathes.index#}">首页</a></li>
  25. <li><a href="{#helper\globals::getFullUrl("database/creator")#}?database={#$database#}&tableName={#$tableName#}">规则管理</a></li>
  26. <li>数据管理</li>
  27. </ul>
  28. </div>
  29. {#/if#}
  30. <div class="rightinfo">
  31. {#if $loadDatabase#}
  32. <div class="tools">
  33. <select id="database" name="database" onchange="if(this.value != ''){window.location.href = '{#helper\globals::getFullUrl("database/table")#}?database='+ $('#database').val()}">
  34. <option value="">请选择数据库</option>
  35. {#foreach key=key item=item from=$databases#}
  36. <option value="{#$item#}" {#if $database == $item#}selected{#/if#}>{#$item#}</option>
  37. {#/foreach#}
  38. </select>
  39. <select name="tableName" onchange="if(this.value != ''){window.location.href = '{#helper\globals::getFullUrl("database/table")#}?tableName='+ this.value +'&database='+ $('#database').val() }">
  40. <option value="">请选择数据表</option>
  41. {#foreach key=key item=item from=$tables#}
  42. <option value="{#$item#}" {#if $tableName == $item#}selected{#/if#}>{#$item#}</option>
  43. {#/foreach#}
  44. </select>
  45. {#if $tables|count > 0#}
  46. <a href="{#helper\globals::getFullUrl("database/add")#}?database={#$database#}&tableName={#$tableName#}">添加数据</a>
  47. {#/if#}
  48. </div>
  49. {#/if#}
  50. {#if $tableName#}
  51. <table class="tablelist">
  52. <thead>
  53. <tr>
  54. {#foreach key=rkey item=ritem from=$data.rules.end#}
  55. <th>{#if isset($data.rules.alias[$rkey]) && $data.rules.alias[$rkey] != ''#}{#$data.rules.alias[$rkey]#}{#else#}{#$rkey#}{#/if#}</th>
  56. {#/foreach#}
  57. {#if !$data.rules#}
  58. <th><a href="{#helper\globals::getFullUrl("database/creator")#}?database={#$database#}&tableName={#$tableName#}">请先去数据生成器中生成数据</a></th>
  59. {#else#}
  60. <th>操作</th>
  61. {#/if#}
  62. </tr>
  63. </thead>
  64. <tbody>
  65. {#foreach key=key item=item from=$data.rows#}
  66. <tr>
  67. {#foreach key=rkey item=ritem from=$data.rules.end#}
  68. <td>{#if isset($item[$rkey])#}{#$item[$rkey]|strip_tags|trim|htmlspecialchars|truncate:50#}{#else#}&nbsp;{#/if#}</td>
  69. {#/foreach#}
  70. <td><a data-operate="modify" data-src="{#$item['__updateFields']#}">修改</a> <a data-operate="remove" data-src="{#$item['__updateFields']#}">删除</a></td>
  71. </tr>
  72. {#/foreach#}
  73. </tbody>
  74. </table>
  75. {#include file="manage/data/pages.html" pagesData=$pages pagesRef="{#helper\globals::getFullUrl("database/$_action")#}?database={#$database#}&tableName={#$tableName#}"#}
  76. </form>
  77. <div class="pagin">
  78. <div class="message">&nbsp;</div>
  79. <ul class="paginList">
  80. <li>
  81. <input type="file" id="fileUpload" name="restoreSQL" value=""/>
  82. <input type="button" name="restoreTable" value="还原数据" class="btn" />
  83. <input type="button" name="backupTable" value="备份数据" class="btn" />
  84. </li>
  85. </ul>
  86. </div>
  87. {#/if#}
  88. </div>
  89. <script type="text/javascript">
  90. $('.tablelist tbody tr:odd').addClass('odd');
  91. $('[data-operate=modify]').on('click', function(){
  92. var pri = $(this).attr('data-src');
  93. var url = '{#helper\globals::getFullUrl("database/update")#}?' + pri;
  94. window.location.href = url;
  95. });
  96. $('[data-operate=remove]').on('click', function(){
  97. var pri = $(this).attr('data-src');
  98. var url = '{#helper\globals::getFullUrl("api/database/table")#}?operate=remove&database={#$database#}&tableName={#$tableName#}';
  99. layer.confirm("数据一旦删除,将无法恢复,请确认", {
  100. btn: ['确认','取消'] //按钮
  101. }, function(){
  102. $.get(url, pri, function(r){
  103. if(typeof r.code != 'undefined' && r.code == 0){
  104. r.code == 0 ? layer.msg('删除成功') : layer.msg(data.msg);
  105. setTimeout(function(){window.location.href = window.location.href;}, 2000);
  106. }else{
  107. layer.msg("删除失败");
  108. }
  109. }, 'json');
  110. });
  111. });
  112. $('input[name=backupTable]').on('click', function(){
  113. window.location.href = "{#\helper\globals::getFullUrl('api/database/backup')#}?database={#$database#}&tableName={#$tableName#}";
  114. });
  115. $('input[name=restoreTable]').on('click', function(){
  116. var data = {};
  117. data.database = '{#$database#}';
  118. data.tableName = '{#$tableName#}';
  119. $.ajaxFileUpload({
  120. url : '{#\helper\globals::getFullUrl('api/database/restore')#}?random='+ Math.random(),
  121. data : data,
  122. type : 'POST',
  123. secureuri : false,
  124. fileElementId : 'fileUpload',
  125. dataType : 'json',
  126. success : function(msg){
  127. if(msg.code == 0){
  128. $.notify("还原成功", "success");
  129. return;
  130. }
  131. $.notify(msg.msg, "error");
  132. },
  133. error : function(data, status, e){
  134. $.notify("系统错误", "error");
  135. }
  136. });
  137. });
  138. </script>
  139. </body>
  140. </html>