Преглед изворни кода

feat: 位置字段改名为机房,移动到ID列后面;优化列表列宽和截断

cnbugs пре 4 недеља
родитељ
комит
cb057b431e

+ 1 - 1
assetapp/excel_utils.py

@@ -16,7 +16,7 @@ EXPORT_COLUMNS = [
     ('model', '型号', 20),
     ('asset_value', '资产面值', 12),
     ('serial_number', '序列号', 25),
-    ('location', '设备位置', 20),
+    ('location', '机房', 20),
     ('cabinet', '机柜', 10),
     ('cabinet_position', '机柜位置', 10),
     ('bmc_address', 'BMC地址', 16),

+ 18 - 0
assetapp/migrations/0008_alter_asset_location.py

@@ -0,0 +1,18 @@
+# Generated by Django 5.2.13 on 2026-04-28 04:54
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('assetapp', '0007_asset_business_type_asset_gpu_count_asset_gpu_type_and_more'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='asset',
+            name='location',
+            field=models.CharField(blank=True, default='', help_text='楼层/房间/区域', max_length=200, verbose_name='机房'),
+        ),
+    ]

+ 1 - 1
assetapp/models.py

@@ -40,7 +40,7 @@ class Asset(models.Model):
     serial_number = models.CharField('序列号', max_length=100, blank=True, default='', db_index=True)
 
     # 位置信息
-    location = models.CharField('设备位置', max_length=200, blank=True, default='', help_text='楼层/房间/区域')
+    location = models.CharField('机房', max_length=200, blank=True, default='', help_text='楼层/房间/区域')
     cabinet = models.CharField('机柜', max_length=50, blank=True, default='')
     cabinet_position = models.CharField('机柜位置', max_length=50, blank=True, default='', help_text='U位')
 

+ 1 - 1
templates/assetapp/asset_detail.html

@@ -52,7 +52,7 @@
             <div class="card-header"><i class="bi bi-geo-alt me-2"></i>位置与网络</div>
             <div class="card-body">
                 <table class="table table-dark table-borderless mb-0 detail-table">
-                    <tr><td class="text-muted" width="120">设备位置</td><td>{{ asset.location|default:"-" }}</td></tr>
+                    <tr><td class="text-muted" width="120">机房</td><td>{{ asset.location|default:"-" }}</td></tr>
                     <tr><td class="text-muted">机柜</td><td>{{ asset.cabinet|default:"-" }}</td></tr>
                     <tr><td class="text-muted">机柜位置</td><td>{{ asset.cabinet_position|default:"-" }}</td></tr>
                     <tr><td class="text-muted">BMC地址</td><td><code>{{ asset.bmc_address|default:"-" }}</code></td></tr>

+ 4 - 4
templates/assetapp/asset_list.html

@@ -70,14 +70,14 @@
                 <thead>
                     <tr>
                         <th style="width:50px">ID</th>
-                        <th style="width:60px">机柜</th>
-                        <th style="width:150px">机柜位置</th>
+                        <th style="width:100px">机房</th>
+                        <th style="width:80px">机柜</th>
+                        <th style="width:120px">机柜位置</th>
                         <th style="width:80px">资产编号</th>
                         <th>设备名称</th>
                         <th>分类</th>
                         <th>品牌/型号</th>
                         <th>资产面值</th>
-                        <th style="width:80px">位置</th>
                         <th>BMC地址</th>
                         <th>IP地址</th>
                         <th>显卡类型</th>
@@ -94,6 +94,7 @@
                     {% for asset in page_obj %}
                     <tr>
                         <td class="text-muted small" title="{{ asset.id }}">{{ asset.id|stringformat:"s"|truncatechars:3 }}</td>
+                        <td title="{{ asset.location }}">{{ asset.location|default:"-"|truncatechars:5 }}</td>
                         <td title="{{ asset.cabinet }}">{{ asset.cabinet|default:"-"|truncatechars:3 }}</td>
                         <td title="{{ asset.cabinet_position }}">{{ asset.cabinet_position|default:"-"|truncatechars:10 }}</td>
                         <td><a href="{% url 'asset_detail' asset.pk %}" class="text-info" title="{{ asset.asset_number }}">{{ asset.asset_number|truncatechars:3 }}</a></td>
@@ -101,7 +102,6 @@
                         <td><span class="badge bg-secondary">{{ asset.category.name }}</span></td>
                         <td>{{ asset.brand }} {% if asset.model %}{{ asset.model }}{% endif %}</td>
                         <td>{% if asset.asset_value %}¥{{ asset.asset_value }}{% else %}-{% endif %}</td>
-                        <td title="{{ asset.location }}">{{ asset.location|default:"-"|truncatechars:5 }}</td>
                         <td><code>{{ asset.bmc_address|default:"-" }}</code></td>
                         <td><code>{{ asset.ip_address|default:"-" }}</code></td>
                         <td>{{ asset.gpu_type|default:"-" }}</td>