update.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. {%include '../inc/header.html'%}
  5. </head>
  6. <body>
  7. <div class="x-body">
  8. <form class="layui-form layui-form-pane" action="{% block action %}{% end %}" method="post" autocomplete="off" target="f1">
  9. {% module xsrf_form_html() %}
  10. <input type="hidden" name="function" id="function" value="msg"/>
  11. <input type="hidden" name="url" id="url" value="{% block url %}{% end %}" />
  12. <input type="hidden" name="project" id="project" value="ai" />
  13. <input type="hidden" name="table" id="table" value="col" />
  14. <input type="hidden" name="id" id="id" value="{% if data['info'] and 'id' in data['info'] and data['info']['id'] > 0 %}{{data['info']['id']}}{% end %}" />
  15. <iframe id="f1" name="f1" style="display:none;"></iframe>
  16. {% block form %}
  17. <div class="layui-form-item">
  18. <label for="L_title" class="layui-form-label">
  19. 标题
  20. </label>
  21. <div class="layui-input-block">
  22. <input type="text" id="L_title" name="title" required lay-verify="title"
  23. autocomplete="off" class="layui-input">
  24. </div>
  25. </div>
  26. <div class="layui-form-item layui-form-text">
  27. <div class="layui-input-block">
  28. <textarea id="content" name="content"
  29. placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 260px;"></textarea>
  30. </div>
  31. <label for="L_content" class="layui-form-label" style="top: -2px;">
  32. 描述
  33. </label>
  34. </div>
  35. <div class="layui-form-item">
  36. <div class="layui-inline">
  37. <label class="layui-form-label">
  38. 所在类别
  39. </label>
  40. <div class="layui-input-block">
  41. <select lay-verify="required" name="cid">
  42. <option>
  43. </option>
  44. <optgroup label="Layui相关">
  45. <option value="0">layui</option>
  46. <option value="2">layer弹层</option>
  47. <option value="3">LayIM即时通讯</option>
  48. </optgroup>
  49. <optgroup label="其它交流">
  50. <option value="100">技术闲谈</option>
  51. <option value="101">建议反馈</option>
  52. <option value="168">官方公告</option>
  53. </optgroup>
  54. </select>
  55. </div>
  56. </div>
  57. </div>
  58. {% end %}
  59. <div class="layui-form-item" style="text-align:center">
  60. <button class="layui-btn" lay-filter="update" lay-submit>
  61. 确定
  62. </button>
  63. </div>
  64. </form>
  65. </div>
  66. {%include '../inc/script.html'%}
  67. <script>
  68. layui.use(['laydate', 'form','layer','layedit','upload'], function(){
  69. $ = layui.jquery;
  70. var form = layui.form()
  71. var layer = layui.layer
  72. var layedit = layui.layedit;
  73. if ($('.time').length) {
  74. laydate = layui.laydate;//日期插件
  75. var date = {
  76. //min: laydate.now()
  77. max: '2099-06-16 23:59:59'
  78. ,format: 'YYYY-MM-DD hh:mm:ss'
  79. ,istoday: true
  80. ,istime: true
  81. };
  82. $('.time').each(function()
  83. {
  84. $(this).click(function()
  85. {
  86. date.elem = this;
  87. laydate(date);
  88. })
  89. })
  90. }
  91. var xsrf = getCookie("_xsrf");
  92. var uploadUrl = '/upload?_xsrf='+xsrf;
  93. layedit.set({
  94. uploadImage: {
  95. url: uploadUrl
  96. ,type: 'post'
  97. }
  98. });
  99. layui.upload({
  100. url: uploadUrl
  101. ,success: function(res, input){ //上传成功后的回调
  102. var id = $(input).attr('id').replace('upload_', '');
  103. $('#upload_' + id + '_show').attr('src',res.data.src + '?v' + Date.parse(new Date())).show();
  104. $('#update_' + id).val(res.data.src);
  105. }
  106. });
  107. if ($('.layui-editor').length) {
  108. $('.layui-editor').each(function()
  109. {
  110. id = $(this).attr('id');
  111. var index = layedit.build(id);
  112. layedit.sync(index)
  113. });
  114. }
  115. if ($(".selectLoad").length) {
  116. $(".selectLoad").each(function()
  117. {
  118. if ($(this).attr('lay-filter')) {
  119. var e = $(this);
  120. selectShow(e, e.attr('change'));
  121. form.render();
  122. }
  123. })
  124. }
  125. form.on('select(yes)', function(data){
  126. var e = $(data.elem);
  127. selectShow(e, e.attr('change'));
  128. form.render();
  129. });
  130. form.verify({
  131. select: function(value, item){
  132. if(!value || value == '请选择'){
  133. return '必填项不能为空';
  134. }
  135. }
  136. });
  137. {% block script %}
  138. {% end %}
  139. form.on('submit(update)');
  140. });
  141. </script>
  142. </body>
  143. </html>