asset_list.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. {% extends "assetapp/base.html" %}
  2. {% block title %}资产列表 - 希姆计算资产管理{% endblock %}
  3. {% block content %}
  4. <div class="d-flex justify-content-between align-items-center mb-4">
  5. <h4 class="mb-0"><i class="bi bi-list-ul me-2"></i>资产列表</h4>
  6. <div>
  7. <a href="{% url 'asset_export' %}" class="btn btn-outline-success btn-sm me-2">
  8. <i class="bi bi-download me-1"></i>导出Excel
  9. </a>
  10. <a href="{% url 'asset_import' %}" class="btn btn-outline-info btn-sm me-2">
  11. <i class="bi bi-upload me-1"></i>导入Excel
  12. </a>
  13. <a href="{% url 'asset_create' %}" class="btn btn-primary btn-sm">
  14. <i class="bi bi-plus-circle me-1"></i>新增资产
  15. </a>
  16. </div>
  17. </div>
  18. <!-- 搜索和筛选 -->
  19. <div class="card card-dark mb-3">
  20. <div class="card-body">
  21. <form method="get" class="row g-2 align-items-end">
  22. <div class="col-md-3">
  23. <label class="form-label text-muted small">搜索</label>
  24. <input type="text" name="search" class="form-control form-control-sm"
  25. placeholder="编号/名称/序列号/IP/BMC/品牌/型号/机柜/负责人/部门/维护人/业务类型..." value="{{ search }}">
  26. </div>
  27. <div class="col-md-2">
  28. <label class="form-label text-muted small">分类</label>
  29. <select name="category" class="form-select form-select-sm">
  30. <option value="">全部分类</option>
  31. {% for cat in categories %}
  32. <option value="{{ cat.id }}" {% if current_category == cat.id|stringformat:"s" %}selected{% endif %}>{{ cat.name }}</option>
  33. {% endfor %}
  34. </select>
  35. </div>
  36. <div class="col-md-2">
  37. <label class="form-label text-muted small">状态</label>
  38. <select name="status" class="form-select form-select-sm">
  39. <option value="">全部状态</option>
  40. {% for key, label in status_map.items %}
  41. <option value="{{ key }}" {% if current_status == key %}selected{% endif %}>{{ label }}</option>
  42. {% endfor %}
  43. </select>
  44. </div>
  45. <div class="col-md-2">
  46. <label class="form-label text-muted small">机柜</label>
  47. <select name="cabinet" class="form-select form-select-sm">
  48. <option value="">全部机柜</option>
  49. {% for cab in cabinets %}
  50. <option value="{{ cab }}" {% if current_cabinet == cab %}selected{% endif %}>{{ cab }}</option>
  51. {% endfor %}
  52. </select>
  53. </div>
  54. <div class="col-md-2">
  55. <label class="form-label text-muted small">业务类型</label>
  56. <select name="business_type" class="form-select form-select-sm">
  57. <option value="">全部业务</option>
  58. {% for bt in business_types %}
  59. <option value="{{ bt }}" {% if current_business_type == bt %}selected{% endif %}>{{ bt }}</option>
  60. {% endfor %}
  61. </select>
  62. </div>
  63. <div class="col-md-1">
  64. <button type="submit" class="btn btn-primary btn-sm me-1"><i class="bi bi-search"></i></button>
  65. <a href="{% url 'asset_list' %}" class="btn btn-outline-secondary btn-sm"><i class="bi bi-arrow-counterclockwise"></i></a>
  66. </div>
  67. </form>
  68. </div>
  69. </div>
  70. <!-- 资产表格 -->
  71. <div class="card card-dark">
  72. <div class="card-body p-0">
  73. <div class="table-responsive">
  74. <table class="table table-dark table-hover table-striped mb-0">
  75. <thead>
  76. <tr>
  77. <th style="width:50px">ID</th>
  78. <th style="width:100px">机房</th>
  79. <th style="width:80px">机柜</th>
  80. <th style="width:120px">机柜位置</th>
  81. <th style="width:80px">资产编号</th>
  82. <th>设备名称</th>
  83. <th>分类</th>
  84. <th>品牌/型号</th>
  85. <th>资产面值</th>
  86. <th>BMC地址</th>
  87. <th>IP地址</th>
  88. <th>显卡类型</th>
  89. <th>卡数</th>
  90. <th style="width:60px">负责人</th>
  91. <th>使用部门</th>
  92. <th style="width:60px">维护人</th>
  93. <th>业务类型</th>
  94. <th>状态</th>
  95. <th>操作</th>
  96. </tr>
  97. </thead>
  98. <tbody>
  99. {% for asset in page_obj %}
  100. <tr>
  101. <td class="text-muted small" title="{{ asset.id }}">{{ asset.id|stringformat:"s"|truncatechars:3 }}</td>
  102. <td title="{{ asset.location }}">{{ asset.location|default:"-"|truncatechars:5 }}</td>
  103. <td title="{{ asset.cabinet }}">{{ asset.cabinet|default:"-"|truncatechars:3 }}</td>
  104. <td title="{{ asset.cabinet_position }}">{{ asset.cabinet_position|default:"-"|truncatechars:10 }}</td>
  105. <td><a href="{% url 'asset_detail' asset.pk %}" class="text-info" title="{{ asset.asset_number }}">{{ asset.asset_number|truncatechars:3 }}</a></td>
  106. <td>{{ asset.name }}</td>
  107. <td><span class="badge bg-secondary">{{ asset.category.name }}</span></td>
  108. <td>{{ asset.brand }} {% if asset.model %}{{ asset.model }}{% endif %}</td>
  109. <td>{% if asset.asset_value %}¥{{ asset.asset_value }}{% else %}-{% endif %}</td>
  110. <td><code>{{ asset.bmc_address|default:"-" }}</code></td>
  111. <td><code>{{ asset.ip_address|default:"-" }}</code></td>
  112. <td>{{ asset.gpu_type|default:"-" }}</td>
  113. <td>{{ asset.gpu_count|default:"-" }}</td>
  114. <td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px" title="{{ asset.responsible_person }}">{{ asset.responsible_person|default:"-" }}</td>
  115. <td>{{ asset.department|default:"-" }}</td>
  116. <td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px" title="{{ asset.user }}">{{ asset.user|default:"-" }}</td>
  117. <td>{{ asset.business_type|default:"-" }}</td>
  118. <td>
  119. <span class="badge
  120. {% if asset.status == 'in_use' %}bg-success
  121. {% elif asset.status == 'idle' %}bg-warning text-dark
  122. {% elif asset.status == 'maintenance' %}bg-info
  123. {% else %}bg-danger{% endif %}">
  124. {{ asset.get_status_display }}
  125. </span>
  126. </td>
  127. <td>
  128. <a href="{% url 'asset_detail' asset.pk %}" class="btn btn-outline-info btn-xs" title="详情">
  129. <i class="bi bi-eye"></i>
  130. </a>
  131. <a href="{% url 'asset_update' asset.pk %}" class="btn btn-outline-warning btn-xs" title="编辑">
  132. <i class="bi bi-pencil"></i>
  133. </a>
  134. <a href="{% url 'asset_delete' asset.pk %}" class="btn btn-outline-danger btn-xs" title="删除">
  135. <i class="bi bi-trash"></i>
  136. </a>
  137. </td>
  138. </tr>
  139. {% empty %}
  140. <tr><td colspan="20" class="text-center text-light opacity-75 py-4">暂无资产数据</td></tr>
  141. {% endfor %}
  142. </tbody>
  143. </table>
  144. </div>
  145. </div>
  146. </div>
  147. <!-- 分页 -->
  148. {% if page_obj.has_other_pages %}
  149. <nav class="mt-3">
  150. <ul class="pagination pagination-sm justify-content-center">
  151. {% if page_obj.has_previous %}
  152. <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if search %}&search={{ search }}{% endif %}{% if current_category %}&category={{ current_category }}{% endif %}{% if current_status %}&status={{ current_status }}{% endif %}{% if current_cabinet %}&cabinet={{ current_cabinet }}{% endif %}{% if current_business_type %}&business_type={{ current_business_type }}{% endif %}"><i class="bi bi-chevron-left"></i></a></li>
  153. {% endif %}
  154. {% for num in page_obj.paginator.page_range %}
  155. {% if page_obj.number == num %}
  156. <li class="page-item active"><span class="page-link">{{ num }}</span></li>
  157. {% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
  158. <li class="page-item"><a class="page-link" href="?page={{ num }}{% if search %}&search={{ search }}{% endif %}{% if current_category %}&category={{ current_category }}{% endif %}{% if current_status %}&status={{ current_status }}{% endif %}{% if current_cabinet %}&cabinet={{ current_cabinet }}{% endif %}{% if current_business_type %}&business_type={{ current_business_type }}{% endif %}">{{ num }}</a></li>
  159. {% endif %}
  160. {% endfor %}
  161. {% if page_obj.has_next %}
  162. <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}{% if search %}&search={{ search }}{% endif %}{% if current_category %}&category={{ current_category }}{% endif %}{% if current_status %}&status={{ current_status }}{% endif %}{% if current_cabinet %}&cabinet={{ current_cabinet }}{% endif %}{% if current_business_type %}&business_type={{ current_business_type }}{% endif %}"><i class="bi bi-chevron-right"></i></a></li>
  163. {% endif %}
  164. </ul>
  165. </nav>
  166. {% endif %}
  167. <div class="text-light opacity-75 small mt-2">
  168. 共 {{ page_obj.paginator.count }} 条记录,第 {{ page_obj.number }}/{{ page_obj.paginator.num_pages }} 页
  169. </div>
  170. {% endblock %}