infoForm.jsp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <%@ page import="com.thinkgem.jeesite.common.config.Global" %>
  2. <%@ taglib prefix="input" uri="/struts-tags" %>
  3. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  4. <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
  5. <html>
  6. <head>
  7. <title>编辑文章</title>
  8. <meta name="decorator" content="default"/>
  9. <style>
  10. .red{color:red}
  11. #inputForm{max-width:1200px;width:100%}
  12. #inputForm table{width:100%;line-height:18px;margin-bottom:50px}
  13. #inputForm th,#inputForm td{font-weight:normal;text-align:left;padding:8px 5px;border-bottom:1px solid rgb(238,238,238)}
  14. #inputForm th{width:15%;text-align:right;white-space:nowrap;font-weight:bold}
  15. #inputForm td input[type="text"]{width:320px;height:16px;line-height:16px}
  16. .init-label label{margin:5px 10px;color:gray}
  17. </style>
  18. </head>
  19. <body>
  20. <ul class="nav nav-tabs">
  21. <li><a href="${ctx}/info/info/">文章列表</a></li>
  22. <li class="active"><a href="${ctx}/info/info/form?id=${info.id}&ltype=${ltype}">文章<shiro:hasPermission name="info:info:edit">${not empty info.id?'编辑':'添加'}</shiro:hasPermission><shiro:lacksPermission name="info:info:edit">查看</shiro:lacksPermission></a></li>
  23. </ul>
  24. <form:form id="inputForm" modelAttribute="info" action="${ctx}/info/info/save?ltype=${ltype}" method="post" class="form-horizontal">
  25. <form:hidden path="id"/>
  26. <sys:message content="${message}"/>
  27. <table border="0" cellspacing="0" cellpadding="0" width="100%">
  28. <tr>
  29. <th><span class="red">*</span>文章标题:</th>
  30. <td colspan="3">
  31. <form:input path="title" htmlEscape="false" maxlength="100" class="input-xxlarge required"/>
  32. <label id="titleSensitiveWords" class="red"></label>
  33. </td>
  34. </tr>
  35. <tr>
  36. <th><span class="red">*</span>文章标签:</th>
  37. <td colspan="3">
  38. <form:input path="label" htmlEscape="false" maxlength="100" class="input-xxlarge required"/>
  39. <label id="labelSensitiveWords" class="red"></label>
  40. <span class="help-inline">多个标签之间请用逗号分隔开</span>
  41. <div class="init-label"></div>
  42. <input id="labelName" type="text" placeholder="在此处输入标签,将自动关联到文章标签" class="input-xlarge"/>
  43. <a href="javascript:addLeable();">添加</a>
  44. </td>
  45. </tr>
  46. <tr>
  47. <th><span class="red">*</span>SEO关键词:</th>
  48. <td colspan="3" class="auto-input">
  49. <form:input path="keyword" htmlEscape="false" maxlength="50" class="input-xxlarge required"/>
  50. <label id="keywordSensitiveWords" class="red"></label>
  51. </td>
  52. </tr>
  53. <tr>
  54. <th><span class="red">*</span>发布人:</th>
  55. <td colspan="3">
  56. <form:input path="publisher" htmlEscape="false" maxlength="50" class="input-xxlarge required"/>
  57. <label id="publisherSensitiveWords" class="red"></label>
  58. </td>
  59. </tr>
  60. <tr>
  61. <th><span class="red">*</span>来源:</th>
  62. <td colspan="3">
  63. <form:input path="source" htmlEscape="false" maxlength="50" class="input-xlarge"/>
  64. <label id="sourceSensitiveWords" class="red"></label>
  65. </td>
  66. </tr>
  67. <tr>
  68. <th><span class="red">*</span>推荐语(描述):</th>
  69. <td colspan="3">
  70. <form:textarea path="recommendContent" htmlEscape="false" maxlength="1000" class="input-xxlarge required"/>
  71. <label id="recommendContentSensitiveWords" class="red"></label>
  72. </td>
  73. </tr>
  74. <tr>
  75. <th><span class="red">*</span>文章内容:</th>
  76. <td colspan="3">
  77. <div class="detailInfoEditor" style="width:760px;">
  78. <form:textarea path="infoContent" class="input-xlarge hide"/>
  79. <!-- 富文本编辑器 -->
  80. <div id="infoDetailEditor">${info.infoContent}</div>
  81. <label id="infoContentSensitiveWords" class="red"></label>
  82. </div>
  83. </td>
  84. </tr>
  85. <tr>
  86. <th><span class="red">*</span>文章分类:</th>
  87. <td colspan="3">
  88. <form:select path="infoType.id" class="input-small required">
  89. <form:options items="${typeList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
  90. </form:select>
  91. </td>
  92. </tr>
  93. <tr>
  94. <th><span class="red">*</span>引导图:</th>
  95. <td colspan="3">
  96. <form:hidden id="nameImage" path="guidanceImage" htmlEscape="false" class="input-xlarge required"/>
  97. <sys:ckfinder input="nameImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  98. </td>
  99. </tr>
  100. <tr>
  101. <th>商城首页图:</th>
  102. <td colspan="3">
  103. <form:hidden id="homePageImage" path="homePageImage" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  104. <sys:ckfinder input="homePageImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  105. <label style="margin-left: 20px">建议图片分辨率252px*252px</label>
  106. </td>
  107. </tr>
  108. <tr>
  109. <th><span class="red">*</span>发布时间:</th>
  110. <td colspan="3">
  111. <input name="pubdate" type="text" maxlength="20" class="input-medium Wdate required"
  112. value="<fmt:formatDate value="${info.pubdate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  113. onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
  114. </td>
  115. </tr>
  116. <tr>
  117. <th><span class="red">*</span>推荐状态:</th>
  118. <td colspan="3">
  119. <form:radiobuttons path="recommendStatus" items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
  120. </td>
  121. </tr>
  122. <tr>
  123. <th><span class="red">*</span>状态:</th>
  124. <td colspan="3">
  125. <form:radiobutton path="enabledStatus" label="发布" value="1" checked="${empty info.enabledStatus?'checked':''}"/>
  126. <form:radiobutton path="enabledStatus" label="暂不发布" value="0"/>
  127. </td>
  128. </tr>
  129. <tr>
  130. <th><span class="red">*</span>基础点赞:</th>
  131. <td colspan="3">
  132. <form:input path="basePraise" htmlEscape="false" maxlength="11" class="input-xlarge required digits" value="${empty info.basePraise?0:(info.basePraise)}"/>
  133. </td>
  134. </tr>
  135. <c:if test="${not empty info.id}">
  136. <tr>
  137. <th><span class="red">*</span>实际点赞:</th>
  138. <td colspan="3">
  139. ${empty info.realPraise?0:(info.realPraise)}
  140. </td>
  141. </tr>
  142. </c:if>
  143. <tr>
  144. <th><span class="red">*</span>基础浏览量:</th>
  145. <td colspan="3">
  146. <form:input path="basePv" htmlEscape="false" maxlength="11" class="input-xlarge required digits" value="${empty info.basePv?0:(info.basePv)}"/>
  147. </td>
  148. </tr>
  149. <c:if test="${not empty info.id}">
  150. <tr>
  151. <th><span class="red">*</span>实际浏览量:</th>
  152. <td colspan="3">
  153. ${empty info.pv?0:(info.pv)}
  154. </td>
  155. </tr>
  156. </c:if>
  157. <tr>
  158. <td colspan="4" style="text-align:center;">
  159. <shiro:hasPermission name="info:info:edit">
  160. <input id="btnSave" class="btn btn-primary" type="submit" value="提 交" onclick="checkInfo()"/>
  161. </shiro:hasPermission>
  162. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  163. </td>
  164. </tr>
  165. </table>
  166. </form:form>
  167. <!-- 富文本编辑器 -->
  168. <% request.setAttribute("caimeiCore", Global.getConfig("caimei.core"));%>
  169. <%--<script src="https://cdn.bootcdn.net/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js"></script>--%>
  170. <script type="text/javascript" src="${ctxStatic}/jquery-validation/1.19.3/jquery.validate.js"></script>
  171. <script type="text/javascript" src="${ctxStatic}/ckeditor5-new/ckeditor.js"></script>
  172. <script type="text/javascript" src="${ctxStatic}/sensitiveWords/mint-filter.umd.js"></script>
  173. <script type="text/javascript" src="${ctxStatic}/auto-input.js"></script>
  174. <script type="text/javascript">
  175. //关键词联动
  176. function autocomplete(text) {
  177. // return ['三全鲜食(北新泾店)', 'Hot honey 首尔炸鸡(仙霞路)', '新旺角茶餐厅', '泷千家(天山西路店)', '胖仙女纸杯蛋糕(上海凌空店)', '贡茶', '豪大大香鸡排超级奶爸', '茶芝兰(奶茶,手抓饼)', '十二泷町', '星移浓缩咖啡', '阿姨奶茶/豪大大', '新麦甜四季甜品炸鸡', 'Monica摩托主题咖啡店', '浮生若茶(凌空soho店)', 'NONO JUICE 鲜榨果汁', 'CoCo都可(北新泾店)', '快乐柠檬(神州智慧店)', 'Merci Paul cafe', '猫山王(西郊百联店)', '枪会山', '纵食', '钱记', '壹杯加', '唦哇嘀咖', '爱茜茜里(西郊百联)', '爱茜茜里(近铁广场)', '鲜果榨汁(金沙江路和美广店)', '开心丽果(缤谷店)', '超级鸡车(丰庄路店)', '妙生活果园(北新泾店)', '香宜度麻辣香锅', '凡仔汉堡(老真北路店)', '港式小铺', '蜀香源麻辣香锅(剑河路店)', '北京饺子馆', '饭典*新简餐(凌空SOHO店)', '焦耳·川式快餐(金钟路店)', '动力鸡车', '浏阳蒸菜', '四海游龙(天山西路店)', '樱花食堂(凌空店)', '壹分米客家传统调制米粉(天山店)', '福荣祥烧腊(平溪路店)', '速记黄焖鸡米饭', '红辣椒麻辣烫', '(小杨生煎)西郊百联餐厅', '阳阳麻辣烫', '南拳妈妈龙虾盖浇饭'].filter(function (item) {
  178. // return text && item.indexOf(text) > -1;
  179. // });
  180. var keywordlist=new Array();
  181. <c:forEach items="${SearchFrequencyVo}" var="search">
  182. keywordlist.push("${search.keyword}")
  183. </c:forEach>
  184. return keywordlist.filter(function (item) {
  185. return text && item.indexOf(text) > -1;
  186. });
  187. }
  188. new AutoComplete({
  189. el: '.auto-input',
  190. callback: autocomplete,
  191. offsetLeft: -25
  192. });
  193. $(document).ready(function() {
  194. //$("#name").focus();
  195. $("#inputForm").validate({
  196. ignore:"",
  197. submitHandler: function(form){
  198. var status = $("input[name='enabledStatus']:checked").val();
  199. var title = $("#title").val();
  200. var label = $("#label").val();
  201. var keyword = $("#keyword").val();
  202. var publisher = $("#publisher").val();
  203. var source = $("#source").val();
  204. var pubdate = $("#pubdate").val();
  205. var recommendContent = $("#recommendContent").val();
  206. var infoContent = $("#infoContent").val();
  207. var guidanceImage = $("#guidanceImage").val();
  208. var basePraise = $("#basePraise").val();
  209. var basePv = $("#basePv").val();
  210. if (title == '') {
  211. alertx("请输入文章标题");
  212. return false;
  213. }
  214. if (label == '') {
  215. alertx("请输入文章标签");
  216. return false;
  217. }
  218. if (keyword == '') {
  219. alertx("请输入SEO关键词");
  220. return false;
  221. }
  222. if (publisher == '') {
  223. alertx("请输入发布人");
  224. return false;
  225. }
  226. if (pubdate == '') {
  227. alertx("请输入发布时间");
  228. return false;
  229. }
  230. if (recommendContent == '') {
  231. alertx("请输入推荐语(描述)");
  232. return false;
  233. }
  234. if (infoContent == '') {
  235. alertx("请输入文章内容");
  236. return false;
  237. }
  238. if (guidanceImage == '') {
  239. alertx("请上传引导图");
  240. return false;
  241. }
  242. if (basePraise == '') {
  243. alertx("请输入基础点赞");
  244. return false;
  245. }
  246. if (basePv == '') {
  247. alertx("请输入基础浏览量");
  248. return false;
  249. }
  250. // 检测敏感词
  251. var propertyMap = new Map();
  252. propertyMap.set("title", title);
  253. propertyMap.set("label", label);
  254. propertyMap.set("keyword", keyword);
  255. propertyMap.set("publisher", publisher);
  256. propertyMap.set("source", source);
  257. propertyMap.set("recommendContent", recommendContent);
  258. propertyMap.set("infoContent", infoContent);
  259. var sensitiveWords = '${sensitiveWords}';
  260. const mint = new MintFilter(sensitiveWords.split('|'));
  261. var filterSync = '';
  262. var touchWords = '';
  263. var touchNum = 0;
  264. propertyMap.forEach(function (value,key,map) {
  265. filterSync = mint.filterSync(value);
  266. filterSync.words.forEach(word=>{
  267. touchWords += touchWords === '' ? word : "," + word;
  268. })
  269. if (touchWords !== '') {
  270. // 增加敏感词触发数量
  271. touchNum++;
  272. // 设置敏感词提示
  273. $("#" + key + "SensitiveWords").text("敏感词:" + touchWords);
  274. touchWords = '';
  275. }
  276. });
  277. if (touchNum > 0) {
  278. var msg = 1 == status?"当前发布内容存在敏感词,已为您标记在输入框下方," +
  279. "请修改后,再进行保存发布,强行保存发布将会导致审核不通过!":
  280. "当前内容存在敏感词,已为您标记在输入框下方,建议修改后再进行保存!否则," +
  281. "将会影响发布时审核不通过!";
  282. top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
  283. if (v == 'ok') {
  284. loading('正在提交,请稍等...');
  285. form.submit();
  286. }
  287. }, {buttonsFocus: 1, persistent: true});
  288. } else{
  289. loading('正在提交,请稍等...');
  290. form.submit();
  291. }
  292. },
  293. errorContainer: "#messageBox",
  294. errorPlacement: function(error, element) {
  295. $("#messageBox").text("输入有误,请先更正。");
  296. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  297. error.appendTo(element.parent().parent());
  298. } else {
  299. error.insertAfter(element);
  300. }
  301. }
  302. });
  303. });
  304. //初始化标签
  305. $(function () {
  306. $(".init-label label").bind("click",function(){
  307. var label=$(this).text();
  308. var label1=label+",";
  309. var _label=$("#label").val()+",";
  310. if(_label.indexOf(label1)>-1){
  311. alert("文章标签中已包含该标签!!");
  312. }else{
  313. setLabel(label);
  314. }
  315. });
  316. });
  317. $(window).load(function () {
  318. LabelInit();
  319. });
  320. //富文本框编辑
  321. function checkInfo() {
  322. var infoContent = infoDetailEditor.getData();
  323. $("#infoContent").val(infoContent);
  324. console.log(infoContent);
  325. }
  326. $(document).ready(function () {
  327. //富文本框
  328. ClassicEditor.create(document.querySelector('#infoDetailEditor'), {
  329. ckfinder: {
  330. uploadUrl: '${caimeiCore}/tools/image/upload/ckeditor'
  331. }
  332. }).then(function(editor) {
  333. window.infoDetailEditor = editor;
  334. }).catch(function(error){
  335. console.log(error);
  336. });
  337. });
  338. function LabelInit(){
  339. var items="${fns:getDictValue('label','sys_config','')}"+",";
  340. /* var _labels="${info.label}";
  341. var _label=_labels.split(",");
  342. for (var i = 0; i < _label.length; i++) {
  343. items=items.replace(_label[i]+",","");
  344. } */
  345. /* var items="美白,祛斑,祛痘,补水,瘦脸,去皱,缩毛孔,减肥瘦身,提拉紧致,嫩肤,去眼袋,去法令纹,脱毛,纹眉,去黑眼圈,美白嫩肤,面部提升,祛斑祛痣,除皱,去红血丝,祛疤,祛妊娠纹,纹身,纤体塑性,纹眉"; */
  346. var info=items.split(",");
  347. var html='';
  348. for (var i = 0; i < info.length; i++) {
  349. if(''!=info[i]){
  350. html+="<label>"+info[i]+"</label>";
  351. if((i+1)%9==0){
  352. html+="<br>";
  353. }
  354. }
  355. }
  356. $(".init-label").append(html);
  357. $("#labelName").typeahead({
  358. property : 'name',
  359. source:function(typeahead, query){
  360. query = $.trim(query);
  361. if(''==query){return;}
  362. $.ajax({
  363. type:"POST", dataType:"JSON", async:false,
  364. url: "${ctx}/info/infoLabel/findByName",
  365. data:{name: query},
  366. success:function(data){
  367. typeahead.process(data);
  368. }
  369. });
  370. },
  371. onselect : function(data) {
  372. setLabel(data.name);
  373. $("#labelName").focus(); //选择完后 回到当前输入框以便下一个动作的验证
  374. }
  375. });
  376. }
  377. function setLabel(name){
  378. if(name!=''){
  379. var label=$("#label").val();
  380. if(label==''){
  381. label=name;
  382. }else{
  383. label=label+","+name;
  384. }
  385. $("#label").val(label);
  386. $("#labelName").val("");
  387. }
  388. }
  389. function addLeable(){
  390. var label=$("#labelName").val();
  391. if(''==label){
  392. $.jBox.tip('添加的标签不能为空!','error');
  393. }else{
  394. setLabel(label);
  395. }
  396. }
  397. </script>
  398. </body>
  399. </html>