<template>
|
<div class="system-add-user-container">
|
<el-dialog :title="title" v-model="isShowDialog" width="50%">
|
<el-form :model="form" size="default" ref="formRef" :rules="rules" label-width="120px">
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="证书名称" prop="name">
|
<el-input v-model.trim="form.name" placeholder="证书名称" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="分类名称">
|
<el-input v-model.trim="form.cateName" placeholder="分类名称" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="分类标识" prop="cateType">
|
<el-select v-model="form.cateType" style="width: 100%">
|
<el-option
|
v-for="item in typeList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="发证机构" prop="orgName">
|
<el-input v-model.trim="form.orgName" placeholder="发证机构" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="发证日期">
|
<el-date-picker v-model="form.pusTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择发证日期" style="width: 100%" />
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="有效期至">
|
<el-date-picker v-model="form.effectiveTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择有效期至" style="width: 100%" />
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="到期提醒时间">
|
<el-date-picker v-model="form.dueTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择到期提醒时间" style="width: 100%" />
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="提醒人" prop="notifyUser">
|
<el-input v-model.trim="form.notifyUser" placeholder="提醒人" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="附件">
|
<el-upload accept="image/*" multiple list-type="picture-card" :action="uploadUrl" :headers="header" method="post" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :on-success="handleAvatarSuccess" :limit='2' v-model:file-list="fileList" :before-upload="picSize" :on-remove="handleRemove" :before-remove="beforeRemove">
|
<el-icon><Plus /></el-icon>
|
<template #tip>
|
<div class="el-upload__tip">上传图片尺寸小于2M,最多可上传2张</div>
|
</template>
|
</el-upload>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="title == '新增上报'? false : true">
|
<el-form-item label="删除状态" prop="deleted">
|
<el-radio-group v-model="form.deleted">
|
<el-radio :label="0">未删除</el-radio>
|
<el-radio :label="1">已删除</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="isShowDialog = !isShowDialog" size="default">取 消</el-button>
|
<el-button type="primary" v-throttle @click="onSubmit" size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { reactive, toRefs, onMounted, defineComponent, ref } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import axios from "axios";
|
import {workApplyApi} from "/@/api/specialWorkSystem/workApply";
|
import {judgeReportApi} from "/@/api/dataUpload/saftyBaseInfo/judgeReport";
|
import Cookies from "js-cookie";
|
|
// 定义接口来定义对象的类型
|
interface DataState {
|
title: string
|
isShowDialog: boolean
|
form: {
|
uuid: string
|
name: string
|
cateName: string
|
orgName: string
|
pusTime: string
|
effectiveTime: string
|
dueTime: string
|
notifyUser: string
|
cateType: string
|
deleted: number | null
|
files: string
|
}
|
rules:{}
|
typeList: Array<any>
|
fileList: [],
|
uploadUrl: string,
|
header: {},
|
imgDialog: boolean,
|
imageUrl: string
|
}
|
|
export default defineComponent({
|
name: 'reportDialog',
|
setup(props, context) {
|
const formRef = ref()
|
const state = reactive<DataState>({
|
title: '',
|
isShowDialog: false,
|
form: {
|
uuid:'',
|
name: '',
|
cateName: '',
|
orgName: '',
|
pusTime: '',
|
effectiveTime: '',
|
dueTime: '',
|
notifyUser: '',
|
cateType: '',
|
deleted: 0,
|
files: ''
|
},
|
typeList:[],
|
rules:{
|
name: [{ required: true, message: '请填写证书名称', trigger: 'blur' }],
|
cateType: [{ required: true, message: '请选择分类标识', trigger: 'blur' }],
|
orgName: [{ required: true, message: '请填写发证机构', trigger: 'blur' }],
|
notifyUser: [{ required: true, message: '请填写提醒人', trigger: 'blur' }]
|
},
|
fileList: [],
|
uploadUrl: import.meta.env.VITE_API_URL + '/account/file/upload',
|
header: {
|
uid: Cookies.get('uid'),
|
Authorization: Cookies.get('token')
|
},
|
imgDialog: false,
|
imageUrl: ''
|
})
|
|
// 页面加载时
|
onMounted(() => {
|
|
})
|
// 打开弹窗
|
const open = (type: string, data: object,cateTypeList: Array<any>) => {
|
state.isShowDialog = true;
|
state.typeList = cateTypeList
|
if (type === 'add') {
|
state.title = '新增上报';
|
state.form = {
|
uuid:'',
|
name: '',
|
cateName: '',
|
orgName: '',
|
pusTime: '',
|
effectiveTime: '',
|
dueTime: '',
|
notifyUser: '',
|
cateType: '',
|
deleted: 0,
|
files: ''
|
}
|
}else{
|
state.title = '重新上报'
|
Object.keys(state.form).forEach(key => {
|
if (Object.prototype.hasOwnProperty.call(data,key)) {
|
state.form[key] = JSON.parse(JSON.stringify(data))[key];
|
}
|
})
|
if(data.files !== ''){
|
state.fileList = data.files.split(',').map((i,index) => {
|
return {
|
url: i,
|
name: i
|
}
|
})
|
}else{
|
state.fileList=[]
|
}
|
// state.form = {
|
// uuid: data.uuid,
|
// name: '',
|
// cateName: '',
|
// orgName: '',
|
// pusTime: '',
|
// effectiveTime: '',
|
// dueTime: '',
|
// notifyUser: ''
|
// }
|
}
|
};
|
|
// 新增修改
|
const onSubmit = async () => {
|
formRef.value.validate(async (valid:Boolean) => {
|
if(valid){
|
state.form.files = state.fileList.map(i=>i.name).join(',')
|
const res = await judgeReportApi().addCard([state.form])
|
if(res.data.code == 200){
|
ElMessage({
|
type:'success',
|
message:'数据上报成功'
|
})
|
state.isShowDialog = false
|
}else{
|
ElMessage({
|
type:'warning',
|
message:res.data.msg
|
})
|
}
|
context.emit('refresh')
|
}else{
|
ElMessage({
|
type:'warning',
|
message:'请完善基本信息'
|
})
|
}
|
})
|
}
|
|
// 图片上传
|
const showTip =()=>{
|
ElMessage({
|
type: 'warning',
|
message: '超出文件上传数量'
|
});
|
}
|
|
const picSize = async(rawFile: any) => {
|
if(rawFile.size / 1024 / 1024 > 2){
|
ElMessage({
|
type: 'warning',
|
message: '文件大小不能超过2M'
|
});
|
return false
|
}
|
}
|
|
const handleAvatarSuccess = (res:any, uploadFile: any) => {
|
if(res){
|
uploadFile.name = res
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: '文件上传失败'
|
})
|
}
|
}
|
|
const handlePictureCardPreview = (uploadFile) => {
|
state.imageUrl = uploadFile.url
|
state.imgDialog = true;
|
}
|
|
const handleRemove = (file, uploadFiles,type) => {
|
state.fileList = uploadFiles
|
}
|
|
return {
|
formRef,
|
showTip,
|
picSize,
|
handleAvatarSuccess,
|
handlePictureCardPreview,
|
handleRemove,
|
open,
|
onSubmit,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|