import{_ as U,d as j,w as u,bH as w,aO as D,r as f,o as k,c as V,l as _,C as d,b as c,F as R,aY as i,aa as y,bI as S,bJ as q,Q as H,R as P}from"./index.1d1a5ecb.js";const v=o=>(H("data-v-55909fd4"),o=o(),P(),o),A=v(()=>c("div",{class:"add-icon"},"+",-1)),L=v(()=>c("div",{class:"el-upload__tip"},"\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247",-1)),M=["src"],N=j({__name:"index",props:{multiple:{type:Boolean,required:!1}},emits:["change"],setup(o,{emit:m}){const F=["image/png","image/jpg","image/bmp","image/jpeg"],n=u([]),s=u([]);w();const h=D(),g=u(""),r=u(!1),I=({type:a,size:e})=>{if(!F.includes(a))return i.error("\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247"),!1;if(e/1024/1024>1)return i.error("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC71M"),!1},b=async({file:a})=>{const e=new FormData,l=y();e.append("img",a),e.append("token",l);const{message:p,code:t,data:x}=await S(e);h({message:p,code:t,handler:()=>{s.value.push(q+"/"+x[0].url),m("change",s.value.join(","))}})},B=()=>{i.error("\u56DE\u6267\u56FE\u7247\u4E0D\u80FD\u8D85\u8FC7\u5341\u5F20")},C=a=>{g.value=a.url,r.value=!0},E=a=>{const e=n.value.findIndex(({uid:l})=>l===a.uid);return s.value.splice(e,1),m("change",s.value.join(","),s),!0};return(a,e)=>{const l=f("el-upload"),p=f("el-dialog");return k(),V(R,null,[_(l,{"file-list":n.value,"onUpdate:fileList":e[0]||(e[0]=t=>n.value=t),"before-upload":I,"http-request":b,"before-remove":E,"on-preview":C,"on-exceed":B,limit:10,"list-type":"picture-card",multiple:o.multiple},{tip:d(()=>[L]),default:d(()=>[A]),_:1},8,["file-list","multiple"]),_(p,{modelValue:r.value,"onUpdate:modelValue":e[1]||(e[1]=t=>r.value=t),"close-on-click-modal":!1},{default:d(()=>[c("img",{"w-full":"",src:g.value,alt:"Preview Image"},null,8,M)]),_:1},8,["modelValue"])],64)}}});var O=U(N,[["__scopeId","data-v-55909fd4"],["__file","C:/Users/63107/Desktop/projects/accout-vue3-ui/src/components/ImageUpload/src/index.vue"]]);export{O as I};
