Authored by liangyi.chen@yoho.cn

Merge branch 'test6.9.4' into test6.9.5

@@ -225,14 +225,12 @@ public class TblCrawlerInfoServiceImpl implements ITblCrawlerInfoService { @@ -225,14 +225,12 @@ public class TblCrawlerInfoServiceImpl implements ITblCrawlerInfoService {
225 //发布到种草文章表 225 //发布到种草文章表
226 req.setArticleType(ArticleTypeEnum.TBLCRAWLER.getValue()); 226 req.setArticleType(ArticleTypeEnum.TBLCRAWLER.getValue());
227 Integer articleId = grassArticleService.publishArticle(req); 227 Integer articleId = grassArticleService.publishArticle(req);
228 - //维护爬虫数据和种草文章关联关系(草稿箱不用维护)  
229 - if(req.getAuthStatus() != 9){  
230 - TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();  
231 - tblCrawlerArticleRelation.setRelateId(articleId);  
232 - tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.TBLCRAWLER.getValue());  
233 - tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());  
234 - tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());  
235 - } 228 + //维护爬虫数据和种草文章关联关系
  229 + TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();
  230 + tblCrawlerArticleRelation.setRelateId(articleId);
  231 + tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.TBLCRAWLER.getValue());
  232 + tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());
  233 + tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());
236 234
237 } 235 }
238 236
@@ -251,14 +249,12 @@ public class TblCrawlerInfoServiceImpl implements ITblCrawlerInfoService { @@ -251,14 +249,12 @@ public class TblCrawlerInfoServiceImpl implements ITblCrawlerInfoService {
251 //发布到种草文章表 249 //发布到种草文章表
252 req.setArticleType(ArticleTypeEnum.TBLCRAWLER.getValue()); 250 req.setArticleType(ArticleTypeEnum.TBLCRAWLER.getValue());
253 Integer articleId = grassArticleService.timerPublish(req); 251 Integer articleId = grassArticleService.timerPublish(req);
254 - //维护爬虫数据和种草文章关联关系(草稿箱不用维护)  
255 - if(req.getAuthStatus() != 9){  
256 - TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();  
257 - tblCrawlerArticleRelation.setRelateId(articleId);  
258 - tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.TBLCRAWLER.getValue());  
259 - tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());  
260 - tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());  
261 - } 252 + //维护爬虫数据和种草文章关联关系
  253 + TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();
  254 + tblCrawlerArticleRelation.setRelateId(articleId);
  255 + tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.TBLCRAWLER.getValue());
  256 + tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());
  257 + tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());
