1 |
- import{c as K,d as j,b9 as G,ay as we,e as A,a as i,bg as be,r as $,bh as Te,o as ke,a2 as ge,n as ne,a4 as oe,bi as Se,ak as Q,m as de,t as F,b as Me,bj as ie,w as te,bk as xe,U as Be,aA as ae,bl as Ce,h as Ae,N as fe,C as Re,k as Ye,ar as pe,ao as Pe,ac as E,q as Oe,x as me,y as Fe,W as Ee,V as he,Q as Ie,A as q,a7 as He,D as Ne}from"./index-7a2f1d19.js";import{s as y}from"./index.module-57f6d7f3.js";import{M as We}from"./index-a36a7624.js";import{M as _e}from"./index-e47c30fb.js";import{u as $e}from"./use-refs-9c01f536.js";import{g as je}from"./utils-80acdcee.js";import{L as Le}from"./index-d83968dc.js";import"./index-23d1a3b3.js";import"./index-dd020c38.js";import"./index-1ec8d9dd.js";import"./Picker-351d76b2.js";import"./use-tab-status-15a4d13f.js";const[Ve,D,I]=K("calendar"),ze=e=>I("monthTitle",e.getFullYear(),e.getMonth()+1);function re(e,n){const r=e.getFullYear(),d=n.getFullYear();if(r===d){const l=e.getMonth(),v=n.getMonth();return l===v?0:l>v?1:-1}return r>d?1:-1}function R(e,n){const r=re(e,n);if(r===0){const d=e.getDate(),l=n.getDate();return d===l?0:d>l?1:-1}return r}const J=e=>new Date(e),ve=e=>Array.isArray(e)?e.map(J):J(e);function ce(e,n){const r=J(e);return r.setDate(r.getDate()+n),r}const se=e=>ce(e,-1),ye=e=>ce(e,1),le=()=>{const e=new Date;return e.setHours(0,0,0,0),e};function Ue(e){const n=e[0].getTime();return(e[1].getTime()-n)/(1e3*60*60*24)+1}const[qe]=K("calendar-day");var Ge=j({name:qe,props:{item:G(Object),color:String,index:Number,offset:we(0),rowHeight:String},emits:["click"],setup(e,{emit:n,slots:r}){const d=A(()=>{var o;const{item:m,index:T,color:B,offset:x,rowHeight:H}=e,p={height:H};if(m.type==="placeholder")return p.width="100%",p;if(T===0&&(p.marginLeft=`${100*x/7}%`),B)switch(m.type){case"end":case"start":case"start-end":case"multiple-middle":case"multiple-selected":p.background=B;break;case"middle":p.color=B;break}return x+(((o=m.date)==null?void 0:o.getDate())||1)>28&&(p.marginBottom=0),p}),l=()=>{e.item.type!=="disabled"&&n("click",e.item)},v=()=>{const{topInfo:o}=e.item;if(o||r["top-info"])return i("div",{class:D("top-info")},[r["top-info"]?r["top-info"](e.item):o])},h=()=>{const{bottomInfo:o}=e.item;if(o||r["bottom-info"])return i("div",{class:D("bottom-info")},[r["bottom-info"]?r["bottom-info"](e.item):o])},f=()=>{const{item:o,color:m,rowHeight:T}=e,{type:B,text:x}=o,H=[v(),x,h()];return B==="selected"?i("div",{class:D("selected-day"),style:{width:T,height:T,background:m}},[H]):H};return()=>{const{type:o,className:m}=e.item;return o==="placeholder"?i("div",{class:D("day"),style:d.value},null):i("div",{role:"gridcell",style:d.value,class:[D("day",o),m],tabindex:o==="disabled"?void 0:-1,onClick:l},[f()])}}});const[Qe]=K("calendar-month"),Je={date:G(Date),type:String,color:String,minDate:G(Date),maxDate:G(Date),showMark:Boolean,rowHeight:ne,formatter:Function,lazyRender:Boolean,currentDate:[Date,Array],allowSameDay:Boolean,showSubtitle:Boolean,showMonthTitle:Boolean,firstDayOfWeek:Number};var Ke=j({name:Qe,props:Je,emits:["click"],setup(e,{emit:n,slots:r}){const[d,l]=be(),v=$(),h=$(),f=Te(h),o=A(()=>ze(e.date)),m=A(()=>ke(e.rowHeight)),T=A(()=>{const s=e.date.getDay();return e.firstDayOfWeek?(s+7-e.firstDayOfWeek)%7:s}),B=A(()=>je(e.date.getFullYear(),e.date.getMonth()+1)),x=A(()=>d.value||!e.lazyRender),H=()=>o.value,p=s=>{const w=k=>e.currentDate.some(g=>R(g,k)===0);if(w(s)){const k=se(s),g=ye(s),S=w(k),t=w(g);return S&&t?"multiple-middle":S?"end":t?"start":"multiple-selected"}return""},N=s=>{const[w,k]=e.currentDate;if(!w)return"";const g=R(s,w);if(!k)return g===0?"start":"";const S=R(s,k);return e.allowSameDay&&g===0&&S===0?"start-end":g===0?"start":S===0?"end":g>0&&S<0?"middle":""},L=s=>{const{type:w,minDate:k,maxDate:g,currentDate:S}=e;if(R(s,k)<0||R(s,g)>0)return"disabled";if(S===null)return"";if(Array.isArray(S)){if(w==="multiple")return p(s);if(w==="range")return N(s)}else if(w==="single")return R(s,S)===0?"selected":"";return""},W=s=>{if(e.type==="range"){if(s==="start"||s==="end")return I(s);if(s==="start-end")return`${I("start")}/${I("end")}`}},V=()=>{if(e.showMonthTitle)return i("div",{class:D("month-title")},[r["month-title"]?r["month-title"]({date:e.date,text:o.value}):o.value])},z=()=>{if(e.showMark&&x.value)return i("div",{class:D("month-mark")},[e.date.getMonth()+1])},U=A(()=>{const s=Math.ceil((B.value+T.value)/7);return Array(s).fill({type:"placeholder"})}),_=A(()=>{const s=[],w=e.date.getFullYear(),k=e.date.getMonth();for(let g=1;g<=B.value;g++){const S=new Date(w,k,g),t=L(S);let a={date:S,type:t,text:g,bottomInfo:W(t)};e.formatter&&(a=e.formatter(a)),s.push(a)}return s}),Y=A(()=>_.value.filter(s=>s.type==="disabled")),X=(s,w)=>{if(v.value){const k=oe(v.value),g=U.value.length,t=(Math.ceil((w.getDate()+T.value)/7)-1)*k.height/g;Se(s,k.top+t+s.scrollTop-oe(s).top)}},Z=(s,w)=>i(Ge,{item:s,index:w,color:e.color,offset:T.value,rowHeight:m.value,onClick:k=>n("click",k)},Q(r,["top-info","bottom-info"])),ee=()=>i("div",{ref:v,role:"grid",class:D("days")},[z(),(x.value?_:U).value.map(Z)]);return ge({getTitle:H,getHeight:()=>f.value,setVisible:l,scrollToDate:X,disabledDays:Y}),()=>i("div",{class:D("month"),ref:h},[V(),ee()])}});const[Xe]=K("calendar-header");var Ze=j({name:Xe,props:{date:Date,title:String,subtitle:String,showTitle:Boolean,showSubtitle:Boolean,firstDayOfWeek:Number},emits:["clickSubtitle"],setup(e,{slots:n,emit:r}){const d=()=>{if(e.showTitle){const f=e.title||I("title"),o=n.title?n.title():f;return i("div",{class:D("header-title")},[o])}},l=f=>r("clickSubtitle",f),v=()=>{if(e.showSubtitle){const f=n.subtitle?n.subtitle({date:e.date,text:e.subtitle}):e.subtitle;return i("div",{class:D("header-subtitle"),onClick:l},[f])}},h=()=>{const{firstDayOfWeek:f}=e,o=I("weekdays"),m=[...o.slice(f,7),...o.slice(0,f)];return i("div",{class:D("weekdays")},[m.map(T=>i("span",{class:D("weekday")},[T]))])};return()=>i("div",{class:D("header")},[d(),v(),h()])}});const et={show:Boolean,type:de("single"),title:String,color:String,round:F,readonly:Boolean,poppable:F,maxRange:Me(null),position:de("bottom"),teleport:[String,Object],showMark:F,showTitle:F,formatter:Function,rowHeight:ne,confirmText:String,rangePrompt:String,lazyRender:F,showConfirm:F,defaultDate:[Date,Array],allowSameDay:Boolean,showSubtitle:F,closeOnPopstate:F,showRangePrompt:F,confirmDisabledText:String,closeOnClickOverlay:F,safeAreaInsetTop:Boolean,safeAreaInsetBottom:F,minDate:{type:Date,validator:ie,default:le},maxDate:{type:Date,validator:ie,default:()=>{const e=le();return new Date(e.getFullYear(),e.getMonth()+6,e.getDate())}},firstDayOfWeek:{type:ne,default:0,validator:e=>e>=0&&e<=6}};var tt=j({name:Ve,props:et,emits:["select","confirm","unselect","monthShow","overRange","update:show","clickSubtitle"],setup(e,{emit:n,slots:r}){const d=(t,a=e.minDate,c=e.maxDate)=>R(t,a)===-1?a:R(t,c)===1?c:t,l=(t=e.defaultDate)=>{const{type:a,minDate:c,maxDate:u,allowSameDay:C}=e;if(t===null)return t;const M=le();if(a==="range"){Array.isArray(t)||(t=[]);const P=d(t[0]||M,c,C?u:se(u)),b=d(t[1]||M,C?c:ye(c));return[P,b]}return a==="multiple"?Array.isArray(t)?t.map(P=>d(P)):[d(M)]:((!t||Array.isArray(t))&&(t=M),d(t))};let v;const h=$(),f=$({text:"",date:void 0}),o=$(l()),[m,T]=$e(),B=A(()=>e.firstDayOfWeek?+e.firstDayOfWeek%7:0),x=A(()=>{const t=[],a=new Date(e.minDate);a.setDate(1);do t.push(new Date(a)),a.setMonth(a.getMonth()+1);while(re(a,e.maxDate)!==1);return t}),H=A(()=>{if(o.value){if(e.type==="range")return!o.value[0]||!o.value[1];if(e.type==="multiple")return!o.value.length}return!o.value}),p=()=>o.value,N=()=>{const t=Ce(h.value),a=t+v,c=x.value.map((b,O)=>m.value[O].getHeight()),u=c.reduce((b,O)=>b+O,0);if(a>u&&t>0)return;let C=0,M;const P=[-1,-1];for(let b=0;b<x.value.length;b++){const O=m.value[b];C<=a&&C+c[b]>=t&&(P[1]=b,M||(M=O,P[0]=b),m.value[b].showed||(m.value[b].showed=!0,n("monthShow",{date:O.date,title:O.getTitle()}))),C+=c[b]}x.value.forEach((b,O)=>{const ue=O>=P[0]-1&&O<=P[1]+1;m.value[O].setVisible(ue)}),M&&(f.value={text:M.getTitle(),date:M.date})},L=t=>{ae(()=>{x.value.some((a,c)=>re(a,t)===0?(h.value&&m.value[c].scrollToDate(h.value,t),!0):!1),N()})},W=()=>{if(!(e.poppable&&!e.show))if(o.value){const t=e.type==="single"?o.value:o.value[0];ie(t)&&L(t)}else ae(N)},V=()=>{e.poppable&&!e.show||(ae(()=>{v=Math.floor(oe(h).height)}),W())},z=(t=l())=>{o.value=t,W()},U=t=>{const{maxRange:a,rangePrompt:c,showRangePrompt:u}=e;return a&&Ue(t)>+a?(u&&fe(c||I("rangePrompt",a)),n("overRange"),!1):!0},_=()=>{var t;return n("confirm",(t=o.value)!=null?t:ve(o.value))},Y=(t,a)=>{const c=u=>{o.value=u,n("select",ve(u))};if(a&&e.type==="range"&&!U(t)){c([t[0],ce(t[0],+e.maxRange-1)]);return}c(t),a&&!e.showConfirm&&_()},X=(t,a,c)=>{var u;return(u=t.find(C=>R(a,C.date)===-1&&R(C.date,c)===-1))==null?void 0:u.date},Z=A(()=>m.value.reduce((t,a)=>{var c,u;return t.push(...(u=(c=a.disabledDays)==null?void 0:c.value)!=null?u:[]),t},[])),ee=t=>{if(e.readonly||!t.date)return;const{date:a}=t,{type:c}=e;if(c==="range"){if(!o.value){Y([a]);return}const[u,C]=o.value;if(u&&!C){const M=R(a,u);if(M===1){const P=X(Z.value,u,a);if(P){const b=se(P);R(u,b)===-1?Y([u,b]):Y([a])}else Y([u,a],!0)}else M===-1?Y([a]):e.allowSameDay&&Y([a,a],!0)}else Y([a])}else if(c==="multiple"){if(!o.value){Y([a]);return}const u=o.value,C=u.findIndex(M=>R(M,a)===0);if(C!==-1){const[M]=u.splice(C,1);n("unselect",J(M))}else e.maxRange&&u.length>=+e.maxRange?fe(e.rangePrompt||I("rangePrompt",e.maxRange)):Y([...u,a])}else Y(a,!0)},s=t=>n("update:show",t),w=(t,a)=>{const c=a!==0||!e.showSubtitle;return i(Ke,Ae({ref:T(a),date:t,currentDate:o.value,showMonthTitle:c,firstDayOfWeek:B.value},Q(e,["type","color","minDate","maxDate","showMark","formatter","rowHeight","lazyRender","showSubtitle","allowSameDay"]),{onClick:ee}),Q(r,["top-info","bottom-info","month-title"]))},k=()=>{if(r.footer)return r.footer();if(e.showConfirm){const t=r["confirm-text"],a=H.value,c=a?e.confirmDisabledText:e.confirmText;return i(Re,{round:!0,block:!0,type:"primary",color:e.color,class:D("confirm"),disabled:a,nativeType:"button",onClick:_},{default:()=>[t?t({disabled:a}):c||I("confirm")]})}},g=()=>i("div",{class:[D("footer"),{"van-safe-area-bottom":e.safeAreaInsetBottom}]},[k()]),S=()=>i("div",{class:D()},[i(Ze,{date:f.value.date,title:e.title,subtitle:f.value.text,showTitle:e.showTitle,showSubtitle:e.showSubtitle,firstDayOfWeek:B.value,onClickSubtitle:t=>n("clickSubtitle",t)},Q(r,["title","subtitle"])),i("div",{ref:h,class:D("body"),onScroll:N},[x.value.map(w)]),g()]);return te(()=>e.show,V),te(()=>[e.type,e.minDate,e.maxDate],()=>z(l(o.value))),te(()=>e.defaultDate,(t=null)=>{o.value=t,W()}),ge({reset:z,scrollToDate:L,getSelectedDate:p}),xe(V),()=>e.poppable?i(Be,{show:e.show,class:D("popup"),round:e.round,position:e.position,closeable:e.showTitle||e.showSubtitle,teleport:e.teleport,closeOnPopstate:e.closeOnPopstate,safeAreaInsetTop:e.safeAreaInsetTop,closeOnClickOverlay:e.closeOnClickOverlay,"onUpdate:show":s},{default:S}):S()}});const at=Ye(tt);var De={exports:{}};(function(e,n){(function(r,d){e.exports=d()})(pe,function(){return function(r,d,l){d.prototype.isBetween=function(v,h,f,o){var m=l(v),T=l(h),B=(o=o||"()")[0]==="(",x=o[1]===")";return(B?this.isAfter(m,f):!this.isBefore(m,f))&&(x?this.isBefore(T,f):!this.isAfter(T,f))||(B?this.isBefore(m,f):!this.isAfter(m,f))&&(x?this.isAfter(T,f):!this.isBefore(T,f))}}})})(De);var nt=De.exports;const ot=Pe(nt);E.extend(ot);const it={DAY:"天",MONTH:"月",YEAR:"年"},Dt=j({name:"activationCode",setup(){const e=Oe(),n=me({showPopoverTime:!1,background:"transparent",loading:!1,finished:!1,list:[]}),r=me({page:1,rows:20,code:null,activateStartTime:E().subtract(1,"months").format("YYYY-MM-DD"),activateEndTime:E().format("YYYY-MM-DD")}),d=async()=>{var l;n.loading=!0;try{const v={...r};r.activateEndTime&&r.activateStartTime&&(v.activateEndTime=r.activateEndTime+" 23:59:59",v.activateStartTime=r.activateStartTime+" 00:00:00");const h=await Ne.post("/edu-app/activationCodeRecord/page",{data:v});h.code===200&&Array.isArray((l=h==null?void 0:h.data)==null?void 0:l.rows)?(n.list=[...n.list,...h.data.rows],n.finished=!h.data.next,r.page=h.data.current+1):n.finished=!0}catch(v){n.finished=!0}n.loading=!1};return Fe(()=>{d()}),()=>i("div",{class:[y.hotMusicMore,he().isTablet?y.hotMusicMoreTablet:""]},[i(We,{position:"top"},{default:()=>[i(Ee,{border:!1,background:"transparent"},{content:()=>i("div",{class:y.woringHeader},[i("div",null,[i("i",{onClick:()=>{he().isApp?Ie({api:"goBack"}):e.back()},class:["van-badge__wrapper van-icon van-icon-arrow-left van-nav-bar__arrow",y.leftArrow]},null),i("span",{class:y.title2},[i("i",null,null)])])])}),i("div",{class:[y.activationContainer,y.recordContainer]},[i("i",{class:y.iconBrid},null),i("div",{class:y.section},[i(_e,{inputBackground:"white",shape:"round",placeholder:"请输入互通码",onSearch:l=>{r.code=l,r.page=1,n.list=[],n.finished=!1,d()}},null),i("div",{class:y.prodSection},[i("div",{class:y.title},[q("周期选择")]),i("div",{class:[y.times,n.showPopoverTime?y.active:""],onClick:()=>{n.showPopoverTime=!0}},[E(r.activateStartTime).format("YYYY-MM-DD"),q("至"),r.activateEndTime])])])])]}),i("div",{class:y.sectionList},[i(Le,{loading:n.loading,finished:n.finished,finishedText:" ",onLoad:d,immediateCheck:!1},{default:()=>[n.list.length>0&&n.list.map(l=>i("div",{class:y.sectionItem},[i("div",{class:y.itemTitle},[i("div",{class:y.text},[q("乐器AI学练工具"),l.times,it[l.type]])]),i("div",{class:y.itemCode},[l.code]),i("div",{class:y.itemTime},[q("激活时间:"),i("span",null,[E(l.activateTime).format("YYYY-MM-DD")])])]))]}),!n.loading&&n.list.length===0&&i("div",{style:{height:"100%"}},[i(He,{description:"暂无激活记录~"},null)])]),i(at,{show:n.showPopoverTime,"onUpdate:show":l=>n.showPopoverTime=l,firstDayOfWeek:1,safeAreaInsetBottom:!0,type:"range",title:"周期选择",minDate:new Date("2023-02-27"),defaultDate:[E(r.activateStartTime).toDate(),E(r.activateEndTime).toDate()],style:{height:"70%"},onConfirm:l=>{r.activateStartTime=E(l[0]).format("YYYY-MM-DD"),r.activateEndTime=E(l[1]).format("YYYY-MM-DD"),n.showPopoverTime=!1,r.page=1,n.list=[],n.finished=!1,d()}},null)])}});export{Dt as default};
|