import{d as q,ar as t,r as u,c_ as C,c$ as K,w as E,o as G,c as H,f as v,aZ as L,B as _,a as O,a2 as P,aH as U,bi as Z,C as f,E as m,G as S,_ as D,K as J,__tla as N}from"./index-92ad187a.js";import{u as Q,__tla as W}from"./useMessage-d9788660.js";let T,X=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return W}catch{}})()]).then(async()=>{let y,h,x,g,b;y={class:"upload-file"},h={style:{"font-size":"8px"}},x={style:{color:"#f56c6c"}},g={style:{"font-size":"8px"}},b={style:{color:"#f56c6c"}},T=q({name:"UploadFile",__name:"UploadFile",props:{modelValue:t.oneOfType([String,Array]).isRequired,title:t.string.def("\u6587\u4EF6\u4E0A\u4F20"),updateUrl:t.string.def("https://zxpt.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(),I=w,i=s,V=u(),d=u([]),l=u([]),c=u(0),$=u({Authorization:"Bearer "+C(),"tenant-id":K()}),B=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)},j=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${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())},M=e=>{console.log(e)};E(()=>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(",")),I("update:modelValue",e)};return(e,a)=>{const r=D,n=J,p=Z;return G(),H("div",y,[v(p,{ref_key:"uploadRef",ref:V,"file-list":O(l),"onUpdate:fileList":a[0]||(a[0]=R=>P(l)?l.value=R:null),action:s.updateUrl,"auto-upload":s.autoUpload,"before-upload":B,drag:s.drag,headers:O($),limit:i.limit,multiple:i.limit>1,"on-error":A,"on-exceed":k,"on-preview":M,"on-remove":F,"on-success":j,"show-file-list":!0,class:"upload-file-uploader",name:"file"},L({default:_(()=>[v(n,{type:"primary"},{default:_(()=>[v(r,{icon:"ep:upload-filled"}),m(" \u9009\u53D6\u6587\u4EF6 ")]),_:1})]),_:2},[s.isShowTip?{name:"tip",fn:_(()=>[f("div",h,[m(" \u5927\u5C0F\u4E0D\u8D85\u8FC7 "),f("b",x,S(s.fileSize)+"MB",1)]),f("div",g,[m(" \u683C\u5F0F\u4E3A "),f("b",b,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};
