|
|
import{n as e}from"./axios-CiYFffbI.js";import{I as t,N as n,Tt as r,V as i,Y as a,_ as o,d as s,f as c,i as l,it as u,kt as d,l as f,nt as p,p as m,u as h,ut as g,v as _,y as v,z as ee}from"./runtime-core.esm-bundler-CnFWH3R5.js";import{n as y}from"./http-LCi9aT1G.js";import{a as te,c as b,f as ne,i as x,n as re,o as ie,r as ae,u as S}from"./index-DXxLd6GV.js";import{o as C,r as w}from"./hikPdcClient-9YlD6z0w.js";var oe={class:`dashboard-page`},se={class:`dashboard-page__inner`},ce={class:`dash-bundle`,"aria-label":`数据统计`},le={class:`dash-core-pack`},ue={class:`dash-metric-card dash-metric-card--core`},de={class:`dash-metric-card__head`},fe={class:`dash-metric-card__icon`,"aria-hidden":`true`},pe={class:`dash-metric-card__body`},me={class:`dash-stat-grid dash-stat-grid--core`},he={class:`dash-stat-cell dash-stat-cell--violet`},ge={class:`dash-stat-cell__value`},_e={class:`dash-stat-cell dash-stat-cell--mint`},ve={class:`dash-stat-cell__value`},ye={class:`dash-stat-cell dash-stat-cell--sky`},T={class:`dash-stat-cell__value`},E={class:`dash-stat-cell__hint`},D={key:0,class:`dash-metric-card dash-metric-card--todo`},O={class:`dash-metric-card__head dash-metric-card__head--todo`},k={class:`dash-metric-card__icon dash-metric-card__icon--todo`,"aria-hidden":`true`},A={class:`dash-metric-card__body`},j={key:0,class:`dash-todo-sheet dash-todo-sheet--loading`},M={key:1,class:`dash-todo-sheet`},N={key:0,class:`dash-todo-sheet--empty-inner`},P={class:`dash-todo-placeholder`},be={class:`dash-todo-line__kind`},xe={class:`dash-todo-line__name`},Se={class:`dash-schedule-dual`},Ce={class:`dash-metric-card`},we={class:`dash-metric-card__head`},Te={class:`dash-metric-card__icon`,"aria-hidden":`true`},Ee={class:`dash-metric-card__body`},De={class:`dash-stat-grid dash-stat-grid--schedule-act`},Oe={class:`dash-stat-cell dash-stat-cell--rose`},ke={class:`dash-stat-cell__value`},Ae={class:`dash-stat-cell dash-stat-cell--violet`},je={class:`dash-stat-cell__value`},Me={class:`dash-stat-cell dash-stat-cell--amber`},Ne={class:`dash-stat-cell__value`},Pe={class:`dash-stat-cell dash-stat-cell--sky`},Fe={class:`dash-stat-cell__value`},Ie={class:`dash-stat-cell dash-stat-cell--mint`},Le={class:`dash-stat-cell__value`},Re={class:`dash-stat-cell dash-stat-cell--indigo`},ze={class:`dash-stat-cell__value`},Be={class:`dash-metric-card`},Ve={class:`dash-metric-card__head`},He={class:`dash-metric-card__icon dash-metric-card__icon--schedule-tg`,"aria-hidden":`true`},Ue={class:`dash-metric-card__body`},We={class:`dash-stat-grid dash-stat-grid--schedule-tg`},Ge={class:`dash-stat-cell dash-stat-cell--rose`},Ke={class:`dash-stat-cell__value`},qe={class:`dash-stat-cell dash-stat-cell--amber`},Je={class:`dash-stat-cell__value`},Ye={class:`dash-stat-cell dash-stat-cell--sky`},Xe={class:`dash-stat-cell__value`},Ze={class:`dash-stat-cell dash-stat-cell--mint`},Qe={class:`dash-stat-cell__value`},$e={class:`dash-stat-cell dash-stat-cell--violet dash-stat-cell--verify-rate`},et={class:`dash-stat-cell__value dash-stat-cell__value--pct`},tt={class:`dash-stat-cell__hint`},nt={class:`dash-rank-dual`},rt={class:`dash-metric-card dash-metric-card--rank`},it={class:`dash-metric-card__head`},at={class:`dash-metric-card__icon dash-metric-card__icon--rank-pub`,"aria-hidden":`true`},ot={class:`dash-metric-card__body dash-rank-card__body`},st={class:`dash-metric-card dash-metric-card--rank`},ct={class:`dash-metric-card__head`},lt={class:`dash-metric-card__icon dash-metric-card__icon--rank-live`,"aria-hidden":`true`},ut={class:`dash-metric-card__body dash-rank-card__body`},dt={class:`dash-venue-pc-bundle`},ft={class:`dash-metric-card dash-metric-card--venue-pc`},pt={class:`dash-metric-card__head`},mt={class:`dash-metric-card__icon dash-metric-card__icon--venue-pc`,"aria-hidden":`true`},ht={class:`dash-metric-card__body dash-metric-card__body--venue-pc`},gt={class:`dash-venue-pc-filters`},_t={key:1,class:`dash-venue-pc-table-wrap`},F=300,I=S(v({__name:`Dashboard`,setup(v){let S=b(),I=u(!1),L=u(!1),R=u(!1),z=u({scope:{role:``,venue_id:void 0,activity_id:void 0},summary:{activity_sessions:0,venues_count:0,ticket_grab_sessions:0,user_count:0,reservation_order_count:0},activity_schedule_counts:{total:0,total_sessions:0,not_started:0,ongoing:0,ended:0,published_venues_count:0},ticket_grab_schedule_counts:{total:0,not_started:0,ongoing:0,ended:0,verify_rate_pct:null,verified_people:0,booked_people:0},pending_audits:null,activity_publish_ranking:[],live_people_ranking:[],live_people_counting_ok:!1}),vt=f(()=>!!C()),B=u([]),V=u(!1),H=u(null),U=u(null),yt=[{title:`场馆ID`,dataIndex:`venueId`,minWidth:110,ellipsis:!0,tooltip:!0},{title:`场馆名称`,dataIndex:`venueName`,minWidth:140,ellipsis:!0,tooltip:!0},{title:`入馆总人数`,dataIndex:`enter`,minWidth:120}];function W(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function bt(e){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function xt(e){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate());return t.setDate(t.getDate()+6),t}function G(){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function K(e,t){return e.getTime()<=t.getTime()?e:t}function St(e){let t=G(),n,r;if(e===`week`){let e=bt(t),i=xt(e);n=W(e),r=W(K(i,t))}else if(e===`month`){let e=new Date(t.getFullYear(),t.getMonth(),1),i=new Date(t.getFullYear(),t.getMonth()+1,0);n=W(e),r=W(K(i,t))}else{let e=new Date(t.getFullYear(),0,1),i=new Date(t.getFullYear(),11,31);n=W(e),r=W(K(i,t))}B.value=[n,r]}function Ct(){let e=W(G());B.value=[e,e]}let q=f(()=>{let e=U.value;if(!e||e.code!==200)return[];let t=[],n=e.venuesRangeTotals;if(Array.isArray(n)&&n.length>0)t=n.map(e=>({venueId:e.venueId,venueName:e.venueName,enter:Number(e.enter)||0}));else{let n=e.venues;if(!Array.isArray(n)||n.length===0)return[];t=n.map(e=>({venueId:e.venueId,venueName:e.venueName,enter:Number(e.enter)||0}))}return t.sort((e,t)=>{let n=(Number(t.enter)||0)-(Number(e.enter)||0);return n===0?String(e.venueId).localeCompare(String(t.venueId),void 0,{numeric:!0}):n})});function wt(e){let t=Array.isArray(e.data)?e.data:[],n=0;for(let e of t)n+=Number(e.enter)||0;return[{venueId:`合计`,venueName:`—`,enter:n}]}function Tt(){let e=B.value;if(!Array.isArray(e)||e.length<2)return null;let t=String(e[0]??``).trim(),n=String(e[1]??``).trim();return!/^\d{4}-\d{2}-\d{2}$/.test(t)||!/^\d{4}-\d{2}-\d{2}$/.test(n)||n<t?null:{start:t,end:n}}async function J(t){if(!C())return;let n=Tt();if(!n){e.warning(`请选择合法的日期时间段(起止 yyyy-MM-dd)`);return}let{start:r,end:i}=n;V.value=!0,H.value=null;let a=t?.silentSuccess===!0;try{U.value=await w(r,i),U.value.code===200?a||e.success(`客流统计已刷新`):(H.value=U.value.message||`接口返回错误码 ${U.value.code}`,a||e.warning(H.value))}catch(t){U.value=null,H.value=(t&&typeof t==`object`&&`message`in t?String(t.message):String(t))||`客流接口请求失败`,e.error(H.value||`客流接口请求失败`)}finally{V.value=!1}}function Et(){J({silentSuccess:!1})}u([]),u(!1),p({eventId:void 0,date:void 0});let Y=u(null);f(()=>Y.value?.daily_verify_matrix?.date_labels??[]),f(()=>Y.value?.daily_verify_matrix?.rows??[]),u(!1);let Dt=f(()=>z.value.pending_audits?.activities.count??0),X=f(()=>Dt.value),Z=f(()=>z.value.pending_audits?.activities.items??[]),Q=f(()=>Z.value.length>0),Ot=f(()=>L.value||R.value),kt=f(()=>R.value?`暂无已退回活动`:`暂无待审核事项`),At=f(()=>R.value?`活动退回`:`活动审核`);function jt(){S.push({path:`/activities`,query:{audit_status:`pending`}})}function Mt(){S.push({path:`/activities`,query:{audit_status:`rejected`}})}function Nt(){R.value?Mt():jt()}let Pt=f(()=>{let e=z.value.ticket_grab_schedule_counts;return!e||e.booked_people<=0?`0%`:`${e.verify_rate_pct??0}%`}),Ft=f(()=>{let e=z.value.ticket_grab_schedule_counts;return`已核销 ${e?.verified_people??0} / 已约 ${e?.booked_people??0} 人`});async function It(){I.value=!0;try{let{data:e}=await y.get(`/dashboard/stats`),{live_people_counting_debug:t,...n}=e;n.live_people_counting_ok===!1&&console.warn(`[工作台] 客流统计接口异常`,t??{}),z.value={...z.value,...n,summary:e.summary??z.value.summary,activity_schedule_counts:{...z.value.activity_schedule_counts,...e.activity_schedule_counts??{}},ticket_grab_schedule_counts:{...z.value.ticket_grab_schedule_counts,...e.ticket_grab_schedule_counts??{}},pending_audits:e.pending_audits??null,activity_publish_ranking:Array.isArray(e.activity_publish_ranking)?e.activity_publish_ranking:z.value.activity_publish_ranking,live_people_ranking:Array.isArray(e.live_people_ranking)?e.live_people_ranking:z.value.live_people_ranking,live_people_counting_ok:typeof e.live_people_counting_ok==`boolean`?e.live_people_counting_ok:z.value.live_people_counting_ok}}catch(t){e.error(t?.response?.data?.message??`加载统计失败`)}finally{I.value=!1}}async function Lt(){let{data:e}=await y.get(`/me`);L.value=e?.full_admin_access===!0,R.value=e?.role===`venue_admin`}function $(e){St(e),J({silentSuccess:!0})}return n(async()=>{await Lt(),await It(),C()&&(Ct(),await J({silentSuccess:!0}))}),(e,n)=>{let u=i(`a-table-column`),f=i(`a-table`),p=i(`a-typography-text`),v=i(`a-range-picker`),y=i(`a-button`),b=i(`a-divider`),S=i(`a-space`),C=i(`a-alert`),w=i(`a-empty`),U=i(`a-spin`);return i(`a-tag`),i(`a-option`),i(`a-select`),i(`a-date-picker`),i(`a-card`),t(),m(`div`,oe,[h(`div`,se,[n[50]||=h(`header`,{class:`dashboard-page__header`},[h(`div`,{class:`dashboard-page__heading`},[h(`h1`,{class:`dashboard-page__title`},`工作台`),h(`span`,{class:`dashboard-page__subtitle`},`数据看板`)])],-1),h(`section`,ce,[h(`div`,{class:r([`dash-overview-dual`,{"dash-overview-dual--split":Ot.value}])},[h(`div`,le,[h(`article`,ue,[h(`header`,de,[h(`div`,fe,[_(g(x))]),n[6]||=h(`div`,{class:`dash-metric-card__head-main`},[h(`h2`,{class:`dash-metric-card__title`},`核心数据统计`)],-1)]),h(`div`,pe,[h(`div`,me,[h(`div`,he,[h(`div`,ge,d(z.value.summary.venues_count??0),1),n[7]||=h(`div`,{class:`dash-stat-cell__label`},`现有场馆`,-1)]),h(`div`,_e,[h(`div`,ve,d(z.value.summary.reservation_order_count??0),1),n[8]||=h(`div`,{class:`dash-stat-cell__label`},`总预约次数`,-1)]),h(`div`,ye,[h(`div`,T,d(z.value.summary.user_count),1),n[9]||=h(`div`,{class:`dash-stat-cell__label`},`用户数`,-1),h(`div`,E,d(R.value?`预约本场馆活动用户`:`预约用户`),1)])])])])]),L.value||R.value?(t(),m(`article`,D,[h(`header`,O,[h(`div`,k,[_(g(ie))]),n[10]||=h(`h2`,{class:`dash-metric-card__title dash-metric-card__title--inline`},`待办事项`,-1),h(`span`,{class:r([`dash-todo-count-badge`,{"dash-todo-count-badge--zero":X.value===0}])},d(X.value),3)]),h(`div`,A,[I.value&&z.value.pending_audits==null?(t(),m(`div`,j,[...n[11]||=[h(`span`,{class:`dash-todo-placeholder`},`加载中…`,-1)]])):(t(),m(`div`,M,[Q.value?(t(!0),m(l,{key:1},ee(Z.value,e=>(t(),m(`button`,{key:`pa-`+e.id,type:`button`,class:`dash-todo-line`,onClick:Nt},[h(`span`,be,d(At.value),1),h(`span`,xe,d(e.title),1),n[12]||=h(`span`,{class:`dash-todo-line__action`},`去处理`,-1)]))),128)):(t(),m(`div`,N,[h(`span`,P,d(kt.value),1)]))]))])])):c(``,!0)],2),h(`div`,Se,[h(`article`,Ce,[h(`header`,we,[h(`div`,Te,[_(g(ne))]),n[13]||=h(`div`,{class:`dash-metric-card__head-main`},[h(`h2`,{class:`dash-metric-card__title`},`活动统计`)],-1)]),h(`div`,Ee,[h(`div`,De,[h(`div`,Oe,[h(`div`,ke,d(z.value.activity_schedule_counts.total),1),n[14]||=h(`div`,{class:`dash-stat-cell__label`},`活动数`,-1)]),h(`div`,Ae,[h(`div`,je,d(z.value.activity_schedule_counts.total_sessions),1),n[15]||=h(`div`,{class:`dash-stat-cell__label`},`总场次`,-1)]),h(`div`,Me,[h(`div`,Ne,d(z.value.activity_schedule_counts.not_started),1),n[16]||=h(`div`,{class:`dash-stat-cell__label`},`未开始`,-1)]),h(`div`,Pe,[h(`div`,Fe,d(z.value.activity_schedule_counts.ongoing),1),n[17]||=h(`div`,{class:`dash-stat-cell__label`},`进行中`,-1)]),h(`div`,Ie,[h(`div`,Le,d(z.value.activity_schedule_counts.ended),1),n[18]||=h(`div`,{class:`dash-stat-cell__label`},`已结束`,-1)]),h(`div`,Re,[h(`div`,ze,d(z.value.activity_schedule_counts.published_venues_count??0),1),n[19]||=h(`div`,{class:`dash-stat-cell__label`},`已发布活动场馆`,-1)])])])]),h(`article`,Be,[h(`header`,Ve,[h(`div`,He,[_(g(ae))]),n[20]||=h(`div`,{class:`dash-metric-card__head-main`},[h(`h2`,{class:`dash-metric-card__title`},`抢票统计`)],-1)]),h(`div`,Ue,[h(`div`,We,[h(`div`,Ge,[h(`div`,Ke,d(z.value.ticket_grab_schedule_counts.total),1),n[21]||=h(`div`,{class:`dash-stat-cell__label`},`总场数`,-1)]),h(`div`,qe,[h(`div`,Je,d(z.value.ticket_grab_schedule_counts.not_started),1),n[22]||=h(`div`,{class:`dash-stat-cell__label`},`未开始`,-1)]),h(`div`,Ye,[h(`div`,Xe,d(z.value.ticket_grab_schedule_counts.ongoing),1),n[23]||=h(`div`,{class:`dash-stat-cell__label`},`进行中`,-1)]),h(`div`,Ze,[h(`div`,Qe,d(z.value.ticket_grab_schedule_counts.ended),1),n[24]||=h(`div`,{class:`dash-stat-cell__label`},`已结束`,-1)]),h(`div`,$e,[h(`div`,et,d(Pt.value),1),n[25]||=h(`div`,{class:`dash-stat-cell__label`},`核销率`,-1),h(`div`,tt,d(Ft.value),1)])])])])]),h(`div`,nt,[h(`article`,rt,[h(`header`,it,[h(`div`,at,[_(g(te))]),n[26]||=h(`div`,{class:`dash-metric-card__head-main`},[h(`h2`,{class:`dash-metric-card__title`},`活动发布排行`)],-1)]),h(`div`,ot,[_(f,{class:`dash-table dash-rank-table`,data:z.value.activity_publish_ranking,loading:I.value,pagination:!1,scroll:{y:F},"row-key":`venue_id`,size:`small`},{columns:a(()=>[_(u,{title:`#`,width:52},{cell:a(({rowIndex:e})=>[o(d(e+1),1)]),_:1}),_(u,{title:`场馆名称`,"data-index":`venue_name`,ellipsis:!0,tooltip:!0}),_(u,{title:`发布活动数`,"data-index":`published_count`,width:108,align:`right`}),_(u,{title:`发布场次数`,"data-index":`published_sessions_count`,width:108,align:`right`})]),_:1},8,[`data`,`loading`,`scroll`])])]),h(`article`,st,[h(`header`,ct,[h(`div`,lt,[_(g(re))]),n[27]||=h(`div`,{class:`dash-metric-card__head-main`},[h(`h2`,{class:`dash-metric-card__title`},`实时人数排行`)],-1)]),h(`div`,ut,[_(f,{class:`dash-table dash-rank-table`,data:z.value.live_people_ranking,loading:I.value,pagination:!1,scroll:{y:F},"row-key":`venue_id`,size:`small`},{columns:a(()=>[_(u,{title:`#`,width:52},{cell:a(({rowIndex:e})=>[o(d(e+1),1)]),_:1}),_(u,{title:`场馆名称`,"data-index":`venue_name`,ellipsis:!0,tooltip:!0}),_(u,{title:`在馆人数`,"data-index":`live_count`,width:100,align:`right`})]),_:1},8,[`data`,`loading`,`scroll`])])])]),h(`div`,dt,[h(`article`,ft,[h(`header`,pt,[h(`div`,mt,[_(g(x))]),n[28]||=h(`div`,{class:`dash-metric-card__head-main`},[h(`h2`,{class:`dash-metric-card__title`},`各场馆人数统计`)],-1)]),h(`div`,ht,[vt.value?(t(),m(l,{key:1},[h(`div`,gt,[_(S,{wrap:``,size:`small`},{default:a(()=>[n[34]||=h(`span`,{class:`dash-venue-pc-filters__label`},`时间段`,-1),_(v,{modelValue:B.value,"onUpdate:modelValue":n[0]||=e=>B.value=e,format:`YYYY-MM-DD`,"value-format":`YYYY-MM-DD`,"exchange-time":!1,"allow-clear":``,style:{width:`260px`},size:`small`},null,8,[`modelValue`]),_(y,{type:`primary`,size:`small`,loading:V.value,onClick:Et},{default:a(()=>[...n[30]||=[o(`查询`,-1)]]),_:1},8,[`loading`]),_(b,{direction:`vertical`,class:`dash-venue-pc-filters__vdiv`}),_(y,{size:`small`,disabled:V.value,onClick:n[1]||=e=>$(`week`)},{default:a(()=>[...n[31]||=[o(`本周`,-1)]]),_:1},8,[`disabled`]),_(y,{size:`small`,disabled:V.value,onClick:n[2]||=e=>$(`month`)},{default:a(()=>[...n[32]||=[o(`本月`,-1)]]),_:1},8,[`disabled`]),_(y,{size:`small`,disabled:V.value,onClick:n[3]||=e=>$(`year`)},{default:a(()=>[...n[33]||=[o(`本年`,-1)]]),_:1},8,[`disabled`])]),_:1})]),_(U,{loading:V.value},{default:a(()=>[H.value?(t(),s(C,{key:0,type:`warning`,"show-icon":``,style:{"margin-bottom":`10px`}},{default:a(()=>[o(d(H.value),1)]),_:1})):c(``,!0),q.value.length?(t(),m(`div`,_t,[_(f,{class:`dash-table dash-venue-pc-table`,"row-key":`venueId`,columns:yt,data:q.value,pagination:!1,size:`small`,"table-layout-fixed":``,scroll:{y:260},summary:wt},null,8,[`data`])])):!V.value&&!H.value?(t(),s(w,{key:2,description:`暂无数据,可调时间段或检查客流归档与场馆映射`})):c(``,!0)]),_:1},8,[`loading`])],64)):(t(),s(p,{key:0,type:`warning`},{default:a(()=>[...n[29]||=[o(` 未配置 VITE_PEOPLE_COUNTING_URL 时无法加载该项。请在构建环境变量中配置海康客流 people-counting 完整接口地址。 `,-1)]]),_:1}))])])])]),c(``,!0)])])}}}),[[`__scopeId`,`data-v-dddc3ab0`]]);export{I as default}; |