1 |
- import{_ as j,d as U,E as u,bh as w,aC as D,x as _,o as y,c as S,y as f,K as d,b as c,L as V,aS as i,bi as k,bj as P,$ as R,a0 as q}from"./index.1417328f.js";const v=o=>(R("data-v-55909fd4"),o=o(),q(),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 h=["image/png","image/jpg","image/bmp","image/jpeg"],n=u([]),s=u([]),F=w(),I=D(),g=u(""),p=u(!1),E=({type:a,size:e})=>{if(!h.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",F.token);const{message:t,code:r,data:l}=await k(e);I({message:t,code:r,handler:()=>{s.value.push(P+"/"+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,p.value=!0},C=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"),r=_("el-dialog");return y(),S(V,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":C,"on-preview":B,"on-exceed":x,limit:10,"list-type":"picture-card",multiple:o.multiple},{tip:d(()=>[H]),default:d(()=>[A]),_:1},8,["file-list","multiple"]),f(r,{modelValue:p.value,"onUpdate:modelValue":e[1]||(e[1]=l=>p.value=l)},{default:d(()=>[c("img",{"w-full":"",src:g.value,alt:"Preview Image"},null,8,L)]),_:1},8,["modelValue"])],64)}}});var K=j(M,[["__scopeId","data-v-55909fd4"],["__file","/Users/apple/Desktop/Company Projects/accout-vue3-ui/src/components/ImageUpload/src/index.vue"]]);export{K as I};
|