portal html css js resource

resourceList.js 5.9KB

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