import{d as b,O as y,P as C,S as s,Q as j,U as E,bC as N,j as l,be as R,C as q,w as I}from"./index.394decd7.js";import{m as f,s as h}from"./header.a67ec441.js";import{g as L}from"./music.a1b63125.js";import{a as k,S as A}from"./hooks.9e5ee122.js";import{L as x}from"./index.dc786267.js";import{S as D}from"./index.06b816c0.js";import"./index.dab716ce.js";import"./index.3bbf4ddb.js";import"./index.f1b52763.js";import"./index.ae00317c.js";import"./use-id.e2f22365.js";import"./use-tab-status.723110ee.js";import"./use-refs.09b2d19c.js";import"./index.5d26697d.js";import"./index.9e0d46e4.js";import"./index.b6ce06cf.js";import"./index.ada5e712.js";import"./index.224299a1.js";import"./index.75a0444f.js";import"./index.b9aedd1d.js";import"./index.926ca9c5.js";import"./select-subject.fa696791.js";import"./index.88270f6d.js";import"./index.e6e212d8.js";import"./icon-xin2.4ab2a52d.js";import"./index.ae2dd816.js";var ue=b({name:"MusicSearch",emits:["confirm"],setup(){localStorage.setItem("behaviorId",L());const c=y(),g=C(),o=s(c.query.keyword||""),w=s(),S=k(A.SEARCH);w.value=S.id;const p=a=>{o.value=a,e.value&&(e.value.rows=[]),r.name=a,r.page=1,n()},r=j({name:c.query.search||"",rows:20,page:1}),e=s(null),u=s(!1),d=s(!1),m=s(!1),n=async()=>{var a;if(!u.value){u.value=!0,m.value=!1;try{const t=await I.post("/api-student/music/sheet/searchTenant",{data:r});if(e.value){const i=(((a=e.value)==null?void 0:a.rows)||[]).concat(t.data.music.rows||[]);e.value.rows=i}e.value=e.value||t.data.music;const v=e.value.rows||[];v.forEach(i=>{o.value&&(i.musicSheetName=i.musicSheetName.replace(o.value,`${o.value}`))}),e.value.rows=v,r.page=t.data.music.pageNo+1,d.value=t.data.music.pageNo>=t.data.music.totalPage}catch{m.value=!0}u.value=!1}};return E(()=>{f.on("search",p),n()}),N(()=>{f.off("search",p)}),()=>l("div",{class:[h.search,h.searchAlbum]},[e.value&&e.value.rows.length?l(x,{finished:d.value,"finished-text":(e.value&&e.value.rows.length,""),onLoad:n,error:m.value,immediateCheck:!1},{default:()=>[l(D,{showTitleImg:!0,list:e.value.rows,onDetail:a=>{const t=location.origin+location.pathname+"#/music-detail?id="+a.id;R(t,()=>{g.push({path:"/music-detail",query:{id:a.id}})})}},null)]}):!u.value&&l(q,{tips:"\u6682\u65E0\u66F2\u76EE",btnStatus:!1},null)])}});export{ue as default};