XH_Digital_Management/application/pjt_mgnt/views.py

120 lines
6.1 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 application.pjt_mgnt.models import *
from common.utils.page_helper import paginate_query_and_assign_numbers
def proj_ledger_list_view(request):
# 声明查询集
query_set = ProjectLedger.objects.filter().order_by('-project_id')
# 获取查询参数
project_name = request.GET.get('project_name', '')
customer_name = request.GET.get('customer_name', '')
# 根据提供的参数进行筛选
if request.GET.get('project_name', ''):
query_set = query_set.filter(project_name__icontains=request.GET.get('project_name', ''))
if request.GET.get('customer_name', ''):
query_set = query_set.filter(customer_name__icontains=request.GET.get('customer_name', ''))
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&project_name={}' + format(project_name) + '&customer_name={}' + format(customer_name)
# 准备上下文
context = {
'items': items,
'list_key': 'project_id',
'filters': [{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"},
{"type": "text", "id": "customer_name", "name": "customer_name", "label": "客户名称",
"placeholder": "请输入客户名称"}],
'form_action_url': 'proj_ledger_list',
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "项目管理", "name": "index"},
{"title": "项目台账", "name": "proj_ledger_list"}],
'query_params': query_params,
'table_columns': [{"header": "项目编号", "field": "project_id"},
{"header": "项目名称", "field": "project_name"},
{"header": "开始日期", "field": "start_date"}, {"header": "结束日期", "field": "end_date"},
{"header": "一级部门", "field": "primary_department"},
{"header": "客户名称", "field": "customer_name"}, {"header": "", "field": "province"},
{"header": "", "field": "city"}, {"header": "区县", "field": "district"},
{"header": "负责人", "field": "project_leader"},
{"header": "项目组员", "field": "project_members"},
{"header": "项目状态", "field": "project_status"},
{"header": "资源类型", "field": "resource_type"},
{"header": "项目性质", "field": "project_nature"},
{"header": "项目进度", "field": "project_progress"},
{"header": "签约时间", "field": "contract_date"},
{"header": "标的金额", "field": "contract_amount"},
{"header": "合同费率", "field": "contract_rate"}, {"header": "收入", "field": "revenue"},
{"header": "成本费率", "field": "cost_rate"}, {"header": "成本", "field": "cost"},
{"header": "净收入", "field": "net_income"},
{"header": "价税合计金额", "field": "total_amount_including_tax"},
{"header": "回款金额", "field": "repayment_amount"},
{"header": "应收净收入", "field": "receivable_net_income"},
{"header": "实收净收入", "field": "actual_net_income"},
{"header": "待收净收入", "field": "outstanding_net_income"},
{"header": "备注", "field": "notes"}, {"header": "操作", "field": "actions"}],
'show_modify_button': True,
'show_add_button': True,
'show_download_button': True,
'show_upload_button': True,
}
return render(request, 'pjt_mgnt/proj_ledger_list.html', context)
def emp_proj_income_list_view(request):
# 声明查询集
query_set = EmployeeProjectIncomeSettlement.objects.filter().order_by('-record_id')
# 获取查询参数
project_name = request.GET.get('project_name', '')
year_month = request.GET.get('year_month', '')
# 根据提供的参数进行筛选
if request.GET.get('project_name', ''):
query_set = query_set.filter(project_name__icontains=request.GET.get('project_name', ''))
if request.GET.get('year_month', ''):
query_set = query_set.filter(year_month__icontains=request.GET.get('year_month', ''))
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&project_name={}' + format(project_name) + '&year_month={}' + format(year_month)
# 准备上下文
context = {
'items': items,
'list_key': 'record_id',
'filters': [{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"},
{"type": "text", "id": "year_month", "name": "year_month", "label": "年月",
"placeholder": "请输入年月"}],
'form_action_url': 'emp_proj_income_list',
'breadcrumb_list': [{"title": "首页", "name": "index"}, {"title": "项目管理", "name": "index"},
{"title": "项目组员收入结算表", "name": "emp_proj_income_list"}],
'query_params': query_params,
'table_columns': [{"header": "记录ID", "field": "record_id"}, {"header": "项目名称", "field": "project_name"},
{"header": "年月", "field": "year_month"}, {"header": "操作", "field": "actions"}],
'show_modify_button': True,
'show_add_button': True,
'show_download_button': True,
'show_upload_button': True,
}
return render(request, 'pjt_mgnt/emp_proj_income_list.html', context)