262 } 258 }
263 259
264 @Override 260 @Override
@@ -482,7 +482,8 @@ @@ -482,7 +482,8 @@
482 iconCls: "icon-save", 482 iconCls: "icon-save",
483 width:200, 483 width:200,
484 onClick: function () { 484 onClick: function () {
485 - window.location.href=contextPath + "/html/grass/tblCrawlerInfoManage/tblCrawlerInfoList.html"; 485 + window.history.back();
  486 + /*=contextPath + "/html/grass/tblCrawlerInfoManage/tblCrawlerInfoList.html"*/
486 } 487 }
487 }); 488 });
488 489
  1 +<!DOCTYPE html>
  2 + <style>
  3 + .btn-long {
  4 + width: 120px;
  5 + height: 37px;
  6 + line-height: 37px;
  7 + font-size: 15px;
  8 + color: white;
  9 + border-radius: 5px;
  10 + display: inline-block;
  11 + cursor: pointer;
  12 + text-align: center;
  13 + }
  14 + .btn-long:hover {
  15 + opacity: 0.9;
  16 + }
  17 +
  18 + .tag{
  19 + display: block;
  20 + float: left;
  21 + padding: 2px 5px;
  22 + background: #1caf9a;
  23 + margin-right: 5px;
  24 + margin-bottom: 5px;
  25 + margin-top: 5px;
  26 + -moz-border-radius: 2px;
  27 + -webkit-border-radius: 2px;
  28 + border-radius: 2px;
  29 + font-size: 13px;
  30 + }
  31 + .goodTag{
  32 + display: block;
  33 + float: right;
  34 + font-size: 18px;
  35 + }
  36 +
  37 + </style>
  38 +<link rel="stylesheet" href="/pfcms/js/emoji/emojionearea.css">
  39 +<script type="text/javascript" src="/pfcms/js/emoji/emojionearea.js"></script>
  40 +
  41 +<div region="center" id="labelGroupList" style="margin-left: 20px">
  42 + <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
  43 + <form name="publishArticleForm" id="publishArticleForm" method="post" >
  44 + <input type="hidden" name="crawlerId" id="crawlerId" />
  45 + <input type="hidden" name="sort" id="sort" />
  46 + <input id="draftType" name="draftType" hidden="hidden"/>
  47 + <input id="draftArticleId" name="articleId" hidden="hidden"/>
  48 + <div style="margin-top: 20px;margin-left: 30px">
  49 + <table border="0" style="width:100%;margin-top:5px;line-height:30px;" id="tab">
  50 +
  51 + <tr style="height: 60px">
  52 + <td >
  53 + <div style="float: left;width:700px;" >
  54 + <span style="color:red">*</span><label style="font-size: 14px;">选择用户</label> <br>
  55 + <input id="articleUid" name="authorUid" style="width:600px; " class="easyui-textbox" />
  56 + <a id="userBotton" class="btn btn-small" style="font-size: 18px; " >确认</a>
  57 +
  58 + <br>
  59 + <span style="color:red"> 必填项,选择某个用户身份后,才能发布</span>
  60 + </div>
  61 + <div id="userInfo" style="float: left;margin-left: 30px;">
  62 + </div>
  63 + </td>
  64 + </tr>
  65 +
  66 + <tr style="height: 60px">
  67 + <td>
  68 + <span style="color:red">*</span><label style="font-size: 14px;">文字内容(必填项,内容不能为空)</label> <br>
  69 + <div style="width:600px; word-wrap:break-word;float: left;position: relative" >
  70 + <textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-500字的笔记" required="" maxlength="500"></textarea>
  71 + <div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/500</div>
  72 +
  73 + </div>
  74 + </td>
  75 + </tr>
  76 +
  77 + <tr style="height: 60px">
  78 + <td>
  79 + <label style="font-size: 14px;">选择标签</label> <br>
  80 + <input id="labelId" name="labelId" class="easyui-combobox" style="width:600px; "/><br>
  81 + <span style="color:red">至多添加5个标签,非必填项</span><label></label>
  82 + <input id="labelIds" name="labelIds" hidden="hidden"/>
  83 + <div id="labelList">
  84 +
  85 + </div>
  86 + </td>
  87 + </tr>
  88 +
  89 + <tr style="height: 60px">
  90 + <td style="width:100%;">
  91 + <label style="font-size: 14px;">选择话题</label> <br>
  92 + <input id="topicGroupId" name="topicGroupId" class="easyui-combobox" style="width:300px; "/>
  93 + <input id="topicId" name="topicId" class="easyui-combobox" style="width:300px; "/><br>
  94 + <span style="color:red">至多添加1个话题,非必填项</span><label></label>
  95 +
  96 + <input id="topicIds" name="topicIds" hidden="hidden"/>
  97 + <div id="topicList">
  98 +
  99 + </div>
  100 + </td>
  101 + </tr>
  102 +
  103 + <tr style="height: 20px">
  104 + <td >
  105 + <span style="color:red">*</span><label style="font-size: 14px;">选择图片(最多九张)</label><br>
  106 + <span style="color:red">1.需要上传1-9张图片,必填项;&nbsp&nbsp&nbsp
  107 + 2.请上传1-9张图片,图片比例1:1、3:4、4:3(宽:高),大小不超过500k</span><label></label><br>
  108 + <!--<a id="addImage" class="btn btn-primary" >选择图片+</a>-->
  109 + <input id="imgs" name="articleImages" hidden="hidden"/>
  110 + </td>
  111 + </tr>
  112 + <tr style="height: 60px">
  113 + <td id="imgTd">
  114 + <div id="imageUpload1">
  115 + </div>
  116 + </td>
  117 + </tr>
  118 + <tr style="height: 60px">
  119 + <td>
  120 + <label style="font-size: 14px;">关联商品</label> <br>
  121 + <span style="color:red">1.支持商品编号(SKN&SKUP)查询商品;&nbsp&nbsp&nbsp
  122 + 2.至多添加10个商品,非必填项</span><label></label><br>
  123 + <a id="addSkn" class="btn btn-primary" style="font-size: 15px">选择商品+</a>
  124 + <span id ="products"></span>
  125 + </td>
  126 +
  127 + </tr>
  128 + <tr style="height: 60px">
  129 + <td id="goodstd">
  130 + <div id="good0" style="float: left;margin-left: 30px;width: 300px;">
  131 +
  132 + </div>
  133 + </td>
  134 + </tr>
  135 + <tr>
  136 + <td valign="bottom">
  137 + <input id="draftBotton" class="btn btn-primary" style="font-size: 18px; height: 36px;" value="保存到草稿箱"/>
  138 + <input id="timerBotton" class="btn btn-primary" style="font-size: 18px; height: 36px;" value="定时发布"/>
  139 + <input id="subBotton" class="btn btn-primary" style="font-size: 18px; margin-left: 30px; height: 36px;" value="立即发布"/>
  140 + <span style="color:red">*运营平台发布的内容,均免审核,直接发布。</span><label></label><br>
  141 + </td>
  142 + </tr>
  143 + </table>
  144 + </div>
  145 + </form>
  146 +
  147 + </div>
  148 +
  149 +</div>
  150 +
  151 +
  152 +
  153 +<script>
  154 + var checkedItems = [];
  155 + var checkedItemsObj = {};
  156 + var searchType = 1;
  157 + var checkType = 1;
  158 + $(function () {
  159 +
  160 + $("#content").emojioneArea({
  161 + // options
  162 + autoHideFilters: true,
  163 + autocomplete : false,
  164 + search :false,
  165 + recentEmojis: false,
  166 + tones: false,
  167 + filters: {
  168 + // see in source file
  169 + animals_nature : true,
  170 + food_drink :true,
  171 + activity: true,
  172 + travel_places :true,
  173 + objects:true,
  174 + symbols: true,
  175 + flags:true
  176 + }
  177 +
  178 + });
  179 +
  180 + $("#addImage").linkbutton({
  181 + iconCls : "icon-search",
  182 + onClick : function() {
  183 +
  184 + }
  185 + });
  186 +
  187 + $("#addSkn").linkbutton({
  188 + iconCls : "icon-search",
  189 + onClick : function() {
  190 + getGoodsDialog();
  191 + }
  192 + });
  193 +
  194 + $("#timerBotton").linkbutton({
  195 + iconCls : "icon-search",
  196 + onClick : function() {
  197 + getTimeDialog();
  198 + }
  199 + });
  200 +
  201 + $("#userBotton").linkbutton({
  202 + iconCls : "icon-search",
  203 + onClick : function() {
  204 + //发送请求
  205 + $.ajax({
  206 + type: "POST",
  207 + url: serverContextPath + "/grassArticle/getUserInfo", //提交到后端的url
  208 + dataType: 'json',
  209 + data:{
  210 + uid : $("#articleUid").textbox("getValue")
  211 + },
  212 + success: function (result) {
  213 + if(result.code == 200) {
  214 + if(result.data !=null && result.data !=''){
  215 + var headIco = result.data.headIco.substring(0, result.data.headIco.indexOf("?"));
  216 + var html = '';
  217 + html += "<span style='font-size: 18px;'>&nbsp&nbsp<img src='"+headIco+"' width='60px;' height='60px;'></span>&nbsp&nbsp&nbsp&nbsp";
  218 + html += "<span style='font-size: 15px;'>&nbsp&nbsp<label>"+result.data.nickName+"</label></span>";
  219 + $("#userInfo").html(html);
  220 + }else{
  221 + var html = '<span style="color:red;font-size: 15px;">获取用户信息失败,请检查uid输入是否正确</span>';
  222 + $("#userInfo").html(html);
  223 + }
  224 + }
  225 + else {
  226 + var html = '<span style="color:red;font-size: 15px;">获取用户信息失败,请稍后重试</span>';
  227 + $("#userInfo").html(html);
  228 + }
  229 +
  230 + }
  231 + });
  232 + }
  233 + });
  234 +
  235 + $("#articleUid").textbox({
  236 + required: true,
  237 + missingMessage: "发布用户不能为空",
  238 + prompt: "请输入发布用户",
  239 + onChange: function () {
  240 + //发送请求
  241 + // $.ajax({
  242 + // type: "POST",
  243 + // url: serverContextPath + "/grassArticle/getUserInfo", //提交到后端的url
  244 + // dataType: 'json',
  245 + // data:{
  246 + // uid : $(this).textbox("getValue")
  247 + // },
  248 + // success: function (result) {
  249 + // if(result.code == 200) {
  250 + // if(result.data !=null && result.data !=''){
  251 + // var headIco = result.data.headIco.substring(0, result.data.headIco.indexOf("?"));
  252 + // var html = '';
  253 + // html += "<span style='font-size: 18px;'>&nbsp&nbsp<img src='"+headIco+"' width='80px;' height='80px;'></span>&nbsp&nbsp&nbsp&nbsp";
  254 + // html += "<span style='font-size: 18px;'>&nbsp&nbsp<label>"+result.data.nickName+"</label></span>";
  255 + // $("#userInfo").html(html);
  256 + // }else{
  257 + // var html = '<span style="color:red;font-size: 18px;">获取用户信息失败,请检查uid输入是否正确</span>';
  258 + // $("#userInfo").html(html);
  259 + // }
  260 + // }
  261 + // else {
  262 + // var html = '<span style="color:red;font-size: 18px;">获取用户信息失败,请稍后重试</span>';
  263 + // $("#userInfo").html(html);
  264 + // }
  265 + //
  266 + // }
  267 + // });
  268 + }
  269 + });
  270 +
  271 + /*字数限制*/
  272 + // $("#content").on("input propertychange", function() {
  273 + // debugger
  274 + // var $this = $(this);
  275 + // var count = $this.val().length;
  276 + // $("#content-count").text(count);
  277 + // });
  278 + /*字数限制*/
  279 + $("#content").emojioneArea()[0].emojioneArea.on("keyup change",function (edite,event) {
  280 + debugger
  281 + var $this = $(this);
  282 + var count = $this[0].getText().length;
  283 + var content = $this[0].getText();
  284 + if(count>500){
  285 + $this[0].setText(content.substring(0,500));
  286 + count = $this[0].getText().length;
  287 + }
  288 + $("#content-count").text(count);
  289 + });
  290 +
  291 + $("#labelId").combobox({
  292 + prompt: "请选择标签",
  293 + required: false,
  294 + selectOnNavigation : true,
  295 + valueField: 'id',
  296 + textField: 'labelName',
  297 + multiple:true,
  298 + url : serverContextPath + "/grassLabelManage/getAllGrassLabelInfo",
  299 + loadFilter: function (data) {
  300 + return defaultLoadFilter(data);
  301 + },
  302 + onChange:function (data) {
  303 + var arr = $(this).combobox("getValues");
  304 + var textarr = $(this).combobox("getData");
  305 + if(arr.length > 5 ){
  306 + $(this).combobox("unselect",arr[arr.length-1]);
  307 + // $.messager.alert("提示","标签最多只能选择5个", "info");
  308 + arr = $(this).combobox("getValues");
  309 + }
  310 + var labelList='';
  311 + debugger
  312 + for (var i=0; i<arr.length;i++){
  313 + var text = '';
  314 + for (var j=0; j< textarr.length;j++){
  315 + if(arr[i] == textarr[j].id){
  316 + text=textarr[j].labelName;
  317 + }
  318 + }
  319 + labelList+='<span class="tag"><span>'+text+'</span><a href="#" class="labelTag" data-index="'+i+'">x</a></span>&nbsp&nbsp&nbsp'
  320 + }
  321 + $("#labelList").html(labelList);
  322 + },
  323 + onLoadSuccess:function () {
  324 + var arr = $(this).combobox("getValues");
  325 + var textarr = $(this).combobox("getData");
  326 + var labelList='';
  327 + debugger
  328 + for (var i=0; i<arr.length;i++){
  329 + var text = '';
  330 + for (var j=0; j< textarr.length;j++){
  331 + if(arr[i] == textarr[j].id){
  332 + text=textarr[j].labelName;
  333 + }
  334 + }
  335 + labelList+='<span class="tag"><span>'+text+'</span><a href="#" class="labelTag" data-index="'+i+'">x</a></span>&nbsp&nbsp&nbsp'
  336 + }
  337 + $("#labelList").html(labelList);
  338 + }
  339 + });
  340 +
  341 + $("#topicGroupId").combobox({
  342 + prompt: "选择话题分组",
  343 + required: false,
  344 + selectOnNavigation : true,
  345 + valueField: 'id',
  346 + textField: 'groupName',
  347 + url : serverContextPath + "/topicGroupManage/getAllTopicGroupInfo",
  348 + loadFilter: function (data) {
  349 + return defaultLoadFilter(data);
  350 + },
  351 + onChange:function (data) {
  352 + debugger
  353 + $('#topicId').combobox('reload',serverContextPath + "/grassTopicManage/grassTopicByGroupId?groupId="+data);
  354 +
  355 + // 清空业务线
  356 + $("#topicId").combobox("setValue",'');
  357 + }
  358 + });
  359 +
  360 + $("#topicId").combobox({
  361 + prompt: "选择话题",
  362 + required: false,
  363 + selectOnNavigation : true,
  364 + valueField: 'id',
  365 + textField: 'topicName',
  366 + url : serverContextPath + "/grassTopicManage/grassTopicByGroupId",
  367 + loadFilter: function (data) {
  368 + return defaultLoadFilter(data);
  369 + },
  370 + onChange:function (data) {
  371 + var arr = $(this).combobox("getValue");
  372 + var textarr = $(this).combobox("getData");
  373 + var html='';
  374 + debugger
  375 + var text = '';
  376 + for (var j=0; j< textarr.length;j++){
  377 + if( arr == textarr[j].id){
  378 + text=textarr[j].topicName;
  379 + }
  380 + }
  381 + if(text !=''){
  382 + html+='<span class="tag"><span>'+text+'</span><a href="#" class="topicTag" ">x</a></span>&nbsp&nbsp&nbsp'
  383 + }
  384 + $("#topicList").html(html);
  385 + }
  386 + });
  387 +
  388 + $(document).on("click", ".topicTag", function () {
  389 + $("#topicId").combobox("setValue","");
  390 + });
  391 +
  392 + function htmlTopic(text){
  393 + var html='';
  394 + if(text !='' && text!=null){
  395 + html+='<span class="tag"><span>'+text+'</span><a href="#" class="topicTag" ">x</a></span>&nbsp&nbsp&nbsp'
  396 + }
  397 + $("#topicList").html(html);
  398 + }
  399 +
  400 + $(document).on("click", ".labelTag", function () {
  401 + var index = $(this).attr("data-index");
  402 + var arr = $("#labelId").combobox("getValues");
  403 + $("#labelId").combobox("unselect",arr[index]);
  404 + });
  405 +
  406 + $(document).on("click", ".goodTag", function () {
  407 + debugger
  408 + var product_skn = $(this).attr("data-index");
  409 + removeSingleItemById(product_skn);
  410 + var skns = '';
  411 + for (var i = 0; i < checkedItems.length; i++) {
  412 + if( i == checkedItems.length -1){
  413 + skns = skns+ checkedItems[i]
  414 + }else{
  415 + skns = skns+ checkedItems[i] +","
  416 + }
  417 + }
  418 + $("#skns").val(skns);
  419 + var div= $(this).parent("span").parent("div");
  420 + div.remove();
  421 + });
  422 +
  423 + $("#subBotton").linkbutton({
  424 + iconCls: "icon-save",
  425 + width:200,
  426 + onClick: function () {
  427 + $("#publishArticleForm").form("submit",{
  428 + url : serverContextPath+"/tblCrawlerArticle/publishCrawlerArticle",
  429 + onSubmit : function(param) {
  430 + debugger;
  431 + if (!$("#publishArticleForm").form("validate")) {
  432 + return false;
  433 +
  434 + }
  435 + var content = $("#content").val();
  436 + if(content == '' || content.length<=0){
  437 + $.messager.alert("保存失败", "请输入文字内容", "error");
  438 + return false;
  439 + }
  440 + if(content.length>500){
  441 + $.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
  442 + return false;
  443 + }
  444 + $("#draftType").val(2);
  445 + var imgs = '';
  446 + var imageCount = 0;
  447 + $("input[name='url']").each(function(j,item){
  448 + debugger
  449 + var url = item.value;
  450 + if(imgs == ''){
  451 + imgs = url;
  452 + }else{
  453 + imgs = imgs + ","+url;
  454 + }
  455 + imageCount++;
  456 + });
  457 + $("#imgs").val(imgs);
  458 + if(imageCount > 9){
  459 + $.messager.alert("发布失败", "最多只能选择9张图片", "error");
  460 + return false;
  461 + }
  462 + if(imageCount < 1){
  463 + $.messager.alert("发布失败", "请选择至少一张图片", "error");
  464 + return false;
  465 + }
  466 + var labels = '';
  467 + $("input[name='labelId']").each(function(j,item){
  468 + debugger
  469 + var id = item.value;
  470 + if(labels == ''){
  471 + labels = id;
  472 + }else{
  473 + labels = labels + ","+id;
  474 + }
  475 + });
  476 + $("#labelIds").val(labels);
  477 + var html = '';
  478 + for (var i = 0; i < checkedItems.length; i++) {
  479 + html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
  480 + html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
  481 + }
  482 + $("#products").html(html);
  483 + return true;
  484 + },
  485 + success : function(data) {
  486 + if (data) {
  487 + data = $.parseJSON(data);
  488 + if (data.code == 200) {
  489 + $.messager.alert("提示","发布成功", "info", function(){window.location.reload()});
  490 + $("#activityListTable").datagrid("reload");
  491 + // alert("保存成功");
  492 + } else {
  493 + $.messager.alert("保存失败", data.message, "error");
  494 + $("#activityListTable").datagrid("reload");
  495 + }
  496 + } else {
  497 + $.messager.alert("保存失败", data.message, "error");
  498 + $("#activityListTable").datagrid("reload");
  499 + }
  500 + }
  501 + });
  502 +
  503 + }
  504 + });
  505 +
  506 + $("#draftBotton").linkbutton({
  507 + iconCls: "icon-save",
  508 + width:200,
  509 + onClick: function () {
  510 + $("#publishArticleForm").form("submit",{
  511 + url : serverContextPath+"/tblCrawlerArticle/saveTblArticleDraft",
  512 + onSubmit : function(param) {
  513 + debugger;
  514 + if (!$("#publishArticleForm").form("validate")) {
  515 + return false;
  516 +
  517 + }
  518 + var content = $("#content").val();
  519 + if(content == '' || content.length<=0){
  520 + $.messager.alert("保存失败", "请输入文字内容", "error");
  521 + return false;
  522 + }
  523 + if(content.length>500){
  524 + $.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
  525 + return false;
  526 + }
  527 + var imgs = '';
  528 + var imageCount = 0;
  529 + $("input[name='url']").each(function(j,item){
  530 + debugger
  531 + var url = item.value;
  532 + if(imgs == ''){
  533 + imgs = url;
  534 + }else{
  535 + imgs = imgs + ","+url;
  536 + }
  537 + imageCount++;
  538 + });
  539 + $("#imgs").val(imgs);
  540 + if(imageCount > 9){
  541 + $.messager.alert("保存失败", "最多只能选择9张图片", "error");
  542 + return false;
  543 + }
  544 + if(imageCount < 1){
  545 + $.messager.alert("发布失败", "请选择至少一张图片", "error");
  546 + return false;
  547 + }
  548 + var labels = '';
  549 + $("input[name='labelId']").each(function(j,item){
  550 + debugger
  551 + var id = item.value;
  552 + if(labels == ''){
  553 + labels = id;
  554 + }else{
  555 + labels = labels + ","+id;
  556 + }
  557 + });
  558 + $("#labelIds").val(labels);
  559 + var html = '';
  560 + for (var i = 0; i < checkedItems.length; i++) {
  561 + html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
  562 + html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
  563 + }
  564 + $("#products").html(html);
  565 + return true;
  566 + },
  567 + success : function(data) {
  568 + if (data) {
  569 + data = $.parseJSON(data);
  570 + if (data.code == 200) {
  571 + $.messager.alert("提示","保存成功", "info", function(){window.location.reload()});
  572 + $("#activityListTable").datagrid("reload");
  573 +
  574 + } else {
  575 + $.messager.alert("保存失败", data.message, "error");
  576 + $("#activityListTable").datagrid("reload");
  577 + }
  578 + } else {
  579 + $.messager.alert("保存失败", data.message, "error");
  580 + $("#activityListTable").datagrid("reload");
  581 + }
  582 + }
  583 + });
  584 +
  585 + }
  586 + });
  587 +
  588 + $("#imageUpload1").imageUpload({
  589 + width: 171,
  590 + height: 120,
  591 + realInputName: "url",
  592 + uploadInputName: "files",
  593 + url: serverContextPath + '/fileupload/uploads',
  594 + queryParams: {
  595 + bucket: "grassImg"
  596 + },
  597 + onBeforeSubmit: function () {
  598 + debugger;
  599 + var oobj = $(this).find("input[type='file']");
  600 + var files = oobj[0].files;
  601 +
  602 + for(var i=0; i<files.length;i++){
  603 + var obj = files[i];
  604 + if(obj!=null && obj!=''){
  605 + debugger
  606 + if(obj.name.substring(obj.name.lastIndexOf(".")).toLowerCase() == '.png'){
  607 + $.messager.alert("提示","不允许上传png格式的图片", "info", function(){return false;});
  608 + return false;
  609 + }
  610 + if(obj.type.toLowerCase() == 'image/png'){
  611 + $.messager.alert("提示","不允许上传png格式的图片", "info", function(){return false;});
  612 + return false;
  613 + }
  614 + }
  615 + }
  616 + var imageCount = 0;
  617 + $("input[name='url']").each(function(j,item){
  618 + debugger
  619 + var url = item.value;
  620 + if(url != ''){
  621 + imageCount++;
  622 + }
  623 + });
  624 + if(imageCount +files.length > 9 ){
  625 + $.messager.alert("提示","最多上传九张图片", "info");
  626 + return false;
  627 + }
  628 + $.messager.progress({
  629 + title: "正在执行",
  630 + msg: "正在执行,请稍后...",
  631 + interval: 500,
  632 + text: ""
  633 + });
  634 + },
  635 + filterFileName: function (data) {
  636 + debugger;
  637 + if (!data || data.code != 200) {
  638 + $.messager.progress("close");
  639 + initimg(1,1);
  640 + $(this).remove();
  641 + $.messager.alert("错误",data.message);
  642 + return "";
  643 + }
  644 + return data.data[0];
  645 + },
  646 + onLoadSuccess: function (data) {
  647 + initimg(1,data.data.length);
  648 + for (var i= 1; i<= data.data.length; i++){
  649 + $("#imageUpload"+i).imageUpload("setValue",data.data[i-1])
  650 + }
  651 + $.messager.progress("close");
  652 + return false;
  653 + },
  654 + onClose:function(data){
  655 + $("#imageUpload1").remove();
  656 + }
  657 + });
  658 +
  659 + debugger;
  660 + var data = paramObject.mkData;
  661 + if (data){
  662 +
  663 +
  664 + $("#articleUid").textbox("setValue", data.authorUid);
  665 + $("#draftArticleId").val(data.articleId);
  666 +
  667 + var context = data.contentText;
  668 + if(context == null || context == '' || context == undefined){
  669 + context = data.articleContent;
  670 + }
  671 + $("#content").emojioneArea()[0].emojioneArea.setText(context);
  672 + if(context !=null && context !=''){
  673 + var count = context.length;
  674 + $("#content-count").text(count);
  675 + }
  676 +
  677 + $("#crawlerId").val(data.id);
  678 + var sort;
  679 + if(data.crawlerType == 1){
  680 + sort = 2;
  681 + }else if(data.crawlerType == 2){
  682 + sort = 1;
  683 + }
  684 + $("#sort").val(sort);
  685 +
  686 +
  687 +
  688 + initimg(1,data.imgList.length);
  689 + for (var j= 1; j<= data.imgList.length; j++){
  690 + $("#imageUpload"+j).imageUpload("setValue",data.imgList[j-1])
  691 + }
  692 +
  693 + }
  694 + });
  695 +
  696 +
  697 + // 定时 选择时间
  698 + function getTimeDialog(data,id, status){
  699 + var timeChoose = $("<div id='timeChoose'>").appendTo($(document.body));
  700 + var title = "选择时间";
  701 + var textVar = "确认";
  702 +
  703 + window.self.paramObject.mkData = data;
  704 + $(timeChoose).myDialog({
  705 + title: title,
  706 + width: "20%",
  707 + height: "30%",
  708 + resizable:false,
  709 + buttons:[{
  710 + id : "saveBtn",
  711 + text:textVar,
  712 + iconCls : "icon-save",
  713 + handler:function(){
  714 + debugger;
  715 + var time=''
  716 + if($("#publishTimeStr").datetimebox('getValue') !=null && $("#publishTimeStr").datetimebox('getValue') !=''){
  717 + time = parseInt(new Date($("#publishTimeStr").datetimebox('getValue')).getTime() );
  718 + }else {
  719 + $.messager.alert("发布失败", "请选择时间", "error");
  720 + return;
  721 + }
  722 + $("#publishArticleForm").form("submit",{
  723 + url : serverContextPath+"/tblCrawlerArticle/tblTimerPublish",
  724 + onSubmit : function(param) {
  725 + debugger;
  726 + if (!$("#publishArticleForm").form("validate")) {
  727 + return false;
  728 + }
  729 + var content = $("#content").val();
  730 + if(content == '' || content.length<=0){
  731 + $.messager.alert("保存失败", "请输入文字内容", "error");
  732 + return false;
  733 + }
  734 + if(content.length>500){
  735 + $.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
  736 + return false;
  737 + }
  738 + param.publishTime =time;
  739 + var imgs = '';
  740 + var imageCount = 0;
  741 + $("input[name='url']").each(function(j,item){
  742 + debugger
  743 + var url = item.value;
  744 + if(imgs == ''){
  745 + imgs = url;
  746 + }else{
  747 + imgs = imgs + ","+url;
  748 + }
  749 + imageCount++;
  750 + });
  751 + $("#imgs").val(imgs);
  752 + if(imageCount > 9){
  753 + $.messager.alert("发布失败", "最多只能选择9张图片", "error");
  754 + return false;
  755 + }
  756 + if(imageCount < 1){
  757 + $.messager.alert("发布失败", "请选择至少一张图片", "error");
  758 + return false;
  759 + }
  760 + var labels = '';
  761 + $("input[name='labelId']").each(function(j,item){
  762 + debugger
  763 + var id = item.value;
  764 + if(labels == ''){
  765 + labels = id;
  766 + }else{
  767 + labels = labels + ","+id;
  768 + }
  769 + });
  770 + $("#labelIds").val(labels);
  771 + var html = '';
  772 + for (var i = 0; i < checkedItems.length; i++) {
  773 + html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
  774 + html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
  775 + }
  776 + $("#products").html(html);
  777 + return true;
  778 + },
  779 + success : function(data) {
  780 + if (data) {
  781 + data = $.parseJSON(data);
  782 + if (data.code == 200) {
  783 + $.messager.alert("提示","发布成功", "info", function(){window.location.reload()});
  784 + $("#activityListTable").datagrid("reload");
  785 + // alert("保存成功");
  786 + } else {
  787 + $.messager.alert("保存失败", data.message, "error");
  788 + $("#activityListTable").datagrid("reload");
  789 + }
  790 + } else {
  791 + $.messager.alert("保存失败", data.message, "error");
  792 + $("#activityListTable").datagrid("reload");
  793 + }
  794 + }
  795 + });
  796 + $(timeChoose).dialog("close");
  797 + }
  798 + }, {
  799 + text: "关闭",
  800 + iconCls: "icon-cancel",
  801 + handler: function () {
  802 + $.messager.confirm("确认", "确认关闭吗?", function (flag) {
  803 + if(flag){
  804 + $(timeChoose).dialog("close");
  805 + }
  806 + });
  807 + }
  808 + }],
  809 + modal: true,
  810 + href: contextPath + "/html/grass/article/chooseTime.html"
  811 + });
  812 + }
  813 +
  814 +
  815 + // 编辑分组
  816 + function getGoodsDialog(data){
  817 + var labelGroupList = $("<div id='labelGroupList'>").appendTo($(document.body));
  818 + var title = "选择商品";
  819 + var textVar = "确认";
  820 + var msgVar = "确认新增吗?";
  821 +
  822 + window.self.paramObject.mkData = data;
  823 + $(labelGroupList).myDialog({
  824 + title: title,
  825 + width: "70%",
  826 + height: "80%",
  827 + resizable:false,
  828 + buttons:[{
  829 + id : "saveBtn",
  830 + text:textVar,
  831 + iconCls : "icon-save",
  832 + handler:function(){
  833 + debugger;
  834 +
  835 + $("#goodstd").html("<div id=\"good0\" style=\"float: left;margin-left: 30px;width: 300px\">\n" +
  836 + " </div>");
  837 + for (var i = 0; i < checkedItems.length; i++) {
  838 + buildgood(i,checkedItems[i].productSkn);
  839 + }
  840 +
  841 + $(labelGroupList).dialog("close");
  842 + }
  843 + }, {
  844 + text: "关闭",
  845 + iconCls: "icon-cancel",
  846 + handler: function () {
  847 + $.messager.confirm("确认", "确认关闭吗?", function (flag) {
  848 + if(flag){
  849 + $(labelGroupList).dialog("close");
  850 + }
  851 + });
  852 + }
  853 + }],
  854 + modal: true,
  855 + href: contextPath + "/html/grass/article/chooseSkns.html"
  856 + });
  857 + }
  858 +
  859 + function oo(num){
  860 +
  861 + $("#imageUpload"+num).imageUpload({
  862 + width: 171,
  863 + height: 120,
  864 + realInputName: "url",
  865 + uploadInputName: "files",
  866 + url: serverContextPath + '/fileupload/uploads',
  867 + queryParams: {
  868 + bucket: "grassImg"
  869 + },
  870 + onBeforeSubmit: function () {
  871 + var oobj = $(this).find("input[type='file']");
  872 + var files = oobj[0].files;
  873 +
  874 + for(var i=0; i<files.length;i++){
  875 + var obj = files[i];
  876 + if(obj!=null && obj!=''){
  877 + debugger
  878 + if(obj.name.substring(obj.name.lastIndexOf(".")).toLowerCase() == 'png'){
  879 + $.messager.alert("提示","不允许上传png格式的图片", "info", function(){return false;});
  880 + return false;
  881 + }
  882 + if(obj.type.toLowerCase() == 'image/png'){
  883 + $.messager.alert("提示","不允许上传png格式的图片", "info", function(){return false;});
  884 + return false;
  885 + }
  886 + }
  887 + }
  888 + var imageCount = 0;
  889 + $("input[name='url']").each(function(j,item){
  890 + debugger
  891 + var url = item.value;
  892 + if(url != ''){
  893 + imageCount++;
  894 + }
  895 + });
  896 + if(imageCount +files.length > 9 ){
  897 + $.messager.alert("提示","最多上传九张图片", "info");
  898 + return false;
  899 + }
  900 + $.messager.progress({
  901 + title: "正在执行",
  902 + msg: "正在执行,请稍后...",
  903 + interval: 500,
  904 + text: ""
  905 + });
  906 + },
  907 + filterFileName: function (data) {
  908 + debugger;
  909 + if (!data || data.code != 200) {
  910 + $.messager.progress("close");
  911 + initimg(num,1);
  912 + $(this).remove();
  913 + $.messager.alert("错误",data.message);
  914 + return "";
  915 + }
  916 + return data.data[0];
  917 + },
  918 + onLoadSuccess: function (data) {
  919 + debugger;
  920 + initimg(num,data.data.length);
  921 + var c =0;
  922 + for (var i= 0; i<= data.data.length; i++){
  923 + nnum = num +i;
  924 + $("#imageUpload"+nnum).imageUpload("setValue",data.data[c]);
  925 + c++;
  926 + }
  927 + $.messager.progress("close");
  928 + return false;
  929 + },
  930 + onClose:function(data){
  931 + $("#imageUpload"+num).remove();
  932 + }
  933 + });
  934 + }
  935 +
  936 +
  937 +
  938 + function initimg(m,n) {
  939 + for (var i =1 ; i<=n; i++){
  940 + debugger
  941 + var nnum = m+i;
  942 + $("#imageUpload"+(nnum-1)).after('<div id="imageUpload'+nnum+'"> </div>');
  943 + oo(nnum);
  944 + }
  945 + }
  946 +
  947 + function buildgood(index,obj) {
  948 + debugger;
  949 + var data = checkedItemsObj[obj];
  950 + if(data ==null){
  951 + return;
  952 + }
  953 + $("#good"+index).html(gooddiv(data));
  954 + $div = $("#good"+(index+1));
  955 + $("#good"+index).after('<div id="good'+(index+1)+'"style="float: left;margin-left: 30px;width: 300px"> </div>');
  956 + }
  957 + function gooddiv(data) {
  958 +
  959 + return " <span>商品图:<img width=\"100\" height=\"60\" src="+getImageUrl(data.default_images)+
  960 + " /> <a href=\"#\" class=\"goodTag\" data-index=\""+data.product_skn+"\">x</a></span>" +
  961 + "<h5 style=\"margin-top: 0px;margin-bottom: 0px\">商品名:"+ data.product_name +"</h5>\n" +
  962 + "<h5 style=\"margin-top: 0px;margin-bottom: 0px\">价格:"+data.sales_price+"</h5>"
  963 + }
  964 +
  965 + function getImageUrl(image) {
  966 + var result='';
  967 + if (image) {
  968 + if(image.indexOf('http://') == 0){
  969 + result = image.split("?")[0];
  970 + }else{
  971 + var fileMode = image.substring(15, 17);
  972 + if(fileMode=='01'){
  973 + result= "http://"+"img11.static.yhbimg.com"+"/goodsimg"+image;
  974 + }
  975 + if(fileMode=='02'){
  976 + result= "http://"+"img12.static.yhbimg.com"+"/goodsimg"+image;
  977 + }
  978 + }
  979 + }
  980 + else {
  981 + result = ""
  982 + }
  983 + if (result) {
  984 + return result + "?imageMogr2/thumbnail/320x320/extent/320x320/background/d2hpdGU=/position/center/quality/90";
  985 + } else {
  986 + return "";
  987 + }
  988 + }
  989 + function findCheckedItem(ID) {
  990 + for (var i = 0; i < checkedItems.length; i++) {
  991 + if (checkedItems[i].productSkn == ID) return i;
  992 + }
  993 + return -1;
  994 + }
  995 + function addcheckItem() {
  996 + // if(searchType != checkType && checkedItems.length>0){
  997 + // }
  998 + checkType = searchType;
  999 + var i=0;
  1000 + $("input[type='checkbox'][name='product_skn']:checked").each(function () {
  1001 + if(i > 9){
  1002 + alert("最多只能选择10个商品");
  1003 + return false;
  1004 + }
  1005 + var k = findCheckedItem($(this).val());
  1006 + if (k == -1) {
  1007 + var product = {};
  1008 + product.productSkn = $(this).val();
  1009 + product.productType = checkType;
  1010 + checkedItems.push(product);
  1011 + }
  1012 + i++;
  1013 +
  1014 + });
  1015 + }
  1016 +
  1017 + function removeAllItem(rows) {
  1018 + $("input[type='checkbox'][name='product_skn']").each(function () {
  1019 + if (!this.checked) {
  1020 + var k = findCheckedItem($(this).val());
  1021 + if (k != -1) {
  1022 + checkedItems.splice(k, 1);
  1023 + }
  1024 + }
  1025 + });
  1026 + }
  1027 + function resetSelectedCheckBox(data){
  1028 + $("input[type='checkbox'][name='product_skn']").each(function () {
  1029 + var cb=$(this);
  1030 + $.each(checkedItems,function(index,value){
  1031 + if(value.productSkn==cb.val()){
  1032 + cb.attr("checked",true);
  1033 + return false;
  1034 + }
  1035 + });
  1036 + });
  1037 + }
  1038 + function removeSingleItem(rowIndex, rowData) {
  1039 + var k = findCheckedItem(rowData.product_skn);
  1040 + if (k != -1) {
  1041 + checkedItems.splice(k, 1);
  1042 + }
  1043 + }
  1044 + function removeSingleItemById(id) {
  1045 + debugger
  1046 + var k = findCheckedItem(id);
  1047 + if (k != -1) {
  1048 + checkedItems.splice(k, 1);
  1049 + }
  1050 + }
  1051 +</script>
