Geen omschrijving

index.js 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * Created by TT on 2018/1/26.
  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_answer_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-lm").each(function() {
  21. var $e = $(this);
  22. var aId = $e.attr("aId");
  23. if (aId) {
  24. util.get("http://www.ekexiu.com/ajax/leavemsg/count", {sid: aId,stype:4}, function (data) {
  25. $e.text(data);
  26. }, {});
  27. $e.removeClass("hand-lm");
  28. }
  29. });
  30. root.find(".hand-col").each(function() {
  31. var $e = $(this);
  32. var aId = $e.attr("aId");
  33. util.get("/ajax/content/countProfessor",{id:aId,type:9},function(data){
  34. $e.text(data);
  35. },{});
  36. $e.removeClass("hand-col");
  37. });
  38. root.find(".table-opt a.name").on("click",function () {
  39. var aId = $(this).parent().attr("aId");
  40. var qId = $(this).parent().attr("qId");
  41. // window.open('http://www.ekexiu.com/articalShow.html?articleId=' + articleId);
  42. window.open('http://www.ekexiu.com/qa-show.html?id='+qId+'&topid=' + aId);
  43. });
  44. root.find("a.author").on("click",function () {
  45. var professorId = $(this).parent().attr("professorId");
  46. if(professorId){
  47. window.open('http://www.ekexiu.com/userInforShow.html?professorId='+professorId);
  48. }
  49. })
  50. });
  51. root.find(".opt-query").on("click", function () {
  52. pdg.load();
  53. });
  54. pdg.load();
  55. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  56. var $this = $(this);
  57. $this.toggleClass("checked");
  58. if ($this.hasClass("checked")) {
  59. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  60. } else {
  61. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  62. }
  63. });
  64. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  65. var $this = $(this);
  66. $this.toggleClass("checked");
  67. });
  68. root.find(".opt-del").on("click", function() {
  69. var $answer = root.find("td.opt-check>i.checked");
  70. if($answer.length) {
  71. if($answer.length > 1) {
  72. util.alert("只能选择一篇回答");
  73. } else {
  74. util.boxMsg({
  75. title: "删除回答",
  76. content: "您是否要删除选中的回答!删除后不可恢复",
  77. btns: [{
  78. caption: "确认",
  79. hand: function() {
  80. util.get("../ajax/qa/deleteAnswer", { id: $answer.attr("aId"),qid:$answer.attr("qId") }, function() { pdg.reload() }, {});
  81. }
  82. },
  83. { caption: "取消" }
  84. ]
  85. });
  86. }
  87. } else {
  88. util.alert("请选择一篇回答");
  89. }
  90. });
  91. root.find(".opt-edit").on("click", function() {
  92. var $answer = root.find("td.opt-check>i.checked");
  93. if ($answer.length) {
  94. if ($answer.length>1) {
  95. util.alert("只能选择一篇回答");
  96. }else {
  97. spa.showModal("sys_answer_edit", {
  98. id: $answer.attr("aId"),
  99. hand: function () {
  100. pdg.reload();
  101. }
  102. });
  103. }
  104. }else {
  105. util.alert("请选择一篇文章");
  106. }
  107. });
  108. root.find(".opt-view").on("click", function () {
  109. var $answer = root.find("td.opt-check>i.checked");
  110. if ($answer.length) {
  111. if ($answer.length > 1) {
  112. util.alert("只能选择一篇回答");
  113. } else {
  114. var aId = $answer.attr("aId");
  115. var qId = $answer.attr("qId");
  116. window.open('http://www.ekexiu.com/qa-show.html?id='+qId+'&topid=' + aId );
  117. }
  118. } else {
  119. util.alert("请选择一篇回答");
  120. }
  121. });
  122. root.find(".opt-count").on("click", function () {
  123. var $answer = root.find("td.opt-check>i.checked");
  124. if ($answer.length) {
  125. if ($answer.length>1) {
  126. util.alert("只能选择一篇回答");
  127. }else {
  128. spa.showModal("sys_answer_count", {
  129. id: $answer.attr("aId"),
  130. hand: function () {
  131. pdg.reload();
  132. }
  133. });
  134. }
  135. }else {
  136. util.alert("请选择一篇回答");
  137. }
  138. });
  139. }, mainDestory: function () {
  140. }
  141. };
  142. });
  143. });