import{d as x,r as l,a as k,o as z,g as p,c as I,k as L,e as r,w as s,b as _,t as N,l as R,aa as E,E as m,_ as U}from"./index-CUnFTKV2.js";import B from"./OrderSearchForm-DIsYPvXe.js";import j from"./BuyOrderTable-D9MnxqrW.js";import P from"./OrderDetailDialog-CCUOom5N.js";import{g as M,e as T}from"./order-BSmesayL.js";const q={class:"page-container"},F={class:"card-header"},$=x({__name:"buy",setup(A){const d=l(!1),g=l([]),v=l(0),i=l(!1),e=k({page:1,pageSize:20}),c=l(!1),u=l(null),n=async()=>{d.value=!0;try{const a=await M(e);g.value=a.data.list,v.value=a.data.total}catch(a){console.error("获取订单列表失败:",a),m.error("获取订单列表失败")}finally{d.value=!1}},f=a=>{e.userId=void 0,e.mobile=void 0,e.orderNum=void 0,e.startDate=void 0,e.endDate=void 0,Object.assign(e,a),e.page=1,n()},h=()=>{e.userId=void 0,e.mobile=void 0,e.orderNum=void 0,e.startDate=void 0,e.endDate=void 0,e.page=1,n()},b=a=>{e.page=a,n()},D=a=>{e.pageSize=a,e.page=1,n()},y=a=>{u.value=a.id,c.value=!0},w=()=>{u.value=null},C=async()=>{i.value=!0;try{const a=await T({userId:e.userId,mobile:e.mobile,orderNum:e.orderNum,startDate:e.startDate,endDate:e.endDate}),o=window.URL.createObjectURL(a),t=document.createElement("a");t.href=o,t.download=`购买订单_${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(o),m.success("导出成功")}catch(a){console.error("导出失败:",a),m.error("导出失败")}finally{i.value=!1}};return z(()=>{n()}),(a,o)=>{const t=p("el-icon"),O=p("el-button"),S=p("el-card");return L(),I("div",q,[r(S,null,{header:s(()=>[_("div",F,[o[2]||(o[2]=_("span",null,"购买订单",-1)),r(O,{type:"primary",onClick:C,loading:i.value},{default:s(()=>[r(t,null,{default:s(()=>[r(R(E))]),_:1}),o[1]||(o[1]=N("导出 ",-1))]),_:1},8,["loading"])])]),default:s(()=>[r(B,{onSearch:f,onReset:h}),r(j,{data:g.value,loading:d.value,total:v.value,page:e.page,"page-size":e.pageSize,onPageChange:b,onSizeChange:D,onViewDetail:y},null,8,["data","loading","total","page","page-size"])]),_:1}),r(P,{modelValue:c.value,"onUpdate:modelValue":o[0]||(o[0]=V=>c.value=V),"order-id":u.value,onClose:w},null,8,["modelValue","order-id"])])}}}),W=U($,[["__scopeId","data-v-2660d200"]]);export{W as default};
