import{d as M,e as h,s as o,O as i,M as G,L as P,N as A,i as t,J as O,C as x,aQ as B,F as q}from"./index.afa1b71c.js";import{S as D}from"./index.db3b0e47.js";import{L as F}from"./index.90f19895.js";import"./index.7c0d35f2.js";import{T as J,a as w}from"./index.0daa711a.js";import{C as U}from"./index.09943e1e.js";import{S as V}from"./select-subject.fb5b00b2.js";import{a as d,S as p}from"./hooks.ea9ec317.js";import{M as z}from"./index.bed38478.js";import{b as Q}from"./index.fce7f544.js";import"./use-tab-status.7451baf9.js";import"./use-id.237d90a3.js";import"./use-refs.fee02e7b.js";import"./index.8fb41b14.js";import"./index.dd9b166a.js";import"./index.30fb9a6a.js";import"./index.2a4aa690.js";import"./index.637c8eb4.js";import"./icon-xin.ff5e2464.js";const $="_sticky_1evma_1",K="_label_1evma_4",W="_musicGrid_1evma_16",X="_tagTabs_1evma_19";var b={sticky:$,label:K,musicGrid:W,tagTabs:X},ge=M({name:"Album",props:{hideSearch:{type:Boolean,default:!1},defauleParams:{type:Object,default:()=>({})}},setup({hideSearch:g,defauleParams:R},{expose:N}){const{isLoading:Y,state:S}=Q(h(o.platformApi+"/MusicTag/tree",{params:{type:"ALBUM"}}),null),n=i({id:"",name:""});if(o.platformType==="TEACHER"){const e=o.user.data;n.value={name:e.defaultSubjectName||"\u5168\u90E8\u58F0\u90E8",id:e.defaultSubject||""}}else if(!d(p.SEARCH).id){const a=o.user.data,f=a.subjectId?Number(a.subjectId.split(",")[0]):"",k=a.subjectName?a.subjectName.split(",")[0]:"";f&&d(p.SEARCH,JSON.stringify({id:f,name:k}),"set")}const H=G(),y=P(),r={};if(o.version&&(r.version=o.version||"",r.platform=o.platformType==="STUDENT"?"ios-student":"ios-teacher"),r.myself=!1,!g)if(o.platformType==="TEACHER")r.subjectIds=n.value.id;else{const e=d(p.SEARCH);r.subjectIds=e.id}const l=A({search:y.query.search||"",albumTagIds:y.query.tagids||"",page:1,...R,...r}),s=i(null),c=i(!1),j=i(!1),v=i(!1),I=i(!1),T=e=>{l.page=1,l.search=e,s.value=null,m()},m=async()=>{var e;if(!c.value){c.value=!0,v.value=!1;try{const a=await h.post("/music/album/list",{prefix:o.platformType==="TEACHER"?"/api-teacher":"/api-student",data:{...l,idAndName:l.search}});if(s.value){const f=(((e=s.value)==null?void 0:e.rows)||[]).concat(a.data.rows||[]);s.value.rows=f}s.value=s.value||a.data,l.page=a.data.pageNo+1,j.value=a.data.pageNo>=a.data.totalPage}catch{v.value=!0}c.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(",");l.albumTagIds=a,l.page=1,s.value=null,m(),I.value=!1},C=e=>{l.page=1,l.subjectIds=e.id,s.value=null,o.platformType==="TEACHER"?(n.value={name:e.name,id:e.id},_(e.id)):(u.id=e.id,u.name=e.name,d(p.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set")),m(),u.show=!1};N({onSearch:T,onComfirm:L,onComfirmSubject:C});const E=d(p.SEARCH),u=A({show:!1,name:E.name||"\u5168\u90E8\u58F0\u90E8",id:E.id||""});return()=>{const e=S.value&&S.value.data||[];return t(q,null,[t(F,{loading:c.value,finished:j.value,"finished-text":s.value&&s.value.rows.length?"\u6CA1\u6709\u66F4\u591A\u4E86":"",onLoad:m,error:v.value},{default:()=>[!g&&t(D,{class:b.sticky},{default:()=>[t(U,{modelValue:l.search,onSearch:T,placeholder:"\u8BF7\u8F93\u5165\u4E13\u8F91\u540D\u79F0 "},{left:()=>t("div",{class:b.label,onClick:()=>u.show=!0},[o.platformType==="TEACHER"?n.value.name:u.name,t(O,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),t(J,{shrink:!0,class:b.tagTabs,lineHeight:0,"onClick-tab":a=>{l.albumTagIds=a.name,s.value=null,l.page=1,m()}},{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=>{H.push({name:"music-album-detail",params:{id:a.id}})}},null)]):!c.value&&t(x,{tips:"\u6682\u65E0\u4E13\u8F91",classImgSize:"SMALL",btnStatus:!1},null)]}),t(B,{show:u.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>u.show=!1,onClosed:()=>u.show=!1},{default:()=>[t(V,{type:"ALBUM",searchParams:o.platformType==="TEACHER"?n.value:u,onComfirm:C},null)]})])}}});export{ge as default};
