diff --git a/inventory/templates/inventory/barcode_product_form.html b/inventory/templates/inventory/barcode_product_form.html index 98ec626..add539b 100644 --- a/inventory/templates/inventory/barcode_product_form.html +++ b/inventory/templates/inventory/barcode_product_form.html @@ -269,6 +269,16 @@ +
+
+ + + {% if form.is_active.errors %} +
{{ form.is_active.errors }}
+ {% endif %} +
+
+
{% if form.description.errors %} diff --git a/inventory/templates/inventory/index.html b/inventory/templates/inventory/index.html index 6860017..5aa0196 100644 --- a/inventory/templates/inventory/index.html +++ b/inventory/templates/inventory/index.html @@ -97,55 +97,6 @@
- -
- -
-
-
-
热销商品
-
-
- {% if top_products %} -
- {% for product in top_products %} -
-
-
{{ product.product__name }}
- {{ product.total_qty }} -
- 销售额: ¥{{ product.total_amount|floatformat:2 }} -
- {% endfor %} -
- {% else %} -

暂无销售数据

- {% endif %} -
-
-
- - -
-
-
-
库存预警
-
-
- {% if low_stock_products > 0 %} -
- 注意: 有 {{ low_stock_products }} 个商品库存不足,其中 {{ out_of_stock_products }} 个商品已无库存! -
- 查看库存不足商品 - {% else %} -
- 所有商品库存充足 -
- {% endif %} -
-
-
-
@@ -158,7 +109,7 @@ 查看全部 -
+
{% if birthday_members %}
{% for member in birthday_members %} @@ -190,13 +141,65 @@ {% endif %}
- - -
+
+
+ + +
+ +
+
+
+
热销商品
+
+
+ {% if top_products %} +
+ {% for product in top_products %} +
+
+
{{ product.product__name }}
+ {{ product.total_qty }} +
+ 销售额: ¥{{ product.total_amount|floatformat:2 }} +
+ {% endfor %} +
+ {% else %} +

暂无销售数据

+ {% endif %} +
+
+
+ + +
+
+
+
库存预警
+
+
+ {% if low_stock_products > 0 %} +
+ 注意: 有 {{ low_stock_products }} 个商品库存不足,其中 {{ out_of_stock_products }} 个商品已无库存! +
+ 查看库存不足商品 + {% else %} +
+ 所有商品库存充足 +
+ {% endif %} +
+
+
+ + +
+
最近操作
-
+
{% if recent_logs %}
{% for log in recent_logs %} @@ -238,6 +241,40 @@ justify-content: center; font-size: 14px; } + + /* 添加固定高度和滚动样式 */ + .card-scrollable { + height: 250px; + overflow-y: auto; + scrollbar-width: thin; + } + + /* 美化滚动条 */ + .card-scrollable::-webkit-scrollbar { + width: 5px; + } + + .card-scrollable::-webkit-scrollbar-track { + background: #f1f1f1; + } + + .card-scrollable::-webkit-scrollbar-thumb { + background: #888; + border-radius: 5px; + } + + .card-scrollable::-webkit-scrollbar-thumb:hover { + background: #555; + } + + /* 确保卡片有统一的高度 */ + .col-md-4 .card { + height: 100%; + } + + .col-md-4 .card-body { + padding: 0.75rem; + } {% block extra_js %} diff --git a/inventory/views_barcode.py b/inventory/views_barcode.py index f697473..8531599 100644 --- a/inventory/views_barcode.py +++ b/inventory/views_barcode.py @@ -41,7 +41,8 @@ def barcode_product_create(request): 'manufacturer': barcode_data.get('manufacturer', ''), 'price': barcode_data.get('suggested_price', 0), 'cost': barcode_data.get('suggested_price', 0) * 0.8 if barcode_data.get('suggested_price') else 0, # 默认成本价为建议售价的80% - 'description': barcode_data.get('description', '') + 'description': barcode_data.get('description', ''), + 'is_active': True # 确保初始化时is_active为True } # 尝试从数据库中查找匹配的商品类别 @@ -57,14 +58,16 @@ def barcode_product_create(request): messages.success(request, '成功获取商品信息,请确认并完善商品详情') else: messages.info(request, f'未找到条码 {barcode} 的商品信息,请手动填写') - initial_data = {'barcode': barcode} + initial_data = {'barcode': barcode, 'is_active': True} # 确保初始化时is_active为True # 处理表单提交 if request.method == 'POST': form = forms.ProductForm(request.POST, request.FILES) if form.is_valid(): - # 保存商品信息 - product = form.save() + # 确保is_active为True + product = form.save(commit=False) + product.is_active = True + product.save() # 创建初始库存记录 initial_stock = request.POST.get('initial_stock', 0)