Showing
7 changed files
with
184 additions
and
46 deletions
@@ -23,7 +23,7 @@ public class GrassArticleController { | @@ -23,7 +23,7 @@ public class GrassArticleController { | ||
23 | IGrassArticleService grassArticleService; | 23 | IGrassArticleService grassArticleService; |
24 | 24 | ||
25 | @RequestMapping("/publishArticle") | 25 | @RequestMapping("/publishArticle") |
26 | - public ApiResponse publishArticle( GrassArticleReq req){ | 26 | + public ApiResponse publishArticle(@RequestBody GrassArticleReq req){ |
27 | logger.info("grassArticle publishArticle begin, req is {}", req); | 27 | logger.info("grassArticle publishArticle begin, req is {}", req); |
28 | try { | 28 | try { |
29 | req.setAuthStatus(1); | 29 | req.setAuthStatus(1); |
@@ -41,13 +41,13 @@ public class GrassArticleController { | @@ -41,13 +41,13 @@ public class GrassArticleController { | ||
41 | } | 41 | } |
42 | 42 | ||
43 | @RequestMapping("/articleList") | 43 | @RequestMapping("/articleList") |
44 | - public ApiResponse grassArticleList( GrassArticleReq req){ | 44 | + public ApiResponse grassArticleList(@RequestBody GrassArticleReq req){ |
45 | logger.info("grassArticle grassArticleList begin, req is {}"); | 45 | logger.info("grassArticle grassArticleList begin, req is {}"); |
46 | return new ApiResponse.ApiResponseBuilder().data(grassArticleService.getArticleList(req)).build(); | 46 | return new ApiResponse.ApiResponseBuilder().data(grassArticleService.getArticleList(req)).build(); |
47 | } | 47 | } |
48 | 48 | ||
49 | @RequestMapping("/updateArticle") | 49 | @RequestMapping("/updateArticle") |
50 | - public ApiResponse updateArticle( GrassArticleReq req){ | 50 | + public ApiResponse updateArticle(@RequestBody GrassArticleReq req){ |
51 | logger.info("grassArticle grassArticleList begin, req is {}"); | 51 | logger.info("grassArticle grassArticleList begin, req is {}"); |
52 | try { | 52 | try { |
53 | grassArticleService.updateArticle(req); | 53 | grassArticleService.updateArticle(req); |
@@ -58,13 +58,13 @@ public class GrassArticleController { | @@ -58,13 +58,13 @@ public class GrassArticleController { | ||
58 | } | 58 | } |
59 | 59 | ||
60 | @RequestMapping("/getUserInfo") | 60 | @RequestMapping("/getUserInfo") |
61 | - public ApiResponse getUserInfo( GrassUserManageReq req){ | ||
62 | - logger.info("grassArticle grassArticleList begin, req is {}"); | 61 | + public ApiResponse getUserInfo(@RequestBody GrassUserManageReq req){ |
62 | + logger.info("grassArticle getUserInfo begin, req is {}"); | ||
63 | return new ApiResponse.ApiResponseBuilder().data(grassArticleService.getUserInfo(req.getUid())).build(); | 63 | return new ApiResponse.ApiResponseBuilder().data(grassArticleService.getUserInfo(req.getUid())).build(); |
64 | } | 64 | } |
65 | 65 | ||
66 | @RequestMapping("/saveArticleDraft") | 66 | @RequestMapping("/saveArticleDraft") |
67 | - public ApiResponse saveArticleDraft( GrassArticleReq req){ | 67 | + public ApiResponse saveArticleDraft(@RequestBody GrassArticleReq req){ |
68 | logger.info("grassArticle saveArticleDraft begin, req is {}", req); | 68 | logger.info("grassArticle saveArticleDraft begin, req is {}", req); |
69 | try { | 69 | try { |
70 | req.setAuthStatus(9); | 70 | req.setAuthStatus(9); |
@@ -76,8 +76,20 @@ public class GrassArticleController { | @@ -76,8 +76,20 @@ public class GrassArticleController { | ||
76 | } | 76 | } |
77 | 77 | ||
78 | @RequestMapping("/draftArticleList") | 78 | @RequestMapping("/draftArticleList") |
79 | - public ApiResponse draftArticleList( GrassArticleReq req){ | ||
80 | - logger.info("grassArticle grassArticleList begin, req is {}"); | 79 | + public ApiResponse draftArticleList(@RequestBody GrassArticleReq req){ |
80 | + logger.info("grassArticle draftArticleList begin, req is {}"); | ||
81 | return new ApiResponse.ApiResponseBuilder().data(grassArticleService.draftArticleList(req)).build(); | 81 | return new ApiResponse.ApiResponseBuilder().data(grassArticleService.draftArticleList(req)).build(); |
82 | } | 82 | } |
83 | + | ||
84 | + | ||
85 | + @RequestMapping("/updateArticleDraft") | ||
86 | + public ApiResponse updateArticleDraft(@RequestBody GrassArticleReq req){ | ||
87 | + logger.info("grassArticle updateArticleDraft begin, req is {}", req); | ||
88 | + try { | ||
89 | + grassArticleService.updateArticleDraft(req); | ||
90 | + } catch (PlatformException e) { | ||
91 | + return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build(); | ||
92 | + } | ||
93 | + return new ApiResponse.ApiResponseBuilder().build(); | ||
94 | + } | ||
83 | } | 95 | } |
@@ -24,4 +24,6 @@ public interface IGrassArticleService { | @@ -24,4 +24,6 @@ public interface IGrassArticleService { | ||
24 | 24 | ||
25 | PageResponseVO<ArticleDetailRspBo> draftArticleList(GrassArticleReq req); | 25 | PageResponseVO<ArticleDetailRspBo> draftArticleList(GrassArticleReq req); |
26 | 26 | ||
27 | + void updateArticleDraft(GrassArticleReq req) throws PlatformException; | ||
28 | + | ||
27 | } | 29 | } |
@@ -540,6 +540,114 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | @@ -540,6 +540,114 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | ||
540 | return rsp; | 540 | return rsp; |
541 | } | 541 | } |
542 | 542 | ||
543 | + @Override | ||
544 | + public void updateArticleDraft(GrassArticleReq req) throws PlatformException { | ||
545 | + | ||
546 | + // 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布 | ||
547 | + Integer type = req.getDraftType(); | ||
548 | + | ||
549 | + //修改文章内容 | ||
550 | + Integer articleId = req.getArticleId(); | ||
551 | + if(articleId == null){ | ||
552 | + throw new PlatformException("articleId is null", 402); | ||
553 | + } | ||
554 | + List<Integer> labels = Lists.newArrayList(); | ||
555 | + String[] urls = req.getArticleImages().split(","); | ||
556 | + String[] skns = null; | ||
557 | + if(StringUtils.isNotEmpty(req.getArticleSkns())){ | ||
558 | + skns = req.getArticleSkns().split(","); | ||
559 | + if(skns.length > 5){ | ||
560 | + logger.info("publishArticle , article products more than most publish number"); | ||
561 | + throw new PlatformException("publish products most number is 5 ", 405); | ||
562 | + } | ||
563 | + } | ||
564 | + if(urls.length > 9){ | ||
565 | + logger.info("publishArticle , article images more than most publish number"); | ||
566 | + throw new PlatformException("publish images most number is 9 ", 405); | ||
567 | + } | ||
568 | + if(StringUtils.isNotEmpty(req.getLabelIds())){ | ||
569 | + labels = Arrays.stream(req.getLabelIds().split(",")).map(Integer::valueOf).collect(Collectors.toList()); | ||
570 | + if(labels.size() > 5){ | ||
571 | + logger.info("publishArticle , article labels more than most publish number"); | ||
572 | + throw new PlatformException("publish labels most number is 5 ", 405); | ||
573 | + } | ||
574 | + } | ||
575 | + | ||
576 | + //修改文章主体内容 | ||
577 | + GrassArticle grassArticle = new GrassArticle(); | ||
578 | + grassArticle.setId(articleId); | ||
579 | + grassArticle.setAuthorUid(req.getAuthorUid()); | ||
580 | + grassArticle.setAuthStatus(type==1? 9 :1); | ||
581 | + grassArticle.setAuthTime(type==1?0L : System.currentTimeMillis()); | ||
582 | + grassArticle.setUpdateTime(System.currentTimeMillis()); | ||
583 | + grassArticleDao.updateByPrimaryKeySelective(grassArticle); | ||
584 | + | ||
585 | + //文章内容 | ||
586 | + grassArticleBlockDao.deleteByArticleId(articleId); | ||
587 | + | ||
588 | + //图片内容 | ||
589 | + List<String> reqlist = req.getArticleImages() == null ? Lists.newArrayList() : Lists.newArrayList(req.getArticleImages().split(",")); | ||
590 | + //新增 | ||
591 | + List<GrassArticleBlock> addList = Lists.newArrayList(); | ||
592 | + int contentOrder = 0; | ||
593 | + for (String src : reqlist) { | ||
594 | + GrassArticleBlock content = new GrassArticleBlock(); | ||
595 | + content.setArticleId(articleId); | ||
596 | + content.setContentData(getBlock(BLOCK_IMAGE,src)); | ||
597 | + content.setCreateTime(System.currentTimeMillis()); | ||
598 | + content.setTemplateKey("image"); | ||
599 | + content.setOrderBy(contentOrder); | ||
600 | + contentOrder++; | ||
601 | + addList.add(content); | ||
602 | + } | ||
603 | + //文字内容 | ||
604 | + if(StringUtils.isNotEmpty(req.getContent())){ | ||
605 | + GrassArticleBlock content = new GrassArticleBlock(); | ||
606 | + content.setArticleId(articleId); | ||
607 | + content.setContentData(getBlock(BLOCK_TEXT,req.getContent())); | ||
608 | + content.setCreateTime(System.currentTimeMillis()); | ||
609 | + content.setTemplateKey("text"); | ||
610 | + content.setOrderBy(contentOrder); | ||
611 | + addList.add(content); | ||
612 | + } | ||
613 | + | ||
614 | + if(CollectionUtils.isNotEmpty(addList)){ | ||
615 | + grassArticleBlockDao.insertArticleContents(addList); | ||
616 | + } | ||
617 | + | ||
618 | + //商品 | ||
619 | + grassArticleProductDao.deleteByArticleId(articleId); | ||
620 | + List<String> reqSknlist = StringUtils.isEmpty(req.getArticleSkns()) ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(",")); | ||
621 | + //新增 | ||
622 | + List<GrassArticleProduct> addSknList = Lists.newArrayList(); | ||
623 | + int orderBy = 0; | ||
624 | + for (String skn : reqSknlist) { | ||
625 | + GrassArticleProduct grassArticleSkn = new GrassArticleProduct(); | ||
626 | + grassArticleSkn.setArticleId(articleId); | ||
627 | + grassArticleSkn.setProductSkn(Integer.valueOf(skn)); | ||
628 | + grassArticleSkn.setCreateTime(System.currentTimeMillis()); | ||
629 | + grassArticleSkn.setOrderBy(orderBy); | ||
630 | + grassArticleSkn.setProductSource(req.getSknType()); | ||
631 | + orderBy++; | ||
632 | + addSknList.add(grassArticleSkn); | ||
633 | + } | ||
634 | + if(CollectionUtils.isNotEmpty(addSknList)){ | ||
635 | + grassArticleProductDao.insertArticleSkns(addSknList); | ||
636 | + } | ||
637 | + | ||
638 | + //构建lables 数据 | ||
639 | + grassArticleLabelDao.deleteByArticleId(articleId); | ||
640 | + List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(articleId, labels,grassArticle.getAuthStatus()); | ||
641 | + try{ | ||
642 | + if(CollectionUtils.isNotEmpty(grassArticleLabels)){ | ||
643 | + grassArticleLabelDao.insertArticleLabels(grassArticleLabels); | ||
644 | + } | ||
645 | + }catch (Exception e){ | ||
646 | + logger.warn("publishArticle ,grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e); | ||
647 | + } | ||
648 | + | ||
649 | + } | ||
650 | + | ||
543 | private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){ | 651 | private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){ |
544 | if(CollectionUtils.isEmpty(articleList)){ | 652 | if(CollectionUtils.isEmpty(articleList)){ |
545 | return new ArrayList<>(); | 653 | return new ArrayList<>(); |
@@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
42 | 42 | ||
43 | <input id="endTimeStr" name="endTimeStr" class="easyui-datetimebox" data-options="prompt:'结束时间'"/> | 43 | <input id="endTimeStr" name="endTimeStr" class="easyui-datetimebox" data-options="prompt:'结束时间'"/> |
44 | </input> | 44 | </input> |
45 | - <a id="searchBtn" class="btn-info">筛选</a> | 45 | + <a id="searchBtn1" class="btn-info">筛选</a> |
46 | <!--<a id="addActivityBtn" class="btn-success">新增</a>--> | 46 | <!--<a id="addActivityBtn" class="btn-success">新增</a>--> |
47 | <a id="allBtn" class="btn-info">全部 </a> | 47 | <a id="allBtn" class="btn-info">全部 </a> |
48 | 48 | ||
@@ -102,7 +102,7 @@ | @@ -102,7 +102,7 @@ | ||
102 | 102 | ||
103 | 103 | ||
104 | // 检索按钮 | 104 | // 检索按钮 |
105 | - $("#searchBtn").linkbutton({ | 105 | + $("#searchBtn1").linkbutton({ |
106 | iconCls : "icon-search", | 106 | iconCls : "icon-search", |
107 | onClick : function() { | 107 | onClick : function() { |
108 | debugger; | 108 | debugger; |
@@ -134,7 +134,7 @@ | @@ -134,7 +134,7 @@ | ||
134 | publisher: $("#publisher").textbox("getValue"), | 134 | publisher: $("#publisher").textbox("getValue"), |
135 | articleId: $("#articleId").textbox("getValue"), | 135 | articleId: $("#articleId").textbox("getValue"), |
136 | }, | 136 | }, |
137 | - url: contextPath + "/grassArticle/draftArticleList", | 137 | + url: serverContextPath + "/grassArticle/draftArticleList", |
138 | method: 'POST', | 138 | method: 'POST', |
139 | loadFilter: function (data) { | 139 | loadFilter: function (data) { |
140 | var tmp = defaultLoadFilter(data); | 140 | var tmp = defaultLoadFilter(data); |
@@ -348,7 +348,7 @@ | @@ -348,7 +348,7 @@ | ||
348 | function publishArticle(id) { | 348 | function publishArticle(id) { |
349 | debugger | 349 | debugger |
350 | var operateType = 5; | 350 | var operateType = 5; |
351 | - $.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&operateType="+ operateType, function (data) { | 351 | + $.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&operateType="+ operateType, function (data) { |
352 | if(data.code != 200){ | 352 | if(data.code != 200){ |
353 | alert(data.message); | 353 | alert(data.message); |
354 | }else{ | 354 | }else{ |
@@ -360,7 +360,7 @@ | @@ -360,7 +360,7 @@ | ||
360 | function switchTimer(id, status,publishTime) { | 360 | function switchTimer(id, status,publishTime) { |
361 | debugger | 361 | debugger |
362 | var operateType = status == 1 ? 3 : 4; | 362 | var operateType = status == 1 ? 3 : 4; |
363 | - $.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&publishTime=" + publishTime+ "&operateType="+ operateType, function (data) { | 363 | + $.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&publishTime=" + publishTime+ "&operateType="+ operateType, function (data) { |
364 | if(data.code != 200){ | 364 | if(data.code != 200){ |
365 | alert(data.message); | 365 | alert(data.message); |
366 | }else{ | 366 | }else{ |
@@ -40,6 +40,8 @@ | @@ -40,6 +40,8 @@ | ||
40 | <div region="center" id="labelGroupList" style="margin-left: 20px"> | 40 | <div region="center" id="labelGroupList" style="margin-left: 20px"> |
41 | <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll"> | 41 | <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll"> |
42 | <form name="publishArticleForm" id="publishArticleForm" method="post" > | 42 | <form name="publishArticleForm" id="publishArticleForm" method="post" > |
43 | + <input id="draftType" name="draftType" hidden="hidden"/> | ||
44 | + <input id="draftArticleId" name="articleId" hidden="hidden"/> | ||
43 | <div style="margin-top: 20px;margin-left: 30px"> | 45 | <div style="margin-top: 20px;margin-left: 30px"> |
44 | <table border="0" style="width:100%;margin-top:5px;line-height:30px;" id="tab"> | 46 | <table border="0" style="width:100%;margin-top:5px;line-height:30px;" id="tab"> |
45 | 47 | ||
@@ -102,7 +104,7 @@ | @@ -102,7 +104,7 @@ | ||
102 | </tr> | 104 | </tr> |
103 | <tr style="height: 60px"> | 105 | <tr style="height: 60px"> |
104 | <td id="goodstd"> | 106 | <td id="goodstd"> |
105 | - <div id="good0" style="float: left;margin-left: 30px;width: 150px;"> | 107 | + <div id="good0" style="float: left;margin-left: 30px;width: 300px;"> |
106 | 108 | ||
107 | </div> | 109 | </div> |
108 | </td> | 110 | </td> |
@@ -154,7 +156,7 @@ | @@ -154,7 +156,7 @@ | ||
154 | //发送请求 | 156 | //发送请求 |
155 | $.ajax({ | 157 | $.ajax({ |
156 | type: "POST", | 158 | type: "POST", |
157 | - url: contextPath + "/grassArticle/getUserInfo", //提交到后端的url | 159 | + url: serverContextPath + "/grassArticle/getUserInfo", //提交到后端的url |
158 | dataType: 'json', | 160 | dataType: 'json', |
159 | data:{ | 161 | data:{ |
160 | uid : $(this).textbox("getValue") | 162 | uid : $(this).textbox("getValue") |
@@ -198,7 +200,7 @@ | @@ -198,7 +200,7 @@ | ||
198 | valueField: 'id', | 200 | valueField: 'id', |
199 | textField: 'labelName', | 201 | textField: 'labelName', |
200 | multiple:true, | 202 | multiple:true, |
201 | - url : contextPath + "/grassLabelManage/getAllGrassLabelInfo", | 203 | + url : serverContextPath + "/grassLabelManage/getAllGrassLabelInfo", |
202 | loadFilter: function (data) { | 204 | loadFilter: function (data) { |
203 | return defaultLoadFilter(data); | 205 | return defaultLoadFilter(data); |
204 | }, | 206 | }, |
@@ -253,7 +255,6 @@ | @@ -253,7 +255,6 @@ | ||
253 | removeSingleItemById(product_skn); | 255 | removeSingleItemById(product_skn); |
254 | var skns = ''; | 256 | var skns = ''; |
255 | for (var i = 0; i < checkedItems.length; i++) { | 257 | for (var i = 0; i < checkedItems.length; i++) { |
256 | - buildgood(i,checkedItems[i]); | ||
257 | if( i == checkedItems.length -1){ | 258 | if( i == checkedItems.length -1){ |
258 | skns = skns+ checkedItems[i] | 259 | skns = skns+ checkedItems[i] |
259 | }else{ | 260 | }else{ |
@@ -270,13 +271,14 @@ | @@ -270,13 +271,14 @@ | ||
270 | width:200, | 271 | width:200, |
271 | onClick: function () { | 272 | onClick: function () { |
272 | $("#publishArticleForm").form("submit",{ | 273 | $("#publishArticleForm").form("submit",{ |
273 | - url : contextPath+"/grassArticle/publishArticle", | 274 | + url : serverContextPath+"/grassArticle/updateArticleDraft", |
274 | onSubmit : function(param) { | 275 | onSubmit : function(param) { |
275 | debugger; | 276 | debugger; |
276 | if (!$("#publishArticleForm").form("validate")) { | 277 | if (!$("#publishArticleForm").form("validate")) { |
277 | return false; | 278 | return false; |
278 | 279 | ||
279 | } | 280 | } |
281 | + $("#draftType").val(2); | ||
280 | var imgs = ''; | 282 | var imgs = ''; |
281 | var imageCount = 0; | 283 | var imageCount = 0; |
282 | $("input[name='url']").each(function(j,item){ | 284 | $("input[name='url']").each(function(j,item){ |
@@ -294,6 +296,10 @@ | @@ -294,6 +296,10 @@ | ||
294 | $.messager.alert("发布失败", "最多只能选择9张图片", "error"); | 296 | $.messager.alert("发布失败", "最多只能选择9张图片", "error"); |
295 | return false; | 297 | return false; |
296 | } | 298 | } |
299 | + if(imageCount < 1){ | ||
300 | + $.messager.alert("发布失败", "请选择至少一张图片", "error"); | ||
301 | + return false; | ||
302 | + } | ||
297 | var labels = ''; | 303 | var labels = ''; |
298 | $("input[name='labelId']").each(function(j,item){ | 304 | $("input[name='labelId']").each(function(j,item){ |
299 | debugger | 305 | debugger |
@@ -332,14 +338,14 @@ | @@ -332,14 +338,14 @@ | ||
332 | width:200, | 338 | width:200, |
333 | onClick: function () { | 339 | onClick: function () { |
334 | $("#publishArticleForm").form("submit",{ | 340 | $("#publishArticleForm").form("submit",{ |
335 | - url : contextPath+"/grassArticle/saveArticleDraft", | 341 | + url : serverContextPath+"/grassArticle/updateArticleDraft", |
336 | onSubmit : function(param) { | 342 | onSubmit : function(param) { |
337 | debugger; | 343 | debugger; |
338 | if (!$("#publishArticleForm").form("validate")) { | 344 | if (!$("#publishArticleForm").form("validate")) { |
339 | return false; | 345 | return false; |
340 | 346 | ||
341 | } | 347 | } |
342 | - | 348 | + $("#draftType").val(1); |
343 | var imgs = ''; | 349 | var imgs = ''; |
344 | var imageCount = 0; | 350 | var imageCount = 0; |
345 | $("input[name='url']").each(function(j,item){ | 351 | $("input[name='url']").each(function(j,item){ |
@@ -357,6 +363,10 @@ | @@ -357,6 +363,10 @@ | ||
357 | $.messager.alert("保存失败", "最多只能选择9张图片", "error"); | 363 | $.messager.alert("保存失败", "最多只能选择9张图片", "error"); |
358 | return false; | 364 | return false; |
359 | } | 365 | } |
366 | + if(imageCount < 1){ | ||
367 | + $.messager.alert("发布失败", "请选择至少一张图片", "error"); | ||
368 | + return false; | ||
369 | + } | ||
360 | var labels = ''; | 370 | var labels = ''; |
361 | $("input[name='labelId']").each(function(j,item){ | 371 | $("input[name='labelId']").each(function(j,item){ |
362 | debugger | 372 | debugger |
@@ -395,7 +405,7 @@ | @@ -395,7 +405,7 @@ | ||
395 | height: 120, | 405 | height: 120, |
396 | realInputName: "url", | 406 | realInputName: "url", |
397 | uploadInputName: "files", | 407 | uploadInputName: "files", |
398 | - url: contextPath + '/fileupload/uploads', | 408 | + url: serverContextPath + '/fileupload/uploads', |
399 | queryParams: { | 409 | queryParams: { |
400 | bucket: "grassImg" | 410 | bucket: "grassImg" |
401 | }, | 411 | }, |
@@ -467,6 +477,7 @@ | @@ -467,6 +477,7 @@ | ||
467 | 477 | ||
468 | 478 | ||
469 | $("#articleUid").textbox("setValue", data.authorUid); | 479 | $("#articleUid").textbox("setValue", data.authorUid); |
480 | + $("#draftArticleId").val(data.articleId); | ||
470 | 481 | ||
471 | //奖品数量不可修改 | 482 | //奖品数量不可修改 |
472 | $("#content").val(data.articleContent); | 483 | $("#content").val(data.articleContent); |
@@ -484,8 +495,10 @@ | @@ -484,8 +495,10 @@ | ||
484 | $("#imageUpload"+j).imageUpload("setValue",data.imgList[j-1]) | 495 | $("#imageUpload"+j).imageUpload("setValue",data.imgList[j-1]) |
485 | } | 496 | } |
486 | 497 | ||
498 | + debugger | ||
487 | if(data.sknList!=null && data.sknList.length>0){ | 499 | if(data.sknList!=null && data.sknList.length>0){ |
488 | initGoods(data.sknList,data.sknType); | 500 | initGoods(data.sknList,data.sknType); |
501 | + $("#sknType").val(data.sknType); | ||
489 | } | 502 | } |
490 | } | 503 | } |
491 | }); | 504 | }); |
@@ -551,7 +564,7 @@ | @@ -551,7 +564,7 @@ | ||
551 | height: 120, | 564 | height: 120, |
552 | realInputName: "url", | 565 | realInputName: "url", |
553 | uploadInputName: "files", | 566 | uploadInputName: "files", |
554 | - url: contextPath + '/fileupload/uploads', | 567 | + url: serverContextPath + '/fileupload/uploads', |
555 | queryParams: { | 568 | queryParams: { |
556 | bucket: "grassImg" | 569 | bucket: "grassImg" |
557 | }, | 570 | }, |
@@ -641,7 +654,7 @@ | @@ -641,7 +654,7 @@ | ||
641 | } | 654 | } |
642 | function gooddiv(data) { | 655 | function gooddiv(data) { |
643 | 656 | ||
644 | - return " <span>商品图:<img width=\"120\" height=\"60\" src="+getImageUrl(data.default_images)+ | 657 | + return " <span>商品图:<img width=\"100\" height=\"60\" src="+getImageUrl(data.default_images)+ |
645 | " /> <a href=\"#\" class=\"goodTag\" data-index=\""+data.product_skn+"\">x</a></span>" + | 658 | " /> <a href=\"#\" class=\"goodTag\" data-index=\""+data.product_skn+"\">x</a></span>" + |
646 | "<h5 style=\"margin-top: 0px;margin-bottom: 0px\">商品名:"+ data.product_name +"</h5>\n" + | 659 | "<h5 style=\"margin-top: 0px;margin-bottom: 0px\">商品名:"+ data.product_name +"</h5>\n" + |
647 | "<h5 style=\"margin-top: 0px;margin-bottom: 0px\">价格:"+data.sales_price+"</h5>" | 660 | "<h5 style=\"margin-top: 0px;margin-bottom: 0px\">价格:"+data.sales_price+"</h5>" |
@@ -734,16 +747,17 @@ | @@ -734,16 +747,17 @@ | ||
734 | 747 | ||
735 | function initGoods(skns,type) { | 748 | function initGoods(skns,type) { |
736 | debugger | 749 | debugger |
737 | - // var url=serverContextPath+"/grassArticle/queryGoods "; | ||
738 | - var url = contextPath+"/search/queryGoods"; | 750 | + var url=serverContextPath+"/grassArticle/queryGoods "; |
751 | + // var url = contextPath+"/search/queryGoods"; | ||
739 | var query =''; | 752 | var query =''; |
740 | var params =''; | 753 | var params =''; |
741 | - for (var i=0;i<skns;i++){ | 754 | + for (var i=0;i<skns.length;i++){ |
742 | if(query==''){ | 755 | if(query==''){ |
743 | query = skns[i]; | 756 | query = skns[i]; |
744 | }else{ | 757 | }else{ |
745 | query = query+","+skns[i]; | 758 | query = query+","+skns[i]; |
746 | } | 759 | } |
760 | + checkedItems.push(skns[i]); | ||
747 | } | 761 | } |
748 | if(type==1){ | 762 | if(type==1){ |
749 | params = "?query="+query+"&status=1&stocknumber=1&attribute_not=2"; | 763 | params = "?query="+query+"&status=1&stocknumber=1&attribute_not=2"; |
@@ -755,21 +769,20 @@ | @@ -755,21 +769,20 @@ | ||
755 | $.post(url+params, function (data) { | 769 | $.post(url+params, function (data) { |
756 | debugger | 770 | debugger |
757 | if(data.code == 200){ | 771 | if(data.code == 200){ |
758 | - for (var i=0; i<data.list.length;i++){ | ||
759 | - var rowdata = data.list[i] | 772 | + for (var i=0; i<data.data.list.length;i++){ |
773 | + var rowdata = data.data.list[i] | ||
760 | checkedItemsObj[rowdata.product_skn] = rowdata; | 774 | checkedItemsObj[rowdata.product_skn] = rowdata; |
761 | - checkedItems.push(rowdata.product_skn); | ||
762 | } | 775 | } |
763 | - var skns = ''; | ||
764 | - for (var i = 0; i < checkedItems.length; i++) { | ||
765 | - buildgood(i,checkedItems[i]); | ||
766 | - if( i == checkedItems.length -1){ | ||
767 | - skns = skns+ checkedItems[i] | 776 | + var skns1 = ''; |
777 | + for (var j = 0; j < checkedItems.length; j++) { | ||
778 | + buildgood(j,checkedItems[j]); | ||
779 | + if( j == checkedItems.length -1){ | ||
780 | + skns1 = skns1+ checkedItems[j] | ||
768 | }else{ | 781 | }else{ |
769 | - skns = skns+ checkedItems[i] +"," | 782 | + skns1 = skns1+ checkedItems[j] +"," |
770 | } | 783 | } |
771 | } | 784 | } |
772 | - $("#skns").val(skns); | 785 | + $("#skns").val(skns1); |
773 | } | 786 | } |
774 | }, "json"); | 787 | }, "json"); |
775 | } | 788 | } |
@@ -195,7 +195,7 @@ | @@ -195,7 +195,7 @@ | ||
195 | //发送请求 | 195 | //发送请求 |
196 | $.ajax({ | 196 | $.ajax({ |
197 | type: "POST", | 197 | type: "POST", |
198 | - url: contextPath + "/grassArticle/getUserInfo", //提交到后端的url | 198 | + url: serverContextPath + "/grassArticle/getUserInfo", //提交到后端的url |
199 | dataType: 'json', | 199 | dataType: 'json', |
200 | data:{ | 200 | data:{ |
201 | uid : $(this).textbox("getValue") | 201 | uid : $(this).textbox("getValue") |
@@ -239,7 +239,7 @@ | @@ -239,7 +239,7 @@ | ||
239 | valueField: 'id', | 239 | valueField: 'id', |
240 | textField: 'labelName', | 240 | textField: 'labelName', |
241 | multiple:true, | 241 | multiple:true, |
242 | - url : contextPath + "/grassLabelManage/getAllGrassLabelInfo", | 242 | + url : serverContextPath + "/grassLabelManage/getAllGrassLabelInfo", |
243 | loadFilter: function (data) { | 243 | loadFilter: function (data) { |
244 | return defaultLoadFilter(data); | 244 | return defaultLoadFilter(data); |
245 | }, | 245 | }, |
@@ -279,7 +279,6 @@ | @@ -279,7 +279,6 @@ | ||
279 | removeSingleItemById(product_skn); | 279 | removeSingleItemById(product_skn); |
280 | var skns = ''; | 280 | var skns = ''; |
281 | for (var i = 0; i < checkedItems.length; i++) { | 281 | for (var i = 0; i < checkedItems.length; i++) { |
282 | - buildgood(i,checkedItems[i]); | ||
283 | if( i == checkedItems.length -1){ | 282 | if( i == checkedItems.length -1){ |
284 | skns = skns+ checkedItems[i] | 283 | skns = skns+ checkedItems[i] |
285 | }else{ | 284 | }else{ |
@@ -296,7 +295,7 @@ | @@ -296,7 +295,7 @@ | ||
296 | width:200, | 295 | width:200, |
297 | onClick: function () { | 296 | onClick: function () { |
298 | $("#publishArticleForm").form("submit",{ | 297 | $("#publishArticleForm").form("submit",{ |
299 | - url : contextPath+"/grassArticle/publishArticle", | 298 | + url : serverContextPath+"/grassArticle/publishArticle", |
300 | onSubmit : function(param) { | 299 | onSubmit : function(param) { |
301 | debugger; | 300 | debugger; |
302 | if (!$("#publishArticleForm").form("validate")) { | 301 | if (!$("#publishArticleForm").form("validate")) { |
@@ -320,6 +319,10 @@ | @@ -320,6 +319,10 @@ | ||
320 | $.messager.alert("发布失败", "最多只能选择9张图片", "error"); | 319 | $.messager.alert("发布失败", "最多只能选择9张图片", "error"); |
321 | return false; | 320 | return false; |
322 | } | 321 | } |
322 | + if(imageCount < 1){ | ||
323 | + $.messager.alert("发布失败", "请选择至少一张图片", "error"); | ||
324 | + return false; | ||
325 | + } | ||
323 | var labels = ''; | 326 | var labels = ''; |
324 | $("input[name='labelId']").each(function(j,item){ | 327 | $("input[name='labelId']").each(function(j,item){ |
325 | debugger | 328 | debugger |
@@ -358,7 +361,7 @@ | @@ -358,7 +361,7 @@ | ||
358 | width:200, | 361 | width:200, |
359 | onClick: function () { | 362 | onClick: function () { |
360 | $("#publishArticleForm").form("submit",{ | 363 | $("#publishArticleForm").form("submit",{ |
361 | - url : contextPath+"/grassArticle/saveArticleDraft", | 364 | + url : serverContextPath+"/grassArticle/saveArticleDraft", |
362 | onSubmit : function(param) { | 365 | onSubmit : function(param) { |
363 | debugger; | 366 | debugger; |
364 | if (!$("#publishArticleForm").form("validate")) { | 367 | if (!$("#publishArticleForm").form("validate")) { |
@@ -421,7 +424,7 @@ | @@ -421,7 +424,7 @@ | ||
421 | height: 120, | 424 | height: 120, |
422 | realInputName: "url", | 425 | realInputName: "url", |
423 | uploadInputName: "files", | 426 | uploadInputName: "files", |
424 | - url: contextPath + '/fileupload/uploads', | 427 | + url: serverContextPath + '/fileupload/uploads', |
425 | queryParams: { | 428 | queryParams: { |
426 | bucket: "grassImg" | 429 | bucket: "grassImg" |
427 | }, | 430 | }, |
@@ -564,7 +567,7 @@ | @@ -564,7 +567,7 @@ | ||
564 | height: 120, | 567 | height: 120, |
565 | realInputName: "url", | 568 | realInputName: "url", |
566 | uploadInputName: "files", | 569 | uploadInputName: "files", |
567 | - url: contextPath + '/fileupload/uploads', | 570 | + url: serverContextPath + '/fileupload/uploads', |
568 | queryParams: { | 571 | queryParams: { |
569 | bucket: "grassImg" | 572 | bucket: "grassImg" |
570 | }, | 573 | }, |
@@ -152,7 +152,7 @@ | @@ -152,7 +152,7 @@ | ||
152 | source: $("#source").textbox("getValue"), | 152 | source: $("#source").textbox("getValue"), |
153 | authStatus: "1" | 153 | authStatus: "1" |
154 | }, | 154 | }, |
155 | - url: contextPath + "/grassArticle/articleList", | 155 | + url: serverContextPath + "/grassArticle/articleList", |
156 | method: 'POST', | 156 | method: 'POST', |
157 | loadFilter: function (data) { | 157 | loadFilter: function (data) { |
158 | var tmp = defaultLoadFilter(data); | 158 | var tmp = defaultLoadFilter(data); |
@@ -401,7 +401,7 @@ | @@ -401,7 +401,7 @@ | ||
401 | function switchRecommend(id, status) { | 401 | function switchRecommend(id, status) { |
402 | debugger | 402 | debugger |
403 | var switchStatus = status == 1 ? 0 : 1; | 403 | var switchStatus = status == 1 ? 0 : 1; |
404 | - $.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&isRecommend=" + switchStatus+ "&operateType=0", function (data) { | 404 | + $.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&isRecommend=" + switchStatus+ "&operateType=0", function (data) { |
405 | if(data.code != 200){ | 405 | if(data.code != 200){ |
406 | alert(data.message); | 406 | alert(data.message); |
407 | }else{ | 407 | }else{ |
@@ -413,7 +413,7 @@ | @@ -413,7 +413,7 @@ | ||
413 | function switchTop(id, status) { | 413 | function switchTop(id, status) { |
414 | debugger | 414 | debugger |
415 | var switchStatus = status == 1 ? 0 : 1; | 415 | var switchStatus = status == 1 ? 0 : 1; |
416 | - $.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&isTop=" + switchStatus+ "&operateType=0", function (data) { | 416 | + $.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&isTop=" + switchStatus+ "&operateType=0", function (data) { |
417 | if(data.code != 200){ | 417 | if(data.code != 200){ |
418 | alert(data.message); | 418 | alert(data.message); |
419 | }else{ | 419 | }else{ |
-
Please register or login to post a comment