portal html css js resource

cmp-needList.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. $(document).ready(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. $(".workmenu>ul>li.demandIcon").addClass("nowLi");
  4. var id = $.cookie('orgId');
  5. if(id == "" || id == null || id == "null"){
  6. location.href = "cmp-settled-log.html";
  7. }
  8. resMgr(id);
  9. demandList(true,10, 1);
  10. /*查询企业认证状态*/
  11. function companyAuthentState() {
  12. $.ajax({
  13. url: '/ajax/org/authStatus',
  14. type: "GET",
  15. timeout: 10000,
  16. dataType: "json",
  17. data: {
  18. "id": id
  19. },
  20. beforeSend: function() {},
  21. success: function(data, textState) {
  22. if(data.success) {
  23. console.log(data);
  24. if(data.data == 3) {
  25. $("#companyDemandList").show();
  26. } else {
  27. $("#identityState").show();
  28. }
  29. }
  30. },
  31. error: function(XMLHttpRequest, textStats, errorThrown) {
  32. $.MsgBox.Alert('提示', '服务器请求失败')
  33. }
  34. })
  35. }
  36. companyAuthentState();
  37. $("#cmpneedList").on("click",".closeThis",function(){//关闭
  38. var dataId=$(this).parents("li").find(".urlHref").attr("data-id");
  39. $.MsgBox.Confirm("提示", "确认要关闭该需求?",function(){
  40. $.ajax({
  41. "url": "/ajax/demand/close",
  42. "type": "POST",
  43. "async": true,
  44. "data":{
  45. "id":dataId,
  46. "uid":id
  47. },
  48. "success": function(data) {
  49. if(data.success && data.data) {
  50. console.log(data);
  51. $(".madiaEdit").remove();
  52. demandList(true,10, 1);
  53. }
  54. }
  55. });
  56. });
  57. })
  58. /*需求列表*/
  59. function demandList(isbind, pageSize, pageNo) {
  60. $.ajax({
  61. url: "/ajax/demand/pq",
  62. type: "GET",
  63. timeout: 10000,
  64. dataType: "json",
  65. traditional: true,
  66. data: {
  67. "state":[1],
  68. 'oname':$.cookie('orgName'),
  69. "pageNo": pageNo,
  70. "pageSize": pageSize
  71. },
  72. "beforeSend": function() {
  73. $("#cmpneedList").append('<img src="../images/loading.gif" class="loading" />');
  74. },
  75. success: function(data, textState) {
  76. if(data.success) {
  77. console.log(data);
  78. $("#cmpneedList").html("");
  79. var $info = data.data.data;
  80. if($info.length > 0){
  81. for(var i = 0; i < $info.length; i++) {
  82. var liStr=$("<li></li>").appendTo("#cmpneedList");
  83. demandHtml($info[i],liStr);
  84. userFun($info[i].creator,liStr);
  85. }
  86. if($info.length != 0) {
  87. if(isbind == true) {
  88. $(".tcdPageCode").createPage({
  89. pageCount: Math.ceil(data.data.total / pageSize),
  90. current: data.data.data.pageNo,
  91. backFn: function(p) {
  92. $("#cmpneedList").html("");
  93. demandList(false,10, p);
  94. document.body.scrollTop = document.documentElement.scrollTop = 0;
  95. }
  96. });
  97. }
  98. }
  99. }else{
  100. $("#cmpneedList").parent().find(".nodatabox").removeClass("displayNone")
  101. }
  102. }
  103. $(".loading").remove();
  104. },
  105. error: function() {
  106. }
  107. })
  108. }
  109. function demandHtml($data,liStr) {
  110. var sowU="";
  111. if($data.pageViews!=0){
  112. sowU='<li><span>浏览量 '+$data.pageViews+'</span></li>'
  113. }
  114. var statusU="";
  115. var dateGap = delayDay($data.invalidDay);
  116. if($data.state==1 && dateGap=="1"){
  117. statusU='<li><span class="draftLable">即将于 '+TimeTr($data.invalidDay)+' 过期</span></li>'
  118. }
  119. if($data.state==0){
  120. statusU='<li><span class="draftLable">已于 '+TimeTr($data.invalidDay)+' 过期</span></li>'
  121. }else if($data.state==2){
  122. statusU='<li><span class="overLable">已于 '+TimeTr($data.modifyTime)+' 完成</span></li>'
  123. }else if($data.state==3){
  124. statusU='<li><span>已于 '+TimeTr($data.modifyTime)+' 关闭</span></li>'
  125. }
  126. var closStr='',pdRight="";
  127. if($data.state==1 || $data.state==0){
  128. pdRight="padding-right:80px";
  129. closStr += '<ul class="madiaEdit"><li><span class="closeThis">关闭</span></li></ul>'
  130. }
  131. var strCon='';
  132. strCon+='<a class="madiaInfo urlHref" style="'+pdRight+'" target="_blank" href="../demandShow.html?demandId='+$data.id+'" data-id="'+$data.id+'">'
  133. strCon+='<p class="h1Font ellipsisSty">'+ $data.title +'</p>'
  134. strCon+='<ul class="showliTop h2Font clearfix">'
  135. strCon+='<li><span>发布于 '+TimeTr($data.createTime)+'</span></li>'
  136. strCon+= sowU
  137. strCon+='<li><span class="creator"></span></li>'
  138. strCon+= statusU
  139. strCon+='</ul>'
  140. strCon+='</a>'+closStr
  141. $(strCon).appendTo(liStr);
  142. }
  143. function userFun(id,$listItem) {
  144. $.ajax({
  145. "url": "/ajax/professor/editBaseInfo/" + id,
  146. "type": "get",
  147. "async": true,
  148. "data":{
  149. "id":id
  150. },
  151. "success": function(data) {
  152. if(data.success && data.data) {
  153. $listItem.find(".creator").text(data.data.name);
  154. }
  155. },
  156. "error": function() {
  157. $.MsgBox.Alert('提示', '链接服务器超时')
  158. }
  159. });
  160. }
  161. function delayDay(startTime){
  162. var dateToday = new Date();
  163. var dateInvalid = new Date();
  164. dateInvalid.setFullYear(parseInt(startTime.substring(0, 4)));
  165. dateInvalid.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  166. dateInvalid.setDate(parseInt(startTime.substring(6, 8)));
  167. var dateGap = Math.abs(dateToday.getTime() - dateInvalid.getTime());
  168. var ifDelay="0";
  169. if(dateGap < 604800000){
  170. ifDelay="1";
  171. }
  172. return ifDelay;
  173. }
  174. })