暫無描述

index.js 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /**
  2. * Created by TT on 2017/8/9.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "pagedatagrid", "util"], function (spa, pdgf, util) {
  7. return {
  8. main: function () {
  9. var root = spa.findInMain(".sys_paper_index");
  10. var pdg = pdgf.build(root);
  11. pdg.code.shell("showDay", function (env) {
  12. if (env.cd && env.cd[this.k]) {
  13. var day = env.cd[this.k];
  14. return day.substring(0, 4) + "年" + day.substring(4, 6) + "月" + day.substring(6, 8) + "日 " + day.substring(8, 10) + ":" + day.substring(10, 12);
  15. }
  16. return "";
  17. });
  18. pdg.code.listen($.dict.doTransfer);
  19. pdg.code.listen(function(){
  20. root.find(".hand-paperid").each(function() {
  21. var $e = $(this);
  22. var paperid = $e.attr("paperid");
  23. if (paperid) {
  24. util.get("/ajax/content/lwCount/paper", {paperId: paperid}, function (data) {
  25. $e.text(data);
  26. }, {});
  27. $e.removeClass("hand-paperid");
  28. }
  29. });
  30. root.find(".hand-collectionid").each(function() {
  31. var $e = $(this);
  32. var collectionid = $e.attr("collectionid");
  33. util.get("/ajax/content/countProfessor",{id:collectionid,type:4},function(data){
  34. $e.text(data);
  35. },{});
  36. $e.removeClass("hand-collectionid");
  37. });
  38. root.find(".hand-agreeid").each(function() {
  39. var $e = $(this);
  40. var agreeid = $e.attr("agreeid");
  41. util.get("/ajax/paper/agreeCount",{id:agreeid},function(data){
  42. $e.text(data);
  43. },{});
  44. $e.removeClass("hand-agreeid");
  45. });
  46. root.find(".table-opt a.name").on("click",function () {
  47. // var paperId = $(this).parent().attr("paperId");
  48. var time = $(this).parent().attr("createTime").substring(0,8);
  49. var shareId = $(this).parent().attr("shareId");
  50. // window.open('http://www.ekexiu.com/paperShow.html?paperId=' + paperId);
  51. window.open('http://www.ekexiu.com/shtml/pp/'+time+'/' + shareId+'.html');
  52. })
  53. });
  54. root.find(".opt-query").on("click", function () {
  55. pdg.load();
  56. });
  57. pdg.load();
  58. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  59. var $this = $(this);
  60. $this.toggleClass("checked");
  61. if ($this.hasClass("checked")) {
  62. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  63. } else {
  64. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  65. }
  66. });
  67. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  68. var $this = $(this);
  69. $this.toggleClass("checked");
  70. });
  71. // root.find(".opt-del").on("click", function() {
  72. // var $org = root.find("td.opt-check>i.checked");
  73. // if($org.length) {
  74. // var ret = [];
  75. // $org.each(function() {
  76. // ret.push($(this).attr("articleId"));
  77. // });
  78. // util.boxMsg({
  79. // title: "确认删除",
  80. // content: "您是否要删除选中的文章?",
  81. // btns: [{
  82. // caption: "删除",
  83. // hand: function () {
  84. // util.post("../ajax/paper/deleteArticle", {articleIds: ret}, function () {
  85. // pdg.reload()
  86. // }, {});
  87. // }
  88. // },
  89. // {caption: "取消"}
  90. // ]
  91. // });
  92. // } else {
  93. // util.alert("请选择一个用户");
  94. // }
  95. // });
  96. root.find(".opt-sort-num").on("click", function() {
  97. var $paper = root.find("td.opt-check>i.checked");
  98. if($paper.length) {
  99. if($paper.length > 1) {
  100. util.alert("只能选择一篇资源");
  101. } else {
  102. $.util.get("../ajax/paper/id/"+$paper.attr("paperId"),null,function(rd){
  103. if(rd){
  104. spa.showModal("sys_paper_sort", { data:rd, hand: function() { pdg.reload() } })
  105. }else{
  106. util.alertMsg("资源不存在", function(){pdg.reload();});
  107. }
  108. },{});
  109. }
  110. } else {
  111. util.alert("请选择一篇资源");
  112. }
  113. });
  114. root.find(".opt-keyword").on("click", function() {
  115. var $paper = root.find("td.opt-check>i.checked");
  116. if($paper.length) {
  117. if($paper.length > 1) {
  118. util.alert("只能选择一篇资源");
  119. } else {
  120. $.util.get("../ajax/paper/id/"+$paper.attr("paperId"),null,function(rd){
  121. if(rd){
  122. spa.showModal("sys_paper_keyword", { data:rd, hand: function() { pdg.reload() } })
  123. }else{
  124. util.alertMsg("资源不存在", function(){pdg.reload();});
  125. }
  126. },{});
  127. }
  128. } else {
  129. util.alert("请选择一篇资源");
  130. }
  131. });
  132. root.find(".opt-view").on("click", function () {
  133. var $paper = root.find("td.opt-check>i.checked");
  134. if ($paper.length) {
  135. if ($paper.length > 1) {
  136. util.alert("只能选择一篇资源");
  137. } else {
  138. var time = $paper.attr("createTime").substring(0,8);
  139. var shareId = $paper.attr("shareId");
  140. // window.open('http://www.ekexiu.com/paperShow.html?paperId=' + $paper.attr("paperId"));
  141. window.open('http://www.ekexiu.com/shtml/pp/'+time+'/' + shareId+'.html');
  142. }
  143. } else {
  144. util.alert("请选择一篇资源");
  145. }
  146. });
  147. }, mainDestory: function () {
  148. }
  149. };
  150. });
  151. });