1
0
Files
asset-management/templates/assetapp/asset_list.html
T
cnbugs a40a0137cf 初始提交:希姆计算硬件资产管理系统
功能:
- Django + MySQL + 深色主题
- 资产增删改查(含资产编号、BMC地址、设备位置、备注)
- Excel导入导出(分类自动创建)
- 设备分类管理
- 资产变更记录追踪
- 质保到期提醒
- 用户认证系统
- Docker部署支持
2026-04-25 08:04:51 +08:00

155 خطوط
7.7 KiB
HTML

{% extends "assetapp/base.html" %}
{% block title %}资产列表 - 希姆计算资产管理{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="mb-0"><i class="bi bi-list-ul me-2"></i>资产列表</h4>
<div>
<a href="{% url 'asset_export' %}" class="btn btn-outline-success btn-sm me-2">
<i class="bi bi-download me-1"></i>导出Excel
</a>
<a href="{% url 'asset_import' %}" class="btn btn-outline-info btn-sm me-2">
<i class="bi bi-upload me-1"></i>导入Excel
</a>
<a href="{% url 'asset_create' %}" class="btn btn-primary btn-sm">
<i class="bi bi-plus-circle me-1"></i>新增资产
</a>
</div>
</div>
<!-- 搜索和筛选 -->
<div class="card card-dark mb-3">
<div class="card-body">
<form method="get" class="row g-2 align-items-end">
<div class="col-md-4">
<label class="form-label text-muted small">搜索</label>
<input type="text" name="search" class="form-control form-control-sm"
placeholder="编号/名称/序列号/IP/品牌/型号/位置/负责人" value="{{ search }}">
</div>
<div class="col-md-2">
<label class="form-label text-muted small">分类</label>
<select name="category" class="form-select form-select-sm">
<option value="">全部分类</option>
{% for cat in categories %}
<option value="{{ cat.id }}" {% if current_category == cat.id|stringformat:"s" %}selected{% endif %}>{{ cat.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<label class="form-label text-muted small">状态</label>
<select name="status" class="form-select form-select-sm">
<option value="">全部状态</option>
{% for key, label in status_map.items %}
<option value="{{ key }}" {% if current_status == key %}selected{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<label class="form-label text-muted small">位置</label>
<select name="location" class="form-select form-select-sm">
<option value="">全部位置</option>
{% for loc in locations %}
<option value="{{ loc }}" {% if current_location == loc %}selected{% endif %}>{{ loc }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary btn-sm me-1"><i class="bi bi-search"></i> 搜索</button>
<a href="{% url 'asset_list' %}" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-counterclockwise"></i></a>
</div>
</form>
</div>
</div>
<!-- 资产表格 -->
<div class="card card-dark">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-dark table-hover table-striped mb-0">
<thead>
<tr>
<th>资产编号</th>
<th>设备名称</th>
<th>分类</th>
<th>品牌/型号</th>
<th>位置</th>
<th>BMC地址</th>
<th>IP地址</th>
<th>负责人</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for asset in page_obj %}
<tr>
<td><a href="{% url 'asset_detail' asset.pk %}" class="text-info">{{ asset.asset_number }}</a></td>
<td>{{ asset.name }}</td>
<td><span class="badge bg-secondary">{{ asset.category.name }}</span></td>
<td>{{ asset.brand }} {% if asset.model %}{{ asset.model }}{% endif %}</td>
<td>
{{ asset.location }}
{% if asset.cabinet %}<small class="text-muted"> {{ asset.cabinet }}{% if asset.cabinet_position %}/{{ asset.cabinet_position }}{% endif %}</small>{% endif %}
</td>
<td><code>{{ asset.bmc_address|default:"-" }}</code></td>
<td><code>{{ asset.ip_address|default:"-" }}</code></td>
<td>{{ asset.responsible_person|default:"-" }}</td>
<td>
<span class="badge
{% if asset.status == 'in_use' %}bg-success
{% elif asset.status == 'idle' %}bg-warning text-dark
{% elif asset.status == 'maintenance' %}bg-info
{% else %}bg-danger{% endif %}">
{{ asset.get_status_display }}
</span>
</td>
<td>
<a href="{% url 'asset_detail' asset.pk %}" class="btn btn-outline-info btn-xs" title="详情">
<i class="bi bi-eye"></i>
</a>
<a href="{% url 'asset_update' asset.pk %}" class="btn btn-outline-warning btn-xs" title="编辑">
<i class="bi bi-pencil"></i>
</a>
<a href="{% url 'asset_delete' asset.pk %}" class="btn btn-outline-danger btn-xs" title="删除">
<i class="bi bi-trash"></i>
</a>
</td>
</tr>
{% empty %}
<tr><td colspan="10" class="text-center text-light opacity-75 py-4">暂无资产数据</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- 分页 -->
{% if page_obj.has_other_pages %}
<nav class="mt-3">
<ul class="pagination pagination-sm justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}&search={{ search }}&category={{ current_category }}&status={{ current_status }}&location={{ current_location }}"><i class="bi bi-chevron-left"></i></a></li>
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<li class="page-item active"><span class="page-link">{{ num }}</span></li>
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
<li class="page-item"><a class="page-link" href="?page={{ num }}&search={{ search }}&category={{ current_category }}&status={{ current_status }}&location={{ current_location }}">{{ num }}</a></li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}&search={{ search }}&category={{ current_category }}&status={{ current_status }}&location={{ current_location }}"><i class="bi bi-chevron-right"></i></a></li>
{% endif %}
</ul>
</nav>
{% endif %}
<div class="text-light opacity-75 small mt-2">
共 {{ page_obj.paginator.count }} 条记录,第 {{ page_obj.number }}/{{ page_obj.paginator.num_pages }} 页
</div>
{% endblock %}