portal html css js resource

articalIssue.js 26KB

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