portal html css js resource

resourceList.js 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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-UnstaffList.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 id="oop" style="color:#e03b43;"></span></li>' +
  123. '</ul>' +
  124. '<p><span>' + draftLable + '</span><span class="crel" style="margin-left:10px"></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 == 0) {
  135. resourecRel.call($os.find(".crel"), $data[i].resourceId);
  136. } else {
  137. resourecRel.call($os.find("#oop"), $data[i].resourceId);
  138. }
  139. }
  140. }
  141. /*判断资源是否设置了资源联系人*/
  142. function resourecRel(rsd) {
  143. $.ajax({
  144. "url": "/ajax/resource/qaLinkman",
  145. "type": "GET",
  146. "context": this,
  147. "success": function(data) {
  148. if(data.success) {
  149. var $data = data.data;
  150. if($data.length == 0) {
  151. this.text("未设置联系人");
  152. }
  153. }
  154. },
  155. "data": {
  156. "resourceId": rsd
  157. },
  158. dataType: "json",
  159. 'error': function() {
  160. $.MsgBox.Alert('提示', '服务器连接超时!');
  161. }
  162. });
  163. }
  164. /*点击修改跳转修改页面*/
  165. $("#resourceList").on("click", ".editThis", function() {
  166. location.href = "resourceIssue.html?resourceId=" + $(this).attr("data-id")
  167. })
  168. /*点击删除跳转修改页面*/
  169. $("#resourceList").on("click", ".deteleThis2", function() {
  170. resourceId = $(this).attr("data-id");
  171. $.MsgBox.Confirm("提示", "确认删除该资源?", deleResource);
  172. })
  173. /*删除函数*/
  174. function deleResource() {
  175. $.ajax({
  176. "url": "/ajax/resource/delete",
  177. "type": "POST",
  178. "success": function(data) {
  179. if(data.success) {
  180. getRecourceMe(1, false);
  181. }
  182. },
  183. "data": {
  184. "resourceId": resourceId
  185. },
  186. "beforeSend": function() { /*console.log(this.data)*/ },
  187. "contentType": "application/x-www-form-urlencoded",
  188. dataType: "json"
  189. });
  190. }
  191. /*输入资源名称限制字数*/
  192. $("#resouceName").bind({
  193. keyup: function() {
  194. if($(this).val().length > 30) {
  195. $(this).val($(this).val().substr(0, 30));
  196. }
  197. }
  198. });
  199. /*点击搜索*/
  200. $(".searchSpan").click(function() {
  201. $(".tcdPageCode").remove();
  202. $(".aboutRes").append('<div class="tcdPageCode"></div>');
  203. getRecourceMe(1, true);
  204. })
  205. })