| | |
| | | placeholder="请选择年份" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="文件名称:" prop="inconsistentName"> |
| | | <el-form-item label="不符合项内容:" prop="inconsistentName"> |
| | | <el-input v-model.trim="state.form.inconsistentName" :disabled="state.title =='查看'" placeholder="文件名称"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="文件:" prop="filePath"> |
| | | <el-upload accept=".doc,.docx,.pdf,.jpg" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" :on-exceed="showTip" :limit='state.fileLimit' v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles)" > |
| | | <el-button type="primary">点击上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip">支持上传.doc、.docx、.pdf、.jpg格式,尺寸小于5M,最多可上传1份</div> |
| | | <div class="el-upload__tip">支持上传.doc、.docx、.pdf、.jpg格式,尺寸小于5M,最多可上传10份</div> |
| | | </template> |
| | | </el-upload> |
| | | </el-form-item> |
| | |
| | | id: null, |
| | | year: '', |
| | | inconsistentName: '', |
| | | filePath: '', |
| | | filePath: [], |
| | | format: '', |
| | | companyId: null |
| | | }, |
| | |
| | | header: { |
| | | Authorization: getToken() |
| | | }, |
| | | fileLimit: 1, |
| | | fileLimit: 10, |
| | | fileList: [] |
| | | }) |
| | | onMounted(() => { |
| | |
| | | state.form[key] = value[key] |
| | | } |
| | | }) |
| | | if(value.filePath) { |
| | | const obj = { |
| | | url: value.filePath, |
| | | name: '模板文件' |
| | | } |
| | | state.fileList = [obj] |
| | | if(!value.filePath || value.filePath == ''){ |
| | | state.form.filePath = [] |
| | | }else{ |
| | | const certificatePaths = value.filePath.split(',') |
| | | state.form.filePath = certificatePaths |
| | | state.fileList = certificatePaths.map((path, index) => { |
| | | const fileName = path.split('/').pop() || `文件${index + 1}` |
| | | return { |
| | | name: fileName, |
| | | url: path, |
| | | response: { |
| | | data: { |
| | | path: path, |
| | | fileName: fileName |
| | | } |
| | | }, |
| | | status: 'success', |
| | | uid: Date.now() + index |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | dialogVisible.value = true |
| | |
| | | if(valid){ |
| | | if(state.title == '新增'){ |
| | | const {id,...data} = state.form |
| | | data.filePath = state.fileList |
| | | .filter(file => file.response?.data?.path) |
| | | .map(file => file.response.data.path).join(',') |
| | | const res = await addSelectInconsistent(data) |
| | | if(res.code == 200){ |
| | | ElMessage.success(res.message) |
| | |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }else{ |
| | | const res = await updateSelectInconsistent(state.form) |
| | | const data = JSON.parse(JSON.stringify(state.form)) |
| | | data.filePath = state.fileList |
| | | .filter(file => file.response?.data?.path) |
| | | .map(file => file.response.data.path).join(',') |
| | | const res = await updateSelectInconsistent(data) |
| | | if(res.code == 200){ |
| | | ElMessage.success(res.message) |
| | | emit('getList') |
| | |
| | | } |
| | | } |
| | | |
| | | const handleAvatarSuccess = (res, uploadFile) => { |
| | | if(res.code == 200){ |
| | | state.form.filePath = res.data.path |
| | | state.form.format = '.' + res.data.filename.split('.')[1] |
| | | }else{ |
| | | state.fileList = [] |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '文件上传失败' |
| | | }) |
| | | const handleAvatarSuccess = (response, uploadFile) => { |
| | | if(response.code === 200){ |
| | | // 设置文件显示名称 |
| | | uploadFile.name = response.data.fileName || `文件${state.fileList.length}` |
| | | uploadFile.url = response.data.url || response.data.path |
| | | ElMessage.success('文件上传成功') |
| | | } else { |
| | | const index = state.fileList.findIndex(file => file.uid === uploadFile.uid) |
| | | if (index > -1) { |
| | | state.fileList.splice(index, 1) |
| | | } |
| | | ElMessage.error(response.message || '文件上传失败') |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | }; |
| | | const handleRemove = async (file, uploadFiles) => { |
| | | let path = state.form.filePath; |
| | | await delPic({path: path}).then(res => { |
| | | if(res.code == 200){ |
| | | // ElMessage({ |
| | | // type: 'success', |
| | | // message: '文件已删除' |
| | | // }) |
| | | state.form.filePath = '' |
| | | state.form.format = '' |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.message |
| | | }) |
| | | try { |
| | | if (file.response?.data?.path) { |
| | | await delPic({ path: file.response.data.path }) |
| | | ElMessage.success('文件删除成功') |
| | | } |
| | | }).catch(() => { |
| | | state.form.imgUrl = '' |
| | | }); |
| | | } catch (error) { |
| | | ElMessage.error('文件删除失败') |
| | | } |
| | | } |
| | | |
| | | const handleClose = () => { |
| | |
| | | id: null, |
| | | year: '', |
| | | inconsistentName: '', |
| | | filePath: '', |
| | | filePath: [], |
| | | format: '', |
| | | companyId: null |
| | | } |