@@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
56 <div region="center" style="margin-left: 20px" > 56 <div region="center" style="margin-left: 20px" >
57 <table id="activityListTable" ></table> 57 <table id="activityListTable" ></table>
58 </div> 58 </div>
59 -</div> 59 +<div region="center" id="articleEditer" style="margin-left: 20px" >
60 60
61 </body> 61 </body>
62 62
@@ -351,12 +351,16 @@ @@ -351,12 +351,16 @@
351 $(this).datagrid("getPanel").find("a[role='showDetail']").linkbutton({ 351 $(this).datagrid("getPanel").find("a[role='showDetail']").linkbutton({
352 iconCls : "icon-edit", 352 iconCls : "icon-edit",
353 onClick : function() { 353 onClick : function() {
  354 + debugger;
354 index = $(this).attr("index"); 355 index = $(this).attr("index");
355 - var row = $("#activityListTable").datagrid('getData').rows[index];  
356 - var yhUid = row.yhUid;  
357 - var imgList = row.imgList;  
358 - var crawlerType = row.crawlerType;  
359 - getPublishDialog(yhUid , row.id , imgList , crawlerType); 356 + var row = $("#activityListTable").datagrid("getData").rows[index];
  357 + var crawlerType =row.crawlerType;
  358 +
  359 + if(crawlerType == '2'){ //笔记
  360 + articleEditer(data.rows[index]);
  361 + }else if(crawlerType == '1'){ //长文章
  362 + longArticleEditer(data.rows[index]);
  363 + }
360 } 364 }
361 }); 365 });
362 366
@@ -384,6 +388,38 @@ @@ -384,6 +388,38 @@
384 +id+"&crawlerType="+crawlerType; 388 +id+"&crawlerType="+crawlerType;
385 } 389 }
386 390
  391 + // 编辑
  392 + function articleEditer(data){
  393 + var articleEditer = $("<div id='articleEditer'>").appendTo($(document.body));
  394 + var title = "编辑";
  395 +
  396 + window.self.paramObject.mkData = data;
  397 + $(articleEditer).myDialog({
  398 + title: title,
  399 + width: "80%",
  400 + height: "100%",
  401 + resizable:false,
  402 + modal: true,
  403 + href: contextPath + "/html/grass/tblCrawlerInfoManage/editTblCrawlerArticle.html"
  404 + });
  405 + }
  406 +
  407 + // 编辑
  408 + function longArticleEditer(data){
  409 + var articleEditer = $("<div id='articleEditer'>").appendTo($(document.body));
  410 + var title = "编辑";
  411 +
  412 + window.self.paramObject.mkData = data;
  413 + $(articleEditer).myDialog({
  414 + title: title,
  415 + width: "80%",
  416 + height: "100%",
  417 + resizable:false,
  418 + modal: true,
  419 + href: contextPath + "/html/grass/longArticle/edit.html"
  420 + });
  421 + }
  422 +
387 423
388 424
389 425