xialashengqing

This commit is contained in:
shilixia 2020-08-13 15:59:59 +08:00
parent 0a5d76fd09
commit d5bc101d0a
16 changed files with 877 additions and 14 deletions

View File

@ -0,0 +1,73 @@
import request from '@/utils/request'
export function getDetectOrgList(query) {
return request({
url: '/laboratory/detectorg/',
method: 'get',
params: query
})
}
export function getDetectOrg(id) {
return request({
url: `/laboratory/detectorg/${id}/`,
method: 'get'
})
}
export function createDetectOrg(data) {
return request({
url: '/laboratory/detectorg/',
method: 'post',
data
})
}
export function updateDetectOrg(id, data) {
return request({
url: `/laboratory/detectorg/${id}/`,
method: 'put',
data
})
}
export function deleteDetectOrg(id) {
return request({
url: `/laboratory/detectorg/${id}/`,
method: 'delete'
})
}
export function getDetectOrgNoticeList(query) {
return request({
url: '/laboratory/detectorgnotice/',
method: 'get',
params: query
})
}
export function getDetectOrgNotice(id) {
return request({
url: `/laboratory/detectorgnotice/${id}/`,
method: 'get'
})
}
export function createDetectOrgNotice(data) {
return request({
url: '/laboratory/detectorgnotice/',
method: 'post',
data
})
}
export function updateDetectOrgNotice(id, data) {
return request({
url: `/laboratory/detectorgnotice/${id}/`,
method: 'put',
data
})
}
export function deleteDetectOrgNotice(id) {
return request({
url: `/laboratory/detectorgnotice/${id}/`,
method: 'delete'
})
}

View File

