2 lines
24 KiB
JavaScript
2 lines
24 KiB
JavaScript
import{o as t,c as e,w as s,t as a,u as i,e as n,r as l,n as o,a as r,i as c,l as d,m as h,F as u,z as f,d as p,p as m,G as b,f as g,g as y,h as x,s as _,A as v}from"./index-CJxdOECQ.js";import{u as S,p as I,t as k,_ as C,a as P,o as $,q as T,n as w,d as z,e as L,v as B,r as D,m as A,b as O}from"./button.BC3KjxGU.js";import{R as N}from"./parent-map.DJ2qhm0x.js";import{_ as M,a as F}from"./tag.BCmt9OVd.js";import{a as E}from"./api.U2gW6MFc.js";const X={badgeProps:{type:Object,default:()=>({})},disabled:Boolean,icon:{type:[String,Object]},label:{type:String,default:""},lazy:Boolean,panel:{type:String},value:{type:[String,Number]}};const j=`${I}-tab-panel`,R=S({name:j,options:{styleIsolation:"shared",virtualHost:!0},externalClasses:[`${I}-class`],mixins:[function(t,e={}){const s=e.indexKey||"index";return{inject:{[t]:{default:null}},data:()=>({}),computed:{[s](){const e=this;return e.bindRelation(),e[t]?e[t].children.indexOf(this):null}},watch:{disableBindRelation(t){t||this.bindRelation()}},created(){},mounted(){this.bindRelation()},beforeUnmount(){this.onBeforeMount()},methods:{bindRelation(){var e,s,a;if(!this[t]||this[t].children&&-1!==this[t].children.indexOf(this))return;const i=[...this[t].children||[],this];this[t].children=i,null==(e=this.innerAfterLinked)||e.call(this,this),null==(a=(s=this[t]).innerAfterLinked)||a.call(s,this)},onBeforeMount(){var e,s,a,i;const n=this;n[t]&&(n[t].children=n[t].children.filter((t=>t!==n)),null==(s=(e=this[t]).innerAfterUnLinked)||s.call(e,this),null==(a=this.innerAfterUnLinked)||a.call(this,this),null==(i=null==n?void 0:n.destroyCallback)||i.call(n))}}}}(N.TabPanel)],props:{...X},data:()=>({prefix:I,classPrefix:j,active:!1,hide:!0,id:"",hasActivated:!1,tools:k}),watch:{label:"update",badgeProps:{handler(){this.update()},deep:!0},disabled:"update",icon:"update",panel:"update",value:"update",lazy:"update"},methods:{setParent(t){this[N.TabPanel]=t,t.children.includes(this)||t.children.push(this),t.innerAfterLinked(this)},setId(t){this.id=t},getComputedName(){return null!=this.value?`${this.value}`:`${this.dataIndex}`},update(){var t;null==(t=this[N.TabPanel])||t.updateTabs()},render(t,e){this.initialized=this.initialized||t,t&&!this.hasActivated&&(this.hasActivated=!0),this.active=t,this.hide=!e.animation&&!t}}});const Y=C(R,[["render",function(d,h,u,f,p,m){const b=c;return!d.lazy||d.hasActivated?(t(),e(b,{key:0,id:d.id,class:o(d.tClass+" "+d.classPrefix+" "+(d.active?d.classPrefix+"--active":d.classPrefix+"--inactive")),style:r(d.tools._style([d.customStyle,d.hide?"display: none":""])),"aria-role":"tabpanel"},{default:s((()=>[d.panel?(t(),e(b,{key:0},{default:s((()=>[a(i(d.panel),1)])),_:1})):n("",!0),l(d.$slots,"default",{},void 0,!0),l(d.$slots,"panel",{},void 0,!0)])),_:3},8,["id","class","style"])):n("",!0)}],["__scopeId","data-v-a6b1077e"]]),W={color:{type:String,default:""},content:{type:String,default:""},count:{type:[String,Number],default:0},dot:Boolean,maxCount:{type:Number,default:99},offset:{type:Array},shape:{type:String,default:"circle",validator:t=>!t||["circle","square","bubble","ribbon","ribbon-right","ribbon-left","triangle-right","triangle-left"].includes(t)},showZero:Boolean,size:{type:String,default:"medium",validator:t=>!t||["medium","large"].includes(t)}},V=function(t){return t.indexOf("px")>0||t.indexOf("rpx")>0||t.indexOf("em")>0||t.indexOf("rem")>0||t.indexOf("%")>0||t.indexOf("vh")>0||t.indexOf("vm")>0},Z=`${I}-badge`,U=$("badge");const H=C(S({name:Z,options:{styleIsolation:"shared"},externalClasses:[`${I}-class`,`${I}-class-count`,`${I}-class-content`],props:{...W},data:()=>({prefix:I,classPrefix:Z,value:"",labelID:"",descriptionID:"",tools:k,useOuterClass:!1}),computed:{hasChild(){var t;return!!(null==(t=this.$slots)?void 0:t.default)}},mounted(){const t=U();this.labelID=`${t}_label`,this.descriptionID=`${t}_description`,this.checkForActualContent()},methods:{getBadgeValue:function(t){return t.dot?"":isNaN(t.count)||isNaN(t.maxCount)?t.count:parseInt(t.count,10)>t.maxCount?`${t.maxCount}+`:t.count},getBadgeStyles:function(t){var e,s;let a="";return t.color&&(a+=`background:${t.color};`),(null==(e=t.offset)?void 0:e[0])&&(a+=`left: calc(100% + ${V(t.offset[0].toString())?t.offset[0]:`${t.offset[0]}px`});`),(null==(s=t.offset)?void 0:s[1])&&(a+=`top:${V(t.offset[1].toString())?t.offset[1]:`${t.offset[1]}px`};`),a},getBadgeInnerClass:function(t){const e=t.classPrefix;return[`${e}--basic`,t.dot?`${e}--dot`:"",`${e}--${t.size}`,`${e}--${t.shape}`,t.dot?"":`${e}--count`].join(" ")},isShowBadge:function(t){return!!t.dot||!(!t.showZero&&!isNaN(t.count)&&0===parseInt(t.count,10))&&null!=t.count},checkForActualContent(){if(!this.content&&["ribbon","ribbon-right","ribbon-left","triangle-right","triangle-left"].includes(this.shape))return P(this,`.${Z}__content`).then((t=>{const e=t.width>0||t.height>0;this.useOuterClass=!e}));this.useOuterClass=!1}}}),[["render",function(p,m,b,g,y,x){const _=f,v=c;return t(),e(v,{style:r(p.tools._style([p.customStyle])),class:o(p.classPrefix+" "+(p.useOuterClass?p.classPrefix+"__"+p.shape+"-outer":"")+p.tClass),"aria-labelledby":p.labelID,"aria-describedby":p.descriptionID,"aria-role":p.ariaRole||"option"},{default:s((()=>[d(v,{id:p.labelID,class:o(p.tools.cls(p.classPrefix+"__content",[["empty",!p.content&&!p.hasChild]])+" "+p.tClassContent),"aria-hidden":!0},{default:s((()=>[p.content?(t(),e(_,{key:1,class:o(p.classPrefix+"__content-text")},{default:s((()=>[a(i(p.content),1)])),_:1},8,["class"])):l(p.$slots,"default",{key:0,class:o(p.classPrefix+"__content-slot")},void 0,!0)])),_:3},8,["id","class"]),p.isShowBadge({dot:p.dot,count:p.count,showZero:p.showZero})||null===p.count?(t(),e(v,{key:0,id:p.descriptionID,"aria-hidden":!0,"aria-label":p.ariaLabel||p.tools.getBadgeAriaLabel({dot:p.dot,count:p.count,maxCount:p.maxCount}),class:o([p.getBadgeInnerClass({classPrefix:p.classPrefix,dot:p.dot,size:p.size,shape:p.shape,count:p.count})+" "+p.prefix+"-has-count ",p.tClassCount]),style:r(p.tools._style([p.getBadgeStyles({color:p.color,offset:p.offset})]))},{default:s((()=>[d(v,{class:o(p.classPrefix+"__count")},{default:s((()=>[p.isShowBadge({dot:p.dot,count:p.count,showZero:p.showZero})?(t(),h(u,{key:0},[a(i(p.getBadgeValue({dot:p.dot,count:p.count,maxCount:p.maxCount})),1)],64)):n("",!0),l(p.$slots,"count",{},void 0,!0)])),_:3},8,["class"])])),_:3},8,["id","aria-label","class","style"])):n("",!0)])),_:3},8,["style","class","aria-labelledby","aria-describedby","aria-role"])}],["__scopeId","data-v-7637c4cc"]]),q={container:{type:Function},disabled:Boolean,offsetTop:{type:[String,Number],default:0},zIndex:{type:Number,default:99},onScroll:{type:Function,default:()=>({})}};const G=/scroll|auto|overlay/i,K=(new class{constructor(){this.listeners=new Map,this.emitted=new Map,this.onceListeners=new Map}on(t,e){const s=this.listeners.get(t)||[];s.push(e),this.listeners.set(t,s),this.emitted.has(t)&&e(...this.emitted.get(t))}once(t,e){if(this.emitted.has(t))return void e(...this.emitted.get(t));const s=(...a)=>{e(...a),this.off(t,s)},a=this.onceListeners.get(t)||new Map;a.set(e,s),this.onceListeners.set(t,a),this.on(t,s)}emit(t,...e){this.emitted.set(t,e);[...this.listeners.get(t)||[]].forEach((t=>t(...e)))}off(t,e){if(e){const s=this.onceListeners.get(t);if(s&&s.has(e)){const a=s.get(e);return this._removeListener(t,a),void s.delete(e)}this._removeListener(t,e)}else this.listeners.delete(t),this.onceListeners.delete(t),this.emitted.delete(t)}_removeListener(t,e){const s=this.listeners.get(t);if(!s)return;const a=s.indexOf(e);a>-1&&(s.splice(a,1),0===s.length&&this.listeners.delete(t))}},function(t){const e=T();if(!e)return;const{pageScroller:s}=e;null==s||s.forEach((e=>{"function"==typeof e&&e(t)}))});const J=`${I}-sticky`,Q=`.${J}`;const tt=C(S({name:J,options:{styleIsolation:"shared"},externalClasses:[`${I}-class`,`${I}-class-content`],mixins:[((t="onScroll",e=!0)=>(!1,{mounted(){this._scroller=function(t,e){void 0===e&&(e=window);let s=t;for(;s&&"HTML"!==s.tagName&&"BODY"!==s.tagName&&1===s.nodeType&&s!==e;){const{overflowY:t}=window.getComputedStyle(s);if(G.test(t))return s;s=s.parentNode}return e}(this.$el),this._scroller&&this._scroller.addEventListener("scroll",this._bindScroller);const t=T();t&&(Array.isArray(t.pageScroller)?t.pageScroller.push(this._bindScroller):t.pageScroller="function"==typeof t.onPageScroll?[t.onPageScroll.bind(t),this._bindScroller]:[this._bindScroller],t.onPageScroll=K)},beforeUnMount(){var t;this._scroller&&this._scroller.removeEventListener("scroll",this._bindScroller);const e=T();e&&(e.pageScroller=(null==(t=e.pageScroller)?void 0:t.filter((t=>t!==this._bindScroller)))||[])},methods:{_bindScroller(e){var s;let a;return a=null==(s=this[t])?void 0:s.call(this,e.target),a}}}))()],props:{...q},data:()=>({prefix:I,classPrefix:J,containerStyle:"",contentStyle:"",tools:k}),watch:{offsetTop:"onScroll",disabled:"onScroll",container:"onScroll"},mounted(){this.onScroll()},methods:{onScroll(t){const{scrollTop:e}=t||{},{container:s,offsetTop:a,disabled:i}=this;i?this.setDataAfterDiff({isFixed:!1,transform:0}):(this.scrollTop=e||this.scrollTop,"function"!=typeof s?P(this,Q).then((t=>{t&&(a>=t.top?(this.setDataAfterDiff({isFixed:!0,height:t.height}),this.transform=0):this.setDataAfterDiff({isFixed:!1}))})):Promise.all([P(this,Q),this.getContainerRect()]).then((([t,e])=>{t&&e&&(a+t.height>e.height+e.top?this.setDataAfterDiff({isFixed:!1,transform:e.height-t.height}):a>=t.top?this.setDataAfterDiff({isFixed:!0,height:t.height,transform:0}):this.setDataAfterDiff({isFixed:!1,transform:0}))})))},setDataAfterDiff(t){const{offsetTop:e}=this,{containerStyle:s,contentStyle:a}=this,{isFixed:i,height:n,transform:l}=t;w().then((()=>{let t="",o="";if(i&&(t+=`height:${n}px;`,o+=`position:fixed;top:${e}px;left:0;right:0;`),l){const t=`translate3d(0, ${l}px, 0)`;o+=`-webkit-transform:${t};transform:${t};`}s===t&&a===o||(this.containerStyle=t,this.contentStyle=o),this.$emit("scroll",{scrollTop:this.scrollTop,isFixed:i})}))},getContainerRect(){const t=this.container();return new Promise((e=>t.boundingClientRect(e).exec()))}}}),[["render",function(a,i,n,h,u,f){const p=c;return t(),e(p,{class:o(a.classPrefix+" "+a.tClass),style:r(a.tools._style(["z-index:"+a.zIndex,a.containerStyle,a.customStyle]))},{default:s((()=>[d(p,{class:o(a.classPrefix+"__content "+a.tClassContent),style:r(a.tools._style(["z-index:"+a.zIndex,a.contentStyle]))},{default:s((()=>[l(a.$slots,"default",{},void 0,!0)])),_:3},8,["class","style"])])),_:3},8,["class","style"])}],["__scopeId","data-v-ed32c77d"]]),et={animation:{type:Object},bottomLineMode:{type:String,default:"fixed",validator:t=>!t||["fixed","auto","full"].includes(t)},showBottomLine:{type:Boolean,default:!0},spaceEvenly:{type:Boolean,default:!0},split:{type:Boolean,default:!0},sticky:Boolean,stickyProps:{type:Object},swipeable:{type:Boolean,default:!0},theme:{type:String,default:"line",validator:t=>!t||["line","tag","card"].includes(t)},value:{type:[String,Number]},defaultValue:{type:[String,Number]},onChange:{type:Function,default:()=>({})},onClick:{type:Function,default:()=>({})},onScroll:{type:Function,default:()=>({})}},st={data:()=>({}),methods:{resetTouchStatus(){this.direction="",this.deltaX=0,this.deltaY=0,this.offsetX=0,this.offsetY=0},touchStart(t){this.resetTouchStatus();const[e]=t.touches;this.startX=e.clientX,this.startY=e.clientY},touchMove(t){const[e]=t.touches;this.deltaX=e.clientX-this.startX,this.deltaY=e.clientY-this.startY,this.offsetX=Math.abs(this.deltaX),this.offsetY=Math.abs(this.deltaY),this.direction=((t,e)=>t>e&&t>10?"horizontal":e>t&&e>10?"vertical":"")(this.offsetX,this.offsetY)}}};const at=`${I}-tabs`,it=$("tabs");var nt;const lt=C(S({name:at,options:{styleIsolation:"shared"},controlledProps:[{key:"value",event:"change"}],externalClasses:[`${I}-class`,`${I}-class-item`,`${I}-class-active`,`${I}-class-track`,`${I}-class-content`],mixins:[st,(nt=N.TabPanel,{provide(){return{[nt]:this}},data:()=>({})})],components:{TSticky:tt,TBadge:H,TIcon:z},props:{...et},emits:["change","scroll","error","click"],watch:{value:{handler(t){this.dataValue=t},immediate:!0},dataValue(t){t!==this.getCurrentName()&&this.setCurrentIndexByName(t)}},created(){this.children=this.children||[]},mounted(){w().then((()=>{this.setTrack()})),P(this,`.${at}`).then((t=>{this.containerWidth=t.width})),this.tabID=it()},data(){return{prefix:I,classPrefix:at,tabs:[],currentLabels:[],currentIndex:-1,trackOption:{lineWidth:0,distance:0,isInit:!0},offset:0,scrollLeft:0,tabID:"",placement:"top",tools:k,dataValue:L(this.value,this.defaultValue)}},methods:{trackStyle:function(t){return t.distance||t.lineWidth?k._style({"-webkit-transform":`translateX(${t.distance}px)`,transform:`translateX(${t.distance}px)`,"transition-duration":t.isInit?"0":"0.3s",width:`${t.lineWidth}px`,opacity:1}):""},animate:function(t){return t.duration?k._style({"transition-duration":`${t.duration}s`,transform:`translate3d( ${-100*t.currentIndex}%,0, 0)`}):""},innerAfterLinked(t){this.initChildId(),t.dataIndex=this.children.length-1,this.updateTabs()},innerAfterUnlinked(t){this.children=this.children.filter((e=>e.index!==t.dataIndex)),this.updateTabs((()=>this.setTrack())),this.initChildId()},initChildId(){this.children.forEach(((t,e)=>{t.setId(`${this.tabID}_panel_${e}`)}))},onScroll(t={}){const{scrollLeft:e}=t.detail||{};this.scrollLeft=e},updateTabs(t){const{children:e}=this,s=e.map((t=>{const{label:e,badgeProps:s,disabled:a,icon:i,panel:n,value:l,lazy:o}=t;return{label:e,badgeProps:s,disabled:a,icon:i,panel:n,value:l,lazy:o}}));s.forEach((t=>{"string"==typeof t.icon&&(t.icon={name:t.icon})})),this.tabs=s,"function"==typeof t&&setTimeout(t,33),this.setCurrentIndexByName(this.dataValue)},setCurrentIndexByName(t){const{children:e}=this,s=e.findIndex((e=>e.getComputedName()===`${t}`));s>-1&&this.setCurrentIndex(s)},setCurrentIndex(t){if(t<=-1||t>=this.children.length)return;const e=[];this.children.forEach(((s,a)=>{const i=t===a;i===s.active&&s.initialized||s.render(i,this),e.push(s.label)}));const{currentIndex:s,currentLabels:a}=this;s===t&&a.join("")===e.join("")||(this.currentIndex=t,this.currentLabels=e,setTimeout((()=>{this.setTrack()}),33))},getCurrentName(){if(this.children){const t=this.children[this.currentIndex];if(t)return t.getComputedName()}},calcScrollOffset:(t,e,s,a)=>a+e-.5*t+s/2,getTabHeight(){return P(this,`.${at}`)},getTrackSize(){const{bottomLineMode:t}=this,e={fixed:`.${I}-tabs__track`,auto:`.${I}-tabs__item--active .${I}-tabs__item-inner`,full:`.${I}-tabs__item--active`};return new Promise(((s,a)=>{this.trackWidth?s(this.trackWidth):P(this,e[t]||e.fixed).then((t=>{t&&s(t.width)})).catch(a)}))},async setTrack(){const{children:t}=this;if(!t)return;const{currentIndex:e}=this;if(!(e<=-1))try{const t=await P(this,`.${I}-tabs__item`,!0),s=t[e];if(!s)return;let a=0,i=0,n=0;if(t.forEach((t=>{a<e&&(i+=t.width,a+=1),n+=t.width})),this.containerWidth){const t=this.calcScrollOffset(this.containerWidth,s.left,s.width,this.scrollLeft),e=n-this.containerWidth;this.offset=Math.min(Math.max(t,0),e)}else this._hasObserved||(this._hasObserved=!0,B(this,`.${at}`).then((()=>this.setTrack())));const l=await this.getTrackSize();"line"===this.theme&&(i+=(s.width-l)/2);const o=void 0===this.previousIndex;(o||this.previousIndex!==e||this.lastDistance!==i)&&(this.previousIndex=e,this.trackOption={lineWidth:l,distance:i,isInit:o},this.lastDistance=i)}catch(s){this.$emit("error",s)}},onTabTap(t){const{index:e}=t.currentTarget.dataset;this.changeIndex(e)},onTouchStart(t){this.swipeable&&this.touchStart(t)},onTouchMove(t){this.swipeable&&this.touchMove(t)},onTouchEnd(){if(!this.swipeable)return;const{direction:t,deltaX:e,offsetX:s}=this;if("horizontal"===t&&s>=50){const t=this.getAvailableTabIndex(e);-1!==t&&this.changeIndex(t)}},onTouchScroll(t){this._trigger("scroll",t)},changeIndex(t){const e=this.tabs[t],{value:s,label:a}=e;(null==e?void 0:e.disabled)||t===this.currentIndex||this._trigger("change",{value:s,label:a}),this._trigger("click",{value:s,label:a})},getAvailableTabIndex(t){const e=t>0?-1:1,{currentIndex:s,tabs:a}=this,i=a.length;for(let n=e;s+e>=0&&s+e<i;n+=e){const t=s+n;if(!(t>=0&&t<i&&a[t]))return s;if(!a[t].disabled)return t}return-1},getBadgeCustomStyle(t,e){return t.disabled?"--td-badge-content-text-color: var(--td-tab-item-disabled-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, .26))))":this.currentIndex===e?"--td-badge-content-text-color: var(--td-tab-item-active-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));":""},getIconCustomStyle:t=>k._style([{fontSize:"var(--td-tab-icon-size, 18px)",marginRight:"calc(var(--td-spacer, 8px) / 4)"},t.icon.style||""])}}),[["render",function(f,g,y,x,_,v){const S=D(p("t-icon"),z),I=D(p("t-badge"),H),k=c,C=b,P=D(p("t-sticky"),tt);return t(),e(k,{style:r(f.tools._style([f.customStyle])),class:o(f.tools.cls(f.classPrefix,[f.placement])+" "+f.tClass)},{default:s((()=>[d(P,{"t-class":f.tools.cls(f.classPrefix+"__sticky",[f.placement]),disabled:!f.sticky,"z-index":f.stickyProps&&f.stickyProps.zIndex||1,"offset-top":f.stickyProps&&f.stickyProps.offsetTop||0,container:f.stickyProps&&f.stickyProps.container,onScroll:f.onTouchScroll},{default:s((()=>[d(k,{class:o(f.tools.cls(f.classPrefix+"__wrapper",[f.theme]))},{default:s((()=>[d(C,{class:o(f.tools.cls(f.classPrefix+"__scroll",[f.placement,["split",f.split]])),enhanced:"","enable-flex":"","scroll-left":f.offset,"scroll-x":!0,"scroll-anchoring":"","scroll-with-animation":"","enable-passive":"","show-scrollbar":!1,type:"list",onScroll:f.onScroll},{default:s((()=>[d(k,{class:o(f.tools.cls(f.classPrefix+"__nav",[f.placement,["evenly",f.spaceEvenly]])),"aria-role":"tablist"},{default:s((()=>[(t(!0),h(u,null,m(f.tabs,((l,r)=>(t(),e(k,{key:r,"data-index":r,class:o(f.tools.cls(f.classPrefix+"__item",[f.theme,["evenly",f.spaceEvenly],f.placement,["disabled",l.disabled],["active",f.currentIndex===r]])+" "+(f.currentIndex===r?f.tClassActive:"")+" "+f.tClassItem),"aria-role":"tab","aria-controls":f.tabID+"_panel_"+r,"aria-selected":f.currentIndex===r,"aria-disabled":l.disabled,"aria-label":f.ariaLabel||(l.badgeProps.dot||l.badgeProps.count?l.label+f.tools.getBadgeAriaLabel({...l.badgeProps}):""),onClick:f.onTabTap},{default:s((()=>[d(k,{class:o(f.tools.cls(f.classPrefix+"__item-inner",[f.theme,["active",f.currentIndex===r]])),"aria-hidden":l.badgeProps.dot||l.badgeProps.count},{default:s((()=>[l.icon?(t(),e(S,{key:0,"t-class":f.classPrefix+"__icon","custom-style":f.getIconCustomStyle(l),prefix:l.icon.prefix,name:l.icon.name,size:l.icon.size,color:l.icon.color,"aria-hidden":!!l.icon.ariaHidden,"aria-label":l.icon.ariaLabel,"aria-role":l.icon.ariaRole,onClick:t=>l.icon.click||""},null,8,["t-class","custom-style","prefix","name","size","color","aria-hidden","aria-label","aria-role","onClick"])):n("",!0),l.badgeProps?(t(),e(I,{key:1,color:l.badgeProps.color||"",content:l.label,count:l.badgeProps.count||0,dot:l.badgeProps.dot||!1,"max-count":l.badgeProps.maxCount||99,offset:l.badgeProps.offset||[],shape:l.badgeProps.shape||"circle","show-zero":l.badgeProps.showZero||!1,size:l.badgeProps.size||"medium","t-class":f.tools.cls(f.classPrefix+"__badge",[["disabled",l.disabled],["active",f.currentIndex===r]]),"custom-style":f.getBadgeCustomStyle(l,r),"t-class-content":l.badgeProps.tClassContent,"t-class-count":l.badgeProps.tClassCount},null,8,["color","content","count","dot","max-count","offset","shape","show-zero","size","t-class","custom-style","t-class-content","t-class-count"])):(t(),h(u,{key:2},[a(i(l.label),1)],64))])),_:2},1032,["class","aria-hidden"]),"card"==f.theme&&f.currentIndex-1==r?(t(),e(k,{key:0,class:o(f.classPrefix+"__item-prefix")},null,8,["class"])):n("",!0),"card"==f.theme&&f.currentIndex+1==r?(t(),e(k,{key:1,class:o(f.classPrefix+"__item-suffix")},null,8,["class"])):n("",!0)])),_:2},1032,["data-index","class","aria-controls","aria-selected","aria-disabled","aria-label","onClick"])))),128)),"line"==f.theme&&f.showBottomLine?(t(),e(k,{key:0,class:o(f.tools.cls(f.classPrefix+"__track",[f.placement])+" "+f.tClassTrack),style:r(f.trackStyle(f.trackOption))},null,8,["class","style"])):n("",!0)])),_:1},8,["class"])])),_:1},8,["class","scroll-left","onScroll"])])),_:1},8,["class"])])),_:1},8,["t-class","disabled","z-index","offset-top","container","onScroll"]),l(f.$slots,"middle",{},void 0,!0),d(k,{class:o(f.tools.cls(f.classPrefix+"__content",[["animated",f.animation]])),onTouchstart:f.onTouchStart,onTouchmove:f.onTouchMove,onTouchend:f.onTouchEnd,onTouchcancel:f.onTouchEnd},{default:s((()=>[d(k,{class:o(f.classPrefix+"__content-inner "+f.tClassContent),style:r(f.animate({duration:f.animation&&f.animation.duration,currentIndex:f.currentIndex}))},{default:s((()=>[l(f.$slots,"default",{},void 0,!0)])),_:3},8,["class","style"])])),_:3},8,["class","onTouchstart","onTouchmove","onTouchend","onTouchcancel"])])),_:3},8,["style","class"])}],["__scopeId","data-v-98155ae0"]]),ot=C(g({__name:"appointments",setup(l){const o=y("all"),r=y([]),b=y(!1);x((()=>{g()}));const g=async()=>{b.value=!0;try{const t={};"all"!==o.value&&(t.status=o.value),r.value=await E.appointments.getList(t)}catch(t){console.error("加载预约失败",t)}finally{b.value=!1}},S=t=>{const e="string"==typeof t?t:(null==t?void 0:t.value)||"all";o.value=e,g()},I=t=>({pending:"待确认",confirmed:"已确认",completed:"已完成",cancelled:"已取消"}[t]||t),k=t=>{if(!t)return"";try{return t.replace("T"," ").split("+")[0]}catch(e){return console.error("Date format error:",e,t),t}},C=t=>{const e=(t.split("T")[1]||t).split("+")[0].split("Z")[0],[s,a]=e.split(":");return`${s}:${a}`};return(l,y)=>{const x=D(p("t-tab-panel"),Y),P=D(p("t-tabs"),lt),$=c,T=D(p("t-loading"),A),w=D(p("t-empty"),M),z=D(p("t-tag"),F),L=f,B=D(p("t-button"),O);return t(),e($,{class:"container"},{default:s((()=>[d($,{class:"tabs"},{default:s((()=>[d(P,{value:o.value,onChange:S},{default:s((()=>[d(x,{value:"all",label:"全部"}),d(x,{value:"pending",label:"待确认"}),d(x,{value:"confirmed",label:"已确认"}),d(x,{value:"completed",label:"已完成"}),d(x,{value:"cancelled",label:"已取消"})])),_:1},8,["value"])])),_:1}),d($,{class:"appointments-list"},{default:s((()=>[b.value?(t(),e(T,{key:0,loading:""})):0===r.value.length?(t(),e($,{key:1,class:"empty-state"},{default:s((()=>[d(w,{description:"暂无预约记录"})])),_:1})):(t(),e($,{key:2},{default:s((()=>[(t(!0),h(u,null,m(r.value,(l=>(t(),e($,{key:l.id,class:"appointment-card"},{default:s((()=>[d($,{class:"appointment-header"},{default:s((()=>[d($,{class:"appointment-status"},{default:s((()=>{return[d(z,{theme:(t=l.status,{pending:"warning",confirmed:"success",completed:"primary",cancelled:"default"}[t]||"default"),size:"small"},{default:s((()=>[a(i(I(l.status)),1)])),_:2},1032,["theme"])];var t})),_:2},1024),d($,{class:"appointment-date"},{default:s((()=>[a(i(k(l.created_at)),1)])),_:2},1024)])),_:2},1024),d($,{class:"appointment-body"},{default:s((()=>[d($,{class:"appointment-row"},{default:s((()=>[d(L,{class:"row-label"},{default:s((()=>[a("时间段:")])),_:1}),d(L,{class:"row-value"},{default:s((()=>[a(i(l.time_slot?l.time_slot.date.split("T")[0]:"")+" "+i(l.time_slot?C(l.time_slot.start_time):"")+" - "+i(l.time_slot?C(l.time_slot.end_time):""),1)])),_:2},1024)])),_:2},1024),d($,{class:"appointment-row"},{default:s((()=>[d(L,{class:"row-label"},{default:s((()=>[a("人数:")])),_:1}),d(L,{class:"row-value"},{default:s((()=>[a(i(l.people_count)+"人",1)])),_:2},1024)])),_:2},1024)])),_:2},1024),"pending"===l.status?(t(),e($,{key:0,class:"appointment-footer"},{default:s((()=>[d(B,{class:"btn-outline",size:"small",theme:"danger",variant:"outline",onClick:t=>(t=>{_({title:"确认取消",content:"确定要取消这个预约吗?",success:async e=>{if(e.confirm)try{await E.appointments.cancel(t.id),v({title:"取消成功",icon:"success"}),g()}catch(s){console.error("取消预约失败",s)}}})})(l)},{default:s((()=>[a(" 取消预约 ")])),_:2},1032,["onClick"])])),_:2},1024)):n("",!0)])),_:2},1024)))),128))])),_:1}))])),_:1})])),_:1})}}}),[["__scopeId","data-v-a1715542"]]);export{ot as default};
|