import{d as q,p as i,r as u,co as J,cp as L,aP as P,o as W,c as C,i as v,ct as D,w as y,a as O,y as E,aW as S,bo as G,g as f,j as m,t as T,v as H,J as K,__tla as N}from"./index-8c6726e5.js";import{u as Q,__tla as X}from"./useMessage-9f6930df.js";let U,Y=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return X}catch{}})()]).then(async()=>{let _,h,x,g,b;_={class:"upload-file"},h={style:{"font-size":"8px"}},x={style:{color:"#f56c6c"}},g={style:{"font-size":"8px"}},b={style:{color:"#f56c6c"}},U=q({name:"UploadFile",__name:"UploadFile",props:{modelValue:i.oneOfType([String,Array]).isRequired,title:i.string.def("\u6587\u4EF6\u4E0A\u4F20"),updateUrl:i.string.def("https://zxpt.newfeifan.cn/admin-api/infra/file/upload"),fileType:i.array.def(["doc","xls","ppt","txt","pdf"]),fileSize:i.number.def(5),limit:i.number.def(5),autoUpload:i.bool.def(!0),drag:i.bool.def(!1),isShowTip:i.bool.def(!0)},emits:["update:modelValue"],setup(s,{emit:w}){const o=Q(),j=w,t=s,I=u(),d=u([]),l=u([]),c=u(0),V=u({Authorization:"Bearer "+J(),"tenant-id":L()}),$=e=>{if(l.value.length>=t.limit)return o.error(`\u4E0A\u4F20\u6587\u4EF6\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${t.limit}\u4E2A!`),!1;let a="";e.name.lastIndexOf(".")>-1&&(a=e.name.slice(e.name.lastIndexOf(".")+1));const r=t.fileType.some(p=>e.type.indexOf(p)>-1||!!(a&&a.indexOf(p)>-1)),n=e.size<1024*t.fileSize*1024;return r?n?(o.success("\u6B63\u5728\u4E0A\u4F20\u6587\u4EF6\uFF0C\u8BF7\u7A0D\u5019..."),void c.value++):(o.error(`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${t.fileSize}MB!`),!1):(o.error(`\u6587\u4EF6\u683C\u5F0F\u4E0D\u6B63\u786E, \u8BF7\u4E0A\u4F20${t.fileType.join("/")}\u683C\u5F0F!`),!1)},B=e=>{o.success("\u4E0A\u4F20\u6210\u529F");const a=l.value.findIndex(r=>{var n;return((n=r.response)==null?void 0:n.data)===e.data});l.value.splice(a,1),d.value.push({name:e.data,url:e.data}),d.value.length==c.value&&(l.value.push(...d.value),d.value=[],c.value=0,z())},k=()=>{o.error(`\u4E0A\u4F20\u6587\u4EF6\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${t.limit}\u4E2A!`)},A=()=>{o.error("\u5BFC\u5165\u6570\u636E\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01")},F=e=>{const a=l.value.map(r=>r.name).indexOf(e.name);a>-1&&(l.value.splice(a,1),z())},M=e=>{console.log(e)};P(()=>t.modelValue,e=>{e?(l.value=[],S(e)?l.value.push(...e.split(",").map(a=>({name:a.substring(a.lastIndexOf("/")+1),url:a}))):l.value.push(...e.map(a=>({name:a.substring(a.lastIndexOf("/")+1),url:a})))):l.value=[]},{immediate:!0,deep:!0});const z=()=>{let e=l.value.map(a=>a.url);S(t.modelValue)&&(e=e.join(",")),j("update:modelValue",e)};return(e,a)=>{const r=H,n=K,p=G;return W(),C("div",_,[v(p,{ref_key:"uploadRef",ref:I,"file-list":O(l),"onUpdate:fileList":a[0]||(a[0]=R=>E(l)?l.value=R:null),action:s.updateUrl,"auto-upload":s.autoUpload,"before-upload":$,drag:s.drag,headers:O(V),limit:t.limit,multiple:t.limit>1,"on-error":A,"on-exceed":k,"on-preview":M,"on-remove":F,"on-success":B,"show-file-list":!0,class:"upload-file-uploader",name:"file"},D({default:y(()=>[v(n,{type:"primary"},{default:y(()=>[v(r,{icon:"ep:upload-filled"}),m(" \u9009\u53D6\u6587\u4EF6 ")]),_:1})]),_:2},[s.isShowTip?{name:"tip",fn:y(()=>[f("div",h,[m(" \u5927\u5C0F\u4E0D\u8D85\u8FC7 "),f("b",x,T(s.fileSize)+"MB",1)]),f("div",g,[m(" \u683C\u5F0F\u4E3A "),f("b",b,T(s.fileType.join("/")),1),m(" \u7684\u6587\u4EF6 ")])]),key:"0"}:void 0]),1032,["file-list","action","auto-upload","drag","headers","limit","multiple"])])}}})});export{U as _,Y as __tla};
