import{d as R,ah as t,r as u,bj as q,bk as C,L as P,o as Y,c as D,f as v,aY as E,w as y,a as O,P as G,az as U,bl as H,g as f,n as m,t as S,j as J,C as K,__tla as N}from"./index-04f8d540.js";import{u as Q,__tla as W}from"./useMessage-9c37e840.js";let T,X=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return W}catch{}})()]).then(async()=>{let h,_,x,b,g;h={class:"upload-file"},_={style:{"font-size":"8px"}},x={style:{color:"#f56c6c"}},b={style:{"font-size":"8px"}},g={style:{color:"#f56c6c"}},T=R({name:"UploadFile",__name:"UploadFile",props:{modelValue:t.oneOfType([String,Array]).isRequired,title:t.string.def("\u6587\u4EF6\u4E0A\u4F20"),updateUrl:t.string.def("https://zxsh.newfeifan.cn/admin-api/infra/file/upload"),fileType:t.array.def(["doc","xls","ppt","txt","pdf"]),fileSize:t.number.def(5),limit:t.number.def(5),autoUpload:t.bool.def(!0),drag:t.bool.def(!1),isShowTip:t.bool.def(!0)},emits:["update:modelValue"],setup(s,{emit:w}){const o=Q(),j=w,i=s,I=u(),d=u([]),l=u([]),c=u(0),V=u({Authorization:"Bearer "+q(),"tenant-id":C()}),$=e=>{if(l.value.length>=i.limit)return o.error(`\u4E0A\u4F20\u6587\u4EF6\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${i.limit}\u4E2A!`),!1;let a="";e.name.lastIndexOf(".")>-1&&(a=e.name.slice(e.name.lastIndexOf(".")+1));const r=i.fileType.some(p=>e.type.indexOf(p)>-1||!!(a&&a.indexOf(p)>-1)),n=e.size<1024*i.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${i.fileSize}MB!`),!1):(o.error(`\u6587\u4EF6\u683C\u5F0F\u4E0D\u6B63\u786E, \u8BF7\u4E0A\u4F20${i.fileType.join("/")}\u683C\u5F0F!`),!1)},k=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())},B=()=>{o.error(`\u4E0A\u4F20\u6587\u4EF6\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${i.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())},L=e=>{console.log(e)};P(()=>i.modelValue,e=>{e?(l.value=[],U(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);U(i.modelValue)&&(e=e.join(",")),j("update:modelValue",e)};return(e,a)=>{const r=J,n=K,p=H;return Y(),D("div",h,[v(p,{ref_key:"uploadRef",ref:I,"file-list":O(l),"onUpdate:fileList":a[0]||(a[0]=M=>G(l)?l.value=M:null),action:s.updateUrl,"auto-upload":s.autoUpload,"before-upload":$,drag:s.drag,headers:O(V),limit:i.limit,multiple:i.limit>1,"on-error":A,"on-exceed":B,"on-preview":L,"on-remove":F,"on-success":k,"show-file-list":!0,class:"upload-file-uploader",name:"file"},E({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",_,[m(" \u5927\u5C0F\u4E0D\u8D85\u8FC7 "),f("b",x,S(s.fileSize)+"MB",1)]),f("div",b,[m(" \u683C\u5F0F\u4E3A "),f("b",g,S(s.fileType.join("/")),1),m(" \u7684\u6587\u4EF6 ")])]),key:"0"}:void 0]),1032,["file-list","action","auto-upload","drag","headers","limit","multiple"])])}}})});export{T as _,X as __tla};
