import{d as y,X as g,ar as M,as as V,f as d,a8 as I,W as K,p as _,aw as P,i as v,a as E,c as R,k as q,m as c,j as G,t as H,e as r,n as x,z as W,v as X,l as J,a4 as O,ax as Q,M as p,_ as Y}from"./index-deffec86.js";const Z={class:"upload-box"},ee={class:"el-upload__tip"},te=y({name:"UploadImg"}),ie=y({...te,props:{fileList:{default:()=>[]},showFileList:{type:Boolean,default:!0},api:{},drag:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},limit:{default:5},fileSize:{default:50},fileType:{default:()=>["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/vnd.ms-powerpoint","video/mp4","application/x-zip-compressed","application/x-rar-compressed","image/jpg","image/png","image/gif","image/jpeg"]},height:{},width:{},borderRadius:{},isFullUrl:{type:Boolean}},emits:["update:fileList"],setup(A,{emit:D}){const u=g(M,void 0),n=g(V,void 0),w=d(()=>a.disabled||(u==null?void 0:u.disabled)),l=d({set(e){m("update:fileList",e)},get(){return a.fileList}}),a=A;let b={pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",jpg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",jpeg:"image/jpeg",mp4:"video/mp4",zip:"application/x-zip-compressed",rar:"application/x-rar-compressed",txt:"text/plain",webp:"image/webp"};const f=I(),h=d(()=>{var i;let e=((i=f.accept)==null?void 0:i.split(","))||[];if(e.length==0)return"";let t=a.fileSize,s="MB";return a.fileSize>1024&&(s="GB",t=a.fileSize/1024),`\u53EA\u80FD\u4E0A\u4F20${e.join("/")}\u6587\u4EF6\uFF0C\u4E14\u4E0D\u8D85\u8FC7${t.toFixed(2)||5}${s}\uFF01`}),B=K(),z=_(B.default),S=_("id-"+P()),C=async e=>{var s;let t=new FormData;t.append("Filedata",e.file);try{const i=(s=a.api)!=null?s:Q,{data:o}=await i(t);e.onSuccess(o)}catch(i){e.onError(i)}},L=e=>{var F;const t=e.size/1024/1024<a.fileSize,o=(((F=f.accept)==null?void 0:F.split(","))||[]).map(k=>{const N=k.substring(1);return b[N]}).includes(e.type);return o||p({title:"\u6E29\u99A8\u63D0\u793A",message:"\u4E0A\u4F20\u6587\u4EF6\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01",type:"warning"}),t||p({title:"\u6E29\u99A8\u63D0\u793A",message:`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${a.fileSize}M\uFF01`,type:"warning"}),o&&t},m=D,j=(e,t)=>{!e||(t.name=e.name,t.file_path=e.file_path,t.file_url=e.file_url,t.size=e.size,t.suffix=e.suffix,l.value,m("update:fileList",l.value),n!=null&&n.prop&&(u==null||u.validateField([n.prop])),p({title:"\u6E29\u99A8\u63D0\u793A",message:`${t.name}\u4E0A\u4F20\u6210\u529F!`,type:"success"}))},T=()=>{p({title:"\u6E29\u99A8\u63D0\u793A",message:"\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01",type:"error"})},U=()=>{p({title:"\u6E29\u99A8\u63D0\u793A",message:"\u5F53\u524D\u6700\u591A\u53EA\u80FD\u4E0A\u4F20 1 \u4E2A\u6587\u4EF6\uFF0C\u8BF7\u79FB\u9664\u540E\u4E0A\u4F20\uFF01",type:"warning"})},$=e=>{};return(e,t)=>{const s=v("el-button"),i=v("el-upload");return E(),R("div",Z,[q(i,{action:"#",id:S.value,multiple:!1,"show-file-list":e.showFileList,limit:e.limit,disabled:r(w),"file-list":r(l),"onUpdate:fileList":t[0]||(t[0]=o=>O(l)?l.value=o:null),"http-request":C,"before-upload":L,"on-success":j,"on-error":T,"on-exceed":U,"on-progress":$},{tip:c(()=>[G("div",ee,H(r(h)),1),x(e.$slots,"tip",{},void 0,!0)]),default:c(()=>[x(e.$slots,"default",{},void 0,!0),z.value?J("v-if",!0):(E(),W(s,{key:0,type:"primary"},{default:c(()=>t[1]||(t[1]=[X("\u70B9\u51FB\u4E0A\u4F20")])),_:1}))]),_:3},8,["id","show-file-list","limit","disabled","file-list"])])}}});const se=Y(ie,[["__scopeId","data-v-25b52ac3"]]);export{se as D};
