import{u as i,w as f}from"./xlsx.ed122d16.js";import{ck as p,X as w,cc as o}from"./index.e80c366d.js";const{VITE_PROXY_USER_REAL:E,VITE_PURCHASE_REPORT:B}=w(),d=E+"/admin/",m=E,F=(r,e,t=!1)=>p.request("post",`${t?d:m}${r}`,{data:e,responseType:"blob"}),h=["\u5E8F\u53F7","\u64CD\u4F5C"];function C(r){const{data:e,columns:t,name:n}=r;if(!e||!t)return;if(e.length===0)return o.warning("\u8BF7\u6253\u5F00\u52FE\u9009\u5217\u5E76\u52FE\u9009\u5BFC\u51FA\u6570\u636E");const a=R({data:e,columns:t}),u=t.map(({label:s})=>s).filter(s=>s&&!h.includes(s));a.unshift(u);const c=i.book_new(),l=i.aoa_to_sheet(a);i.book_append_sheet(c,l,"sheet1"),f(c,n)}function b(r,{fileType:e="aplication/zip",...t}){const n=new Blob([r],{type:e}),a=window.URL.createObjectURL(n),u=document.createElement("a");u.style.display="none",u.href=a,u.setAttribute("download",t.name),document.body.appendChild(u),u.click(),window.URL.revokeObjectURL(a),o.success("\u4E0B\u8F7D\u5B8C\u6210"),t.onSuccess&&t.onSuccess()}async function g({isAdmin:r=!1,...e}){e.onStart&&e.onStart();try{let t=null;if(!e.api&&!e.url){console.warn("\u5FC5\u987B\u4F20\u5165api\u6216url");return}e.api&&(t=await e.api(e.params)),e.url&&(t=await F(e.url,e.params,r));const{code:n}=t;if(Number(n)!==0&&e.onFail&&e.onFail(),t.type==="application/json"){o.warning("\u672A\u627E\u5230\u6570\u636E");return}if(o.warning("\u4E0B\u8F7D\u4E2D,\u8BF7\u7A0D\u7B49"),n&&Number(n)!==0){o.warning(t.message);return}b(t,e)}catch{e.onFail&&e.onFail()}}function R({data:r,columns:e}){return r.map(t=>{const n=[];for(let a=0;a<e.length;a++){const{prop:u,transform:c}=e[a];if(!u)continue;const l=c?c(t[u]):t[u];n.push(l)}return n})}export{C as f,g as h};
