Commit 5788ed0a4b2d16f4d5ddfca67a339f204b65f687

Authored by yangfei
1 parent a2758e4e67
Exists in master

内容管理模块

Showing 10 changed files with 276 additions and 180 deletions

parent/base.common/src/main/java/com/lyms/base/common/dao/content/ContentArticlesMapper.xml View file @ 5788ed0
... ... @@ -12,6 +12,7 @@
12 12 <result column="TITLE" property="title" />
13 13 <result column="INTRODUCTION" property="introduction" />
14 14 <result column="CONTENT" property="content" />
  15 + <result column="CONTENT_TYPE" property="contentType" />
15 16 <result column="LINK" property="link" />
16 17 <result column="STATUS" property="status" />
17 18 <result column="REASON" property="reason" />
... ... @@ -30,7 +31,7 @@
30 31  
31 32 <!-- 通用查询结果列 -->
32 33 <sql id="Base_Column_List">
33   - ID AS id, CATEGORY_ID AS categoryId, TYPE AS type, WEIGHT AS weight, IMAGE AS image, TITLE AS title, INTRODUCTION AS introduction, CONTENT AS content, LINK AS link, STATUS AS status, REASON AS reason, AUDITOR_TIME AS auditorTime, AUDITOR_ID AS auditorId, AUDITOR_NAME AS auditorName, CREATE_TIME AS createTime, CREATE_ID AS createId, CREATE_NAME AS createName, MODIFY_ID AS modifyId, MODIFY_NAME AS modifyName, MODIFY_TIME AS modifyTime, IFDEL AS ifdel, ENABLE AS enable
  34 + ID AS id, CATEGORY_ID AS categoryId, TYPE AS type, WEIGHT AS weight, IMAGE AS image, TITLE AS title, INTRODUCTION AS introduction, CONTENT AS content,CONTENT_TYPE as contentType LINK AS link, STATUS AS status, REASON AS reason, AUDITOR_TIME AS auditorTime, AUDITOR_ID AS auditorId, AUDITOR_NAME AS auditorName, CREATE_TIME AS createTime, CREATE_ID AS createId, CREATE_NAME AS createName, MODIFY_ID AS modifyId, MODIFY_NAME AS modifyName, MODIFY_TIME AS modifyTime, IFDEL AS ifdel, ENABLE AS enable
34 35 </sql>
35 36 </mapper>
parent/base.common/src/main/java/com/lyms/base/common/dao/content/ContentMessageTemplateMapper.xml View file @ 5788ed0
... ... @@ -7,7 +7,7 @@
7 7 <id column="ID" property="id" />
8 8 <result column="CONTENT" property="content" />
9 9 <result column="TEMPLATE_VERSION_ID" property="templateVersionId" />
10   - <result column="RICH_TEXT" property="richTitle" />
  10 + <result column="IS_RICH" property="isRich" />
11 11 <result column="RICH_TEXT" property="richText" />
12 12 <result column="KEY_CODE" property="keyCode" />
13 13 <result column="CREATE_TIME" property="createTime" />
... ... @@ -22,7 +22,7 @@
22 22  
23 23 <!-- 通用查询结果列 -->
24 24 <sql id="Base_Column_List">
25   - ID AS id,TEMPLATE_VERSION_ID AS templateVersionId, CONTENT AS content, RICH_TEXT AS richTitle, RICH_TEXT AS richText, KEY_CODE AS keyCode, CREATE_TIME AS createTime, CREATE_ID AS createId, CREATE_NAME AS createName, MODIFY_ID AS modifyId, MODIFY_NAME AS modifyName, MODIFY_TIME AS modifyTime, IFDEL AS ifdel, ENABLE AS enable
  25 + ID AS id,TEMPLATE_VERSION_ID AS templateVersionId, CONTENT AS content,IS_RICH AS isRich, RICH_TEXT AS richTitle, RICH_TEXT AS richText, KEY_CODE AS keyCode, CREATE_TIME AS createTime, CREATE_ID AS createId, CREATE_NAME AS createName, MODIFY_ID AS modifyId, MODIFY_NAME AS modifyName, MODIFY_TIME AS modifyTime, IFDEL AS ifdel, ENABLE AS enable
26 26 </sql>
27 27  
28 28  
parent/base.common/src/main/java/com/lyms/base/common/entity/content/ContentArticles.java View file @ 5788ed0
... ... @@ -34,7 +34,7 @@
34 34 * 分类:1:孕期,2:育儿,3:其它
35 35 */
36 36 @TableField(value="TYPE")
37   - private String type;
  37 + private int type;
