diff --git a/apps/hrm/serializers.py b/apps/hrm/serializers.py index 1e52745b..4a99bd61 100755 --- a/apps/hrm/serializers.py +++ b/apps/hrm/serializers.py @@ -325,4 +325,14 @@ class ResignationSerializer(CustomModelSerializer): employee_id_number = serializers.CharField(source="employee.id_number", read_only=True) class Meta: model = Resignation - fields = '__all__' \ No newline at end of file + fields = '__all__' + + def create(self, validated_data): + employee:Employee = validated_data['employee'] + if employee.job_state == Employee.JOB_ON: + pass + else: + raise ParseError('员工不在职,不可创建申请') + if Resignation.objects.filter(employee=employee).exists(): + raise ParseError('该员工已存在离职申请') + return super().create(validated_data) \ No newline at end of file