diff --git a/client/src/api/util.js b/client/src/api/util.js
new file mode 100644
index 0000000..1fccd50
--- /dev/null
+++ b/client/src/api/util.js
@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+export function genSignature(data) {
+ return request({
+ url: '/signature/',
+ method: 'post',
+ data
+ })
+}
diff --git a/client/src/router/index.js b/client/src/router/index.js
index 37a62d2..33d5cf7 100644
--- a/client/src/router/index.js
+++ b/client/src/router/index.js
@@ -82,10 +82,10 @@ export const asyncRoutes = [
hidden: true
},
{
- path: 'qualification',
- name: 'Qualification',
- component: () => import('@/views/qualification/qualification'),
- meta: { title: '注册资格', icon: 'example', perms: ['qualification_view'] }
+ path: 'qualification_',
+ name: 'Qualification_',
+ component: () => import('@/views/qualification/qualification_'),
+ meta: { title: '注册资格检索', icon: 'example', perms: ['qualification_view'] }
},
]
},
diff --git a/client/src/views/ability/ability.vue b/client/src/views/ability/ability.vue
index 0d0c123..01384ed 100644
--- a/client/src/views/ability/ability.vue
+++ b/client/src/views/ability/ability.vue
@@ -2,6 +2,21 @@
+
+
+
{
+ this.afromOptions = genTree(res.data)
+ })
+ },
resetFilter() {
this.listQuery = {
page: 1,
diff --git a/client/src/views/ability/abilityform.vue b/client/src/views/ability/abilityform.vue
index 81b070a..6ff03ed 100644
--- a/client/src/views/ability/abilityform.vue
+++ b/client/src/views/ability/abilityform.vue
@@ -31,7 +31,7 @@
>
-
+
-
+
+
+
{
this.afromOptions = genTree(res.data);
diff --git a/client/src/views/education/education.vue b/client/src/views/education/education.vue
index c84f032..8557afe 100644
--- a/client/src/views/education/education.vue
+++ b/client/src/views/education/education.vue
@@ -1,6 +1,6 @@
-
+
新增
-
-
+
+
+
+
+
+
+
@@ -29,10 +43,10 @@
type="primary"
icon="el-icon-search"
@click="handleFilter"
+ style="margin-left:10px"
>搜索
-
+
{{ scope.row.code }}
-
+
{{ scope.row.user.username }}
-
+
{{ scope.row.user.name }}
-
+
{{ scope.row.user.dept_name }}
-
- {{ scope.row.user.position }}
+
+ {{ scope.row.ID_number }}
+
+
+ {{ scope.row.max_edu }}
{{ scope.row.create_time }}
-
+
\ No newline at end of file
diff --git a/client/src/views/qualification/qualification.vue b/client/src/views/qualification/qualification.vue
index 9fdf62f..e2104d4 100644
--- a/client/src/views/qualification/qualification.vue
+++ b/client/src/views/qualification/qualification.vue
@@ -1,13 +1,29 @@
-
+
+
+
+
-
@@ -29,6 +44,7 @@
type="primary"
icon="el-icon-search"
@click="handleFilter"
+ style="margin-left:10px"
>搜索
新增
-
{
+ this.auditor_typeOptions = genTree(res.data)
+ })
+ },
resetFilter() {
this.listQuery = {
page: 1,
page_size: 20,
- is_enabled:true,
employee: this.employee
}
this.getList()
diff --git a/client/src/views/qualification/qualification_.vue b/client/src/views/qualification/qualification_.vue
new file mode 100644
index 0000000..aa0218c
--- /dev/null
+++ b/client/src/views/qualification/qualification_.vue
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 刷新重置
+
+
+
+
+ {{ scope.row.cert_field_.fullname }}
+
+
+ {{ scope.row.cert_number }}
+
+
+ {{ scope.row.auditor_type_.name }}
+
+
+ {{ scope.row.registration_date }}
+
+
+ {{ scope.row.expiration_date }}
+
+
+
+ 是
+ 否
+
+
+
+ 有效
+ 失效
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/server/apps/employee/migrations/0013_auto_20200716_1806.py b/server/apps/employee/migrations/0013_auto_20200716_1806.py
new file mode 100644
index 0000000..b267ceb
--- /dev/null
+++ b/server/apps/employee/migrations/0013_auto_20200716_1806.py
@@ -0,0 +1,32 @@
+# Generated by Django 3.0.7 on 2020-07-16 10:06
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('certset', '0009_auto_20200709_1522'),
+ ('system', '0024_auto_20200716_0927'),
+ ('employee', '0012_auto_20200716_1200'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='ability',
+ options={'verbose_name': '专业能力', 'verbose_name_plural': ('专业能力',)},
+ ),
+ migrations.AddField(
+ model_name='employee',
+ name='education',
+ field=models.TextField(blank=True, verbose_name='最高学历'),
+ ),
+ migrations.AlterUniqueTogether(
+ name='ability',
+ unique_together={('employee', 'major', 'major_rule')},
+ ),
+ migrations.AlterUniqueTogether(
+ name='qualification',
+ unique_together=set(),
+ ),
+ ]
diff --git a/server/apps/employee/migrations/0014_auto_20200717_0832.py b/server/apps/employee/migrations/0014_auto_20200717_0832.py
new file mode 100644
index 0000000..c794c0b
--- /dev/null
+++ b/server/apps/employee/migrations/0014_auto_20200717_0832.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.7 on 2020-07-17 00:32
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('employee', '0013_auto_20200716_1806'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='employee',
+ old_name='education',
+ new_name='max_edu',
+ ),
+ ]
diff --git a/server/apps/employee/models.py b/server/apps/employee/models.py
index ef90b21..a6bd2d8 100644
--- a/server/apps/employee/models.py
+++ b/server/apps/employee/models.py
@@ -2,6 +2,7 @@ from django.db import models
from apps.system.models import CommonAModel, Dict, User, CommonBModel
from apps.certset.models import ImplementRule
from simple_history.models import HistoricalRecords
+from rest_framework.exceptions import ParseError
# Create your models here.
@@ -39,6 +40,7 @@ class Employee(CommonAModel):
blank=True, verbose_name='省市区', related_name='userdetail_region')
address = models.TextField('详细地址', null=True, blank=True)
signature = models.CharField('签名图片', max_length=200, null=True, blank=True)
+ max_edu = models.TextField('最高学历', blank=True)
class Meta:
verbose_name = '人员详细信息'
@@ -68,10 +70,25 @@ class Qualification(CommonAModel):
class Meta:
verbose_name = '注册资格'
verbose_name_plural = verbose_name
- unique_together = ('employee', 'cert_field', 'is_enabled')
def __str__(self):
return self.cert_number
+
+ def save(self, *args, **kwargs):
+ """
+ 暂停和启用该资格,需要操作能力表
+ """
+ bool_ = Qualification.objects.filter(employee=self.employee, cert_field=self.cert_field, is_enabled=True, is_deleted=False).exclude(pk=self.id).exists()
+ if bool_:
+ raise ParseError('已存在该领域的有效注册资格')
+ else:
+ if not self.is_enabled:
+ for i in Ability.objects.filter(employee=self.employee, cert_field=self.cert_field):
+ i.auditor_abilitys.remove(Dict.objects.get(code='checker_auditor'))
+ else:
+ for i in Ability.objects.filter(employee=self.employee, cert_field=self.cert_field):
+ i.auditor_abilitys.add(Dict.objects.get(code='checker_auditor'))
+ super().save(*args, **kwargs)
class Ability(CommonAModel):
@@ -95,7 +112,8 @@ class Ability(CommonAModel):
class Meta:
verbose_name = '专业能力'
- verbose_name_plural = verbose_name
+ verbose_name_plural = verbose_name,
+ unique_together = ('employee', 'major', 'major_rule')
def __str__(self):
s = ''
@@ -105,6 +123,12 @@ class Ability(CommonAModel):
s = s + self.major_rule.code
return s
+ def save(self, *args, **kwargs):
+ if self.cert_field and self.cert_field.code == 'CCC':
+ self.major = None
+ else:
+ self.major_rule = None
+ super().save(*args, **kwargs)
class Education(CommonAModel):
"""
@@ -126,6 +150,14 @@ class Education(CommonAModel):
def __str__(self):
return self.school
+ def save(self, *args, **kwargs):
+ super().save(*args, **kwargs)
+ queryset = Education.objects.filter(employee=self.employee,is_deleted=False).order_by('level')
+ if queryset.exists():
+ max_edu = queryset[0].level.name + '-' + queryset[0].school
+ self.employee.max_edu = max_edu
+ self.employee.save()
+
class Train(CommonAModel):
"""
diff --git a/server/apps/employee/serializers.py b/server/apps/employee/serializers.py
index c6e0b0e..5ac4f38 100644
--- a/server/apps/employee/serializers.py
+++ b/server/apps/employee/serializers.py
@@ -9,10 +9,13 @@ class EmployeeSerializer(serializers.ModelSerializer):
"""
普通序列化
"""
- user = UserListSerializer()
+ user = UserListSerializer(read_only=True)
+
class Meta:
model = Employee
fields = '__all__'
+
+
@staticmethod
def setup_eager_loading(queryset):
@@ -20,13 +23,6 @@ class EmployeeSerializer(serializers.ModelSerializer):
queryset = queryset.select_related('user')
return queryset
-class EmployeeUpdateSerializer(serializers.ModelSerializer):
- """
- update序列化
- """
- class Meta:
- model = Employee
- exclude = ['user']
class QualificationSerializer(serializers.ModelSerializer):
"""
@@ -67,22 +63,6 @@ class AbilitySerializer(serializers.ModelSerializer):
queryset = queryset.prefetch_related('auditor_abilitys',)
return queryset
-
- def save(self, **kwargs):
- validated_data = dict(
- list(self.validated_data.items()) +
- list(kwargs.items())
- )
- if validated_data['cert_field'] and validated_data['cert_field'].code == 'CCC':
- validated_data['major'] = None
- else:
- validated_data['major_rule'] = None
- if self.instance is not None:
- self.instance = self.update(self.instance, validated_data)
- else:
- self.instance = self.create(validated_data)
- return self.instance
-
class EducationSerializer(serializers.ModelSerializer):
"""
普通序列化
@@ -92,6 +72,7 @@ class EducationSerializer(serializers.ModelSerializer):
model = Education
fields = '__all__'
+
class TrainSerializer(serializers.ModelSerializer):
"""
普通序列化
diff --git a/server/apps/employee/views.py b/server/apps/employee/views.py
index f48b6d2..f90cf14 100644
--- a/server/apps/employee/views.py
+++ b/server/apps/employee/views.py
@@ -1,5 +1,7 @@
from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet
+from rest_framework.response import Response
+from rest_framework import status
from .models import *
from .serializers import *
from apps.system.permission_data import RbacFilterSet
@@ -14,14 +16,9 @@ class EmployeeViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
queryset = Employee.objects.all()
serializer_class = EmployeeSerializer
search_fields = ['code', 'remember_code', 'user__name']
- filterset_fields = ['is_onjob', 'is_fulltime']
+ filterset_fields = ['is_onjob', 'is_fulltime', 'user__dept']
ordering = ['-create_time']
- def get_serializer_class(self):
- if self.action == 'update':
- return EmployeeUpdateSerializer
- else:
- return self.serializer_class
class QualificationViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
"""
@@ -44,7 +41,7 @@ class AbilityViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
queryset = Ability.objects.all()
serializer_class = AbilitySerializer
search_fields = ['major__code', 'major_rule__code']
- filterset_fields = ['major', 'major_rule', 'auditor_abilitys']
+ filterset_fields = ['major', 'major_rule', 'auditor_abilitys', 'afrom']
ordering = ['-create_time']
class EducationViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
@@ -57,7 +54,7 @@ class EducationViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet)
serializer_class = EducationSerializer
search_fields = ['school', 'major', 'employee__name']
filterset_fields = ['level']
- ordering = ['-create_time']
+ ordering = ['level__sort']
class TrainViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
"""
diff --git a/server/apps/system/serializers.py b/server/apps/system/serializers.py
index 8c25ac8..2500294 100644
--- a/server/apps/system/serializers.py
+++ b/server/apps/system/serializers.py
@@ -84,11 +84,11 @@ class UserListSerializer(serializers.ModelSerializer):
用户列表序列化
"""
dept_name = serializers.StringRelatedField(source='dept')
-
+ roles_name = serializers.StringRelatedField(source='roles', many=True)
class Meta:
model = User
fields = ['id', 'name', 'phone', 'email', 'position',
- 'username', 'is_active', 'date_joined', 'dept_name', 'dept', 'roles', 'avatar']
+ 'username', 'is_active', 'date_joined', 'dept_name', 'dept', 'roles', 'avatar', 'roles_name']
@staticmethod
def setup_eager_loading(queryset):
diff --git a/server/server/urls.py b/server/server/urls.py
index 7171242..d4bd73c 100644
--- a/server/server/urls.py
+++ b/server/server/urls.py
@@ -21,7 +21,7 @@ from rest_framework import routers
from rest_framework.documentation import include_docs_urls
from rest_framework_simplejwt.views import (TokenObtainPairView,
TokenRefreshView)
-
+from utils.view import GenSignature
from apps.system.views import FileViewSet, LogoutView
router = routers.DefaultRouter()
router.register('file', FileViewSet, basename="file")
@@ -36,6 +36,7 @@ urlpatterns = [
path('employee/', include('apps.employee.urls')),
path('docs/', include_docs_urls(title="接口文档",
authentication_classes=[], permission_classes=[])),
+ path('signature/', GenSignature.as_view(), name='gen_signature'),
path('', include(router.urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
diff --git a/server/utils/view.py b/server/utils/view.py
index 09ef5b7..4fc4db8 100644
--- a/server/utils/view.py
+++ b/server/utils/view.py
@@ -4,11 +4,12 @@ from rest_framework.parsers import MultiPartParser
from rest_framework.permissions import IsAuthenticated
from PIL import Image
from django.conf import settings
-
+from rest_framework import status
from datetime import datetime
import os
import uuid
-
+import cv2
+from server.settings import BASE_DIR
# class UploadFileView(APIView):
# permission_classes = [IsAuthenticated]
@@ -28,3 +29,22 @@ import uuid
# f.write(chunk)
# resdata = {"name": file_name, "path": '/' + file_path}
# return Response(resdata)
+
+class GenSignature(APIView):
+ """
+ 生成签名图片
+ """
+ permission_classes=[]
+
+ def post(self, request, *args, **kwargs):
+ path = (BASE_DIR + request.data['path']).replace('\\', '/')
+ image = cv2.imread(path, cv2.IMREAD_UNCHANGED)
+ size = image.shape
+ for i in range(size[0]):
+ for j in range(size[1]):
+ if image[i][j][0]>100 and image[i][j][1]>100 and image[i][j][2]>100:
+ image[i][j][3] = 0
+ else:
+ image[i][j][0],image[i][j][1],image[i][j][2] = 0,0,0
+ cv2.imwrite(path,image)
+ return Response(request.data, status=status.HTTP_200_OK)