portal html css js resource

news-list.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. $(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. loginStatus();//判断个人是否登录
  4. var userid = $.cookie("userid");
  5. var articleId;
  6. newslist();//科研新闻列表
  7. $("#workmysrc").on("click", ".newsadd", function() {
  8. newsBombBox();//插入弹框
  9. addDele();//编辑学术领域和应用行业
  10. $("#inputb").on("click", function() {
  11. if($("#newsName").val()!=""){
  12. newsAdd();
  13. }else{
  14. $(".workmsg1").text("发布文章名称不能为空");
  15. }
  16. });
  17. });
  18. $("#workmysrc").on("click", ".resoumag", function() {
  19. articleId = $(this).attr("data-title");
  20. newsBombBox();//插入弹框
  21. addDele();//编辑学术领域和应用行业
  22. modifyDisplay();
  23. $("#inputb").on("click", function() {
  24. if($("#newsName").val()!=""){
  25. $.MsgBox.Confirm("消息", "确定修改文章信息吗?", newsModify)
  26. }else{
  27. $(".workmsg1").text("发布文章名称不能为空");
  28. }
  29. });
  30. });
  31. /*科研新闻列表*/
  32. function newslist() {
  33. $.ajax({
  34. "url": "/ajax/article/qaPro",
  35. "type": "get",
  36. "async": true,
  37. "data": {
  38. "professorId": userid
  39. },
  40. "beforeSend": function() {
  41. $("#newsbox").append('<img src="../images/loading.gif" class="loading" />');
  42. },
  43. "success": function(data) {
  44. //console.log(data);
  45. if(data.success) {
  46. var add = '';
  47. $("#newsbox").html("");
  48. var addbut = ' <div class="addworkbtn newsadd" ></div>';
  49. $("#newsbox").append(addbut);
  50. for(var i = 0; i < data.data.length; i++) {
  51. var add = '<div class="addworkbtn-list addworkbtn-list2" ><div class="resoumag" data-title="">'
  52. add += '<div class="art_topicBox art_topicBox2"><div class="art_img" style=""></div>'
  53. add += '<div class="art_tbox"><h6 id="artical_topic" >'+ data.data[i].articleTitle + '</h6></div>'
  54. add += '</div><div class="tagsBox"><span></span></div>'
  55. add += '</div></div>';
  56. $add = $(add);
  57. $("#newsbox").append($add);
  58. $add.find('.resoumag').attr("data-title", data.data[i].articleId);
  59. $add.find('.tagsBox span').text(data.data[i].industry);
  60. if(data.data[i].articleImg) {
  61. $add.find(".art_img").attr("style", "background: url(/data/article/"+data.data[i].articleImg+") center center no-repeat;background-size:cover;");
  62. }
  63. $(".loading").remove();
  64. }
  65. } else {
  66. $.MsgBox.Alert('message', "系统异常!");
  67. }
  68. },
  69. "error": function() {
  70. $.MsgBox.Alert('message', 'failed')
  71. }
  72. });
  73. }
  74. /*科研新闻添加*/
  75. function newsAdd(){
  76. var $data = {};
  77. $data.professorId = userid;
  78. $data.articleTitle = $("#newsName").val();
  79. $data.subject = captiureSubInd("SubjectList .deleteSubject");
  80. $data.industry = captiureSubInd("industryList .deleteIndustry");
  81. $data.articleContent = ue.getContent();
  82. if(cacheImageKey) {
  83. $data.articleImg = cacheImageKey;
  84. }
  85. $.ajax({
  86. "url" : "/ajax/article",
  87. "type" : "post" ,
  88. "dataType" : "json",
  89. "data" :$data,
  90. "success" : function(data) {
  91. //console.log(data);
  92. if (data.success){
  93. newsname = data.data;
  94. //console.log(newsname);
  95. $.MsgBox.Alert("消息","文章发表成功!");
  96. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  97. newslist();
  98. $(".blackcover").remove();
  99. UE.delEditor('editor');
  100. } else {
  101. $.MsgBox.Alert("消息","文章发表失败!");
  102. }
  103. },
  104. "error":function(){
  105. $.MsgBox.Alert('消息','链接服务器超时')
  106. }
  107. });
  108. }
  109. /*科研新闻修改回显内容*/
  110. function modifyDisplay(){
  111. $.ajax({
  112. "url" : "/ajax/article/query",
  113. "type" : "GET",
  114. "dataType" : "json",
  115. "data": {
  116. "articleId": articleId
  117. },
  118. "success" : function($data) {
  119. //console.log($data);
  120. if ($data.success) {
  121. $("#newsName").val($data.data.articleTitle);
  122. industryShow($data.data.subject,"SubjectList","deleteSubject");
  123. industryShow($data.data.industry,"industryList","deleteIndustry");
  124. ue.ready(function() {
  125. if($data.data.articleContent==undefined){
  126. var datadescp ="";
  127. }else{
  128. var datadescp = $data.data.articleContent;
  129. }
  130. ue.setContent(datadescp);
  131. });
  132. if($data.data.articleImg) {
  133. var $liMages = $(
  134. '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:226px;width:226px;height: 226px;">'+
  135. '<img class="resImg headRadius resourceImg" style="display: inline;" src="data/article/'+$data.data.articleImg+'">'+
  136. '</div>'
  137. )
  138. }else{
  139. var $liMages = $(
  140. '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:226px;width:226px;height: 226px;">'+
  141. '<img class="resImg headRadius resourceImg" style="display: inline;" src="/images/default-artical.jpg">'+
  142. '</div>'
  143. )
  144. }
  145. $("#fileList").append($liMages);
  146. }
  147. },
  148. "error":function(){
  149. $.MsgBox.Alert('消息','链接服务器超时')
  150. }
  151. })
  152. $("#deletedResource").show();
  153. //$.MsgBox.Confirm("消息", "确定修改文章信息吗?", newsAdd())
  154. $("#deletedResource").on("click", function() {
  155. $.MsgBox.Confirm("消息", "执行删除后文章信息将无法恢复,确定继续吗?",newsDelet)
  156. });
  157. }
  158. /*科研新闻修改*/
  159. function newsModify() {
  160. var $data = {};
  161. $data.articleId = articleId;
  162. $data.articleTitle = $("#newsName").val();
  163. $data.subject = captiureSubInd("SubjectList .deleteSubject");
  164. $data.industry = captiureSubInd("industryList .deleteIndustry");
  165. $data.articleContent = ue.getContent();
  166. if(cacheImageKey) {
  167. $data.articleImg = cacheImageKey;
  168. }
  169. //console.log($data);
  170. $.ajax({
  171. "url" : "/ajax/article/updateArt",
  172. "type" : "POST",
  173. "dataType" : "json",
  174. "data" :$data,
  175. "success" : function($data) {
  176. //console.log($data);
  177. if ($data.success) {
  178. newslist();
  179. $(".blackcover").remove();
  180. UE.delEditor('editor');
  181. }
  182. },
  183. "error":function(){
  184. $.MsgBox.Alert('消息','链接服务器超时')
  185. }
  186. })
  187. $("#deletedResource").show();
  188. //$.MsgBox.Confirm("消息", "确定修改文章信息吗?", newsAdd())
  189. $("#deletedResource").on("click", function() {
  190. $.MsgBox.Confirm("消息", "执行删除后文章信息将无法恢复,确定继续吗?",newsDelet)
  191. });
  192. }
  193. /*科研新闻删除*/
  194. function newsDelet() {
  195. $.ajax({
  196. "url" : "/ajax/article/delete",
  197. "type" : "POST",
  198. "dataType" : "json",
  199. "data": {
  200. "articleId": articleId
  201. },
  202. "success" : function($data) {
  203. if ($data.success) {
  204. $(".blackcover").remove();
  205. UE.delEditor('editor');
  206. newslist();
  207. }
  208. },
  209. "error":function(){
  210. $.MsgBox.Alert('消息','链接服务器超时')
  211. }
  212. })
  213. }
  214. //组合应用行业及学术领域
  215. function captiureSubInd(subIndu) {
  216. var industrys = $("#" + subIndu + "");
  217. var industryAll = "";
  218. if(industrys.size() > 0) {
  219. for(var i = 0; i < industrys.size(); i++) {
  220. industryAll += industrys[i].innerText;
  221. industryAll += ',';
  222. };
  223. industryAll = industryAll.substring(0, industryAll.length - 1);
  224. }
  225. return industryAll;
  226. }
  227. //拆解应用行业及学术领域
  228. function industryShow(data,industryList,deleteIndustry){
  229. if(data != undefined && data.length != 0 ){
  230. var subs = new Array();
  231. if(data.indexOf(',')){
  232. subs = data.split(',');
  233. }else{
  234. subs[0] = data;
  235. }
  236. if(subs.length>0){
  237. for (var i = 0; i < subs.length; i++)
  238. {
  239. $("#"+industryList+"").append("<div class='"+deleteIndustry+"'>"+ subs[i] +"<span class='removeNu'><img src='images/move.png'></span></div>");
  240. };
  241. }
  242. }
  243. }
  244. //添加或者删除应用行业及学术领域
  245. function addDele() {
  246. $("#industryList").on("click", ".removeNu", function() {
  247. $(this).parent().remove();
  248. });
  249. $("#industryAdd").click(function() {
  250. var val = $("#industry").val();
  251. if(val==""){
  252. $(".workmsg4").text("请填写应用行业");
  253. return;
  254. }
  255. var vallist = $("#industryList .deleteIndustry em");
  256. for(var i=0;i<vallist.length;i++){
  257. if(vallist[i].innerText==val){
  258. $(".workmsg4").text("不能添加重复内容");
  259. return;
  260. }
  261. }
  262. $("#industryList").append("<div class='deleteIndustry'><em>" + val + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
  263. $("#industry").val("");
  264. $(".workmsg4").text("");
  265. });
  266. $("#SubjectList").on("click", ".removeNu", function() {
  267. $(this).parent().remove();
  268. });
  269. $("#subjectAdd").click(function() {
  270. var val = $("#subject").val();
  271. if(val==""){
  272. $(".workmsg3").text("请填写学术领域");
  273. return;
  274. }
  275. var vallist = $("#SubjectList .deleteSubject em");
  276. for(var i=0;i<vallist.length;i++){
  277. if(vallist[i].innerText==val){
  278. $(".workmsg3").text("不能添加重复内容");
  279. return;
  280. }
  281. }
  282. $("#SubjectList").append("<div class='deleteSubject'><em>" + val + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
  283. $("#subject").val("");
  284. $(".workmsg3").text("");
  285. });
  286. }
  287. });