Files
eam-project/templates/assets/list.html
T
2025-05-23 14:44:12 +08:00

121 lines
6.3 KiB
HTML

{% extends 'layouts/main-layout.html' %}
{% block content %}
<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>资产</h3>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page">Assets</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
{% if perms.authentication.add_asset %}
<div>
<a href="{% url 'assets:add' %}" class="btn btn-sm btn-outline-info my-3">添加资产</a>
</div>
{% endif %}
<div class="card">
<div class="card-body">
{% if page_object %}
<div class="d-flex justify-content-end my-2 gap-2">
<input name="search_text" type="search" class='dataTable-input' autocomplete="off" placeholder='Search here...'
hx-get="{% url 'assets:search' page_object.number %}" hx-trigger="keyup changed delay:500ms, search" hx-target="#search_result">
</div>
{% endif %}
<table class="table" id="table1">
<thead>
<tr>
<th>序号</th>
<th>资产名称</th>
<th>序列号</th>
<th>产品类型</th>
<th>产品</th>
<th>供应商</th>
<th>当前状态</th>
<th>状态</th>
{% if perms.authentication.edit_asset or perms.authentication.view_asset or perms.authentication.delete_asset %}
<th>操作</th>
{% endif %}
</tr>
</thead>
{% if page_object %}
<tbody id="search_result">
{% for asset in page_object %}
<tr>
<td>{{page_object.start_index|add:forloop.counter0}}</td>
<td>{{asset.name}}</td>
<td>{{asset.serial_no}}</td>
<td>{{asset.product.product_type}}</td>
<td>
{{asset.product}}
{% if asset.product.is_deleted %}
<i class="bi bi-exclamation-triangle text-warning" title="Product is deleted, please update or restore."></i>
{% endif %}
</td>
<td>
{{asset.vendor}}
{% if asset.vendor.is_deleted %}
<i class="bi bi-exclamation-triangle text-warning" title="Vendor is deleted, please update or restore."></i>
{% endif %}
</td>
<td>
{% if asset.is_assigned %}
In Use
{% else %}
In Store
{% endif %}
</td>
<td>
{% if request.user.is_superuser %}
<div class="form-check form-switch">
<input
class="form-check-input"
hx-post="{% url 'assets:status' asset.id %}"
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
type="checkbox" {% if asset.status %} checked {% endif %}
style="cursor: pointer;"
>
</div>
{% else %}
{% if products.status %} Active {% else %} Inactive {% endif %}
{% endif %}
</td>
<td>
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
{% if perms.authentication.view_asset %}
<a href="{% url 'assets:details' asset.id %}" class="btn btn-success"><i class="bi bi-eye-fill"></i></a>
{% endif %}
{% if perms.authentication.edit_asset %}
<a href="{% url 'assets:update' asset.id %}"type="button" class="btn btn-info"><i class="bi bi-pencil-square"></i></a>
{% endif %}
{% if perms.authentication.delete_asset %}
<form action="{% url 'assets:delete' asset.id %}" method="post" onsubmit="return confirm('Are you sure you want to delete this?')">
{% csrf_token %}
<button type="submit" value="Delete" class="btn btn-sm btn-danger"><i class="bi bi-trash3-fill"></i></button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
{% else %}
<div class="alert alert-info" role="alert">
暂无记录
</div>
{% endif %}
</table>
{% include 'commons/pagination.html' %}
</div>
</div>
</section>
</div>
{% endblock content%}