portal html css js resource

patentImport.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. $(document).ready(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. $(".workmenu>ul>li").eq(3).addClass("nowLi");
  4. loginStatus(); //判断个人是否登录
  5. valUser();
  6. var userid = $.cookie("userid");
  7. console.log(userid)
  8. var userName = $.cookie("userName");
  9. /*资源列表查询*/
  10. function getRecourceMe(n, isbind, num) {
  11. var resourceNameVa = $("#patentName").val();
  12. var $info = {};
  13. $info.id = userid;
  14. $info.author = userName;
  15. $info.pageSize = 10;
  16. if(resourceNameVa != "") {
  17. $info.name = resourceNameVa;
  18. }
  19. $info.pageNo = n;
  20. $.ajax({
  21. "url": "/ajax/ppatent/byAuthor",
  22. "type": "GET",
  23. "success": function(data) {
  24. if(data.success) {
  25. $(".importUl").html("");
  26. if(num == 1) {
  27. if(data.data.data.length == 0) {
  28. $("#noresource").removeClass("displayNone");
  29. $(".noContip").text("没有需要导入的专利");
  30. return;
  31. } else {
  32. $("#noresource").addClass("displayNone");
  33. }
  34. } else {
  35. if(data.data.data.length == 0) {
  36. $("#noresource").removeClass("displayNone");
  37. $(".noContip").text("没有符合该搜索条件的内容");
  38. return;
  39. } else {
  40. $("#noresource").addClass("displayNone");
  41. }
  42. }
  43. resourceHtml(data.data.data);
  44. if(isbind == true) {
  45. $(".tcdPageCode").createPage({
  46. pageCount: Math.ceil(data.data.total / data.data.pageSize),
  47. current: data.data.pageNo,
  48. backFn: function(p) {
  49. getRecourceMe(p, false);
  50. document.body.scrollTop = document.documentElement.scrollTop = 0;
  51. }
  52. });
  53. }
  54. }
  55. },
  56. "data": $info,
  57. dataType: "json",
  58. 'error': function() {
  59. $.MsgBox.Alert('提示', '服务器连接超时!');
  60. }
  61. });
  62. }
  63. getRecourceMe(1, true);
  64. function resourceHtml($data) {
  65. for(var i = 0; i < $data.length; i++) {
  66. var imgSrc = "../images/default-resource.jpg";
  67. var oSpec = "",
  68. comp = "";
  69. if($data[i].img) {
  70. imgSrc = "/data/resource/" + $data[i].img;
  71. }
  72. if($data[i].authors) {
  73. oSpec = "发明人:" + $data[i].authors;
  74. }
  75. if($data[i].code) {
  76. comp = "专利号:" + $data[i].code;
  77. }
  78. var oImg = "";
  79. if($data[i].img) {
  80. oImg = $data[i].img;
  81. }
  82. var oT, oText,cs;
  83. if($data[i].professorId.substring(0,1)!="#") {
  84. oT = "importSpan-2";
  85. oText = "已导入";
  86. cs="auto"
  87. } else {
  88. oT = "importSpan-1";
  89. oText = "导入";
  90. cs="pointer";
  91. }
  92. var oString = '<li>' +
  93. '<a class="flexCenter">' +
  94. '<div class="madiaHead resouseHead" style="background-image: url(' + imgSrc + ');"></div>' +
  95. '<div class="madiaInfo">' +
  96. '<p class="h1Font ellipsisSty">' + $data[i].name + '</p>' +
  97. '<p class="h2Font ellipsisSty">' + oSpec + '</p>' +
  98. '<p class="h2Font ellipsisSty">' + comp + '</p>' +
  99. '</div>' +
  100. '</a>' +
  101. '<div class="importBtn">' +
  102. '<span class="importResource ' + oT + '" data-id="' + $data[i].id + '" style="cursor:'+cs+'">' + oText + '</span>' +
  103. /*'<span class="importSpan-2">再次导入</span>' +
  104. '<span class="importSpan-3">已导入</span>' +*/
  105. '</div>' +
  106. '</li>'
  107. var $st=$(oString);
  108. $(".importUl").append(oString);
  109. }
  110. }
  111. /*输入资源名称限制字数*/
  112. $("#resouceName").bind({
  113. keyup: function() {
  114. if($(this).val().length > 30) {
  115. $(this).val($(this).val().substr(0, 30));
  116. }
  117. }
  118. });
  119. /*点击搜索*/
  120. $(".searchSpan").click(function() {
  121. $(".tcdPageCode").remove();
  122. $(".aboutRes").append('<div class="tcdPageCode"></div>');
  123. getRecourceMe(1, true);
  124. })
  125. /*导入资源*/
  126. $(".importUl").on("click", ".importSpan-1", function() {
  127. var oF = $(this).attr("flag");
  128. var $this = $(this);
  129. $.ajax({
  130. "url": "/ajax/ppatent/ass",
  131. "type": "POST",
  132. "success": function(data) {
  133. if(data.success) {
  134. if(data.data > 0) {
  135. $this.text("导入成功").addClass("importSpan-3").removeClass("importSpan-1").removeClass("importSpan-2").css("cursor", "auto");
  136. }
  137. }
  138. },
  139. "data": {
  140. id: $(this).attr("data-id"),
  141. uid: userid,
  142. author: userName,
  143. },
  144. dataType: "json",
  145. 'error': function() {
  146. $.MsgBox.Alert('提示', '服务器连接超时!');
  147. }
  148. });
  149. });
  150. })