portal html css js resource

newsciresource.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. $(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. loginStatus();//判断个人是否登录
  4. var userid = $.cookie("userid");
  5. var name = $.cookie("userName");
  6. var flag;
  7. ////发布资源发布及修改
  8. var resourceNamePass = true;
  9. //var professorPass=true;
  10. var supportedServicesPass = true;
  11. function resourceName() {
  12. var code = $("#resourceName").val();
  13. if(code.length == 0 || code == " ") {
  14. $(".workmsg1").text("发布资源名称不能为空");
  15. resourceNamePass = false;
  16. } else {
  17. $(".workmsg1").text("");
  18. resourceNamePass = true;
  19. }
  20. }
  21. $("#resourceName").blur(function() {
  22. resourceName();
  23. });
  24. //验证可提供服务
  25. function supportedServices() {
  26. var code = $("#supportedServices").val();
  27. if(code.length == 0 || code == " ") {
  28. $(".workmsg3").text("可提供服务不能为空");
  29. supportedServicesPass = false;
  30. } else {
  31. $(".workmsg3").text("");
  32. supportedServicesPass = true;
  33. }
  34. }
  35. $("#supportedServices").blur(function() {
  36. supportedServices();
  37. });
  38. function industryShow(data, industryList, deleteIndustry) {
  39. if(data != undefined && data.length != 0) {
  40. var subs = new Array();
  41. if(data.indexOf(',')) {
  42. subs = data.split(',');
  43. } else {
  44. subs[0] = data;
  45. }
  46. if(subs.length > 0) {
  47. for(var i = 0; i < subs.length; i++) {
  48. $("#" + industryList + "").append("<div class='" + deleteIndustry + "'><em>" + subs[i] + "</em><span class='removeNu'><img src='images/move.png'></span></div>");
  49. };
  50. }
  51. }
  52. }
  53. //添加或者删除应用行业及学术领域
  54. function addDele() {
  55. $("#industryList").on("click", ".removeNu", function() {
  56. $(this).parent().remove();
  57. });
  58. $("#industryAdd").click(function() {
  59. var val = $("#industry").val();
  60. if(!val.trim()) {
  61. $(".workmsg5").text("请填写应用行业");
  62. return;
  63. } else {
  64. $(".workmsg5").text("");
  65. }
  66. var vallist1 = $("#industryList .deleteIndustry em");
  67. for(var i = 0; i < vallist1.length; i++) {
  68. if(vallist1[i].innerText == val) {
  69. $(".workmsg5").text("不能添加重复内容");
  70. return;
  71. }
  72. }
  73. $("#industryList").append("<div class='deleteIndustry'><em>" + val + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
  74. $("#industry").val("");
  75. });
  76. $("#SubjectList").on("click", ".removeNu", function() {
  77. $(this).parent().remove();
  78. });
  79. $("#subjectAdd").click(function() {
  80. var va = $("#subject").val();
  81. if(!va.trim()) {
  82. $(".workmsg4").text("请填写学术领域");
  83. return;
  84. } else {
  85. $(".workmsg4").text("");
  86. }
  87. var vallist2 = $("#SubjectList .deleteSubject em");
  88. for(var i = 0; i < vallist2.length; i++) {
  89. if(vallist2[i].innerText == va) {
  90. $(".workmsg4").text("不能添加重复内容");
  91. return;
  92. }
  93. }
  94. $("#SubjectList").append("<div class='deleteSubject'><em>" + va + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
  95. $("#subject").val("");
  96. });
  97. }
  98. //我的资源的删除,修改
  99. $("#workmysrc").on("click", ".resoumag", function() {
  100. //初始引用编辑器
  101. ResourceInfo();
  102. addDele();
  103. $(".limitBox").removeClass("limitBox");
  104. $(".limitwords").removeClass("limitwords");
  105. $(".limitwordbox").removeClass("limitwordbox");
  106. $(".respublisher").css("display", "none");
  107. $(".stateinfor span").text("资源发布中");
  108. var resourceID = $(this).attr("resourceId");
  109. function delet() {
  110. $.ajax({
  111. "url": "/ajax/resource/" + resourceID,
  112. "type": "DELETE",
  113. "success": function($data) {
  114. if($data.success) {
  115. $(".blackcover").remove();
  116. $("body").css("position", "");
  117. getDataResource();
  118. UE.delEditor('editor');
  119. } else {
  120. $.MsgBox.Alert('message', $data.msg);
  121. }
  122. }
  123. })
  124. }
  125. if(resourceID) {
  126. $("#deletedResource").on("click", function() {
  127. $("body").css("position", "");
  128. $.MsgBox.Confirm("消息", "执行删除后资源信息将无法恢复,确定继续吗?", delet)
  129. })
  130. $.ajax({
  131. "url": "/ajax/resource/" + resourceID,
  132. "type": "get",
  133. "async": false,
  134. "success": function(info) {
  135. if(info.success) {
  136. //console.log(info);
  137. $("#resourceName").val(info.data.resourceName);
  138. $("#supportedServices").val(info.data.supportedServices);
  139. $("#hopePayMethod").val(info.data.hopePayMethod);
  140. $("#cooperationNotes").val(info.data.cooperationNotes);
  141. industryShow(info.data.subject, "SubjectList", "deleteSubject");
  142. industryShow(info.data.industry, "industryList", "deleteIndustry");
  143. ue.ready(function() {
  144. if(info.data.descp == undefined) {
  145. var datadescp = "";
  146. } else {
  147. var datadescp = info.data.descp;
  148. }
  149. ue.setContent(datadescp);
  150. });
  151. $("#professor").text(name);
  152. if(info.data.images.length) {
  153. var $liMages = $(
  154. '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:216px;width:216px;height: 216px;">' +
  155. '<img class="resImg headRadius resourceImg" style="display: inline;" src="/images/resource/' + resourceID + '.jpg">' +
  156. '</div>'
  157. )
  158. } else {
  159. var $liMages = $(
  160. '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:216px;width:216px;height: 216px;">' +
  161. '<img class="resImg headRadius resourceImg" style="display: inline;" src="/images/default-resource.jpg">' +
  162. '</div>'
  163. )
  164. }
  165. $("#fileList").append($liMages);
  166. $(".upbox").css({
  167. "marginTop": "0px"
  168. });
  169. $("#deletedResource").show();
  170. } else {
  171. $.MsgBox.Alert('message', "系统异常!");
  172. }
  173. },
  174. "error": function() {
  175. $.MsgBox.Alert('message', 'failed')
  176. }
  177. });
  178. }
  179. function captiureSubInd(subIndu) {
  180. var industrys = $("#" + subIndu + "");
  181. var industryAll = "";
  182. if(industrys.size() > 0) {
  183. for(var i = 0; i < industrys.size(); i++) {
  184. industryAll += industrys[i].innerText;
  185. industryAll += ',';
  186. };
  187. industryAll = industryAll.substring(0, industryAll.length - 1);
  188. }
  189. return industryAll;
  190. }
  191. $("#inputb").on("click", function() {
  192. var $data = {};
  193. $data.resourceName = $("#resourceName").val();
  194. $data.supportedServices = $("#supportedServices").val();
  195. $data.professorId = userid;
  196. $data.hopePayMethod = $("#hopePayMethod").val();
  197. $data.cooperationNotes = $("#cooperationNotes").val();
  198. $data.subject = captiureSubInd("SubjectList .deleteSubject");
  199. $data.industry = captiureSubInd("industryList .deleteIndustry");
  200. $data.descp = ue.getContent();
  201. if(cacheImageKey) {
  202. //console.log(cacheImageKey);
  203. $data.fn = cacheImageKey;
  204. }
  205. if(resourceID) {
  206. $data.resourceId = resourceID;
  207. }
  208. //console.log($data);
  209. function getDataput() {
  210. $.ajax({
  211. "url": "ajax/resource/updateResource",
  212. "type": "post",
  213. "success": function(rdata) {
  214. //console.log(rdata);
  215. if(rdata.success) {
  216. getDataResource();
  217. $(".blackcover").remove();
  218. UE.delEditor('editor');
  219. } else {
  220. $.MsgBox.Alert("消息", "资源发布失败");
  221. }
  222. },
  223. "data": $data,
  224. "beforeSend": function() { /*console.log(this.data)*/ },
  225. "contentType": "application/x-www-form-urlencoded",
  226. dataType: "json"
  227. });
  228. }
  229. //console.log($data);
  230. resourceName();
  231. // professor();
  232. supportedServices();
  233. if(resourceNamePass && supportedServicesPass) {
  234. if(resourceID) {
  235. //$(".blackcover").remove();
  236. $("body").css("position", "");
  237. $.MsgBox.Confirm("消息", "确定修改资源信息吗?", getDataput)
  238. $data.fn = cacheImageKey;
  239. } else {
  240. $.ajax({
  241. "url": "/ajax/resource",
  242. "type": "POST",
  243. "success": function(rdata) {
  244. if(rdata.success) {
  245. $(".blackcover").remove();
  246. $("body").css("position", "");
  247. getDataResource();
  248. $.MsgBox.Alert("消息", "资源发布成功");
  249. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  250. UE.delEditor('editor');
  251. } else {
  252. $.MsgBox.Alert("消息", "资源发布失败");
  253. }
  254. },
  255. "data": $data,
  256. "beforeSend": function() { /*console.log(this.data)*/ },
  257. "contentType": "application/x-www-form-urlencoded",
  258. dataType: "json"
  259. });
  260. }
  261. }
  262. });
  263. });
  264. getDataResource();
  265. function getDataResource() {
  266. $.ajax({
  267. "url": "/ajax/resource/qapro",
  268. "type": "get",
  269. "async": true,
  270. "data": {
  271. "professorId": userid
  272. },
  273. "beforeSend": function() {
  274. $("#consd").append('<img src="../images/loading.gif" class="loading" />');
  275. },
  276. "success": function(data) {
  277. if(data.success) {
  278. var add = '';
  279. var k = 0;
  280. $("#consd").html("");
  281. var addbut = ' <div class="addworkbtn resoumag" ></div>';
  282. $("#consd").append(addbut);
  283. for(var i = 0; i < data.data.length; i++) {
  284. var add = '<div class="addworkbtn-list"> <div class="resoumag">'
  285. add += '<div class="ResImgBox" style="max-width:216px;width:216px;height: 216px;"><img class="resImg headRadius resourceImg" src="" /></div>'
  286. add += '<h2>' + data.data[i].resourceName + '</h2>'
  287. add += '<p>' + data.data[i].supportedServices + '</p>'
  288. add += '</div></div>';
  289. $add = $(add);
  290. $("#consd").append($add);
  291. if(data.data[i].subject == undefined) {
  292. $(".li1").eq(i).css({
  293. "display": "none"
  294. });
  295. }
  296. $add.find('.resoumag').attr("resourceId", data.data[i].resourceId);
  297. //$('.resoumag').eq(i+1).attr("resourceId",data.data[i].resourceId);
  298. if(data.data[i].images.length) {
  299. $add.find(".resourceImg").attr("src", "/images/resource/" + data.data[i].resourceId + ".jpg");
  300. } else {
  301. $add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
  302. }
  303. add = "";
  304. $(".loading").remove();
  305. }
  306. } else {
  307. $.MsgBox.Alert('message', "系统异常!");
  308. }
  309. },
  310. "error": function() {
  311. $.MsgBox.Alert('message', 'failed')
  312. }
  313. });
  314. }
  315. });