import{d as P,e as h,s as o,U as i,Q as G,P as M,S as A,i as t,N as x,C as B,aT as O,F as U}from"./index.7994470a.js";import{S as q}from"./index.6449f9de.js";import{L as D}from"./index.ec643df3.js";import"./index.889feca1.js";import{T as F,a as w}from"./index.a28173c9.js";import{C as V}from"./index.0f4f72db.js";import{S as z}from"./select-subject.cc64fd7c.js";import{a as d,S as p}from"./hooks.04c1f931.js";import{M as J}from"./index.b3dca421.js";import{b as Q}from"./index.9eb2b8e9.js";import"./use-tab-status.00d7316c.js";import"./use-id.117b75b2.js";import"./use-refs.ad5f4144.js";import"./index.777f4790.js";import"./index.3dd26d27.js";import"./index.0262b810.js";import"./index.ab866de2.js";import"./index.2fbdc579.js";import"./icon-xin.df8ab2d7.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},Se=P({name:"Album",props:{hideSearch:{type:Boolean,default:!1},defauleParams:{type:Object,default:()=>({})}},setup({hideSearch:S,defauleParams:R},{expose:N}){const{isLoading:Y,state:g}=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=M(),r={};if(o.version&&(r.version=o.version||"",r.platform=o.platformType==="STUDENT"?"ios-student":"ios-teacher"),r.myself=!1,!S)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),T=i(!1),v=i(!1),I=i(!1),j=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,T.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:j,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=g.value&&g.value.data||[];return t(U,null,[t(D,{loading:c.value,finished:T.value,"finished-text":s.value&&s.value.rows.length?"\u6CA1\u6709\u66F4\u591A\u4E86":"",onLoad:m,error:v.value},{default:()=>[!S&&t(q,{class:b.sticky},{default:()=>[t(V,{modelValue:l.search,onSearch:j,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(x,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),t(F,{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(J,{list:s.value.rows,onGoto:a=>{H.push({name:"music-album-detail",params:{id:a.id}})}},null)]):!c.value&&t(B,{tips:"\u6682\u65E0\u4E13\u8F91",classImgSize:"SMALL",btnStatus:!1},null)]}),t(O,{show:u.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>u.show=!1,onClosed:()=>u.show=!1},{default:()=>[t(z,{type:"ALBUM",searchParams:o.platformType==="TEACHER"?n.value:u,onComfirm:C},null)]})])}}});export{Se as default};
