portal html css js resource

articalModify.js 29KB

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