import{r as _,e as P,o as l,c as n,a as t,t as c,f as R,F as b,g as y,i as w,h as q,E as V,u as j,n as x}from"./index-gTPnkE6J.js";import{a as H,r as L,b as T}from"./modules-WNnkeNp8.js";import{u as U}from"./user-CV-Xe0d9.js";import{_ as Y}from"./_plugin-vue_export-helper-DlAUqK2U.js";const G={class:"kiosk-page"},J={class:"kiosk-header"},K={class:"header-left"},O={class:"header-right"},Q={class:"kiosk-body",style:{display:"flex",gap:"32px"}},W={style:{flex:"0 0 440px"}},X={style:{background:"#FFF","border-radius":"20px",padding:"24px","box-shadow":"0 4px 16px rgba(0,0,0,0.06)"}},Z={class:"cal-nav"},ee={class:"nav-title"},te={class:"cal-week-row"},ae={class:"cal-grid-big",style:{gap:"6px"}},se=["onClick"],le={class:"cell-num",style:{"font-size":"22px"}},ne={key:0,class:"cell-count",style:{"font-size":"12px"}},oe={style:{flex:"1"}},ie={key:0},ce={style:{"font-size":"24px","font-weight":"700",color:"#1A6FB5","margin-bottom":"16px"}},de={style:{"font-size":"20px",color:"#718096","margin-bottom":"10px"}},re={key:0,class:"slot-btn-grid",style:{"grid-template-columns":"repeat(3,1fr)"}},ue=["onClick"],ve={class:"slot-time",style:{"font-size":"22px"}},pe={class:"slot-remain"},_e={key:1,class:"slot-btn-grid",style:{"grid-template-columns":"repeat(3,1fr)",gap:"12px"}},he=["onClick"],be={class:"slot-time",style:{"font-size":"22px"}},ye={class:"slot-remain",style:{"font-size":"16px"}},me={key:1,style:{"text-align":"center",padding:"60px 0",color:"#A0AEC0","font-size":"22px"}},fe={key:2,style:{"text-align":"center",padding:"60px 0",color:"#A0AEC0","font-size":"22px"}},ge={key:0,style:{padding:"20px 48px",background:"#FFF","box-shadow":"0 -4px 16px rgba(0,0,0,0.05)",display:"flex","justify-content":"center"}},xe=["disabled"],ke={__name:"index",setup(Ce){const k=q(),D=j(),z=U(),F=k.query.appointment_id||"",C=k.query.application_id||"",r=_(new Date().getFullYear()),d=_(new Date().getMonth()+1),m=_([]),u=_(""),v=_([]),p=_(null),h=_(!1);function f(){const s=new Date(r.value,d.value-1,1).getDay(),o=new Date(r.value,d.value,0).getDate(),e=new Date;e.setHours(0,0,0,0);const a=[];for(let i=0;i(e.slot_data||[]).forEach(a=>{o[a.date]=(o[a.date]||0)+a.available_count})),m.value.forEach(e=>{e.date&&(e.available=o[e.date]||0)})}catch{}}function E(){d.value--,d.value<1&&(d.value=12,r.value--),u.value="",v.value=[],f(),g()}function $(){d.value++,d.value>12&&(d.value=1,r.value++),u.value="",v.value=[],f(),g()}function A(s){u.value=s.date,p.value=null,N()}async function N(){try{const s=await T({exam_application_ids:[Number(C)],start_date:u.value});v.value=[],(s.data.resources||[]).forEach(o=>{o.periods&&v.value.push(...o.periods)})}catch{v.value=[]}}function S(s){p.value=s.plan_id}function M(s){p.value=s.id}async function B(){h.value=!0;try{await L({appointment_id:Number(F),plan_id:Number(p.value),cancel_reason:"患者主动改约"}),V.success("改约成功"),D.push("/my-appointments")}catch{}h.value=!1}return P(()=>{f(),g()}),(s,o)=>(l(),n("div",G,[t("div",J,[t("div",K,[t("button",{class:"back-btn",onClick:o[0]||(o[0]=e=>s.$router.back())},"← 返回"),o[1]||(o[1]=t("span",{class:"header-title"},"改约",-1))]),t("div",O,c(R(z).patientName),1)]),t("div",Q,[t("div",W,[t("div",X,[t("div",Z,[t("button",{class:"nav-btn",onClick:E},"◀"),t("span",ee,c(r.value)+"年"+c(d.value)+"月",1),t("button",{class:"nav-btn",onClick:$},"▶")]),t("div",te,[(l(),n(b,null,y(["日","一","二","三","四","五","六"],e=>t("span",{key:e,class:"cal-w"},c(e),1)),64))]),t("div",ae,[(l(!0),n(b,null,y(m.value,(e,a)=>(l(),n("div",{key:a,class:x(["cal-cell",{disabled:!e.date||e.past,"has-plan":e.available>0&&!e.past,selected:u.value===e.date}]),style:{"font-size":"20px"},onClick:i=>e.date&&!e.past&&e.available>0&&A(e)},[t("span",le,c(e.day),1),e.available>0&&!e.past?(l(),n("span",ne,"余"+c(e.available),1)):w("",!0)],10,se))),128))])])]),t("div",oe,[u.value&&v.value.length>0?(l(),n("div",ie,[t("div",ce,c(u.value)+" 可预约时段",1),(l(!0),n(b,null,y(v.value,e=>(l(),n("div",{key:e.period_id,style:{"margin-bottom":"20px"}},[t("div",de,c(e.time_range),1),e.slots?(l(),n("div",_e,[(l(!0),n(b,null,y(e.slots,a=>(l(),n("div",{key:a.id,class:x(["slot-btn",{disabled:!a.enable,selected:p.value===a.id}]),style:{padding:"20px 12px"},onClick:i=>a.enable&&M(a)},[t("div",be,c(a.time),1),t("div",ye,c(a.enable?"可约":"已满"),1)],10,he))),128))])):(l(),n("div",re,[t("div",{class:x(["slot-btn",{disabled:!e.enable,selected:p.value===e.plan_id}]),onClick:a=>e.enable&&S(e)},[t("div",ve,c(e.time_range),1),t("div",pe,c(e.enable?`余 ${e.remain_count||0}`:"已满"),1)],10,ue)]))]))),128))])):u.value?(l(),n("div",me,"该日期暂无可用号源")):(l(),n("div",fe,"请在左侧选择日期"))])]),p.value?(l(),n("div",ge,[t("button",{class:"big-btn big-btn-primary",style:{width:"480px"},disabled:h.value,onClick:B},c(h.value?"提交中...":"确认改约"),9,xe)])):w("",!0)]))}},Ee=Y(ke,[["__scopeId","data-v-efba26bc"]]);export{Ee as default};