1 |
- import{aW as i,aw as a,df as o,dg as c}from"./index-3c72d77b-1714304141006.js";const m=i("catch-store",{state:()=>({bookVersionList:[],musicTypeList:[],subjectList:[],musicInstrumentList:[],subjectInstruemnts:[]}),getters:{getBookVersion(){return this.bookVersionList},getMusicCategories(){return this.musicTypeList},getMusicInstruments(){return this.musicInstrumentList},getAllMusicCategories(){return[{name:"全部",id:null},...this.musicTypeList]},getSubjectList(){return this.subjectList},getSubjectAllList(){return[{name:"全部",id:null},...this.subjectList]},getEnableSubjects(){const t=[];return this.subjectList.forEach(u=>{if(u.enableFlag){const{instruments:r,...e}=u;if(r&&r.length>0){const n=[];r==null||r.forEach(s=>{s.enableFlag&&n.push(s)}),t.push({...e,instruments:n})}}}),t},getSubjectInstruments(){return[{name:"全部",id:null,label:"全部",value:null},...this.subjectInstruemnts]}},actions:{setBookVersion(t){this.bookVersionList=t},setMusicCategories(t){this.musicTypeList=t},setSubjects(t){this.subjectList=t},setSubjectInstruemnts(t){this.subjectInstruemnts=t},setMusicInstruments(t){this.musicInstrumentList=t},async getSubjects(){try{if(this.getSubjectList&&this.getSubjectList.length>0)return Promise.resolve();const{data:t}=await a({delFlag:0,page:1,rows:999}),u=t||[],r=[];return u.forEach(e=>{if(e.instruments&&e.instruments.length>0){e.value=e.id,e.label=e.name,e.instruments.forEach(s=>{s.label=s.name,s.value=s.id});const n={value:e.id,label:e.name,id:e.id,name:e.name,instruments:[]};e.instruments&&(e.instruments.length==1?(n.value=e.instruments[0].id,n.label=e.instruments[0].name,n.id=e.id,n.name=e.name):e.instruments.length>1&&e.instruments.forEach(s=>{s.label=s.name,s.value=s.id,n.instruments.push({label:s.name,value:s.id,id:s.id,name:s.name})})),r.push(n)}}),this.setSubjects(u.filter(e=>e.instruments&&e.instruments.length>0)||0),this.setSubjectInstruemnts(r||[]),Promise.resolve()}catch(t){return Promise.reject(t)}},async getMusicSheetCategory(){try{if(this.getMusicCategories&&this.getMusicCategories.length>0)return Promise.resolve();const{data:t}=await o({enable:!0,page:1,rows:999});return this.setMusicCategories(t.rows||[]),Promise.resolve()}catch(t){return Promise.reject(t)}},async getMusicInstrument(){try{if(this.getMusicInstruments&&this.getMusicInstruments.length>0)return Promise.resolve();const{data:t}=await c({enableFlag:!0});return console.log(t,"data"),this.setMusicInstruments(t||[]),Promise.resolve()}catch(t){return Promise.reject(t)}}}});export{m as u};
|