import{_ as C,d as U,E as u,bE as j,aI as D,x as _,o as S,c as V,y as f,K as p,b as c,L as k,aS as i,bF as y,bG as R,$ as q,a0 as P}from"./index.743f0c80.js";const v=o=>(q("data-v-55909fd4"),o=o(),P(),o),A=v(()=>c("div",{class:"add-icon"},"+",-1)),H=v(()=>c("div",{class:"el-upload__tip"},"\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247",-1)),L=["src"],M=U({__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([]),h=j(),I=D(),g=u(""),r=u(!1),E=({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;e.append("img",a),e.append("token",h.token);const{message:t,code:d,data:l}=await y(e);I({message:t,code:d,handler:()=>{s.value.push(R+"/"+l[0].url),m("change",s.value.join(","))}})},x=()=>{i.error("\u56DE\u6267\u56FE\u7247\u4E0D\u80FD\u8D85\u8FC7\u5341\u5F20")},B=a=>{g.value=a.url,r.value=!0},w=a=>{const e=n.value.findIndex(({uid:t})=>t===a.uid);return s.value.splice(e,1),m("change",s.value.join(","),s),!0};return(a,e)=>{const t=_("el-upload"),d=_("el-dialog");return S(),V(k,null,[f(t,{"file-list":n.value,"onUpdate:file-list":e[0]||(e[0]=l=>n.value=l),"before-upload":E,"http-request":b,"before-remove":w,"on-preview":B,"on-exceed":x,limit:10,"list-type":"picture-card",multiple:o.multiple},{tip:p(()=>[H]),default:p(()=>[A]),_:1},8,["file-list","multiple"]),f(d,{modelValue:r.value,"onUpdate:modelValue":e[1]||(e[1]=l=>r.value=l)},{default:p(()=>[c("img",{"w-full":"",src:g.value,alt:"Preview Image"},null,8,L)]),_:1},8,["modelValue"])],64)}}});var G=C(M,[["__scopeId","data-v-55909fd4"],["__file","D:/work/accout-vue3-ui/src/components/ImageUpload/src/index.vue"]]);export{G as I};