import{d as e,aj as l,A as a,B as i,C as s,s as t,r as d,a as u,b as o,h as p,e as n,w as r,k as c,v as f,l as m,p as v,f as g,ai as y,L as b,c as h,I as w,_}from"./index-d052b22f-1780912037814v=1.0.0.js";import{a as k}from"./upload-f9f23203-1780912037814v=1.0.0.js";const L={class:"upload-box"},x={class:"upload-empty"},C=["src"],z=["onClick"],j=["onClick"],I={class:"el-upload__tip"},S=e({name:"UploadImgs"}),U=_(e({...S,props:{fileList:{default:()=>[]},api:{},drag:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},limit:{default:5},fileSize:{default:5},fileType:{default:()=>["image/jpeg","image/png","image/gif"]},height:{default:"150px"},width:{default:"150px"},borderRadius:{default:"8px"}},emits:["update:fileList","uploadFile"],setup(e,{emit:_}){l((e=>({"17a0b2c2":e.borderRadius,"4765aa25":e.width,e8febeb0:e.height})));const S=e,U=a(i,void 0),$=a(s,void 0),P=t((()=>S.disabled||(null==U?void 0:U.disabled))),B=t({set(e){D("update:fileList",e)},get:()=>S.fileList}),F=e=>{const l=e.size/1024/1024<S.fileSize,a=S.fileType;return a.includes(e.type)||w({title:"温馨提示",message:"上传图片不符合所需的格式！",type:"warning"}),l||w({title:"温馨提示",message:`上传图片大小不能超过 ${S.fileSize}M！`,type:"warning"}),a.includes(e.type)&&l},T=async e=>{var l;let a=new FormData;a.append("image",e.file),a.append("size",`${S.fileSize}`);try{const i=null!=(l=S.api)?l:k,{data:s}=await i(a),t={fileUrl:s.imgUrl,imgPath:s.imgPath};e.onSuccess(t)}catch(i){e.onError(i)}},D=_,R=(e,l)=>{e&&(l.url=e.fileUrl,l.imgPath=e.imgPath,D("update:fileList",B.value),(null==$?void 0:$.prop)&&(null==U||U.validateField([$.prop])),w({title:"温馨提示",message:"图片上传成功！",type:"success"}))},q=()=>{w({title:"温馨提示",message:"图片上传失败，请您重新上传！",type:"error"})},A=()=>{w({title:"温馨提示",message:`当前最多只能上传 ${S.limit} 张图片，请移除后上传！`,type:"warning"})},E=d(""),M=d(!1);return(e,l)=>{const a=u("el-icon"),i=u("ZoomIn"),s=u("Delete"),t=u("el-upload"),d=u("el-image-viewer");return o(),p("div",L,[n(t,{action:"#","list-type":"picture-card",class:b(["upload",P.value?"disabled":"",e.drag?"no-border":""]),"file-list":B.value,"onUpdate:fileList":l[1]||(l[1]=e=>B.value=e),multiple:!0,disabled:P.value,limit:e.limit,"http-request":T,"before-upload":F,"on-exceed":A,"on-success":R,"on-error":q,drag:e.drag,accept:e.fileType.join(","),teleported:!0},{file:r((({file:e})=>[c("img",{src:e.url,class:"upload-image"},null,8,C),c("div",{class:"upload-handle",onClick:l[0]||(l[0]=f((()=>{}),["stop"]))},[c("div",{class:"handle-icon",onClick:l=>{return a=e,E.value=a.url,void(M.value=!0);var a}},[n(a,null,{default:r((()=>[n(i)])),_:1}),l[3]||(l[3]=c("span",null,"查看",-1))],8,z),P.value?m("v-if",!0):(o(),p("div",{key:0,class:"handle-icon",onClick:l=>(e=>{let l=B.value.filter((l=>l.url!==e.url||l.name!==e.name));D("update:fileList",l)})(e)},[n(a,null,{default:r((()=>[n(s)])),_:1}),l[4]||(l[4]=c("span",null,"删除",-1))],8,j))])])),default:r((()=>[c("div",x,[v(e.$slots,"empty",{},(()=>[n(a,null,{default:r((()=>[n(g(y))])),_:1})]),!0)])])),_:3},8,["class","file-list","disabled","limit","drag","accept"]),c("div",I,[v(e.$slots,"tip",{},void 0,!0)]),M.value?(o(),h(d,{key:0,onClose:l[2]||(l[2]=e=>M.value=!1),"url-list":[E.value]},null,8,["url-list"])):m("v-if",!0)])}}}),[["__scopeId","data-v-ca8210b6"]]);export{U as I};
