| | |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-form> |
| | | <el-upload |
| | | style="margin-top: 25px;width: 250px" |
| | | :disabled="projectType === 'view' || isEnd" |
| | | accept=".pdf" |
| | | :action="state.uploadUrl" |
| | | :data="{moduleType: 12,projectId: props.projectId}" |
| | | :headers="state.header" |
| | | method="post" |
| | | :limit="state.imgLimit" |
| | | :before-upload="beforeUpload" |
| | | :on-success="handleAvatarSuccess" |
| | | v-model:file-list="state.fileList" |
| | | :on-preview="handlePreview" |
| | | :on-remove="handleRemove"> |
| | | <el-button type="primary">上传从业告知书pdf</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">只能上传pdf类型,最多上传1份</div> |
| | | </template> |
| | | </el-upload> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | |
| | | import {defineEmits, defineProps, onMounted, reactive, ref, watchEffect} from "vue" |
| | | import {ElMessage} from "element-plus" |
| | | import {ElMessage, ElMessageBox} from "element-plus" |
| | | import {Search} from '@element-plus/icons-vue' |
| | | import {addWorkRecord, editWorkRecord, getWorkDetail} from "@/api/projectManage/employNoticeRcd" |
| | | import {getWorks, editWorks} from "@/api/projectManage/evaPlan" |
| | |
| | | const props = defineProps(['projectId']) |
| | | const emit = defineEmits(["getNextStatus"]) |
| | | import { useRoute } from 'vue-router' |
| | | import {getToken} from "@/utils/auth"; |
| | | import {getFiles} from "@/api/projectManage/siteCheckRcd"; |
| | | import {delAccessoryFile} from "@/api/projectManage/project"; |
| | | import axios from "axios"; |
| | | const route = useRoute() |
| | | const state = reactive({ |
| | | formData: { |
| | |
| | | rules: { |
| | | timeRange: [{required: true, message: '请选择技术服务期限', trigger: 'blur'}], |
| | | investigationPlanDate: [{required: true, message: '请选择计划现场勘验时间', trigger: 'blur'}] |
| | | } |
| | | }, |
| | | imgLimit: 1, |
| | | uploadUrl: import.meta.env.VITE_APP_BASE_API + '/manage/accessory-file/uploadFile', |
| | | header: { |
| | | Authorization: getToken() |
| | | }, |
| | | fileList: [] |
| | | }) |
| | | |
| | | const isEnd = ref('') |
| | | const isAmin = ref(false) |
| | | const formRef = ref() |
| | | onMounted(() => { |
| | |
| | | } |
| | | if(props.projectId){ |
| | | getWorksList(props.projectId) |
| | | getProcessFiles(props.projectId); |
| | | } |
| | | isEnd.value = Cookies.get('end') |
| | | |
| | | }); |
| | | |
| | |
| | | state.formData.projectId = val |
| | | state.projectId = val |
| | | projectType.value = route.query.type; |
| | | isEnd.value = Cookies.get('end') |
| | | // await getWorksList(val) |
| | | if(type === 'detail' || type === 'edit' ){ |
| | | const res = await getWorkDetail({projectId: val}) |
| | | if(res.code == 200){ |
| | | state.formData = JSON.parse(JSON.stringify(res.data)) |
| | | state.formData.timeRange = [state.formData.serviceStartDate,state.formData.serviceEndDate] |
| | | // state.fileList = res.data.accessoryFiles.map(item => { |
| | | // return { |
| | | // ...item, |
| | | // name: item.originName, |
| | | // } |
| | | // }) |
| | | }else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | |
| | | } |
| | | await getWorksList(props.projectId) |
| | | } |
| | | const beforeUpload = (file) => { |
| | | let fileType = file.name.substring(file.name.lastIndexOf(".") + 1); |
| | | if (fileType === 'pdf') { |
| | | } else { |
| | | ElMessage.error("文件类型必须为pdf格式") |
| | | return false |
| | | } |
| | | } |
| | | const handleAvatarSuccess = (res) => { |
| | | if(res.code === 200){ |
| | | getProcessFiles() |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '文件上传成功' |
| | | }) |
| | | }else { |
| | | state.fileList.splice(state.fileList.indexOf(uploadFile),1) |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: 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() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | const getProcessFiles = async (id)=>{ |
| | | const res = await getFiles({projectId: id ? id : props.projectId ,moduleType: 12}) |
| | | 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 handlePreview = (file) => { |
| | | const url = file.url |
| | | window.open(url) |
| | | } |
| | | defineExpose({ |
| | | riskOpen |
| | | }); |