2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{o as G,ap as oe,bx as se,ac as re,bi as le,q as s,r,s as e,v as l,D as c,u as p,cL as ie,w as ce,cO as de,L as d,T as o,P as f,by as me,K as _e,O as u,bh as pe,bZ as ue,F as m,ae as w,d9 as P,da as R,cg as j,a1 as ge,G as E,t as A,bB as ve,cP as he,cJ as ye,bX as fe,ba as be,M as x,p as h}from"./.pnpm-Bie2Sx_u.js";import{v as ke}from"./stats-Be0WYYiy.js";import{_ as we}from"./index-BwhoO6F6.js";const xe={class:"performance-dashboard","element-loading-text":"正在汇总权限范围内的数据"},Ne={class:"dashboard-header"},De={class:"dashboard-heading"},$e={class:"dashboard-heading__icon"},Ce={class:"dashboard-title-row"},Se={class:"scope-badge"},ze={key:0},Fe={class:"dashboard-actions"},Me={key:0,class:"updated-at"},Ee={key:1,class:"dashboard-skeleton"},Ie={class:"performance-strip","aria-label":"业绩概览"},Le={class:"metric-card metric-card--primary"},Te={class:"metric-value metric-value--money"},Ve={class:"metric-card"},Be={class:"metric-value metric-value--money"},Oe={class:"metric-card"},Pe={class:"metric-label-row"},Re={class:"metric-value metric-value--money"},je={class:"metric-card metric-card--clock"},Ae={class:"metric-value metric-value--time"},Ge={class:"metric-foot"},Ue={class:"operating-grid","aria-label":"今日运营指标"},We={class:"metric-label"},qe={class:"metric-foot"},He={class:"dashboard-grid dashboard-grid--rankings"},Je={class:"dashboard-panel ranking-panel"},Ke={class:"panel-header"},Xe={key:0,class:"ranking-list"},Ze={class:"ranking-main"},Qe={class:"ranking-copy"},Ye={class:"ranking-meter","aria-hidden":"true"},et={class:"ranking-value"},tt={class:"dashboard-panel ranking-panel"},at={class:"panel-header"},nt={key:0,class:"ranking-list"},ot={class:"ranking-main"},st={class:"ranking-copy"},rt={class:"ranking-meter","aria-hidden":"true"},lt={class:"ranking-value ranking-value--money"},it={class:"dashboard-grid dashboard-grid--bottom"},ct={class:"dashboard-panel trend-panel"},dt={class:"panel-header panel-header--stack-mobile"},mt={class:"dashboard-panel target-panel"},_t={class:"panel-header"},pt={class:"panel-meta"},ut={class:"target-block"},gt={class:"target-copy"},vt={key:0},ht={key:1},yt={class:"target-block target-block--secondary"},ft={class:"target-copy"},bt={key:0,class:"target-empty-note"},kt={class:"dashboard-notes"},wt={key:3,class:"dashboard-empty"},xt=G({name:"performanceDashboardPage"}),Nt=G({...xt,setup(Dt){const I=()=>({scope:{key:"",scope_value:4,label:"",is_limited:!0,viewer_name:"",role_ids:[],role_names:[],department_names:[],visible_member_count:0},performance:{month_amount:0,month_compare_rate:null,month_compare_label:"",yesterday_amount:0,yesterday_compare_rate:null,yesterday_compare_label:"",personal_month_amount:0},today:{add_fans_count:0,appointment_total_count:0,interview_count:0,completed_order_count:0,completed_order_amount:0,paid_appointment_rate:0,interview_receive_rate:0},rankings:{appointments:{title:"实时挂号排行",kind:"assistant",scope_label:"",items:[]},performance:{title:"今日部门业绩排行",scope_label:"",items:[]}},trend:{date_range:[],dates:[],appointments:[],leads:[],orders:[]},target:{year_month:"",target_amount:0,completed_amount:0,completion_rate:null,personal_amount:0,personal_contribution_rate:null,department_count:0},meta:{generated_at:"",timezone:"",commission_note:"",rate_note:""}}),t=be(I()),b=x(!1),C=x(!1),k=x(""),S=x("appointments"),z=x(new Date);let F;const U=[{label:"挂号",value:"appointments"},{label:"进线",value:"leads"},{label:"诊单",value:"orders"}],W=h(()=>{const n=t.scope.role_names.length?t.scope.role_names.join("、"):"管理员",a=t.scope.department_names.length?t.scope.department_names.join("、"):"未绑定部门";return`${t.scope.viewer_name||"当前账号"},${n},${a}`}),q=h(()=>[{key:"fans",label:"今日加粉",value:v(t.today.add_fans_count),hint:"按企微新增客户事件统计"},{key:"appointments",label:"今日挂号",value:v(t.today.appointment_total_count),hint:"状态为已预约、已完成或改期,排除已取消"},{key:"orders",label:"今日接诊 / 诊单金额",value:"",hint:"按业务订单统计,排除取消、拒收和退款"},{key:"appointmentRate",label:"付费挂号率",value:N(t.today.paid_appointment_rate),hint:"付费挂号数 / 加粉数"},{key:"receiveRate",label:"面诊接诊率",value:N(t.today.interview_receive_rate),hint:"诊单数 / 面诊数"},{key:"interviews",label:"今日面诊",value:v(t.today.interview_count),hint:"状态为已完成的挂号"}]),H=h(()=>new Intl.DateTimeFormat("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(z.value)),J=h(()=>new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",weekday:"short"}).format(z.value)),K=h(()=>{const n=t.rankings.appointments.kind==="doctor"?"医生":"医助";return`${t.rankings.appointments.scope_label}内的${n}有效挂号数(不含已取消)`}),X=h(()=>Math.max(0,...t.rankings.appointments.items.map(n=>Number(n.count||0)))),Z=h(()=>Math.max(0,...t.rankings.performance.items.map(n=>Number(n.amount||0)))),Q=h(()=>{const a={appointments:{label:"挂号",data:t.trend.appointments},leads:{label:"进线",data:t.trend.leads},orders:{label:"诊单",data:t.trend.orders}}[S.value];return{animationDuration:320,tooltip:{trigger:"axis",valueFormatter:_=>`${v(_)} 条`},grid:{left:42,right:18,top:24,bottom:30,containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:t.trend.dates,axisLine:{lineStyle:{color:"#d9e0e7"}},axisLabel:{color:"#7d8996"}},yAxis:{type:"value",minInterval:1,splitLine:{lineStyle:{color:"#edf1f4"}},axisLabel:{color:"#7d8996"}},series:[{name:a.label,type:"line",smooth:.35,showSymbol:!0,symbolSize:7,data:a.data,lineStyle:{color:"#0f8f83",width:3},itemStyle:{color:"#0f8f83",borderColor:"#ffffff",borderWidth:2},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(15, 143, 131, 0.20)"},{offset:1,color:"rgba(15, 143, 131, 0.01)"}]}}}]}}),g=(n,a=2)=>`¥${new Intl.NumberFormat("zh-CN",{minimumFractionDigits:a,maximumFractionDigits:a}).format(Number(n||0))}`,v=n=>new Intl.NumberFormat("zh-CN",{maximumFractionDigits:0}).format(Number(n||0)),N=n=>n===null?"暂无":`${Number(n||0).toFixed(1)}%`,L=n=>`${n>=0?"+":""}${Number(n).toFixed(1)}%`,T=n=>n===null||n===0?"":n>0?"is-positive":"is-negative",V=(n,a)=>a<=0||n<=0?"0%":`${Math.max(6,Math.min(100,Number(n)/a*100))}%`,B=n=>n===null||!Number.isFinite(Number(n))?0:Math.max(0,Math.min(100,Number(n))),D=async()=>{b.value=!0,k.value="";try{const n=await ke();Object.assign(t,I(),n||{}),C.value=!0}catch(n){k.value=(n==null?void 0:n.msg)||(n==null?void 0:n.message)||"驾驶舱数据加载失败,请稍后重试"}finally{b.value=!1}};return oe(()=>{D(),F=setInterval(()=>{z.value=new Date},1e3)}),se(()=>{F&&clearInterval(F)}),(n,a)=>{const _=ce,M=_e,Y=pe,ee=ue,te=ge,$=ve,ae=he,O=fe,ne=le;return re((s(),r("div",xe,[e("header",Ne,[e("div",De,[e("div",$e,[l(_,null,{default:c(()=>[l(p(ie))]),_:1})]),e("div",null,[e("div",Ce,[a[1]||(a[1]=e("h1",null,"数据驾驶舱",-1)),e("span",Se,[l(_,null,{default:c(()=>[l(p(de))]),_:1}),d(" "+o(t.scope.label||"数据范围"),1)])]),e("p",null,[d(o(W.value)+" ",1),t.scope.visible_member_count>0?(s(),r("span",ze," ,当前可见 "+o(t.scope.visible_member_count)+" 位成员 ",1)):f("",!0)])])]),e("div",Fe,[t.meta.generated_at?(s(),r("div",Me," 数据更新于 "+o(t.meta.generated_at),1)):f("",!0),l(M,{icon:p(me),loading:b.value,onClick:D},{default:c(()=>[...a[2]||(a[2]=[d("刷新数据",-1)])]),_:1},8,["icon","loading"])])]),k.value?(s(),u(Y,{key:0,class:"dashboard-error",type:"error",closable:!1,"show-icon":"",title:k.value},{default:c(()=>[l(M,{size:"small",onClick:D},{default:c(()=>[...a[3]||(a[3]=[d("重新加载",-1)])]),_:1})]),_:1},8,["title"])):f("",!0),!C.value&&b.value?(s(),r("div",Ee,[l(ee,{rows:12,animated:""})])):C.value?(s(),r(m,{key:2},[e("section",Ie,[e("article",Le,[a[4]||(a[4]=e("div",{class:"metric-label"},"本月实时业绩",-1)),e("div",Te,o(g(t.performance.month_amount)),1),e("div",{class:w(["metric-foot",T(t.performance.month_compare_rate)])},[t.performance.month_compare_rate!==null?(s(),r(m,{key:0},[t.performance.month_compare_rate>=0?(s(),u(_,{key:0},{default:c(()=>[l(p(P))]),_:1})):(s(),u(_,{key:1},{default:c(()=>[l(p(R))]),_:1})),d(" "+o(t.performance.month_compare_label)+" "+o(L(t.performance.month_compare_rate)),1)],64)):(s(),r(m,{key:1},[d("上月同期暂无可比数据")],64))],2)]),e("article",Ve,[a[5]||(a[5]=e("div",{class:"metric-label"},"昨日新增业绩",-1)),e("div",Be,o(g(t.performance.yesterday_amount)),1),e("div",{class:w(["metric-foot",T(t.performance.yesterday_compare_rate)])},[t.performance.yesterday_compare_rate!==null?(s(),r(m,{key:0},[t.performance.yesterday_compare_rate>=0?(s(),u(_,{key:0},{default:c(()=>[l(p(P))]),_:1})):(s(),u(_,{key:1},{default:c(()=>[l(p(R))]),_:1})),d(" "+o(t.performance.yesterday_compare_label)+" "+o(L(t.performance.yesterday_compare_rate)),1)],64)):(s(),r(m,{key:1},[d("前一日暂无可比数据")],64))],2)]),e("article",Oe,[e("div",Pe,[a[6]||(a[6]=e("span",null,"本人本月业绩",-1)),l(te,{content:t.meta.commission_note,placement:"top"},{default:c(()=>[l(_,{class:"metric-help"},{default:c(()=>[l(p(j))]),_:1})]),_:1},8,["content"])]),e("div",Re,o(g(t.performance.personal_month_amount)),1),a[7]||(a[7]=e("div",{class:"metric-foot"},"仅统计当前登录账号",-1))]),e("article",je,[a[8]||(a[8]=e("div",{class:"metric-label"},"当前时间",-1)),e("div",Ae,o(H.value),1),e("div",Ge,o(J.value),1)])]),e("section",Ue,[(s(!0),r(m,null,E(q.value,i=>(s(),r("article",{key:i.key,class:"metric-card metric-card--compact"},[e("div",We,o(i.label),1),e("div",{class:w(["metric-value",{"metric-value--pair":i.key==="orders"}])},[i.key==="orders"?(s(),r(m,{key:0},[d(o(v(t.today.completed_order_count))+" ",1),a[9]||(a[9]=e("span",null,"/",-1)),d(" "+o(g(t.today.completed_order_amount)),1)],64)):(s(),r(m,{key:1},[d(o(i.value),1)],64))],2),e("div",qe,o(i.hint),1)]))),128))]),e("section",He,[e("article",Je,[e("div",Ke,[e("div",null,[e("h2",null,o(t.rankings.appointments.title),1),e("p",null,o(K.value),1)]),a[10]||(a[10]=e("span",{class:"panel-meta"},"实时",-1))]),t.rankings.appointments.items.length?(s(),r("div",Xe,[(s(!0),r(m,null,E(t.rankings.appointments.items,(i,y)=>(s(),r("div",{key:`appointment-${i.id}-${y}`,class:"ranking-row"},[e("span",{class:w(["ranking-index",{"is-top":y<2}])},o(y+1),3),e("div",Ze,[e("div",Qe,[e("strong",null,o(i.name||"未命名成员"),1),e("span",null,o(v(i.count))+" 个挂号",1)]),e("div",Ye,[e("span",{style:A({width:V(i.count,X.value)})},null,4)])]),e("b",et,o(v(i.count)),1)]))),128))])):(s(),u($,{key:1,"image-size":72,description:"当前数据范围内暂无挂号排行"}))]),e("article",tt,[e("div",at,[e("div",null,[e("h2",null,o(t.rankings.performance.title),1),e("p",null,o(t.rankings.performance.scope_label)+"内今日计入业绩的业务订单",1)]),a[11]||(a[11]=e("span",{class:"panel-meta"},"今日",-1))]),t.rankings.performance.items.length?(s(),r("div",nt,[(s(!0),r(m,null,E(t.rankings.performance.items,(i,y)=>(s(),r("div",{key:`performance-${i.id}-${y}`,class:"ranking-row"},[e("span",{class:w(["ranking-index",{"is-top":y<2}])},o(y+1),3),e("div",ot,[e("div",st,[e("strong",null,o(i.name||"未命名部门"),1),e("span",null,o(v(i.count))+" 个诊单",1)]),e("div",rt,[e("span",{style:A({width:V(i.amount,Z.value)})},null,4)])]),e("b",lt,o(g(i.amount)),1)]))),128))])):(s(),u($,{key:1,"image-size":72,description:"当前数据范围内暂无业务订单业绩"}))])]),e("section",it,[e("article",ct,[e("div",dt,[e("div",null,[a[12]||(a[12]=e("h2",null,"近 7 天数据趋势",-1)),e("p",null,o(t.trend.date_range.join(" 至 ")),1)]),l(ae,{modelValue:S.value,"onUpdate:modelValue":a[0]||(a[0]=i=>S.value=i),options:U},null,8,["modelValue"])]),t.trend.dates.length?(s(),u(p(ye),{key:0,class:"trend-chart",option:Q.value,autoresize:""},null,8,["option"])):(s(),u($,{key:1,"image-size":72,description:"暂无趋势数据"}))]),e("article",mt,[e("div",_t,[e("div",null,[a[13]||(a[13]=e("h2",null,"进度目标",-1)),e("p",null,o(t.target.year_month)+",按当前角色数据范围计算",1)]),e("span",pt,o(t.target.department_count)+" 个目标部门",1)]),e("div",ut,[e("div",gt,[e("div",null,[a[14]||(a[14]=e("span",null,"范围目标进度",-1)),t.target.target_amount>0?(s(),r("strong",vt,o(N(t.target.completion_rate)),1)):(s(),r("strong",ht,"未设置"))]),e("p",null,[d(" 已完成 "+o(g(t.target.completed_amount))+" ",1),t.target.target_amount>0?(s(),r(m,{key:0},[d(" ,目标 "+o(g(t.target.target_amount)),1)],64)):f("",!0)])]),l(O,{percentage:B(t.target.completion_rate),"show-text":!1,"stroke-width":12,color:"#0f8f83"},null,8,["percentage"])]),e("div",yt,[e("div",ft,[e("div",null,[a[15]||(a[15]=e("span",null,"本人业绩贡献",-1)),e("strong",null,o(N(t.target.personal_contribution_rate)),1)]),e("p",null," 本人 "+o(g(t.target.personal_amount))+",占当前范围已完成业绩 ",1)]),l(O,{percentage:B(t.target.personal_contribution_rate),"show-text":!1,"stroke-width":12,color:"#738196"},null,8,["percentage"])]),t.target.target_amount<=0?(s(),r("div",bt," 当前范围尚未设置本月部门目标,已完成业绩仍会正常统计。 ")):f("",!0)])]),e("footer",kt,[l(_,null,{default:c(()=>[l(p(j))]),_:1}),e("span",null,o(t.meta.rate_note),1)])],64)):k.value?(s(),r("div",wt,[l($,{description:"驾驶舱数据加载失败"},{default:c(()=>[l(M,{type:"primary",onClick:D},{default:c(()=>[...a[16]||(a[16]=[d("重新加载",-1)])]),_:1})]),_:1})])):f("",!0)])),[[ne,b.value]])}}}),zt=we(Nt,[["__scopeId","data-v-75711d0a"]]);export{zt as default};
|