diff --git a/application/hrm_mgnt/models.py b/application/hrm_mgnt/models.py index 219b049..429afb1 100644 --- a/application/hrm_mgnt/models.py +++ b/application/hrm_mgnt/models.py @@ -2,6 +2,8 @@ import datetime from django.db import models +from application.org_mgnt.models import PrimaryDepartment, SecondaryDepartment + # 岗位表 class Position(models.Model): @@ -104,15 +106,16 @@ class EmployeeInformation(models.Model): ethnicity = models.CharField(max_length=255, verbose_name='民族', blank=True) domicile = models.CharField(max_length=255, verbose_name='户籍地', blank=True) marital_status = models.CharField(max_length=50, choices=MARITAL_STATUS_CHOICES, verbose_name='婚姻状态') - political_affiliation = models.CharField(max_length=50, choices=POLITICAL_AFFILIATION_CHOICES, verbose_name='政治面貌') + political_affiliation = models.CharField(max_length=50, choices=POLITICAL_AFFILIATION_CHOICES, + verbose_name='政治面貌') entry_date = models.DateField(verbose_name='入职日期') regularization_date = models.DateField(null=True, blank=True, verbose_name='转正日期') employment_type = models.CharField(max_length=50, choices=EMPLOYMENT_TYPE_CHOICES, verbose_name='用工性质') status = models.CharField(max_length=50, choices=STATUS_CHOICES, verbose_name='状态') - primary_department = models.ForeignKey('org_mgnt.PrimaryDepartment', on_delete=models.SET_NULL, null=True, verbose_name='一级部门') - secondary_department = models.ForeignKey('org_mgnt.SecondaryDepartment', on_delete=models.SET_NULL, null=True, verbose_name='二级部门', blank=True) - position = models.ForeignKey('Position', on_delete=models.SET_NULL, null=True, verbose_name='岗位') - rank = models.ForeignKey('Rank', on_delete=models.SET_NULL, null=True, verbose_name='职级', blank=True) + primary_department = models.CharField(max_length=255, verbose_name='一级部门', default='星河') + secondary_department = models.CharField(max_length=255, verbose_name='二级部门', default='数资团队') + position = models.CharField(max_length=255, verbose_name='岗位', default='数据分析师') + rank = models.CharField(max_length=255, verbose_name='职级', default='P1') contract_end_date = models.DateField(null=True, blank=True, verbose_name='当前合同到期日期') mobile_number = models.CharField(max_length=255, verbose_name='手机号') email = models.EmailField(verbose_name='邮箱') @@ -128,11 +131,30 @@ class EmployeeInformation(models.Model): base_salary = models.TextField(verbose_name='基础工资(元)', blank=True) salary_account_number = models.CharField(max_length=255, verbose_name='工资卡号', blank=True) bank_of_salary_account = models.CharField(max_length=255, verbose_name='工资卡开户行', blank=True) - resignation_type = models.CharField(max_length=50, choices=RESIGNATION_TYPE_CHOICES, verbose_name='离职类型', blank=True) + resignation_type = models.CharField(max_length=50, choices=RESIGNATION_TYPE_CHOICES, verbose_name='离职类型', + blank=True) resignation_reason = models.TextField(verbose_name='离职原因', blank=True) resignation_date = models.DateField(null=True, blank=True, verbose_name='离职日期') - excluded_fields = ['resignation_type', 'resignation_reason', 'resignation_date'] + def save(self, *args, **kwargs): + primary_department_name = PrimaryDepartment.objects.filter(department_name=self.primary_department).first() + secondary_department = SecondaryDepartment.objects.filter(secondary_department_name=self.secondary_department).first() + position = Position.objects.filter(position_name=self.position).first() + rank = Rank.objects.filter(rank_name=self.rank).first() + + if not primary_department_name: + raise ValueError("一级部门不存在") + + if not secondary_department: + raise ValueError("二级部门不存在") + + if not position: + raise ValueError("岗位不存在") + + if not rank: + raise ValueError("职位不存在") + + super(EmployeeInformation, self).save(*args, **kwargs) class Meta: verbose_name = '人员基本信息表' @@ -189,7 +211,8 @@ class OtherLeaveDetails(models.Model): ] record_id = models.AutoField(primary_key=True) - attendance_record = models.ForeignKey(EmployeeAttendanceRecord, on_delete=models.CASCADE, related_name='other_leaves', verbose_name='考勤记录') + attendance_record = models.ForeignKey(EmployeeAttendanceRecord, on_delete=models.CASCADE, + related_name='other_leaves', verbose_name='考勤记录') leave_type = models.CharField(max_length=255, choices=LEAVE_TYPE_CHOICES, verbose_name='假期类型') days = models.IntegerField(verbose_name='天数') description = models.TextField(verbose_name='说明') diff --git a/application/hrm_mgnt/templates/emp_list.html b/application/hrm_mgnt/templates/emp_list.html index b6251ff..59a7a19 100644 --- a/application/hrm_mgnt/templates/emp_list.html +++ b/application/hrm_mgnt/templates/emp_list.html @@ -16,7 +16,7 @@
-
+ {% csrf_token %}
{% for filter in filters %} @@ -74,11 +74,13 @@
- -
@@ -171,20 +173,6 @@ - - + + + + +
+ {% 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 %} + + {% block item_list_custom_content %} + {% endblock %} - {% endblock %} diff --git a/static/excels/组织管理-公司主体信息登记-Excel上传模板.xlsx b/static/excels/组织管理-公司主体信息登记-Excel上传模板.xlsx index 2ce231d..456a9bc 100644 Binary files a/static/excels/组织管理-公司主体信息登记-Excel上传模板.xlsx and b/static/excels/组织管理-公司主体信息登记-Excel上传模板.xlsx differ diff --git a/templates/items_list.html b/templates/items_list.html index a1e4b9b..5012248 100644 --- a/templates/items_list.html +++ b/templates/items_list.html @@ -117,7 +117,7 @@ data-bs-target="#addEditModal">编辑