Sin Descripción

index.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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-collectionid").each(function() {
  21. var $e = $(this);
  22. var collectionid = $e.attr("collectionid");
  23. util.get("/ajax/content/countProfessor",{id:collectionid,type:4},function(data){
  24. $e.text(data);
  25. },{});
  26. $e.removeClass("hand-collectionid");
  27. });
  28. });
  29. root.find(".opt-query").on("click", function () {
  30. pdg.load();
  31. });
  32. pdg.load();
  33. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  34. var $this = $(this);
  35. $this.toggleClass("checked");
  36. if ($this.hasClass("checked")) {
  37. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  38. } else {
  39. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  40. }
  41. });
  42. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  43. var $this = $(this);
  44. $this.toggleClass("checked");
  45. });
  46. // root.find(".opt-del").on("click", function() {
  47. // var $org = root.find("td.opt-check>i.checked");
  48. // if($org.length) {
  49. // var ret = [];
  50. // $org.each(function() {
  51. // ret.push($(this).attr("articleId"));
  52. // });
  53. // util.boxMsg({
  54. // title: "确认删除",
  55. // content: "您是否要删除选中的文章?",
  56. // btns: [{
  57. // caption: "删除",
  58. // hand: function () {
  59. // util.post("../ajax/paper/deleteArticle", {articleIds: ret}, function () {
  60. // pdg.reload()
  61. // }, {});
  62. // }
  63. // },
  64. // {caption: "取消"}
  65. // ]
  66. // });
  67. // } else {
  68. // util.alert("请选择一个用户");
  69. // }
  70. // });
  71. root.find(".opt-sort-num").on("click", function() {
  72. var $paper = root.find("td.opt-check>i.checked");
  73. if($paper.length) {
  74. if($paper.length > 1) {
  75. util.alert("只能选择一篇资源");
  76. } else {
  77. $.util.get("../ajax/paper/id/"+$paper.attr("paperId"),null,function(rd){
  78. if(rd){
  79. spa.showModal("sys_paper_sort", { data:rd, hand: function() { pdg.reload() } })
  80. }else{
  81. util.alertMsg("资源不存在", function(){pdg.reload();});
  82. }
  83. },{});
  84. }
  85. } else {
  86. util.alert("请选择一篇资源");
  87. }
  88. });
  89. root.find(".opt-view").on("click", function () {
  90. var $org = root.find("td.opt-check>i.checked");
  91. if ($org.length) {
  92. if ($org.length > 1) {
  93. util.alert("只能选择一篇资源");
  94. } else {
  95. window.open('http://www.ekexiu.com/paperShow.html?paperId=' + $org.attr("paperId"));
  96. }
  97. } else {
  98. util.alert("请选择一篇资源");
  99. }
  100. });
  101. }, mainDestory: function () {
  102. }
  103. };
  104. });
  105. });