1 |
- import{aW as l,aw as o,dg as g,dh as m}from"./index-27f38392-1715840129614.js";const c=t=>{if(t===null)return null;const r=Object.assign({},t);return Object.keys(r).forEach(u=>r[u]=typeof t[u]=="object"?c(t[u]):t[u]),Array.isArray(t)?(r.length=t.length,Array.from(r)):r},b=l("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(r=>{if(r.enableFlag){const{instruments:u,...e}=r;if(u&&u.length>0){const n=[];u==null||u.forEach(s=>{s.enableFlag&&n.push(s)}),n.length>0&&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 o({delFlag:0,page:1,rows:999}),r=t||[],u=[];return r.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})})),u.push(n)}}),this.setSubjects(r.filter(e=>e.instruments&&e.instruments.length>0)||0),this.setSubjectInstruemnts(u||[]),Promise.resolve()}catch(t){return Promise.reject(t)}},getEnableSingleAllSubjects(t){t=t||[];const r=[];this.getSubjectList.forEach(e=>{const n=c(e);Array.isArray(n.instruments)&&n.instruments.forEach(s=>{t.includes(s.id)&&(s.enableFlag=!0,n.enableFlag=!0)}),r.push(n)});const u=[];return r.forEach(e=>{if(e.enableFlag){const{instruments:n,...s}=e,i=[];n==null||n.forEach(a=>{a.enableFlag&&i.push(a)}),i.length>0&&u.push({...s,instruments:i})}}),u},async getMusicSheetCategory(t=!1){try{if(this.getMusicCategories&&this.getMusicCategories.length>0&&!t)return Promise.resolve();const{data:r}=await g({enable:!0,page:1,rows:999});return this.setMusicCategories(r.rows||[]),Promise.resolve()}catch(r){return Promise.reject(r)}},async getMusicInstrument(){try{if(this.getMusicInstruments&&this.getMusicInstruments.length>0)return Promise.resolve();const{data:t}=await m({enableFlag:!0});return console.log(t,"data"),this.setMusicInstruments(t||[]),Promise.resolve()}catch(t){return Promise.reject(t)}}}});export{c as d,b as u};
|