feat: 修改优培企业 增加铺装工匠
This commit is contained in:
parent
cd1f5b69e0
commit
be23a9b6e3
|
@ -152,6 +152,37 @@ export function deleteCompany(id) {
|
|||
})
|
||||
}
|
||||
|
||||
//铺装工匠
|
||||
export function getArtList(query) {
|
||||
return request({
|
||||
url: '/cms/userpz/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function createArt(data) {
|
||||
return request({
|
||||
url: '/cms/userpz/',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function updateArt(id, data) {
|
||||
return request({
|
||||
url: `/cms/userpz/${id}/`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function deleteArt(id) {
|
||||
return request({
|
||||
url: `/cms/userpz/${id}/`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function getChildcompanyList(query) {
|
||||
return request({
|
||||
url: '/cms/childcomany/',
|
||||
|
|
|
@ -109,7 +109,13 @@ export const asyncRoutes = [
|
|||
name: 'youpeiList',
|
||||
component: () => import('@/views/youpei/index.vue'),
|
||||
meta: { title: '优培企业', icon: 'documentation', perms: ['youpei_view'] }
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'artist',
|
||||
name: 'articleList',
|
||||
component: () => import('@/views/youpei/artist.vue'),
|
||||
meta: { title: '铺装工匠', icon: 'documentation', perms: ['youpei_view'] }
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-row :gutter="2">
|
||||
<el-col :span="12">
|
||||
<el-card style=" height:750px">
|
||||
<div style="margin-top:10px">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
||||
</div>
|
||||
<div style="height: calc(100vh - 200px); overflow: auto;">
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="tableData.results"
|
||||
style="width: 100%"
|
||||
height="100%"
|
||||
border
|
||||
stripe
|
||||
fit
|
||||
highlight-current-row
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column align="left" width="230" label="姓名">
|
||||
<template slot-scope="scope">{{ scope.row.art_name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="头像">
|
||||
<template slot-scope="scope"><img
|
||||
v-if="scope.row.art_photo"
|
||||
:src="scope.row.art_photo"
|
||||
style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px;"></template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="scope">
|
||||
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-edit"
|
||||
@click="handleEdit(scope)"
|
||||
/>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑信息':'新增信息'">
|
||||
<el-form
|
||||
ref="commonForm"
|
||||
:model="userinfo"
|
||||
label-width="120px"
|
||||
label-position="right"
|
||||
>
|
||||
<el-form-item label="姓名" prop="art_name" style="width: 400px;">
|
||||
<el-input v-model="userinfo.art_name " placeholder="姓名" />
|
||||
</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="userinfo.path" :src="userinfo.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="art_remark" v-show="is_show">
|
||||
<tinymce v-model="userinfo.art_remark" :height="400" width="90%"/>
|
||||
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align:right;">
|
||||
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmcompany('commonForm')">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<pagination
|
||||
v-show="tableData.count>0"
|
||||
:total="tableData.count"
|
||||
:page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.limit"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createArt, deleteArt, updateArt, getArtList} from '@/api/cms'
|
||||
import checkPermission from '@/utils/permission'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import Tinymce from '@/components/Tinymce'
|
||||
import { upUrl } from "@/api/file";
|
||||
import { genTree, deepClone } from '@/utils'
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
const listQuery = {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
search: ''
|
||||
}
|
||||
const listQuery2 = {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
search: ''
|
||||
}
|
||||
export default {
|
||||
name: 'TinymceDemo',
|
||||
components: { Pagination, Tinymce},
|
||||
data() {
|
||||
return {
|
||||
upUrl: upUrl(),
|
||||
banner: {
|
||||
id: "",
|
||||
name: "",
|
||||
url:"",
|
||||
sort:0,
|
||||
path:""
|
||||
},
|
||||
upHeaders: { Authorization: "JWT " + getToken() },
|
||||
listQuery: Object.assign({}, listQuery),
|
||||
listQuery2: Object.assign({}, listQuery2),
|
||||
tableData: [],
|
||||
tableData2: [],
|
||||
is_show: true,
|
||||
listLoading: true,
|
||||
dialogVisible: false,
|
||||
dialogType: 'new',
|
||||
dialogType2: 'new',
|
||||
dialogVisible2: false,
|
||||
childCompy: {},
|
||||
userinfo: {},
|
||||
companyOption: [],
|
||||
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
checkPermission,
|
||||
getList() {
|
||||
this.listLoading = true
|
||||
getArtList(this.listQuery).then((response) => {
|
||||
this.tableData = response.data
|
||||
this.companyOption = genTree(response.data.results)
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
handleImgSuccess(res, file) {
|
||||
this.userinfo.art_photo = res.data.path
|
||||
},
|
||||
beforeImgUpload(file) {
|
||||
const isLt2M = file.size / 1024 / 1024 < 0.6;
|
||||
if (!isLt2M) {
|
||||
this.$message.error("上传图片大小不能超过 600KB!");
|
||||
}
|
||||
return isLt2M;
|
||||
},
|
||||
handleAdd() {
|
||||
this.userinfo = {}
|
||||
this.dialogType = 'new'
|
||||
this.dialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['commonForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
handleAdd2() {
|
||||
this.childCompy = {}
|
||||
this.dialogType2 = 'new'
|
||||
this.dialogVisible2 = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['commonForm2'].clearValidate()
|
||||
})
|
||||
},
|
||||
handleEdit(scope) {
|
||||
this.userinfo = Object.assign({}, scope.row) // copy obj
|
||||
this.dialogType = 'edit'
|
||||
this.dialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['commonForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
handleDelete(scope) {
|
||||
this.$confirm('确认删数据吗?将丢失数据!', '警告', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'error'
|
||||
})
|
||||
.then(async() => {
|
||||
await deleteArt(scope.row.id)
|
||||
this.getList()
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '成功删除!'
|
||||
})
|
||||
})
|
||||
// eslint-disable-next-line handle-callback-err
|
||||
.catch(err => {
|
||||
// console.error(err);
|
||||
})
|
||||
},
|
||||
// 行单击事件
|
||||
sourceRowClick(row) {
|
||||
this.listQuery2.parent_company = row.id
|
||||
this.compayNameC = row.company_name
|
||||
this.getList2()
|
||||
},
|
||||
handleTop(scope) {
|
||||
|
||||
},
|
||||
//企业创建
|
||||
async confirmcompany(form) {
|
||||
this.$refs[form].validate(valid => {
|
||||
if (valid) {
|
||||
const isEdit = this.dialogType === 'edit'
|
||||
if (isEdit) {
|
||||
updateArt(this.userinfo.id, this.userinfo).then(() => {
|
||||
this.getList()
|
||||
// 清空上传图片
|
||||
this.dialogVisible = false
|
||||
this.$message.success('成功')
|
||||
})
|
||||
} else {
|
||||
createArt(this.userinfo).then(res => {
|
||||
// this.exam = res.data
|
||||
// this.tableData.unshift(this.exam)
|
||||
this.getList()
|
||||
this.dialogVisible = false
|
||||
this.$message.success('成功')
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -84,8 +84,9 @@
|
|||
<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 label="备注" prop="remark" v-show="is_show">
|
||||
<tinymce v-model="companydata.remark" :height="400" width="90%"/>
|
||||
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align:right;">
|
||||
|
@ -193,6 +194,7 @@
|
|||
import { getCompanyList, createCompany, deleteCompany, updateCompany, getChildcompanyList, createChildcomany, deleteChildcomany, updateChildcomany } from '@/api/cms'
|
||||
import checkPermission from '@/utils/permission'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import Tinymce from '@/components/Tinymce'
|
||||
import { upUrl } from "@/api/file";
|
||||
import { genTree, deepClone } from '@/utils'
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
@ -208,7 +210,8 @@ const listQuery2 = {
|
|||
search: ''
|
||||
}
|
||||
export default {
|
||||
components: { Pagination },
|
||||
name: 'TinymceDemo',
|
||||
components: { Pagination, Tinymce},
|
||||
data() {
|
||||
return {
|
||||
upUrl: upUrl(),
|
||||
|
@ -224,6 +227,7 @@ export default {
|
|||
listQuery2: Object.assign({}, listQuery2),
|
||||
tableData: [],
|
||||
tableData2: [],
|
||||
is_show: true,
|
||||
listLoading: true,
|
||||
dialogVisible: false,
|
||||
dialogType: 'new',
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# Generated by Django 3.2.12 on 2025-04-17 07:38
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cms', '0019_auto_20250304_1552'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Userpz',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
|
||||
('is_delete', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
|
||||
('art_name', models.CharField(max_length=50, verbose_name='姓名')),
|
||||
('art_photo', models.CharField(max_length=100, verbose_name='照片')),
|
||||
('art_remark', models.TextField(blank=True, max_length=1000, null=True, verbose_name='备注')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='companyinfo',
|
||||
name='remark',
|
||||
field=models.TextField(blank=True, max_length=1000, null=True, verbose_name='备注'),
|
||||
),
|
||||
]
|
|
@ -64,13 +64,23 @@ class Threshold(CommonModel):
|
|||
cas = models.CharField('cas号', max_length=20)
|
||||
|
||||
|
||||
|
||||
class Userpz(CommonModel):
|
||||
art_name = models.CharField('姓名', max_length=50)
|
||||
art_photo = models.CharField('照片', max_length=100)
|
||||
art_remark = models.TextField('备注', null=True, blank=True, max_length=1000)
|
||||
|
||||
def __str__(self):
|
||||
return self.art_name
|
||||
|
||||
|
||||
class CompanyInfo(CommonModel):
|
||||
company_name = models.CharField('父公司名称', max_length=50)
|
||||
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.CharField('公司图片', null=True, blank=True, max_length=100)
|
||||
remark = models.TextField('备注', null=True, blank=True, max_length=500)
|
||||
remark = models.TextField('备注', null=True, blank=True, max_length=1000)
|
||||
|
||||
def __str__(self):
|
||||
return self.company_name
|
||||
|
@ -83,6 +93,9 @@ class ChildrenCompany(CommonModel):
|
|||
|
||||
def __str__(self):
|
||||
return self.child_company_name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from rest_framework import serializers
|
||||
from .models import Article, Material, Source, Threshold, CompanyInfo, ChildrenCompany
|
||||
from .models import Article, Material, Source, Threshold, CompanyInfo, ChildrenCompany, Userpz
|
||||
from utils.constants import EXCLUDE_FIELDS_BASE
|
||||
|
||||
|
||||
|
@ -50,6 +50,11 @@ class PathSerializer(serializers.Serializer):
|
|||
path = serializers.CharField(label='文件地址')
|
||||
|
||||
|
||||
class UserpzSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Userpz
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CompanyInfoSerializer(serializers.ModelSerializer):
|
||||
# children_companies = serializers.SerializerMethodField()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.urls import path,include
|
||||
from .views import ArticleViewSet, MaterialViewSet, SourceViewSet, ThresholdViewSet, ConpamyInfoViewSet, ChildrenCompanyViewSet
|
||||
from .views import ArticleViewSet, MaterialViewSet, SourceViewSet, ThresholdViewSet, ConpamyInfoViewSet, ChildrenCompanyViewSet, UserpzViewSet
|
||||
from rest_framework import routers
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ router.register('source', SourceViewSet, basename='source')
|
|||
router.register('threshold', ThresholdViewSet, basename='threshold')
|
||||
router.register('company', ConpamyInfoViewSet, basename='company')
|
||||
router.register('childcomany', ChildrenCompanyViewSet, basename='child_company')
|
||||
router.register('userpz', UserpzViewSet, basename='userpz')
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
|
|
|
@ -11,8 +11,8 @@ from openpyxl import load_workbook, Workbook
|
|||
from django.db import transaction
|
||||
# Create your views here.
|
||||
|
||||
from .models import Article, Material, Source, Threshold, CompanyInfo, ChildrenCompany
|
||||
from .serializers import ArticelSerializer, ArticelListSerializer, MaterialSerializer, SourceSerializer, ThresholdSerializer, PathSerializer, CompanyInfoSerializer, ChildrenCompanySerializer
|
||||
from .models import Article, Material, Source, Threshold, CompanyInfo, ChildrenCompany, Userpz
|
||||
from .serializers import ArticelSerializer,UserpzSerializer, ArticelListSerializer, MaterialSerializer, SourceSerializer, ThresholdSerializer, PathSerializer, CompanyInfoSerializer, ChildrenCompanySerializer
|
||||
from utils.custom import CommonPagination
|
||||
class ArticleViewSet(ModelViewSet):
|
||||
"""
|
||||
|
@ -62,6 +62,19 @@ class ConpamyInfoViewSet(ModelViewSet):
|
|||
ordering_fields = ['update_time']
|
||||
ordering = ['-sum_points']
|
||||
|
||||
class UserpzViewSet(ModelViewSet):
|
||||
"""
|
||||
铺装工匠:增删改查
|
||||
"""
|
||||
perms_map = [
|
||||
{'get': '*'}, {'post': 'article_create'},
|
||||
{'put': 'article_update'}, {'delete': 'article_delete'}]
|
||||
queryset = Userpz.objects.filter(is_delete=0).all()
|
||||
serializer_class = UserpzSerializer
|
||||
pagination_class = CommonPagination
|
||||
search_fields = ['name']
|
||||
ordering_fields = ['update_time']
|
||||
|
||||
|
||||
class ChildrenCompanyViewSet(ModelViewSet):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue