import{d as q,aq as R,l as E,N as b,ar as T,as as j,r as D,a as c,o as h,c as C,b as l,e as p,f as s,at as M,h as w,M as k,u as K,au as Z,p as H,i as G,a6 as f,_ as J}from"./index-8184dd63-1780045603901v=1.0.0.js";import{u as O}from"./upload-cfe11744-1780045603901v=1.0.0.js";const Q={class:"upload-box"},W={class:"upload-empty"},X=["src"],Y=["onClick"],ee=["onClick"],te={class:"el-upload__tip"},ue=q({name:"UploadImgs"}),ae=q({...ue,props:{fileList:{type:Array,required:!0,default:()=>[]},api:{type:Function,required:!1},drag:{type:Boolean,required:!1,default:!0},disabled:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:5},fileSize:{type:Number,required:!1,default:5},fileType:{type:Array,required:!1,default:()=>["image/jpeg","image/png","image/gif"]},height:{type:String,required:!1,default:"150px"},width:{type:String,required:!1,default:"150px"},borderRadius:{type:String,required:!1,default:"8px"}},emits:["update:fileList"],setup(n,{emit:B}){R(e=>({"ef94ac01-uploadStyle":S.value,"ef94ac01-borderRadius":e.borderRadius,"ef94ac01-width":e.width,"ef94ac01-height":e.height}));const a=n,S=E(()=>a.limit==1&&r.value.length==1?"none":"block"),i=b(T,void 0),m=b(j,void 0),v=E(()=>a.disabled||(i==null?void 0:i.disabled)),r=E({set(e){y("update:fileList",e)},get(){return a.fileList}}),I=e=>{const t=e.size/1024/1024<a.fileSize,u=a.fileType;return u.includes(e.type)||f({title:"\u6E29\u99A8\u63D0\u793A",message:"\u4E0A\u4F20\u56FE\u7247\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01",type:"warning"}),t||f({title:"\u6E29\u99A8\u63D0\u793A",message:`\u4E0A\u4F20\u56FE\u7247\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${a.fileSize}M\uFF01`,type:"warning"}),u.includes(e.type)&&t},U=async e=>{var u;let t=new FormData;t.append("image",e.file);try{const d=(u=a.api)!=null?u:O,{data:g}=await d(t),_={fileUrl:g.imgUrl,imgPath:g.imgPath};e.onSuccess(_)}catch(d){e.onError(d)}},y=B,L=(e,t)=>{!e||(t.url=e.fileUrl,t.imgPath=e.imgPath,y("update:fileList",r.value),m!=null&&m.prop&&(i==null||i.validateField([m.prop])),f({title:"\u6E29\u99A8\u63D0\u793A",message:"\u56FE\u7247\u4E0A\u4F20\u6210\u529F\uFF01",type:"success"}))},N=e=>{let t=r.value.filter(u=>u.url!==e.url||u.name!==e.name);y("update:fileList",t)},$=()=>{f({title:"\u6E29\u99A8\u63D0\u793A",message:"\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01",type:"error"})},z=()=>{f({title:"\u6E29\u99A8\u63D0\u793A",message:`\u5F53\u524D\u6700\u591A\u53EA\u80FD\u4E0A\u4F20 ${a.limit} \u5F20\u56FE\u7247\uFF0C\u8BF7\u79FB\u9664\u540E\u4E0A\u4F20\uFF01`,type:"warning"})},A=D(""),F=D(!1),P=e=>{A.value=e.url,F.value=!0};return(e,t)=>{const u=c("el-icon"),d=c("ZoomIn"),g=c("Delete"),_=c("el-upload"),V=c("el-image-viewer");return h(),C("div",Q,[l(_,{action:"#","list-type":"picture-card",class:H(["upload",v.value?"disabled":"",n.drag?"no-border":""]),"file-list":r.value,"onUpdate:fileList":t[1]||(t[1]=o=>r.value=o),multiple:!0,disabled:v.value,limit:n.limit,"http-request":U,"before-upload":I,"on-exceed":z,"on-success":L,"on-error":$,drag:n.drag,accept:n.fileType.join(","),teleported:!0},{file:p(({file:o})=>[s("img",{src:o.url,class:"upload-image"},null,8,X),s("div",{class:"upload-handle",onClick:t[0]||(t[0]=M(()=>{},["stop"]))},[s("div",{class:"handle-icon",onClick:x=>P(o)},[l(u,null,{default:p(()=>[l(d)]),_:1}),t[3]||(t[3]=s("span",null,"\u67E5\u770B",-1))],8,Y),v.value?w("v-if",!0):(h(),C("div",{key:0,class:"handle-icon",onClick:x=>N(o)},[l(u,null,{default:p(()=>[l(g)]),_:1}),t[4]||(t[4]=s("span",null,"\u5220\u9664",-1))],8,ee))])]),default:p(()=>[s("div",W,[k(e.$slots,"empty",{},()=>[l(u,null,{default:p(()=>[l(K(Z))]),_:1})],!0)])]),_:3},8,["class","file-list","disabled","limit","drag","accept"]),s("div",te,[k(e.$slots,"tip",{},void 0,!0)]),F.value?(h(),G(V,{key:0,onClose:t[2]||(t[2]=o=>F.value=!1),"url-list":[A.value]},null,8,["url-list"])):w("v-if",!0)])}}});const ie=J(ae,[["__scopeId","data-v-ef94ac01"],["__file","D:/desktop/yunNan/vue-area-submit/src/components/Upload/Imgs.vue"]]);export{ie as I};