38 38 /**
39 39 * 排序
40 40 */
... ... @@ -56,6 +56,11 @@
56 56 @TableField(value="INTRODUCTION")
57 57 private String introduction;
58 58 /**
  59 + * 内容类型 1:普通内容,2:专题内容
  60 + */
  61 + @TableField(value="CONTENT")
  62 + private int contentType;
  63 + /**
59 64 * 正文
60 65 */
61 66 @TableField(value="CONTENT")
62 67  
... ... @@ -148,11 +153,19 @@
148 153 this.categoryId = categoryId;
149 154 }
150 155  
151   - public String getType() {
  156 + public int getType() {
152 157 return type;
153 158 }
154 159  
155   - public void setType(String type) {
  160 + public int getContentType() {
  161 + return contentType;
  162 + }
  163 +
  164 + public void setContentType(int contentType) {
  165 + this.contentType = contentType;
  166 + }
  167 +
  168 + public void setType(int type) {
156 169 this.type = type;
157 170 }
158 171  
parent/base.common/src/main/java/com/lyms/base/common/entity/content/ContentMessageTemplate.java View file @ 5788ed0
... ... @@ -36,6 +36,10 @@
36 36 @TableField(value="CONTENT")
37 37 private String content;
38 38 /**
  39 + * 是否图文
  40 + */
  41 + private String isRich;
  42 + /**
39 43 * 富文本标题
40 44 */
41 45 @TableField(value="RICH_TITLE")
... ... @@ -137,6 +141,14 @@
137 141  
138 142 public void setKeyCode(String keyCode) {
139 143 this.keyCode = keyCode;
  144 + }
  145 +
  146 + public String getIsRich() {
  147 + return isRich;
  148 + }
  149 +
  150 + public void setIsRich(String isRich) {
  151 + this.isRich = isRich;
140 152 }
141 153  
142 154 public Date getCreateTime() {
parent/base.common/src/main/java/com/lyms/base/common/service/content/ContentArticlesService.java View file @ 5788ed0
... ... @@ -21,6 +21,7 @@
21 21 * <li>@return 大于0修改成功,否则为失败
22 22 */
23 23 public Integer deleteLogicById(Serializable id);
24   -
  24 +
  25 + public boolean create(ContentArticles conArti);
25 26 }
parent/base.common/src/main/java/com/lyms/base/common/service/content/impl/ContentArticlesServiceImpl.java View file @ 5788ed0
... ... @@ -5,8 +5,10 @@
5 5 import com.lyms.base.common.entity.content.ContentArticles;
6 6 import com.lyms.base.common.service.content.ContentArticlesService;
7 7 import org.springframework.stereotype.Service;
  8 +import org.springframework.transaction.annotation.Transactional;
8 9  
9 10 import java.io.Serializable;
  11 +import java.util.Date;
10 12  
11 13 /**
12 14 * <p>
... ... @@ -21,6 +23,16 @@
21 23  
22 24 public Integer deleteLogicById(Serializable id){
23 25 return baseMapper.deleteLogicById(id);
  26 + }
  27 +
  28 + @Transactional
  29 + @Override
  30 + public boolean create(ContentArticles conArti) {
  31 + if (conArti == null)
  32 + return false;
  33 + conArti.setCreateTime(new Date());
  34 + Integer tag = baseMapper.insert(conArti);
  35 + return tag != null && tag > 0;
24 36 }
25 37 }
parent/center.manager/src/main/java/com/lyms/cm/controller/content/ContentArticlesController.java View file @ 5788ed0
1 1 package com.lyms.cm.controller.content;
2 2  
  3 +import com.lyms.base.common.entity.content.ContentArticles;
  4 +import com.lyms.base.common.service.content.ContentArticlesService;
  5 +import com.lyms.base.common.vo.content.ContentArticlesVO;
  6 +import com.lyms.constants.OperationName;
  7 +import com.lyms.util.StrUtils;
  8 +import com.lyms.web.bean.AjaxResult;
3 9 import com.lyms.web.controller.BaseController;
  10 +import org.springframework.beans.factory.annotation.Autowired;
4 11 import org.springframework.stereotype.Controller;
5 12 import org.springframework.web.bind.annotation.RequestMapping;
6 13 import org.springframework.web.bind.annotation.RequestMethod;
  14 +import org.springframework.web.bind.annotation.ResponseBody;
7 15  
8 16 /**
9 17 * <p>
... ... @@ -16,7 +24,9 @@
16 24 @Controller
17 25 @RequestMapping("/contentArticles")
18 26 public class ContentArticlesController extends BaseController {
19   -
  27 + @Autowired
  28 + private ContentArticlesService contentArticlesService;
  29 +
20 30 /**
21 31 * 跳转到新增页面
22 32 *
... ... @@ -35,6 +45,30 @@
35 45 @RequestMapping(value = "/toList", method = { RequestMethod.GET })
36 46 public String toList() {
37 47 return "/articles/articles_list";
  48 + }
  49 +
  50 + @ResponseBody
  51 + @RequestMapping(value = "/create", method = { RequestMethod.POST })
  52 + public AjaxResult create(ContentArticlesVO cav, AjaxResult ajaxResult) {
  53 + ContentArticles conArti = new ContentArticles();
  54 +
  55 + conArti.setId(StrUtils.uuid());
  56 + conArti.setCategoryId(cav.getCategoryId());
  57 + conArti.setType(cav.getType());
  58 + conArti.setWeight(cav.getWeight());
  59 + conArti.setImage(cav.getImage());
  60 + conArti.setTitle(cav.getTitle());
  61 + conArti.setIntroduction(cav.getIntroduction());
  62 + conArti.setContentType(cav.getContentType());
  63 + conArti.setContent(cav.getContent());
  64 + conArti.setLink(cav.getLink());
  65 +
  66 + for (String tags:cav.getTags()){
  67 +
  68 +
  69 + }
  70 + boolean tag = contentArticlesService.create(conArti);
  71 + return handleAjaxResult(ajaxResult, true, OperationName.CREATE);
38 72 }
39 73  
40 74 }
parent/center.manager/src/main/webapp/WEB-INF/views/articles/articles_edit.html View file @ 5788ed0
... ... @@ -3,12 +3,17 @@
3 3 #select6 {
4 4 width: 100%;
5 5 height: 36px;
  6 +
6 7 }
7   -</style>
8 8  
  9 +/*
  10 +.tagsClass{
  11 + width: 100%;
  12 + height: 36px;
  13 + min-height:36px;
  14 +}*/
9 15  
10   -
11   -
  16 +</style>
12 17 <div class="ibox float-e-margins">
13 18 <div class="ibox-content">
14 19 <div class="col-sm-12">
... ... @@ -17,7 +22,7 @@
17 22 <div class="form-group">
18 23 <label class="col-sm-2 control-label">*栏目:</label>
19 24 <div class="col-sm-5">
20   - <select class="form-control" id="columnList">
  25 + <select class="form-control" required="" name="categoryId" id="columnList">
21 26  
22 27 </select>
23 28 </div>
... ... @@ -26,8 +31,8 @@
26 31 <div class="form-group">
27 32 <label class="col-sm-2 control-label">*分类:</label>
28 33 <div class="col-sm-5">
29   - <select class="form-control">
30   - <option value="">请选择</option>
  34 + <select class="form-control" required="" name="type">
  35 + <option value>请选择</option>
31 36 <option value="1">孕期</option>
32 37 <option value="2">育儿</option>
33 38 <option value="3">其它</option>
34 39  
35 40  
... ... @@ -38,17 +43,15 @@
38 43 <div class="form-group">
39 44 <label class="col-sm-2 control-label">权重:</label>
40 45 <div class="col-sm-5">
41   - <input type="text" class="form-control" class="form-control"
42   - placeholder="选填" name="">
  46 + <input type="number" class="form-control" class="form-control" placeholder="选填" name="weight">
43 47 </div>
44 48 </div>
  49 +
45 50 <div class="hr-line-dashed"></div>
46 51 <div class="form-group">
47   - <label class="col-sm-2 control-label">*标签:</label>
48   - <div class="col-sm-5">
49   - <select id="select6" name="contentTagIds" multiple
50   - data-selectator-keep-open="true">
51   - </select>
  52 + <label class="col-sm-2 control-label">*标签:</label><button type="button" onclick="addTags()" class="glyphicon glyphicon-plus btn glyphicon btn-primary btn-sm"></button>
  53 + <div class="col-sm-5" id="seleArrs">
  54 +
52 55 </div>
53 56 </div>
54 57 <div class="hr-line-dashed"></div>
... ... @@ -63,6 +66,7 @@
63 66 onclick="switchContent(2)"> <i class="fa text-active"
64 67 id="specialCon"></i> 专题内容
65 68 </label>
  69 + <input type="hidden" value="1" name="contentType" id="contentType">
66 70 </div>
67 71 <div class="col-sm-12 no-padder" id="container">
68 72 <div data-multiple="false"
69 73  
70 74  
... ... @@ -83,17 +87,16 @@
83 87 class="form-control w-lg" required="" aria-required="true">
84 88 </div>
85 89 </div>
86   - <div class="form-group" id="linkContent">
  90 + <div class="form-group" id="linkContent" style="display:none">
87 91 <label class="col-sm-2 control-label">*链接:</label>
88 92 <div class="col-sm-5">
89   - <input type="text" type="url" name="link"
90   - class="form-control w-lg" aria-required="true">
  93 + <input type="text" type="url" name="link" id="linkAddr" class="form-control w-lg">
91 94 </div>
92 95 </div>
93 96 <div class="form-group" id="zaiyaoContent">
94 97 <label class="col-sm-2 control-label">*摘要:</label>
95 98 <div class="col-sm-5">
96   - <input type="text" maxlength="255" name="introduction" class="form-control w-lg">
  99 + <input type="text" maxlength="255" required="" id="introdu" name="introduction" class="form-control w-lg">
97 100 </div>
98 101 </div>
99 102  
... ... @@ -131,7 +134,32 @@
131 134 <script type="text/javascript" src="${ctx}/static/js/plugins/qiniu/qiniu.min.js"></script>
132 135  
133 136 <script type="text/javascript">
134   -
  137 + var seleNum = 1;
  138 + var optionHtml = "";
  139 + function addTags(){
  140 +
  141 + var seleHtml = "<select id='select"+seleNum+"' style='width: 100%;height: 36px;' multiple data-selectator-keep-open='true'>"+optionHtml+"</select>";
  142 +
  143 + $("#seleArrs").append(seleHtml);
  144 +
  145 + $('#select'+seleNum).selectator({
  146 + prefix : 'selectator_', // CSS class prefix
  147 + height : '36', // auto or element
  148 + useDimmer : false, // dims the screen when option list is visible
  149 + useSearch : true, // if false, the search boxes are removed and
  150 + keepOpen : true, // if true, then the dropdown will not close when
  151 + showAllOptionsOnFocus : true, // shows all options if input box is empty
  152 + selectFirstOptionOnSearch : true, // selects the topmost option on every search
  153 + searchCallback : function(value) {
  154 + },
  155 + labels : {
  156 + search : 'Search...' // Placeholder text in search box in single select box
  157 + }
  158 + });
  159 + //ID累计
  160 + seleNum++;
  161 + }
  162 +
135 163 function switchContent(num) {
136 164 if (num == 1) {//普通内容
137 165 $("#commonCon").addClass("fa-check");
138 166  
139 167  
140 168  
141 169  
... ... @@ -140,15 +168,24 @@
140 168 $("#zaiyaoContent").show();
141 169 $("#zhengwenConent").show();
142 170 $("#linkContent").hide();
  171 +
  172 + $("#contentType").val(1);
143 173  
  174 + //链接不是必须的
  175 + $("#linkAddr").removeAttr("required");
  176 + $("#introdu").attr("required","");
144 177  
145   - } else {
  178 + } else {//专题内容
146 179 $("#commonCon").removeClass("fa-check");
147 180 $("#specialCon").addClass("fa-check");
148   -
149 181 $("#zaiyaoContent").hide();
150 182 $("#zhengwenConent").hide();
151 183 $("#linkContent").show();
  184 + //摘要不是必须
  185 + $("#introdu").removeAttr("required");
  186 + $("#linkAddr").attr("required","");
  187 + $("#contentType").val(2);
  188 +
152 189 }
153 190 }
154 191  
... ... @@ -157,8 +194,6 @@
157 194 runtimes: 'html5,flash,html4', //上传模式,依次退化
158 195 browse_button: 'pickfiles', //上传选择的点选按钮,**必需**
159 196 uptoken_url: "${ctx}/ueditor/uploadGetToken", //Ajax请求upToken的Url,**强烈建议设置**(服务端提供)
160   - //uptoken:"hZgfmtYjqtz1UC96gy4uatu5FmyvtoPULkUB9QgA:J51SWS11RoS_0JhE_4LaU_YAWj4=:eyJzY29wZSI6Im1vbW15YmFieSIsImRlYWRsaW5lIjoxNDkzMDA2ODY3fQ==",
161   - // uptoken : '<Your upload token>', //若未指定uptoken_url,则必须指定 uptoken ,uptoken由其他程序生成
162 197 unique_names: true, // 默认 false,key为文件名。若开启该选项,SDK为自动生成上传成功后的key(文件名)。
163 198 // save_key: true, // 默认 false。若在服务端生成uptoken的上传策略中指定了 `sava_key`,则开启,SDK会忽略对key的处理
164 199 domain: 'http://img1.healthbaby.com.cn/', //bucket 域名,下载资源时用到,**必需**
165 200  
166 201  
167 202  
168 203  
... ... @@ -171,68 +206,19 @@
171 206 chunk_size: '4mb', //分块上传时,每片的体积
172 207 auto_start: true, //选择文件后自动上传,若关闭需要自己绑定事件触发上传
173 208 init: {
174   - 'FilesAdded': function(up, files) {
175   - plupload.each(files, function(file) {
176   - // var progress = new FileProgress(file, 'fsUploadProgress');
177   - // progress.setStatus("等待...");
178   - // progress.bindUploadCancel(up);
179   - });
180   - },
181   - 'BeforeUpload': function(up, file) {
182   - // var progress = new FileProgress(file, 'fsUploadProgress');
183   - // var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
184   - // if (up.runtime === 'html5' && chunk_size) {
185   - // progress.setChunkProgess(chunk_size);
186   - // }
187   - },
188   - 'UploadProgress': function(up, file) {
189   - // var progress = new FileProgress(file, 'fsUploadProgress');
190   - // var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
191   - // progress.setProgress(file.percent + "%", file.speed, chunk_size);
192   - },
193 209 'FileUploaded': function(up, file, info) {
194   - // 每个文件上传成功后,处理相关的事情
195   - // 其中 info 是文件上传成功后,服务端返回的json,形式如
196   - // {
197   - // "hash": "Fh8xVqod2MQ1mocfI4S4KpRL6D98",
198   - // "key": "gogopher.jpg"
199   - // }
200   - // 参考http://developer.qiniu.com/docs/v6/api/overview/up/response/simple-response.html
201   -
202   - //var progress = new FileProgress(err.file, 'fsUploadProgress');
203   - // progress.setError();
204   - // progress.setStatus(errTip);
205   -
206 210 var domain = up.getOption('domain');
207   -
208 211 var res = JSON.parse(info);
209 212 var sourceLink = domain + res.key; //获取上传成功后的文件的Url+
210 213  
211 214 $("#pickImage").attr("src",sourceLink);
212   - },
213   - 'Error': function(up, err, errTip) {
214   - //上传出错时,处理相关的事情
215   - },
216   - 'UploadComplete': function() {
217   - //队列文件处理完毕后,处理相关的事情
218   - },
219   - 'Key': function(up, file) {
220   - var key = "";
221   - return key
222 215 }
223 216 }
224 217 });
225 218  
226 219 }
227 220  
228   - $(function() {
229   - //初始化图片上传插件
230   - initUpload();
231   - //初始化
232   - var ue = UE.getEditor('editor', {
233   - initialFrameHeight : 200,
234   - initialFrameWidth : "100%"
235   - });
  221 + function initCloumnData(){
236 222 $.getJSON("${ctx}/contentCategories/selelist", function(data) {
237 223 if (data.success) {
238 224 var columnList = "<option value=''>请选择</option>";
239 225  
240 226  
241 227  
242 228  
243 229  
... ... @@ -243,37 +229,33 @@
243 229 $("#columnList").append(columnList);
244 230 }
245 231 });
  232 + }
246 233  
  234 + function initTagsData(){
247 235 $.get("${ctx}/contentTags/seleList", "json", function(data) {
248 236 if (data.success) {
249   - var seleHtml = "";
250 237 data.data.forEach(function(d, i) {
251   - seleHtml += '<option value="'+d.id+'">' + d.tagName + '</option>';
  238 + optionHtml += '<option value="'+d.id+'">' + d.tagName + '</option>';
252 239 });
253   -
254   - $("#select6").empty();
255   - $("#select6").append(seleHtml);
256   -
257   - $('#select6').selectator({
258   - prefix : 'selectator_', // CSS class prefix
259   - height : 'auto', // auto or element
260   - useDimmer : false, // dims the screen when option list is visible
261   - useSearch : true, // if false, the search boxes are removed and
262   - // `showAllOptionsOnFocus` is forced to true
263   - keepOpen : true, // if true, then the dropdown will not close when
264   - // selecting options, but stay open until losing focus
265   - showAllOptionsOnFocus : true, // shows all options if input box is empty
266   - selectFirstOptionOnSearch : true, // selects the topmost option on every search
267   - searchCallback : function(value) {
268   - }, // Callback function when enter is pressed and
269   - // no option is active in multi select box
270   - labels : {
271   - search : 'Search...' // Placeholder text in search box in single select box
272   - }
273   - });
274   -
  240 + //默认一个选择标签
  241 + addTags();
275 242 }
276 243 });
  244 + }
  245 +
  246 + $(function() {
  247 + //初始化图片上传插件
  248 + initUpload();
  249 + //初始化栏目数据
  250 + initCloumnData();
  251 + //初始化标签数据
  252 + initTagsData();
  253 +
  254 + //初始化
  255 + var ue = UE.getEditor('editor', {
  256 + initialFrameHeight : 200,
  257 + initialFrameWidth : "100%"
  258 + });
277 259 });
278 260  
279 261 function save() {
... ... @@ -283,9 +265,18 @@
283 265 var pickImgSrc = $("#pickImage").attr("src");
284 266 var content = UE.getEditor('editor').getContent();
285 267 data+="&content="+content;
286   - data+="&image="+pickImgSrc;
287   - //data+"&"
288   - //ajaxPost(APP.PATH + "/contentMessageTemplate/create", data);
  268 +
  269 + if(pickImgSrc.indexOf("p0.jpg")==-1){
  270 + data+="&image="+pickImgSrc;
  271 + }
  272 +
  273 + for(var i=1;i<seleNum;i++){
  274 + data+="&contentTagIds="+$("#select"+i).val();
  275 + }
  276 +
  277 + alert(data);
  278 +
  279 + ajaxPost(APP.PATH + "/contentArticles/create", data);
289 280 //parent.reloadGrid('dataTable');
290 281 }
291 282 }
parent/center.manager/src/main/webapp/WEB-INF/views/content/template_edit.html View file @ 5788ed0
1 1 #override("css")
2 2 #end
3 3 #override("body")
4   -<style>
5   - #select6 {
6   - width: 100%;
7   - height: 36px;
8   - }
9   -</style>
10   -<script type="text/javascript" charset="utf-8" src="${ctx}/static/js/plugins/uediter/ueditor.config.js"></script>
11   -<script type="text/javascript" charset="utf-8" src="${ctx}/static/js/plugins/uediter/ueditor.all.min.js"> </script>
12   -<script type="text/javascript" charset="utf-8" src="${ctx}/static/js/plugins/uediter/lang/zh-cn/zh-cn.js"></script>
  4 +
  5 +
