|
@@ -6,7 +6,8 @@ export const useCatchStore = defineStore('catch-store', {
|
|
|
state: () => ({
|
|
|
bookVersionList: [] as any[], // 其它类型
|
|
|
musicTypeList: [] as any[], // 乐谱分类
|
|
|
- subjectList: [] as any[] // 声部列表
|
|
|
+ subjectList: [] as any[], // 声部列表,
|
|
|
+ subjectInstruemnts: [] as any[] // 乐器列表,
|
|
|
}),
|
|
|
getters: {
|
|
|
getBookVersion(): any[] {
|
|
@@ -35,6 +36,17 @@ export const useCatchStore = defineStore('catch-store', {
|
|
|
},
|
|
|
...this.subjectList
|
|
|
];
|
|
|
+ },
|
|
|
+ getSubjectInstruments(): any[] {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ name: '全部',
|
|
|
+ id: null,
|
|
|
+ label: '全部',
|
|
|
+ value: null
|
|
|
+ },
|
|
|
+ ...this.subjectInstruemnts
|
|
|
+ ];
|
|
|
}
|
|
|
},
|
|
|
actions: {
|
|
@@ -47,6 +59,9 @@ export const useCatchStore = defineStore('catch-store', {
|
|
|
setSubjects(subjects: any[]) {
|
|
|
this.subjectList = subjects;
|
|
|
},
|
|
|
+ setSubjectInstruemnts(subjects: any[]) {
|
|
|
+ this.subjectInstruemnts = subjects;
|
|
|
+ },
|
|
|
/**
|
|
|
* 判断是否有声部数据,如不存在则获取声部列表
|
|
|
* @returns Promise
|
|
@@ -65,6 +80,8 @@ export const useCatchStore = defineStore('catch-store', {
|
|
|
});
|
|
|
|
|
|
const tempSubjectList = data || [];
|
|
|
+
|
|
|
+ const tempSubjectInstruments: any = [];
|
|
|
tempSubjectList.forEach((item: any) => {
|
|
|
item.value = item.id;
|
|
|
item.label = item.name;
|
|
@@ -74,9 +91,38 @@ export const useCatchStore = defineStore('catch-store', {
|
|
|
child.value = child.id;
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ const tempSi = {
|
|
|
+ value: item.id,
|
|
|
+ label: item.name,
|
|
|
+ id: item.id,
|
|
|
+ name: item.name,
|
|
|
+ instruments: [] as any
|
|
|
+ };
|
|
|
+ if (item.instruments) {
|
|
|
+ if (item.instruments.length == 1) {
|
|
|
+ tempSi.value = item.instruments[0].id;
|
|
|
+ tempSi.label = item.instruments[0].name;
|
|
|
+ tempSi.id = item.id;
|
|
|
+ tempSi.name = item.name;
|
|
|
+ } else if (item.instruments.length > 1) {
|
|
|
+ item.instruments.forEach((child: any) => {
|
|
|
+ child.label = child.name;
|
|
|
+ child.value = child.id;
|
|
|
+ tempSi.instruments.push({
|
|
|
+ label: child.name,
|
|
|
+ value: child.id,
|
|
|
+ id: child.id,
|
|
|
+ name: child.name
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tempSubjectInstruments.push(tempSi);
|
|
|
});
|
|
|
|
|
|
this.setSubjects(tempSubjectList || []);
|
|
|
+ this.setSubjectInstruemnts(tempSubjectInstruments || []);
|
|
|
return Promise.resolve();
|
|
|
} catch (e) {
|
|
|
return Promise.reject(e);
|