portal html css js resource

resourceList.js 7.5KB

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