first push
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
{% 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" aria-current="page">Assets</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Add Asset</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div>
|
||||
<a href="{% url 'assets:list' %}" class="btn btn-sm btn-outline-info my-3">返回资产列表</a>
|
||||
</div>
|
||||
<form class="form row" action="{% url 'assets:add' %}" method="POST" novalidate>
|
||||
{% csrf_token %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<button type="submit" class="btn btn-sm btn-info float-end">保存</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="city-column">产品</label>
|
||||
{{form.product}}
|
||||
{% for error in form.product.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="country-floating">供应商</label>
|
||||
{{form.vendor}}
|
||||
{% for error in form.vendor.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">办公地点</label>
|
||||
{{form.location}}
|
||||
{% for error in form.location.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="company-column">资产名称</label>
|
||||
{{form.name}}
|
||||
{% for error in form.name.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">序列号</label>
|
||||
{{form.serial_no}}
|
||||
{% for error in form.serial_no.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">价格</label>
|
||||
{{form.price}}
|
||||
{% for error in form.price.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="country-floating">购买类型</label>
|
||||
{{form.purchase_type}}
|
||||
{% for error in form.purchase_type.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">购买日期</label>
|
||||
{{form.purchase_date}}
|
||||
{% for error in form.purchase_date.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">保修到期日期</label>
|
||||
{{form.warranty_expiry_date}}
|
||||
{% for error in form.warranty_expiry_date.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">描述</label>
|
||||
{{form.description}}
|
||||
{% for error in form.description.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">资产规格</div>
|
||||
<div class="card-body" id="container">
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="first-name-column">Specification Name</label> -->
|
||||
<input type="text" id="first-name-column" class="form-control"
|
||||
placeholder="Specification Name" name="specifications_name" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="last-name-column">Specification Value</label> -->
|
||||
<input type="text" id="last-name-column" class="form-control"
|
||||
placeholder="Specification Value" name="specifications_value" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto" id="mainsections">
|
||||
<div class="form-group">
|
||||
<button type="button" id="newsectionbtn" class="btn btn-sm btn-info"><i class="bi bi-plus-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display:none">
|
||||
<div class="row rmsection" id="mainsection">
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="first-name-column">Specification Name</label> -->
|
||||
<input type="text" id="first-name-column" class="form-control"
|
||||
placeholder="Specification Name" name="specifications_name" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="last-name-column">Specification Value</label> -->
|
||||
<input type="text" id="last-name-column" class="form-control"
|
||||
placeholder="Specification Value" name="specifications_value" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-group">
|
||||
<button type="button" onclick="remove(this)" class="btn btn-sm btn-danger"><i class="bi bi-dash-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("newsectionbtn").onclick = function() {
|
||||
var container = document.getElementById("container");
|
||||
var section = document.getElementById("mainsection");
|
||||
container.appendChild(section.cloneNode(true));
|
||||
}
|
||||
|
||||
function remove(el) {
|
||||
var element = el;
|
||||
element.closest(".rmsection").remove()
|
||||
}
|
||||
</script>
|
||||
{% endblock content%}
|
||||
@@ -0,0 +1,68 @@
|
||||
{% if page_object %}
|
||||
{% for asset in page_object %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if page_object.start_index %}
|
||||
{{page_object.start_index|add:forloop.counter0}}
|
||||
{% else %}
|
||||
{{forloop.counter}}
|
||||
{% endif %}
|
||||
</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 %}
|
||||
{% else %}
|
||||
<td colspan="9" class="text-center"> No record found related to your search keyword</td>
|
||||
{% endif %}
|
||||
@@ -0,0 +1,47 @@
|
||||
<div class="modal-header bg-dark text-center">
|
||||
<h5 class="modal-title white w-100" id="myModalLabel160">Reassign Asset</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||
aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
<form hx-post='{{request.path}}' novalidate>
|
||||
{% csrf_token %}
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label>Asset Name</label>
|
||||
{{form.asset}}
|
||||
{% for error in form.asset.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Assign To</label>
|
||||
{{form.user}}
|
||||
{% for error in form.user.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-light-secondary"
|
||||
data-bs-dismiss="modal">
|
||||
<i class="bx bx-x d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block">Close</span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-sm btn-info ml-1"
|
||||
onclick="this.innerHTML = `<span class='spinner-grow spinner-grow-sm' role='status' aria-hidden='true'></span> Saving...`;"
|
||||
>
|
||||
<i class="bx bx-check d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block">Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
htmx.on("htmx:beforeSwap", (e) => {
|
||||
if ((e.detail.target.id == "assign-asset-modal-content") && !e.detail.xhr.response) {
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,40 @@
|
||||
{% if page_object %}
|
||||
{% for assign_asset in page_object %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if page_object.start_index %}
|
||||
{{page_object.start_index|add:forloop.counter0}}
|
||||
{% else %}
|
||||
{{forloop.counter}}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{assign_asset.asset.name}}</td>
|
||||
<td>{{assign_asset.asset.serial_no}}</td>
|
||||
<td>
|
||||
{{assign_asset.user.full_name}}
|
||||
{% if assign_asset.user.is_deleted %}
|
||||
<i class="bi bi-exclamation-triangle text-warning" title="User is deleted, please update."></i>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{assign_asset.user.department.name}}</td>
|
||||
<td>
|
||||
{% if perms.authentication.reassign_assign_asset %}
|
||||
<button type="button" class="btn btn-info btn-sm"
|
||||
hx-get="{% url 'assets:reassign_asset' assign_asset.id %}" hx-target="#reassign-asset-modal-content"
|
||||
data-bs-toggle="modal" data-bs-target="#reassign-asset-modal"
|
||||
>Reassign</button>
|
||||
{% endif %}
|
||||
{% if perms.authentication.delete_assign_asset %}
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
|
||||
<form action="{% url 'assets:delete_assign' assign_asset.id %}" method="post" onsubmit="return confirm('Are you sure you want to unassign this?')">
|
||||
{% csrf_token %}
|
||||
<button type="submit" value="Delete" class="btn btn-sm btn-danger">Unassign</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<td colspan="9" class="text-center"> No record found related to your search keyword</td>
|
||||
{% endif %}
|
||||
@@ -0,0 +1,108 @@
|
||||
{% 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">
|
||||
<!-- assign modal -->
|
||||
<div class="modal fade text-left" id="assign-asset-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel160" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div id="assign-asset-modal-content" class="modal-content" hx-target="this"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% if perms.authentication.add_assign_asset %}
|
||||
<!-- assign btn -->
|
||||
<button type="button" class="btn btn-sm btn-outline-info my-3"
|
||||
hx-get="{% url 'assets:assign_asset' %}" hx-target="#assign-asset-modal-content"
|
||||
data-bs-toggle="modal" data-bs-target="#assign-asset-modal"
|
||||
>分配资产</button>
|
||||
{% endif %}
|
||||
|
||||
<!-- reassign modal -->
|
||||
<div class="modal fade text-left" id="reassign-asset-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel160" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div id="reassign-asset-modal-content" class="modal-content" hx-target="this"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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:assign_asset_search' page_object.number %}" hx-trigger="keyup changed delay:500ms, search" hx-target="#search_result">
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-hover" id="table1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>资产名称</th>
|
||||
<th>序列号</th>
|
||||
<th>分配给</th>
|
||||
<th>部门</th>
|
||||
{% if perms.authentication.reassign_assign_asset or perms.authentication.delete_assign_asset%}
|
||||
<th>操作</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
{% if page_object %}
|
||||
<tbody id="search_result">
|
||||
{% for assign_asset in page_object %}
|
||||
<tr>
|
||||
<td>{{page_object.start_index|add:forloop.counter0}}</td>
|
||||
<td>{{assign_asset.asset.name}}</td>
|
||||
<td>{{assign_asset.asset.serial_no}}</td>
|
||||
<td>
|
||||
{{assign_asset.user.full_name}}
|
||||
{% if assign_asset.user.is_deleted %}
|
||||
<i class="bi bi-exclamation-triangle text-warning" title="User is deleted, please update or restore."></i>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{assign_asset.user.department.name}}</td>
|
||||
<td>
|
||||
{% if perms.authentication.reassign_assign_asset %}
|
||||
<button type="button" class="btn btn-info btn-sm"
|
||||
hx-get="{% url 'assets:reassign_asset' assign_asset.id %}" hx-target="#reassign-asset-modal-content"
|
||||
data-bs-toggle="modal" data-bs-target="#reassign-asset-modal"
|
||||
>Reassign</button>
|
||||
{% endif %}
|
||||
{% if perms.authentication.delete_assign_asset %}
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
|
||||
<form action="{% url 'assets:delete_assign' assign_asset.id %}" method="post" onsubmit="return confirm('Are you sure you want to unassign this?')">
|
||||
{% csrf_token %}
|
||||
<button type="submit" value="Delete" class="btn btn-sm btn-danger">Unassign</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</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%}
|
||||
@@ -0,0 +1,116 @@
|
||||
{% 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>Asset Details</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" aria-current="page">Assets</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Asset Details</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div>
|
||||
<a href="{% url 'assets:list' %}" class="btn btn-sm btn-outline-info my-3">Back to Asset List</a>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="my-3">
|
||||
<i class="bi bi-pc-display"></i>
|
||||
<span>Asset Information</span>
|
||||
</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">Asset Name</th>
|
||||
<td>{{asset.name}}</td>
|
||||
<th scope="row">Vendor</th>
|
||||
<td>{{asset.vendor}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Product</th>
|
||||
<td>{{asset.product}}</td>
|
||||
<th scope="row">Product Type</th>
|
||||
<td>{{asset.product.product_type}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Product Category</th>
|
||||
<td>{{asset.product.product_category}}</td>
|
||||
<th scope="row">Serial No.</th>
|
||||
<td>{{asset.serial_no}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Price</th>
|
||||
<td>{{asset.price}}</td>
|
||||
<th scope="row">Office Location</th>
|
||||
<td>{{asset.location}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Purchase Date</th>
|
||||
<td>{{asset.purchase_date}}</td>
|
||||
<th scope="row">Warranty Expiry Date</th>
|
||||
<td>{{asset.warranty_expiry_date}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td colspan="3">{{asset.description|urlize}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="accordion" id="accordionExample">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#specifications" aria-expanded="true" aria-controls="collapseOne">
|
||||
Asset Specifications
|
||||
</button>
|
||||
</h2>
|
||||
<div id="specifications" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
|
||||
<div class="accordion-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Specification Name</th>
|
||||
<th>Specification Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if assetSpecifications %}
|
||||
{% for assetSpecification in assetSpecifications %}
|
||||
<tr>
|
||||
<th scope="row">
|
||||
{{assetSpecification.name}}
|
||||
</th>
|
||||
<td>
|
||||
{{assetSpecification.value}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'commons/history.html' %}
|
||||
</section>
|
||||
</div>
|
||||
{% endblock content%}
|
||||
@@ -0,0 +1,121 @@
|
||||
{% 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%}
|
||||
@@ -0,0 +1,40 @@
|
||||
<div class="modal-header bg-dark text-center">
|
||||
<h5 class="modal-title white w-100" id="myModalLabel160">Reassign Asset</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||
aria-label="Close">
|
||||
</button>
|
||||
</div>
|
||||
<form hx-post='{{request.path}}' novalidate>
|
||||
{% csrf_token %}
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="last-name-column">Assign To</label>
|
||||
{{form.user}}
|
||||
{% for error in form.user.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-light-secondary"
|
||||
data-bs-dismiss="modal">
|
||||
<i class="bx bx-x d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block">Close</span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-sm btn-info ml-1"
|
||||
onclick="this.innerHTML = `<span class='spinner-grow spinner-grow-sm' role='status' aria-hidden='true'></span> Saving...`;"
|
||||
>
|
||||
<i class="bx bx-check d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block">Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
htmx.on("htmx:beforeSwap", (e) => {
|
||||
if ((e.detail.target.id == "reassign-asset-modal-content") && !e.detail.xhr.response) {
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,226 @@
|
||||
{% 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>Update Asset</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">Assets</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Update Asset</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div>
|
||||
<a href="{% url 'assets:list' %}" class="btn btn-sm btn-outline-info my-3">Back to Asset List</a>
|
||||
</div>
|
||||
<form class="form row" method="POST" action="{{request.path}}" novalidate>
|
||||
{% csrf_token %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<button type="submit" class="btn btn-sm btn-info float-end">Save</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="city-column">Product</label>
|
||||
{{form.product}}
|
||||
{% for error in form.product.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="country-floating">Vendor</label>
|
||||
{{form.vendor}}
|
||||
{% for error in form.vendor.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">Office Location</label>
|
||||
{{form.location}}
|
||||
{% for error in form.location.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="company-column">Asset Name</label>
|
||||
{{form.name}}
|
||||
{% for error in form.name.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">Serial No.</label>
|
||||
{{form.serial_no}}
|
||||
{% for error in form.serial_no.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">Price</label>
|
||||
{{form.price}}
|
||||
{% for error in form.price.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="country-floating">Purchase Type</label>
|
||||
{{form.purchase_type}}
|
||||
{% for error in form.purchase_type.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">Purchase Date</label>
|
||||
{{form.purchase_date}}
|
||||
{% for error in form.purchase_date.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">Warranty Expiry Date</label>
|
||||
{{form.warranty_expiry_date}}
|
||||
{% for error in form.warranty_expiry_date.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-12">
|
||||
<div class="form-group">
|
||||
<label for="email-id-column">Description</label>
|
||||
{{form.description}}
|
||||
{% for error in form.description.errors %}
|
||||
<small class="text-danger mb-3">{{ error }}</small>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">Asset Specifications</div>
|
||||
<div class="card-body" id="container">
|
||||
{% if assetSpecifications %}
|
||||
{% for assetSpecification in assetSpecifications %}
|
||||
<div class="row rmsection">
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="first-name-column">Specification Name</label> -->
|
||||
<input type="text" id="first-name-column" class="form-control"
|
||||
placeholder="Specification Name" name="specifications_name" autocomplete="off" value="{{assetSpecification.name}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="last-name-column">Specification Value</label> -->
|
||||
<input type="text" id="last-name-column" class="form-control"
|
||||
placeholder="Specification Value" name="specifications_value" autocomplete="off" value="{{assetSpecification.value}}">
|
||||
</div>
|
||||
</div>
|
||||
{% if forloop.counter == 1 %}
|
||||
<div class="col-auto">
|
||||
<div class="form-group">
|
||||
<button type="button" id="newsectionbtn" class="btn btn-sm btn-info"><i class="bi bi-plus-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-auto">
|
||||
<div class="form-group">
|
||||
<button type="button" onclick="remove(this)" class="btn btn-sm btn-danger"><i class="bi bi-dash-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="first-name-column">Specification Name</label> -->
|
||||
<input type="text" id="first-name-column" class="form-control"
|
||||
placeholder="Specification Name" name="specifications_name" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="last-name-column">Specification Value</label> -->
|
||||
<input type="text" id="last-name-column" class="form-control"
|
||||
placeholder="Specification Value" name="specifications_value" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-group">
|
||||
<button type="button" id="newsectionbtn" class="btn btn-sm btn-info"><i class="bi bi-plus-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div style="display:none">
|
||||
<div class="row rmsection" id="mainsection">
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="first-name-column">Specification Name</label> -->
|
||||
<input type="text" id="first-name-column" class="form-control"
|
||||
placeholder="Specification Name" name="specifications_name" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="form-group">
|
||||
<!-- <label for="last-name-column">Specification Value</label> -->
|
||||
<input type="text" id="last-name-column" class="form-control"
|
||||
placeholder="Specification Value" name="specifications_value" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-group">
|
||||
<button type="button" onclick="remove(this)" class="btn btn-sm btn-danger"><i class="bi bi-dash-lg"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("newsectionbtn").onclick = function() {
|
||||
var container = document.getElementById("container");
|
||||
var section = document.getElementById("mainsection");
|
||||
container.appendChild(section.cloneNode(true));
|
||||
}
|
||||
|
||||
function remove(el) {
|
||||
var element = el;
|
||||
element.closest(".rmsection").remove()
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock content%}
|
||||
Reference in New Issue
Block a user