add.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <script type="text/javascript" src="{#_link("static/js/jquery.min.js")#}"></script>
  9. <script type="text/javascript" src="{#_link("static/js/jquery.idTabs.min.js")#}"></script>
  10. <script type="text/javascript" src="{#_link("static/js/select-ui.min.js")#}"></script>
  11. <script type="text/javascript" src="{#_link("static/js/jquery.bgiframe.min.js")#}"></script>
  12. <script type="text/javascript" src="{#_link("static/js/jquery.multiSelect.js")#}"></script>
  13. <script type="text/javascript" src="{#_link("static/js/tips.js")#}"></script>
  14. <script type="text/javascript" src="{#_link("static/js/notify-custom.min.js")#}"></script>
  15. <script type="text/javascript" src="{#_link('static/js/xheditor/xheditor-1.2.2.min.js')#}"></script>
  16. <script type="text/javascript" src="{#_link('static/js/xheditor/xheditor_lang/zh-cn.js')#}"></script>
  17. <script>
  18. $(document).ready(function(){
  19. $("#modifyForm").submit(function()
  20. {
  21. $('input').removeClass('input_error');
  22. $.post($(this).attr('action'), $(this).serialize(), function(r)
  23. {
  24. if(r == null)
  25. {
  26. $.notify("系统错误,请重试", "error");
  27. };
  28. if(typeof r.code != 'undefined' && r.code == 0)
  29. {
  30. $.notify("保存成功", "success");
  31. }
  32. else
  33. {
  34. $.notify((r.error || "保存失败"), "error");
  35. if(r.error && r.error.fields)
  36. {
  37. for(var field in r.error.fields)
  38. {
  39. $('input[name="fields['+field+']"]').addClass('input_error');
  40. }
  41. }
  42. if(r.error && r.error.opt && r.error.opt._save)
  43. {
  44. $.notify(r.error.opt._save, "error");
  45. }
  46. }
  47. }, 'json');
  48. return false;
  49. });
  50. });
  51. </script>
  52. </head>
  53. <body>
  54. <div class="place">
  55. <span>位置:</span>
  56. <ul class="placeul">
  57. <li><a href="{#$pathes.index#}">首页</a></li>
  58. <li><a href="{#_link("database/creator")#}?database={#$database#}&tableName={#$tableName#}">规则管理</a></li>
  59. <li><a href="{#$pathes.table#}?database={#$database#}&tableName={#$tableName#}">数据管理</a></li>
  60. <li>添加数据</li>
  61. </ul>
  62. </div>
  63. <div class="formbody">
  64. <div class="formtitle"><span>基本信息</span></div>
  65. <form name="modifyForm" id="modifyForm" method="POST" action="{#_link("api/database/add.json")#}?isAjax=1">
  66. <input type="hidden" name="database" value="{#$database#}" id="database" />
  67. <input type="hidden" name="tableName" value="{#$tableName#}" id="tableName" />
  68. <ul class="forminfo">
  69. {#foreach key=key item=item from=$fields#}
  70. <li><label>{#if isset($rules['rules']['alias'][$key]) && $rules['rules']['alias'][$key] != ''#}{#$rules['rules']['alias'][$key]#}{#else#}{#$key#}{#/if#}</label>
  71. {#if $rules['rules']['type'][$key] == 'mediumtext' || $rules['rules']['type'][$key] == 'text'#}
  72. <textarea name="fields[{#$key#}]" cols="100" rows="20" class="textinput {#if helper\globals::hasHtmlTag($item)#}xheditor{#/if#}"></textarea>
  73. {#else if $rules['rules']['type'][$key] == 'enum'#}
  74. <div class="vocation">
  75. <select class="select1" name="fields[{#$key#}]" id="fields[{#$key#}]">
  76. {#foreach key=set item=sitem from=$rules['rules']['setsArray'][$key]#}
  77. <option value="{#$sitem#}" {#if $item == $sitem#}selected{#/if#}>{#$sitem#}</option>
  78. {#/foreach#}
  79. </select>
  80. </div>
  81. {#else#}
  82. <input name="fields[{#$key#}]" type="text" class="dfinput" value="" />
  83. {#/if#}
  84. <i>{#if isset($rules['rules']['length'][$key]) && $rules['rules']['length'][$key] > 0 #}最大长度{#$rules['rules']['length'][$key]#}个字符{#else#}{#/if#}</i></li>
  85. {#/foreach#}
  86. <li><label>&nbsp;</label><input name="submit" type="submit" class="btn" value="确认保存"/></li>
  87. </ul>
  88. </form>
  89. </div>
  90. <script>
  91. $('.xheditor').xheditor({skin:'nostyle'});
  92. $(".select1").uedSelect({
  93. width : 345
  94. });
  95. </script>
  96. </body>
  97. </html>