Aucune description

index.js 12KB

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