portal html css js resource

articalModify.js 28KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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 > 3) {
  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": 3
  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": 3
  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>请设置文章发布的时间:</p>'+
  528. '<div class="formTime"><div class="form-group">'+
  529. '<input size="16" type="text" value="" readonly class="form-control form_datetime">'+
  530. '</div></div></div>';
  531. //文章发布
  532. $("#release").on("click", function() {
  533. if($(this).hasClass("disableLi")){
  534. return;
  535. }
  536. noTitleImg();
  537. if(titleflase) {
  538. console.log(colMgr)
  539. if(colMgr=="true"){
  540. $(".blackcover2").fadeIn();
  541. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkpub" type="button" value="确定">'
  542. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  543. $(".modelContain").show(); $("body").addClass("modelOpen");
  544. $(".mb-listR").remove();
  545. $(".mb-listL").remove();
  546. $("#promotTh").prepend(seleClum);
  547. fillColum(7);//填充select栏目
  548. $(".mb_btnOkpub").on("click", function() {
  549. $(".blackcover2").fadeOut();
  550. $(".modelContain").hide();
  551. $("body").removeClass("modelOpen");
  552. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  553. })
  554. }else{
  555. $.MsgBox.Confirm("提示", "确认发布该文章?", newsAdd);
  556. }
  557. }
  558. })
  559. //定时文章发布
  560. $("#setTimeIssue").on("click", function() {
  561. if($(this).hasClass("disableLi")){
  562. return;
  563. }
  564. noTitleImg();
  565. if(titleflase) {
  566. $(".blackcover2").fadeIn();
  567. var btnOk='<input class="mb_btn mb_btnOk mb_btnOkset" type="button" value="确定">'
  568. $(".mb_btnOk").remove(); $("#promotGt").prepend(btnOk);
  569. $(".modelContain").show(); $("body").addClass("modelOpen");
  570. $(".mb-listR").remove(); $("#promotTh").append(seleTime);//时间选择器
  571. $(".mb-listR .form_datetime").datetimepicker({
  572. format: 'yyyy-mm-dd hh:ii',
  573. forceParse: true,
  574. autoclose: true,
  575. });
  576. $(".mb-listR .form_datetime").val(getNowFormatDate());
  577. if(colMgr=="true"){
  578. $(".mb-listL").remove();
  579. $("#promotTh").prepend(seleClum);
  580. fillColum(7);//填充select栏目
  581. }
  582. $(".mb_btnOkset").on("click", function() {
  583. var publishTime = $(".form_datetime").val();
  584. console.log(st6(publishTime));
  585. setTimeIssue(st6(publishTime));
  586. })
  587. }
  588. })
  589. //文章存草稿
  590. $("#draft").on("click",function(){
  591. if($(this).hasClass("disableLi")){
  592. return;
  593. }
  594. noTitleImg();
  595. if(titleflase){
  596. draftAdd(1);
  597. }
  598. })
  599. //文章预览
  600. $("#preview").on("click",function(){
  601. if($(this).hasClass("disableLi")){
  602. return;
  603. }
  604. noTitleImg();
  605. if(titleflase){
  606. draftAdd(2);
  607. }
  608. })
  609. //删除文章
  610. $("#delete").on("click",function(){
  611. $.MsgBox.Confirm("提示","确认删除该文章?",newsDelet);
  612. })
  613. function getAttrId() {
  614. var arr=[];
  615. this.each(function(){
  616. arr.push( $(this).attr("data-id"));
  617. });
  618. return arr;
  619. }
  620. /*获取数据*/
  621. function getdata(publishTime) {
  622. var industrys = $("#keyWordlist li");
  623. var industryAll = "";
  624. if(industrys.size() > 0) {
  625. for(var i = 0; i < industrys.size(); i++) {
  626. industryAll += industrys[i].innerText.trim();
  627. industryAll += ',';
  628. };
  629. industryAll = industryAll.substring(0, industryAll.length - 1);
  630. }
  631. expertli(); //相关专家
  632. resourcesli(); //相关咨询
  633. $data.orgId = orgId;
  634. $data.articleId=articleId;
  635. if($("#companys li").length) {
  636. $data.orgs = getAttrId.call($("#companys li"));
  637. }
  638. $data.articleTitle = $("#newstitle").val();
  639. $data.subject = industryAll;
  640. $data.articleImg = $("#uploader").attr("data-id");
  641. $data.articleContent = ue.getContent();
  642. $data.professors = experarray;
  643. $data.resources = resourcesarray;
  644. $data.wares=seli();
  645. if(colMgr=="true"){
  646. $data.colNum = $("#seletColum").val();
  647. if(publishTime!="") {
  648. $data.publishTime = publishTime;
  649. }
  650. }else{
  651. if(publishTime!="") {
  652. $data.publishTime = publishTime;
  653. }
  654. $data.colNum=2;
  655. }
  656. console.log($data);
  657. }
  658. /*文章添加*/
  659. function newsAdd(){
  660. getdata();
  661. $(".operateBlock").find("li").addClass("disableLi");
  662. $.ajax({
  663. "url" : "/ajax/article/save",
  664. "type" : "post" ,
  665. "dataType" : "json",
  666. "data" :$data,
  667. "traditional": true, //传数组必须加这个
  668. "complete":function(){
  669. $(".operateBlock").find("li").removeClass("disableLi");
  670. },
  671. "success" : function(data) {
  672. console.log(data);
  673. if (data.success){
  674. articleId = data.data;
  675. $.MsgBox.Alert("提示","文章发表成功!",function articalList(){
  676. location.href = "cmp-articalList.html";
  677. });
  678. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  679. } else {
  680. if(data.code==90) {
  681. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  682. }else{
  683. $.MsgBox.Alert("提示", "文章发表失败!");
  684. }
  685. }
  686. },
  687. "error":function(){
  688. $.MsgBox.Alert('提示','链接服务器超时')
  689. }
  690. });
  691. }
  692. /*文章定时发布*/
  693. function setTimeIssue(publishTime,settime) {
  694. var opublishTime=publishTime+"01";
  695. getdata(opublishTime,settime);
  696. $(".operateBlock").find("li").addClass("disableLi");
  697. $.ajax({
  698. "url": "/ajax/article/timing",
  699. "type": "post",
  700. "dataType": "json",
  701. "data": $data,
  702. "traditional": true, //传数组必须加这个
  703. "complete":function(){
  704. $(".operateBlock").find("li").removeClass("disableLi");
  705. },
  706. "success": function(data) {
  707. console.log(data);
  708. if(data.success) {
  709. articleId = data.data;
  710. location.href = "cmp-articalList.html";
  711. } else {
  712. if(data.code==90) {
  713. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  714. }else{
  715. $.MsgBox.Alert("提示", "文章发表失败!");
  716. }
  717. }
  718. },
  719. "error": function() {
  720. $.MsgBox.Alert('提示', '链接服务器超时')
  721. }
  722. });
  723. }
  724. /*文章添加草稿和文章预览*/
  725. function draftAdd(num){
  726. getdata();
  727. $(".operateBlock").find("li").addClass("disableLi");
  728. $.ajax({
  729. "url" : "/ajax/article/draft",
  730. "type" : "post" ,
  731. "dataType" : "json",
  732. "data" :$data,
  733. "traditional": true, //传数组必须加这个
  734. "complete":function(){
  735. $(".operateBlock").find("li").removeClass("disableLi");
  736. },
  737. "success" : function(data) {
  738. console.log(data);
  739. if(num==1){
  740. if (data.success){
  741. articleId = data.data;
  742. $.MsgBox.Alert("提示","文章已保存草稿。");
  743. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  744. articleshow();
  745. }else{
  746. if(data.code==90) {
  747. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  748. }else{
  749. $.MsgBox.Alert("提示", "文章发表失败!");
  750. }
  751. }
  752. }
  753. if(num==2){
  754. if(data.success) {
  755. $("#hidearticleId").val(data.data);
  756. articleId = data.data;
  757. $("#delete").removeClass("disableLi").addClass("odele");
  758. fa = true;
  759. }else{
  760. if(data.code==90) {
  761. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  762. }else{
  763. $.MsgBox.Alert("提示", "文章发表失败!");
  764. }
  765. }
  766. if(fa) {
  767. window.open("../articalPreview.html?articleId=" + articleId)
  768. }
  769. }
  770. },
  771. "error":function(){
  772. $.MsgBox.Alert('提示','链接服务器超时')
  773. }
  774. });
  775. }
  776. /*文章删除*/
  777. function newsDelet() {
  778. $.ajax({
  779. "url" : "/ajax/article/deleteArticle",
  780. "type" : "POST",
  781. "dataType" : "json",
  782. "data": {
  783. "articleId": articleId
  784. },
  785. "success" : function($data) {
  786. if ($data.success) {
  787. location.href = "cmp-articalList.html";
  788. }
  789. },
  790. "error":function(){
  791. $.MsgBox.Alert('提示','链接服务器超时')
  792. }
  793. })
  794. }
  795. function st6(osr) {
  796. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) + osr.substring(11, 13) + osr.substring(14, 16);
  797. return tim;
  798. }
  799. function timeGeshi(otm) {
  800. var otme = otm.substring(0, 4) + "-" + otm.substring(4, 6) + "-" + otm.substring(6, 8) + " " + otm.substring(8, 10)+ ":" + otm.substring(10, 12);
  801. return otme;
  802. }
  803. /*添加相关企业*/
  804. relatCompanies("#company");
  805. /*添加相关企业*/
  806. function relatCompanies(sel) {
  807. $(sel).bind({
  808. paste: function(e) {
  809. var pastedText;
  810. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  811.             
  812. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  813. else  {            
  814. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  815.           
  816. }
  817. $(this).val(pastedText);
  818. e.preventDefault();
  819. },
  820. cut: function(e) {
  821. var $this = $(this);
  822. },
  823. blur: function() {
  824. var $this = $(this);
  825. setTimeout(function() {
  826. $this.siblings(".form-drop").hide();
  827. }, 500)
  828. $(this).siblings(".aboutTit").find("span").text("");
  829. },
  830. focus: function() {
  831. $(this).siblings(".form-drop").show();
  832. $(this).siblings(".aboutTit").find("span").text("最多选择3家企业");
  833. },
  834. keyup: function(e) {
  835. var ti=$(this).val();
  836. orgr=ti;
  837. var $this=$(this);
  838. if($(this).val().trim()) {
  839. var lNum = $.trim($(this).val()).length;
  840. if(0 < lNum) {
  841. setTimeout(function(){
  842. if( ti===orgr && ti!== orgrEnd) {
  843. var tt=ti;
  844. orgrEnd=tt;
  845. $("#companylist").parent().show();
  846. $.ajax({
  847. "url": "/ajax/org/qr",
  848. "type": "GET",
  849. "data":{
  850. kw: $this.val(),
  851. limit:3
  852. },
  853. "success": function(data) {
  854. console.log(data);
  855. if(data.success) {
  856. if(orgrEnd==tt) {
  857. if(data.data.length == 0) {
  858. $this.siblings(".form-drop").addClass("displayNone");
  859. $this.siblings(".form-drop").find("ul").html("");
  860. } else {
  861. $this.siblings(".form-drop").removeClass("displayNone");
  862. var oSr = "";
  863. for(var i = 0; i < data.data.length; i++) {
  864. var busName=(data.data[i].forShort)?data.data[i].forShort:data.data[i].name;
  865. oSr += '<li style="min-height:40px;position:static;"data-id="'+data.data[i].id+'">' + busName + '</li>';
  866. }
  867. $this.siblings(".form-drop").find("ul").html(oSr);
  868. }
  869. }
  870. } else {
  871. $this.siblings(".form-drop").addClass("displayNone");
  872. $this.siblings(".form-drop").find("ul").html("");
  873. }
  874. },
  875. dataType: "json",
  876. 'error': function() {
  877. $.MsgBox.Alert('提示', '服务器连接超时!');
  878. }
  879. });
  880. }
  881. },500)
  882. }
  883. } else {
  884. $(this).siblings(".form-drop").addClass("displayNone");
  885. $(this).siblings(".form-drop").find("ul").html("");
  886. }
  887. }
  888. })
  889. $("#company").siblings(".form-drop").on("click", "li", function() {
  890. var oValue = $(this).text();
  891. var oJudge = $(this).parents(".form-drop").siblings(".form-result").find("ul li");
  892. for(var i = 0; i < oJudge.length; i++) {
  893. if(oValue == oJudge[i].innerText) {
  894. $.MsgBox.Alert('提示', '该企业已选择.');
  895. return;
  896. }
  897. }
  898. $(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>');
  899. $(this).parents(".form-drop").siblings("input").val("");
  900. if(oJudge.length == 4) {
  901. $(this).parents(".form-drop").siblings("input").val("");
  902. $("#company").hide();
  903. }
  904. $(this).parent("ul").html("")
  905. })
  906. }
  907. companylist()
  908. //相关企业
  909. function companylist() {
  910. $.ajax({
  911. url:"/ajax/article/ralateOrg",
  912. dataType: 'json', //数据格式类型
  913. type: 'GET', //http请求类型
  914. data: {
  915. "articleId": articleId,
  916. },
  917. timeout: 10000, //超时设置
  918. success: function(data) {
  919. if(data.success) {
  920. var $data=data.data;
  921. if($data.length>=5) {
  922. $("#company").hide();
  923. }
  924. for(var i=0;i<$data.length;i++) {
  925. angleBus.call($data[i])
  926. }
  927. }
  928. },
  929. error: function() {
  930. $.MsgBox.Alert('提示', '服务器请求失败')
  931. }
  932. });
  933. }
  934. function angleBus() {
  935. $.ajax({
  936. url: "/ajax/org/" +this.orgId,
  937. type: "GET",
  938. timeout: 10000,
  939. dataType: "json",
  940. context: $("#companys"),
  941. success: function(data) {
  942. if(data.success) {
  943. var oValue=data.data.forShort?data.data.forShort:data.data.name;
  944. this.append('<li class="ellipsisSty" style="min-height:40px;padding-right:42px;" data-id="'+data.data.id+'">' + oValue + '<div class="deleteThis"></div></li>')
  945. }
  946. },
  947. error: function(XMLHttpRequest, textStats, errorThrown) {
  948. $.MsgBox.Alert('提示', '服务器请求失败')
  949. }
  950. })
  951. }
  952. });