Files
tehran_tala/apps/admin-panel/dist/assets/Dashboard-Bycj9shr.js
T

2 lines
7.4 KiB
JavaScript
Raw Normal View History

import{d as F,o as d,a as m,w as s,n as l,s as K,g as Q,t as p,p as o,r as i,_ as R,v as X,x as Z,l as tt,y as at,c as e,i as k,f as b,b as et,h as st,F as ot}from"./index-Du-kGM0u.js";import{B as D,D as nt,S as rt,T as it}from"./TeamOutlined-DsdJFeT7.js";import{j as P,p as $}from"./filters-BmR7ImkZ.js";import"./index-CNoJT7bc.js";const lt={class:"stat-row"},ct={class:"stat-value"},dt={class:"stat-title"},ut=F({__name:"StatisticsCardLine",props:{icon:{},statistic:{},statisticTitle:{},color:{default:"primary"},hideChart:{type:Boolean,default:!0}},setup(h){const g=h,t={UsersIcon:it,ShoppingBagIcon:rt,DollarSignIcon:nt,BarChartIcon:D},v=o(()=>t[g.icon??""]??D);return(I,L)=>{const y=i("a-card");return d(),m(y,{class:"stat-card"},{default:s(()=>[l("div",lt,[l("span",{class:K(["stat-icon",`icon-${h.color}`])},[(d(),m(Q(v.value)))],2),l("div",null,[l("h2",ct,p(h.statistic),1),l("span",dt,p(h.statisticTitle),1)])])]),_:1})}}}),_=R(ut,[["__scopeId","data-v-2ccaa937"]]),mt={class:"grid-4"},pt={class:"grid-2 mt-4"},_t={class:"grid-2 mt-4"},ht={class:"grid-2 mt-4"},f="#1c2d56",C="#28c76f",w="#ff9f43",gt="#ea5455",bt=F({__name:"Dashboard",setup(h){const g=tt(!1),t=at({customerCount:0,allgram:0,ordercount:0,reagent:[],lastOrder:[],sumLastOrder:0,sumLastOrderMonth:0,ordersTrend:[],statusBreakdown:[],channelBreakdown:[],topProducts:[],goldPricePerGram:null,totalCustomerDebtGrams:0}),v=[{title:"کارشناس فروش",dataIndex:"name"},{title:"میزان فروش (گرم)",dataIndex:"grams_sell"},{title:"تعداد سفارش",dataIndex:"order_count"}],I=[{title:"شماره سفارش",dataIndex:"name"},{title:"مشتری",dataIndex:"customer"},{title:"وزن",dataIndex:"w"},{title:"وضعیت",dataIndex:"sts_str"},{title:"تاریخ",dataIndex:"caj"}];function L(a){return{success:"green",warning:"orange",danger:"red",primary:"blue"}[a]??""}const y=o(()=>t.goldPricePerGram?`${$(Math.round(Number(t.goldPricePerGram)))} تومان`:"—"),T=o(()=>$(Number(t.totalCustomerDebtGrams??0).toFixed(2))),z=o(()=>{const a=Number(t.sumLastOrder??0),n=Number(t.sumLastOrderMonth??0);return a>0?(n/a).toFixed(2):"0"}),G=o(()=>{const a=t.ordersTrend??[];return[{name:"تک فروشی",data:a.map(n=>n.retail)},{name:"عمده فروشی",data:a.map(n=>n.wholesale)}]}),j=o(()=>({chart:{toolbar:{show:!1},fontFamily:"inherit"},colors:[f,C],dataLabels:{enabled:!1},stroke:{curve:"smooth",width:2},fill:{type:"gradient",gradient:{opacityFrom:.35,opacityTo:.05}},legend:{position:"top",horizontalAlign:"right"},xaxis:{categories:(t.ordersTrend??[]).map(a=>P(a.date)),labels:{rotate:-45,rotateAlways:!0,hideOverlappingLabels:!0,style:{fontSize:"12px",fontWeight:500}}},tooltip:{shared:!0}})),M=o(()=>(t.statusBreakdown??[]).map(a=>a.count)),A=o(()=>({chart:{fontFamily:"inherit"},labels:(t.statusBreakdown??[]).map(a=>a.label),colors:[w,f,f,w,w,C,C,gt],legend:{position:"bottom"},dataLabels:{enabled:!0}})),V=o(()=>(t.channelBreakdown??[]).map(a=>a.count)),W=o(()=>({chart:{fontFamily:"inherit"},labels:(t.channelBreakdown??[]).map(a=>a.label),colors:[f,C],legend:{position:"bottom"},dataLabels:{enabled:!0}})),S=o(()=>[{name:"گرم فروخته‌شده",data:(t.reagent??[]).map(a=>Number(a.grams_sell??0))}]),E=o(()=>({chart:{toolbar:{show:!1},fontFamily:"inherit"},plotOptions:{bar:{horizontal:!0,borderRadius:4}},colors:[f],dataLabels:{enabled:!0},xaxis:{categories:(t.reagent??[]).map(a=>a.name)}})),B=o(()=>[{name:"وزن فروخته‌شده (گرم)",data:(t.topProducts??[]).map(a=>Number(a.weight??0))}]),U=o(()=>({chart:{toolbar:{show:!1},fontFamily:"inherit"},plotOptions:{bar:{borderRadius:4,columnWidth:"55%"}},colors:[C],dataLabels:{enabled:!1},xaxis:{categories:(t.topProducts??[]).map(a=>a.title)}}));return X(async()=>{try{g.value=!0;const{data:a}=await Z.get("dashboard/overview");Object.assign(t,a),t.reagent=[...t.reagent??[]].sort((n,r)=>Number(r.grams_sell)-Number(n.grams_sell)),t.lastOrder=[...t.lastOrder??[]].sort((n,r)=>Number(r.w)-Number(n.w))}catch(a){console.error(a)}finally{g.value=!1}}),(a,n)=>{const r=i("apexchart"),u=i("a-card"),N=i("a-table"),Y=i("a-empt