Brak opisu

index.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. root.find(".table-opt a.name").on("click",function () {
  39. var articleId = $(this).parent().attr("articleId");
  40. var time = $(this).parent().attr("createTime").substring(0,8);
  41. var shareId = $(this).parent().attr("shareId");
  42. // window.open('http://www.ekexiu.com/articalShow.html?articleId=' + articleId);
  43. window.open('http://www.ekexiu.com/shtml/a/'+time+'/' + shareId+'.html');
  44. });
  45. root.find("a.author").on("click",function () {
  46. var professorId = $(this).parent().attr("professorId");
  47. var orgId = $(this).parent().attr("orgId");
  48. if(orgId) {
  49. window.open('http://www.ekexiu.com/cmpInforShow.html?orgId='+orgId);
  50. }else if(professorId){
  51. window.open('http://www.ekexiu.com/userInforShow.html?professorId='+professorId);
  52. }
  53. })
  54. });
  55. root.find(".opt-query").on("click", function () {
  56. pdg.load();
  57. });
  58. pdg.load();
  59. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  60. var $this = $(this);
  61. $this.toggleClass("checked");
  62. if ($this.hasClass("checked")) {
  63. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  64. } else {
  65. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  66. }
  67. });
  68. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  69. var $this = $(this);
  70. $this.toggleClass("checked");
  71. });
  72. root.find(".opt-del").on("click", function() {
  73. var $article = root.find("td.opt-check>i.checked");
  74. if($article.length) {
  75. var ret = [];
  76. $article.each(function() {
  77. ret.push($(this).attr("articleId"));
  78. });
  79. util.boxMsg({
  80. title: "确认删除",
  81. content: "您是否要删除选中的文章?",
  82. btns: [{
  83. caption: "删除",
  84. hand: function () {
  85. util.post("../ajax/article/deleteArticle", {articleIds: ret}, function () {
  86. pdg.reload()
  87. }, {});
  88. }
  89. },
  90. {caption: "取消"}
  91. ]
  92. });
  93. } else {
  94. util.alert("请选择一个用户");
  95. }
  96. });
  97. root.find(".opt-sort-num").on("click", function() {
  98. var $article = root.find("td.opt-check>i.checked");
  99. if($article.length) {
  100. if($article.length > 1) {
  101. util.alert("只能选择一篇文章");
  102. } else {
  103. $.util.get("../ajax/article/id/"+$article.attr("articleId"),null,function(rd){
  104. if(rd){
  105. spa.showModal("sys_article_sort", { data:rd, hand: function() { pdg.reload() } })
  106. }else{
  107. util.alertMsg("文章不存在", function(){pdg.load();});
  108. }
  109. },{});
  110. }
  111. } else {
  112. util.alert("请选择一篇文章");
  113. }
  114. });
  115. root.find(".opt-col-num").on("click", function () {
  116. var $article = root.find("td.opt-check>i.checked");
  117. if ($article.length) {
  118. var articles = [];
  119. $article.each(function () {
  120. articles.push($(this).attr("articleId"));
  121. });
  122. if (articles) {
  123. spa.showModal("sys_article_colnum", {
  124. data: articles, hand: function () {
  125. pdg.reload();
  126. }
  127. });
  128. } else {
  129. util.alertMsg("文章不存在", function () {
  130. pdg.load();
  131. });
  132. }
  133. } else {
  134. util.alert("请选择一篇文章");
  135. }
  136. });
  137. root.find(".opt-subject").on("click", function() {
  138. var $article = root.find("td.opt-check>i.checked");
  139. if($article.length) {
  140. if($article.length > 1) {
  141. util.alert("只能选择一篇文章");
  142. } else {
  143. $.util.get("../ajax/article/id/"+$article.attr("articleId"),null,function(rd){
  144. if(rd){
  145. spa.showModal("sys_article_subject", { data:rd, hand: function() { pdg.reload() } })
  146. }else{
  147. util.alertMsg("文章不存在", function(){pdg.load();});
  148. }
  149. },{});
  150. }
  151. } else {
  152. util.alert("请选择一篇文章");
  153. }
  154. });
  155. root.find(".opt-edit").on("click", function() {
  156. var $article = root.find("td.opt-check>i.checked");
  157. if($article.length) {
  158. if($article.length > 1) {
  159. util.alert("只能选择一篇文章");
  160. } else {
  161. // $.util.get("../ajax/article/id/"+$article.attr("articleId"),null,function(rd){
  162. // if(rd){
  163. // window.open('http://www.ekexiu.com:81/html/model/sys/article/articleModify.html?articleId=' + $article.attr("articleId"));
  164. window.open('http://'+window.location.host+'/html/model/sys/article/articleModify.html?articleId=' + $article.attr("articleId"));
  165. // }else{
  166. // util.alertMsg("文章不存在", function(){pdg.reload();});
  167. // }
  168. // },{});
  169. }
  170. } else {
  171. util.alert("请选择一篇文章");
  172. }
  173. });
  174. root.find(".opt-relate").on("click", function() {
  175. var $article = root.find("td.opt-check>i.checked");
  176. if($article.length) {
  177. if($article.length > 1) {
  178. util.alert("只能选择一篇文章");
  179. } else {
  180. $.util.get("../ajax/article/id/" + $article.attr("articleId"), null, function (rd) {
  181. if (rd) {
  182. spa.showModal("sys_article_relate", {
  183. data: rd, hand: function () {
  184. pdg.reload()
  185. }
  186. })
  187. } else {
  188. util.alertMsg("文章不存在", function () {
  189. pdg.reload();
  190. });
  191. }
  192. }, {});
  193. }
  194. } else {
  195. util.alert("请选择一篇文章");
  196. }
  197. });
  198. root.find(".opt-view").on("click", function () {
  199. var $article = root.find("td.opt-check>i.checked");
  200. if ($article.length) {
  201. if ($article.length > 1) {
  202. util.alert("只能选择一篇文章");
  203. } else {
  204. var time = $article.attr("createTime").substring(0,8);
  205. var shareId = $article.attr("shareId");
  206. // window.open('http://www.ekexiu.com/articalShow.html?articleId=' + $article.attr("articleId"));
  207. window.open('http://www.ekexiu.com/shtml/a/'+time+'/' + shareId+'.html');
  208. }
  209. } else {
  210. util.alert("请选择一篇文章");
  211. }
  212. });
  213. root.find(".opt-count").on("click", function () {
  214. var $article = root.find("td.opt-check>i.checked");
  215. if ($article.length) {
  216. if ($article.length>1) {
  217. util.alert("只能选择一篇文章");
  218. }else {
  219. spa.showModal("sys_article_count", {
  220. id: $article.attr("articleId"),
  221. hand: function () {
  222. pdg.reload();
  223. }
  224. });
  225. }
  226. }else {
  227. util.alert("请选择一篇文章");
  228. }
  229. });
  230. root.find(".opt-banner").on("click",function () {
  231. var $article = root.find("td.opt-check>i.checked");
  232. if ($article.length) {
  233. if ($article.length>1) {
  234. util.alert("只能选择一篇文章");
  235. }else {
  236. spa.showModal("sys_article_banner", {
  237. id: $article.attr("articleId"),
  238. hand: function () {
  239. pdg.reload();
  240. }
  241. });
  242. }
  243. }else {
  244. util.alert("请选择一篇文章");
  245. }
  246. })
  247. }, mainDestory: function () {
  248. }
  249. };
  250. });
  251. });