基础信息页:计量单位改 el-select(下拉历史+手动输入);表单排版重排为 4 行(类别占满行);类别末级英文后缀自动填规格型号
This commit is contained in:
@ -98,6 +98,24 @@ def search_base():
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# 1.1 计量单位字典接口 (GET /api/v1/inbound/base/units)
|
||||
# ==============================================================================
|
||||
@inbound_base_bp.route('/units', methods=['GET'])
|
||||
@permission_required('material_list')
|
||||
def get_unit_dict():
|
||||
"""
|
||||
获取所有已存在的非空计量单位(去重 + 排序),用于前端
|
||||
新增/编辑弹窗中"计量单位"下拉框的历史记录。
|
||||
"""
|
||||
try:
|
||||
units = MaterialBaseService.get_distinct_units()
|
||||
return jsonify({"code": 200, "msg": "success", "data": units})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# 2. 列表接口 (GET /api/v1/inbound/base/list)
|
||||
# ==============================================================================
|
||||
|
||||
@ -528,6 +528,29 @@ class MaterialBaseService:
|
||||
traceback.print_exc()
|
||||
return {"categories": [], "types": [], "companies": []}
|
||||
|
||||
@staticmethod
|
||||
def get_distinct_units():
|
||||
"""
|
||||
获取所有已存在且非空的计量单位(去重 + 排序)。
|
||||
用于前端"基础信息"新增/编辑弹窗的"计量单位"下拉历史记录。
|
||||
|
||||
SQL 语义:
|
||||
SELECT DISTINCT unit FROM material_base
|
||||
WHERE unit IS NOT NULL AND unit != ''
|
||||
ORDER BY unit ASC
|
||||
"""
|
||||
try:
|
||||
rows = db.session.query(MaterialBase.unit) \
|
||||
.filter(MaterialBase.unit.isnot(None), MaterialBase.unit != '') \
|
||||
.distinct() \
|
||||
.all()
|
||||
sorted_units = sorted([u[0] for u in rows if u[0]])
|
||||
return sorted_units
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
print(f"查询计量单位字典失败: {e}")
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def create_material(data):
|
||||
"""新增基础信息"""
|
||||
|
||||
Reference in New Issue
Block a user