import{d as M,x as h,g as l,S as c,P,O as G,Q as A,j as t,M as x,C as O,aR as q,F as B}from"./index.3bfa6a0e.js";import{L as D}from"./index.0a290e73.js";import"./index.6bd4dfa5.js";import"./index.e9acc943.js";import{T as F,a as w}from"./index.cd00eeaf.js";import{S as U}from"./index.8a87fb9c.js";import{S as V}from"./select-subject.0b31a0d6.js";import{a as p,S as f}from"./hooks.435f47d5.js";import{M as z}from"./index.d7aedf5c.js";import{c as J}from"./index.b1671445.js";import{C as Q}from"./index.645e7ddc.js";import{T as $}from"./index.52c97b40.js";import"./use-tab-status.c0d730a9.js";import"./use-id.7c44c16f.js";import"./use-refs.7efc98f2.js";import"./index.79997a38.js";import"./index.983bfd1a.js";import"./index.c171ade0.js";import"./index.8711ee78.js";import"./index.0fd5538f.js";import"./icon-xin.62588855.js";import"./index.4a8093e5.js";const K="_sticky_1evma_1",W="_label_1evma_4",X="_musicGrid_1evma_16",Y="_tagTabs_1evma_19";var b={sticky:K,label:W,musicGrid:X,tagTabs:Y},Te=M({name:"Album",props:{hideSearch:{type:Boolean,default:!1},defauleParams:{type:Object,default:()=>({})}},setup({hideSearch:g,defauleParams:R},{expose:H}){const{isLoading:Z,state:S}=J(h(l.platformApi+"/MusicTag/tree",{params:{type:"ALBUM"}}),null),i=c({id:"",name:""});if(l.platformType==="TEACHER"){const e=l.user.data;i.value={name:e.defaultSubjectName||"\u5168\u90E8\u58F0\u90E8",id:e.defaultSubject||""}}else if(!p(f.SEARCH).id){const a=l.user.data,u=a.subjectId?Number(a.subjectId.split(",")[0]):"",k=a.subjectName?a.subjectName.split(",")[0]:"";u&&p(f.SEARCH,JSON.stringify({id:u,name:k}),"set")}const I=P(),j=G(),n={};if(l.version&&(n.version=l.version||"",n.platform=l.platformType==="STUDENT"?"ios-student":"ios-teacher"),n.myself=!1,!g)if(l.platformType==="TEACHER")n.subjectIds=i.value.id;else{const e=p(f.SEARCH);n.subjectIds=e.id}const o=A({search:j.query.search||"",albumTagIds:j.query.tagids||"",page:1,...R,...n}),s=c(null),m=c(!1),y=c(!1),v=c(!1),N=c(!1),T=e=>{o.page=1,o.search=e,s.value=null,d()},d=async()=>{var e;if(!m.value){m.value=!0,v.value=!1;try{const a=await h.post("/music/album/list",{prefix:l.platformType==="TEACHER"?"/api-teacher":"/api-student",data:{...o,idAndName:o.search}});if(s.value){const u=(((e=s.value)==null?void 0:e.rows)||[]).concat(a.data.rows||[]);s.value.rows=u}s.value=s.value||a.data,o.page=a.data.pageNo+1,y.value=a.data.pageNo>=a.data.totalPage}catch{v.value=!0}m.value=!1}},_=async e=>{try{await h.post("/api-teacher/teacher/defaultSubject",{params:{subjectId:e}})}catch{}},L=e=>{const a=Object.values(e).flat().filter(Boolean).join(",");o.albumTagIds=a,o.page=1,s.value=null,d(),N.value=!1},C=e=>{o.page=1,o.subjectIds=e.id,s.value=null,l.platformType==="TEACHER"?(i.value={name:e.name,id:e.id},_(e.id)):(r.id=e.id,r.name=e.name,p(f.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set")),d(),r.show=!1};H({onSearch:T,onComfirm:L,onComfirmSubject:C});const E=p(f.SEARCH),r=A({show:!1,name:E.name||"\u5168\u90E8\u58F0\u90E8",id:E.id||""});return()=>{const e=S.value&&S.value.data||[];return t(B,null,[t(D,{loading:m.value,finished:y.value,"finished-text":s.value&&s.value.rows.length?"\u6CA1\u6709\u66F4\u591A\u4E86":"",onLoad:d,error:v.value},{default:()=>[!g&&t($,{class:b.sticky},{default:()=>[t(Q,{border:!1},null),t(U,{modelValue:o.search,onSearch:T,placeholder:"\u8BF7\u8F93\u5165\u4E13\u8F91\u540D\u79F0 "},{left:()=>t("div",{class:b.label,onClick:()=>r.show=!0},[l.platformType==="TEACHER"?i.value.name:r.name,t(x,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),t(F,{shrink:!0,class:b.tagTabs,lineHeight:0,"onClick-tab":a=>{o.albumTagIds=a.name,s.value=null,o.page=1,d()}},{default:()=>[t(w,{title:"\u5168\u90E8",name:""},null),e.map(a=>t(w,{title:a.name,name:a.id},null))]})]}),s.value&&s.value.rows.length?t("div",{class:b.musicGrid},[t(z,{list:s.value.rows,onGoto:a=>{const u=l.platformType==="TEACHER"?i.value:r;I.push({name:"music-album-detail",params:{id:a.id},query:{subjectId:u.id,subjectName:u.name}})}},null)]):!m.value&&t(O,{tips:"\u6682\u65E0\u4E13\u8F91",classImgSize:"SMALL",btnStatus:!1},null)]}),t(q,{show:r.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>r.show=!1,onClosed:()=>r.show=!1},{default:()=>[t(V,{type:"ALBUM",searchParams:l.platformType==="TEACHER"?i.value:r,onComfirm:C},null)]})])}}});export{Te as default};
