Files
tehran_taj/apps/admin-panel/dist/assets/index-DkDx4Jil.js
T

2 lines
6.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{j as H}from"./filters-FOBe3caU.js";import{d as J,u as K,x as W,a as h,w as u,y as X,r as v,m as b,o as t,c as y,f as m,i as k,p as a,b as o,e as Y,t as n,F as f,q as T,B as V,h as ee,Z as se,s as p,_ as te}from"./index-DkUTdlVu.js";import"./index-adwhba7e.js";const ae={class:"kpis"},le={class:"kpi__label"},oe={class:"kpi__value"},ne={class:"panel"},ie={key:1,class:"name"},ce={key:2,class:"code"},ue={key:2,class:"share"},de={class:"share__bar"},re={key:0,class:"statics__notice"},pe={class:"panels-2"},_e={class:"panel"},ve={key:1,class:"name"},ye={key:2,class:"code"},ke={key:2,class:"share"},me={class:"share__bar"},we={class:"panel"},he={key:1,class:"name"},be={key:2,class:"share"},fe={class:"share__bar"},ge=J({__name:"index",setup(xe){const N=K(),d=e=>e.toLocaleString("fa-IR"),_=b(30),E=[{label:"۷ روز",value:7},{label:"۳۰ روز",value:30},{label:"۹۰ روز",value:90},{label:"همه",value:0}],B=p(()=>_.value?`${d(_.value)} روز گذشته`:"کل دوره"),g=b(!1),x=b(!1),i=b({totals:{soldQty:0,orders:0,views:0,viewedProducts:0},viewsTrackedSince:null,topSoldProducts:[],topViewedProducts:[],topViewedBrands:[]}),D=p(()=>[{label:"تعداد فروش",value:i.value.totals.soldQty},{label:"سفارش‌ها",value:i.value.totals.orders},{label:"بازدید محصولات",value:i.value.totals.views},{label:"محصولات دیده‌شده",value:i.value.totals.viewedProducts}]),I=p(()=>Math.max(1,...i.value.topSoldProducts.map(e=>e.qty))),j=p(()=>Math.max(1,...i.value.topViewedProducts.map(e=>e.views))),F=p(()=>Math.max(1,...i.value.topViewedBrands.map(e=>e.views))),C=(e,c)=>Math.max(4,Math.round(e/c*100)),M={key:"rank",title:"#",width:48,align:"center"},O=[M,{key:"title",title:"محصول"},{key:"qty",title:"تعداد فروش",width:180},{key:"orders",title:"سفارش",width:80,align:"center"}],z=e=>[M,{key:"title",title:e},{key:"views",title:"بازدید",width:150}],$=p(()=>i.value.viewsTrackedSince?`در ${B.value} بازدیدی ثبت نشده است.`:"هنوز بازدیدی ثبت نشده. هر بار که مشتری صفحهٔ یک محصول را در اپ باز کند شمرده می‌شود."),q=p(()=>{const e=i.value.viewsTrackedSince;return!e||(_.value?Date.now()-_.value*864e5:0)>=new Date(e).getTime()?null:`آمار بازدید از ${H(e)} ثبت می‌شود؛ قبل از این تاریخ بازدیدی در دست نیست.`}),Q=p(()=>!!N.hasPermission("product.list.edit"));function w(e){return Q.value?{name:"product-edit",params:{id:e}}:null}async function S(){try{g.value=!0,x.value=!1;const{data:e}=await X.get("admin/misc/stats/top",{params:{days:_.value}});i.value=e}catch(e){console.log(e),x.value=!0}finally{g.value=!1}}return W(S),(e,c)=>{const U=v("a-segmented"),R=v("a-button"),Z=v("a-alert"),L=v("router-link"),P=v("a-table"),A=v("a-spin"),G=v("a-card");return t(),h(G,{title:"آمار فروش و بازدید",class:"page-card statics"},{extra:u(()=>[y(U,{value:_.value,"onUpdate:value":c[0]||(c[0]=l=>_.value=l),options:E,size:"small",onChange:S},null,8,["value"])]),default:u(()=>[x.value?(t(),h(Z,{key:0,type:"error","show-icon":"",message:"آمار بارگذاری نشد.",class:"statics__alert"},{action:u(()=>[y(R,{size:"small",onClick:S},{default:u(()=>[...c[1]||(c[1]=[m("تلاش دوباره",-1)])]),_:1})]),_:1})):k("",!0),y(A,{spinning:g.value},{default:u(()=>[a("div",ae,[(t(!0),o(f,null,Y(D.value,l=>(t(),o("div",{key:l.label,class:"kpi"},[a("span",le,n(l.label),1),a("b",oe,n(d(l.value)),1)]))),128))]),a("section",ne,[c[2]||(c[2]=a("h3",{class:"panel__title"},"پرفروش‌ترین محصولات",-1)),y(P,{"data-source":i.value.topSoldProducts,columns:O,pagination:!1,locale:{emptyText:`در ${B.value} سفارشی ثبت نشده است.`},size:"small","row-key":"id",class:"table-scroll"},{bodyCell:u(({column:l,record:s,index:r})=>[l.key==="rank"?(t(),o("span",{key:0,class:T(["pos",{"is-top":r<3}])},n(d(r+1)),3)):l.key==="title"?(t(),o(f,{key:1},[w(s.id)?(t(),h(L,{key:0,to:w(s.id),class:"name"},{default:u(()=>[m(n(s.title),1)]),_:2},1032,["to"])):(t(),o("span",ie,n(s.title),1)),s.code?(t(),o("span",ce,n(s.code),1)):k("",!0)],64)):l.key==="qty"?(t(),o("div",ue,[a("b",null,n(d(s.qty)),1),a("span",de,[a("i",{style:V({width:`${C(s.qty,I.value)}%`})},null,4)])])):l.key==="orders"?(t(),o(f,{key:3},[m(n(d(s.orders)),1)],64)):k("",!0)]),_:1},8,["data-source","locale"])]),q.value?(t(),o("p",re,[y(ee(se)),m(" "+n(q.value),1)])):k("",!0),a("div",pe,[a("section",_e,[c[3]||(c[3]=a("h3",{class:"panel__title"},"پربازدیدترین محصولات",-1)),y(P,{"data-source":i.value.topViewedProducts,columns:z("محصول"),pagination:!1,locale:{emptyText:$.value},size:"small","row-key":"id",class:"table-scroll"},{bodyCell:u(({column:l,record:s,index:r})=>[l.key==="rank"?(t(),o("span",{key:0,class:T(["pos",{"is-top":r<3}])},n(d(r+1)),3)):l.key==="title"?(t(),o(f,{key:1},[w(s.id)?(t(),h(L,{key:0,to:w(s.id),class:"name"},{default:u(()=>[m(n(s.title),1)]),_:2},1032,["to"])):(t(),o("span",ve,n(s.title),1)),s.code?(t(),o("span",ye,n(s.code),1)):k("",!0)],64)):l.key==="views"?(t(),o("div",ke,[a("b",null,n(d(s.views)),1),a("span",me,[a("i",{style:V({width:`${C(s.views,j.value)}%`})},null,4)])])):k("",!0)]),_:1},8,["data-source","columns","locale"])]),a("section",we,[c[4]||(c[4]=a("h3",{class:"panel__title"},"پربازدیدترین برندها",-1)),y(P,{"data-source":i.value.topViewedBrands,columns:z("برند"),pagination:!1,locale:{emptyText:i.value.totals.views?"محصولات بازدیدشده در این بازه برند ندارند.":$.value},size:"small","row-key":"id",class:"table-scroll"},{bodyCell:u(({column:l,record:s,index:r})=>[l.key==="rank"?(t(),o("span",{key:0,class:T(["pos",{"is-top":r<3}])},n(d(r+1)),3)):l.key==="title"?(t(),o("span",he,n(s.title),1)):l.key==="views"?(t(),o("div",be,[a("b",null,n(d(s.views)),1),a("span",fe,[a("i",{style:V({width:`${C(s.views,F.value)}%`})},null,4)])])):k("",!0)]),_:1},8,["data-source","columns","locale"])])])]),_:1},8,["spinning"])]),_:1})}}}),Te=te(ge,[["__scopeId","data-v-ee7aeba6"]]);export{Te as default};