feat: 修改职业等级

This commit is contained in:
zty 2025-03-05 13:56:45 +08:00
parent 5638574339
commit 343f82e859
11 changed files with 124 additions and 43 deletions

View File

@ -48,7 +48,7 @@
<template slot-scope="scope">{{ scope.row.workscope_name }}</template>
</el-table-column>
<el-table-column label="职业等级">
<template slot-scope="scope">{{ scope.row.opllevel }}</template>
<template slot-scope="scope">{{ getOpllevelName(scope.row.opllevel) }}</template>
</el-table-column>
<el-table-column label="单位">
<template slot-scope="scope">{{ scope.row.company_name }}</template>
@ -259,7 +259,7 @@ import Pagination from '@/components/Pagination'
const listQuery = {
page: 1,
limit: 20,
search: ''
ordering: 'opllevel'
}
export default {
components: { Pagination },
@ -281,13 +281,12 @@ export default {
number: [{ required: true, message: '请输入编号', trigger: 'blur' }]
},
typeOption:[
{ name: '初级工', value: '初级工' },
{ name: '中级工', value: '中级工'},
{ name: '高级工', value: '高级工' },
{ name: '技师', value: '技师'},
{ name: '高级技师', value: '高级技师' }
{ name: '初级工', value: 2 },
{ name: '中级工', value: 1},
{ name: '高级工', value: 0},
{ name: '技师', value: 4},
{ name: '高级技师', value: 3 }
],
}
},
computed: {},
@ -299,6 +298,13 @@ export default {
handleAvatarSuccess(res, file) {
this.candidate.photo = res.data.path
},
getOpllevelName(value) {
console.log(value, 'value')
const numValue = Number(value)
const item = this.typeOption.find((item) => item.value === numValue);
console.log(item, 'item-name')
return item ? item.name : '';
},
beforeAvatarUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 2
if (!isLt2M) {

View File

@ -1,6 +1,6 @@
<template>
<el-container>
<el-header>
<el-header style="height: 100px;">
<div style="margin-top: 10px;">
<el-input
v-model="listQuery.search"
@ -18,7 +18,7 @@
@click="resetFilter"
>刷新重置</el-button>
</div>
<div style="margin-top:10px">
<div style="margin-top:10px;height:50px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate('文档')">文档</el-button>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate('视频')">视频</el-button>
</div>
@ -27,7 +27,7 @@
<el-table
v-loading="listLoading"
:data="materialList.results"
style="width: 100%;margin-top:30px;"
style="width: 100%;"
border
max-height="600"
>
@ -288,6 +288,7 @@ export default {
})
},
handleCreate(val) {
console.log(val)
this.material = Object.assign({}, defaultmaterial)
this.material.type = val
this.fileList = []

View File

@ -27,6 +27,12 @@
<el-table-column align="left" label="协办大赛总积分">
<template slot-scope="scope">{{ scope.row.co_sponsor_points }}</template>
</el-table-column>
<el-table-column align="left" label="企业图片">
<template slot-scope="scope"><img
v-if="scope.row.photo"
:src="scope.row.photo"
style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px;"></template>
</el-table-column>
<el-table-column align="left" label="企业总积分">
<template slot-scope="scope">{{ scope.row.edu_points+scope.row.co_sponsor_points }}</template>
</el-table-column>
@ -56,9 +62,8 @@
:model="companydata"
label-width="120px"
label-position="right"
:rules="rule1"
>
<el-form-item label="企业名称" prop="company_name">
<el-form-item label="企业名称" prop="company_name" style="width: 400px;">
<el-input v-model="companydata.company_name " placeholder="企业名称" />
</el-form-item>
<el-form-item label="教育工匠总积分" prop="edu_points">
@ -67,6 +72,23 @@
<el-form-item label="协办大赛总积分" prop="co_sponsor_points">
<el-input-number v-model="companydata.co_sponsor_points " />
</el-form-item>
<el-form-item label="头像" prop="path" >
<el-upload
class="avatar-uploader"
:headers="upHeaders"
:action="upUrl"
accept="image/jpeg, image/gif, image/png, image/bmp"
:show-file-list="true"
:on-success="handleImgSuccess"
:before-upload="beforeImgUpload"
>
<img v-if="companydata.path" :src="companydata.path" style="width: 80%;height: auto;display: block;"/>
<el-button size="small" type="primary" v-else>点击上传</el-button>
</el-upload>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="companydata.remark" type="textarea" placeholder="备注" style="width: 600px;" />
</el-form-item>
</el-form>
<div style="text-align:right;">
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
@ -129,7 +151,6 @@
:model="childCompy"
label-width="120px"
label-position="right"
:rules="rule1"
>
<el-form-item label="企业名称" prop="child_edu_points">
<el-select
@ -175,7 +196,9 @@
import { getCompanyList, createCompany, deleteCompany, updateCompany, getChildcompanyList, createChildcomany, deleteChildcomany, updateChildcomany } from '@/api/cms'
import checkPermission from '@/utils/permission'
import Pagination from '@/components/Pagination'
import { upUrl } from "@/api/file";
import { genTree, deepClone } from '@/utils'
import { getToken } from "@/utils/auth";
const listQuery = {
page: 1,
@ -191,6 +214,15 @@ export default {
components: { Pagination },
data() {
return {
upUrl: upUrl(),
banner: {
id: "",
name: "",
url:"",
sort:0,
path:""
},
upHeaders: { Authorization: "JWT " + getToken() },
listQuery: Object.assign({}, listQuery),
listQuery2: Object.assign({}, listQuery2),
tableData: [],
@ -202,7 +234,7 @@ export default {
dialogVisible2: false,
childCompy: {},
companydata: {},
companyOption: []
companyOption: [],
}
},
@ -228,7 +260,16 @@ export default {
this.listLoading = false
})
},
handleImgSuccess(res, file) {
this.companydata.photo = res.data.path
},
beforeImgUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 0.6;
if (!isLt2M) {
this.$message.error("上传图片大小不能超过 600KB!");
}
return isLt2M;
},
handleAdd() {
this.companydata = {}
this.dialogType = 'new'
@ -287,8 +328,9 @@ export default {
if (valid) {
const isEdit = this.dialogType === 'edit'
if (isEdit) {
updateChildcomany(this.companydata.id, this.companydata).then(() => {
updateCompany(this.companydata.id, this.companydata).then(() => {
this.getList()
//
this.dialogVisible = false
this.$message.success('成功')
})

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.12 on 2025-03-04 07:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cms', '0018_auto_20240918_1109'),
]
operations = [
migrations.AddField(
model_name='companyinfo',
name='photo',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='公司图片'),
),
migrations.AddField(
model_name='companyinfo',
name='remark',
field=models.TextField(blank=True, max_length=500, null=True, verbose_name='备注'),
),
]

View File

@ -69,7 +69,7 @@ class CompanyInfo(CommonModel):
edu_points = models.FloatField('教育积分', null=True, blank=True)
co_sponsor_points = models.FloatField('协办大赛积分', null=True, blank=True)
sum_points = models.FloatField('总积分', null=True, blank=True)
photo = models.ImageField('公司图片', upload_to='photo', null=True, blank=True)
photo = models.CharField('公司图片', null=True, blank=True, max_length=100)
remark = models.TextField('备注', null=True, blank=True, max_length=500)
def __str__(self):

View File

@ -88,24 +88,3 @@ class ChildrenCompanySerializer(serializers.ModelSerializer):
parent_company.sum_points = parent_company.edu_points + parent_company.co_sponsor_points
parent_company.save()
return instance
# # # 定义信号处理器
# from django.db.models.signals import pre_save
# from django.dispatch import receiver
# from .models import ChildrenCompany, CompanyInfo
# @receiver(pre_save, sender=ChildrenCompany)
# def update_parent_sum_points(sender, instance, **kwargs):
# parent_company = instance.parent_company
# child_companies = ChildrenCompany.objects.filter(parent_company=parent_company)
# # 计算子公司的积分
# child_edu_sum = sum(c.child_edu_points or 0 for c in child_companies)
# child_co_sponsor_sum = sum(c.child_co_sponsor_points or 0 for c in child_companies)
# # 更新父公司的总积分
# parent_company.edu_points = child_edu_sum
# parent_company.co_sponsor_points = child_co_sponsor_sum
# parent_company.sum_points = child_edu_sum + child_co_sponsor_sum
# parent_company.save()

View File

@ -78,6 +78,7 @@ class ChildrenCompanyViewSet(ModelViewSet):
ordering_fields = ['update_time']
ordering = ['-update_time']
class MaterialViewSet(ModelViewSet):
"""
资料增删改查

View File

@ -0,0 +1,22 @@
# Generated by Django 3.2.12 on 2025-03-04 06:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('crm', '0047_auto_20240919_1605'),
]
operations = [
migrations.AlterModelOptions(
name='candidate',
options={'ordering': ['opllevel'], 'verbose_name': '证书', 'verbose_name_plural': '证书'},
),
migrations.AlterField(
model_name='candidate',
name='opllevel',
field=models.IntegerField(blank=True, choices=[(0, '高级工'), (1, '中级工'), (2, '初级工'), (3, '高级技师'), (4, '技师')], null=True),
),
]

View File

@ -107,6 +107,13 @@ class SendCode(CommonModel):
code = models.CharField(max_length=6, verbose_name= '验证码')
class Candidate(CommonModel):
OP_LEVEL_CHOICES = [
(0, '高级工'),
(1, '中级工'),
(2, '初级工'),
(3, '高级技师'),
(4, '技师'),
]
consumer = models.ForeignKey(Consumer, on_delete=models.SET_NULL, related_name='candidate_consumer', null=True, blank=True)
workscope = models.ForeignKey(WorkScope, on_delete=models.SET_NULL, related_name='candidate_workscope', null=True, blank=True)
examtest = models.OneToOneField(to='examtest.examtest', verbose_name='关联考试', null=True, blank=True, on_delete=models.SET_NULL)
@ -130,11 +137,12 @@ class Candidate(CommonModel):
train_end_date = models.DateField('培训结束日期', null=True)
create_admin = models.ForeignKey(UserProfile, verbose_name="创建管理员", null=True, blank=True, on_delete=models.SET_NULL)
gender = models.CharField('性别', max_length=10, null=True, blank=True)
opllevel = models.CharField('职业等级',max_length=60, null=True, blank=True)
opllevel = models.IntegerField(choices=OP_LEVEL_CHOICES, null=True, blank=True, default=0)
class Meta:
verbose_name = '证书'
verbose_name_plural = verbose_name
ordering = ['opllevel']
def __str__(self):
return self.consumer.username

View File

@ -743,8 +743,7 @@ class CandidateViewSet(RetrieveModelMixin, ListModelMixin, CreateModelMixin, Upd
filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter]
filterset_fields = ['consumer', 'create_admin']
search_fields = ('number', 'consumer_name', 'workscope_name', 'company_name', 'create_admin__username', 'ID_number')
ordering_fields = ('-id', 'update_time')
ordering = ['-update_time']
ordering_fields = ('-id', 'update_time', 'opllevel')
def get_serializer_class(self):
if self.action in ['create', 'update']:

View File

@ -5,7 +5,7 @@ from datetime import timedelta
from rest_framework.exceptions import ParseError
from rbac.models import UserProfile
from PIL import Image, ImageDraw, ImageFont
import settings, datetime
import datetime
from server import settings
def issue(obj: ExamTest, create_admin: UserProfile = None):