feature:<master> feat:新增外审员以及文件上传功能
This commit is contained in:
parent
1102b57ebc
commit
39699e1a7a
|
@ -0,0 +1,51 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
|
||||
|
||||
export function getEa(query) {
|
||||
return request({
|
||||
url: '/info/ea/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getMyEas(query) {
|
||||
return request({
|
||||
url: '/info/ea/activate_info/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getOneEa(id) {
|
||||
return request({
|
||||
url: `/info/ea/${id}/`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function updateEa(id, data) {
|
||||
return request({
|
||||
url: `/info/ea/${id}/`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function createEa(data) {
|
||||
return request({
|
||||
url: `/info/ea/`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function delEa(id) {
|
||||
return request({
|
||||
url: `/info/ea/${id}/`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
|
@ -2,62 +2,131 @@
|
|||
<div class="app-container">
|
||||
<el-card class="elHeader">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAddFile">新增</el-button>
|
||||
<el-button type="primary" @click="handleImport('ea')">导入</el-button>
|
||||
<!-- <el-button type="primary" size="mini" icon="el-icon-plus" @click="handleCreate('oinspect')"></el-button> -->
|
||||
<el-button type="primary" @click="exportTableExcel('oinspect','外部监督检查信息')">导出</el-button>
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-table v-loading="listLoading" :data="tableData.results" :hieght="tableHeight" border fit stripe
|
||||
<el-table v-loading="listLoading"
|
||||
:data="tableData.results"
|
||||
border fit stripe height="500px"
|
||||
highlight-current-row>
|
||||
<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.description }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="文件格式">
|
||||
<template slot-scope="scope">{{ scope.row.file_.mime }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="文件下载">
|
||||
<el-table-column label="公司名称" prop="name_company"></el-table-column>
|
||||
<el-table-column label="姓名" prop="name"></el-table-column>
|
||||
<el-table-column label="评审类型" prop="review_types"></el-table-column>
|
||||
<el-table-column label="证书有效期" prop="certificate_expiration"></el-table-column>
|
||||
<el-table-column label="联系方式" prop="contact"></el-table-column>
|
||||
<el-table-column label="评审领域" prop="judging_areas"></el-table-column>
|
||||
<el-table-column label="备注" prop="remark"></el-table-column>
|
||||
<!-- <el-table-column align="center" label="文件下载">
|
||||
<template slot-scope="scope" v-if="scope.row.file_.file">
|
||||
<el-link :href="scope.row.file_.file" type="primary">下载</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column align="center" label="操作" width="120px" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-link :disabled="!checkPermission(['infoCollect_RS'])" type="primary" size="small"
|
||||
<el-link :disabled="!checkPermission(['infoCollect_EA'])" type="primary" size="small"
|
||||
@click="handleEdit(scope)">编辑</el-link>
|
||||
<el-divider direction="vertical"
|
||||
v-if="checkPermission(['infoCollect_RS']) && checkPermission(['infoCollect_RS']) "></el-divider>
|
||||
<el-link :disabled="!checkPermission(['infoCollect_RS'])" type="danger" size="small"
|
||||
v-if="checkPermission(['infoCollect_EA']) && checkPermission(['infoCollect_EA'])"></el-divider>
|
||||
<el-link :disabled="!checkPermission(['infoCollect_EA'])" type="danger" size="small"
|
||||
@click="handleDelete(scope)">删除</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-col :span="12" style="margin-top: 5px;">
|
||||
<div class="cardHead">
|
||||
<span class="cardTitle">外审员情况</span>
|
||||
</div>
|
||||
|
||||
</el-col>
|
||||
</el-table>
|
||||
<pagination v-show="tableData.count > 0" :total="tableData.count" :page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.page_size" @pagination="getTableList" />
|
||||
</el-card>
|
||||
<el-dialog :visible.sync="dialogVisible" :title="dialogType === 'edit' ? '编辑评审' : '新增评审'">
|
||||
<el-form ref="Form" :model="Content" label-width="80px" label-position="right" :rules="rule">
|
||||
<el-form-item label="评审名称" prop="name">
|
||||
<el-input v-model="Content.name" placeholder="评审名称" />
|
||||
<el-dialog :visible.sync="dialogVisible" :title="dialogType === 'edit' ? '编辑' : '新增'">
|
||||
<el-form ref="Form" :model="Content" label-width="100px" label-position="right" :rules="rule">
|
||||
<el-form-item label="公司名称" prop="name_company">
|
||||
<el-input v-model="Content.name_company" placeholder="公司名称"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="Content.name" placeholder="姓名"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="评审类型">
|
||||
<el-select
|
||||
v-model="Content.review_types"
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reviewOptions"
|
||||
:key="item.value"
|
||||
:label="item.key"
|
||||
:value="item.value"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="证书有效期" prop="certificate_expiration">
|
||||
<el-date-picker
|
||||
v-model="Content.certificate_expiration"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width:50%"
|
||||
>
|
||||
</el-date-picker>
|
||||
|
||||
<el-form-item label="" prop="description">
|
||||
<el-input type="textarea" :rows="2" v-model="Content.description" placeholder="评审描述" />
|
||||
</el-form-item>
|
||||
<el-form-item label="评审文件" prop="file" v-if="dialogVisible">
|
||||
<el-upload ref="upload" :action="upUrl" :on-preview="handlePreview" :on-success="handleUpSuccess"
|
||||
:on-remove="handleRemove" :headers="upHeaders" :file-list="fileList" :limit="1"
|
||||
accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf">
|
||||
<el-button size="small" type="primary">上传文件</el-button>
|
||||
</el-upload>
|
||||
<el-form-item label="联系方式" prop="contact">
|
||||
<el-input v-model="Content.contact" ></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="评审领域" prop="judging_areas">
|
||||
<el-input v-model="Content.judging_areas"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark" >
|
||||
<el-input v-model="Content.remark"></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>
|
||||
<el-dialog
|
||||
:visible.sync="impDialogVisible"
|
||||
title="导入"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="Form"
|
||||
label-width="80px"
|
||||
label-position="right"
|
||||
:rules="rule"
|
||||
>
|
||||
<el-form-item label="下载模板" prop="path">
|
||||
<a :href="downloadUrl">点击下载模板</a>
|
||||
</el-form-item>
|
||||
<el-form-item label="导入文件" prop="path">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="upUrl"
|
||||
:on-success="handleUpSuccess"
|
||||
:on-remove="handleRemove_res"
|
||||
:on-preview="handlePreview"
|
||||
:headers="upHeaders"
|
||||
:limit="3"
|
||||
:file-list="fileList"
|
||||
accept=".xls,.xlsx"
|
||||
>
|
||||
<el-button slot="trigger" size="small" type="primary">导入</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align: right">
|
||||
<el-button @click=close_dialog()>取 消</el-button>
|
||||
<el-button type="primary" @click="submitUpload">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
@ -66,16 +135,33 @@ import Pagination from "@/components/Pagination"; // secondary package based on
|
|||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { getDictList, getDictTypeList } from "@/api/dict";
|
||||
import { getMyEas, delEa, createEa, updateEa } from "@/api/eaduitors";
|
||||
import { upUrl, upHeaders } from "@/api/file";
|
||||
|
||||
const defaultContent = {
|
||||
name: "",
|
||||
description: "",
|
||||
file: null
|
||||
};
|
||||
name_company:"",
|
||||
name: "",
|
||||
review_types: "",
|
||||
certificate_expiration: "",
|
||||
contact: "",
|
||||
judging_areas: "",
|
||||
remark: ""
|
||||
};
|
||||
|
||||
export default {
|
||||
components: { Pagination, Treeselect },
|
||||
data() {
|
||||
data(){
|
||||
return {
|
||||
form: {
|
||||
name_company:"",
|
||||
name: "",
|
||||
review_types: "",
|
||||
certificate_expiration: "",
|
||||
contact: "",
|
||||
judging_areas: "",
|
||||
remark: ""
|
||||
},
|
||||
downloadUrl: process.env.VUE_APP_BASE_API,
|
||||
upHeaders: upHeaders(),
|
||||
upUrl: upUrl(),
|
||||
fileList: [],
|
||||
|
@ -95,44 +181,79 @@ export default {
|
|||
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
||||
},
|
||||
filterOrgText: "",
|
||||
tableHeight:null,
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
watch: {
|
||||
filterOrgText(val) {
|
||||
this.$refs.tree.filter(val);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
|
||||
// tableHeight: '300px',
|
||||
reviewOptions:[
|
||||
{key:'CNAS',value:0},
|
||||
{key:'CMA',value:1},
|
||||
{key:'DICA',value:2}
|
||||
],
|
||||
ac_options:{0:'组织方', 1:'参与方'}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let that = this;
|
||||
let height1 = document.getElementsByClassName('app-main')[0].clientHeight;
|
||||
let height2 = document.getElementsByClassName('elHeader')[0].clientHeight;
|
||||
that.tableHeight = height1 - height2 - 70;
|
||||
console.log(that.tableHeight)
|
||||
that.getList();
|
||||
|
||||
},
|
||||
let that = this;
|
||||
let height1 = document.getElementsByClassName('app-main')[0].clientHeight;
|
||||
let height2 = document.getElementsByClassName('elHeader')[0].clientHeight;
|
||||
that.tableHeight = height1 - height2 - 70;
|
||||
console.log(that.tableHeight)
|
||||
that.getList();
|
||||
|
||||
},
|
||||
methods: {
|
||||
getTableList() {
|
||||
this.getList();
|
||||
|
||||
//提交表单
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.dialogType == "new") {
|
||||
this.addData();
|
||||
} else {
|
||||
this.editData();
|
||||
}
|
||||
} else {
|
||||
console.log("error submit!!");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
close_dialog(){
|
||||
this.impDialogVisible = false;
|
||||
},
|
||||
submitUpload() {
|
||||
this.$refs.upload.submit();
|
||||
this.impDialogVisible = false;
|
||||
},
|
||||
handleImport(type){
|
||||
this.impDialogVisible = true;
|
||||
this.impType = type;
|
||||
let file_url = '';
|
||||
if(type=='ea'){
|
||||
file_url = "media/default/外审员情况-外审员情况统计表.xlsx";
|
||||
}
|
||||
let base_url = this.downloadUrl.substr(0, this.downloadUrl.length - 3);
|
||||
this.downloadUrl = base_url+file_url;
|
||||
},
|
||||
getTableList(){
|
||||
this.getList()
|
||||
|
||||
},
|
||||
handlePreview(file) {
|
||||
if ("url" in file) {
|
||||
window.open(file.url);
|
||||
} else {
|
||||
window.open(file.response.data.path);
|
||||
}
|
||||
if ("response" in file) {
|
||||
window.open(file.response.data.path);
|
||||
} else {
|
||||
window.open(file.value);
|
||||
}
|
||||
},
|
||||
handleUpSuccess(res, file, filelist) {
|
||||
this.Content.file = res.data.id;
|
||||
|
||||
handleUpSuccess(res, file) {
|
||||
this.fileList = [file];
|
||||
this.form.notification_form = res.data.path
|
||||
console.log(this.form)
|
||||
},
|
||||
handleRemove(file, filelist) {
|
||||
this.Content.file = null;
|
||||
handleRemove_res(file) {
|
||||
// 实现删除文件结果告知单
|
||||
this.fileList_res = [];
|
||||
this.form.result_form = null
|
||||
console.log(this.form)
|
||||
},
|
||||
checkPermission,
|
||||
|
||||
|
@ -142,8 +263,18 @@ export default {
|
|||
},
|
||||
|
||||
getList() {
|
||||
},
|
||||
this.listLoading = true;
|
||||
this.tableData.results =[];
|
||||
this.tableData.count =0;
|
||||
getMyEas(this.listQuery).then((response) => {
|
||||
console.log(response);
|
||||
if (response.data) {
|
||||
this.tableData = response.data;
|
||||
|
||||
}
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1;
|
||||
|
@ -181,9 +312,12 @@ export default {
|
|||
type: "error",
|
||||
})
|
||||
.then(async () => {
|
||||
// await deleteDoc(scope.row.id);
|
||||
// this.getList();
|
||||
// this.$message.success("成功");
|
||||
await delEa(scope.row.id).then(() => {
|
||||
this.getList();
|
||||
this.$message.success("成功");
|
||||
this.getTableList();
|
||||
})
|
||||
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
@ -195,17 +329,71 @@ export default {
|
|||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
console.log(this.Content)
|
||||
|
||||
updateEa(this.Content.id, this.Content).then((response) => {
|
||||
if (response.data) {
|
||||
this.tableData = response.data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
this.dialogVisible = false;
|
||||
this.getTableList();
|
||||
});
|
||||
} else {
|
||||
|
||||
createEa(this.Content).then((response) => {
|
||||
if (response.data) {
|
||||
this.tableData = response.data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
this.dialogVisible = false;
|
||||
this.getTableList();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
submitForm(form) {
|
||||
this.$refs.dialogForm.validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.isSaveing = true;
|
||||
try {
|
||||
var res;
|
||||
if (this.type == "add") {
|
||||
createOinspect(this.form).then(res=>{
|
||||
this.isSaveing = false;
|
||||
if(res.code>=200){
|
||||
this.dialogVisible = false;
|
||||
this.$emit("success",this.type);
|
||||
}else{
|
||||
this.$message.warning(res.data.msg);
|
||||
}
|
||||
})
|
||||
} else if (this.type == "edit") {
|
||||
updateOinspect(this.form.id,this.form).then(res=>{
|
||||
this.isSaveing = false;
|
||||
if(res.code>=200){
|
||||
this.dialogVisible = false;
|
||||
this.$emit("success",this.type);
|
||||
}else{
|
||||
this.$message.warning(res.data.msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
return res;
|
||||
} catch (err) {
|
||||
//可以处理校验错误
|
||||
this.isSaveing = false;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
onCancel() {
|
||||
this.$emit("closed");
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
<style></style>
|
|
@ -301,7 +301,7 @@ export default {
|
|||
if (valid) {
|
||||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
console.log(this.Content)
|
||||
console.log(this.Content);
|
||||
updateRs(this.Content.id, this.Content).then((response) => {
|
||||
if (response.data) {
|
||||
this.tableData = response.data;
|
||||
|
|
|
@ -65,10 +65,10 @@
|
|||
accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip">
|
||||
<el-button size="small" type="primary">上传文件</el-button>
|
||||
</el-upload>
|
||||
<!-- <div style="text-align: right">
|
||||
<div style="text-align: right">
|
||||
<el-button type="danger" @click="impDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit()">确认</el-button>
|
||||
</div> -->
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="结果告知单" prop="file">
|
||||
<el-upload
|
||||
|
@ -88,6 +88,7 @@
|
|||
<el-button type="primary" @click="onSubmit_result()">确认</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
|
||||
</el-dialog>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 3.2.12 on 2024-04-03 01:04
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('system', '0023_alter_user_first_name'),
|
||||
('information', '0016_auto_20240402_1558'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='externalauditors',
|
||||
name='department',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='system.organization', verbose_name='组织单位'),
|
||||
),
|
||||
]
|
|
@ -82,8 +82,8 @@ class ExternalAuditors(models.Model):
|
|||
certificate_expiration = models.DateField(verbose_name='证书有效期')
|
||||
contact = models.CharField(max_length=20, verbose_name='联系方式')
|
||||
judging_areas = models.CharField(max_length=20, verbose_name='评审领域')
|
||||
remark = models.CharField(max_length=20, verbose_name='备注', null=True)
|
||||
|
||||
remark = models.CharField(max_length=20, verbose_name='备注', null=True, blank=True)
|
||||
department = models.ForeignKey(Organization, on_delete=models.PROTECT, null=True, verbose_name='单位名称')
|
||||
class Meta:
|
||||
verbose_name = '外审员情况'
|
||||
db_table = 'externalauditors'
|
||||
|
|
|
@ -186,23 +186,32 @@ class QualityActivitiesViewSet(ModelViewSet):
|
|||
serializer = QualityActivitiesSerializer(query, many=True)
|
||||
data = {'count':len(serializer.data), 'results':serializer.data}
|
||||
return Response(data, status = status.HTTP_200_OK)
|
||||
|
||||
|
||||
class ContactViewSet(mixins.CreateModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.UpdateModelMixin,
|
||||
viewsets.GenericViewSet):
|
||||
|
||||
class ContactViewSet(ModelViewSet):
|
||||
queryset = Contact.objects.all()
|
||||
serializer_class = ContactSerializer
|
||||
|
||||
|
||||
class ExternalAuditorsViewSet(mixins.CreateModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.UpdateModelMixin,
|
||||
viewsets.GenericViewSet):
|
||||
class ExternalAuditorsViewSet(ModelViewSet):
|
||||
queryset = ExternalAuditors.objects.all()
|
||||
serializer_class = ExternalAuditorsSerializer
|
||||
|
||||
def create(self, request):
|
||||
if Organization.objects.filter(name=request.data['name_company']).exists():
|
||||
department_id = Organization.objects.filter(name=request.data['name_company']).first().id
|
||||
request.data['department'] = department_id
|
||||
serializer = self.get_serializer(data=request.data)
|
||||
if serializer.is_valid(raise_exception=True):
|
||||
serializer.save()
|
||||
return Response(serializer.data, status = status.HTTP_201_CREATED)
|
||||
else:
|
||||
raise ParseError("组织单位不存在")
|
||||
|
||||
# 查询子以及已经本公司的质量活动
|
||||
@action(detail=False, methods=['get'])
|
||||
def activate_info(self, request, *args, **kwargs):
|
||||
child_dept = get_child_queryset2(request.user.dept)
|
||||
query = ExternalAuditors.objects.filter(department__in=child_dept)
|
||||
serializer = ExternalAuditorsSerializer(query, many=True)
|
||||
data = {'count':len(serializer.data), 'results':serializer.data}
|
||||
return Response(data, status = status.HTTP_200_OK)
|
||||
|
||||
|
|
Loading…
Reference in New Issue