select-subject.5a3e156f.js 2.5 KB

1
  1. import{d as c,g as d,y as l,j as t,A as r,F as u,B as o}from"./ResizeObserver.es.39b48a47.js";import{T as n}from"./index.34ac729a.js";import{S as h}from"./index.608320e9.js";const m="_filterTitle_g9vbz_1",b="_searchResult_g9vbz_9",p="_searchTitle_g9vbz_14",f="_radio_g9vbz_19",j="_btn_g9vbz_56";var s={filterTitle:m,searchResult:b,searchTitle:p,"radio-group":"_radio-group_g9vbz_19",radio:f,"organ-radio":"_organ-radio_g9vbz_49",btn:j},S=c({name:"selectSubject",props:{isReset:{type:Boolean,default:!1},searchParams:{type:Object,default:{name:"",id:""}},type:{type:String,default:"MUSIC"},isShowAllSubject:{type:Boolean,default:!1},onComfirm:{type:Function,default:e=>{}}},data(){return{subject:{name:"\u5168\u90E8\u58F0\u90E8",id:"",instrumentId:""},subjectList:[],apiSuffix:d.platformType==="STUDENT"?"/api-student":"/api-teacher"}},mounted(){this.subject={name:this.searchParams.id?this.searchParams.name:"\u5168\u90E8\u58F0\u90E8",id:this.searchParams.id||"",instrumentId:this.searchParams.instrumentId},this.getList()},methods:{async getList(){const{data:e}=await l.get(`${this.apiSuffix}/subject/subjectSelect?type=${this.type}`);Array.isArray(e)&&(this.subjectList=e,this.subject.id&&e.forEach(i=>{Array.isArray(i.subjects)&&i.subjects.forEach(a=>{a.id==this.subject.id&&(this.subject.instrumentId=a.instrumentId)})}))}},render(){return t(u,null,[t("div",{class:s.filterTitle},[r("\u5168\u90E8\u58F0\u90E8")]),t("div",{class:s.searchResult,style:{maxHeight:"45vh",overflowY:"auto"}},[this.isShowAllSubject&&t("div",{class:[s["radio-group"],s.radio,s["organ-radio"]]},[t(n,{size:"large",plain:this.subject.id=="",type:this.subject.id==""?"primary":"default",round:!0,onClick:()=>{this.subject={id:"",name:"\u5168\u90E8\u58F0\u90E8"}}},{default:()=>[r("\u5168\u90E8\u58F0\u90E8")]})]),this.subjectList.map(e=>e.subjects&&e.subjects.length>0&&t(u,null,[t("div",{class:s.searchTitle},[e.name]),t("div",{class:[s["radio-group"],s.radio,s["organ-radio"]]},[e.subjects.map(i=>{const a=i.id===Number(this.subject.id);return t(n,{size:"large",plain:a,type:a?"primary":"default",round:!0,onClick:()=>{this.subject={...i}}},{default:()=>[i.name]})})])]))]),t(h,{position:"bottom",offsetBottom:0},{default:()=>[t("div",{class:["btnGroup",this.isReset?"btnMore":""]},[this.isReset&&t(o,{type:"primary",plain:!0,round:!0,onClick:()=>{this.subject.name="\u5168\u90E8\u58F0\u90E8",this.subject.id="",this.onComfirm({...this.subject})}},{default:()=>[r("\u91CD \u7F6E")]}),t(o,{type:"primary",round:!0,block:!0,onClick:()=>{this.onComfirm({...this.subject})}},{default:()=>[r("\u786E \u8BA4")]})])]})])}});export{S};