import{d as S,ag as g,r as y,g as c,R as m,$ as v,e as E,b3 as R,c as a,aj as w,a5 as C,q as L,ak as T,al as U,m as O,o as k}from"./index.8f93de0e.js";import{O as x}from"./index.b662df5e.js";import{O as I}from"./index.a9a604b9.js";import{s as u,U as P}from"./unit-list-item.e25d0cd2.js";import{O as b}from"./index.ac6701a3.js";import{O as V}from"./index.0c758b5f.js";import{L as N}from"./index.1e20fccc.js";import"./index.9b99667f.js";import"./index.f729b332.js";import"./icon-edit.664c5ff1.js";import"./icon-muit-message.0a72e92d.js";import"./index.b1095de8.js";import"./index.a2e558d4.js";import"./index.038430de.js";import"./use-tab-status.69e46758.js";var B="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAAXNSR0IArs4c6QAAALtJREFUWEftmNENwyAMRPEgyRJmiUzSmTpJlsBLlEGokKiEojTSxVRC1fFtH9YDzIGEASPGuJVSnlVKRB4ppd0rK16Bmq+qrxDC0rSyma1e3VGFlb4QM3PrugUaMRYGbRFVJTES+0aApxLaG/UGQRPO4nkqUYokRmIXBKQzeR8/hQIbHZ+r2ZSDyRs9yV29PG9h0y7lXdZ9HvsYSpHESOyq86N06MdIDCRAzw8C4ysJBfb/xOb86vzF5/AbfM2i57toBH8AAAAASUVORK5CYII=";function G(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!U(o)}var W=S({name:"unit-list",setup(){const o=g(),e=y({oPopover:!1,list:[],listState:{dataShow:!0,loading:!1,finished:!1},statusText:"\u73ED\u7EA7\u7C7B\u578B",params:{keyword:null,classTypeCode:null,page:1,rows:20},isClick:!1,action:[{name:"\u73ED\u7EA7\u7C7B\u578B",id:"ALL",selected:!0},{name:"\u5355\u6280\u73ED",id:"SINGLE"},{name:"\u4E50\u7406\u73ED",id:"MUSIC_THEORY"},{name:"\u5408\u594F\u73ED",id:"INSTRUMENTAL_ENSEMBLE"}]}),l=c.platformApi,i=m(!1),n=m(!1),r=async()=>{if(!e.isClick){e.isClick=!0,n.value=!0;try{i.value&&(e.params.page=1,e.list=[],i.value=!1);const s=c.platformType==="TEACHER"?`${l}/studentUnitExamination/queryPageByTeacher`:`${l}/studentUnitExamination/queryPageByManage`,t=await O.post(s,{data:{...e.params}});if(e.list.length>0&&t.data.pages===1)return;e.params.page=t.data.current+1,e.list=e.list.concat(t.data.rows||[]),e.listState.dataShow=e.list.length>0,n.value=!1,e.listState.finished=t.data.current>=t.data.pages}catch(s){const t=s.message;k(t),e.listState.dataShow=!1,e.listState.finished=!0}e.isClick=!1}},f=()=>{e.listState.finished=!0,n.value=!0,r()},d=()=>{e.params.page=1,e.list=[],e.listState.dataShow=!0,e.listState.loading=!1,e.listState.finished=!1,r()};v(()=>{r(),window.history.pushState(null,"",document.URL),window.addEventListener("popstate",p,!1)});const p=()=>{E({api:"back"})};R(()=>{window.removeEventListener("popstate",p)});const h=()=>{sessionStorage.removeItem("unit-create"),o.push("/unit-create")};return()=>{let s;return a("div",{class:u.unitTest},[a(I,{position:"top",onGetHeight:t=>{document.documentElement.style.setProperty("--header-height",t+"px")}},{default:()=>[a(w,{border:!1},{right:()=>l=="/api-teacher"?a(C,{name:B,size:19,onClick:h},null):null}),a(x,{placeholder:"\u8BF7\u8F93\u5165\u6D4B\u9A8C\u540D\u79F0",onSearch:t=>{e.params.keyword=t,d()}},{left:()=>a("div",{class:["searchItem-left",e.oPopover?"searchItem-active":""],onClick:()=>e.oPopover=!0},[a("span",null,[e.statusText,L(" ")])])})]}),e.listState.dataShow?a(b,{modelValue:i.value,"onUpdate:modelValue":t=>i.value=t,onRefresh:f,style:"min-height: calc(100vh - var(--header-height));"},{default:()=>[a(N,{finished:e.listState.finished,finishedText:" ",class:[u.liveList],onLoad:r,style:{paddingTop:"12px"},immediateCheck:!1},G(s=e.list.map(t=>a(P,{item:t},null)))?s:{default:()=>[s]})]}):a(T,{tips:"\u6682\u65E0\u9636\u6BB5\u81EA\u6D4B"},null),a(V,{show:e.oPopover,"onUpdate:show":t=>e.oPopover=t,actions:e.action,onSelect:t=>{e.action.forEach(A=>{A.selected=!1}),t.selected=!0,e.statusText=t.name,e.params.classTypeCode=t.id==="ALL"?null:t.id,e.oPopover=!1,d()}},null)])}}});export{W as default};