13 6 <div class="ibox float-e-margins">
14 7 <div class="ibox-content">
15   - <div class="col-sm-9">
  8 + <div class="col-sm-12">
16 9 <form id="validForm" class="form-horizontal m-t" novalidate="novalidate">
17 10 <input id="resource" name="roles" type="hidden" value="$!userRoles"/>
18 11 <input type="hidden" id="user.id" name="id" value="$!user.id"/>
19 12 <div class="form-group">
20   - <label class="col-sm-5 control-label">短信内容:</label>
21   - <div class="col-sm-7">
  13 + <label class="col-sm-2 control-label">短信内容:</label>
  14 + <div class="col-sm-5">
22 15 <textarea class="form-control" rows="4" cols="12" aria-required="true" name="content" required="true" placeholder="请输入短信内容"></textarea>
23 16 </div>
24 17 </div>
25 18 <div class="form-group">
26   - <label class="col-sm-5 control-label">标签:</label>
27   - <div class="col-sm-7">
28   - <select id="select6" name="contentTagIds" multiple data-selectator-keep-open="true">
29   -
30   - </select>
31   - </div>
  19 + <label class="col-sm-2 control-label">标签:</label><button type="button" onclick="addSeleTags()" class="glyphicon glyphicon-plus btn glyphicon btn-primary btn-sm"></button>
  20 + <div class="col-sm-5" id="seleTagArrs">
  21 + </div>
