index.2d0e4f12.js 4.0 KB

1
  1. import{d as M,w as h,g as o,S as i,P,O as G,Q as A,j as s,M as O,C as x,aR as B,F as q}from"./index.e6d6174e.js";import{S as D}from"./index.9093bc60.js";import{L as F}from"./index.f904775d.js";import"./index.b4a53c6a.js";import{T as U,a as w}from"./index.54627972.js";import{S as V}from"./index.c42f80e3.js";import{S as z}from"./select-subject.5521b320.js";import{a as d,S as p}from"./hooks.00b5b341.js";import{M as J}from"./index.f5daa90d.js";import{b as Q}from"./index.684ca989.js";import"./use-tab-status.e9ba8498.js";import"./use-id.f239f36f.js";import"./use-refs.eb803454.js";import"./index.af99cf22.js";import"./index.17d70acf.js";import"./index.05f2b7dd.js";import"./index.c3601b28.js";import"./index.67c54471.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=M({name:"Album",props:{hideSearch:{type:Boolean,default:!1},defauleParams:{type:Object,default:()=>({})}},setup({hideSearch:S,defauleParams:R},{expose:H}){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 I=P(),y=G(),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}),t=i(null),c=i(!1),j=i(!1),v=i(!1),N=i(!1),T=e=>{l.page=1,l.search=e,t.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(t.value){const f=(((e=t.value)==null?void 0:e.rows)||[]).concat(a.data.rows||[]);t.value.rows=f}t.value=t.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,t.value=null,m(),N.value=!1},C=e=>{l.page=1,l.subjectIds=e.id,t.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};H({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=g.value&&g.value.data||[];return s(q,null,[s(F,{loading:c.value,finished:j.value,"finished-text":t.value&&t.value.rows.length?"\u6CA1\u6709\u66F4\u591A\u4E86":"",onLoad:m,error:v.value},{default:()=>[!S&&s(D,{class:b.sticky},{default:()=>[s(V,{modelValue:l.search,onSearch:T,placeholder:"\u8BF7\u8F93\u5165\u4E13\u8F91\u540D\u79F0 "},{left:()=>s("div",{class:b.label,onClick:()=>u.show=!0},[o.platformType==="TEACHER"?n.value.name:u.name,s(O,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),s(U,{shrink:!0,class:b.tagTabs,lineHeight:0,"onClick-tab":a=>{l.albumTagIds=a.name,t.value=null,l.page=1,m()}},{default:()=>[s(w,{title:"\u5168\u90E8",name:""},null),e.map(a=>s(w,{title:a.name,name:a.id},null))]})]}),t.value&&t.value.rows.length?s("div",{class:b.musicGrid},[s(J,{list:t.value.rows,onGoto:a=>{I.push({name:"music-album-detail",params:{id:a.id}})}},null)]):!c.value&&s(x,{tips:"\u6682\u65E0\u4E13\u8F91",classImgSize:"SMALL",btnStatus:!1},null)]}),s(B,{show:u.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>u.show=!1,onClosed:()=>u.show=!1},{default:()=>[s(z,{type:"ALBUM",searchParams:o.platformType==="TEACHER"?n.value:u,onComfirm:C},null)]})])}}});export{Se as default};