From 7132270dbcb01808e205e108ad6bb87270dbe4b8 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期三, 05 二月 2025 13:42:43 +0800 Subject: [PATCH] 资质证书上传修改 --- src/layout/components/Register/index.vue | 41 ++++++++++++++++++++++++++++++++--------- 1 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/layout/components/Register/index.vue b/src/layout/components/Register/index.vue index afdc9b3..b386538 100644 --- a/src/layout/components/Register/index.vue +++ b/src/layout/components/Register/index.vue @@ -138,12 +138,12 @@ </el-col> </el-row> <el-row :gutter="30"> - <el-col :span="8"> + <el-col :span="12"> <el-form-item prop="agency.certPath" label="资质证书"> <el-upload accept="image/*" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,'证书')" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='state.imgLimit' v-model:file-list="state.certList" list-type="picture-card" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,'证书')" > <el-icon><Plus /></el-icon> <template #tip> - <div class="el-upload__tip">上传jpg/png图片尺寸小于5M,最多可上传1张</div> + <div class="el-upload__tip">上传jpg/png图片尺寸小于5M,最多可上传5张</div> </template> </el-upload> </el-form-item> @@ -334,7 +334,7 @@ busList: [], fileList: [], certList: [], - imgLimit: 1, + imgLimit: 5, uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile', header: { Authorization: 'Bearer ' + getToken() @@ -502,6 +502,7 @@ { required: true, validator: equalToPassword, trigger: "blur" } ] }; +const cert = ref([]) const loading = ref(false) const dialogVisible = ref(false) @@ -559,7 +560,18 @@ state.fileList = imgUrl ? imgUrl.split(',').map(url => {return {url} }) : [] } if(res.data.certPath) { - const imgUrl = import.meta.env.VITE_APP_BASE_API + "/" + res.data.certPath + // cert.value.push(res.data.certPath) + const imgList = res.data.certPath.split(',') + cert.value = imgList + imgList.forEach((item,index) => { + if(item.includes(import.meta.env.VITE_APP_BASE_API)){ + + }else{ + imgList[index] = import.meta.env.VITE_APP_BASE_API + "/" + item + } + + }) + const imgUrl = imgList.join(',') state.certList = imgUrl ? imgUrl.split(',').map(url => {return {url} }) : [] } @@ -652,7 +664,9 @@ if(type === '上报表'){ state.registerForm.agency.reportPath = res.data.path }else { - state.registerForm.agency.certPath = res.data.path + cert.value.push(res.data.path) + state.registerForm.agency.certPath = cert.value.join(',') + console.log('cert',cert.value) } }else{ @@ -665,13 +679,15 @@ const handleRemove = async (file, uploadFiles,type) => { if(file && file.status == 'success'){ - - let path = ''; if(type === '上报表'){ path = state.registerForm.agency.reportPath; }else { - path = state.registerForm.agency.certPath; + path = file.url.substring(file.url.indexOf('upload')) + console.log('cert',cert.value) + cert.value = cert.value.filter(url => !file.url.includes(url)) + state.registerForm.agency.certPath = cert.value.join(',') + } const res = await delPic({path: path}) if(res.code == 200){ @@ -680,6 +696,7 @@ message: '文件已删除' }) }else{ + ElMessage({ type: 'warning', message: res.message @@ -696,6 +713,8 @@ const {confirmPassword,id, ...data} = JSON.parse(JSON.stringify(state.registerForm)) data.password = Base64.encode(data.password) data.agency.business = data.agency.business.join(',') + const cert = state.certList.map(item => item.response ?item.response.data.path:item.url) + data.agency.certPath = cert.join(',') delete data.agency.area delete data.agency.id register(data).then(res => { @@ -729,11 +748,14 @@ const {confirmPassword, ...data} = JSON.parse(JSON.stringify(state.registerForm)) data.password = Base64.encode(data.password) data.agency.business = data.agency.business.join(',') + console.log('rea',state.certList) + const cert = state.certList.map(item => item.response ?item.response.data.path:item.url) + data.agency.certPath = cert.join(',') if(isReject.value) { data.state = 1; } // delete data.agency.area - console.log('data',data) + // console.log('data',data) editAgency(data).then(res => { if(res.code == 200){ ElMessage({ @@ -769,6 +791,7 @@ proxy.$refs.registerRef.clearValidate() state.fileList = [] state.certList = [] + cert.value = [] } defineExpose({ -- Gitblit v1.9.2