From a318384f63076bcda3f59a5b9f80a9d807e499c0 Mon Sep 17 00:00:00 2001 From: sichan Date: Wed, 19 Jun 2024 05:31:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=86EmployeeInformationA?= =?UTF-8?q?ddForm=E3=80=81EmployeeInformationEditForm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/hrm_mgnt/forms.py | 86 +++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/application/hrm_mgnt/forms.py b/application/hrm_mgnt/forms.py index b8b1af9..0571c9b 100644 --- a/application/hrm_mgnt/forms.py +++ b/application/hrm_mgnt/forms.py @@ -1,61 +1,67 @@ from django import forms -from common.forms import DepartmentSelectionForm from .models import * class EmployeeInformationForm(forms.ModelForm): - class Meta: - model = EmployeeInformation - fields = [field.name for field in EmployeeInformation._meta.fields if - field.name not in ['resignation_type', 'resignation_reason', 'resignation_date']] - widgets = { - 'birthday': forms.DateInput(attrs={'type': 'date'}), - 'entry_date': forms.DateInput(attrs={'type': 'date'}), - 'regularization_date': forms.DateInput(attrs={'type': 'date'}), - 'departure_date': forms.DateInput(attrs={'type': 'date'}), - 'contract_end_date': forms.DateInput(attrs={'type': 'date'}), - } - - -class EmployeeInformationAddForm(DepartmentSelectionForm, 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'}), label="一级部门" ) + position = forms.ChoiceField( + choices=[('', '---------')] + [(p.position_name, p.position_name) for p in Position.objects.all()], + widget=forms.Select(attrs={'class': 'form-control'}), + label="岗位" + ) + + rank = forms.ChoiceField( + choices=[('', '---------')] + [(r.rank_name, r.rank_name) for r in Rank.objects.all()], + widget=forms.Select(attrs={'class': 'form-control'}), + label="职级" + ) + class Meta: model = EmployeeInformation - fields = [field.name for field in EmployeeInformation._meta.fields if - field.name not in ['resignation_type', 'resignation_reason', 'resignation_date']] + exclude = ['resignation_type', 'resignation_reason', 'resignation_date'] widgets = { - 'birthday': forms.DateInput(attrs={'type': 'date'}), - 'entry_date': forms.DateInput(attrs={'type': 'date'}), - 'regularization_date': forms.DateInput(attrs={'type': 'date'}), - 'departure_date': forms.DateInput(attrs={'type': 'date'}), - 'contract_end_date': forms.DateInput(attrs={'type': 'date'}), - 'resignation_date': forms.DateInput(attrs={'type': 'date'}), - 'base_salary': forms.NumberInput() + 'name': forms.TextInput(attrs={'class': 'form-control'}), + 'id_number': forms.TextInput(attrs={'class': 'form-control'}), + 'gender': forms.Select(choices=EmployeeInformation.GENDER_CHOICES, attrs={'class': 'form-control'}), + 'birthday': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}), + 'age': forms.NumberInput(attrs={'class': 'form-control'}), + 'height': forms.NumberInput(attrs={'class': 'form-control'}), + 'weight': forms.NumberInput(attrs={'class': 'form-control'}), + 'blood_type': forms.Select(choices=EmployeeInformation.BLOOD_TYPE_CHOICES, attrs={'class': 'form-control'}), + 'ethnicity': forms.TextInput(attrs={'class': 'form-control'}), + 'domicile': forms.TextInput(attrs={'class': 'form-control'}), + 'marital_status': forms.Select(choices=EmployeeInformation.MARITAL_STATUS_CHOICES, attrs={'class': 'form-control'}), + 'political_affiliation': forms.Select(choices=EmployeeInformation.POLITICAL_AFFILIATION_CHOICES, attrs={'class': 'form-control'}), + 'entry_date': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}), + 'regularization_date': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}), + 'employment_type': forms.Select(choices=EmployeeInformation.EMPLOYMENT_TYPE_CHOICES, attrs={'class': 'form-control'}), + 'status': forms.Select(choices=EmployeeInformation.STATUS_CHOICES, attrs={'class': 'form-control'}), + 'secondary_department': forms.Select(attrs={'class': 'form-control'}), + 'contract_end_date': forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}), + 'mobile_number': forms.TextInput(attrs={'class': 'form-control'}), + 'email': forms.EmailInput(attrs={'class': 'form-control'}), + 'mailing_address': forms.TextInput(attrs={'class': 'form-control'}), + 'emergency_contact': forms.TextInput(attrs={'class': 'form-control'}), + 'relation_with_contact': forms.TextInput(attrs={'class': 'form-control'}), + 'emergency_contact_phone': forms.TextInput(attrs={'class': 'form-control'}), + 'education': forms.Select(choices=EmployeeInformation.EDUCATION_CHOICES, attrs={'class': 'form-control'}), + 'undergraduate_school': forms.TextInput(attrs={'class': 'form-control'}), + 'graduate_school': forms.TextInput(attrs={'class': 'form-control'}), + 'major': forms.TextInput(attrs={'class': 'form-control'}), + 'technical_title': forms.TextInput(attrs={'class': 'form-control'}), + 'base_salary': forms.NumberInput(attrs={'class': 'form-control'}), + 'salary_account_number': forms.TextInput(attrs={'class': 'form-control'}), + 'bank_of_salary_account': forms.TextInput(attrs={'class': 'form-control'}) } def __init__(self, *args, **kwargs): - super(EmployeeInformationAddForm, self).__init__(*args, **kwargs) - - -class EmployeeInformationEditForm(DepartmentSelectionForm, forms.ModelForm): - class Meta: - model = EmployeeInformation - fields = '__all__' - widgets = { - 'birthday': forms.DateInput(attrs={'type': 'date'}), - 'entry_date': forms.DateInput(attrs={'type': 'date'}), - 'regularization_date': forms.DateInput(attrs={'type': 'date'}), - 'departure_date': forms.DateInput(attrs={'type': 'date'}), - 'contract_end_date': forms.DateInput(attrs={'type': 'date'}), - 'resignation_date': forms.DateInput(attrs={'type': 'date'}), - 'base_salary': forms.NumberInput() - } + super(EmployeeInformationForm, self).__init__(*args, **kwargs) class EmployeeAttendanceRecordForm(forms.ModelForm):