portal html css js resource

articalModify.js 29KB

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