| | |
| | | <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="6"> |
| | | <el-button type="primary" @click="addUpload">新增附件</el-button> |
| | | <el-col :span="10"> |
| | | <el-button type="primary" :disabled="projectType === 'edit'" @click="addUpload">新增附件列表</el-button> |
| | | <span style="font-size: 13px;color: rgb(232, 78, 79);font-weight: 400;margin-left: 10px">项目列表仅支持pdf、jpg、jpeg 等格式上传</span> |
| | | </el-col> |
| | | </el-row> |
| | | <el-table :data="state.uploadList" :border="true" style="margin: 20px 0"> |
| | | <el-table-column label="序号" width="60" align="center" type="index"></el-table-column> |
| | | <el-table-column label="名称" header-align="center" class-name="small-padding fixed-width"> |
| | | <el-table-column label="名称" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.fileName" maxlength="30" show-word-limit type="text" size="large"/> |
| | | <el-input v-model="scope.row.name" show-word-limit type="text" size="large"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="是否必须文件" header-align="center" class-name="small-padding fixed-width"> |
| | | <el-table-column label="是否必须文件" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-radio-group v-model="state.formData.status" > |
| | | <el-radio-group v-model="scope.row.type" > |
| | | <el-radio :label="1">是</el-radio> |
| | | <el-radio :label="0">否</el-radio> |
| | | </el-radio-group> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="原因说明" header-align="center" class-name="small-padding fixed-width"> |
| | | <el-table-column label="原因说明" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.deviceName" maxlength="50" show-word-limit type="text" size="large"/> |
| | | <el-input v-model="scope.row.remark" show-word-limit type="text" size="large"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="附件上传" header-align="center" class-name="small-padding fixed-width"> |
| | | <el-table-column label="附件上传" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-upload accept="image/*,.pdf" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="handleAvatarSuccess" :on-exceed="showTip" :limit='1' v-model:file-list="state.fileList[scope.$index]" :before-upload="picSize" :on-remove="handleRemove" :before-remove="beforeRemove"> |
| | | <el-upload accept=".pdf,.doc,.docx" |
| | | :action="state.uploadUrl" |
| | | :disabled="state.disabled" |
| | | :headers="state.header" |
| | | method="post" |
| | | :on-success="handleAvatarSuccess" |
| | | v-model:file-list="scope.row.fileList" |
| | | :on-remove="handleRemove" |
| | | :data="state.uploadData" |
| | | :on-preview="handlePreview" |
| | | > |
| | | <el-button type="primary">附件上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">上传图片或pdf尺寸小于5M,最多可上传1张</div> |
| | | </template> |
| | | </el-upload> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" header-align="center" class-name="small-padding fixed-width"> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="danger" @click="delUpload(scope.$index)">删除</el-button> |
| | | </template> |
| | |
| | | 项目合同额<span style="font-size: 13px;color: red;font-weight: normal;display: inline-block;margin-left: 6px">预估合同金额,归档阶段可以进行修改。仅支持数字,单位万元,小数点后最多两位,数值范围(0.01-999.99)</span> |
| | | </template> |
| | | <el-input |
| | | v-model="state.formData.contractMoney" |
| | | v-model="state.actualContract.actualContractMoney" |
| | | size="large" |
| | | type="number" |
| | | placeholder="请输入项目合同额" |
| | |
| | | </el-row> |
| | | <el-form-item label="实际合同额说明"> |
| | | <el-input |
| | | v-model="state.formData.contractIntroduction" |
| | | v-model="state.actualContract.actualContractIntroduction" |
| | | :autosize="{ minRows: 6 }" |
| | | maxlength="100" |
| | | show-word-limit |
| | |
| | | import {addRecord, editRecord, getDetail} from "@/api/projectManage/contractMng"; |
| | | import Cookies from "js-cookie"; |
| | | import { getToken } from "@/utils/auth"; |
| | | import axios from "axios"; |
| | | import {delAccessoryFile, getAccessoryFile} from "@/api/projectManage/project"; |
| | | import {addProcessMaterial, getProcessMaterialDetail, editProcessMaterial} from "@/api/projectManage/riskAnalysis"; |
| | | |
| | | const emit = defineEmits(["getNextStatus"]); |
| | | const state = reactive({ |
| | | formData: { |
| | | id: '', |
| | | contractSignDate: '', |
| | | contractMoney: '', |
| | | contractIntroduction: '' |
| | | |
| | | }, |
| | | uploadList: [], |
| | | actualContract: { |
| | | actualContractMoney: '', |
| | | actualContractIntroduction: '' |
| | | }, |
| | | uploadList: [ |
| | | { |
| | | name: '安全评价过程控制记录文档', |
| | | type: 1, |
| | | remark: '', |
| | | }, |
| | | { |
| | | name: '项目发票电子版', |
| | | type: 1, |
| | | remark: '', |
| | | }, |
| | | { |
| | | name: '项目转账记录/入账证明', |
| | | type: 1, |
| | | remark: '', |
| | | } |
| | | ], |
| | | rules: { |
| | | contractSignDate: [{required: true, message: '请选择合同签订日期', trigger: 'blur'}], |
| | | contractMoney: [{required: true, message: '请输入项目合同额', trigger: 'blur'}] |
| | | actualContractMoney: [{required: true, message: '请输入项目合同额', trigger: 'blur'}] |
| | | }, |
| | | fileList: [], |
| | | 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() |
| | | }, |
| | | uploadData: { |
| | | moduleType: 9 |
| | | }, |
| | | }) |
| | | |
| | | const isAmin = ref(false) |
| | | const formRef = ref(); |
| | | onMounted(() => { |
| | | onMounted(async () => { |
| | | |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | if(userInfo.identity === 0){ |
| | | isAmin.value = true; |
| | | } |
| | | if(Cookies.get('projectId')){ |
| | | state.uploadData.projectId = Cookies.get('projectId'); |
| | | getRecord(state.uploadData.projectId); |
| | | // const res = await getAccessoryFile({projectId: val,moduleType: 9}); |
| | | // console.log('res',res) |
| | | } |
| | | |
| | | }); |
| | | |
| | | const getRecord = async (val) =>{ |
| | | const res = await getDetail({projectId: val}); |
| | | if(res.code == 200){ |
| | | state.formData = res.data; |
| | | state.actualContract.actualContractMoney = res.data.actualContractMoney; |
| | | state.actualContract.actualContractIntroduction = res.data.actualContractIntroduction; |
| | | }else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const projectType = ref('') |
| | | const riskOpen = async (type,val) => { |
| | | state.formData.projectId = val; |
| | | projectType.value = type; |
| | | state.uploadData.projectId = val; |
| | | if(type === 'detail' || type === 'edit' ){ |
| | | const res = await getDetail({projectId: val}); |
| | | const res = await getProcessMaterialDetail({projectId: val}); |
| | | if(res.code == 200){ |
| | | state.formData = res.data; |
| | | state.uploadList = res.data; |
| | | state.uploadList.forEach((item,index) => { |
| | | if(item.accessoryFile){ |
| | | item.accessoryFile.name = item.accessoryFile.originName |
| | | state.uploadList[index].fileList = [item.accessoryFile]; |
| | | } |
| | | }) |
| | | |
| | | console.log("res",state.uploadList) |
| | | }else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | getRecord(val); |
| | | } |
| | | if(type === 'add' || type === 'clickEdit') { |
| | | const valid = await formRef.value.validate(); |
| | |
| | | ElMessage.warning("当前用户暂无权限"); |
| | | return; |
| | | } |
| | | console.log(state.uploadList,'state.uploadList') |
| | | const file = state.uploadList.map(item => { |
| | | return{ |
| | | id: item.id ? item.id : null, |
| | | fileId: item.fileList ? item.fileList[0].response ? item.fileList[0].response.data.id : item.fileList[0].id : '', |
| | | name: item.name, |
| | | type: item.type, |
| | | remark: item.remark, |
| | | projectId: val |
| | | } |
| | | }) |
| | | const { ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | data.actualContractMoney = state.actualContract.actualContractMoney; |
| | | data.actualContractIntroduction = state.actualContract.actualContractIntroduction; |
| | | const params = { |
| | | projectId: val, |
| | | projectMaterials: file, |
| | | contract: data |
| | | } |
| | | console.log("params",params) |
| | | if(type === 'add'){ |
| | | const {id, ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | const res = await addRecord(data); |
| | | const res = await addProcessMaterial(params); |
| | | if (res.code == 200) { |
| | | ElMessage.success('保存成功') |
| | | formRef.value.clearValidate(); |
| | | emit('getNextStatus', state.formData.projectId); |
| | | emit('getNextStatus', val); |
| | | } else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }else if(type === 'clickEdit'){ |
| | | const { ...data} = JSON.parse(JSON.stringify(state.formData)) |
| | | const res = await editRecord(data); |
| | | const res = await editProcessMaterial(params); |
| | | if (res.code == 200) { |
| | | ElMessage.success('变更成功') |
| | | formRef.value.clearValidate(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | const addUpload = ()=>{ |
| | | let file = { |
| | | fileName: '', |
| | | deviceName: '', |
| | | startDate: '', |
| | | endDate: '' |
| | | name: '', |
| | | type: 1, |
| | | remark: '', |
| | | } |
| | | state.uploadList.push(file) |
| | | } |
| | |
| | | }; |
| | | |
| | | const handleAvatarSuccess = (res, uploadFile) => { |
| | | if(res.code == 200){ |
| | | // state.registerForm.agency.reportPath = res.data.path |
| | | }else{ |
| | | if(res.code === 200){ |
| | | console.log("if",state.uploadList) |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '文件上传成功' |
| | | }) |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '文件上传失败' |
| | | 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 handleRemove = async (file, uploadFiles) => { |
| | | const res = await delPic({path: state.registerForm.agency.reportPath}) |
| | | console.log("file",file) |
| | | 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', |