portal html css js resource

articalIssue.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. $(function() {
  2. var experarray = [];
  3. var resourcesarray = [];
  4. var $data = {};
  5. var articleId;
  6. var fa = false;
  7. var orgId = $.cookie("orgId");
  8. var colMgr = stringToBoolean($.cookie("colMgr"));
  9. var resMgr = stringToBoolean($.cookie("resMgr"));
  10. if(!colMgr && !resMgr) {
  11. $(".conItem").eq(5).show();
  12. }
  13. if(resMgr) {
  14. $(".conItem").eq(2).show();
  15. $(".conItem").eq(3).show();
  16. }
  17. if(colMgr) {
  18. $(".conItem").show().eq(5).hide();
  19. }
  20. var hbur,hburEnd;
  21. var pr,prEnd;
  22. var re,reEnd;
  23. var orgr,orgrEnd;
  24. if(orgId == "" || orgId == null || orgId == "null"){
  25. location.href = "cmp-settled-log.html";
  26. }
  27. // 上传附件
  28. var uploaderFile =new WebUploader.create({
  29. auto: true,
  30. fileNumLimit: 5,
  31. server: '../ajax/article/files/upload',
  32. fileSingleSizeLimit: 50 * 1024 * 1024,
  33. pick: {
  34. id: "#upAttachPicker",
  35. multiple: false
  36. }
  37. });
  38. uploaderFile.on('error', function(code) {
  39. if(code=="F_EXCEED_SIZE"){
  40. $.MsgBox.Alert('提示', '上传附件的大小不超过50M')
  41. }
  42. });
  43. var fileId;
  44. // 当有文件添加进来的时候
  45. uploaderFile.on('fileQueued', function(file) {
  46. fileId = file.id;
  47. });
  48. uploaderFile.on('uploadError', function(file, data) {
  49. $.MsgBox.Alert('提示', '该附件上传失败,请重试')
  50. });
  51. uploaderFile.on('uploadSuccess', function(file, data) {
  52. if(data.success) {
  53. var $li = $(
  54. '<li class="file_list ellipsisSty-2" data-id="'+file.id+'" data-size="'+file.size+'" data-name="'+file.name+'">'+
  55. file.name +
  56. '<div class="deleteThis"></div>'+
  57. '</li>'
  58. ),
  59. $file = $li.find('li');
  60. var $list = $("#fileAttachList");
  61. $list.prepend($li);
  62. var $len = $("#fileAttachList").find("li").length;
  63. if($len>0 && $len<5){
  64. $("#upAttachPicker").addClass("upAtteched")
  65. $("#upAttachPicker>.webuploader-pick").text('继续上传')
  66. }
  67. if($len>=5){
  68. $("#upAttachPicker").hide()
  69. }
  70. uploaderFile.removeFile(fileId);
  71. $("#fileAttachList li:first-child").attr("data-url",data.data[0].uri);
  72. }
  73. });
  74. //校验标题
  75. $("#newstitle").on({
  76. focus: function() {
  77. $(this).prev().find("span").text("50字以内");
  78. },
  79. blur: function() {
  80. $(this).prev().find("span").text("");
  81. },
  82. keyup: function() {
  83. if($(this).val().length > 50) {
  84. $(this).val($(this).val().substr(0, 50));
  85. }
  86. }
  87. })
  88. hotKey(".oinput");
  89. //校验关键字
  90. $("#KeyWord").on({
  91. focus: function() {
  92. $("#keyPrompt").text("最多可添加5个关键词,每个关键词15字以内");
  93. },
  94. blur: function() {
  95. $("#keyPrompt").text("");
  96. }
  97. })
  98. $("#keyWordlist").on("click", ".closeThis", function() {
  99. $(this).parent().remove();
  100. var liNum = $("#keyWordlist").find("li").length;
  101. if(liNum < 5) {
  102. $("#keyWordlist").parents(".keyResult").siblings("div.col-w-12").show();
  103. }
  104. })
  105. //校验右侧专家和资源
  106. $("#checkZj").on("focus", function() {
  107. $(this).prev().find("span").text("最多选择5位专家");
  108. })
  109. $("#checkZy").on("focus", function() {
  110. $(this).prev().find("span").text("最多选择5个资源");
  111. })
  112. $("#sevrice").on("focus", function() {
  113. $(this).prev().find("span").text("最多选择5个服务");
  114. })
  115. $("#product").on("focus", function() {
  116. $(this).prev().find("span").text("最多选择5个产品");
  117. })
  118. $("#checkZj,#checkZy,#sevrice,#product").on("blur", function() {
  119. $(this).prev().find("span").text("");
  120. })
  121. $("#checkZj").on("keyup", function() {
  122. var _this = this;
  123. var ti=$(this).val();
  124. pr=ti;
  125. if($(this).val()=="") {
  126. return;
  127. }
  128. setTimeout(function(){
  129. if( ti===pr && ti!== prEnd) {
  130. checkZj(_this,ti);
  131. }
  132. },500)
  133. })
  134. $("#checkZy").on("keyup", function() {
  135. var ti=$(this).val();
  136. re=ti;
  137. if($(this).val()=="") {
  138. return;
  139. }
  140. var _this = this;
  141. setTimeout(function(){
  142. if( ti===re && ti!== reEnd) {
  143. checkZy(_this,ti);
  144. }
  145. },500)
  146. })
  147. var se,seEnd;
  148. $("#sevrice").on("keyup", function() {
  149. var ti=$(this).val();
  150. se=ti;
  151. if($(this).val()=="") {
  152. return;
  153. }
  154. var _this = this;
  155. setTimeout(function(){
  156. if( ti===se && ti!== seEnd) {
  157. checkSy(_this,ti);
  158. }
  159. },500)
  160. })
  161. var proD,proDEnd;
  162. $("#product").on("keyup", function() {
  163. var ti=$(this).val();
  164. proD=ti;
  165. if($(this).val()=="") {
  166. return;
  167. }
  168. var _this = this;
  169. setTimeout(function(){
  170. if( ti===proD && ti!== proDEnd) {
  171. checkProDy(_this,ti);
  172. }
  173. },500)
  174. })
  175. $("#expertlist").on("click", "li", function() {
  176. var _this = this;
  177. expertlist(_this, "该专家已选择");
  178. });
  179. $("#resouselist").on("click", "li", function() {
  180. var _this = this;
  181. expertlist(_this, "该资源已选择");
  182. });
  183. $("#sevricelist").on("click", "li", function() {
  184. var _this = this;
  185. expertlist(_this, "该服务已选择");
  186. });
  187. $("#productlist").on("click", "li", function() {
  188. var _this = this;
  189. expertlist(_this, "该产品已选择");
  190. });
  191. //点击右侧搜索出的专家和资源列表
  192. function expertlist(_this, title) {
  193. var liId = $(_this).html();
  194. var plength = $(_this).parents(".otherBlock").find(".addexpert li");
  195. for(var i = 0; i < plength.length; i++) {
  196. if(plength[i].innerHTML == liId) {
  197. $(_this).parents(".otherBlock").find(".aboutTit span").text(title);
  198. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  199. $(_this).parents(".otherBlock").find("input").val("");
  200. return;
  201. }
  202. }
  203. if(plength.length > 5) {
  204. $(_this).parents(".otherBlock").find("input").hide();
  205. $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
  206. $(_this).parents(".otherBlock").find("input").val("");
  207. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  208. } else {
  209. $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
  210. $(_this).parents(".otherBlock").find("input").val("");
  211. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  212. }
  213. }
  214. //删除右侧搜索出的专家和资源
  215. $(".addexpert").on("click", ".deleteThis", function() {
  216. var plength = $(this).parent().parent().find("li").length;
  217. if(plength < 6) {
  218. $(this).parents(".otherBlock").find("input").show();
  219. }
  220. $(this).parent().remove();
  221. })
  222. $("#fileAttachList").on("click", ".deleteThis",function() {
  223. var filid = $(this).parent().attr("data-id");
  224. var $len = $("#fileAttachList li").length;
  225. if($len>0 && $len<5){
  226. $("#upAttachPicker").show()
  227. $("#upAttachPicker").addClass("upAtteched")
  228. $("#upAttachPicker>.webuploader-pick").text('继续上传')
  229. }
  230. if($len>=5){
  231. $("#upAttachPicker").hide()
  232. }
  233. })
  234. function checkZj(_this,prd) {
  235. prEnd=prd;
  236. $.ajax({
  237. "url": "/ajax/professor/qaByName",
  238. "type": "get",
  239. "data": {
  240. "name": $("#checkZj").val(),
  241. "total": 3
  242. },
  243. "success": function(data) {
  244. console.log(data);
  245. if(data.success) {
  246. if(data.data != "") {
  247. if(prEnd == prd){
  248. $(_this).next().removeClass("displayNone");
  249. var itemlist = '';
  250. $("#expertlist").html("");
  251. for(var i = 0; i < data.data.length; i++) {
  252. var itemlist = '<li id="usid" class="flexCenter">';
  253. itemlist += '<div class="madiaHead useHead" id="userimg"></div>';
  254. itemlist += '<div class="madiaInfo">';
  255. itemlist += '<p class="ellipsisSty"><span class="h1Font" id="name"></span><span class="h2Font" style="margin-left:10px;" id="title"></span></p>';
  256. itemlist += '<p class="h2Font ellipsisSty" id="orgName"></p>';
  257. itemlist += '</div><div class="deleteThis"></div></li>';
  258. $itemlist = $(itemlist);
  259. $("#expertlist").append($itemlist);
  260. var datalist = data.data[i];
  261. $itemlist.attr("data-id", datalist.id);
  262. $itemlist.find("#name").text(datalist.name);
  263. $itemlist.find("#title").text(datalist.title);
  264. $itemlist.find("#orgName").text(datalist.orgName);
  265. if(datalist.hasHeadImage == 1) {
  266. $itemlist.find("#userimg").attr("style", "background-image: url(/images/head/" + datalist.id + "_l.jpg);");
  267. }
  268. }
  269. }
  270. } else {
  271. $(_this).next().removeClass("displayNone");
  272. var itemlist = '<div class="null-data">没有找到相关专家</div>'
  273. $("#expertlist").html(itemlist);
  274. return;
  275. }
  276. } else {
  277. $(_this).next().addClass("displayNone");
  278. }
  279. },
  280. "error": function() {
  281. $.MsgBox.Alert('提示', '链接服务器超时')
  282. }
  283. });
  284. }
  285. function checkZy(_this, prd) {
  286. reEnd = prd;
  287. $.ajax({
  288. "url": "/ajax/resource/lq/publish/org",
  289. "type": "get",
  290. "data": {
  291. "orgid": orgId,
  292. "resourceName": $("#checkZy").val(),
  293. "rows": 3
  294. },
  295. "success": function(data) {
  296. console.log(data);
  297. if(data.success) {
  298. if(data.data != "") {
  299. if(reEnd == prd) {
  300. $(_this).next().removeClass("displayNone");
  301. $("#resouselist").html("");
  302. for(var i = 0; i < data.data.length; i++) {
  303. var itemlist = '<li id="usid" class="flexCenter" >' +
  304. '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
  305. '<div class="deleteThis"></div></li>'
  306. $itemlist = $(itemlist);
  307. $("#resouselist").append($itemlist);
  308. var datalist = data.data[i];
  309. $itemlist.attr("data-id", datalist.resourceId);
  310. $itemlist.find("#resourceName").text(datalist.resourceName);
  311. }
  312. }
  313. } else {
  314. $(_this).next().removeClass("displayNone");
  315. var itemlist = '<div class="null-data">没有找到相关资源</div>'
  316. $("#resouselist").html(itemlist);
  317. }
  318. } else {
  319. $(_this).next().addClass("displayNone");
  320. }
  321. },
  322. "error": function() {
  323. $.MsgBox.Alert('提示', '链接服务器超时')
  324. }
  325. });
  326. }
  327. function checkSy(_this, prd) {
  328. seEnd = prd;
  329. $.ajax({
  330. "url": "../ajax/ware/publish",
  331. "type": "get",
  332. "data": {
  333. category:2,
  334. owner:orgId,
  335. rows:5
  336. },
  337. "success": function(data) {
  338. console.log(data);
  339. if(data.success) {
  340. if(data.data != "") {
  341. if(seEnd == prd) {
  342. $(_this).next().removeClass("displayNone");
  343. $("#sevricelist").html("");
  344. for(var i = 0; i < data.data.length; i++) {
  345. var itemlist = '<li id="usid" class="flexCenter" >' +
  346. '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
  347. '<div class="deleteThis"></div></li>'
  348. $itemlist = $(itemlist);
  349. $("#sevricelist").append($itemlist);
  350. var datalist = data.data[i];
  351. $itemlist.attr("data-id", datalist.id);
  352. $itemlist.find("#resourceName").text(datalist.name);
  353. }
  354. }
  355. } else {
  356. $(_this).next().removeClass("displayNone");
  357. var itemlist = '<div class="null-data">没有找到相关服务</div>'
  358. $("#sevricelist").html(itemlist);
  359. }
  360. } else {
  361. $(_this).next().addClass("displayNone");
  362. }
  363. },
  364. "error": function() {
  365. $.MsgBox.Alert('提示', '链接服务器超时')
  366. }
  367. });
  368. }
  369. function checkProDy(_this, prd) {
  370. proDEnd = prd;
  371. $.ajax({
  372. "url": "../ajax/product/publish",
  373. "type": "get",
  374. "data": {
  375. owner:orgId,
  376. rows:5
  377. },
  378. "success": function(data) {
  379. console.log(data);
  380. if(data.success) {
  381. if(data.data != "") {
  382. if(proDEnd == prd) {
  383. $(_this).next().removeClass("displayNone");
  384. $("#productlist").html("");
  385. for(var i = 0; i < data.data.length; i++) {
  386. var itemlist = '<li id="usid" class="flexCenter" >' +
  387. '<p class="h1Font ellipsisSty-2 childElement" id="resourceName"></p>' +
  388. '<div class="deleteThis"></div></li>'
  389. $itemlist = $(itemlist);
  390. $("#productlist").append($itemlist);
  391. var datalist = data.data[i];
  392. $itemlist.attr("data-id", datalist.id);
  393. $itemlist.find("#resourceName").text(datalist.name);
  394. }
  395. }
  396. } else {
  397. $(_this).next().removeClass("displayNone");
  398. var itemlist = '<div class="null-data">没有找到相关产品</div>'
  399. $("#productlist").html(itemlist);
  400. }
  401. } else {
  402. $(_this).next().addClass("displayNone");
  403. }
  404. }
  405. });
  406. }
  407. var titleflase = false;
  408. var imgflase = false;
  409. //交验图片和标题不能为空
  410. function noTitleImg() {
  411. var ImageKey = $("#uploader").attr("data-id");
  412. var newstitle = $("#newstitle").val();
  413. if(ImageKey == "") {
  414. $.MsgBox.Alert('提示', '请上传封面图片');
  415. return;
  416. } else {
  417. $(".imgtis").text("");
  418. imgflase = true;
  419. }
  420. if(newstitle == "") {
  421. $.MsgBox.Alert('提示', '请输入文章标题');
  422. return;
  423. } else {
  424. $("#aboutTit span").text("");
  425. titleflase = true;
  426. }
  427. }
  428. //获取相关专家
  429. function expertli() {
  430. experarray=[];
  431. $("#expertli li").each(function(i) {
  432. var liid = $(this).attr("data-id");
  433. experarray.push(liid);
  434. });
  435. return $.unique(experarray);
  436. }
  437. //获取相关资源
  438. function resourcesli() {
  439. resourcesarray=[];
  440. $("#resources li").each(function(i) {
  441. var liid = $(this).attr("data-id");
  442. resourcesarray.push(liid);
  443. });
  444. return $.unique(resourcesarray);
  445. }
  446. function seli() {
  447. var arr=[];
  448. $("#sevriceli li").each(function(i) {
  449. var liid = $(this).attr("data-id");
  450. arr.push(liid);
  451. });
  452. return $.unique(arr);
  453. }
  454. function productli() {
  455. var arr=[];
  456. $("#productli li").each(function(i) {
  457. var liid = $(this).attr("data-id");
  458. arr.push(liid);
  459. });
  460. return $.unique(arr);
  461. }
  462. function fileArrli() {
  463. var arr=[];
  464. $("#fileAttachList li").each(function(i){
  465. var liid = $(this).attr("data-id"),
  466. liurl = $(this).attr("data-url")
  467. liname = $(this).attr("data-name"),
  468. lisize = $(this).attr("data-size");
  469. var item
  470. item=liurl+','+i+','+lisize+','+liname;
  471. arr.push(item)
  472. })
  473. return $.unique(arr);
  474. }
  475. var seleClum ='<div class="mb-list mb-listL"><p>请选择文章发布的栏目:</p>'+
  476. '<select class="form-control form-column" id="seletColum"></select></div>';
  477. var seleTime = '<div class="mb-list mb-listR"><p class="msg-tit">请设置文章发布的时间:</p>'+
  478. '<div style="position:relative"><div class="input-append date form_date form_datetime" data-link-field="dtp_input2" >'+
  479. '<em class="mr_sj"></em>'+
  480. '<input size="16" type="text" readonly class="frmtype frmcontype fColor" placeholder="请设置文章发布的时间">'+
  481. '<span class="dateIcon"><i class="icon-calendar displayNone"></i></span>'+
  482. '<span class="add-on"><i class="icon-th displayNone"></i></span>'+
  483. '</div>'+
  484. '<input type="hidden" id="dtp_input2"/>'+
  485. '<span></span></div></div>';
  486. var a = new Date();
  487. var c = a.getFullYear() + "-" + (Number(a.getMonth()) + 1) + "-" + (Number(a.getDate()));
  488. //文章发布
  489. $("#release").on("click", function() {
  490. if($(this).hasClass("disableLi")){
  491. return;
  492. }
  493. noTitleImg();
  494. if(imgflase && titleflase) {
  495. if(colMgr){
  496. $(".blackcover2").fadeIn();
  497. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkpub" type="button" value="确定">'
  498. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  499. $(".modelContain").show(); $("body").addClass("modelOpen");
  500. $(".mb-listR").remove();
  501. $(".mb-listL").remove();
  502. $("#promotTh").prepend(seleClum);
  503. fillColum(7);//填充select栏目
  504. $(".mb_btnOkpub").on("click", function() {
  505. $(".blackcover2").fadeOut();
  506. $(".modelContain").hide();
  507. $("body").removeClass("modelOpen");
  508. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  509. })
  510. }else{
  511. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  512. }
  513. }
  514. })
  515. //定时文章发布
  516. $("#setTimeIssue").on("click", function() {
  517. if($(this).hasClass("disableLi")){
  518. return;
  519. }
  520. noTitleImg();
  521. if(imgflase && titleflase) {
  522. $(".blackcover2").fadeIn();
  523. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkset" type="button" value="确定">'
  524. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  525. $(".modelContain").show(); $("body").addClass("modelOpen");
  526. $(".mb-listR").remove(); $("#promotTh").append(seleTime);//时间选择器
  527. $(".mb-listR .form_datetime").datetimepicker({
  528. language: 'ch',
  529. format: 'yyyy-mm-dd hh:ii',
  530. forceParse: 1,
  531. autoclose: 1,
  532. todayBtn: 1,
  533. todayHighlight: 1,
  534. startDate: c,
  535. oflag: 1,
  536. });
  537. $(".mb-listR .form_datetime .frmcontype").val(getNowFormatDate());
  538. if(colMgr){
  539. $(".mb-listL").remove();
  540. $("#promotTh").prepend(seleClum);
  541. fillColum(7);//填充select栏目
  542. }
  543. $(".mb_btnOkset").on("click", function() {
  544. var publishTime = $(".mb-listR .form_datetime .frmcontype").val();
  545. console.log(st6(publishTime));
  546. setTimeIssue(st6(publishTime));
  547. })
  548. }
  549. })
  550. //文章存草稿
  551. $("#draft").on("click", function() {
  552. if($(this).hasClass("disableLi")){
  553. return;
  554. }
  555. noTitleImg();
  556. if(imgflase && titleflase) {
  557. draftAdd(1);
  558. }
  559. })
  560. //文章预览
  561. $("#preview").on("click", function() {
  562. if($(this).hasClass("disableLi")){
  563. return;
  564. }
  565. noTitleImg();
  566. if(imgflase && titleflase) {
  567. draftAdd(2);
  568. }
  569. })
  570. function getAttrId() {
  571. var arr=[];
  572. this.each(function(){
  573. arr.push( $(this).attr("data-id"));
  574. });
  575. return arr;
  576. }
  577. /*获取数据*/
  578. function getdata(publishTime) {
  579. var industrys = $("#keyWordlist li");
  580. var industryAll = "";
  581. if(industrys.size() > 0) {
  582. for(var i = 0; i < industrys.size(); i++) {
  583. industryAll += industrys[i].innerText.trim();
  584. industryAll += ',';
  585. };
  586. industryAll = industryAll.substring(0, industryAll.length - 1);
  587. }
  588. expertli(); //相关专家
  589. resourcesli(); //相关咨询
  590. $data.ownerId = orgId;
  591. $data.articleType = "2";
  592. if($("#companys li").length) {
  593. $data.orgs = getAttrId.call($("#companys li"));
  594. }
  595. $data.articleTitle = $("#newstitle").val();
  596. $data.subject = industryAll;
  597. $data.articleImg = $("#uploader").attr("data-id");
  598. $data.articleContent = ue.getContent();
  599. $data.professors = experarray;
  600. $data.resources = resourcesarray;
  601. $data.wares=seli();
  602. $data.products=productli();
  603. if(colMgr){
  604. $data.colNum = $("#seletColum").val();
  605. if(publishTime!="") {
  606. $data.publishTime = publishTime;
  607. }
  608. $data.files=fileArrli();
  609. }else{
  610. if(publishTime!="") {
  611. $data.publishTime = publishTime;
  612. }
  613. $data.colNum=2;
  614. }
  615. if($("#hidearticleId").val().length != 0) {
  616. $data.articleId = $("#hidearticleId").val();
  617. }
  618. console.log($data);
  619. }
  620. /*文章发布*/
  621. function newsAdd() {
  622. getdata();
  623. $(".operateBlock").find("li").addClass("disableLi");
  624. $.ajax({
  625. "url": "/ajax/article/save",
  626. "type": "post",
  627. "dataType": "json",
  628. "data": $data,
  629. "traditional": true, //传数组必须加这个
  630. "complete":function(){
  631. $(".operateBlock").find("li").removeClass("disableLi");
  632. },
  633. "success": function(data) {
  634. console.log(data);
  635. if(data.success) {
  636. $("#hidearticleId").val(data.data);
  637. $.MsgBox.Alert("提示", "文章发表成功!", function articalList() {
  638. location.href = "cmp-articalList.html";
  639. });
  640. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  641. } else {
  642. if(data.code==90) {
  643. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  644. }else{
  645. $.MsgBox.Alert("提示", "文章发表失败!");
  646. }
  647. }
  648. },
  649. "error": function() {
  650. $.MsgBox.Alert('提示', '链接服务器超时')
  651. }
  652. });
  653. }
  654. /*文章定时发布*/
  655. function setTimeIssue(publishTime) {
  656. var opublishTime=publishTime+"01";
  657. getdata(opublishTime);
  658. $(".operateBlock").find("li").addClass("disableLi");
  659. $.ajax({
  660. "url": "/ajax/article/timing",
  661. "type": "post",
  662. "dataType": "json",
  663. "data": $data,
  664. "traditional": true, //传数组必须加这个
  665. "complete":function(){
  666. $(".operateBlock").find("li").removeClass("disableLi");
  667. },
  668. "success": function(data) {
  669. console.log(data);
  670. if(data.success) {
  671. $("#hidearticleId").val(data.data);
  672. location.href = "cmp-articalList.html";
  673. } else {
  674. if(data.code==90) {
  675. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  676. }else{
  677. $.MsgBox.Alert("提示", "文章发表失败!");
  678. }
  679. }
  680. },
  681. "error": function() {
  682. $.MsgBox.Alert('提示', '链接服务器超时')
  683. }
  684. });
  685. }
  686. /*文章添加草稿和文章预览*/
  687. function draftAdd(num) {
  688. getdata();
  689. $(".operateBlock").find("li").addClass("disableLi");
  690. $.ajax({
  691. "url": "/ajax/article/draft",
  692. "type": "post",
  693. "dataType": "json",
  694. "data": $data,
  695. "traditional": true, //传数组必须加这个
  696. "complete":function(){
  697. $(".operateBlock").find("li").removeClass("disableLi");
  698. },
  699. "success": function(data) {
  700. console.log(data);
  701. if(num == 1) {
  702. if(data.success) {
  703. $("#hidearticleId").val(data.data);
  704. articleId = data.data;
  705. $.MsgBox.Alert("提示", "文章已保存草稿。");
  706. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  707. $("#delete").removeClass("disableLi").addClass("odele");
  708. }else{
  709. if(data.code==90) {
  710. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  711. }else{
  712. $.MsgBox.Alert("提示", "文章保存草稿失败!");
  713. }
  714. }
  715. }
  716. if(num == 2) {
  717. var fa=false;
  718. if(data.success) {
  719. $("#hidearticleId").val(data.data);
  720. articleId = data.data;
  721. $("#delete").removeClass("disableLi").addClass("odele");
  722. fa = true;
  723. }else{
  724. if(data.code==90) {
  725. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  726. }else{
  727. $.MsgBox.Alert("提示", "文章预览失败!");
  728. }
  729. }
  730. if(fa) {
  731. window.open("../articalPreview.html?articleId=" + articleId)
  732. }
  733. }
  734. },
  735. "error": function() {
  736. $.MsgBox.Alert('提示', '链接服务器超时')
  737. }
  738. });
  739. }
  740. function st6(osr) {
  741. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) + osr.substring(11, 13) + osr.substring(14, 16);
  742. return tim;
  743. }
  744. /*删除文章*/
  745. $(".operateBlock").on("click",".odele",function(){
  746. $.MsgBox.Confirm("提示","确认删除该文章?",newsDelet);
  747. })
  748. /*文章删除*/
  749. function newsDelet() {
  750. $.ajax({
  751. "url" : "/ajax/article/deleteArticle",
  752. "type" : "POST",
  753. "dataType" : "json",
  754. "data": {
  755. "articleId": articleId
  756. },
  757. "success" : function($data) {
  758. if ($data.success) {
  759. location.href = "cmp-articalList.html";
  760. }
  761. },
  762. "error":function(){
  763. $.MsgBox.Alert('提示','链接服务器超时')
  764. }
  765. })
  766. }
  767. relatCompanies("#company");
  768. /*添加相关企业*/
  769. function relatCompanies(sel) {
  770. $(sel).bind({
  771. paste: function(e) {
  772. var pastedText;
  773. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  774.             
  775. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  776. else  {            
  777. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  778.           
  779. }
  780. $(this).val(pastedText);
  781. e.preventDefault();
  782. },
  783. cut: function(e) {
  784. var $this = $(this);
  785. },
  786. blur: function() {
  787. var $this = $(this);
  788. $(this).siblings(".aboutTit").find("span").text("");
  789. setTimeout(function() {
  790. $this.siblings(".form-drop").hide();
  791. }, 500)
  792. },
  793. focus: function() {
  794. $(this).siblings(".form-drop").show();
  795. $(this).siblings(".aboutTit").find("span").text("最多选择5家企业");
  796. },
  797. keyup: function(e) {
  798. var ti=$(this).val();
  799. orgr=ti;
  800. var $this=$(this);
  801. if($(this).val().trim()) {
  802. var lNum = $.trim($(this).val()).length;
  803. if(0 < lNum) {
  804. setTimeout(function(){
  805. if( ti===orgr && ti!== orgrEnd) {
  806. var tt=ti;
  807. orgrEnd=tt;
  808. $("#companylist").parent().show();
  809. $.ajax({
  810. "url": "/ajax/org/qr",
  811. "type": "GET",
  812. "data":{
  813. kw: $this.val(),
  814. limit:3
  815. },
  816. "success": function(data) {
  817. console.log(data);
  818. if(data.success) {
  819. if(orgrEnd==tt) {
  820. if(data.data.length == 0) {
  821. $this.parent().removeClass("displayNone");
  822. var itemlist = '<div class="null-data">没有找到相关企业</div>'
  823. $("#companylist").html(itemlist);
  824. } else {
  825. $this.siblings(".form-drop").removeClass("displayNone");
  826. var oSr = "";
  827. for(var i = 0; i < data.data.length; i++) {
  828. var busName=(data.data[i].forShort)?data.data[i].forShort:data.data[i].name;
  829. oSr += '<li style="min-height:40px;position:static;"data-id="'+data.data[i].id+'">' + busName + '</li>';
  830. }
  831. $this.siblings(".form-drop").find("ul").html(oSr);
  832. }
  833. }
  834. } else {
  835. $this.siblings(".form-drop").addClass("displayNone");
  836. $this.siblings(".form-drop").find("ul").html("");
  837. }
  838. },
  839. dataType: "json"
  840. });
  841. }
  842. },500)
  843. }
  844. } else {
  845. $(this).siblings(".form-drop").addClass("displayNone");
  846. $(this).siblings(".form-drop").find("ul").html("");
  847. }
  848. }
  849. })
  850. $("#company").siblings(".form-drop").on("click", "li", function() {
  851. var oValue = $(this).text();
  852. var oJudge = $(this).parents(".form-drop").siblings(".form-result").find("ul li");
  853. for(var i = 0; i < oJudge.length; i++) {
  854. if(oValue == oJudge[i].innerText) {
  855. $.MsgBox.Alert('提示', '该企业已选择.');
  856. return;
  857. }
  858. }
  859. $(this).parents(".form-drop").siblings(".form-result").find("ul").append('<li class="ellipsisSty" style="min-height:40px;padding-right:42px;" data-id="'+$(this).attr("data-id")+'">' + oValue + '<div class="deleteThis"></div></li>');
  860. $(this).parents(".form-drop").siblings("input").val("");
  861. if(oJudge.length == 4) {
  862. $(this).parents(".form-drop").siblings("input").val("");
  863. $("#company").hide();
  864. }
  865. $(this).parent("ul").html("")
  866. })
  867. }
  868. });