|
@@ -388,6 +388,7 @@ export default defineComponent({
|
|
|
} catch (error) {
|
|
|
}
|
|
|
state.partListNames = getPartListNames(res?.target?.result as any) as any
|
|
|
+ parseInstrumentAndSubject(res?.target?.result as any)
|
|
|
// 这里是如果没有当前音轨就重新写
|
|
|
for (let j = 0; j < state.partListNames.length; j++) {
|
|
|
if (!forms.musicSheetSoundList[j]) {
|
|
@@ -418,6 +419,36 @@ export default defineComponent({
|
|
|
xmlRead.readAsText(file)
|
|
|
}
|
|
|
|
|
|
+ const parseInstrumentAndSubject = (xml: any) => {
|
|
|
+ if (!xml) return
|
|
|
+ const xmlParse = new DOMParser().parseFromString(xml, 'text/xml')
|
|
|
+ // 乐器
|
|
|
+ const instrumentCodeList: any = [];
|
|
|
+ const instrumentEle = xmlParse.getElementsByTagName('virtual-instrument');
|
|
|
+ for (let index = 0; index < instrumentEle.length; index++) {
|
|
|
+ const note = instrumentEle[index]
|
|
|
+ const instrumentCode = note.getElementsByTagName('virtual-name')?.[0]?.textContent || '';
|
|
|
+ if (instrumentCode && !instrumentCodeList.includes(instrumentCode)) {
|
|
|
+ instrumentCodeList.push(instrumentCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const codeIdMap = new Map<string, string>();
|
|
|
+ state.instrumentData.forEach((data: any) => {
|
|
|
+ codeIdMap.set(data.code, data.id + '');
|
|
|
+ })
|
|
|
+ forms.musicalInstrumentIdList = [];
|
|
|
+ instrumentCodeList.forEach((code: string) => {
|
|
|
+ if (codeIdMap.has(code)) {
|
|
|
+ forms.musicalInstrumentIdList.push(codeIdMap.get(code));
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 声部
|
|
|
+ if (forms.musicalInstrumentIdList.length > 0) {
|
|
|
+ showBackSubject(forms.musicalInstrumentIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取xml中所有轨道 乐器
|
|
|
const getPartListNames = (xml: any) => {
|
|
|
if (!xml) return []
|
|
@@ -447,30 +478,30 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
// 乐器
|
|
|
- const instrumentCodeList: any = [];
|
|
|
- const instrumentEle = xmlParse.getElementsByTagName('virtual-instrument');
|
|
|
- for (let index = 0; index < instrumentEle.length; index++) {
|
|
|
- const note = instrumentEle[index]
|
|
|
- const instrumentCode = note.getElementsByTagName('virtual-name')?.[0]?.textContent || '';
|
|
|
- if (instrumentCode && !instrumentCodeList.includes(instrumentCode)) {
|
|
|
- instrumentCodeList.push(instrumentCode);
|
|
|
- }
|
|
|
- }
|
|
|
- const codeIdMap = new Map<string, string>();
|
|
|
- state.instrumentData.forEach((data: any) => {
|
|
|
- codeIdMap.set(data.code, data.id + '');
|
|
|
- })
|
|
|
- forms.musicalInstrumentIdList = [];
|
|
|
- instrumentCodeList.forEach((code: string) => {
|
|
|
- if (codeIdMap.has(code)) {
|
|
|
- forms.musicalInstrumentIdList.push(codeIdMap.get(code));
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- // 声部
|
|
|
- if (forms.musicalInstrumentIdList.length > 0) {
|
|
|
- showBackSubject(forms.musicalInstrumentIdList);
|
|
|
- }
|
|
|
+ // const instrumentCodeList: any = [];
|
|
|
+ // const instrumentEle = xmlParse.getElementsByTagName('virtual-instrument');
|
|
|
+ // for (let index = 0; index < instrumentEle.length; index++) {
|
|
|
+ // const note = instrumentEle[index]
|
|
|
+ // const instrumentCode = note.getElementsByTagName('virtual-name')?.[0]?.textContent || '';
|
|
|
+ // if (instrumentCode && !instrumentCodeList.includes(instrumentCode)) {
|
|
|
+ // instrumentCodeList.push(instrumentCode);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // const codeIdMap = new Map<string, string>();
|
|
|
+ // state.instrumentData.forEach((data: any) => {
|
|
|
+ // codeIdMap.set(data.code, data.id + '');
|
|
|
+ // })
|
|
|
+ // forms.musicalInstrumentIdList = [];
|
|
|
+ // instrumentCodeList.forEach((code: string) => {
|
|
|
+ // if (codeIdMap.has(code)) {
|
|
|
+ // forms.musicalInstrumentIdList.push(codeIdMap.get(code));
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ //
|
|
|
+ // // 声部
|
|
|
+ // if (forms.musicalInstrumentIdList.length > 0) {
|
|
|
+ // showBackSubject(forms.musicalInstrumentIdList);
|
|
|
+ // }
|
|
|
return partListNames
|
|
|
}
|
|
|
|
|
@@ -480,11 +511,16 @@ export default defineComponent({
|
|
|
const partListNames = deepClone(_names) || []
|
|
|
partListNames.forEach((item: any) => {
|
|
|
const index = forms.musicSheetSoundList.findIndex((ground: any) => item.value == ground.track)
|
|
|
- if (index > -1 && track != item.value) {
|
|
|
- item.disabled = true
|
|
|
- } else {
|
|
|
+ if (index > -1 && track == item.value) {
|
|
|
item.disabled = false
|
|
|
+ } else {
|
|
|
+ item.disabled = true
|
|
|
}
|
|
|
+ // if (index > -1 && track != item.value) {
|
|
|
+ // item.disabled = true
|
|
|
+ // } else {
|
|
|
+ // item.disabled = false
|
|
|
+ // }
|
|
|
})
|
|
|
return partListNames || []
|
|
|
}
|
|
@@ -661,11 +697,6 @@ export default defineComponent({
|
|
|
forms.sourceType = data.sourceType
|
|
|
forms.musicSheetExtend = data.musicSheetExtend
|
|
|
|
|
|
- // 初始化音轨和原音
|
|
|
- forms.musicSheetSoundList = data.musicSheetSoundList || []
|
|
|
- forms.musicSheetSoundList.forEach((next: any) => {
|
|
|
- forms.multiTracksSelection.push(next.track)
|
|
|
- })
|
|
|
|
|
|
// 获取渐变 和 是否多声部
|
|
|
try {
|
|
@@ -679,14 +710,13 @@ export default defineComponent({
|
|
|
gradualData.list = getGradualLengthByXml(res?.data as any).filter(
|
|
|
(item: any) => item.length === 2
|
|
|
)
|
|
|
- // state.partListNames = getPartListNames(res?.data as any) as any
|
|
|
- //
|
|
|
- // state.partListNames.forEach((item: any) => {
|
|
|
- // const tracks = forms.musicSheetSoundList.map((item: any) => item.track);
|
|
|
- // if (tracks.indexOf(item.label) <= -1) {
|
|
|
- // forms.musicSheetSoundList.push({audioFileUrl: '', track: item.label})
|
|
|
- // }
|
|
|
- // })
|
|
|
+ state.partListNames = getPartListNames(res?.data as any) as any
|
|
|
+
|
|
|
+ // 初始化音轨和原音
|
|
|
+ forms.musicSheetSoundList = data.musicSheetSoundList || []
|
|
|
+ forms.musicSheetSoundList.forEach((next: any) => {
|
|
|
+ forms.multiTracksSelection.push(next.track)
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
|