import{x as b,i as v,c as g,F as O,r,al as F,y as E,z as R,M as h,O as $,Q as A,I as _,B as D,H as j,u as d,L as H,A as K,J as q,R as J,l as Q}from"./vendor-27e23c1b-1782468512657v=1.0.0.js";import{k as G,l as W,m as X,_ as Y}from"./index-c87bcfde-1782468512657v=1.0.0.js";import{f as Z,e as ee,c as i}from"./eleVendor-12a75a9a-1782468512657v=1.0.0.js";const te={class:"upload-box"},ae={class:"el-upload__tip"},oe=b({name:"UploadImg"}),le=b({...oe,props:{name:{},url:{},showFileList:{type:Boolean,default:!1},api:{},drag:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},limit:{default:5},fileSize:{default:20},fileType:{default:()=>["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","image/jpeg","image/png","image/gif"]},height:{},width:{},borderRadius:{},isFullUrl:{type:Boolean},uploadType:{default:"video"},process:{type:Boolean,default:!0}},emits:["update:name","update:url","uploadFile","getFileInfo"],setup(w,{emit:B}){const U=[{color:"#f56c6c",percentage:20},{color:"#e6a23c",percentage:40},{color:"#5cb87a",percentage:60},{color:"#1989fa",percentage:80},{color:"#6f7ad3",percentage:100}],o=v(Z,void 0),n=v(ee,void 0),y=g(()=>l.disabled||(o==null?void 0:o.disabled)),c=g({set(e){s("update:name",e.name),s("update:url",e.url)},get(e){return e}}),l=w,S=O(),C=r(S.default),P=r("id-"+G()),s=B,p=r(0),z=g(()=>f.value&&l.process),f=r(!1),I=e=>{f.value=!0,p.value=Math.round(e.loaded*100/e.total)<90?Math.round(e.loaded*100/e.total):90},T=async e=>{let t=new FormData;t.append("file",e.file);try{const u=await(l.uploadType=="video"?W:X)(t,!0,I);if(u.code!==0){e.onError(u.msg);return}const m={fileUrl:u.data,filePath:u.data,name:e.file.name};e.onSuccess(m)}catch(a){f.value=!1,e.onError(a)}},k=e=>{const t=e.size/1024/1024<l.fileSize,a=l.fileType;return a.includes(e.type)||i({title:"\u6E29\u99A8\u63D0\u793A",message:"\u4E0A\u4F20\u6587\u4EF6\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01",type:"warning"}),t||i({title:"\u6E29\u99A8\u63D0\u793A",message:`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${l.fileSize}M\uFF01`,type:"warning"}),a.includes(e.type)&&t},x=(e,t)=>{!e||(t.name=e.fileUrl,t.url=e.fileUrl,t.filePath=e.filePath,t.url=e.fileUrl,s("update:name",e.name),s("update:url",e.fileUrl),s("getFileInfo",t),n!=null&&n.prop&&(o==null||o.validateField([n.prop])),p.value=100,i({title:"\u6E29\u99A8\u63D0\u793A",message:"\u6587\u4EF6\u4E0A\u4F20\u6210\u529F\uFF01",type:"success"}))},L=e=>{i({title:"\u6E29\u99A8\u63D0\u793A",message:e,type:"error"})},M=()=>{i({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"})},N=e=>{};return(e,t)=>{const a=F("el-button"),u=F("el-progress"),m=F("el-upload");return E(),R("div",te,[h($(e.url)+" ",1),A(m,{action:"#",id:P.value,multiple:!1,"show-file-list":e.showFileList,limit:e.limit,disabled:d(y),"file-list":d(c),"onUpdate:fileList":t[0]||(t[0]=V=>Q(c)?c.value=V:null),"http-request":T,"before-upload":k,"on-success":x,"on-error":L,"on-exceed":M,"on-progress":N},{trigger:_(()=>[D(e.$slots,"default",{},void 0,!0),C.value?H("v-if",!0):(E(),j(a,{key:0,type:"primary",disabled:d(y)},{default:_(()=>t[1]||(t[1]=[h("\u70B9\u51FB\u4E0A\u4F20",-1)])),_:1,__:[1]},8,["disabled"]))]),tip:_(()=>[K("div",ae,[D(e.$slots,"tip",{},void 0,!0),q(A(u,{percentage:p.value,color:U},null,8,["percentage"]),[[J,d(z)]])])]),_:3},8,["id","show-file-list","limit","disabled","file-list"])])}}});const ne=Y(le,[["__scopeId","data-v-adc25abf"]]);export{ne as D};
