"use strict";const e=require("../../common/vendor.js"),t=require("../../utils/api.js");if(!Array){(e.resolveComponent("t-tab-panel")+e.resolveComponent("t-tabs")+e.resolveComponent("t-loading")+e.resolveComponent("t-empty")+e.resolveComponent("t-tag")+e.resolveComponent("t-button"))()}Math||((()=>"../../uni_modules/tdesign-uniapp/components/tab-panel/tab-panel.js")+(()=>"../../uni_modules/tdesign-uniapp/components/tabs/tabs.js")+(()=>"../../uni_modules/tdesign-uniapp/components/loading/loading.js")+(()=>"../../uni_modules/tdesign-uniapp/components/empty/empty.js")+(()=>"../../uni_modules/tdesign-uniapp/components/tag/tag.js")+(()=>"../../uni_modules/tdesign-uniapp/components/button/button.js"))();const n=e.defineComponent({__name:"appointments",setup(n){const a=e.ref("all"),l=e.ref([]),o=e.ref(!1);e.onMounted((()=>{s()}));const s=async()=>{o.value=!0;try{const e={};"all"!==a.value&&(e.status=a.value),l.value=await t.api.appointments.getList(e)}catch(e){console.error("加载预约失败",e)}finally{o.value=!1}},i=e=>{const t="string"==typeof e?e:(null==e?void 0:e.value)||"all";a.value=t,s()},p=e=>({pending:"warning",confirmed:"success",completed:"primary",cancelled:"default"}[e]||"default"),u=e=>{if(!e)return"";try{return e.replace("T"," ").split("+")[0]}catch(t){return console.error("Date format error:",t,e),e}},r=e=>{const t=(e.split("T")[1]||e).split("+")[0].split("Z")[0],[n,a]=t.split(":");return`${n}:${a}`};return(n,c)=>e.e({a:e.p({value:"all",label:"全部"}),b:e.p({value:"pending",label:"待确认"}),c:e.p({value:"confirmed",label:"已确认"}),d:e.p({value:"completed",label:"已完成"}),e:e.p({value:"cancelled",label:"已取消"}),f:e.o(i),g:e.p({value:a.value}),h:o.value},o.value?{i:e.p({loading:!0})}:0===l.value.length?{k:e.p({description:"暂无预约记录"})}:{l:e.f(l.value,((n,a,l)=>{return e.e({a:e.t((o=n.status,{pending:"待确认",confirmed:"已确认",completed:"已完成",cancelled:"已取消"}[o]||o)),b:"a1715542-8-"+l,c:e.p({theme:p(n.status),size:"small"}),d:e.t(u(n.created_at)),e:e.t(n.time_slot?n.time_slot.date.split("T")[0]:""),f:e.t(n.time_slot?r(n.time_slot.start_time):""),g:e.t(n.time_slot?r(n.time_slot.end_time):""),h:e.t(n.people_count),i:"pending"===n.status},"pending"===n.status?{j:e.o((a=>(n=>{e.index.showModal({title:"确认取消",content:"确定要取消这个预约吗？",success:async a=>{if(a.confirm)try{await t.api.appointments.cancel(n.id),e.index.showToast({title:"取消成功",icon:"success"}),s()}catch(l){console.error("取消预约失败",l)}}})})(n)),n.id),k:"a1715542-9-"+l,l:e.p({size:"small",theme:"danger",variant:"outline"})}:{},{m:n.id});var o}))},{j:0===l.value.length})}}),a=e._export_sfc(n,[["__scopeId","data-v-a1715542"]]);wx.createPage(a);
