357 lines
20 KiB
Python
357 lines
20 KiB
Python
from django.http import JsonResponse
|
||
from django.shortcuts import render
|
||
from django.urls import reverse
|
||
from rest_framework.decorators import api_view
|
||
|
||
from application.org_mgnt.models import PrimaryDepartment, SecondaryDepartment, CompanyEntity
|
||
from common.utils.page_helper import paginate_query_and_assign_numbers
|
||
|
||
|
||
def pd_list_view(request):
|
||
# 声明查询集
|
||
query_set = PrimaryDepartment.objects.filter().order_by('-primary_department_id')
|
||
|
||
# 获取查询参数
|
||
department_name = request.GET.get('department_name', '')
|
||
|
||
# 根据提供的参数进行筛选
|
||
if department_name:
|
||
query_set = query_set.filter(primary_department=department_name)
|
||
|
||
# 对查询结果进行分页,每页10条记录
|
||
items = paginate_query_and_assign_numbers(
|
||
request=request,
|
||
queryset=query_set,
|
||
per_page=10
|
||
)
|
||
|
||
# 构建上下文查询参数字符串
|
||
query_params = '&department_name={}'.format(department_name)
|
||
|
||
# 准备上下文
|
||
context = {
|
||
'items': items,
|
||
'list_key': 'primary_department_id',
|
||
'filters': [
|
||
{
|
||
'type': 'text',
|
||
'id': 'name',
|
||
'name': 'name',
|
||
'label': '一级部门名称',
|
||
'placeholder': '请输入一级部门名称',
|
||
},
|
||
], # 筛选框配置
|
||
"form_action_url": 'pd_list',
|
||
'breadcrumb_list': [
|
||
{'title': '首页', 'name': 'index'},
|
||
{'title': '组织管理', 'name': 'index'},
|
||
{'title': '一级部门表', 'name': 'gbo_list'},
|
||
], # 面包屑
|
||
'query_params': query_params, # 查询参数字符串
|
||
'table_columns': [
|
||
{'header': '部门ID', 'field': 'primary_department_id'},
|
||
{'header': '部门名称', 'field': 'department_name'},
|
||
{'header': '描述', 'field': 'description'},
|
||
{'header': '操作', 'field': 'actions'},
|
||
],
|
||
'show_modify_button': False, # 显示修改记录按钮
|
||
'show_add_button': False, # 显示添加按钮
|
||
'show_download_button': False, # 显示导出按钮
|
||
'show_upload_button': False, # 显示上传Excel按钮
|
||
}
|
||
|
||
return render(request, 'org_mgnt/pd_list.html', context)
|
||
|
||
|
||
def sd_list_view(request):
|
||
# 声明查询集
|
||
query_set = SecondaryDepartment.objects.filter().order_by('-secondary_department_id')
|
||
|
||
# 获取查询参数
|
||
secondary_department_name = request.GET.get('secondary_department_name', '')
|
||
|
||
# 根据提供的参数进行筛选
|
||
if secondary_department_name:
|
||
query_set = query_set.filter(primary_department=secondary_department_name)
|
||
|
||
# 对查询结果进行分页,每页10条记录
|
||
items = paginate_query_and_assign_numbers(
|
||
request=request,
|
||
queryset=query_set,
|
||
per_page=10
|
||
)
|
||
|
||
# 构建上下文查询参数字符串
|
||
query_params = '&secondary_department_name={}'.format(secondary_department_name)
|
||
|
||
# 准备上下文
|
||
context = {
|
||
'items': items,
|
||
'list_key': "secondary_department_id",
|
||
'list_key': 'secondary_department_id',
|
||
'filters': [
|
||
{
|
||
'type': 'text',
|
||
'id': 'name',
|
||
'name': 'name',
|
||
'label': '二级部门名称',
|
||
'placeholder': '请输入二级部门名称',
|
||
},
|
||
], # 筛选框配置
|
||
"form_action_url": 'sd_list',
|
||
'breadcrumb_list': [
|
||
{'title': '首页', 'name': 'index'},
|
||
{'title': '组织管理', 'name': 'index'},
|
||
{'title': '二级部门表', 'name': 'gbo_list'},
|
||
], # 面包屑
|
||
'query_params': query_params, # 查询参数字符串
|
||
'table_columns': [
|
||
{'header': '一级部门名称', 'field': 'primary_department'},
|
||
{'header': '二级部门ID', 'field': 'secondary_department_id'},
|
||
{'header': '二级部门名称', 'field': 'secondary_department_name'},
|
||
{'header': '描述', 'field': 'description'},
|
||
{'header': '操作', 'field': 'actions'},
|
||
],
|
||
'show_modify_button': False, # 显示修改记录按钮
|
||
'show_add_button': False, # 显示添加按钮
|
||
'show_download_button': False, # 显示导出按钮
|
||
'show_upload_button': False, # 显示上传Excel按钮
|
||
}
|
||
|
||
return render(request, 'org_mgnt/sd_list.html', context)
|
||
|
||
|
||
def eir_list_view(request):
|
||
# 声明查询集
|
||
query_set = CompanyEntity.objects.filter().order_by('-entity_id')
|
||
|
||
# 获取查询参数
|
||
company_name = request.GET.get('company_name', '')
|
||
business_status = request.GET.get('business_status', '')
|
||
taxpayer_identification_number = request.GET.get('taxpayer_identification_number', '')
|
||
|
||
# 根据提供的参数进行筛选
|
||
if request.GET.get('company_name', ''):
|
||
query_set = query_set.filter(company_name=request.GET.get('company_name', ''))
|
||
if request.GET.get('business_status', ''):
|
||
query_set = query_set.filter(business_status=request.GET.get('business_status', ''))
|
||
if request.GET.get('taxpayer_identification_number', ''):
|
||
query_set = query_set.filter(
|
||
taxpayer_identification_number=request.GET.get('taxpayer_identification_number', ''))
|
||
|
||
# 对查询结果进行分页,每页10条记录
|
||
items = paginate_query_and_assign_numbers(
|
||
request=request,
|
||
queryset=query_set,
|
||
per_page=10
|
||
)
|
||
|
||
# 构建上下文查询参数字符串
|
||
query_params = '&company_name={}'.format(company_name) + '&business_status={}'.format(
|
||
business_status) + '&taxpayer_identification_number={}'.format(taxpayer_identification_number)
|
||
|
||
fields = {"company_type": {"id": "operation_company_type", "type": "text", "label": "公司类型"},
|
||
"company_name": {"id": "operation_company_name", "type": "text", "label": "公司名称"},
|
||
"registration_address": {"id": "operation_registration_address", "type": "text",
|
||
"label": "注册地址"},
|
||
"registered_capital": {"id": "operation_registered_capital", "type": "text",
|
||
"label": "注册资本金"},
|
||
"capital_paid_time": {"id": "operation_capital_paid_time", "type": "date", "label": "实缴时间"},
|
||
"capital_paid": {"id": "operation_capital_paid", "type": "text", "label": "实缴资金"},
|
||
"establishment_time": {"id": "operation_establishment_time", "type": "date",
|
||
"label": "设立时间"},
|
||
"operation_period": {"id": "operation_operation_period", "type": "text", "label": "营业期限"},
|
||
"taxpayer_identification_number": {"id": "operation_taxpayer_identification_number",
|
||
"type": "text", "label": "纳税人识别号"},
|
||
"business_status": {"id": "operation_business_status", "type": "select", "label": "公司经营状态",
|
||
"options": ["存续", "注销"]},
|
||
"scope_of_business": {"id": "operation_scope_of_business", "type": "textarea",
|
||
"label": "营业范围"},
|
||
"purpose_of_company": {"id": "operation_purpose_of_company", "type": "text",
|
||
"label": "公司用途"},
|
||
"shareholders_and_stakes": {"id": "operation_shareholders_and_stakes", "type": "textarea",
|
||
"label": "股东姓名及持股比例"},
|
||
"chairman": {"id": "operation_chairman", "type": "text", "label": "董事长"},
|
||
"directors": {"id": "operation_directors", "type": "text", "label": "董事"},
|
||
"supervisor_chairman": {"id": "operation_supervisor_chairman", "type": "text",
|
||
"label": "监事长"},
|
||
"employee_supervisor": {"id": "operation_employee_supervisor", "type": "text",
|
||
"label": "职工监事"},
|
||
"supervisors": {"id": "operation_supervisors", "type": "text", "label": "监事"},
|
||
"general_manager": {"id": "operation_general_manager", "type": "text", "label": "总经理"},
|
||
"financial_officer": {"id": "operation_financial_officer", "type": "text",
|
||
"label": "财务负责人"},
|
||
"historical_evolution": {"id": "operation_historical_evolution", "type": "textarea",
|
||
"label": "历史沿革"},
|
||
"related_bank_accounts": {"id": "operation_related_bank_accounts", "type": "select",
|
||
"label": "相关银行账户", "options": []}}
|
||
|
||
# 构建上下文
|
||
context = {
|
||
"items": items,
|
||
"list_key": "entity_id",
|
||
"filters": [{"type": "text", "id": "company_name", "name": "company_name", "label": "公司名称",
|
||
"placeholder": "请输入公司名称"},
|
||
{"type": "select", "id": "business_status", "name": "business_status", "label": "公司经营状态",
|
||
"options": [{"value": "存续", "display": "存续"}, {"value": "注销", "display": "注销"}]},
|
||
{"type": "text", "id": "taxpayer_identification_number", "name": "taxpayer_identification_number",
|
||
"label": "纳税人识别号", "placeholder": "请输入纳税人识别号"}],
|
||
"form_action_url": "eir_list",
|
||
"breadcrumb_list": [{"title": "首页", "name": "index"}, {"title": "组织管理", "name": "index"},
|
||
{"title": "公司主体信息登记表", "name": "eir_list"}],
|
||
"query_params": query_params,
|
||
"table_columns": [
|
||
{"header": "公司类型", "field": "company_type"},
|
||
{"header": "公司名称", "field": "company_name"},
|
||
{"header": "注册地址", "field": "registration_address"},
|
||
{"header": "注册资本金", "field": "registered_capital"},
|
||
{"header": "实缴时间", "field": "capital_paid_time"},
|
||
{"header": "实缴资金", "field": "capital_paid"},
|
||
{"header": "设立时间", "field": "establishment_time"},
|
||
{"header": "营业期限", "field": "operation_period"},
|
||
{"header": "纳税人识别号", "field": "taxpayer_identification_number"},
|
||
{"header": "公司经营状态", "field": "business_status"},
|
||
{"header": "营业范围", "field": "scope_of_business"},
|
||
{"header": "公司用途", "field": "purpose_of_company"},
|
||
{"header": "股东姓名及持股比例", "field": "shareholders_and_stakes"},
|
||
{"header": "董事长", "field": "chairman"}, {"header": "董事", "field": "directors"},
|
||
{"header": "监事长", "field": "supervisor_chairman"},
|
||
{"header": "职工监事", "field": "employee_supervisor"},
|
||
{"header": "监事", "field": "supervisors"}, {"header": "总经理", "field": "general_manager"},
|
||
{"header": "财务负责人", "field": "financial_officer"},
|
||
{"header": "历史沿革", "field": "historical_evolution"},
|
||
{"header": "相关银行账户", "field": "related_bank_accounts"},
|
||
{"header": "操作", "field": "actions"}
|
||
],
|
||
"show_modify_button": True,
|
||
"show_add_button": True,
|
||
"show_download_button": True,
|
||
"show_upload_button": True,
|
||
"modify_url": reverse("eir_list_modify"),
|
||
"add_url": reverse("eir_list_add"),
|
||
"delete_url": reverse("eir_list_delete"),
|
||
"form_fields_config": {"fields": fields},
|
||
"excel_upload_config": {
|
||
"template_url": reverse("download_excel_template",
|
||
kwargs={"template_name": "组织管理-公司主体信息登记表-Excel上传模板.xlsx",
|
||
"fields": fields}),
|
||
"parse_url": reverse("common_excel_parse"),
|
||
"save_url": reverse("save_excel_table_data"),
|
||
"model_config": {"app_label": "org_mgnt", "model_name": "CompanyEntity"},
|
||
"fields_map": {"company_type": "公司类型", "company_name": "公司名称",
|
||
"registration_address": "注册地址", "registered_capital": "注册资本金",
|
||
"capital_paid_time": "实缴时间", "capital_paid": "实缴资金",
|
||
"establishment_time": "设立时间", "operation_period": "营业期限",
|
||
"taxpayer_identification_number": "纳税人识别号",
|
||
"business_status": "公司经营状态", "scope_of_business": "营业范围",
|
||
"purpose_of_company": "公司用途",
|
||
"shareholders_and_stakes": "股东姓名及持股比例", "chairman": "董事长",
|
||
"directors": "董事", "supervisor_chairman": "监事长",
|
||
"employee_supervisor": "职工监事", "supervisors": "监事",
|
||
"general_manager": "总经理", "financial_officer": "财务负责人",
|
||
"historical_evolution": "历史沿革",
|
||
"related_bank_accounts": "相关银行账户"},
|
||
"fields_preview_config": {"company_type": {"type": "text", "width": "180px"},
|
||
"company_name": {"type": "text", "width": "180px"},
|
||
"registration_address": {"type": "text", "width": "180px"},
|
||
"registered_capital": {"type": "text", "width": "180px"},
|
||
"capital_paid_time": {"type": "date", "width": "180px"},
|
||
"capital_paid": {"type": "text", "width": "180px"},
|
||
"establishment_time": {"type": "date", "width": "180px"},
|
||
"operation_period": {"type": "text", "width": "180px"},
|
||
"taxpayer_identification_number": {"type": "text",
|
||
"width": "180px"},
|
||
"business_status": {"type": "select", "width": "180px",
|
||
"options": ["存续", "注销"]},
|
||
"scope_of_business": {"type": "textarea", "width": "180px"},
|
||
"purpose_of_company": {"type": "text", "width": "180px"},
|
||
"shareholders_and_stakes": {"type": "textarea",
|
||
"width": "180px"},
|
||
"chairman": {"type": "text", "width": "180px"},
|
||
"directors": {"type": "text", "width": "180px"},
|
||
"supervisor_chairman": {"type": "text", "width": "180px"},
|
||
"employee_supervisor": {"type": "text", "width": "180px"},
|
||
"supervisors": {"type": "text", "width": "180px"},
|
||
"general_manager": {"type": "text", "width": "180px"},
|
||
"financial_officer": {"type": "text", "width": "180px"},
|
||
"historical_evolution": {"type": "textarea",
|
||
"width": "180px"},
|
||
"related_bank_accounts": {"type": "select", "width": "180px",
|
||
"options": []}}
|
||
},
|
||
}
|
||
|
||
return render(request, 'org_mgnt/eir_list.html', context)
|
||
|
||
|
||
def eir_list_add(request):
|
||
if request.method == 'POST':
|
||
data = {
|
||
'company_type': request.POST.get('company_type'), 'company_name': request.POST.get('company_name'),
|
||
'registration_address': request.POST.get('registration_address'),
|
||
'registered_capital': request.POST.get('registered_capital'),
|
||
'capital_paid_time': request.POST.get('capital_paid_time'),
|
||
'capital_paid': request.POST.get('capital_paid'),
|
||
'establishment_time': request.POST.get('establishment_time'),
|
||
'operation_period': request.POST.get('operation_period'),
|
||
'taxpayer_identification_number': request.POST.get('taxpayer_identification_number'),
|
||
'business_status': request.POST.get('business_status'),
|
||
'scope_of_business': request.POST.get('scope_of_business'),
|
||
'purpose_of_company': request.POST.get('purpose_of_company'),
|
||
'shareholders_and_stakes': request.POST.get('shareholders_and_stakes'),
|
||
'chairman': request.POST.get('chairman'), 'directors': request.POST.get('directors'),
|
||
'supervisor_chairman': request.POST.get('supervisor_chairman'),
|
||
'employee_supervisor': request.POST.get('employee_supervisor'),
|
||
'supervisors': request.POST.get('supervisors'), 'general_manager': request.POST.get('general_manager'),
|
||
'financial_officer': request.POST.get('financial_officer'),
|
||
'historical_evolution': request.POST.get('historical_evolution'),
|
||
'related_bank_accounts': request.POST.get('related_bank_accounts')
|
||
}
|
||
CompanyEntity.objects.create(**data)
|
||
return JsonResponse({"message": "添加成功"})
|
||
return JsonResponse({"message": "无效的请求方法"}, status=405)
|
||
|
||
|
||
def eir_list_modify(request):
|
||
if request.method == 'POST':
|
||
entity_id = request.POST.get('entity_id')
|
||
data = {
|
||
'company_type': request.POST.get('company_type'), 'company_name': request.POST.get('company_name'),
|
||
'registration_address': request.POST.get('registration_address'),
|
||
'registered_capital': request.POST.get('registered_capital'),
|
||
'capital_paid_time': request.POST.get('capital_paid_time'),
|
||
'capital_paid': request.POST.get('capital_paid'),
|
||
'establishment_time': request.POST.get('establishment_time'),
|
||
'operation_period': request.POST.get('operation_period'),
|
||
'taxpayer_identification_number': request.POST.get('taxpayer_identification_number'),
|
||
'business_status': request.POST.get('business_status'),
|
||
'scope_of_business': request.POST.get('scope_of_business'),
|
||
'purpose_of_company': request.POST.get('purpose_of_company'),
|
||
'shareholders_and_stakes': request.POST.get('shareholders_and_stakes'),
|
||
'chairman': request.POST.get('chairman'), 'directors': request.POST.get('directors'),
|
||
'supervisor_chairman': request.POST.get('supervisor_chairman'),
|
||
'employee_supervisor': request.POST.get('employee_supervisor'),
|
||
'supervisors': request.POST.get('supervisors'), 'general_manager': request.POST.get('general_manager'),
|
||
'financial_officer': request.POST.get('financial_officer'),
|
||
'historical_evolution': request.POST.get('historical_evolution'),
|
||
'related_bank_accounts': request.POST.get('related_bank_accounts')
|
||
}
|
||
|
||
target = CompanyEntity.objects.get(entity_id=entity_id)
|
||
changes = []
|
||
for key, value in data.items():
|
||
if getattr(target, key) != value:
|
||
changes.append((key, getattr(target, key), value))
|
||
|
||
CompanyEntity.objects.filter(entity_id=entity_id).update(**data)
|
||
return JsonResponse({"message": "修改成功"})
|
||
return JsonResponse({"message": "无效的请求方法"}, status=405)
|
||
|
||
|
||
def eir_list_delete(request):
|
||
if request.method == 'GET':
|
||
entity_id = request.GET.get('entity_id')
|
||
CompanyEntity.objects.filter(entity_id=entity_id).delete()
|
||
return JsonResponse({"message": "删除成功"})
|
||
return JsonResponse({"message": "无效的请求方法"}, status=405)
|