From 91718feaf21450a828c11b94ecc2ec111ee68021 Mon Sep 17 00:00:00 2001 From: sichan Date: Sun, 16 Jun 2024 22:38:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AE=B0=E5=BD=95=E6=8C=89=E9=92=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/fac_mgnt/templates/pc_list.html | 2 +- application/fac_mgnt/templates/rep_list.html | 2 +- application/hrm_mgnt/templates/attd_list.html | 2 +- application/hrm_mgnt/templates/emp_list.html | 1 - .../hrm_mgnt/templates/performance_list.html | 2 +- application/mkt_mgnt/templates/pj_list.html | 2 +- application/org_mgnt/templates/ce_list.html | 4 - .../perf_mgnt/templates/gbo_form_partial.html | 12 ++ application/rsc_mgnt/templates/cg_list.html | 2 +- application/rsc_mgnt/templates/svc_list.html | 2 +- templates/form_partial_pure.html | 178 ++++++++++++++++++ 11 files changed, 197 insertions(+), 12 deletions(-) create mode 100644 application/perf_mgnt/templates/gbo_form_partial.html create mode 100644 templates/form_partial_pure.html diff --git a/application/fac_mgnt/templates/pc_list.html b/application/fac_mgnt/templates/pc_list.html index 80c4f37..2478a5b 100644 --- a/application/fac_mgnt/templates/pc_list.html +++ b/application/fac_mgnt/templates/pc_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/application/fac_mgnt/templates/rep_list.html b/application/fac_mgnt/templates/rep_list.html index a731698..62d4d55 100644 --- a/application/fac_mgnt/templates/rep_list.html +++ b/application/fac_mgnt/templates/rep_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/application/hrm_mgnt/templates/attd_list.html b/application/hrm_mgnt/templates/attd_list.html index 213c8c4..b07a95c 100644 --- a/application/hrm_mgnt/templates/attd_list.html +++ b/application/hrm_mgnt/templates/attd_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/application/hrm_mgnt/templates/emp_list.html b/application/hrm_mgnt/templates/emp_list.html index afb0c0f..3f9a717 100644 --- a/application/hrm_mgnt/templates/emp_list.html +++ b/application/hrm_mgnt/templates/emp_list.html @@ -74,7 +74,6 @@
- {% show_modify_records_button model_config %} diff --git a/application/hrm_mgnt/templates/performance_list.html b/application/hrm_mgnt/templates/performance_list.html index 208a3dd..179bb87 100644 --- a/application/hrm_mgnt/templates/performance_list.html +++ b/application/hrm_mgnt/templates/performance_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/application/mkt_mgnt/templates/pj_list.html b/application/mkt_mgnt/templates/pj_list.html index bde7b75..7e6141a 100644 --- a/application/mkt_mgnt/templates/pj_list.html +++ b/application/mkt_mgnt/templates/pj_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/application/org_mgnt/templates/ce_list.html b/application/org_mgnt/templates/ce_list.html index ae2d7ed..e0a3d70 100644 --- a/application/org_mgnt/templates/ce_list.html +++ b/application/org_mgnt/templates/ce_list.html @@ -74,13 +74,9 @@
- {% show_modify_records_button model_config %} - diff --git a/application/perf_mgnt/templates/gbo_form_partial.html b/application/perf_mgnt/templates/gbo_form_partial.html new file mode 100644 index 0000000..37dc637 --- /dev/null +++ b/application/perf_mgnt/templates/gbo_form_partial.html @@ -0,0 +1,12 @@ +{% include 'form_partial_pure.html' %} + + \ No newline at end of file diff --git a/application/rsc_mgnt/templates/cg_list.html b/application/rsc_mgnt/templates/cg_list.html index 931d552..079c6d9 100644 --- a/application/rsc_mgnt/templates/cg_list.html +++ b/application/rsc_mgnt/templates/cg_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/application/rsc_mgnt/templates/svc_list.html b/application/rsc_mgnt/templates/svc_list.html index d371c48..0671369 100644 --- a/application/rsc_mgnt/templates/svc_list.html +++ b/application/rsc_mgnt/templates/svc_list.html @@ -74,7 +74,7 @@
- {% show_modify_records_button model_config %} + diff --git a/templates/form_partial_pure.html b/templates/form_partial_pure.html new file mode 100644 index 0000000..45cb16d --- /dev/null +++ b/templates/form_partial_pure.html @@ -0,0 +1,178 @@ +{% load tags %} +
+ {% csrf_token %} + {% if form.instance.pk %} + + {% endif %} +
+
+
+ {% for field in form %} + {% if forloop.counter0|divisibleby:2 %} +
+ + {% if field.field.widget.input_type == "text" %} + + {% elif field.field.widget.input_type == "number" %} + + {% elif field.field.widget.input_type == "select" %} + + {% elif field|is_input_type:"textarea" %} + + {% elif field.field.widget.input_type == "date" %} + + {% elif field.field.widget.input_type == "datetime-local" %} + + {% elif field.field.widget.input_type == "email" %} + + {% elif field.field.widget.input_type == "password" %} + + {% elif field.field.widget.input_type == "checkbox" %} +
+ + +
+ {% else %} + {{ field }} + {% endif %} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +
{{ error }}
+ {% endfor %} +
+ {% endif %} + {% endfor %} +
+
+ {% for field in form %} + {% if not forloop.counter0|divisibleby:2 %} +
+ + {% if field.field.widget.input_type == "text" %} + + {% elif field.field.widget.input_type == "number" %} + + {% elif field.field.widget.input_type == "select" %} + + {% elif field|is_input_type:"textarea" %} + + {% elif field.field.widget.input_type == "date" %} + + {% elif field.field.widget.input_type == "datetime-local" %} + + {% elif field.field.widget.input_type == "month" %} + + {% elif field.field.widget.input_type == "email" %} + + {% elif field.field.widget.input_type == "password" %} + + {% elif field.field.widget.input_type == "checkbox" %} +
+ + +
+ {% else %} + {{ field }} + {% endif %} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +
{{ error }}
+ {% endfor %} +
+ {% endif %} + {% endfor %} +
+
+
+ +
+ + + From ee19ae05c4d32adb6d0ec0349e547d41ad3312ca Mon Sep 17 00:00:00 2001 From: sichan Date: Sun, 16 Jun 2024 22:40:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=9C=A8=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=BB=9F=E4=B8=80=E7=9A=84=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/org_mgnt/views.py | 55 +++++++++-------- common/templatetags/tags.py | 42 ++++++++++--- templates/items_list.html | 107 +++++++++++++++++++++++----------- 3 files changed, 134 insertions(+), 70 deletions(-) diff --git a/application/org_mgnt/views.py b/application/org_mgnt/views.py index 090b142..8a978f3 100644 --- a/application/org_mgnt/views.py +++ b/application/org_mgnt/views.py @@ -1,30 +1,41 @@ import json +import os +from django.apps import apps +from django.conf import settings +from django.contrib.auth.decorators import login_required +from django.core.exceptions import ValidationError +from django.core.files.storage import default_storage from django.http import JsonResponse, Http404 from django.shortcuts import render, get_object_or_404 from django.template.loader import render_to_string from django.urls import reverse from django.views.decorators.csrf import csrf_protect +from openpyxl import load_workbook from rest_framework import status from rest_framework.decorators import api_view, permission_classes from rest_framework.pagination import PageNumberPagination from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response -from django.contrib.auth.decorators import login_required +from rest_framework.serializers import ModelSerializer -from application.org_mgnt.forms import CompanyEntityForm, PrimaryDepartmentForm, SecondaryDepartmentForm -from application.org_mgnt.models import PrimaryDepartment, SecondaryDepartment, CompanyEntity, CompanyBankAccount -from application.org_mgnt.serializers import EntityChangeRecordSerializer, CompanyBankAccountSerializer +from application.org_mgnt.forms import ( + CompanyEntityForm, + PrimaryDepartmentForm, + SecondaryDepartmentForm +) +from application.org_mgnt.models import ( + PrimaryDepartment, + SecondaryDepartment, + CompanyEntity, + CompanyBankAccount +) +from application.org_mgnt.serializers import ( + EntityChangeRecordSerializer, + CompanyBankAccountSerializer +) from common.auth import custom_permission_required from common.utils.page_helper import paginate_query_and_assign_numbers -from django.http import JsonResponse -from django.core.files.storage import default_storage -from django.conf import settings -from openpyxl import load_workbook -from django.apps import apps -from rest_framework.serializers import ModelSerializer -from django.core.exceptions import ValidationError -import os class StandardResultsSetPagination(PageNumberPagination): @@ -33,7 +44,6 @@ class StandardResultsSetPagination(PageNumberPagination): max_page_size = 100 -@login_required @custom_permission_required('org_mgnt.view_companyentity') def eir_list_view(request): # 声明查询集 @@ -122,7 +132,6 @@ def eir_list_view(request): return render(request, 'ce_list.html', context) -@login_required @custom_permission_required('org_mgnt.add_companyentity') def eir_list_add(request): if request.method == 'POST': @@ -141,7 +150,6 @@ def eir_list_add(request): return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.change_companyentity') def eir_list_modify(request): if request.method == 'POST': @@ -173,7 +181,6 @@ def eir_list_modify(request): return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.delete_companyentity') def eir_list_delete(request): if request.method == 'GET': @@ -184,7 +191,6 @@ def eir_list_delete(request): @api_view(['GET']) -@login_required @custom_permission_required('org_mgnt.view_entitychangerecord') def change_record_list(request, entity_id): entity = get_object_or_404(CompanyEntity, pk=entity_id) @@ -198,7 +204,6 @@ def change_record_list(request, entity_id): @api_view(['GET']) -@login_required @custom_permission_required('org_mgnt.view_companybankaccount') def bank_account_list(request, entity_id): entity = get_object_or_404(CompanyEntity, pk=entity_id) @@ -256,7 +261,6 @@ def delete_bank_account(request, account_id): return Response(status=status.HTTP_204_NO_CONTENT) -@login_required @custom_permission_required('org_mgnt.view_primarydepartment') def pd_list_view(request): # 声明查询集 @@ -310,12 +314,12 @@ def pd_list_view(request): "modify_url": reverse("pd_list_modify"), "add_url": reverse("pd_list_add"), "delete_url": reverse("pd_list_delete"), + "add_button": True } return render(request, 'items_list.html', context) -@login_required @custom_permission_required('org_mgnt.add_primarydepartment') def pd_list_add(request): if request.method == 'POST': @@ -334,7 +338,6 @@ def pd_list_add(request): return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.change_primarydepartment') def pd_list_modify(request): if request.method == 'POST': @@ -366,17 +369,15 @@ def pd_list_modify(request): return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.delete_primarydepartment') def pd_list_delete(request): if request.method == 'GET': - primary_department_id = request.GET.get('primary_department_id') - PrimaryDepartment.objects.filter(primary_department_id=primary_department_id).delete() + id = request.GET.get('id') + PrimaryDepartment.objects.filter(primary_department_id=id).delete() return JsonResponse({"message": "删除成功"}) return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.view_secondarydepartment') def sd_list_view(request): # 声明查询集 @@ -431,12 +432,12 @@ def sd_list_view(request): "modify_url": reverse("sd_list_modify"), "add_url": reverse("sd_list_add"), "delete_url": reverse("sd_list_delete"), + "add_button": True } return render(request, 'items_list.html', context) -@login_required @custom_permission_required('org_mgnt.add_secondarydepartment') def sd_list_add(request): if request.method == 'POST': @@ -455,7 +456,6 @@ def sd_list_add(request): return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.change_secondarydepartment') def sd_list_modify(request): if request.method == 'POST': @@ -487,7 +487,6 @@ def sd_list_modify(request): return JsonResponse({"message": "无效的请求方法"}, status=405) -@login_required @custom_permission_required('org_mgnt.delete_secondarydepartment') def sd_list_delete(request): if request.method == 'GET': diff --git a/common/templatetags/tags.py b/common/templatetags/tags.py index 57438be..de8a847 100644 --- a/common/templatetags/tags.py +++ b/common/templatetags/tags.py @@ -79,16 +79,40 @@ def subtract(value, arg): return '' -@register.simple_tag() -def show_modify_records_button(model_config): - # 预设的模型配置列表 - display = [ +@register.simple_tag(takes_context=True) +def render_button(context, button_type): + buttons = { + 'modify_records_button': { + 'class': 'btn btn-outline-secondary', + 'target': '#modifyRecordsModal', + 'text': '修改记录', + 'id': 'modifyRecordBtn' + }, + 'report_excel_button': { + 'class': 'btn btn-outline-secondary', + 'target': '#downloadModal', + 'text': '导出', + 'id': 'reportExcelBtn' + }, + 'import_excel_button': { + 'class': 'btn btn-outline-primary', + 'target': '#uploadModal', + 'text': '上传Excel', + 'id': 'importExcelBtn' + }, + 'add_button': { + 'class': 'btn btn-outline-secondary', + 'target': '#addEditModal', + 'text': '添加', + 'id': 'addItemBtn' + } + } - ] - - if model_config in display: - return mark_safe( - '') + if context.get(button_type): + button = buttons.get(button_type) + if button: + return mark_safe( + f'') return '' diff --git a/templates/items_list.html b/templates/items_list.html index 36e94eb..e8560f2 100644 --- a/templates/items_list.html +++ b/templates/items_list.html @@ -15,39 +15,37 @@
-
{% csrf_token %}
{% for filter in filters %} {% if filter.type == 'text' %}
- + + placeholder="{{ filter.placeholder }}" + value="{{ request.GET|get_value:filter.name|default:'' }}">
{% elif filter.type == 'select' %}
- +
{% elif filter.type == 'date' %}
- + {% elif filter.type == 'month' %}
- + - +
-
-
- {% show_modify_records_button model_config %} - - - + {% render_button 'modify_records_button' %} + {% render_button 'add_button' %} + {% render_button 'report_excel_button' %} + {% render_button 'import_excel_button' %}
-
@@ -96,7 +83,6 @@
- {% get_verbose_field_names_from_model model_config table_exclude_field_name as columns %} @@ -114,14 +100,19 @@ {% endfor %} {% empty %} @@ -133,7 +124,6 @@ {% endfor %}
{{ field.value }} - 编辑 - 删除 + data-bs-target="#deleteModal">删除
-
@@ -162,13 +152,35 @@
+ + {% include 'modify_record_modal.html' with modify_records_url=modify_records_url %} - {% include 'delete_modal.html' with delete_url=delete_url %} {% include 'upload_excel_modal.html' with excel_upload_config=excel_upload_config %} From bd12201a3b4cd7631a922e4231d221394026e7ed Mon Sep 17 00:00:00 2001 From: sichan Date: Sun, 16 Jun 2024 23:36:08 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 通用编辑表单显示问题(一级部门加载问题没解决) 2. 列表页面的按钮显示 --- application/asset_mgnt/views.py | 4 + application/cpc_mgnt/views.py | 8 + application/fac_mgnt/views.py | 22 +++ application/hrm_mgnt/views.py | 6 + application/mkt_mgnt/views.py | 4 + application/opa_mgnt/views.py | 8 + application/perf_mgnt/forms.py | 27 +++ .../perf_mgnt/templates/gbo_form_partial.html | 12 -- application/perf_mgnt/views.py | 6 +- application/pjt_mgnt/views.py | 4 + application/rsc_mgnt/views.py | 8 + templates/form_partial_pure.html | 178 ------------------ 12 files changed, 96 insertions(+), 191 deletions(-) delete mode 100644 application/perf_mgnt/templates/gbo_form_partial.html delete mode 100644 templates/form_partial_pure.html diff --git a/application/asset_mgnt/views.py b/application/asset_mgnt/views.py index a17e27c..7e08007 100644 --- a/application/asset_mgnt/views.py +++ b/application/asset_mgnt/views.py @@ -87,6 +87,8 @@ def fixed_assets_list_view(request): "add_url": reverse("fixed_assets_list_add"), "delete_url": reverse("fixed_assets_list_delete"), "table_exclude_field_name": ['asset_id'], + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -229,6 +231,8 @@ def intangible_assets_list_view(request): "add_url": reverse("intangible_assets_list_add"), "delete_url": reverse("intangible_assets_list_delete"), "table_exclude_field_name": ['asset_id'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/cpc_mgnt/views.py b/application/cpc_mgnt/views.py index 0d11eb8..a67c6fa 100644 --- a/application/cpc_mgnt/views.py +++ b/application/cpc_mgnt/views.py @@ -56,6 +56,8 @@ def seal_reg_list_view(request): "add_url": reverse("seal_reg_list_add"), "delete_url": reverse("seal_reg_list_delete"), "table_exclude_field_name": [], # Add any fields you want to exclude + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -172,6 +174,8 @@ def seal_doc_borrow_list_view(request): "add_url": reverse("seal_doc_borrow_list_add"), "delete_url": reverse("seal_doc_borrow_list_delete"), "table_exclude_field_name": [], # Add any fields you want to exclude + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -314,6 +318,8 @@ def contract_mgmt_list_view(request): "add_url": reverse("contract_mgmt_list_add"), "delete_url": reverse("contract_mgmt_list_delete"), "table_exclude_field_name": ['contract_number'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -441,6 +447,8 @@ def policies_list_view(request): "add_url": reverse("policies_list_add"), "delete_url": reverse("policies_list_delete"), "table_exclude_field_name": ['policy_id'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/fac_mgnt/views.py b/application/fac_mgnt/views.py index 720726a..c81eb38 100644 --- a/application/fac_mgnt/views.py +++ b/application/fac_mgnt/views.py @@ -63,6 +63,8 @@ def exp_type_list_view(request): "modify_url": reverse("exp_type_list_modify"), "add_url": reverse("exp_type_list_add"), "delete_url": reverse("exp_type_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -164,6 +166,8 @@ def exp_detail_list_view(request): "modify_url": reverse("exp_detail_list_modify"), "add_url": reverse("exp_detail_list_add"), "delete_url": reverse("exp_detail_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -295,6 +299,8 @@ def gpb_list_view(request): "modify_url": reverse("gpb_list_modify"), "add_url": reverse("gpb_list_add"), "delete_url": reverse("gpb_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -413,6 +419,8 @@ def lcb_list_view(request): "modify_url": reverse("lcb_list_modify"), "add_url": reverse("lcb_list_add"), "delete_url": reverse("lcb_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -541,6 +549,8 @@ def rbm_detail_list_view(request): "modify_url": reverse("rbm_detail_list_modify"), "add_url": reverse("rbm_detail_list_add"), "delete_url": reverse("rbm_detail_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -641,6 +651,8 @@ def bns_cat_list_view(request): "modify_url": reverse("bns_cat_list_modify"), "add_url": reverse("bns_cat_list_add"), "delete_url": reverse("bns_cat_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -755,6 +767,8 @@ def bns_alloc_list_view(request): "modify_url": reverse("bns_alloc_list_modify"), "add_url": reverse("bns_alloc_list_add"), "delete_url": reverse("bns_alloc_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -868,6 +882,8 @@ def tax_rec_list_view(request): "modify_url": reverse("tax_rec_list_modify"), "add_url": reverse("tax_rec_list_add"), "delete_url": reverse("tax_rec_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -1001,6 +1017,8 @@ def inv_ledger_list_view(request): "modify_url": reverse("inv_ledger_list_modify"), "add_url": reverse("inv_ledger_list_add"), "delete_url": reverse("inv_ledger_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -1137,6 +1155,8 @@ def inv_rec_list_view(request): "modify_url": reverse("inv_rec_list_modify"), "add_url": reverse("inv_rec_list_add"), "delete_url": reverse("inv_rec_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -1397,6 +1417,8 @@ def emp_comm_list_view(request): "modify_url": reverse("emp_comm_list_modify"), "add_url": reverse("emp_comm_list_add"), "delete_url": reverse("emp_comm_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/hrm_mgnt/views.py b/application/hrm_mgnt/views.py index d4a8d85..da7908e 100644 --- a/application/hrm_mgnt/views.py +++ b/application/hrm_mgnt/views.py @@ -447,6 +447,8 @@ def alv_list_view(request): "add_url": reverse("alv_list_add"), "delete_url": reverse("alv_list_delete"), "table_exclude_field_name": ['record_id'], + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -565,6 +567,8 @@ def rk_list_view(request): "add_url": reverse("rk_list_add"), "delete_url": reverse("rk_list_delete"), "table_exclude_field_name": ['rank_id'], + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -685,6 +689,8 @@ def pst_list_view(request): "add_url": reverse("pst_list_add"), "delete_url": reverse("pst_list_delete"), "table_exclude_field_name": ['position_id'], + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/mkt_mgnt/views.py b/application/mkt_mgnt/views.py index d61f2fb..3109f35 100644 --- a/application/mkt_mgnt/views.py +++ b/application/mkt_mgnt/views.py @@ -85,6 +85,8 @@ def proj_res_list_view(request): "add_url": reverse("proj_res_list_add"), "delete_url": reverse("proj_res_list_delete"), "table_exclude_field_name": ['resource_id'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'pj_list.html', context) @@ -217,6 +219,8 @@ def cust_list_view(request): "add_url": reverse("cust_list_add"), "delete_url": reverse("cust_list_delete"), "table_exclude_field_name": ['customer_id'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/opa_mgnt/views.py b/application/opa_mgnt/views.py index d38380a..c2bd5c4 100644 --- a/application/opa_mgnt/views.py +++ b/application/opa_mgnt/views.py @@ -56,6 +56,8 @@ def sma_reg_list_view(request): "modify_url": reverse("sma_reg_list_modify"), "add_url": reverse("sma_reg_list_add"), "delete_url": reverse("sma_reg_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -172,6 +174,8 @@ def acc_op_mgmt_list_view(request): "add_url": reverse("acc_op_mgmt_list_add"), "delete_url": reverse("acc_op_mgmt_list_delete"), "table_exclude_field_name": [], # Add any fields you want to exclude + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -288,6 +292,8 @@ def web_reg_list_view(request): "add_url": reverse("web_reg_list_add"), "delete_url": reverse("web_reg_list_delete"), "table_exclude_field_name": [], # Add any fields you want to exclude + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -399,6 +405,8 @@ def web_maint_rec_list_view(request): "add_url": reverse("web_maint_rec_list_add"), "delete_url": reverse("web_maint_rec_list_delete"), "table_exclude_field_name": [], # Add any fields you want to exclude + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/perf_mgnt/forms.py b/application/perf_mgnt/forms.py index ccd94e5..167437b 100644 --- a/application/perf_mgnt/forms.py +++ b/application/perf_mgnt/forms.py @@ -1,8 +1,17 @@ from django import forms + from .models import * +from ..org_mgnt.models import PrimaryDepartment class GroupBusinessTargetForm(forms.ModelForm): + primary_department = forms.ModelChoiceField( + queryset=PrimaryDepartment.objects.all(), + widget=forms.Select(attrs={'class': 'form-control'}), + empty_label="选择一级部门", + label="一级部门" + ) + class Meta: model = GroupBusinessTarget fields = '__all__' @@ -19,6 +28,24 @@ class GroupBusinessTargetForm(forms.ModelForm): 'operating_profit': forms.NumberInput(attrs={'class': 'form-control'}), } + def __init__(self, *args, **kwargs): + super(GroupBusinessTargetForm, self).__init__(*args, **kwargs) + if 'instance' in kwargs: + self.fields['primary_department'].initial = kwargs['instance'].primary_department + print(f"Initial primary department: {self.fields['primary_department'].initial}") # 调试输出 + + def clean(self): + cleaned_data = super().clean() + primary_department = cleaned_data.get('primary_department') + year = cleaned_data.get('year') + project_nature = cleaned_data.get('project_nature') + + if primary_department and year and project_nature: + if GroupBusinessTarget.objects.filter(primary_department=primary_department, year=year, project_nature=project_nature).exists(): + raise forms.ValidationError("该一级部门在同一年已经有一个相同项目性质的业绩目标。") + + return cleaned_data + class EmployeePerformanceTargetForm(forms.ModelForm): class Meta: diff --git a/application/perf_mgnt/templates/gbo_form_partial.html b/application/perf_mgnt/templates/gbo_form_partial.html deleted file mode 100644 index 37dc637..0000000 --- a/application/perf_mgnt/templates/gbo_form_partial.html +++ /dev/null @@ -1,12 +0,0 @@ -{% include 'form_partial_pure.html' %} - - \ No newline at end of file diff --git a/application/perf_mgnt/views.py b/application/perf_mgnt/views.py index c5ed360..ee45284 100644 --- a/application/perf_mgnt/views.py +++ b/application/perf_mgnt/views.py @@ -123,6 +123,8 @@ def gbo_list_view(request): "modify_url": reverse("gbo_list_modify"), "add_url": reverse("gbo_list_add"), "delete_url": reverse("gbo_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -183,7 +185,7 @@ def gbo_list_modify(request): @custom_permission_required('perf_mgnt.delete_groupbusinesstarget') def gbo_list_delete(request): if request.method == 'GET': - target_id = request.GET.get('target_id') + target_id = request.GET.get('id') GroupBusinessTarget.objects.filter(target_id=target_id).delete() return JsonResponse({"message": "删除成功"}) return JsonResponse({"message": "无效的请求方法"}, status=405) @@ -341,6 +343,8 @@ def emt_list_view(request): "modify_url": reverse("emt_list_modify"), "add_url": reverse("emt_list_add"), "delete_url": reverse("emt_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/pjt_mgnt/views.py b/application/pjt_mgnt/views.py index eb632ce..0461408 100644 --- a/application/pjt_mgnt/views.py +++ b/application/pjt_mgnt/views.py @@ -97,6 +97,8 @@ def proj_ledger_list_view(request): "add_url": reverse("proj_ledger_list_add"), "delete_url": reverse("proj_ledger_list_delete"), "table_exclude_field_name": ['project_id'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -223,6 +225,8 @@ def emp_proj_income_list_view(request): "add_url": reverse("emp_proj_income_list_add"), "delete_url": reverse("emp_proj_income_list_delete"), "table_exclude_field_name": ['record_id'], # Exclude primary key + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/application/rsc_mgnt/views.py b/application/rsc_mgnt/views.py index 256c695..bec530e 100644 --- a/application/rsc_mgnt/views.py +++ b/application/rsc_mgnt/views.py @@ -59,6 +59,8 @@ def cg_cat_list_view(request): "modify_url": reverse("cg_cat_list_modify"), "add_url": reverse("cg_cat_list_add"), "delete_url": reverse("cg_cat_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -292,6 +294,8 @@ def cmp_phone_reg_list_view(request): "modify_url": reverse("cmp_phone_reg_list_modify"), "add_url": reverse("cmp_phone_reg_list_add"), "delete_url": reverse("cmp_phone_reg_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -410,6 +414,8 @@ def bv_usage_list_view(request): "modify_url": reverse("bv_usage_list_modify"), "add_url": reverse("bv_usage_list_add"), "delete_url": reverse("bv_usage_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) @@ -533,6 +539,8 @@ def mem_acc_list_view(request): "modify_url": reverse("mem_acc_list_modify"), "add_url": reverse("mem_acc_list_add"), "delete_url": reverse("mem_acc_list_delete"), + "add_button": True, + "import_excel_button": True } return render(request, 'items_list.html', context) diff --git a/templates/form_partial_pure.html b/templates/form_partial_pure.html deleted file mode 100644 index 45cb16d..0000000 --- a/templates/form_partial_pure.html +++ /dev/null @@ -1,178 +0,0 @@ -{% load tags %} -
- {% csrf_token %} - {% if form.instance.pk %} - - {% endif %} -
-
-
- {% for field in form %} - {% if forloop.counter0|divisibleby:2 %} -
- - {% if field.field.widget.input_type == "text" %} - - {% elif field.field.widget.input_type == "number" %} - - {% elif field.field.widget.input_type == "select" %} - - {% elif field|is_input_type:"textarea" %} - - {% elif field.field.widget.input_type == "date" %} - - {% elif field.field.widget.input_type == "datetime-local" %} - - {% elif field.field.widget.input_type == "email" %} - - {% elif field.field.widget.input_type == "password" %} - - {% elif field.field.widget.input_type == "checkbox" %} -
- - -
- {% else %} - {{ field }} - {% endif %} - {% if field.help_text %} - {{ field.help_text }} - {% endif %} - {% for error in field.errors %} -
{{ error }}
- {% endfor %} -
- {% endif %} - {% endfor %} -
-
- {% for field in form %} - {% if not forloop.counter0|divisibleby:2 %} -
- - {% if field.field.widget.input_type == "text" %} - - {% elif field.field.widget.input_type == "number" %} - - {% elif field.field.widget.input_type == "select" %} - - {% elif field|is_input_type:"textarea" %} - - {% elif field.field.widget.input_type == "date" %} - - {% elif field.field.widget.input_type == "datetime-local" %} - - {% elif field.field.widget.input_type == "month" %} - - {% elif field.field.widget.input_type == "email" %} - - {% elif field.field.widget.input_type == "password" %} - - {% elif field.field.widget.input_type == "checkbox" %} -
- - -
- {% else %} - {{ field }} - {% endif %} - {% if field.help_text %} - {{ field.help_text }} - {% endif %} - {% for error in field.errors %} -
{{ error }}
- {% endfor %} -
- {% endif %} - {% endfor %} -
-
-
- -
- - - From 6e72b0bdb32c39374ff1d724c16d8a16080cc7bf Mon Sep 17 00:00:00 2001 From: sichan Date: Mon, 17 Jun 2024 00:21:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 列表页多显示了记录id --- application/cpc_mgnt/views.py | 6 +++--- application/fac_mgnt/templates/pc_list.html | 3 --- application/fac_mgnt/templates/rep_list.html | 3 --- application/hrm_mgnt/templates/emp_list.html | 3 --- application/opa_mgnt/views.py | 6 +++--- application/rsc_mgnt/templates/cg_list.html | 3 --- application/rsc_mgnt/templates/svc_list.html | 3 --- templates/upload_excel_modal.html | 4 ++-- 8 files changed, 8 insertions(+), 23 deletions(-) diff --git a/application/cpc_mgnt/views.py b/application/cpc_mgnt/views.py index a67c6fa..6f884b3 100644 --- a/application/cpc_mgnt/views.py +++ b/application/cpc_mgnt/views.py @@ -55,7 +55,7 @@ def seal_reg_list_view(request): "modify_url": reverse("seal_reg_list_modify"), "add_url": reverse("seal_reg_list_add"), "delete_url": reverse("seal_reg_list_delete"), - "table_exclude_field_name": [], # Add any fields you want to exclude + "table_exclude_field_name": ["record_id"], # Add any fields you want to exclude "add_button": True, "import_excel_button": True } @@ -173,7 +173,7 @@ def seal_doc_borrow_list_view(request): "modify_url": reverse("seal_doc_borrow_list_modify"), "add_url": reverse("seal_doc_borrow_list_add"), "delete_url": reverse("seal_doc_borrow_list_delete"), - "table_exclude_field_name": [], # Add any fields you want to exclude + "table_exclude_field_name": ["record_id"], # Add any fields you want to exclude "add_button": True, "import_excel_button": True } @@ -317,7 +317,7 @@ def contract_mgmt_list_view(request): "modify_url": reverse("contract_mgmt_list_modify"), "add_url": reverse("contract_mgmt_list_add"), "delete_url": reverse("contract_mgmt_list_delete"), - "table_exclude_field_name": ['contract_number'], # Exclude primary key + "table_exclude_field_name": ["id", 'contract_number'], # Exclude primary key "add_button": True, "import_excel_button": True } diff --git a/application/fac_mgnt/templates/pc_list.html b/application/fac_mgnt/templates/pc_list.html index 2478a5b..061ae81 100644 --- a/application/fac_mgnt/templates/pc_list.html +++ b/application/fac_mgnt/templates/pc_list.html @@ -78,9 +78,6 @@ - diff --git a/application/fac_mgnt/templates/rep_list.html b/application/fac_mgnt/templates/rep_list.html index 62d4d55..4b0e6c4 100644 --- a/application/fac_mgnt/templates/rep_list.html +++ b/application/fac_mgnt/templates/rep_list.html @@ -78,9 +78,6 @@ - diff --git a/application/hrm_mgnt/templates/emp_list.html b/application/hrm_mgnt/templates/emp_list.html index 3f9a717..af6931b 100644 --- a/application/hrm_mgnt/templates/emp_list.html +++ b/application/hrm_mgnt/templates/emp_list.html @@ -77,9 +77,6 @@ - diff --git a/application/opa_mgnt/views.py b/application/opa_mgnt/views.py index c2bd5c4..2e8f4ef 100644 --- a/application/opa_mgnt/views.py +++ b/application/opa_mgnt/views.py @@ -173,7 +173,7 @@ def acc_op_mgmt_list_view(request): "modify_url": reverse("acc_op_mgmt_list_modify"), "add_url": reverse("acc_op_mgmt_list_add"), "delete_url": reverse("acc_op_mgmt_list_delete"), - "table_exclude_field_name": [], # Add any fields you want to exclude + "table_exclude_field_name": ["record_id"], # Add any fields you want to exclude "add_button": True, "import_excel_button": True } @@ -291,7 +291,7 @@ def web_reg_list_view(request): "modify_url": reverse("web_reg_list_modify"), "add_url": reverse("web_reg_list_add"), "delete_url": reverse("web_reg_list_delete"), - "table_exclude_field_name": [], # Add any fields you want to exclude + "table_exclude_field_name": ["record_id"], # Add any fields you want to exclude "add_button": True, "import_excel_button": True } @@ -404,7 +404,7 @@ def web_maint_rec_list_view(request): "modify_url": reverse("web_maint_rec_list_modify"), "add_url": reverse("web_maint_rec_list_add"), "delete_url": reverse("web_maint_rec_list_delete"), - "table_exclude_field_name": [], # Add any fields you want to exclude + "table_exclude_field_name": ["record_id"], # Add any fields you want to exclude "add_button": True, "import_excel_button": True } diff --git a/application/rsc_mgnt/templates/cg_list.html b/application/rsc_mgnt/templates/cg_list.html index 079c6d9..b9f9171 100644 --- a/application/rsc_mgnt/templates/cg_list.html +++ b/application/rsc_mgnt/templates/cg_list.html @@ -78,9 +78,6 @@ - diff --git a/application/rsc_mgnt/templates/svc_list.html b/application/rsc_mgnt/templates/svc_list.html index 0671369..1be407a 100644 --- a/application/rsc_mgnt/templates/svc_list.html +++ b/application/rsc_mgnt/templates/svc_list.html @@ -78,9 +78,6 @@ - diff --git a/templates/upload_excel_modal.html b/templates/upload_excel_modal.html index c60fee5..66fa5f7 100644 --- a/templates/upload_excel_modal.html +++ b/templates/upload_excel_modal.html @@ -119,7 +119,7 @@ {#$('#uploadModal').modal('hide');#} // 检查是否有文件被选中 if ($('#inputFile').get(0).files.length === 0) { - alert("没有文件选中"); + showAlert('danger', '未选择文件'); $('#uploadModal').modal('show'); return; } @@ -172,7 +172,7 @@ } // 显示错误消息 - alert(errorMsg); + showAlert('danger', errorMsg); } }); }); From deff7858570e6279b66237271aab26b3e2db75ca Mon Sep 17 00:00:00 2001 From: sichan Date: Mon, 17 Jun 2024 00:33:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 删除了刷新权限按钮 --- .../accounts/templates/accounts/user_permissions_list.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/application/accounts/templates/accounts/user_permissions_list.html b/application/accounts/templates/accounts/user_permissions_list.html index 9ad3fa5..28034d3 100644 --- a/application/accounts/templates/accounts/user_permissions_list.html +++ b/application/accounts/templates/accounts/user_permissions_list.html @@ -41,6 +41,7 @@ {% endfor %} 权限组 用户权限 + 操作 @@ -59,6 +60,7 @@ + 删除 {% empty %} @@ -142,7 +144,7 @@ - +{# #} @@ -179,6 +181,7 @@ +{% include "delete_modal.html" %}