XH_Digital_Management/application/exec_tbl/views.py

450 lines
21 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.shortcuts import render
from django.urls import reverse
from common.utils.page_helper import paginate_query_and_assign_numbers
from .models import *
def financial_data_list_view(request):
# 声明查询集
query_set = FinancialData.objects.all().order_by('-year')
# 获取查询参数
year = request.GET.get('year', '')
# 根据提供的参数进行筛选
if year:
query_set = query_set.filter(year__icontains=year)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&year={}'.format(year)
fields = [
{"label": "年份", "field": "year", "type": "text", "is_show": 1, "is_add": 1},
{"label": "年度营业收入", "field": "annual_revenue", "type": "number", "is_show": 1, "is_add": 1},
{"label": "年度新增收入", "field": "annual_new_revenue", "type": "number", "is_show": 1, "is_add": 1},
{"label": "年度存量收入", "field": "annual_existing_revenue", "type": "number", "is_show": 1, "is_add": 1},
{"label": "年度营业成本", "field": "annual_operating_costs", "type": "number", "is_show": 1, "is_add": 1},
{"label": "年度费用开销", "field": "annual_expenses", "type": "number", "is_show": 1, "is_add": 1},
{"label": "营业利润", "field": "operating_profit", "type": "number", "is_show": 1, "is_add": 1},
{"label": "年未完成收入", "field": "unfinished_annual_revenue", "type": "number", "is_show": 1, "is_add": 1},
{"label": "剩余日均收入目标", "field": "daily_income_target_remaining", "type": "number", "is_show": 1,
"is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'year',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "FinancialData", "html_name": "financial_data_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "公司整体经营情况", "name": "financial_data_list"}],
'filters': [
{"type": "text", "id": "year", "name": "year", "label": "年份", "placeholder": "请输入年份"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True},
}
return render(request, 'exec_tbl/fd_list.html', context)
def monthly_financial_data_list_view(request):
# 声明查询集
query_set = MonthlyFinancialData.objects.all().order_by('-year_month')
# 获取查询参数
year_month = request.GET.get('year_month', '')
# 根据提供的参数进行筛选
if year_month:
query_set = query_set.filter(year_month__icontains=year_month)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&year_month={}'.format(year_month)
fields = [
{"label": "年月", "field": "year_month", "type": "text", "is_show": 1, "is_add": 1},
{"label": "当月收入", "field": "current_month_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "月收入目标", "field": "monthly_income_target", "type": "number", "is_show": 1, "is_add": 1},
{"label": "月目标完成率", "field": "monthly_target_completion_rate", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "当月新增收入", "field": "current_month_new_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "月新增收入目标", "field": "monthly_new_income_target", "type": "number", "is_show": 1, "is_add": 1},
{"label": "月新增收入完成率", "field": "monthly_new_income_completion_rate", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "当月存量收入", "field": "current_month_existing_income", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "月存量收入目标", "field": "monthly_existing_income_target", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "月存量收入完成率", "field": "monthly_existing_income_completion_rate", "type": "number",
"is_show": 1, "is_add": 1},
{"label": "年累计收入", "field": "annual_accumulated_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "累计目标完成率", "field": "accumulated_target_completion_rate", "type": "number", "is_show": 1,
"is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'year_month',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "MonthlyFinancialData",
"html_name": "monthly_financial_data_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "公司整体收入情况", "name": "monthly_financial_data_list"}],
'filters': [
{"type": "text", "id": "year_month", "name": "year_month", "label": "年月", "placeholder": "请输入年月"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True},
}
return render(request, 'exec_tbl/fd_list.html', context)
def receivables_data_list_view(request):
# 声明查询集
query_set = ReceivablesData.objects.all().order_by('-total_receivables')
# 获取查询参数
total_receivables = request.GET.get('total_receivables', '')
# 根据提供的参数进行筛选
if total_receivables:
query_set = query_set.filter(total_receivables__icontains=total_receivables)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&total_receivables={}'.format(total_receivables)
fields = [
{"label": "应收账款总额", "field": "total_receivables", "type": "number", "is_show": 1, "is_add": 1},
{"label": "0-3个月", "field": "receivables_0_3_months", "type": "number", "is_show": 1, "is_add": 1},
{"label": "3-6个月", "field": "receivables_3_6_months", "type": "number", "is_show": 1, "is_add": 1},
{"label": "6-12个月", "field": "receivables_6_12_months", "type": "number", "is_show": 1, "is_add": 1},
{"label": "1-2年", "field": "receivables_1_2_years", "type": "number", "is_show": 1, "is_add": 1},
{"label": "2-3年", "field": "receivables_2_3_years", "type": "number", "is_show": 1, "is_add": 1},
{"label": "3-5年", "field": "receivables_3_5_years", "type": "number", "is_show": 1, "is_add": 1},
{"label": "5年以上", "field": "receivables_over_5_years", "type": "number", "is_show": 1, "is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'total_receivables',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "ReceivablesData",
"html_name": "receivables_data_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "公司应收账款情况", "name": "receivables_data_list"}],
'filters': [
{"type": "number", "id": "total_receivables", "name": "total_receivables", "label": "应收账款总额",
"placeholder": "请输入应收账款总额"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True},
}
return render(request, 'exec_tbl/fd_list.html', context)
def receivables_detail_list_view(request):
# 声明查询集
query_set = ReceivablesDetail.objects.all().order_by('-outstanding_amount')
# 获取查询参数
project_name = request.GET.get('project_name', '')
# 根据提供的参数进行筛选
if project_name:
query_set = query_set.filter(project_name__icontains=project_name)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&project_name={}'.format(project_name)
fields = [
{"label": "项目名称", "field": "project_name", "type": "text", "is_show": 1, "is_add": 1},
{"label": "一级部门", "field": "primary_department", "type": "text", "is_show": 1, "is_add": 1},
{"label": "项目负责人", "field": "project_manager", "type": "text", "is_show": 1, "is_add": 1},
{"label": "待回款金额", "field": "outstanding_amount", "type": "number", "is_show": 1, "is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'project_name',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "ReceivablesDetail",
"html_name": "receivables_detail_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "公司应收账款明细", "name": "receivables_detail_list"}],
'filters': [
{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True},
}
return render(request, 'exec_tbl/fd_list.html', context)
def employee_status_list_view(request):
# 声明查询集
query_set = EmployeeStatus.objects.all().order_by('-total_employees')
# 获取查询参数
total_employees = request.GET.get('total_employees', '')
# 根据提供的参数进行筛选
if total_employees:
query_set = query_set.filter(total_employees__icontains=total_employees)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&total_employees={}'.format(total_employees)
fields = [
{"label": "员工总数", "field": "total_employees", "type": "number", "is_show": 1, "is_add": 1},
{"label": "当年新入职员工数", "field": "new_employees_current_year", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "转正人数", "field": "regularized_employees", "type": "number", "is_show": 1, "is_add": 1},
{"label": "试用期未通过人数", "field": "probation_failed", "type": "number", "is_show": 1, "is_add": 1},
{"label": "当年离职员工数", "field": "employees_left_current_year", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "实习人数", "field": "intern_employees", "type": "number", "is_show": 1, "is_add": 1},
{"label": "兼职人数", "field": "part_time_employees", "type": "number", "is_show": 1, "is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'total_employees',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "EmployeeStatus", "html_name": "employee_status_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "公司人员情况", "name": "employee_status_list"}],
'filters': [
{"type": "text", "id": "total_employees", "name": "total_employees", "label": "员工总数",
"placeholder": "请输入员工总数"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True}
}
return render(request, 'exec_tbl/fd_list.html', context)
def employee_performance_list_view(request):
# 声明查询集
query_set = EmployeePerformance.objects.all().order_by('-year')
# 获取查询参数
year = request.GET.get('year', '')
# 根据提供的参数进行筛选
if year:
query_set = query_set.filter(year__icontains=year)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&year={}'.format(year)
fields = [
{"label": "年份", "field": "year", "type": "text", "is_show": 1, "is_add": 1},
{"label": "姓名", "field": "name", "type": "text", "is_show": 1, "is_add": 1},
{"label": "一级部门", "field": "department", "type": "text", "is_show": 1, "is_add": 1},
{"label": "当年收入", "field": "current_year_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "收入目标", "field": "income_target", "type": "number", "is_show": 1, "is_add": 1},
{"label": "收入目标完成率", "field": "income_target_completion_rate", "type": "number", "is_show": 1,
"is_add": 1},
{"label": "已发放提成", "field": "commission_paid", "type": "number", "is_show": 1, "is_add": 1},
{"label": "计提金额", "field": "accrued_amount", "type": "number", "is_show": 1, "is_add": 1},
{"label": "其他奖金", "field": "other_bonuses", "type": "number", "is_show": 1, "is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'year',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "EmployeePerformance",
"html_name": "employee_performance_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "员工业绩及提成情况", "name": "employee_performance_list"}],
'filters': [
{"type": "text", "id": "year", "name": "year", "label": "年份", "placeholder": "请输入年份"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True},
}
return render(request, 'exec_tbl/fd_list.html', context)
def employee_attendance_list_view(request):
# 声明查询集
query_set = EmployeeAttendance.objects.all().order_by('-name')
# 获取查询参数
name = request.GET.get('name', '')
# 根据提供的参数进行筛选
if name:
query_set = query_set.filter(name__icontains=name)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&name={}'.format(name)
fields = [
{"label": "姓名", "field": "name", "type": "text", "is_show": 1, "is_add": 1},
{"label": "迟到", "field": "late", "type": "number", "is_show": 1, "is_add": 1},
{"label": "早退", "field": "early_departure", "type": "number", "is_show": 1, "is_add": 1},
{"label": "旷工", "field": "absenteeism", "type": "number", "is_show": 1, "is_add": 1},
{"label": "年假", "field": "annual_leave", "type": "number", "is_show": 1, "is_add": 1},
{"label": "事假", "field": "personal_leave", "type": "number", "is_show": 1, "is_add": 1},
{"label": "病假", "field": "sick_leave", "type": "number", "is_show": 1, "is_add": 1},
{"label": "其他", "field": "other_leave", "type": "number", "is_show": 1, "is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'name',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "EmployeeAttendance",
"html_name": "employee_attendance_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "员工出勤情况", "name": "employee_attendance_list"}],
'filters': [
{"type": "text", "id": "name", "name": "name", "label": "姓名", "placeholder": "请输入姓名"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True},
}
return render(request, 'exec_tbl/fd_list.html', context)
def project_ledger_list_view(request):
# 声明查询集
query_set = ProjectLedger.objects.all().order_by('-project_id')
# 获取查询参数
project_name = request.GET.get('project_name', '')
# 根据提供的参数进行筛选
if project_name:
query_set = query_set.filter(project_name__icontains=project_name)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&project_name={}'.format(project_name)
fields = [
{"label": "项目编号", "field": "project_id", "type": "text", "is_show": 1, "is_add": 0},
{"label": "项目名称", "field": "project_name", "type": "text", "is_show": 1, "is_add": 1},
{"label": "开始日期", "field": "start_date", "type": "date", "is_show": 1, "is_add": 1},
{"label": "结束日期", "field": "end_date", "type": "date", "is_show": 1, "is_add": 1},
{"label": "一级部门", "field": "primary_department", "type": "text", "is_show": 1, "is_add": 1},
{"label": "客户名称", "field": "customer_name", "type": "text", "is_show": 1, "is_add": 1},
{"label": "", "field": "province", "type": "text", "is_show": 1, "is_add": 1},
{"label": "", "field": "city", "type": "text", "is_show": 1, "is_add": 1},
{"label": "区县", "field": "district", "type": "text", "is_show": 1, "is_add": 1},
{"label": "负责人", "field": "project_leader", "type": "text", "is_show": 1, "is_add": 1},
{"label": "项目组员", "field": "project_members", "type": "text", "is_show": 1, "is_add": 1},
{"label": "项目状态", "field": "project_status", "type": "select", "is_show": 1, "is_add": 1,
"options": ["进行中", "暂停", "待收款", "完成"]},
{"label": "资源类型", "field": "resource_type", "type": "select", "is_show": 1, "is_add": 1,
"options": ["公司", "个人"]},
{"label": "项目性质", "field": "project_nature", "type": "select", "is_show": 1, "is_add": 1,
"options": ["新增", "存量", "新增及存量", "老客户新业务"]},
{"label": "项目进度", "field": "project_progress", "type": "text", "is_show": 1, "is_add": 1},
{"label": "签约时间", "field": "contract_date", "type": "date", "is_show": 1, "is_add": 1},
{"label": "标的金额", "field": "contract_amount", "type": "number", "is_show": 1, "is_add": 1},
{"label": "合同费率", "field": "contract_rate", "type": "number", "is_show": 1, "is_add": 1},
{"label": "收入", "field": "revenue", "type": "number", "is_show": 1, "is_add": 1},
{"label": "成本费率", "field": "cost_rate", "type": "number", "is_show": 1, "is_add": 1},
{"label": "成本", "field": "cost", "type": "number", "is_show": 1, "is_add": 1},
{"label": "净收入", "field": "net_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "价税合计金额", "field": "total_amount_including_tax", "type": "number", "is_show": 1, "is_add": 1},
{"label": "回款金额", "field": "repayment_amount", "type": "number", "is_show": 1, "is_add": 1},
{"label": "应收净收入", "field": "receivable_net_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "实收净收入", "field": "actual_net_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "待收净收入", "field": "outstanding_net_income", "type": "number", "is_show": 1, "is_add": 1},
{"label": "备注", "field": "notes", "type": "textarea", "is_show": 1, "is_add": 1},
]
# 准备上下文
context = {
'items': items,
'id_name': 'project_id',
'query_params': query_params,
'model_config': {"app_label": "app_label", "model_name": "ProjectLedger", "html_name": "project_ledger_list"},
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "董事会、总经办", "name": "index"},
{"title": "公司项目台账", "name": "project_ledger_list"}],
'filters': [
{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"}
],
'table_columns': fields,
'show_button': {"add": True, "modify": True, "download": True, "upload": True}
}
return render(request, 'exec_tbl/fd_list.html', context)