catchData-e5072c59-1743496079034.js 4.3 KB

1
  1. import{ab as i,bi as l,aM as c,dt as g,du as m,dv as h}from"./index-32ff339b-1743496079034.js";import{d as p}from"./deep-clone-c0d00fc2-1743496079034.js";const f=e=>i.post("/edu-app/material/queryPage",{data:e}),j=e=>i.post("/edu-app/material/favorite",{data:e}),v=e=>i.post("/edu-app/material/remove",{requestType:"form",data:e}),M=e=>i.post("/edu-app/lessonCourseware/save",{data:e}),L=e=>i.post("/edu-app/material/save",{data:e}),S=e=>i.post("/edu-app/material/updateAll",{data:e}),y=e=>i.post("/edu-app/material/removeMusic",{data:e}),b=e=>i.post("/edu-app/materialTag/page",{data:e}),I=l("catch-store",{state:()=>({bookVersionList:[],musicTypeList:[],subjectList:[],musicInstrumentList:[],subjectInstruemnts:[],musicTagTree:[],materialTags:[]}),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 e=[];return this.subjectList.forEach(r=>{if(r.enableFlag){const{instruments:n,...t}=r;if(n&&n.length>0){const a=[];n==null||n.forEach(s=>{s.enableFlag&&a.push(s)}),a.length>0&&e.push({...t,instruments:a})}}}),e},getSubjectInstruments(){return[{name:"全部",id:null,label:"全部",value:null},...this.subjectInstruemnts]},getSubjectInstrumentOnly(){return this.subjectInstruemnts},getMusicTagTree(){return this.musicTagTree},getMaterialTags(){return this.materialTags},getAllMaterialTags(){return[{label:"全部",value:null},...this.materialTags]}},actions:{setBookVersion(e){this.bookVersionList=e},setMusicCategories(e){this.musicTypeList=e},setSubjects(e){this.subjectList=e},setSubjectInstruemnts(e){this.subjectInstruemnts=e},setMusicInstruments(e){this.musicInstrumentList=e},setMusicTagTree(e){this.musicTagTree=e},setMaterialTags(e){this.materialTags=e},async getSubjects(){try{if(this.getSubjectList&&this.getSubjectList.length>0)return Promise.resolve();const{data:e}=await c({delFlag:0,page:1,rows:999}),r=e||[],n=[];return r.forEach(t=>{if(t.instruments&&t.instruments.length>0){t.value=t.id,t.label=t.name,t.instruments.forEach(s=>{s.label=s.name,s.value=s.id});const a={value:t.id,label:t.name,id:t.id,name:t.name,instruments:[]};t.instruments&&(t.instruments.length==1?(a.value=t.instruments[0].id,a.label=t.instruments[0].name,a.id=t.id,a.name=t.name):t.instruments.length>1&&t.instruments.forEach(s=>{s.label=s.name,s.value=s.id,a.instruments.push({label:s.name,value:s.id,id:s.id,name:s.name})})),n.push(a)}}),this.setSubjects(r.filter(t=>t.instruments&&t.instruments.length>0)||0),this.setSubjectInstruemnts(n||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},getEnableSingleAllSubjects(e){e=e||[];const r=[];this.getSubjectList.forEach(t=>{const a=p(t);Array.isArray(a.instruments)&&a.instruments.forEach(s=>{e.includes(s.id)&&(s.enableFlag=!0,a.enableFlag=!0)}),r.push(a)});const n=[];return r.forEach(t=>{if(t.enableFlag){const{instruments:a,...s}=t,u=[];a==null||a.forEach(o=>{o.enableFlag&&u.push(o)}),u.length>0&&n.push({...s,instruments:u})}}),n},async getMusicSheetCategory(e=!1){try{if(this.getMusicCategories&&this.getMusicCategories.length>0&&!e)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:e}=await m({enableFlag:!0});return console.log(e,"data"),this.setMusicInstruments(e||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},async getMusicTagTreeApi(){try{if(this.getMusicTagTree&&this.getMusicTagTree.length>0)return Promise.resolve();const{data:e}=await h(),r=e||[];return this.setMusicTagTree(r||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},async getMaterialTagsApi(){try{if(this.getMaterialTags&&this.getMaterialTags.length>0)return Promise.resolve();const{data:e}=await b({page:1,rows:100}),r=e.rows||[],n=[];return r.forEach(t=>{n.push({label:t.name,value:t.id})}),this.setMaterialTags(n||[]),Promise.resolve()}catch(e){return Promise.reject(e)}}}});export{y as a,S as b,v as c,L as d,b as e,j as f,M as g,f as m,I as u};