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.4f40e5e1.js";import{m as f,s as h}from"./header.936a9b9f.js";import{g as L}from"./music.ef20ecaf.js";import{a as k,S as A}from"./hooks.eddecfbf.js";import{L as x}from"./index.ec6e6a47.js";import{S as D}from"./index.b0a3835a.js";import"./index.ff0c0b1f.js";import"./index.54ea2849.js";import"./index.39d21790.js";import"./index.c9ba21fe.js";import"./use-id.d72892eb.js";import"./use-tab-status.122f9fa5.js";import"./use-refs.29c07da0.js";import"./index.f404167d.js";import"./index.c4fa4795.js";import"./index.b6ce06cf.js";import"./index.9cb1152c.js";import"./index.8e0ac410.js";import"./index.10256463.js";import"./index.926ca9c5.js";import"./select-subject.cbacbaa1.js";import"./index.4b5981fc.js";import"./index.41aa1fc7.js";import"./icon-xin2.4ab2a52d.js";import"./index.97fec1a5.js";var re=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,`<span style="color: #FE2451">${o.value}</span>`))}),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{re as default};