32 22 </div>
  23 +
33 24 <div class="form-group">
34   - <label class="col-sm-5 control-label">图文指导:</label>
35   - <div class="col-sm-7">
  25 + <label class="col-sm-2 control-label">图文指导:</label>
  26 + <div class="col-sm-5">
36 27 <label class="checkbox-inline i-checks">
37 28 <div class="icheckbox_square-green" style="position: relative;">
38   - <input type="checkbox" class="i-checks" name="enable" id="multChe" style="position: absolute; opacity: 0;" >
  29 + <input type="checkbox" class="i-checks" id="multChe" style="position: absolute; opacity: 0;" >
39 30 </div>
40 31 </label>
41 32 </div>
42 33 <div class="form-group">
43   - <label class="col-sm-5 control-label"></label>
44   - <div class="col-sm-7">
  34 + <label class="col-sm-2 control-label"></label>
  35 + <div class="col-sm-5">
45 36 <input type="hidden" class="i-checks" value="$!verId" name="templateVersionId">
46 37 </div>
47 38 </div>
48 39 <div class="form-group hidden" id="imageTitle">
49   - <label class="col-sm-5 control-label"></label>
50   - <div class="col-sm-7">
  40 + <label class="col-sm-2 control-label">标题:</label>
  41 + <div class="col-sm-5">
