portal html css js resource

articalModify.js 28KB

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