update.html 7.0 KB

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