XH_Digital_Management/common/utils/select_data.py

38 lines
1.2 KiB
Python
Raw Normal View History

from application.fac_mgnt.models import ExpenseType
from application.org_mgnt.models import PrimaryDepartment
def get_primary_department_filter_options():
"""
获取一级部门的筛选选项以指定的格式返回
:return: 包含筛选选项的字典
"""
primary_departments = PrimaryDepartment.objects.values_list('department_name', flat=True).distinct()
primary_department_options = [{'value': dept, 'display': dept} for dept in primary_departments]
return {
"type": "select",
"id": "primary_department",
"name": "primary_department",
"label": "一级部门",
"options": primary_department_options
}
def get_expense_type_filter_options():
"""
获取费用类型的筛选选项以指定的格式返回
:return: 包含筛选选项的字典
"""
expense_types = ExpenseType.objects.values_list('expense_type', flat=True).distinct()
expense_type_options = [{'value': types, 'display': types} for types in expense_types]
return {
"type": "select",
"id": "expense_type",
"name": "expense_type",
"label": "费用类型",
"options": expense_type_options
}