修改了一些明显的问题

This commit is contained in:
王思川 2024-06-19 10:39:14 +08:00
parent fd7ceaceae
commit b250fced58
5 changed files with 48 additions and 28 deletions

View File

@ -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__'

View File

@ -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:

View File

@ -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)

View File

@ -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()

View File

@ -103,7 +103,7 @@
<tr>
{% for field in item|get_fields:table_exclude_field_name %}
{% if '(元)' in field.verbose_name %}
<td class="text-center">{{ field.value|thousands_separator }}</td>
<td class="text-center">{{ field.value|default_if_none:'-'|thousands_separator }}</td>
{% else %}
<td class="text-center">{{ field.value|default_if_none:'-' }}</td>
{% endif %}