dept.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. {% load static %}
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>部门</title>
  7. <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
  8. <style>
  9. #dept td, #dept th {
  10. text-align: center;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <div class="container">
  16. <div class="row clearfix">
  17. <div class="col-md-12 column">
  18. <h3>部门信息</h3>
  19. <hr>
  20. </div>
  21. </div>
  22. <div class="row clearfix">
  23. <div class="col-md-8 column">
  24. <table id="dept" class="table table-striped table-hover">
  25. <thead>
  26. <tr>
  27. <th>部门编号</th>
  28. <th>部门名称</th>
  29. <th>部门所在地</th>
  30. <th>是否优秀</th>
  31. <th>操作</th>
  32. </tr>
  33. </thead>
  34. <tbody>
  35. {% for dept in dept_list %}
  36. <tr>
  37. <td>{{ dept.no }}</td>
  38. <td>
  39. <!-- 写代码时要尽量避免使用硬编码(hard code) -->
  40. <a href="{% url 'empsindept' dept.no %}">{{ dept.name }}</a>
  41. </td>
  42. <td>{{ dept.location }}</td>
  43. <td>
  44. {% if dept.excellent %}
  45. <span style="color: green;">√</span>
  46. {% else %}
  47. <span style="color: red;">×</span>
  48. {% endif %}
  49. </td>
  50. <td>
  51. <a id="{{ dept.no }}" href="javascript:void(0);" class="btn btn-xs btn-warning">删除</a>
  52. </td>
  53. </tr>
  54. {% endfor %}
  55. </tbody>
  56. </table>
  57. </div>
  58. <div class="col-md-4 column">
  59. </div>
  60. </div>
  61. </div>
  62. <script src="{% static 'js/jquery.min.js' %}"></script>
  63. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  64. <script>
  65. $(function() {
  66. $('#dept tbody tr:even').addClass('info');
  67. $('#dept tbody tr:odd').addClass('warning');
  68. $('#dept a[id]').on('click', function(evt) {
  69. var a = $(evt.target);
  70. if (confirm('确定要删除吗?')) {
  71. $.getJSON('/hrs/deldept/' + a.attr('id'), function(json) {
  72. if (json.code == 200) {
  73. a.parent().parent().remove();
  74. $('#dept tbody tr:even').addClass('info');
  75. $('#dept tbody tr:odd').addClass('warning');
  76. }
  77. });
  78. }
  79. });
  80. });
  81. </script>
  82. </body>
  83. </html>