portal html css js resource

articalIssue.js 25KB

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