51 42 <input type="text" name="richTitle" class="form-control" placeholder="请输入图文指导标题">
52 43 </div>
53 44 </div>
54 45 <div class="form-group hidden" id="imageContext">
55   - <label class="col-sm-5 control-label"></label>
56   - <div class="col-sm-7">
  46 + <label class="col-sm-2 control-label">正文:</label>
  47 + <div class="col-sm-5">
57 48 <script id="editor" name="richText" type="text/plain"></script>
58 49 </div>
59 50 </div>
60 51  
61 52  
62 53  
63 54  
64 55  
65 56  
... ... @@ -70,57 +61,83 @@
70 61 </div>
71 62 #end
72 63 #extends("/common/base_list.html")
  64 +<script type="text/javascript" charset="utf-8" src="${ctx}/static/js/plugins/ueditor/ueditor.config.js"></script>
  65 +<script type="text/javascript" charset="utf-8" src="${ctx}/static/js/plugins/ueditor/ueditor.all.min.js"></script>
  66 +<script type="text/javascript" charset="utf-8" src="${ctx}/static/js/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
73 67 <script type="text/javascript">
  68 + var seleTagNum = 1;
  69 + var optionTagHtml = "";
  70 +
  71 + function addSeleTags(){
  72 +
  73 + var seleHtml = "<select id='select"+seleTagNum+"' style='width: 100%;height: 36px;' multiple data-selectator-keep-open='true'>"+optionTagHtml+"</select>";
  74 +
  75 + $("#seleTagArrs").append(seleHtml);
  76 +
  77 + $('#select'+seleTagNum).selectator({
  78 + prefix : 'selectator_', // CSS class prefix
  79 + height : '36', // auto or element
  80 + useDimmer : false, // dims the screen when option list is visible
  81 + useSearch : true, // if false, the search boxes are removed and
  82 + keepOpen : true, // if true, then the dropdown will not close when
  83 + showAllOptionsOnFocus : true, // shows all options if input box is empty
  84 + selectFirstOptionOnSearch : true, // selects the topmost option on every search
  85 + searchCallback : function(value) {
  86 + },
  87 + labels : {
  88 + search : 'Search...' // Placeholder text in search box in single select box
  89 + }
  90 + });
  91 + //ID累计
  92 + seleTagNum++;
  93 + }
  94 +
  95 + function initTagsData(){
  96 + $.get("${ctx}/contentTags/seleList", "json", function(data) {
  97 + if (data.success) {
  98 + data.data.forEach(function(d, i) {
  99 + optionTagHtml += '<option value="'+d.id+'">' + d.tagName + '</option>';
  100 + });
  101 + //默认一个选择标签
  102 + addSeleTags();
  103 + }
  104 + });
  105 + }
  106 +
