From b250fced58608183f4ab5db6d5967ac1540e643b Mon Sep 17 00:00:00 2001 From: sichan Date: Wed, 19 Jun 2024 10:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=98=8E=E6=98=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/hrm_mgnt/forms.py | 33 ++++++++++++++++++--------------- application/hrm_mgnt/views.py | 4 ++-- application/perf_mgnt/forms.py | 21 +++++++++++++++++++-- application/perf_mgnt/models.py | 16 ++++++++-------- templates/items_list.html | 2 +- 5 files changed, 48 insertions(+), 28 deletions(-) diff --git a/application/hrm_mgnt/forms.py b/application/hrm_mgnt/forms.py index 0571c9b..4b7d36c 100644 --- a/application/hrm_mgnt/forms.py +++ b/application/hrm_mgnt/forms.py @@ -4,6 +4,9 @@ from .models import * class EmployeeInformationForm(forms.ModelForm): + """ + 人力资源管理-人员基本信息表单 + """ primary_department = forms.ChoiceField( choices=[('', '---------')] + [(dept.department_name, dept.department_name) for dept in PrimaryDepartment.objects.all()], widget=forms.Select(attrs={'class': 'form-control'}), @@ -65,6 +68,9 @@ class EmployeeInformationForm(forms.ModelForm): class EmployeeAttendanceRecordForm(forms.ModelForm): + """ + 人力资源管理-员工考勤记录表单 + """ class Meta: model = EmployeeAttendanceRecord fields = '__all__' @@ -80,16 +86,10 @@ class EmployeeAttendanceRecordForm(forms.ModelForm): } -class OtherLeaveDetailsForm(forms.ModelForm): - class Meta: - model = OtherLeaveDetails - fields = '__all__' - widgets = { - 'description': forms.Textarea(attrs={'rows': 3}), - } - - class AnnualLeaveRecordForm(forms.ModelForm): + """ + 人力资源管理-年假使用记录表单 + """ class Meta: model = AnnualLeaveRecord fields = '__all__' @@ -102,6 +102,9 @@ class AnnualLeaveRecordForm(forms.ModelForm): class RankForm(forms.ModelForm): + """ + 人力资源管理-职级表单 + """ class Meta: model = Rank fields = '__all__' @@ -112,6 +115,9 @@ class RankForm(forms.ModelForm): class PositionForm(forms.ModelForm): + """ + 人力资源管理-岗位表单 + """ class Meta: model = Position fields = '__all__' @@ -122,12 +128,9 @@ class PositionForm(forms.ModelForm): class PerformanceEvaluationForm(forms.ModelForm): - class Meta: - model = PerformanceEvaluation - fields = '__all__' - - -class PerformanceEvaluationAddForm(forms.ModelForm): + """ + 人力资源管理-员工绩效表单 + """ class Meta: model = PerformanceEvaluation fields = '__all__' diff --git a/application/hrm_mgnt/views.py b/application/hrm_mgnt/views.py index 174f9a7..7eb329c 100644 --- a/application/hrm_mgnt/views.py +++ b/application/hrm_mgnt/views.py @@ -865,7 +865,7 @@ def performance_add(request): 基础数据-人力资源管理-员工绩效表-添加 """ if request.method == 'POST': - form = PerformanceEvaluationAddForm(request.POST) + form = PerformanceEvaluationForm(request.POST) if form.is_valid(): form.save() return JsonResponse({"message": "添加成功"}) @@ -873,7 +873,7 @@ def performance_add(request): form_html = render_to_string('form_partial.html', {'form': form}, request) return JsonResponse({"form_html": form_html, "errors": form.errors}, status=400) elif request.method == 'GET': - form = PerformanceEvaluationAddForm() + form = PerformanceEvaluationForm() form_html = render_to_string('form_partial.html', {'form': form}, request) return JsonResponse({"form_html": form_html}) else: diff --git a/application/perf_mgnt/forms.py b/application/perf_mgnt/forms.py index a7190e4..05ede36 100644 --- a/application/perf_mgnt/forms.py +++ b/application/perf_mgnt/forms.py @@ -1,3 +1,5 @@ +import datetime + from django import forms from .models import * @@ -5,17 +7,24 @@ from ..org_mgnt.models import PrimaryDepartment class GroupBusinessTargetForm(forms.ModelForm): + current_year = datetime.datetime.now().year + primary_department = forms.ChoiceField( choices=[('', '---------')] + [(dept.department_name, dept.department_name) for dept in PrimaryDepartment.objects.all()], widget=forms.Select(attrs={'class': 'form-control'}), label="一级部门" ) + year = forms.ChoiceField( + choices=[('', '---------')] + [(year, year) for year in range(current_year-1, current_year+2)], + widget=forms.Select(attrs={'class': 'form-control'}), + label="年份", + required=False + ) class Meta: model = GroupBusinessTarget fields = '__all__' widgets = { - 'year': forms.NumberInput(attrs={'class': 'form-control'}), 'project_nature': forms.Select(attrs={'class': 'form-control'}), 'sales': forms.NumberInput(attrs={'class': 'form-control'}), 'total_revenue_target': forms.NumberInput(attrs={'class': 'form-control'}), @@ -44,12 +53,17 @@ class GroupBusinessTargetForm(forms.ModelForm): class EmployeePerformanceTargetForm(forms.ModelForm): + department = forms.ChoiceField( + choices=[('', '---------')] + [(dept.department_name, dept.department_name) for dept in PrimaryDepartment.objects.all()], + widget=forms.Select(attrs={'class': 'form-control'}), + label="一级部门" + ) + class Meta: model = EmployeePerformanceTarget fields = '__all__' widgets = { 'name': forms.TextInput(attrs={'class': 'form-control'}), - 'department': forms.Select(attrs={'class': 'form-control'}), 'year': forms.NumberInput(attrs={'class': 'form-control'}), 'project_nature': forms.Select(attrs={'class': 'form-control'}), 'sales_target': forms.NumberInput(attrs={'class': 'form-control'}), @@ -57,3 +71,6 @@ class EmployeePerformanceTargetForm(forms.ModelForm): 'new_revenue_target': forms.NumberInput(attrs={'class': 'form-control'}), 'existing_revenue_target': forms.NumberInput(attrs={'class': 'form-control'}), } + + def __init__(self, *args, **kwargs): + super(EmployeePerformanceTargetForm, self).__init__(*args, **kwargs) diff --git a/application/perf_mgnt/models.py b/application/perf_mgnt/models.py index 932313a..23c1fdd 100644 --- a/application/perf_mgnt/models.py +++ b/application/perf_mgnt/models.py @@ -16,14 +16,14 @@ class GroupBusinessTarget(models.Model): primary_department = models.CharField(max_length=255, verbose_name='一级部门') year = models.IntegerField(verbose_name='年份') project_nature = models.CharField(max_length=255, choices=PROJECT_NATURE_CHOICES, verbose_name='项目性质') - sales = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='销售额(元)') - total_revenue_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='收入总目标(元)') - new_revenue_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='新增收入目标(元)') - existing_revenue_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='存量收入目标(元)') - cost_limit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='成本限额(元)') - gross_profit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='毛利润(元)') - expense_limit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='费用限额(元)') - operating_profit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='营业利润(元)') + sales = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='销售额(元)', null=True, blank=True) + total_revenue_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='收入总目标(元)', null=True, blank=True) + new_revenue_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='新增收入目标(元)', null=True, blank=True) + existing_revenue_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='存量收入目标(元)', null=True, blank=True) + cost_limit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='成本限额(元)', null=True, blank=True) + gross_profit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='毛利润(元)', null=True, blank=True) + expense_limit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='费用限额(元)', null=True, blank=True) + operating_profit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='营业利润(元)', null=True, blank=True) def save(self, *args, **kwargs): primary_department_name = PrimaryDepartment.objects.filter(department_name=self.primary_department).first() diff --git a/templates/items_list.html b/templates/items_list.html index 3884573..2d8105b 100644 --- a/templates/items_list.html +++ b/templates/items_list.html @@ -103,7 +103,7 @@ {% for field in item|get_fields:table_exclude_field_name %} {% if '(元)' in field.verbose_name %} - {{ field.value|thousands_separator }} + {{ field.value|default_if_none:'-'|thousands_separator }} {% else %} {{ field.value|default_if_none:'-' }} {% endif %}