| | |
| | | <template> |
| | | <div class="riskBox"> |
| | | <el-form ref="formRef" :model="state.formData" :rules="state.rules" class="register-form" label-position="top"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="18"> |
| | | <el-form-item label="附件上传"> |
| | | <el-upload accept=".pdf,.doc,.docx" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="handleAvatarSuccess" :on-exceed="showTip" :limit='state.imgLimit' v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="handleRemove" :before-remove="beforeRemove"> |
| | | <el-button type="primary">附件上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">支持上传pdf/word/doc/docx格式文件,尺寸小于2M,最多可上传3张</div> |
| | | </template> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item prop="technology" label="评价结论"> |
| | | <el-form-item prop="conclusion" label="评价结论"> |
| | | <el-input |
| | | v-model="state.formData.technology" |
| | | v-model.trim="state.formData.conclusion" |
| | | :autosize="{ minRows: 6 }" |
| | | maxlength="500" |
| | | show-word-limit |
| | |
| | | </el-form-item> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="9"> |
| | | <el-form-item prop="technology" label="是否有评价报告修改说明"> |
| | | <el-radio-group v-model="state.formData.status" > |
| | | <el-radio :label="1">是</el-radio> |
| | | <el-radio :label="0">否</el-radio> |
| | | </el-radio-group> |
| | | <el-form-item prop="isReviseManual" label="评价报告修改说明"> |
| | | <!-- <el-radio-group v-model="state.formData.isReviseManual" >--> |
| | | <!-- <el-radio :label="1">是</el-radio>--> |
| | | <!-- <el-radio :label="0">否</el-radio>--> |
| | | <!-- </el-radio-group>--> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="18"> |
| | | <el-form-item> |
| | | <el-upload |
| | | accept="image/*,.pdf,.doc,.docx,.xlsx,.xls" |
| | | :action="state.uploadUrl" |
| | | :disabled="projectType === 'view' || isEnd" |
| | | :headers="state.header" |
| | | method="post" |
| | | :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" |
| | | :on-exceed="showTip" |
| | | v-model:file-list="state.fileList" |
| | | :on-remove="handleRemove" |
| | | :data="state.uploadData" |
| | | :on-preview="handlePreview" |
| | | :limit='15' |
| | | :before-upload="picSize" |
| | | > |
| | | <el-button type="primary">评价报告上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">上传文件尺寸小于15M,最多可上传15份,多张图片建议合并为PDF文件规范上传。</div> |
| | | </template> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </template> |
| | | <script setup> |
| | | |
| | | import {defineEmits, onMounted, reactive, ref} from "vue"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {defineEmits, defineProps, onMounted, reactive, ref} from "vue"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import {Search} from '@element-plus/icons-vue' |
| | | import {addRisk, editRisk, getRiskDetail} from "@/api/projectManage/riskAnalysis" |
| | | import {addRate, addRisk, editRate, editRisk, getRateDetail, getRiskDetail} from "@/api/projectManage/riskAnalysis" |
| | | import {delPic} from "@/api/login" |
| | | import { getToken } from "@/utils/auth"; |
| | | import Cookies from "js-cookie" |
| | | import {delAccessoryFile, getAccessoryFile} from "@/api/projectManage/project"; |
| | | import axios from "axios"; |
| | | import {delFile, getFiles} from "@/api/projectManage/siteCheckRcd"; |
| | | import { useRoute } from 'vue-router' |
| | | const route = useRoute() |
| | | const emit = defineEmits(["getNextStatus"]); |
| | | |
| | | const prop = defineProps(['projectId']) |
| | | const state = reactive({ |
| | | formData: { |
| | | id: '', |
| | | leader: { |
| | | name: '' |
| | | }, |
| | | leaderId: null, |
| | | linkMan: '', |
| | | transmitPerson: '', |
| | | transmitDate: '' |
| | | isReviseManual: 1, |
| | | }, |
| | | rules: { |
| | | "leader.name": [{required: true, message: '请选择项目负责人', trigger: 'blur'}], |
| | | linkMan: [{required: true, message: '请输入联系人', trigger: 'blur'}], |
| | | linkPhone: [{required: true, message: '请输入联系电话', trigger: 'blur'}], |
| | | transmitDate: [{required: true, message: '请选择任务下达时间', trigger: 'blur'}] |
| | | conclusion: [{required: true, message: '请输入评价结论', trigger: 'blur'}], |
| | | }, |
| | | tableData: [], |
| | | imgLimit: 3, |
| | | uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile', |
| | | uploadUrl: import.meta.env.VITE_APP_BASE_API + '/manage/accessory-file/uploadFile', |
| | | header: { |
| | | Authorization: 'Bearer ' + getToken() |
| | | } |
| | | Authorization: getToken() |
| | | }, |
| | | fileList: [], |
| | | uploadData: { |
| | | moduleType: 7 |
| | | }, |
| | | disabled: false |
| | | }) |
| | | const props = { |
| | | expandTrigger: 'hover', |
| | |
| | | if(userInfo.identity === 0){ |
| | | isAmin.value = true; |
| | | } |
| | | if(prop.projectId){ |
| | | const val = prop.projectId; |
| | | state.uploadData.projectId = val; |
| | | getProcessFiles(val); |
| | | } |
| | | isEnd.value = Cookies.get('end') |
| | | projectType.value = route.query.type; |
| | | }) |
| | | |
| | | const projectType = ref(''); |
| | | const isEnd = ref('') |
| | | const riskOpen = async (type,val) => { |
| | | state.uploadData.projectId = val; |
| | | projectType.value = route.query.type; |
| | | isEnd.value = Cookies.get('end') |
| | | if(type === 'detail' || type === 'edit' ){ |
| | | const res = await getRiskDetail({projectId: val}); |
| | | if(type === 'detail'){ |
| | | state.disabled = true |
| | | } |
| | | const res = await getRateDetail({projectId: val}); |
| | | if(res.code == 200){ |
| | | state.formData = res.data; |
| | | if(res.data){ |
| | | state.formData = res.data; |
| | | state.formData.isReviseManual = res.data.isReviseManual ? 1 : 0 |
| | | state.fileList = res.data.accessoryFiles.map(item => { |
| | | return { |
| | | ...item, |
| | | name: item.originName, |
| | | } |
| | | }) |
| | | } |
| | | }else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | if(type === 'add' || type === 'clickEdit') { |
| | | const valid = await formRef.value.validate(); |
| | | if(state.fileList && state.fileList.length<=0 ){ |
| | | ElMessage.warning('请上传评价报告') |
| | | return |
| | | } |
| | | |
| | | if(valid){ |
| | | if (isAmin.value) { |
| | | ElMessage.warning("当前用户暂无权限"); |
| | | return; |
| | | } |
| | | if(type === 'add'){ |
| | | const {id, ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | const res = await addRisk(data); |
| | | const {id,attachments, ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | data.projectId = val; |
| | | data.accessoryFiles = state.fileList |
| | | const res = await addRate(data); |
| | | if (res.code == 200) { |
| | | ElMessage.success('保存成功') |
| | | formRef.value.clearValidate(); |
| | | emit('getNextStatus', res.data); |
| | | emit('getNextStatus', val); |
| | | |
| | | } else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }else if(type === 'clickEdit'){ |
| | | const { ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | const res = await editRisk(data); |
| | | const { attachments, ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | data.accessoryFiles = state.fileList |
| | | const res = await editRate(data); |
| | | if (res.code == 200) { |
| | | ElMessage.success('变更成功') |
| | | formRef.value.clearValidate(); |
| | |
| | | } |
| | | } |
| | | |
| | | // 图片上传 |
| | | // 上传 |
| | | const showTip =()=>{ |
| | | ElMessage({ |
| | | type: 'warning', |
| | |
| | | } |
| | | |
| | | const picSize = async (rawFile) => { |
| | | if(rawFile.size / 1024 / 1024 > 2){ |
| | | if(rawFile.size / 1024 / 1024 > 15){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '文件大小不能超过2M' |
| | | message: '文件大小不能超过15M' |
| | | }); |
| | | return false |
| | | } |
| | | }; |
| | | |
| | | const handleAvatarSuccess = (res, uploadFile) => { |
| | | if(res.code == 200){ |
| | | // state.registerForm.agency.reportPath = res.data.path |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '文件上传失败' |
| | | }) |
| | | } |
| | | } |
| | | |
| | | const handleRemove = async (file, uploadFiles) => { |
| | | const res = await delPic({path: state.registerForm.agency.reportPath}) |
| | | if(res.code == 200){ |
| | | const handleAvatarSuccess = (res,uploadFile) => { |
| | | if(res.code === 200){ |
| | | getProcessFiles() |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '文件已删除' |
| | | message: '文件上传成功' |
| | | }) |
| | | }else{ |
| | | }else { |
| | | state.fileList.splice(state.fileList.indexOf(uploadFile),1) |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.message |
| | | }) |
| | | } |
| | | |
| | | } |
| | | const handlePreview = (file) => { |
| | | let path = ""; |
| | | if(file.path){ |
| | | path = file.path |
| | | }else { |
| | | path = file.response.data.path |
| | | |
| | | } |
| | | const url = import.meta.env.VITE_APP_BASE_API + '/' + path |
| | | axios.get( url,{ |
| | | headers: |
| | | { |
| | | 'Content-Type': 'application/json', |
| | | 'Authorization':getToken(), |
| | | }, |
| | | responseType: 'blob' |
| | | } |
| | | ).then(res=>{ |
| | | if (res) { |
| | | const link = document.createElement('a') |
| | | let blob = new Blob([res.data],{type: res.data.type}) |
| | | link.style.display = "none"; |
| | | link.href = URL.createObjectURL(blob); // 创建URL |
| | | link.setAttribute("download", file.name); |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | } else { |
| | | this.$message.error('获取文件失败') |
| | | } |
| | | }) |
| | | } |
| | | const getProcessFiles = async (id)=>{ |
| | | const res = await getFiles({projectId: id ? id : prop.projectId ,moduleType: 7}) |
| | | if(res.code == 200){ |
| | | if(res.data && res.data.length>0){ |
| | | state.fileList = res.data.map(i=>{ |
| | | return { |
| | | name: i.originName, |
| | | url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, |
| | | id: i.id, |
| | | projectId: i.projectId, |
| | | moduleType: i.moduleType |
| | | } |
| | | }) |
| | | }else{ |
| | | state.fileList = [] |
| | | } |
| | | }else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const handleRemove = async (file, uploadFiles) => { |
| | | if (file && file.status === 'success') { |
| | | ElMessageBox.confirm( |
| | | '确定删除该附件?', |
| | | '提示', |
| | | { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(async () => { |
| | | let accessoryFileId = ""; |
| | | if (file.id) { |
| | | accessoryFileId = file.id |
| | | } else { |
| | | accessoryFileId = file.response.data.id |
| | | } |
| | | const res = await delAccessoryFile(accessoryFileId) |
| | | if (res.code == 200) { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '文件已删除' |
| | | }) |
| | | await getProcessFiles() |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | getProcessFiles() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | defineExpose({ |