diff --git a/inventory-backend/app/api/v1/inbound/product.py b/inventory-backend/app/api/v1/inbound/product.py index 091479b..c4c2aac 100644 --- a/inventory-backend/app/api/v1/inbound/product.py +++ b/inventory-backend/app/api/v1/inbound/product.py @@ -114,3 +114,15 @@ def get_user_suggestions(): keyword = request.args.get('keyword', '') data = ProductInboundService.search_system_users(keyword) return jsonify({"code": 200, "msg": "success", "data": data}) + + +# ------------------------------------------------------------------ +# 7. 获取筛选选项 +# ------------------------------------------------------------------ +@inbound_product_bp.route('/options', methods=['GET']) +def get_options(): + try: + data = ProductInboundService.get_filter_options() + return jsonify({"code": 200, "msg": "success", "data": data}) + except Exception as e: + return jsonify({"code": 500, "msg": str(e)}), 500 diff --git a/inventory-backend/app/api/v1/inbound/semi.py b/inventory-backend/app/api/v1/inbound/semi.py index 1fb2f89..c2b4c4f 100644 --- a/inventory-backend/app/api/v1/inbound/semi.py +++ b/inventory-backend/app/api/v1/inbound/semi.py @@ -128,3 +128,15 @@ def get_user_suggestions(): keyword = request.args.get('keyword', '') data = SemiInboundService.search_system_users(keyword) return jsonify({"code": 200, "msg": "success", "data": data}) + + +# ------------------------------------------------------------------ +# 7. 获取筛选选项 +# ------------------------------------------------------------------ +@inbound_semi_bp.route('/options', methods=['GET']) +def get_options(): + try: + data = SemiInboundService.get_filter_options() + return jsonify({"code": 200, "msg": "success", "data": data}) + except Exception as e: + return jsonify({"code": 500, "msg": str(e)}), 500 diff --git a/inventory-backend/app/api/v1/inbound/service.py b/inventory-backend/app/api/v1/inbound/service.py index 43df132..e9a3057 100644 --- a/inventory-backend/app/api/v1/inbound/service.py +++ b/inventory-backend/app/api/v1/inbound/service.py @@ -162,3 +162,16 @@ def get_user_suggestions(): keyword = request.args.get('keyword', '') data = ServiceService.search_system_users(keyword) return jsonify({'code': 200, 'msg': 'success', 'data': data}) + + +# ------------------------------------------------------------------ +# 获取筛选选项 +# ------------------------------------------------------------------ +@inbound_bp.route('/service/options', methods=['GET']) +@jwt_required() +def get_options(): + try: + data = ServiceService.get_filter_options() + return jsonify({'code': 200, 'msg': 'success', 'data': data}) + except Exception as e: + return jsonify({'code': 500, 'msg': str(e)}), 500 diff --git a/inventory-backend/app/services/inbound/product_service.py b/inventory-backend/app/services/inbound/product_service.py index ec4b160..da06ce3 100644 --- a/inventory-backend/app/services/inbound/product_service.py +++ b/inventory-backend/app/services/inbound/product_service.py @@ -280,7 +280,7 @@ class ProductInboundService: # 6. 获取列表 # ============================================================ @staticmethod - def get_list(page, limit, keyword=None, statuses=None): + def get_list(page, limit, keyword=None, statuses=None, category=None, material_type=None): from app.models.inbound.product import StockProduct try: query = db.session.query(StockProduct).outerjoin(MaterialBase, StockProduct.base_id == MaterialBase.id) @@ -295,6 +295,13 @@ class ProductInboundService: StockProduct.sku.ilike(f'%{keyword}%') )) + # 类别筛选 + if category and category.strip(): + query = query.filter(MaterialBase.category == category.strip()) + # 类型筛选 + if material_type and material_type.strip(): + query = query.filter(MaterialBase.material_type == material_type.strip()) + if not statuses: statuses = ['在库', '借库'] @@ -377,3 +384,25 @@ class ProductInboundService: return users except Exception: return [] + + # ============================================================ + # 8. 获取筛选选项(类别、类型) + # ============================================================ + @staticmethod + def get_filter_options(): + try: + from app.models.base import MaterialBase + categories = db.session.query(MaterialBase.category) \ + .filter(MaterialBase.category != None, MaterialBase.category != '') \ + .distinct().all() + types = db.session.query(MaterialBase.material_type) \ + .filter(MaterialBase.material_type != None, MaterialBase.material_type != '') \ + .distinct().all() + return { + "categories": [r[0] for r in categories], + "types": [r[0] for r in types] + } + except Exception: + import traceback + traceback.print_exc() + return {"categories": [], "types": []} diff --git a/inventory-backend/app/services/inbound/semi_service.py b/inventory-backend/app/services/inbound/semi_service.py index fb49896..f9a770c 100644 --- a/inventory-backend/app/services/inbound/semi_service.py +++ b/inventory-backend/app/services/inbound/semi_service.py @@ -378,7 +378,7 @@ class SemiInboundService: # 6. 获取列表 # ============================================================ @staticmethod - def get_list(page, limit, keyword=None, statuses=None): + def get_list(page, limit, keyword=None, statuses=None, category=None, material_type=None): from app.models.inbound.semi import StockSemi try: query = db.session.query(StockSemi).outerjoin(MaterialBase, StockSemi.base_id == MaterialBase.id) @@ -397,6 +397,13 @@ class SemiInboundService: ) ) + # 类别筛选 + if category and category.strip(): + query = query.filter(MaterialBase.category == category.strip()) + # 类型筛选 + if material_type and material_type.strip(): + query = query.filter(MaterialBase.material_type == material_type.strip()) + if not statuses: statuses = ['在库', '借库'] @@ -479,3 +486,25 @@ class SemiInboundService: return users except Exception: return [] + + # ============================================================ + # 8. 获取筛选选项(类别、类型) + # ============================================================ + @staticmethod + def get_filter_options(): + try: + from app.models.base import MaterialBase + categories = db.session.query(MaterialBase.category) \ + .filter(MaterialBase.category != None, MaterialBase.category != '') \ + .distinct().all() + types = db.session.query(MaterialBase.material_type) \ + .filter(MaterialBase.material_type != None, MaterialBase.material_type != '') \ + .distinct().all() + return { + "categories": [r[0] for r in categories], + "types": [r[0] for r in types] + } + except Exception: + import traceback + traceback.print_exc() + return {"categories": [], "types": []} diff --git a/inventory-backend/app/services/inbound/service_service.py b/inventory-backend/app/services/inbound/service_service.py index 8ffe865..9135204 100644 --- a/inventory-backend/app/services/inbound/service_service.py +++ b/inventory-backend/app/services/inbound/service_service.py @@ -204,3 +204,25 @@ class ServiceService: return users except Exception: return [] + + # ============================================================ + # 获取筛选选项(类别、类型) + # ============================================================ + @classmethod + def get_filter_options(cls): + try: + from app.models.base import MaterialBase + categories = db.session.query(MaterialBase.category) \ + .filter(MaterialBase.category != None, MaterialBase.category != '') \ + .distinct().all() + types = db.session.query(MaterialBase.material_type) \ + .filter(MaterialBase.material_type != None, MaterialBase.material_type != '') \ + .distinct().all() + return { + "categories": [r[0] for r in categories], + "types": [r[0] for r in types] + } + except Exception: + import traceback + traceback.print_exc() + return {"categories": [], "types": []} diff --git a/inventory-web/src/api/inbound/product.ts b/inventory-web/src/api/inbound/product.ts index cb15cdd..d342203 100644 --- a/inventory-web/src/api/inbound/product.ts +++ b/inventory-web/src/api/inbound/product.ts @@ -49,3 +49,11 @@ export function getUserSuggestions(params: any) { params }) } + +// 筛选选项 +export function getFilterOptions() { + return request({ + url: '/inbound/product/options', + method: 'get' + }) +} diff --git a/inventory-web/src/api/inbound/semi.ts b/inventory-web/src/api/inbound/semi.ts index 028a1de..0a9a0c6 100644 --- a/inventory-web/src/api/inbound/semi.ts +++ b/inventory-web/src/api/inbound/semi.ts @@ -52,3 +52,11 @@ export function getUserSuggestions(params: any) { params }) } + +// 筛选选项 +export function getFilterOptions() { + return request({ + url: '/inbound/semi/options', + method: 'get' + }) +} diff --git a/inventory-web/src/api/inbound/service.ts b/inventory-web/src/api/inbound/service.ts index dd85a27..e8a95f8 100644 --- a/inventory-web/src/api/inbound/service.ts +++ b/inventory-web/src/api/inbound/service.ts @@ -122,6 +122,14 @@ export function getUserSuggestions(params: any) { }) } +// 筛选选项 +export function getFilterOptions() { + return request({ + url: '/v1/inbound/service/options', + method: 'get' + }) +} + // 删除服务权益 export function deleteService(id: number) { return request({ diff --git a/inventory-web/src/views/stock/inbound/semi.vue b/inventory-web/src/views/stock/inbound/semi.vue index 788929a..c8bcbbc 100644 --- a/inventory-web/src/views/stock/inbound/semi.vue +++ b/inventory-web/src/views/stock/inbound/semi.vue @@ -1,21 +1,36 @@