portal html css js resource

resourceList.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. $(document).ready(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. $(".workmenu>ul>li.resIcon").addClass("nowLi");
  4. var orgId = $.cookie('orgId');
  5. if(orgId == "" || orgId == null || orgId == "null") {
  6. location.href = "cmp-settled-log.html";
  7. }
  8. var resourceId;
  9. $(".issueSpan").click(function(e){
  10. UnauthorizedUser()
  11. e.preventDefault();
  12. })
  13. function UnauthorizedUser() {
  14. $.ajax({
  15. url: "/ajax/professor/qaOrgAuth",
  16. type: "GET",
  17. timeout: 10000,
  18. dataType: "json",
  19. async:"true",
  20. data: {
  21. "orgId": orgId,
  22. "orgAuth": 1
  23. },
  24. success: function(data, textState) {
  25. if(data.success) {
  26. if(data.data.length==0) {
  27. $.MsgBox.Confirm("提示", "请至少认证1位员工?", function(){
  28. location.href="cmp-staffList.html";
  29. });
  30. $("#mb_btn_no").val("稍后再说");
  31. $("#mb_btn_ok").val("去认证");
  32. }else if(data.data.length>0){
  33. window.open("resourceIssue.html")
  34. }
  35. }
  36. },
  37. error: function(XMLHttpRequest, textStats, errorThrown) {
  38. $.MsgBox.Alert('提示', '服务器请求失败')
  39. }
  40. })
  41. }
  42. /*资源列表查询*/
  43. function getRecourceMe(n, isbind, num) {
  44. var resourceNameVa = $("#resouceName").val();
  45. var $info = {};
  46. $info.orgId = orgId;
  47. $info.pageSize = 10;
  48. if(resourceNameVa != "") {
  49. $info.key = resourceNameVa;
  50. }
  51. $info.pageNo = n;
  52. $.ajax({
  53. "url": "/ajax/resource/pqForOrg",
  54. "type": "GET",
  55. "success": function(data) {
  56. console.log(data)
  57. if(data.success) {
  58. $("#resourceList").html("");
  59. if(num == 1) {
  60. if(data.data.data.length == 0) {
  61. $("#noresource").removeClass("displayNone");
  62. $(".noContip").text("您还未发布任何资源");
  63. return;
  64. } else {
  65. $("#noresource").addClass("displayNone");
  66. }
  67. } else {
  68. if(data.data.data.length == 0) {
  69. $("#noresource").removeClass("displayNone");
  70. $(".noContip").text("没有符合该搜索条件的内容");
  71. return;
  72. } else {
  73. $("#noresource").addClass("displayNone");
  74. }
  75. }
  76. resourceHtml(data.data.data);
  77. if(isbind == true) {
  78. $(".tcdPageCode").createPage({
  79. pageCount: Math.ceil(data.data.total / data.data.pageSize),
  80. current: data.data.pageNo,
  81. backFn: function(p) {
  82. getRecourceMe(p, false);
  83. }
  84. });
  85. }
  86. }
  87. },
  88. "data": $info,
  89. dataType: "json",
  90. 'error': function() {
  91. $.MsgBox.Alert('提示', '服务器连接超时!');
  92. }
  93. });
  94. }
  95. getRecourceMe(1, true);
  96. function resourceHtml($data) {
  97. for(var i = 0; i < $data.length; i++) {
  98. var imgSrc = "../images/default-resource.jpg";
  99. var oTime, pageview = "",
  100. draftLable = "",
  101. oHtml, oLi = '';
  102. if($data[i].images.length) {
  103. imgSrc = "/data/resource/" + $data[i].images[0].imageSrc
  104. }
  105. console.log($data[i].status)
  106. if($data[i].status == 0) {
  107. oTime = "修改于 " + TimeTr($data[i].modifyTime);
  108. draftLable = '<span class="draftLable">草稿</span>';
  109. oHtml = "resourceIssue.html";
  110. oLi = "class='draftList'"
  111. } else {
  112. oTime = "发布于 " + TimeTr($data[i].publishTime);
  113. pageview = '<li><span>浏览量 ' + $data[i].pageViews + '</span></li>';
  114. oHtml = "../resourceShow.html"
  115. }
  116. var oStr = '<li ' + oLi + '>' +
  117. '<a href="' + oHtml + '?resourceId=' + $data[i].resourceId + '" target="_blank">' +
  118. '<div class="madiaHead resouseHead" style="background-image: url(' + imgSrc + ');"></div>' +
  119. '<div class="madiaInfo">' +
  120. '<p class="h1Font ellipsisSty">' + $data[i].resourceName + '</p>' +
  121. '<ul class="h2Font clearfix">' +
  122. '<li><span>' + oTime + '</span></li>' + pageview + '<li><span class="ellipsisSty oop" style="display:inline-block;max-width:200px;"></span></li>' +
  123. '</ul>' +
  124. '<p><span>' + draftLable + '</span><span class="crel ellipsisSty" style="display:inline-block;max-width:200px;"></span></p>' +
  125. '</div>' +
  126. '</a>' +
  127. '<ul class="madiaEdit">' +
  128. '<li><span class="deteleThis2" data-id="' + $data[i].resourceId + '"></span></li>' +
  129. '<li><span class="editThis" data-id="' + $data[i].resourceId + '"></span></li>' +
  130. '</ul>' +
  131. '</li>'
  132. var $os = $(oStr);
  133. $("#resourceList").append($os);
  134. if($data[i].status == 2) {
  135. resourecRel.call($os.find(".crel"), $data[i].resourceId);
  136. } else {
  137. resourecRel.call($os.find(".oop"), $data[i].resourceId);
  138. }
  139. }
  140. }
  141. function professList(par) {
  142. $.ajax({
  143. "url": "/ajax/professor/qm",
  144. "type": "GET",
  145. "context": this,
  146. "traditional":true,
  147. "success": function(data) {
  148. if(data.success) {
  149. var $data = data.data;
  150. var arr = []
  151. if($data.length) {
  152. for(var i=0;i<$data.length;i++) {
  153. arr.push($data[i].name)
  154. }
  155. this.text("联系人 " + arr.join("、"))
  156. }
  157. }
  158. },
  159. "data": {
  160. "id": par
  161. },
  162. dataType: "json",
  163. 'error': function() {
  164. $.MsgBox.Alert('提示', '服务器连接超时!');
  165. }
  166. });
  167. }
  168. /*判断资源是否设置了资源联系人*/
  169. function resourecRel(rsd) {
  170. $.ajax({
  171. "url": "/ajax/resource/qaLinkman",
  172. "type": "GET",
  173. "context": this,
  174. "success": function(data) {
  175. if(data.success) {
  176. var $data = data.data;
  177. if($data.length == 0) {
  178. this.text("未设置联系人").css("color","#e03b43");
  179. }else {
  180. var arr = [];
  181. for(var i =0;i<$data.length;i++) {
  182. arr.push($data[i].professor.id)
  183. }
  184. professList.call(this,arr);
  185. }
  186. }
  187. },
  188. "data": {
  189. "resourceId": rsd
  190. },
  191. dataType: "json",
  192. 'error': function() {
  193. $.MsgBox.Alert('提示', '服务器连接超时!');
  194. }
  195. });
  196. }
  197. /*点击修改跳转修改页面*/
  198. $("#resourceList").on("click", ".editThis", function() {
  199. location.href = "resourceIssue.html?resourceId=" + $(this).attr("data-id")
  200. })
  201. /*点击删除跳转修改页面*/
  202. $("#resourceList").on("click", ".deteleThis2", function() {
  203. resourceId = $(this).attr("data-id");
  204. $.MsgBox.Confirm("提示", "确认删除该资源?", deleResource);
  205. })
  206. /*删除函数*/
  207. function deleResource() {
  208. $.ajax({
  209. "url": "/ajax/resource/delete",
  210. "type": "POST",
  211. "success": function(data) {
  212. if(data.success) {
  213. getRecourceMe(1, false);
  214. }
  215. },
  216. "data": {
  217. "resourceId": resourceId
  218. },
  219. "beforeSend": function() { /*console.log(this.data)*/ },
  220. "contentType": "application/x-www-form-urlencoded",
  221. dataType: "json"
  222. });
  223. }
  224. /*输入资源名称限制字数*/
  225. $("#resouceName").bind({
  226. keyup: function() {
  227. if($(this).val().length > 30) {
  228. $(this).val($(this).val().substr(0, 30));
  229. }
  230. }
  231. });
  232. /*点击搜索*/
  233. $(".searchSpan").click(function() {
  234. $(".tcdPageCode").remove();
  235. $(".aboutRes").append('<div class="tcdPageCode"></div>');
  236. getRecourceMe(1, true);
  237. })
  238. })