74 107 $('#multChe').on('ifClicked', function (event) {
75 108 $("#imageTitle").toggleClass("hidden");
76 109 $("#imageContext").toggleClass("hidden");
77 110 $("#imageTitle").toggleClass("show");
78 111 $("#imageContext").toggleClass("show");
  112 + //初始化富文本
  113 + var ue = UE.getEditor('editor',{initialFrameHeight:200,initialFrameWidth:"100%" });
79 114 });
80 115  
81   -
82 116 $(function(){
83   - //初始化
84   - var ue = UE.getEditor('editor',{initialFrameHeight:200,initialFrameWidth:"100%" });
85 117  
86   - $.get("${ctx}/contentTags/seleList","json",function(data){
87   - if(data.success){
88   - var seleHtml = "";
89   - data.data.forEach(function(d,i){
90   - seleHtml+='<option value="'+d.id+'">'+d.tagName+'</option>';
91   - });
92   -
93   - $("#select6").empty(seleHtml);
94   - $("#select6").append(seleHtml);
95   -
96   - $('#select6').selectator({
97   - prefix: 'selectator_', // CSS class prefix
98   - height: 'auto', // auto or element
99   - useDimmer: false, // dims the screen when option list is visible
100   - useSearch: true, // if false, the search boxes are removed and
101   - // `showAllOptionsOnFocus` is forced to true
102   - keepOpen: true, // if true, then the dropdown will not close when
103   - // selecting options, but stay open until losing focus
104   - showAllOptionsOnFocus: true, // shows all options if input box is empty
105   - selectFirstOptionOnSearch: true, // selects the topmost option on every search
106   - searchCallback: function(value){}, // Callback function when enter is pressed and
107   - // no option is active in multi select box
108   - labels: {
109   - search: 'Search...' // Placeholder text in search box in single select box
110   - }
111   - });
112   -
113   - }
114   - });
  118 + setTimeout(function(){
  119 + initTagsData();
  120 + },500);
  121 +
115 122 });
116 123  
117 124 function save(){
118 125 var content = UE.getEditor('editor').getContent();
119 126 if($('#validForm').valid()){
120 127 var data = $('#validForm').serialize();
121   - //data+"&"
122   - ajaxPost(APP.PATH + "/contentMessageTemplate/create",data);
123   - parent.reloadGrid('dataTable');
  128 + for(var i=1;i<seleTagNum;i++){
  129 + data+="&contentTagIds="+$("#select"+i).val();
  130 + }
  131 + if($("#multChe:checked").val() == "on"){
  132 + data+="&isRich=1";
  133 + }else{
  134 + data+="&isRich=0";
  135 + }
  136 +
  137 +
  138 + alert(data);
  139 + //ajaxPost(APP.PATH + "/contentMessageTemplate/create",data);
  140 + //parent.reloadGrid('dataTable');
124 141 }
125 142 }
126 143 </script>
parent/center.manager/src/main/webapp/WEB-INF/views/content/template_list.html View file @ 5788ed0
... ... @@ -22,7 +22,7 @@
22 22 <div class="panel panel-default">
23 23 <div class="panel-body">
24 24 <label>版本:</label><label id="version">加载中</label><label style="margin-left: 80px;"><!-- 当前状态:</label><label id="status">未更改</label> -->
25   - <input type="text" value="" id="verId">
  25 + <input type="hidden" value="" id="verId">
