Keine Beschreibung

index.js 5.3KB

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