Python-100-Days/Day41-55/oa/templates/dept.html

84 lines
2.7 KiB
HTML
Raw Normal View History

2018-05-22 16:36:08 +08:00
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>部门</title>
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
2018-05-24 16:49:40 +08:00
<style>
#dept td, #dept th {
text-align: center;
}
</style>
2018-05-22 16:36:08 +08:00
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<h3>部门信息</h3>
<hr>
</div>
</div>
2018-05-24 16:49:40 +08:00
2018-05-22 16:36:08 +08:00
<div class="row clearfix">
<div class="col-md-8 column">
<table id="dept" class="table table-striped table-hover">
<thead>
<tr>
<th>部门编号</th>
<th>部门名称</th>
<th>部门所在地</th>
2018-05-23 11:57:06 +08:00
<th>是否优秀</th>
2018-05-22 16:36:08 +08:00
<th>操作</th>
</tr>
</thead>
<tbody>
{% for dept in dept_list %}
<tr>
<td>{{ dept.no }}</td>
<td>
2018-05-23 11:57:06 +08:00
<!-- 写代码时要尽量避免使用硬编码(hard code) -->
2018-05-24 16:49:40 +08:00
<a href="{% url 'empsindept' dept.no %}">{{ dept.name }}</a>
2018-05-22 16:36:08 +08:00
</td>
<td>{{ dept.location }}</td>
<td>
2018-05-23 11:57:06 +08:00
{% if dept.excellent %}
<span style="color: green;"></span>
{% else %}
<span style="color: red;">×</span>
{% endif %}
</td>
<td>
2018-05-24 16:49:40 +08:00
<a id="{{ dept.no }}" href="javascript:void(0);" class="btn btn-xs btn-warning">删除</a>
2018-05-22 16:36:08 +08:00
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-4 column">
</div>
</div>
</div>
<script src="{% static 'js/jquery.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script>
$(function() {
$('#dept tbody tr:even').addClass('info');
$('#dept tbody tr:odd').addClass('warning');
2018-05-24 16:49:40 +08:00
$('#dept a[id]').on('click', function(evt) {
var a = $(evt.target);
if (confirm('确定要删除吗?')) {
$.getJSON('/hrs/deldept/' + a.attr('id'), function(json) {
if (json.code == 200) {
a.parent().parent().remove();
$('#dept tbody tr:even').addClass('info');
$('#dept tbody tr:odd').addClass('warning');
}
});
}
});
2018-05-22 16:36:08 +08:00
});
</script>
</body>
</html>