import{u as l,w as E}from"./xlsx.ed122d16.js";import{aU as f,ac as p,aY as s}from"./index.1d1a5ecb.js";const{VITE_PROXY_DOMAIN_REAL:B,VITE_PROXY_USER_REAL:m}=p(),d=m+"/admin/",h=(e,t)=>f.request("post",`${d}${e}`,{data:t,responseType:"blob"}),w=["\u5E8F\u53F7","\u64CD\u4F5C"];function F(e){const{data:t,columns:n,name:a}=e;if(!t||!n)return;if(t.length===0)return s.warning("\u8BF7\u6253\u5F00\u52FE\u9009\u5217\u5E76\u52FE\u9009\u5BFC\u51FA\u6570\u636E");const u=R({data:t,columns:n}),r=n.map(({label:c})=>c).filter(c=>c&&!w.includes(c));u.unshift(r);const o=l.book_new(),i=l.aoa_to_sheet(u);l.book_append_sheet(o,i,"sheet1"),E(o,a)}async function b(e){if(!e.url)return;e.onStart&&e.onStart();const t=await h(e.url,{...e.params}).catch(()=>e.onFail&&e.onFail()),{code:n}=t;if(Number(n)!==0&&e.onFail&&e.onFail(),t.type==="application/json"){s.warning("\u672A\u627E\u5230\u6570\u636E");return}if(s.warning("\u4E0B\u8F7D\u4E2D,\u8BF7\u7A0D\u7B49"),n&&Number(n)!==0){s.warning(t.message);return}function a(){const u=new Blob([t],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),r=window.URL.createObjectURL(u),o=document.createElement("a");o.style.display="none",o.href=r,o.setAttribute("download",e.name),document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),s.success("\u4E0B\u8F7D\u5B8C\u6210"),e.onSuccess&&e.onSuccess()}a()}function R({data:e,columns:t}){return e.map(n=>{const a=[];for(let u=0;u<t.length;u++){const{prop:r,transform:o}=t[u];if(!r)continue;const i=o?o(n[r]):n[r];a.push(i)}return a})}function C({type:e,url:t,columns:n,data:a,name:u}){const r=u||"\u5BFC\u51FA\u6570\u636E.xlsx";switch(e){case"front":F({data:a,columns:n,name:r});break;case"http":b({url:t,name:r});break}}export{C as e,b as h};