26 26 </div>
27 27 </div>
28 28  
... ... @@ -37,10 +37,8 @@
37 37 </div>
38 38 <div class="form-group">
39 39 <label>标签:</label>
40   - <select class="form-control m-b" name="type" id="searchType" style="margin-bottom: 0;">
41   - <option value="">所有</option>
42   - <option value="1">孕20周</option>
43   - <option value="0">孕30周</option>
  40 + <select class="form-control m-b" id="searchTags" style="margin-bottom: 0;">
  41 +
44 42 </select>
45 43 </div>
46 44  
47 45  
48 46  
49 47  
... ... @@ -76,20 +74,34 @@
76 74 function addVer(){
77 75 layer.open({
78 76 type: 1 //Page层类型
79   - ,area: ['500px', '300px']
  77 + ,area: ['530px', '300px']
80 78 ,title: '新增消息模板版本'
81 79 ,shade: 0.6 //遮罩透明度
82 80 ,maxmin: true //允许全屏最小化
83 81 ,anim: 2 //0-6的动画形式,-1不开启
84   - ,content: " <form class='navbar-form navbar-left'><div class='form-group'><label class='col-sm-5 control-label'>信息版本名称:</label><div class='col-sm-3'><input type='text' placeholder='版本名称' id='verName' aria-required='true' required='true'></div></div><button type='submit' onclick='return saveVersion()' class='btn btn-default navbar-btn'>提交</button></form>"
  82 + ,content: "<div class='col-sm-9 col-sm-offset-1'><form class='form-horizontal m-t navbar-form navbar-left' id='validForm'><div class='form-group'><label class='col-sm-4 control-label'>版本名称:</label><div class='col-sm-5'><input type='text' class='form-control w-lg' placeholder='版本名称' id='verName' aria-required='true' required></div></div><div class='col-sm-offset-12'><button type='submit' onclick='return saveVersion()' class='btn btn-primary navbar-btn'>提交</button></div></form></div>"
85 83 });
86 84 }
  85 +
  86 + function initTagsData(){
  87 + $.get("${ctx}/contentTags/seleList", "json", function(data) {
  88 + if (data.success) {
  89 + var optionTagHtml = "";
  90 + data.data.forEach(function(d, i) {
  91 + optionTagHtml += '<option value="'+d.id+'">' + d.tagName + '</option>';
  92 + });
  93 + $("#searchTags").append(optionTagHtml);
  94 + }
  95 + });
  96 + }
87 97  
88 98 function saveVersion(){
89   - var verName = $("#verName").val();
90   - console.log(verName);
91   - ajaxPost(APP.PATH +'/contentTemplateVersion/create',"versionName="+verName);
92   - return false;
  99 + if($('#validForm').valid()){
  100 + var verName = $("#verName").val();
  101 + ajaxPost(APP.PATH +'/contentTemplateVersion/create',"versionName="+verName);
  102 + }else{
  103 + return false;
  104 + }
93 105 }
94 106 function add() {
95 107 var verId = $("#verId").val();
... ... @@ -118,6 +130,9 @@
118 130 }
119 131  
120 132 $(function(){
  133 + initTagsData();
  134 +
  135 + //获取消息模板版本列表
121 136 $.ajax({
122 137 url: "${ctx}/contentTemplateVersion/list",
123 138 cache: false,