save.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <style>
  2. .ck-editor__editable_inline {
  3. height: 400px !important;
  4. }
  5. </style>
  6. <article class="cl pd-20">
  7. <form action="{:url('save')}" method="post" class="form form-horizontal" id="form-save">
  8. <input type="hidden" name="id" value="{$data['id']}">
  9. <input type="hidden" name="content_type" value="{$data['content_type']}">
  10. <div class="row cl">
  11. <label class="form-label col-xs-4 col-sm-2">
  12. <span class="c-red">*</span>栏目:</label>
  13. <div class="formControls col-xs-8 col-sm-6">
  14. <span class="select-box inline">
  15. <select name="cid" class="select" id="cid">
  16. <option value="">所有栏目</option>
  17. {foreach $category_tree as $value}
  18. <option value="{$value.id}" {eq name='data.cid' value="$value.id" }selected{/eq}>{$value.name}
  19. </option>
  20. {notempty name="value.child"}
  21. {foreach $value.child as $val}
  22. <option value="{$val.id}" {eq name='data.cid' value="$val.id" }selected{/eq}>--{$val.name}
  23. </option>
  24. {notempty name="val.child"}
  25. {foreach $val.child as $vo}
  26. <option value="{$vo.id}" {eq name='data.cid' value="$vo.id" }selected{/eq}>&nbsp;&nbsp;└
  27. --{$vo.name}
  28. </option>
  29. {/foreach}
  30. {/notempty}
  31. {/foreach}
  32. {/notempty}
  33. {/foreach}
  34. </select>
  35. </span>
  36. </div>
  37. <div class="col-3"> </div>
  38. </div>
  39. <div class="row cl">
  40. <label class="form-label col-xs-4 col-sm-2">
  41. <span class="c-red">*</span>标题:</label>
  42. <div class="formControls col-xs-8 col-sm-6">
  43. <input type="text" class="input-text" value="{$data.title}" placeholder="请填写标题" id="title" name="title">
  44. </div>
  45. <div class="col-3"> </div>
  46. </div>
  47. <div class="row cl">
  48. <label class="form-label col-xs-4 col-sm-2">
  49. 作者: </label>
  50. <div class="formControls col-xs-4 col-sm-2">
  51. <input type="text" class="input-text" value="{$data.writer}" placeholder="作者" id="writer" name="writer">
  52. </div>
  53. <label class="form-label col-xs-4 col-sm-2">
  54. 来源:</label>
  55. <div class="formControls col-xs-4 col-sm-2">
  56. <input type="text" class="input-text" value="{$data.source}" placeholder="来源" id="source" name="source">
  57. </div>
  58. <div class="col-3"> </div>
  59. </div>
  60. <div class="row cl">
  61. <div class="col-3"> </div>
  62. </div>
  63. <div class="row cl">
  64. <label class="form-label col-xs-4 col-sm-2">
  65. 标题图:</label>
  66. <div class="formControls col-xs-6 col-sm-4">
  67. <input type="text" class="input-text" value="{$data.titlepic}" name="titlepic" id="titlepic">
  68. <div style="width: 160px;height: 160px;">
  69. <a href="javascript:void(0);" onclick="addTitlePic()">
  70. <img id="view-titlepic"
  71. src="{$data.titlepic ? $data.titlepic : '/static/images/upload_picture.png'}" alt="标题图"
  72. title="{$data.titlepic ? '更换' : '添加'}标题图" style="max-width: 160px;max-height: 160px;">
  73. </a>
  74. </div>
  75. </div>
  76. <label class="form-label col-xs-2 col-sm-2">
  77. <a class="btn btn-success radius" href="javascript:addTitlePic();">{$data.titlepic ? '更换' :
  78. '添加'}标题图</a></label>
  79. <div class="col-3"> </div>
  80. </div>
  81. <div class="row cl">
  82. <label class="form-label col-xs-4 col-sm-2">
  83. 关键词:</label>
  84. <div class="formControls col-xs-8 col-sm-6">
  85. <input type="text" class="input-text" value="{$data.keywords}" placeholder="关键词" id="keywords"
  86. name="keywords">
  87. <span class="c-red">多个关键词用英文','分割</span>
  88. </div>
  89. <div class="col-3"> </div>
  90. </div>
  91. <div class="row cl">
  92. <label class="form-label col-xs-4 col-sm-2">内容简介:</label>
  93. <div class="formControls col-xs-8 col-sm-6">
  94. <textarea name="summary" id="summary" cols="" rows="" class="textarea" placeholder="说点什么...最多输入500个字符"
  95. datatype="*10-100" dragonfly="true" onKeyUp="textarealength(this,500)">{$data.summary}</textarea>
  96. <p class="textarea-numberbar">
  97. <em class="textarea-length">0</em>/500
  98. </p>
  99. </div>
  100. <div class="col-3"> </div>
  101. </div>
  102. <div class="row cl">
  103. <label class="form-label col-xs-4 col-sm-2">文章正文:</label>
  104. </div>
  105. <div class="row cl">
  106. <label class="form-label col-xs-1 col-sm-1"></label>
  107. <div class="formControls col-xs-11 col-sm-10">
  108. <div id="editor">{$data.content|raw}</div>
  109. </div>
  110. </div>
  111. <div class="row cl">
  112. <label class="form-label col-xs-2 col-sm-2">
  113. 点击量:</label>
  114. <div class="formControls col-xs-4 col-sm-2">
  115. <input type="number" class="input-text" value="{$data.hits}" id="hits" name="hits"
  116. style="width: 120px;">
  117. </div>
  118. <label class="form-label col-xs-2 col-sm-2">
  119. 排序:</label>
  120. <div class="formControls col-xs-4 col-sm-2">
  121. <input type="number" class="input-text" value="{$data.sort}" id="sort" name="sort"
  122. style="width: 120px;">
  123. </div>
  124. </div>
  125. <div class="row cl">
  126. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  127. <button type="button" class="btn btn-success radius" id="form-button-save">确&nbsp;定</button>
  128. <button type="button" class="btn btn-default radius" onclick="window.history.back();"
  129. style="margin-left:20px;">取&nbsp;消</button>
  130. </div>
  131. </div>
  132. </form>
  133. </article>
  134. <!--请在下方写此页面业务相关的脚本-->
  135. <script type="text/javascript" src="/static/plugins/jquery.validation/1.14.0/jquery.validate.js"></script>
  136. <script type="text/javascript" src="/static/plugins/jquery.validation/1.14.0/messages_zh.js"></script>
  137. <script type="text/javascript" src="/static/plugins/jquery.validation/1.14.0/validate-methods.js"></script>
  138. <script type="text/javascript" src="/static/plugins/ckeditor/ckeditor5/ckeditor.js"></script>
  139. <script type="text/javascript">
  140. $(function () {
  141. ClassicEditor.create(document.querySelector('#editor'), {
  142. toolbar: {
  143. items: [
  144. 'sourceEditing', '|',
  145. 'bold', 'italic', 'strikethrough', 'underline', 'subscript', 'superscript', '|',
  146. 'heading', '|',
  147. 'fontfamily', 'fontsize', 'fontColor', 'fontBackgroundColor', 'highlight', '|',
  148. 'alignment', 'outdent', 'indent', '|',
  149. 'undo', 'redo',
  150. '-',
  151. 'link', 'imageUpload', 'imageInsert', 'mediaEmbed', 'insertTable', '|',
  152. 'code', 'codeBlock', 'blockQuote', '|',
  153. 'findAndReplace', 'horizontalLine', 'numberedList', 'bulletedList',
  154. ],
  155. shouldNotGroupWhenFull: true
  156. },
  157. licenseKey: '',
  158. //图片上传
  159. simpleUpload: {
  160. // The URL the images are uploaded to.
  161. uploadUrl: '/sys/file_manager/ckeditorUploadImage'
  162. },
  163. //自定义字体
  164. fontFamily: {
  165. options: [
  166. 'default',
  167. '微软雅黑,Microsoft YaHei',
  168. '新宋体,NSimSun',
  169. '楷体_GB2312,KaiTi_GB2312',
  170. '黑体,SimHei',
  171. '隶书,LiSu',
  172. '幼园,YouYuan',
  173. 'Blackoak Std',
  174. 'Arial',
  175. 'Georgia',
  176. 'Tahoma',
  177. 'Trebuchet MS',
  178. 'verdana',
  179. ]
  180. },
  181. }).then(editor => {
  182. window.editor = editor;
  183. }).catch(error => {
  184. console.error('Oops, something went wrong!');
  185. console.error('Please, report the following error on https://github.com/ckeditor/ckeditor5/issues with the build id and the error stack trace:');
  186. console.warn('Build id: z4e2d8lqju9w-6lwv92tbu4hm');
  187. console.error(error);
  188. });
  189. })
  190. function validator(params) {
  191. return $("#form-save").validate({
  192. debug: true,
  193. rules: {
  194. title: {
  195. required: true,
  196. }
  197. , summary: {
  198. maxlength: 500,
  199. }
  200. , sort: {
  201. max: 99
  202. }
  203. , cid: {
  204. required: true
  205. }
  206. },
  207. messages: {
  208. title: {
  209. required: "标题不能为空"
  210. }
  211. , cid: {
  212. required: "栏目不能为空"
  213. }
  214. }
  215. });
  216. }
  217. $("#form-button-save").click(function () {
  218. if (!validator().form()) {
  219. return false
  220. }
  221. const content = window.editor.getData();
  222. $("<input/>").attr("type","hidden").attr("name", "content").val(content).appendTo($("#form-save"));
  223. $("#form-save")[0].submit();
  224. })
  225. //添加标题图
  226. function addTitlePic() {
  227. layer.open({
  228. type: 2,
  229. area: ['700px', '500px'],
  230. fix: false, //不固定
  231. maxmin: true,
  232. shade: 0.4,
  233. title: '添加标题图',
  234. content: '{:url("file_manager/uploadimg", ["_layer"=>true,"img_id"=>"titlepic"])}'
  235. });
  236. }
  237. </script>