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