var ee=Object.defineProperty,te=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var B=(i,l,u)=>l in i?ee(i,l,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[l]=u,E=(i,l)=>{for(var u in l||(l={}))oe.call(l,u)&&B(i,u,l[u]);if($)for(var u of $(l))le.call(l,u)&&B(i,u,l[u]);return i},V=(i,l)=>te(i,ae(l));import{d as ne,u as re,i as p,W as b,o as c,j as v,c as o,w as r,b as t,a as H,Z as ue,e as _,U as se,x as ie,v as ce,f as d,t as k,F as R,n as N,H as me,J as P,aN as _e,aq as pe,B as ve,aO as de,aP as fe,aQ as ye}from"./index.29cf2edd.js";/* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              */import{R as he}from"./ReportService.10f7d665.js";import{f as D}from"./filters.69c883c5.js";import{_ as ge}from"./ReportGroupSelection.4516a291.js";import{_ as xe}from"./StatusSelection.682823fe.js";import{_ as Ce}from"./ServiceLocationSelection.6ec04a32.js";import{_ as Se}from"./BuyTypeSelection.f3739a5a.js";import{_ as be}from"./BuyModeSelection.7846d63e.js";import{_ as ke}from"./VisaTypeSelection.8f552476.js";const Ne=d("Search"),Le=d("Clear"),Te=d("Excel "),Ye={key:0},Oe={key:1},Me={key:2},Re={key:3},De=d("Total"),Ze=ne({__name:"SaleSummaryReport",setup(i){const l=[{title:"Date",dataIndex:"txtime",key:"txtime"},{title:"Buy Orders",dataIndex:"total",key:"total"},{title:"Volume",dataIndex:"volume",key:"volume"}],u=re();let s=p(),n=p();const f=p([]);let y=p(),x=p(),C=p(),S=p(),h=p();const I=b(()=>{let e=0,a=0;return s.value.forEach(({total:Y,volume:g})=>{e+=Number(Y),a+=Number(g)}),{totalOrders:e,totalVolume:a}}),G=e=>{if(s.value=[],e==="HOSPITAL")return n.value=void 0,N.warn("Can't report group by hospital");e==="LOCATION"&&(y.value=void 0),n.value=e},F=e=>{S.value=e},U=e=>{x.value=e},X=e=>{C.value=e},j=e=>{if(n.value==="LOCATION")return N.warn("Report group by location, Can't choose service location"),y.value=void 0;y.value=e},q=async()=>{if(!n.value)return N.warn("Please choose a report group");if(!L.value&&!T.value)return N.warn("Please choose report date");const e={reportGroup:n.value,fromdate:L.value,todate:T.value,serviceLocation:y.value,buyType:x.value,buyMode:C.value,status:S.value,visatype_id:h.value};me(),await he.getSaleSummaryReport(e).then(a=>{P(),s.value=a.data}).catch(a=>{P()})},z=()=>{n.value=void 0,f.value=[],y.value=void 0,x.value=void 0,C.value=void 0,S.value=void 0},J=()=>{const e=`${n.value}_Report.${L.value}.${T.value}.xlsx`;_e(e,w.value)},L=b(()=>f.value[0]?f.value[0].format("YYYY-MM-DD"):null),T=b(()=>f.value[1]?f.value[1].format("YYYY-MM-DD"):null),w=b(()=>s&&s.value.length>0?s.value.map(e=>{let a=e.txtime;return n.value==="DAILY"&&(a=D.formatDob(a)),n.value==="MONTHLY"&&(a=a.toString().padStart(2,"0")),V(E({},e),{total:Number(e.total),volume:Number(e.volume),txtime:a})}):s.value);return(e,a)=>{const Y=pe,g=ve,Q=se,O=de,A=fe,W=ye,Z=ie;return c(),v("div",null,[o(Q,{size:8,style:{"margin-bottom":"8px"}},{default:r(()=>[o(ge,{value:t(n),onChange:G},null,8,["value"]),o(Y,{value:f.value,"onUpdate:value":a[0]||(a[0]=m=>f.value=m)},null,8,["value"]),["ADMIN","ACCOUNTING"].includes(t(u).role)?(c(),H(Ce,{key:0,value:t(y),onChange:j},null,8,["value"])):_("",!0),o(ke,{value:t(h),onChange:a[1]||(a[1]=m=>ce(h)?h.value=m:h=m)},null,8,["value"]),o(Se,{value:t(x),onChange:U},null,8,["value"]),o(be,{value:t(C),onChange:X},null,8,["value"]),o(xe,{value:t(S),onChange:F},null,8,["value"]),o(g,{onClick:q},{default:r(()=>[Ne]),_:1}),o(g,{onClick:z},{default:r(()=>[Le]),_:1}),o(g,{disabled:!t(s)||t(s)&&t(s).length===0,type:"primary",onClick:J},{default:r(()=>[Te]),_:1},8,["disabled"])]),_:1}),t(s)?(c(),H(Z,{key:0,columns:l,"data-source":t(w),pagination:!1},ue({headerCell:r(({column:m,text:K,record:M})=>[m.key==="txtime"?(c(),v(R,{key:0},[t(n)==="DAILY"?(c(),v("span",Ye,"Date")):_("",!0),t(n)==="MONTHLY"?(c(),v("span",Oe,"Month")):_("",!0),t(n)==="YEARLY"?(c(),v("span",Me,"Year")):_("",!0),t(n)==="LOCATION"?(c(),v("span",Re,"Service Location")):_("",!0)],64)):_("",!0)]),bodyCell:r(({column:m,text:K,record:M})=>[m.key==="txtime"?(c(),v(R,{key:0},[d(k(M.txtime),1)],64)):_("",!0),m.key==="volume"?(c(),v(R,{key:1},[d(k(t(D).formatMoney(M.volume)),1)],64)):_("",!0)]),_:2},[t(s)?{name:"summary",fn:r(()=>[o(W,null,{default:r(()=>[o(O,null,{default:r(()=>[De]),_:1}),o(O,null,{default:r(()=>[o(A,{type:"success"},{default:r(()=>[d(k(t(I).totalOrders),1)]),_:1})]),_:1}),o(O,null,{default:r(()=>[o(A,{type:"success"},{default:r(()=>[d(k(t(D).formatMoney(t(I).totalVolume)),1)]),_:1})]),_:1})]),_:1})])}:void 0]),1032,["data-source"])):_("",!0)])}}});export{Ze as default};
