Technical.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. $(function() {
  2. var defaultPage = 0;
  3. var defaultSize = 10;
  4. var currentPage = defaultPage;
  5. var currentSize = defaultSize;
  6. var tableFirstLoad = true;
  7. layui.use(["form", "table", "laypage", "layer", 'upload', ], function() {
  8. var table = layui.table;
  9. var laypage = layui.laypage;
  10. var layer = layui.layer;
  11. var upload = layui.upload;
  12. var title = $("#realName");
  13. var searchTitleKey = "";
  14. var storage = window.localStorage;
  15. function loadLogList(page, size, searchTitle) {
  16. if (page === null || page === undefined) page = defaultPage;
  17. if (size === null || size === undefined) size = defaultSize;
  18. var tableOption = {
  19. elem: "#logList",
  20. height: "full-81",
  21. limit: size,
  22. cols: [
  23. [{
  24. type: "checkbox"
  25. },
  26. {
  27. field: "title",
  28. title: "标题",
  29. align: "center"
  30. },
  31. {
  32. field: "author",
  33. title: "作者",
  34. align: "center"
  35. },
  36. {
  37. field: "input_time",
  38. title: "输入时间",
  39. align: "center"
  40. },
  41. {
  42. field: "keywords",
  43. title: "关键词",
  44. align: "center"
  45. },
  46. {
  47. field: "aircraft",
  48. title: "机型",
  49. align: "center"
  50. },
  51. {
  52. field: "aircraft_system",
  53. title: "系统",
  54. align: "center"
  55. },
  56. {
  57. field: "major_name",
  58. title: "专业",
  59. align: "center"
  60. },
  61. {
  62. field: "article_number",
  63. title: "文章数量",
  64. align: "center"
  65. },
  66. {
  67. field: "article_type",
  68. title: "文章类型",
  69. align: "center"
  70. },
  71. // {
  72. // field: "file_path",
  73. // title: "文件路径",
  74. // align: "center",
  75. // },
  76. {
  77. fixed: "right",
  78. title: "操作",
  79. width: 200,
  80. toolbar: "#operationToolbar",
  81. align: "center"
  82. }
  83. ]
  84. ]
  85. };
  86. var articleType = "技术通报"
  87. if (searchTitle === null || searchTitle === undefined || searchTitle === "") {
  88. url = "api/article/searchArticleType?articleType=" + articleType + "&page=" + (page + 1) + " &size=" + size;
  89. fetchJSON(url, {}, "get", function(data) {
  90. if (data.status === 0) {
  91. if (tableFirstLoad) {
  92. tableFirstLoad = false;
  93. laypage.render({
  94. curr: page + 1,
  95. elem: "pagination",
  96. count: data.data.total,
  97. layout: ["count", "prev", "page", "next", "limit", "refresh", "skip"],
  98. jump: function(obj, first) {
  99. if (first) return;
  100. currentPage = obj.curr - 1;
  101. currentSize = obj.limit;
  102. loadLogList(currentPage, currentSize, searchTitleKey);
  103. }
  104. });
  105. }
  106. tableOption.data = data.data.list;
  107. table.render(tableOption);
  108. } else {
  109. showMsg(data.msg, 2, 2000);
  110. }
  111. });
  112. } else {
  113. var url = "api/article/listByKey?keyWords=" + searchTitle + "&page=" + (page + 1) + "&size=" + size;
  114. fetchJSON(url, {}, "get", function(data) {
  115. if (data.status === 0) {
  116. if (tableFirstLoad) {
  117. tableFirstLoad = false;
  118. laypage.render({
  119. curr: page + 1,
  120. elem: "pagination",
  121. count: data.data.total,
  122. layout: ["count", "prev", "page", "next", "limit", "refresh", "skip"],
  123. jump: function(obj, first) {
  124. if (first) return;
  125. currentPage = obj.curr - 1;
  126. currentSize = obj.limit;
  127. loadLogList(currentPage, currentSize, searchTitleKey);
  128. }
  129. });
  130. }
  131. tableOption.data = data.data.list;
  132. table.render(tableOption);
  133. } else {
  134. showMsg(data.msg, 2, 2000);
  135. }
  136. });
  137. }
  138. }
  139. loadLogList();
  140. $("#searchArticle").on("click", function(e) {
  141. e.preventDefault();
  142. tableFirstLoad = true;
  143. searchTitleKey = title.val().trim();
  144. if (searchTitleKey === "")
  145. loadLogList(0, currentSize);
  146. else
  147. loadLogList(0, currentSize, searchTitleKey);
  148. });
  149. $("#keyword").on("keyup", function(e) {
  150. e.preventDefault();
  151. if (e.keyCode === 13) {
  152. $("#searchArticle").click();
  153. }
  154. });
  155. // 监听表内工具条
  156. table.on("tool(logList)", function(obj) {
  157. var data = obj.data;
  158. if (obj.event === "delete") {
  159. var id = data.id
  160. layer.confirm("确认要删除吗?", function() {
  161. fetchJSON("api/article/delete?id=" + id, {}, "post", function(data) {
  162. if (data.status === 0) {
  163. showMsg("已删除!");
  164. tableFirstLoad = true;
  165. loadLogList(currentPage, currentSize);
  166. } else {
  167. showMsg(data.msg, 2, 2000);
  168. }
  169. });
  170. });
  171. } else
  172. if (obj.event === "edit") {
  173. var dataflie = data.file_path;
  174. // var dataflie = "\source\1614821180657保密协议.docx"
  175. // flie = urlBase + dataflie
  176. fetchJSON("api/article/browse", { filepath: dataflie }, "get", function(d) {
  177. if (d.status === 0) {
  178. sessionStorage.setItem("url", d.msg)
  179. x_admin_show(
  180. "在线查看",
  181. encodeURI(
  182. "../admin/article-look.html"
  183. ),
  184. 1300,
  185. 600,
  186. function() {
  187. loadLogList(currentPage, currentSize);
  188. }
  189. );
  190. }
  191. });
  192. }
  193. if (obj.event === "replace") {
  194. }
  195. });
  196. // 批量删除
  197. $("#batchDelete").on("click", function(e) {
  198. e.preventDefault();
  199. var checkedData = table.checkStatus("logList").data;
  200. if (checkedData.length === 0) {
  201. showMsg("未选择需要删除的日志", 2, 2000);
  202. return;
  203. }
  204. layer.confirm("确认要删除吗?", function() {
  205. var ids = [];
  206. for (var i = 0; i < checkedData.length; i++) {
  207. ids.push(checkedData[i].id);
  208. }
  209. fetchJSON("api/article/deleteByIds", { ids: ids }, "post", function(data) {
  210. if (data.status === 0) {
  211. showMsg("已删除!");
  212. tableFirstLoad = true;
  213. loadLogList(currentPage, currentSize);
  214. } else {
  215. showMsg(data.msg, 2, 2000);
  216. }
  217. });
  218. });
  219. });
  220. //上传
  221. $("#uploading").on("click", function(e) {
  222. e.preventDefault();
  223. tableFirstLoad = true;
  224. x_admin_show("上传文件",
  225. "../admin/article-add.html?title=&author=&input_time=&keywords=&description=&major_id=&major_name=&article_type=",
  226. 800, 450,
  227. function() {
  228. loadLogList(currentPage, currentSize);
  229. });
  230. });
  231. });
  232. });