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