category.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. {% extends 'management/_common/base.html' %}
  2. {% load page_tag %}
  3. {% block content %}
  4. <form style="padding: 0;" action="/management/category" method="get">
  5. <div style="padding: 0" class="ui input">
  6. <input name="search_name" type="text" style="margin-right: 5px" placeholder="Name">
  7. <button type="submit" class="ui button primary"><i class="search icon"></i>搜索</button>
  8. <a href="/management/category" type="reset" class="ui button secondary"><i class="refresh icon"></i>重置</a>
  9. <a onclick="addConfirm()" type="reset" class="ui button green"><i class="add icon"></i>添加分类</a>
  10. </div>
  11. </form>
  12. <table style="padding: 0" class="ui celled table">
  13. <thead>
  14. <tr>
  15. <th>SEQ</th>
  16. <th>名称</th>
  17. <th>操作</th>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. {% for item in category %}
  22. <tr>
  23. <td>{{ item.seq }}</td>
  24. <td>{{ item.name }}</td>
  25. <td><a onclick="deleteConfirm({{ item.id }})" href="#" class="button" style="color: red">删除</a>
  26. </td>
  27. </tr>
  28. {% endfor %}
  29. </tbody>
  30. <tfoot>
  31. <tr>
  32. <th colspan="7">
  33. <div class="ui right floated pagination menu">
  34. {% if category.number > 1 %}
  35. <a href="?page={{ category.number|add:-1 }}" class="icon item">
  36. <i class="left chevron icon"></i>
  37. </a>
  38. {% else %}
  39. <a class="icon item">
  40. <i class="left chevron icon"></i>
  41. </a>
  42. {% endif %}
  43. {% for page in category.paginator.page_range %}
  44. {% circle_page category.number page %}
  45. {% endfor %}
  46. {% if category.number < category.paginator.num_pages %}
  47. <a href="?page={{ category.number | add:1 }}" class="icon item">
  48. <i class="right chevron icon"></i>
  49. </a>
  50. {% else %}
  51. <a class="icon item">
  52. <i class="right chevron icon"></i>
  53. </a>
  54. {% endif %}
  55. </div>
  56. </th>
  57. </tr>
  58. </tfoot>
  59. </table>
  60. <div class="ui mini test modal">
  61. <div class="header">
  62. 警告
  63. </div>
  64. <div class="content">
  65. <p>确认删除该分类?</p>
  66. </div>
  67. <div class="actions">
  68. <div class="ui negative button">
  69. 取消
  70. </div>
  71. <a id="deleteBtn" href="" class="ui positive right labeled icon button">
  72. 确认
  73. <i class="checkmark icon"></i>
  74. </a>
  75. </div>
  76. </div>
  77. <div id="addModel" class="ui special modal">
  78. <div class="header">
  79. 添加分类
  80. </div>
  81. <div class="content">
  82. <form method="post" action="/management/category/add" id="addform" class="ui form">
  83. {% csrf_token %}
  84. <div class="field">
  85. <label>排序</label>
  86. <input type="text" name="seq" placeholder="排序">
  87. </div>
  88. <div class="field">
  89. <label>分类名称</label>
  90. <input type="text" name="category_name" placeholder="分类名称">
  91. </div>
  92. </form>
  93. </div>
  94. <div class="actions">
  95. <div class="ui negative button">
  96. 取消
  97. </div>
  98. <div id="addBtn" class="ui positive right labeled icon button">
  99. 确认
  100. <i class="checkmark icon"></i>
  101. </div>
  102. </div>
  103. </div>
  104. {% endblock %}
  105. {% block js %}
  106. <script>
  107. $("#addform").form({
  108. fields: {
  109. title: {
  110. identifier: "seq",
  111. rules: [
  112. {
  113. type: "empty",
  114. prompt: "请输入SEQ"
  115. }
  116. ]
  117. },
  118. intro: {
  119. identifier: "category_name",
  120. rules: [
  121. {
  122. type: "empty",
  123. prompt: "请输入名称"
  124. }
  125. ]
  126. }
  127. },
  128. inline: true,
  129. on: "blur"
  130. });
  131. $("#addBtn").on("click", function () {
  132. $("#addform").submit();
  133. });
  134. function deleteConfirm(id) {
  135. $('.mini.modal')
  136. .modal('show')
  137. $("#deleteBtn").attr('href', '/management/category/delete?id=' + id)
  138. }
  139. function addConfirm() {
  140. $('#addModel')
  141. .modal('show')
  142. }
  143. </script>
  144. {% endblock %}