import{d as G,V as u,y as v,g as l,S as B,Q as F,U as I,j as t,F as O,C as P}from"./ResizeObserver.es.62ab429c.js";import{L as U}from"./index.00698f4b.js";import"./index.b0c6821a.js";import"./index.3d6f6bcd.js";import{T as V,a as H}from"./index.ffd89e39.js";import{I as J}from"./index.021584f9.js";import{D as z,a as Q}from"./index.da737397.js";import"./index.d7a13e47.js";import{S as $}from"./index.002d8e53.js";import{S as K}from"./select-subject.87733b5b.js";import{b as f,S as p}from"./hooks.3b599d36.js";import{M as W}from"./index.16b0645f.js";import{c as X}from"./index.a6e5e68b.js";import{C as Y}from"./index.786e83cc.js";import{T as Z}from"./index.1db64c88.js";import{b as ee}from"./bg-image.e9966434.js";import"./use-tab-status.a98984d2.js";import"./use-id.1bbe472d.js";import"./use-refs.259e72cb.js";import"./index.82be4917.js";import"./index.0eba5ce9.js";import"./index.2a571689.js";import"./icon-xin2.4ab2a52d.js";const ae="_memberHeader_12ffq_1",te="_headerImg_12ffq_7",se="_headerContent_12ffq_16",le="_sticky_12ffq_51",re="_label_12ffq_54",oe="_musicGrid_12ffq_66",ue="_tagTabs_12ffq_69";var n={memberHeader:ae,headerImg:te,headerContent:se,sticky:le,label:re,musicGrid:oe,tagTabs:ue},Ne=G({name:"Album",props:{hideSearch:{type:Boolean,default:!1},defauleParams:{type:Object,default:()=>({})},showLight:{type:Boolean,default:!1},lightText:{type:String,default:""}},setup({hideSearch:y,defauleParams:R,showLight:w,lightText:L},{expose:N}){const g=u(L),{isLoading:ie,state:S}=X(v(l.platformApi+"/MusicTag/tree",{params:{type:"ALBUM"}}),null),c=u({id:"",name:""});if(l.platformType==="TEACHER"){const e=l.user.data;c.value={name:e.defaultSubjectName||"\u5168\u90E8\u58F0\u90E8",id:e.defaultSubject||""}}else if(!f(p.SEARCH).id){const a=l.user.data,o=a.subjectId?Number(a.subjectId.split(",")[0]):"",D=a.subjectName?a.subjectName.split(",")[0]:"";o&&f(p.SEARCH,JSON.stringify({id:o,name:D}),"set")}const q=B(),T=F(),i={};if(l.version&&(i.version=l.version||"",i.platform=l.platformType==="STUDENT"?"ios-student":"ios-teacher"),i.myself=!1,!y)if(l.platformType==="TEACHER")i.subjectIds=c.value.id;else{const e=f(p.SEARCH);i.subjectIds=e.id}const r=I({search:T.query.search||"",albumTagIds:T.query.tagids||"",page:1,...R,...i}),s=u(null),b=u(!1),j=u(!1),h=u(!1),k=u(!1),C=e=>{r.page=1,r.search=e,g.value=e,s.value=null,m()},m=async()=>{var e;if(!b.value){b.value=!0,h.value=!1;try{const a=await v.post("/music/album/list",{prefix:l.platformType==="TEACHER"?"/api-teacher":"/api-student",data:{...r,idAndName:g.value}});if(s.value){const o=(((e=s.value)==null?void 0:e.rows)||[]).concat(a.data.rows||[]);s.value.rows=o}s.value=s.value||a.data,r.page=a.data.pageNo+1,j.value=a.data.pageNo>=a.data.totalPage}catch{h.value=!0}b.value=!1}},x=async e=>{try{await v.post("/api-teacher/teacher/defaultSubject",{params:{subjectId:e}})}catch{}},M=e=>{const a=Object.values(e).flat().filter(Boolean).join(",");r.albumTagIds=a,r.page=1,s.value=null,m(),k.value=!1},_=u(),A=e=>{r.page=1,r.subjectIds=e.id,_.value.toggle(),s.value=null,l.platformType==="TEACHER"?(c.value={name:e.name,id:e.id},x(e.id)):(d.id=e.id,d.name=e.name,f(p.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set")),m(),d.show=!1};N({onSearch:C,onComfirm:M,onComfirmSubject:A});const E=f(p.SEARCH),d=I({show:!1,name:E.name||"\u5168\u90E8\u58F0\u90E8",id:E.id||""});return()=>{const e=S.value&&S.value.data||[];return t("div",null,[t(U,{finished:j.value,"finished-text":s.value&&s.value.rows.length?" ":"",onLoad:m,error:h.value},{default:()=>[!y&&t(O,null,[t(Z,{position:"top"},{default:()=>[t(Y,{class:n.memberHeader,background:"transparent",border:!1,isFixed:!1,color:"#131415"},{default:()=>t("div",{class:n.headerContent},[t($,{type:"tenant",modelValue:r.search,onSearch:C,placeholder:"\u8BF7\u8F93\u5165\u4E13\u8F91\u540D\u79F0 ",background:"transparent"},{left:()=>t(z,null,{default:()=>[t(Q,{titleClass:n.titleActive,title:"\u7B5B\u9009",ref:_},{default:()=>[t(K,{type:"ALBUM",isReset:!0,searchParams:l.platformType==="TEACHER"?c.value:d,onComfirm:A},null)]})]})}),t(V,{shrink:!0,class:n.tagTabs,lineHeight:0,"onClick-tab":a=>{r.albumTagIds=a.name,s.value=null,r.page=1,m()}},{default:()=>[t(H,{title:"\u5168\u90E8",name:""},null),e.map(a=>t(H,{title:a.name,name:a.id},null))]})])})]}),t(J,{class:n.headerImg,src:ee},null)]),s.value&&s.value.rows.length?t("div",{class:n.musicGrid},[t(W,{showLight:w,lightText:g.value,list:s.value.rows,onGoto:a=>{const o=l.platformType==="TEACHER"?c.value:d;console.log(o),q.push({name:"music-album-detail",params:{id:a.id},query:{subjectId:o.id,subjectName:o.name}})}},null)]):!b.value&&t("div",{style:"height: calc(100vh - var(--header-height));display: flex;align-items: center;"},[t(P,{tips:"\u6682\u65E0\u4E13\u8F91",classImgSize:"SMALL",btnStatus:!1},null)])]})])}}});export{Ne as default};