@ -235,6 +235,29 @@ export const asyncRoutes = [
},
]
},
{
path: '/detectorg',
component: Layout,
redirect: '/detectorg/detectorg',
name: 'detectorg',
meta: { title: '实验室管理', icon: 'example' },
children: [
{
path: 'detectorg',
name: 'DetectOrg',
component: () => import('@/views/detectorg/detectorg'),
meta: { title: '实验室信息', icon: 'example', perms: ['detectorg_manage'] }
},
{
path: 'detectorgnotice',
name: 'DetectOrgNotice',
component: () => import('@/views/detectorg/detectorgnotice'),
meta: { title: '实验室通知公告', icon: 'example', perms: ['detectorg_manage'] }
},
]
},
{
path: '/system',
component: Layout,

View File

@ -0,0 +1,269 @@
<template>
<div class="app-container">
<div style="margin-top:6px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">新增</el-button>
</div>
<el-table v-loading="listLoading"
:data="detectoryList.results"
style="width: 100%;margin-top:10px;"
border
fit
stripe
highlight-current-row
max-height="600">
<el-table-column type="index" width="50" />
<el-table-column label="实验室编号">
<template slot-scope="scope">
{{ scope.row.code }}
</template>
</el-table-column>
<el-table-column label="实验室名称">
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column align="header-center" label="通讯地址">
<template slot-scope="scope">
{{ scope.row.address }}
</template>
</el-table-column>
<el-table-column align="header-center" label="联系人姓名">
<template slot-scope="scope">
{{ scope.row.contactman }}
</template>
</el-table-column>
<el-table-column align="header-center" label="联系人电话">
<template slot-scope="scope">
{{ scope.row.ontactManTel }}
</template>
</el-table-column>
<el-table-column align="header-center" label="联系人手机">
<template slot-scope="scope">
{{ scope.row.contactmanmoblie }}
</template>
</el-table-column>
<el-table-column align="header-center" label="登录名">
<template slot-scope="scope">
{{ scope.row.loginname }}
</template>
</el-table-column>
<el-table-column align="header-center" label="密码">
<template slot-scope="scope">
{{ scope.row.password }}
</template>
</el-table-column>
<el-table-column align="header-center" label="是否自有">
<template slot-scope="scope">
{{ scope.row.iszy==true?'':'' }}
</template>
</el-table-column>
<el-table-column align="header-center" label="备注">
<template slot-scope="scope">
{{ scope.row.note }}
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary"
size="small"
icon="el-icon-edit"
:disabled="!checkPermission(['detectorg_update'])"
@click="handleUpdate(scope)" />
<el-button type="danger"
size="small"
icon="el-icon-delete"
:disabled="!checkPermission(['detectorg_delete'])"
@click="handleDelete(scope)" />
</template>
</el-table-column>
</el-table>
<pagination v-show="detectoryList.count>0"
:total="detectoryList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList" />
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='update'?'编辑标准':'新增标准'">
<el-form ref="Form"
:model="standard"
label-width="100px"
label-position="right"
:rules="rule1">
<el-form-item label="实验室编号" prop="code">
<el-input v-model="standard.code" placeholder="编号" />
</el-form-item>
<el-form-item label="实验室名称" prop="name">
<el-input v-model="standard.name" placeholder="名称" />
</el-form-item>
<el-form-item label="通讯地址" prop="address">
<el-input v-model="standard.address" placeholder="通讯地址" />
</el-form-item>
<el-form-item label="联系人姓名" prop="contactman">
<el-input v-model="standard.contactman" placeholder="联系人姓名" />
</el-form-item>
<el-form-item label="联系人电话" prop="ontactManTel">
<el-input v-model="standard.ontactManTel" placeholder="联系人电话" />
</el-form-item>
<el-form-item label="联系人手机" prop="contactmanmoblie">
<el-input v-model="standard.contactmanmoblie" placeholder="联系人手机" />
</el-form-item>
<el-form-item label="登录名" prop="loginname">
<el-input v-model="standard.loginname" placeholder="登录名" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="standard.password" placeholder="密码" />
</el-form-item>
<el-form-item label="自有" prop="iszy">
<el-switch v-model="standard.iszy"
active-color="#13ce66"
inactive-color="#8C969D">
</el-switch>
</el-form-item>
<el-form-item label="备注" prop="note">
<el-input type="textarea"
:rows="2"
placeholder="备注"
v-model="standard.note">
</el-input>
</el-form-item>
</el-form>
<div style="text-align:right;">
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getDetectOrgList, createDetectOrg, updateDetectOrg, deleteDetectOrg } from "@/api/laboratory"
import Pagination from "@/components/Pagination"
import checkPermission from '@/utils/permission'
const defaultStandard = {
id: null,
code: null,
name: null,
address: null,
contactman: null,
ontactManTel: null,
contactmanmoblie: null,
loginname: null,
password: null,
iszy: false,
note:null
}
export default {
components: { Pagination },
data() {
return {
detectoryList: { count: 0 },
standard: Object.assign({}, defaultStandard),
listLoading: true,
listQuery: {
page: 1,
page_size: 20
},
dialogVisible: false,
dialogType: 'create',
rule1: {
},
fileList: []
};
},
created() {
this.getList();
},
methods: {
checkPermission,
getList() {
this.listLoading = true;
getDetectOrgList(this.listQuery).then(response => {
if (response.data) {
this.detectoryList = response.data
}
this.listLoading = false;
});
},
resetFilter() {
this.listQuery = {
page: 1,
page_size: 20
};
this.getList();
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
},
handleCreate() {
this.standard = Object.assign({}, defaultStandard);
this.dialogType = "create";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleUpdate(scope) {
this.standard = Object.assign({}, scope.row) // copy obj
this.dialogType = 'update'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs['Form'].clearValidate()
})
},
handleDelete(scope) {
this.$confirm('确定删除本条数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteDetectOrg(scope.row.id).then(res=>{
this.$message.success('删除成功')
this.getList()
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
async confirm(form) {
this.$refs[form].validate(valid => {
if (valid) {
const isEdit = this.dialogType === "update";
if (isEdit) {
updateDetectOrg(this.standard.id, this.standard).then(res => {
this.getList();
this.dialogVisible = false
this.$message.success('成功')
});
} else {
createDetectOrg(this.standard).then(res => {
this.getList();
this.dialogVisible = false
this.$message.success('成功')
}).catch(error => { })
}
} else {
return false;
}
});
}
}
};
</script>

View File

@ -0,0 +1,335 @@
<template>
<div class="app-container">
<div style="margin-top:6px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">新增</el-button>
</div>
<el-table v-loading="listLoading"
:data="detectorynoticeList.results"
style="width: 100%;margin-top:10px;"
border
fit
stripe
highlight-current-row
max-height="600">
<el-table-column type="index" width="50" />
<el-table-column label="公告标题">
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column label="发布日期">
<template slot-scope="scope">
{{ scope.row.publishdate }}
</template>
</el-table-column>
<el-table-column label="公告内容">
<template slot-scope="scope">
{{ scope.row.note }}
</template>
</el-table-column>
<el-table-column label="重要公告">
<template slot-scope="scope">
{{ scope.row.ismportant==true?'':'' }}
</template>
</el-table-column>
<el-table-column label="实验室">
<template slot-scope="scope">
<ul style="list-style: none;">
<li v-for="(item, index) in scope.row.dettonotice" :key="index" >{{item.name}}</li>
</ul>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary"
size="small"
icon="el-icon-edit"
:disabled="!checkPermission(['detectorg_update'])"
@click="handleUpdate(scope)" />
<el-button type="danger"
size="small"
icon="el-icon-delete"
:disabled="!checkPermission(['detectorg_delete'])"
@click="handleDelete(scope)" />
</template>
</el-table-column>
</el-table>
<pagination v-show="detectorynoticeList.count>0"
:total="detectorynoticeList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList" />
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='update'?'编辑标准':'新增标准'">
<el-form ref="Form"
:model="standard"
label-width="100px"
label-position="right"
:rules="rule1">
<el-form-item label="公告标题" prop="name">
<el-input v-model="standard.name" placeholder="标题" />
</el-form-item>
<el-form-item label="发布时间" prop="publishdate">
<el-date-picker v-model="standard.publishdate"
type="datetime"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
<el-form-item label="重要公告" prop="ismportant">
<el-switch v-model="standard.ismportant"
active-color="#13ce66"
inactive-color="#8C969D">
</el-switch>
</el-form-item>
<el-form-item label="公告内容" prop="note">
<el-input type="textarea"
:rows="5"
placeholder="内容"
v-model="standard.note">
</el-input>
</el-form-item>
<el-form-item label="上传附件" prop="path">
<el-upload :on-preview="handlePreview"
:on-success="handleSuccess"
:action="upUrl"
:headers="upHeaders"
:limit="1"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
<el-form-item prop="path">
<el-button type="primary" @click="innerVisible = true">选择实验室</el-button>
</el-form-item>
</el-form>
<el-dialog width="30%"
title="选择实验室"
:visible.sync="innerVisible"
append-to-body>
<el-table ref="staffTable"
v-loading="listLoading"
:key="tableKey"
:data="staffList"
border
fit
highlight-current-row
@selection-change="handleStaffChange">
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
<el-table-column label="编号" align="center">
<template slot-scope="{row}">
<span>{{ row.code }}</span>
</template>
</el-table-column>
<el-table-column label="名称" align="center">
<template slot-scope="{row}">
<span>{{ row.name }}</span>
</template>
</el-table-column>
</el-table>
<el-button type="primary" @click="modifyStaff">提交</el-button>
</el-dialog>
<div style="text-align:right;">
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getDetectOrgNoticeList,getDetectOrgList, createDetectOrgNotice, updateDetectOrgNotice, deleteDetectOrgNotice } from "@/api/laboratory"
import { upUrl, upHeaders} from "@/api/file"
import Pagination from "@/components/Pagination"
import checkPermission from '@/utils/permission'
const defaultStandard = {
id: null,
name: null,
publishdate: null,
ismportant: false,
note:null
}
export default {
components: { Pagination },
data() {
return {
outerVisible: false,
innerVisible: false,
upHeaders: upHeaders(),
upUrl: upUrl(),
detectorynoticeList: { count: 0 },
standard: Object.assign({}, defaultStandard),
listLoading: true,
staffList: [],
tableKey: 0,
listQuery: {
page: 1,
page_size: 20
},
dialogVisible: false,
dialogType: 'create',
rule1: {
},
fileList: []
};
},
created() {
this.getList();
this.getStaffList()
},
methods: {
checkPermission,
handleFilter() {
this.listQuery.page = 1;
this.getList();
},
handlePreview(file) {
if ('url' in file){
window.open(file.url)
}else{
window.open(file.response.data.path)
}
},
getStaffList() {
getDetectOrgList().then(response => {
this.staffList = response.data.results;
})
},
getList() {
this.listLoading = true;
getDetectOrgNoticeList(this.listQuery).then(response => {
if (response.data) {
this.detectorynoticeList = response.data
console.log(this.detectorynoticeList)
}
this.listLoading = false;
});
},
resetFilter() {
this.listQuery = {
page: 1,
page_size: 20
};
this.getList();
},
handleStaffChange(rows) {
this.staffData = [];
if (rows) {
rows.forEach(row => {
if (row) {
this.staffData.push(row.id);
}
});
}
},
modifyStaff() {
this.standard.dettonotice = this.staffData;
this.innerVisible = false
},
handleSuccess(response, file, fileList) {
this.standard.path = response.data.path
},
handleCreate() {
this.standard = Object.assign({}, defaultStandard);
this.fileList = []
this.dialogType = "create";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleUpdate(scope) {
this.standard = Object.assign({}, scope.row) // copy obj
this.items = [];
if (this.standard.dettonotice) {
this.standard.dettonotice.forEach(row => {
if (row) {
this.items.push(row.id);
}
});
this.standard.dettonotice = this.items;
};
if(this.standard.path){
this.fileList = [{
name:this.standard.name,
url:this.standard.path
}]
}
this.dialogType = 'update'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs['Form'].clearValidate()
})
},
handleDelete(scope) {
this.$confirm('确定删除本条数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteDetectOrgNotice(scope.row.id).then(res=>{
this.$message.success('删除成功')
this.getList()
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
async confirm(form) {
this.$refs[form].validate(valid => {
if (valid) {
const isEdit = this.dialogType === "update";
if (isEdit) {
updateDetectOrgNotice(this.standard.id, this.standard).then(res => {
this.getList();
this.dialogVisible = false
this.$message.success('成功')
});
} else {
createDetectOrgNotice(this.standard).then(res => {
this.getList();
this.dialogVisible = false
this.$message.success('成功')
}).catch(error => { })
}
} else {
return false;
}
});
}
}
};
</script>

View File

@ -55,7 +55,7 @@
<el-col :span="12">
<el-form-item label="选择学员" prop="employees">
<!--<el-lable v-for="(item,index) in type_employees" :key="index">{{item.name}},</el-lable>-->
<!--<el-lable v-for="(item,index) in type_employees" :key="index">,</el-lable>-->
<el-input v-model="formData.employeeList" placeholder="参加人员" clearable :style="{width: '80%'}"></el-input>
<el-button type="text" @click="dialogVisible = true">选择</el-button>
<el-dialog title="" :visible.sync="dialogVisible">

View File

@ -166,7 +166,7 @@ methods: {
,
handleOrgClick(obj, node, vue) {
this.listQuery.page = 1;
this.listQuery.dept = obj.id;
this.listQuery.user__dept = obj.id;
this.getStaffList();
},
getStaffList() {

View File

@ -0,0 +1,45 @@
# Generated by Django 3.0.5 on 2020-08-10 06:57
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('system', '0028_auto_20200807_1018'),
]
operations = [
migrations.CreateModel(
name='DetectOrg',
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_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
('code', models.CharField(max_length=100, unique=True, verbose_name='实验室编号')),
('name', models.CharField(blank=True, max_length=200, null=True, unique=True, verbose_name='实验室名称')),
('address', models.CharField(blank=True, max_length=500, null=True, verbose_name='通讯地址')),
('contactman', models.CharField(blank=True, max_length=50, null=True, verbose_name='联系人')),
('contactmanmoblie', models.CharField(blank=True, max_length=50, null=True, verbose_name='联系人手机')),
('ontactManTel', models.CharField(blank=True, max_length=50, null=True, verbose_name='联系人电话')),
('loginname', models.CharField(blank=True, max_length=50, null=True, verbose_name='登录名')),
('password', models.CharField(blank=True, max_length=50, null=True, verbose_name='登录密码')),
('note', models.CharField(blank=True, max_length=200, null=True, verbose_name='备注')),
('iszy', models.BooleanField(default=True, verbose_name='是否自有')),
('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detectorg_belong_dept', to='system.Organization', verbose_name='所属部门')),
('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detectorg_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detectorg_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
],
options={
'verbose_name': '实验室信息',
'verbose_name_plural': '实验室信息',
},
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.5 on 2020-08-11 02:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('laboratory', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='detectorg',
name='code',
field=models.CharField(max_length=100, verbose_name='实验室编号'),
),
migrations.AlterField(
model_name='detectorg',
name='name',
field=models.CharField(blank=True, max_length=200, null=True, verbose_name='实验室名称'),
),
]

View File

@ -0,0 +1,41 @@
# Generated by Django 3.0.5 on 2020-08-12 00:59
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('system', '0028_auto_20200807_1018'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('laboratory', '0002_auto_20200811_1024'),
]
operations = [
migrations.CreateModel(
name='DetectOrgNotice',
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_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
('name', models.CharField(blank=True, max_length=500, null=True, verbose_name='公告标题')),
('publishdate', models.DateField(verbose_name='发布时间')),
('ismportant', models.BooleanField(default=True, verbose_name='是否重要公告')),
('note', models.CharField(blank=True, max_length=6000, null=True, verbose_name='公告内容')),
('isalluser', models.BooleanField(default=True, verbose_name='是否通知全员')),
('path', models.CharField(blank=True, max_length=1000, null=True, verbose_name='文件地址')),
('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detectorgnotice_belong_dept', to='system.Organization', verbose_name='所属部门')),
('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detectorgnotice_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
('dettonotice', models.ManyToManyField(blank=True, related_name='detectorgnotice_dettonotice', to='laboratory.DetectOrg', verbose_name='选择的实验室')),
('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='detectorgnotice_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
],
options={
'verbose_name': '实验室通知公告',
'verbose_name_plural': '实验室通知公告',
},
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2020-08-12 07:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('laboratory', '0003_detectorgnotice'),
]
operations = [
migrations.AlterField(
model_name='detectorgnotice',
name='publishdate',
field=models.DateTimeField(verbose_name='发布时间'),
),
]

View File

@ -6,8 +6,8 @@ import uuid
# Create your models here.
class DetectOrg(CommonBModel):
code = models.CharField('实验室编号',unique=True, max_length=100)
name = models.CharField('实验室名称',null=True,unique=True, blank=True,max_length=200)
code = models.CharField('实验室编号', max_length=100)
name = models.CharField('实验室名称',null=True, blank=True,max_length=200)
address = models.CharField('通讯地址',null=True, blank=True,max_length=500)
contactman = models.CharField('联系人',null=True, blank=True,max_length=50)
contactmanmoblie = models.CharField('联系人手机',null=True, blank=True,max_length=50)
@ -22,4 +22,19 @@ class DetectOrg(CommonBModel):
def __str__(self):
return self.name
class DetectOrgNotice(CommonBModel):
name = models.CharField('公告标题',null=True, blank=True,max_length=500)
publishdate = models.DateTimeField('发布时间')
ismportant = models.BooleanField('是否重要公告', default=True)
note = models.CharField('公告内容',null=True, blank=True,max_length=6000)
isalluser = models.BooleanField('是否通知全员', default=True)
path = models.CharField('文件地址', max_length=1000, null=True, blank=True)
dettonotice = models.ManyToManyField(DetectOrg, blank=True, verbose_name='选择的实验室', related_name= 'detectorgnotice_dettonotice')
class Meta:
verbose_name = '实验室通知公告'
verbose_name_plural = verbose_name
def __str__(self):
return self.name

View File

@ -1,6 +1,6 @@
from rest_framework import serializers
from .models import DetectOrg
from .models import DetectOrg,DetectOrgNotice
from apps.system.serializers import DictSerializer
@ -8,6 +8,12 @@ class DetectOrgSerializer(serializers.ModelSerializer):
class Meta:
model = DetectOrg
fields = '__all__'
class DetectOrgNoticeSerializer(serializers.ModelSerializer):
class Meta:
model = DetectOrgNotice
fields = '__all__'
class DetectOrgNoticListSerializer(serializers.ModelSerializer):
dettonotice = DetectOrgSerializer(many=True)
class Meta:
model = DetectOrgNotice
fields = ['id','name','publishdate','ismportant','note','dettonotice','path']

View File

@ -1,9 +1,10 @@
from django.urls import path, include
from .views import DetectOrgViewSet
from .views import DetectOrgViewSet,DetectOrgNoticeViewSet
from rest_framework import routers
router = routers.DefaultRouter()
router.register('detectorg', DetectOrgViewSet, basename="enterprise")
router.register('detectorg', DetectOrgViewSet, basename="detectorg")
router.register('detectorgnotice', DetectOrgNoticeViewSet, basename="detectorgnotice")
urlpatterns = [
path('', include(router.urls))

View File

@ -1,9 +1,9 @@
from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet
from .models import DetectOrg
from .models import DetectOrg,DetectOrgNotice
from utils.queryset import get_child_queryset2
from .serializers import DetectOrgSerializer
from .serializers import DetectOrgSerializer,DetectOrgNoticeSerializer,DetectOrgNoticListSerializer
from apps.system.permission_data import RbacFilterSet
from apps.system.mixins import CreateUpdateCustomMixin, OptimizationMixin
# Create your views here.
@ -13,6 +13,18 @@ class DetectOrgViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet)
'put': 'DetectOrg_update', 'delete': 'DetectOrg_delete'}
queryset = DetectOrg.objects
serializer_class = DetectOrgSerializer
search_fields = ['name','query_code', 'code']
search_fields = ['name', 'code']
ordering = ['-create_time']
class DetectOrgNoticeViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
perms_map = {'get': '*', 'post': 'DetectOrgNotice_create',
'put': 'DetectOrgNotice_update', 'delete': 'DetectOrgNotice_delete'}
queryset = DetectOrgNotice.objects
serializer_class = DetectOrgNoticeSerializer
search_fields = ['name']
ordering = ['-create_time']
def get_serializer_class(self):
# 根据请求类型动态变更serializer
if self.action == 'list':
return DetectOrgNoticListSerializer
return DetectOrgNoticeSerializer

View File

@ -48,7 +48,8 @@ INSTALLED_APPS = [
'apps.crm',
'apps.certset',
'apps.employee',
'apps.project'
'apps.project',
'apps.laboratory'
]
MIDDLEWARE = [

View File

@ -36,6 +36,7 @@ urlpatterns = [
path('crm/', include('apps.crm.urls')),
path('employee/', include('apps.employee.urls')),
path('project/', include('apps.project.urls')),
path('laboratory/', include('apps.laboratory.urls')),
path('docs/', include_docs_urls(title="接口文档",
authentication_classes=[], permission_classes=[])),
path('signature/', GenSignature.as_view(), name='gen_signature'),