XH_Digital_Management/application/fac_mgnt/views.py

1416 lines
62 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.http import JsonResponse
from django.shortcuts import render
from django.urls import reverse
from application.fac_mgnt.models import *
from common.utils.page_helper import paginate_query_and_assign_numbers
def exp_type_list_view(request):
# 声明查询集
query_set = ExpenseType.objects.filter().order_by('-type_id')
# 获取查询参数
expense_type = request.GET.get('expense_type', '')
# 根据提供的参数进行筛选
if expense_type:
query_set = query_set.filter(expense_type__icontains=expense_type)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&expense_type={}'.format(expense_type)
# Excel上传模板
template_name = "财会管理-费用类型-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.ExpenseType',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "费用类型", "name": "exp_type_list"}
],
"filters": [
{"type": "select", "id": "expense_type", "name": "expense_type", "label": "费用类型",
"options": [{"value": "差旅费", "display": "差旅费"}, {"value": "办公费", "display": "办公费"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"type_id": {"type": "text", "width": "180px"},
"expense_type": {"type": "text", "width": "180px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'exp_type_list',
"modify_url": reverse("exp_type_list_modify"),
"add_url": reverse("exp_type_list_add"),
"delete_url": reverse("exp_type_list_delete"),
}
return render(request, '../templates/list.html', context)
def exp_type_list_add(request):
if request.method == 'POST':
data = {
'expense_type': request.POST.get('expense_type')
}
ExpenseType.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def exp_type_list_modify(request):
if request.method == 'POST':
type_id = request.POST.get('type_id')
data = {
'expense_type': request.POST.get('expense_type')
}
ExpenseType.objects.filter(type_id=type_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def exp_type_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
ExpenseType.objects.filter(type_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def exp_detail_list_view(request):
# 声明查询集
query_set = ExpenseDetail.objects.filter().order_by('-detail_id')
# 获取查询参数
expense_detail = request.GET.get('expense_detail', '')
# 根据提供的参数进行筛选
if expense_detail:
query_set = query_set.filter(expense_detail__icontains=expense_detail)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&expense_detail={}'.format(expense_detail)
# Excel上传模板
template_name = "财会管理-费用明细-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.ExpenseDetail',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "费用明细", "name": "exp_detail_list"}
],
"filters": [
{"type": "select", "id": "expense_detail", "name": "expense_detail", "label": "费用明细",
"options": [{"value": "工资", "display": "工资"}, {"value": "社保", "display": "社保"},
{"value": "公积金", "display": "公积金"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"detail_id": {"type": "number", "width": "180px"},
"type_id": {"type": "number", "width": "180px"},
"expense_detail": {"type": "text", "width": "180px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'exp_detail_list',
"modify_url": reverse("exp_detail_list_modify"),
"add_url": reverse("exp_detail_list_add"),
"delete_url": reverse("exp_detail_list_delete"),
}
return render(request, '../templates/list.html', context)
def exp_detail_list_add(request):
if request.method == 'POST':
data = {
'type_id': request.POST.get('type_id'),
'expense_detail': request.POST.get('expense_detail')
}
ExpenseDetail.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def exp_detail_list_modify(request):
if request.method == 'POST':
detail_id = request.POST.get('detail_id')
data = {
'type_id': request.POST.get('type_id'),
'expense_detail': request.POST.get('expense_detail')
}
ExpenseDetail.objects.filter(detail_id=detail_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def exp_detail_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
ExpenseDetail.objects.filter(detail_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def gpb_list_view(request):
# 声明查询集
query_set = GroupAnnualBudget.objects.filter().order_by('-budget_id')
# 获取查询参数
primary_department = request.GET.get('primary_department', '')
expense_detail = request.GET.get('expense_detail', '')
expense_type = request.GET.get('expense_type', '')
year = request.GET.get('year', '')
# 根据提供的参数进行筛选
if primary_department:
query_set = query_set.filter(primary_department__icontains=primary_department)
if expense_detail:
query_set = query_set.filter(expense_detail__expense_detail__icontains=expense_detail)
if expense_type:
query_set = query_set.filter(expense_type__expense_type__icontains=expense_type)
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 = '&primary_department={}&expense_detail={}&expense_type={}&year={}'.format(
primary_department, expense_detail, expense_type, year)
# Excel上传模板
template_name = "财会管理-集团年度预算-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.GroupAnnualBudget',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "集团年度预算", "name": "gpb_list"}
],
"filters": [
{"type": "select", "id": "primary_department", "name": "primary_department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]},
{"type": "select", "id": "expense_detail", "name": "expense_detail", "label": "费用明细",
"options": [{"value": "办公用品购置", "display": "办公用品购置"},
{"value": "员工出差住宿费", "display": "员工出差住宿费"},
{"value": "员工技能培训", "display": "员工技能培训"},
{"value": "软件订阅服务费", "display": "软件订阅服务费"},
{"value": "市场推广活动费", "display": "市场推广活动费"}]},
{"type": "select", "id": "expense_type", "name": "expense_type", "label": "费用类型",
"options": [{"value": "办公费用", "display": "办公费用"},
{"value": "差旅费用", "display": "差旅费用"},
{"value": "培训费用", "display": "培训费用"},
{"value": "技术服务费", "display": "技术服务费"},
{"value": "营销推广费", "display": "营销推广费"}]},
{"type": "select", "id": "year", "name": "year", "label": "年度",
"options": [{"value": "2024", "display": "2024"}, {"value": "2023", "display": "2023"},
{"value": "2022", "display": "2022"}, {"value": "2021", "display": "2021"},
{"value": "2020", "display": "2020"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"budget_id": {"type": "number", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"year": {"type": "number", "width": "100px"},
"expense_type": {"type": "text", "width": "180px"},
"expense_detail": {"type": "text", "width": "180px"},
"amount": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'gpb_list',
"modify_url": reverse("gpb_list_modify"),
"add_url": reverse("gpb_list_add"),
"delete_url": reverse("gpb_list_delete"),
}
return render(request, '../templates/list.html', context)
def gpb_list_add(request):
if request.method == 'POST':
data = {
'primary_department': request.POST.get('primary_department'),
'year': request.POST.get('year'),
'expense_type_id': request.POST.get('expense_type_id'),
'expense_detail_id': request.POST.get('expense_detail_id'),
'amount': request.POST.get('amount')
}
GroupAnnualBudget.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def gpb_list_modify(request):
if request.method == 'POST':
budget_id = request.POST.get('budget_id')
data = {
'primary_department': request.POST.get('primary_department'),
'year': request.POST.get('year'),
'expense_type_id': request.POST.get('expense_type_id'),
'expense_detail_id': request.POST.get('expense_detail_id'),
'amount': request.POST.get('amount')
}
GroupAnnualBudget.objects.filter(budget_id=budget_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def gpb_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
GroupAnnualBudget.objects.filter(budget_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def lcb_list_view(request):
# 声明查询集
query_set = LaborCostDetail.objects.filter().order_by('-record_id')
# 获取查询参数
name = request.GET.get('name', '')
department = request.GET.get('department', '')
# 根据提供的参数进行筛选
if name:
query_set = query_set.filter(name__icontains=name)
if department:
query_set = query_set.filter(primary_department__icontains=department)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&name={}&department={}'.format(name, department)
# Excel上传模板
template_name = "财会管理-人工费明细-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.LaborCostDetail',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "人工费明细", "name": "lcb_list"}
],
"filters": [
{"type": "text", "id": "name", "name": "name", "label": "姓名", "placeholder": "请输入姓名"},
{"type": "select", "id": "department", "name": "department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"record_id": {"type": "number", "width": "180px"},
"year_month": {"type": "text", "width": "180px"},
"name": {"type": "text", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"secondary_department": {"type": "text", "width": "180px"},
"attendance_days": {"type": "number", "width": "100px"},
"gross_salary": {"type": "number", "width": "100px"},
"attendance_reward": {"type": "number", "width": "100px"},
"lunch_allowance": {"type": "number", "width": "100px"},
"other_monetary_benefits": {"type": "number", "width": "100px"},
"social_security_deduction": {"type": "number", "width": "100px"},
"housing_fund_deduction": {"type": "number", "width": "100px"},
"net_salary": {"type": "number", "width": "100px"},
"employer_social_security": {"type": "number", "width": "100px"},
"employer_housing_fund": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'lcb_list',
"modify_url": reverse("lcb_list_modify"),
"add_url": reverse("lcb_list_add"),
"delete_url": reverse("lcb_list_delete"),
}
return render(request, '../templates/list.html', context)
def lcb_list_add(request):
if request.method == 'POST':
data = {
'year_month': request.POST.get('year_month'),
'name': request.POST.get('name'),
'primary_department': request.POST.get('primary_department'),
'secondary_department': request.POST.get('secondary_department'),
'attendance_days': request.POST.get('attendance_days'),
'gross_salary': request.POST.get('gross_salary'),
'attendance_reward': request.POST.get('attendance_reward'),
'lunch_allowance': request.POST.get('lunch_allowance'),
'other_monetary_benefits': request.POST.get('other_monetary_benefits'),
'social_security_deduction': request.POST.get('social_security_deduction'),
'housing_fund_deduction': request.POST.get('housing_fund_deduction'),
'net_salary': request.POST.get('net_salary'),
'employer_social_security': request.POST.get('employer_social_security'),
'employer_housing_fund': request.POST.get('employer_housing_fund')
}
LaborCostDetail.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def lcb_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('record_id')
data = {
'year_month': request.POST.get('year_month'),
'name': request.POST.get('name'),
'primary_department': request.POST.get('primary_department'),
'secondary_department': request.POST.get('secondary_department'),
'attendance_days': request.POST.get('attendance_days'),
'gross_salary': request.POST.get('gross_salary'),
'attendance_reward': request.POST.get('attendance_reward'),
'lunch_allowance': request.POST.get('lunch_allowance'),
'other_monetary_benefits': request.POST.get('other_monetary_benefits'),
'social_security_deduction': request.POST.get('social_security_deduction'),
'housing_fund_deduction': request.POST.get('housing_fund_deduction'),
'net_salary': request.POST.get('net_salary'),
'employer_social_security': request.POST.get('employer_social_security'),
'employer_housing_fund': request.POST.get('employer_housing_fund')
}
LaborCostDetail.objects.filter(record_id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def lcb_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
LaborCostDetail.objects.filter(record_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def rbm_detail_list_view(request):
# 声明查询集
query_set = ReimbursementDetail.objects.filter().order_by('-record_id')
# 获取查询参数
name = request.GET.get('name', '')
year_month = request.GET.get('year_month', '')
primary_department = request.GET.get('primary_department', '')
project_name = request.GET.get('project_name', '')
# 根据提供的参数进行筛选
if name:
query_set = query_set.filter(name__icontains=name)
if year_month:
query_set = query_set.filter(year_month__icontains=year_month)
if primary_department:
query_set = query_set.filter(primary_department__icontains=primary_department)
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 = '&name={}&year_month={}&primary_department={}&project_name={}'.format(
name, year_month, primary_department, project_name)
# Excel上传模板
template_name = "财会管理-报销明细-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.ReimbursementDetail',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "报销明细", "name": "rbm_detail_list"}
],
"filters": [
{"type": "text", "id": "name", "name": "name", "label": "姓名", "placeholder": "请输入姓名"},
{"type": "month", "id": "year_month", "name": "year_month", "label": "年月"},
{"type": "select", "id": "primary_department", "name": "primary_department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]},
{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"record_id": {"type": "number", "width": "180px"},
"year_month": {"type": "date", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"name": {"type": "text", "width": "180px"},
"is_project_based": {"type": "select", "width": "100px", "options": ["", ""]},
"project_id": {"type": "number", "width": "180px"},
"project_name": {"type": "text", "width": "180px"},
"expense_type": {"type": "text", "width": "180px"},
"expense_details": {"type": "text", "width": "180px"},
"expense_description": {"type": "textarea", "width": "300px"},
"expense_date": {"type": "date", "width": "180px"},
"amount": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'rbm_detail_list',
"modify_url": reverse("rbm_detail_list_modify"),
"add_url": reverse("rbm_detail_list_add"),
"delete_url": reverse("rbm_detail_list_delete"),
}
return render(request, '../templates/list.html', context)
def rbm_detail_list_add(request):
if request.method == 'POST':
data = {
'year_month': request.POST.get('year_month'),
'primary_department': request.POST.get('primary_department'),
'name': request.POST.get('name'),
'is_project_based': request.POST.get('is_project_based'),
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'expense_type': request.POST.get('expense_type'),
'expense_details': request.POST.get('expense_details'),
'expense_description': request.POST.get('expense_description'),
'expense_date': request.POST.get('expense_date'),
'amount': request.POST.get('amount')
}
ReimbursementDetail.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def rbm_detail_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('record_id')
data = {
'year_month': request.POST.get('year_month'),
'primary_department': request.POST.get('primary_department'),
'name': request.POST.get('name'),
'is_project_based': request.POST.get('is_project_based'),
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'expense_type': request.POST.get('expense_type'),
'expense_details': request.POST.get('expense_details'),
'expense_description': request.POST.get('expense_description'),
'expense_date': request.POST.get('expense_date'),
'amount': request.POST.get('amount')
}
ReimbursementDetail.objects.filter(record_id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def rbm_detail_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
ReimbursementDetail.objects.filter(record_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def bns_cat_list_view(request):
# 声明查询集
query_set = BonusCategory.objects.filter().order_by('-category_id')
# 获取查询参数
category_name = request.GET.get('category_name', '')
# 根据提供的参数进行筛选
if category_name:
query_set = query_set.filter(category_name__icontains=category_name)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&category_name={}'.format(category_name)
# Excel上传模板
template_name = "财会管理-奖金类别表-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.BonusCategory',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "奖金类别表", "name": "bns_cat_list"}
],
"filters": [
{"type": "text", "id": "category_name", "name": "category_name", "label": "奖金类别",
"placeholder": "请输入奖金类别"}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"category_id": {"type": "number", "width": "180px"},
"category_name": {"type": "text", "width": "180px"},
"description": {"type": "textarea", "width": "300px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'bns_cat_list',
"modify_url": reverse("bns_cat_list_modify"),
"add_url": reverse("bns_cat_list_add"),
"delete_url": reverse("bns_cat_list_delete"),
}
return render(request, '../templates/list.html', context)
def bns_cat_list_add(request):
if request.method == 'POST':
data = {
'category_name': request.POST.get('category_name'),
'description': request.POST.get('description')
}
BonusCategory.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def bns_cat_list_modify(request):
if request.method == 'POST':
category_id = request.POST.get('category_id')
data = {
'category_name': request.POST.get('category_name'),
'description': request.POST.get('description')
}
BonusCategory.objects.filter(category_id=category_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def bns_cat_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
BonusCategory.objects.filter(category_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def bns_alloc_list_view(request):
# 声明查询集
query_set = BonusAllocation.objects.filter().order_by('-record_id')
# 获取查询参数
name = request.GET.get('name', '')
year_month = request.GET.get('year_month', '')
department = request.GET.get('department', '')
# 根据提供的参数进行筛选
if name:
query_set = query_set.filter(name__icontains=name)
if year_month:
query_set = query_set.filter(year_month__icontains=year_month)
if department:
query_set = query_set.filter(primary_department__icontains=department)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&name={}&year_month={}&department={}'.format(name, year_month, department)
# Excel上传模板
template_name = "财会管理-奖金分配表-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.BonusAllocation',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "奖金分配表", "name": "bns_alloc_list"}
],
"filters": [
{"type": "text", "id": "name", "name": "name", "label": "姓名", "placeholder": "请输入姓名"},
{"type": "month", "id": "year_month", "name": "year_month", "label": "年月"},
{"type": "select", "id": "department", "name": "department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"record_id": {"type": "number", "width": "180px"},
"year_month": {"type": "text", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"secondary_department": {"type": "text", "width": "180px"},
"name": {"type": "text", "width": "180px"},
"bonus_category": {"type": "text", "width": "180px"},
"award_amount": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'bns_alloc_list',
"modify_url": reverse("bns_alloc_list_modify"),
"add_url": reverse("bns_alloc_list_add"),
"delete_url": reverse("bns_alloc_list_delete"),
}
return render(request, '../templates/list.html', context)
def bns_alloc_list_add(request):
if request.method == 'POST':
data = {
'year_month': request.POST.get('year_month'),
'primary_department': request.POST.get('primary_department'),
'secondary_department': request.POST.get('secondary_department'),
'name': request.POST.get('name'),
'bonus_category': request.POST.get('bonus_category'),
'award_amount': request.POST.get('award_amount')
}
BonusAllocation.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def bns_alloc_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('record_id')
data = {
'year_month': request.POST.get('year_month'),
'primary_department': request.POST.get('primary_department'),
'secondary_department': request.POST.get('secondary_department'),
'name': request.POST.get('name'),
'bonus_category': request.POST.get('bonus_category'),
'award_amount': request.POST.get('award_amount')
}
BonusAllocation.objects.filter(record_id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def bns_alloc_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
BonusAllocation.objects.filter(record_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def tax_rec_list_view(request):
# 声明查询集
query_set = TaxRecord.objects.filter().order_by('-id')
# 获取查询参数
tax_entity = request.GET.get('tax_entity', '')
year = request.GET.get('year', '')
# 根据提供的参数进行筛选
if tax_entity:
query_set = query_set.filter(tax_entity__icontains=tax_entity)
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 = '&tax_entity={}&year={}'.format(tax_entity, year)
# Excel上传模板
template_name = "财会管理-纳税记录表-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.TaxRecord',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "纳税记录表", "name": "tax_rec_list"}
],
"filters": [
{"type": "text", "id": "tax_entity", "name": "tax_entity", "label": "纳税主体",
"placeholder": "请输入纳税主体"},
{"type": "select", "id": "year", "name": "year", "label": "年度",
"options": [{"value": "2024", "display": "2024"}, {"value": "2023", "display": "2023"},
{"value": "2022", "display": "2022"}, {"value": "2021", "display": "2021"},
{"value": "2020", "display": "2020"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"id": {"type": "number", "width": "180px"},
"tax_entity": {"type": "text", "width": "180px"},
"year": {"type": "number", "width": "100px"},
"tax_type": {"type": "select", "width": "180px", "options": ["增值税", "消费税"]},
"tax_period": {"type": "select", "width": "180px", "options": ["月度", "季度", "年度"]},
"tax_date": {"type": "date", "width": "180px"},
"tax_amount": {"type": "number", "width": "100px"},
"annual_cumulative": {"type": "number", "width": "100px"},
"note": {"type": "text", "width": "300px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'tax_rec_list',
"modify_url": reverse("tax_rec_list_modify"),
"add_url": reverse("tax_rec_list_add"),
"delete_url": reverse("tax_rec_list_delete"),
}
return render(request, '../templates/list.html', context)
def tax_rec_list_add(request):
if request.method == 'POST':
data = {
'tax_entity': request.POST.get('tax_entity'),
'year': request.POST.get('year'),
'tax_type': request.POST.get('tax_type'),
'tax_period': request.POST.get('tax_period'),
'tax_date': request.POST.get('tax_date'),
'tax_amount': request.POST.get('tax_amount'),
'annual_cumulative': request.POST.get('annual_cumulative'),
'note': request.POST.get('note')
}
TaxRecord.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def tax_rec_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('id')
data = {
'tax_entity': request.POST.get('tax_entity'),
'year': request.POST.get('year'),
'tax_type': request.POST.get('tax_type'),
'tax_period': request.POST.get('tax_period'),
'tax_date': request.POST.get('tax_date'),
'tax_amount': request.POST.get('tax_amount'),
'annual_cumulative': request.POST.get('annual_cumulative'),
'note': request.POST.get('note')
}
TaxRecord.objects.filter(id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def tax_rec_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
TaxRecord.objects.filter(id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def inv_ledger_list_view(request):
# 声明查询集
query_set = ElectronicInvoiceLedger.objects.filter().order_by('-invoice_number')
# 获取查询参数
expense_party = request.GET.get('expense_party', '')
primary_department = request.GET.get('primary_department', '')
invoice_code = request.GET.get('invoice_code', '')
invoice_number = request.GET.get('invoice_number', '')
invoice_date = request.GET.get('invoice_date', '')
# 根据提供的参数进行筛选
if expense_party:
query_set = query_set.filter(expense_party__icontains=expense_party)
if primary_department:
query_set = query_set.filter(primary_department__icontains=primary_department)
if invoice_code:
query_set = query_set.filter(invoice_code__icontains=invoice_code)
if invoice_number:
query_set = query_set.filter(invoice_number__icontains=invoice_number)
if invoice_date:
query_set = query_set.filter(invoice_date__icontains=invoice_date)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&expense_party={}&primary_department={}&invoice_code={}&invoice_number={}&invoice_date={}'.format(
expense_party, primary_department, invoice_code, invoice_number, invoice_date)
# Excel上传模板
template_name = "财会管理-电子发票台账-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.ElectronicInvoiceLedger',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "电子发票台账", "name": "inv_ledger_list"}
],
"filters": [
{"type": "text", "id": "expense_party", "name": "expense_party", "label": "费用当事人",
"placeholder": "请输入费用当事人"},
{"type": "select", "id": "primary_department", "name": "primary_department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]},
{"type": "text", "id": "invoice_code", "name": "invoice_code", "label": "发票代码",
"placeholder": "请输入发票代码"},
{"type": "text", "id": "invoice_number", "name": "invoice_number", "label": "发票号码",
"placeholder": "请输入发票号码"},
{"type": "date", "id": "invoice_date", "name": "invoice_date", "label": "开票日期"}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"record_id": {"type": "text", "width": "180px"},
"expense_party": {"type": "text", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"submission_date": {"type": "date", "width": "180px"},
"invoice_code": {"type": "text", "width": "180px"},
"invoice_number": {"type": "text", "width": "180px"},
"invoice_date": {"type": "date", "width": "180px"},
"buyer_name": {"type": "text", "width": "180px"},
"buyer_tax_number": {"type": "text", "width": "180px"},
"seller_name": {"type": "text", "width": "180px"},
"seller_tax_number": {"type": "text", "width": "180px"},
"goods_or_services_name": {"type": "text", "width": "180px"},
"tax_rate": {"type": "number", "width": "100px"},
"total_amount_including_tax": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'inv_ledger_list',
"modify_url": reverse("inv_ledger_list_modify"),
"add_url": reverse("inv_ledger_list_add"),
"delete_url": reverse("inv_ledger_list_delete"),
}
return render(request, '../templates/list.html', context)
def inv_ledger_list_add(request):
if request.method == 'POST':
data = {
'expense_party': request.POST.get('expense_party'),
'primary_department': request.POST.get('primary_department'),
'submission_date': request.POST.get('submission_date'),
'invoice_code': request.POST.get('invoice_code'),
'invoice_number': request.POST.get('invoice_number'),
'invoice_date': request.POST.get('invoice_date'),
'buyer_name': request.POST.get('buyer_name'),
'buyer_tax_number': request.POST.get('buyer_tax_number'),
'seller_name': request.POST.get('seller_name'),
'seller_tax_number': request.POST.get('seller_tax_number'),
'goods_or_services_name': request.POST.get('goods_or_services_name'),
'tax_rate': request.POST.get('tax_rate'),
'total_amount_including_tax': request.POST.get('total_amount_including_tax')
}
ElectronicInvoiceLedger.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def inv_ledger_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('invoice_number')
data = {
'expense_party': request.POST.get('expense_party'),
'primary_department': request.POST.get('primary_department'),
'submission_date': request.POST.get('submission_date'),
'invoice_code': request.POST.get('invoice_code'),
'invoice_number': request.POST.get('invoice_number'),
'invoice_date': request.POST.get('invoice_date'),
'buyer_name': request.POST.get('buyer_name'),
'buyer_tax_number': request.POST.get('buyer_tax_number'),
'seller_name': request.POST.get('seller_name'),
'seller_tax_number': request.POST.get('seller_tax_number'),
'goods_or_services_name': request.POST.get('goods_or_services_name'),
'tax_rate': request.POST.get('tax_rate'),
'total_amount_including_tax': request.POST.get('total_amount_including_tax')
}
ElectronicInvoiceLedger.objects.filter(invoice_number=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def inv_ledger_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
ElectronicInvoiceLedger.objects.filter(invoice_number=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def inv_rec_list_view(request):
# 声明查询集
query_set = InvoiceRecord.objects.filter().order_by('-record_id')
# 获取查询参数
project_name = request.GET.get('project_name', '')
project_nature = request.GET.get('project_nature', '')
department = request.GET.get('department', '')
invoice_date = request.GET.get('invoice_date', '')
project_manager = request.GET.get('project_manager', '')
# 根据提供的参数进行筛选
if project_name:
query_set = query_set.filter(project_name__icontains=project_name)
if project_nature:
query_set = query_set.filter(project_nature__icontains=project_nature)
if department:
query_set = query_set.filter(primary_department__icontains=department)
if invoice_date:
query_set = query_set.filter(invoice_date__icontains=invoice_date)
if project_manager:
query_set = query_set.filter(project_manager__icontains=project_manager)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&project_name={}&project_nature={}&department={}&invoice_date={}&project_manager={}'.format(
project_name, project_nature, department, invoice_date, project_manager
)
# Excel上传模板
template_name = "财会管理-开票记录-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.InvoiceRecord',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "开票记录", "name": "inv_rec_list"}
],
"filters": [
{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"},
{"type": "select", "id": "project_nature", "name": "project_nature", "label": "项目性质",
"options": [{"value": "新增", "display": "新增"}, {"value": "存续", "display": "存续"},
{"value": "新增及存续", "display": "新增及存续"},
{"value": "老客户新业务", "display": "老客户新业务"}]},
{"type": "select", "id": "department", "name": "department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]},
{"type": "date", "id": "invoice_date", "name": "invoice_date", "label": "开票日期"},
{"type": "text", "id": "project_manager", "name": "project_manager", "label": "项目负责人",
"placeholder": "请输入项目负责人"}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"project_id": {"type": "text", "width": "180px"},
"project_name": {"type": "text", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"project_manager": {"type": "text", "width": "180px"},
"nature": {"type": "select", "width": "100px", "options": ["新增", "开票"]},
"billing_entity": {"type": "text", "width": "180px"},
"invoice_number": {"type": "text", "width": "180px"},
"purchase_info": {"type": "text", "width": "180px"},
"invoice_date": {"type": "date", "width": "180px"},
"invoice_content": {"type": "text", "width": "180px"},
"total_amount": {"type": "number", "width": "100px"},
"tax_rate": {"type": "number", "width": "100px"},
"amount_excluding_tax": {"type": "number", "width": "100px"},
"tax_amount": {"type": "number", "width": "100px"},
"invoice_type": {"type": "select", "width": "100px", "options": ["专票", "普票"]},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'inv_rec_list',
"modify_url": reverse("inv_rec_list_modify"),
"add_url": reverse("inv_rec_list_add"),
"delete_url": reverse("inv_rec_list_delete"),
}
return render(request, '../templates/list.html', context)
def inv_rec_list_add(request):
if request.method == 'POST':
data = {
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'primary_department': request.POST.get('primary_department'),
'project_manager': request.POST.get('project_manager'),
'nature': request.POST.get('nature'),
'billing_entity': request.POST.get('billing_entity'),
'invoice_number': request.POST.get('invoice_number'),
'purchase_info': request.POST.get('purchase_info'),
'invoice_date': request.POST.get('invoice_date'),
'invoice_content': request.POST.get('invoice_content'),
'total_amount': request.POST.get('total_amount'),
'tax_rate': request.POST.get('tax_rate'),
'amount_excluding_tax': request.POST.get('amount_excluding_tax'),
'tax_amount': request.POST.get('tax_amount'),
'invoice_type': request.POST.get('invoice_type')
}
InvoiceRecord.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def inv_rec_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('record_id')
data = {
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'primary_department': request.POST.get('primary_department'),
'project_manager': request.POST.get('project_manager'),
'nature': request.POST.get('nature'),
'billing_entity': request.POST.get('billing_entity'),
'invoice_number': request.POST.get('invoice_number'),
'purchase_info': request.POST.get('purchase_info'),
'invoice_date': request.POST.get('invoice_date'),
'invoice_content': request.POST.get('invoice_content'),
'total_amount': request.POST.get('total_amount'),
'tax_rate': request.POST.get('tax_rate'),
'amount_excluding_tax': request.POST.get('amount_excluding_tax'),
'tax_amount': request.POST.get('tax_amount'),
'invoice_type': request.POST.get('invoice_type')
}
InvoiceRecord.objects.filter(record_id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def inv_rec_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
InvoiceRecord.objects.filter(record_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def rep_rec_list_view(request):
# 声明查询集
query_set = RepaymentRecord.objects.filter().order_by('-record_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)
# Excel上传模板
template_name = "财会管理-回款记录表-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.RepaymentRecord',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "回款记录表", "name": "rep_rec_list"}
],
"filters": [
{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"project_id": {"type": "text", "width": "180px"},
"project_name": {"type": "text", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"project_manager": {"type": "text", "width": "180px"},
"invoice": {"type": "text", "width": "180px"},
"repayment_amount": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'rep_rec_list',
"modify_url": reverse("rep_rec_list_modify"),
"add_url": reverse("rep_rec_list_add"),
"delete_url": reverse("rep_rec_list_delete"),
}
return render(request, '../templates/list.html', context)
def rep_rec_list_add(request):
if request.method == 'POST':
data = {
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'primary_department': request.POST.get('primary_department'),
'project_manager': request.POST.get('project_manager'),
'invoice': request.POST.get('invoice'),
'repayment_amount': request.POST.get('repayment_amount')
}
RepaymentRecord.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def rep_rec_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('record_id')
data = {
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'primary_department': request.POST.get('primary_department'),
'project_manager': request.POST.get('project_manager'),
'invoice': request.POST.get('invoice'),
'repayment_amount': request.POST.get('repayment_amount')
}
RepaymentRecord.objects.filter(record_id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def rep_rec_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
RepaymentRecord.objects.filter(record_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def emp_comm_list_view(request):
# 声明查询集
query_set = EmployeeCommission.objects.filter().order_by('-record_id')
# 获取查询参数
project_name = request.GET.get('project_name', '')
name = request.GET.get('name', '')
primary_department = request.GET.get('primary_department', '')
# 根据提供的参数进行筛选
if project_name:
query_set = query_set.filter(project_name__icontains=project_name)
if name:
query_set = query_set.filter(name__icontains=name)
if primary_department:
query_set = query_set.filter(primary_department__icontains=primary_department)
# 对查询结果进行分页每页10条记录
items = paginate_query_and_assign_numbers(
request=request,
queryset=query_set,
per_page=10
)
# 构建上下文查询参数字符串
query_params = '&project_name={}&name={}&primary_department={}'.format(project_name, name, primary_department)
# Excel上传模板
template_name = "财会管理-员工提成情况表-Excel上传模板.xlsx"
# 构建上下文
context = {
"model_config": 'fac_mgnt.EmployeeCommission',
"items": items,
"breadcrumb_list": [
{"title": "首页", "name": "index"},
{"title": "财会管理", "name": "index"},
{"title": "员工提成情况表", "name": "emp_comm_list"}
],
"filters": [
{"type": "text", "id": "project_name", "name": "project_name", "label": "项目名称",
"placeholder": "请输入项目名称"},
{"type": "text", "id": "name", "name": "name", "label": "姓名", "placeholder": "请输入姓名"},
{"type": "select", "id": "primary_department", "name": "primary_department", "label": "一级部门",
"options": [{"value": "天信", "display": "天信"}, {"value": "混改", "display": "混改"},
{"value": "艾力芬特", "display": "艾力芬特"}, {"value": "星河", "display": "星河"},
{"value": "星海", "display": "星海"}]}
],
"excel_upload_config": {
"template_url": reverse("download_template", kwargs={'template_name': template_name}),
"parse_url": reverse("common_excel_parse"),
"save_url": reverse("save_excel_table_data"),
"fields_preview_config": {
"project_name": {"type": "text", "width": "180px"},
"year_month": {"type": "date", "width": "180px"},
"company_retained": {"type": "number", "width": "100px"},
"name": {"type": "text", "width": "180px"},
"primary_department": {"type": "text", "width": "180px"},
"total_commission": {"type": "number", "width": "100px"},
"amount_paid": {"type": "number", "width": "100px"},
"accrued_amount": {"type": "number", "width": "100px"},
"chairman_fund": {"type": "number", "width": "100px"},
"actions": {"type": "actions", "width": "100px"}
}
},
"query_params": query_params,
"form_action_url": 'emp_comm_list',
"modify_url": reverse("emp_comm_list_modify"),
"add_url": reverse("emp_comm_list_add"),
"delete_url": reverse("emp_comm_list_delete"),
}
return render(request, '../templates/list.html', context)
def emp_comm_list_add(request):
if request.method == 'POST':
data = {
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'year_month': request.POST.get('year_month'),
'company_retained': request.POST.get('company_retained'),
'name': request.POST.get('name'),
'primary_department': request.POST.get('primary_department'),
'total_commission': request.POST.get('total_commission'),
'amount_paid': request.POST.get('amount_paid'),
'accrued_amount': request.POST.get('accrued_amount'),
'chairman_fund': request.POST.get('chairman_fund')
}
EmployeeCommission.objects.create(**data)
return JsonResponse({"message": "添加成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def emp_comm_list_modify(request):
if request.method == 'POST':
record_id = request.POST.get('record_id')
data = {
'project_id': request.POST.get('project_id'),
'project_name': request.POST.get('project_name'),
'year_month': request.POST.get('year_month'),
'company_retained': request.POST.get('company_retained'),
'name': request.POST.get('name'),
'primary_department': request.POST.get('primary_department'),
'total_commission': request.POST.get('total_commission'),
'amount_paid': request.POST.get('amount_paid'),
'accrued_amount': request.POST.get('accrued_amount'),
'chairman_fund': request.POST.get('chairman_fund')
}
EmployeeCommission.objects.filter(record_id=record_id).update(**data)
return JsonResponse({"message": "修改成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)
def emp_comm_list_delete(request):
if request.method == 'GET':
target_id = request.GET.get('target_id')
EmployeeCommission.objects.filter(record_id=target_id).delete()
return JsonResponse({"message": "删除成功"})
return JsonResponse({"message": "无效的请求方法"}, status=405)