blogManage.jsp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: njc
  4. Date: 2022/5/8
  5. Time: 10:02
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9. <script type="text/javascript">
  10. function formatBlogType(val, row) {
  11. return val.typeName;
  12. }
  13. /**
  14. * 根据标题查询
  15. */
  16. function searchBlog() {
  17. $("#dg").datagrid('load', {"title": $("#s_title").val()});
  18. }
  19. /**
  20. * 修改一条博客信息
  21. */
  22. function openBlogModifyTab() {
  23. var selectedRows = $("#dg").datagrid("getSelections");
  24. if (selectedRows.length != 1) {
  25. $.messager.alert("系统提示", "请选择一个要修改的博客!");
  26. return;
  27. }
  28. var row = selectedRows[0];
  29. window.parent.addTab("修改博客", "modifyBlog.jsp?id=" + row.id, "icon-writeBlog");
  30. }
  31. /**
  32. * 删除一条博客信息
  33. */
  34. function deleteBlog() {
  35. var selectedRows = $("#dg").datagrid("getSelections");
  36. if (selectedRows.length == 0) {
  37. $.messager.alert("系统提示", "请选择要删除的博客!");
  38. return;
  39. }
  40. var strIds = [];
  41. for (var i = 0; i < selectedRows.length; i++) {
  42. strIds.push(selectedRows[i].id);
  43. }
  44. var ids = strIds.join(",");
  45. $.messager.confirm("系统提示!", "你确定要删除<font color=red>" + selectedRows.length + "<font>条数据吗?", function (r) {
  46. if (r) {
  47. $.post("${pageContext.request.contextPath}/admin/blog/delete.do", {ids: ids}, function (result) {
  48. if (result.success) {
  49. $.messager.alert("系统提示", "数据已经成功删除!");
  50. $("#dg").datagrid("reload");
  51. } else {
  52. $.messager.alert("系统提示", "数据删除失败!");
  53. }
  54. }, "json");
  55. }
  56. });
  57. }
  58. </script>
  59. <table id="dg" title="博客管理" class="easyui-datagrid" fitcolumns="true" pagination="true" rownumber="true"
  60. toolbar="#tb" url="${pageContext.request.contextPath}/admin/blog/list.do">
  61. <thead>
  62. <tr>
  63. <th field="cb" checkbox="true" align="center"></th>
  64. <th field="id" width="20" align="center">编号</th>
  65. <th field="title" width="200" align="center">标题</th>
  66. <th field="releaseDate" width="50" align="center">发布日期</th>
  67. <th field="blogType" width="50" align="center" formatter="formatBlogType">博客类型</th>
  68. </tr>
  69. </thead>
  70. </table>
  71. <div id="tb">
  72. <div>
  73. <a href="javascript:openBlogModifyTab()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
  74. <a href="javascript:deleteBlog()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
  75. </div>
  76. &nbsp;标题:&nbsp;<input type="text" id="s_title" size="20" onkeydown="if (event.keyCode===13) searchBlog()"/>
  77. <a href="javascript:searchBlog()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
  78. </div>