portal html css js resource

newsciresource.js 10KB

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