|
@@ -450,6 +450,73 @@ export default defineComponent({
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ /** 获取分轨名称 */
|
|
|
|
+ const getInstrumentNameCode = (instruments: any, name = '') => {
|
|
|
|
+ name = name.toLocaleLowerCase().replace(/ /g, '').replace(/\d*/gi, '');
|
|
|
|
+ if (!name) return '';
|
|
|
|
+ for (let key of instruments) {
|
|
|
|
+ const _key = key.toLocaleLowerCase().replace(/ /g, '');
|
|
|
|
+ // if (_key.includes(name)) {
|
|
|
|
+ // return key
|
|
|
|
+ // }
|
|
|
|
+ if (_key === name) {
|
|
|
|
+ return _key;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // for (let key of instruments) {
|
|
|
|
+ // const _key = key.toLocaleLowerCase().replace(/ /g, '')
|
|
|
|
+ // if (name.includes(_key)) {
|
|
|
|
+ // return key
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ return '';
|
|
|
|
+ };
|
|
|
|
+ // 通过乐器编码返回乐器编号
|
|
|
|
+ const instrumentCodeToInstrumentId = (
|
|
|
|
+ subjectList: Array<any>,
|
|
|
|
+ code: string
|
|
|
|
+ ) => {
|
|
|
|
+ const codeIdMap = new Map<string, []>() as any;
|
|
|
|
+ const codeMapKeys: string[] = [];
|
|
|
|
+ subjectList.forEach((data: any) => {
|
|
|
|
+ if (data.enableFlag) {
|
|
|
|
+ const codes = data.code.split(/[,,]/);
|
|
|
|
+ codes.forEach((code: string) => {
|
|
|
|
+ let codeTemp = code.replaceAll(' ', '').toLowerCase();
|
|
|
|
+ codeMapKeys.push(codeTemp);
|
|
|
|
+ if (codeIdMap.has(codeTemp)) {
|
|
|
|
+ codeIdMap.get(codeTemp).push(data.id + '');
|
|
|
|
+ } else {
|
|
|
|
+ const arr = [] as any;
|
|
|
|
+ arr.push(data.id + '');
|
|
|
|
+ codeIdMap.set(codeTemp, arr);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (!code) {
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ code = code.replaceAll(' ', '').toLowerCase();
|
|
|
|
+ const tempCode = getInstrumentNameCode(codeMapKeys, code);
|
|
|
|
+ if (codeIdMap.has(tempCode)) {
|
|
|
|
+ const result = codeIdMap.get(tempCode);
|
|
|
|
+ console.log('result:', result);
|
|
|
|
+ return result[0] || '';
|
|
|
|
+ }
|
|
|
|
+ return '';
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 初始化编号
|
|
|
|
+ const initUserDefaultInstrument = () => {
|
|
|
|
+ const userInstrumentId = state.user.data.instrumentId;
|
|
|
|
+ const item = data.trackList.find(
|
|
|
|
+ (track: any) => track.instrumentId === userInstrumentId + ''
|
|
|
|
+ );
|
|
|
|
+ data.selectMusicInstrumentIndex = item ? item.value : 0;
|
|
|
|
+ };
|
|
|
|
+
|
|
// 过滤出能切换的分轨
|
|
// 过滤出能切换的分轨
|
|
const filterTracks = (xml: any) => {
|
|
const filterTracks = (xml: any) => {
|
|
const xmlParse = new DOMParser().parseFromString(xml, 'text/xml');
|
|
const xmlParse = new DOMParser().parseFromString(xml, 'text/xml');
|
|
@@ -473,6 +540,8 @@ export default defineComponent({
|
|
const canSelectTracks = multiTracksSelection
|
|
const canSelectTracks = multiTracksSelection
|
|
? multiTracksSelection?.split(',')
|
|
? multiTracksSelection?.split(',')
|
|
: [];
|
|
: [];
|
|
|
|
+ const musicalInstruments =
|
|
|
|
+ data.musics[data.musicIndex]?.musicalInstruments || [];
|
|
// console.log(canSelectTracks, partListNames);
|
|
// console.log(canSelectTracks, partListNames);
|
|
const arr = partListNames
|
|
const arr = partListNames
|
|
.map((item: any, index: number) => {
|
|
.map((item: any, index: number) => {
|
|
@@ -481,12 +550,17 @@ export default defineComponent({
|
|
canSelectTracks.length == 0 || canSelectTracks.includes(item)
|
|
canSelectTracks.length == 0 || canSelectTracks.includes(item)
|
|
? true
|
|
? true
|
|
: false;
|
|
: false;
|
|
- // console.log(canselect,index)
|
|
|
|
|
|
+
|
|
const instrumentName = getInstrumentName(item);
|
|
const instrumentName = getInstrumentName(item);
|
|
|
|
+ const instrumentId = instrumentCodeToInstrumentId(
|
|
|
|
+ musicalInstruments,
|
|
|
|
+ item
|
|
|
|
+ );
|
|
const sortId = sortMusical(instrumentName, index);
|
|
const sortId = sortMusical(instrumentName, index);
|
|
return {
|
|
return {
|
|
text: item + (instrumentName ? `(${instrumentName})` : ''),
|
|
text: item + (instrumentName ? `(${instrumentName})` : ''),
|
|
value: index,
|
|
value: index,
|
|
|
|
+ instrumentId,
|
|
sortId,
|
|
sortId,
|
|
canselect,
|
|
canselect,
|
|
track: item
|
|
track: item
|
|
@@ -498,7 +572,8 @@ export default defineComponent({
|
|
// 是否显示总谱
|
|
// 是否显示总谱
|
|
const selectMusic = data.musics[data.musicIndex];
|
|
const selectMusic = data.musics[data.musicIndex];
|
|
if (selectMusic) {
|
|
if (selectMusic) {
|
|
- selectMusic.isScoreRender &&
|
|
|
|
|
|
+ const musicalInstruments = selectMusic.musicalInstruments || [];
|
|
|
|
+ if (selectMusic.isScoreRender) {
|
|
data.trackList.unshift({
|
|
data.trackList.unshift({
|
|
text: '总谱',
|
|
text: '总谱',
|
|
value: 999,
|
|
value: 999,
|
|
@@ -506,6 +581,15 @@ export default defineComponent({
|
|
canselect: true,
|
|
canselect: true,
|
|
track: 999
|
|
track: 999
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ if (selectMusic.defaultScoreRender) {
|
|
|
|
+ data.selectMusicInstrumentIndex = 999;
|
|
|
|
+ } else {
|
|
|
|
+ initUserDefaultInstrument();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ initUserDefaultInstrument();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// let track = arr.find(
|
|
// let track = arr.find(
|
|
@@ -597,6 +681,8 @@ export default defineComponent({
|
|
|
|
|
|
initLoadingObv();
|
|
initLoadingObv();
|
|
|
|
|
|
|
|
+ console.log(state.user.data);
|
|
|
|
+
|
|
const getUserInfo = async () => {
|
|
const getUserInfo = async () => {
|
|
const res = await request.get('/edu-app/user/getUserInfo', {
|
|
const res = await request.get('/edu-app/user/getUserInfo', {
|
|
initRequest: true, // 初始化接口
|
|
initRequest: true, // 初始化接口
|
|
@@ -614,9 +700,10 @@ export default defineComponent({
|
|
listenerMessage('webViewOnResume', () => {
|
|
listenerMessage('webViewOnResume', () => {
|
|
console.log('页面显示', data.iframeSrc);
|
|
console.log('页面显示', data.iframeSrc);
|
|
getUserInfo();
|
|
getUserInfo();
|
|
- data.typeIndex = 0;
|
|
|
|
- data.musicIndex = 0;
|
|
|
|
- handleReset();
|
|
|
|
|
|
+ // 为了处理返回显示刷新的问题
|
|
|
|
+ // data.typeIndex = 0;
|
|
|
|
+ // data.musicIndex = 0;
|
|
|
|
+ // handleReset();
|
|
});
|
|
});
|
|
setSearchBox();
|
|
setSearchBox();
|
|
});
|
|
});
|
|
@@ -747,9 +834,13 @@ export default defineComponent({
|
|
// 是否显示总谱
|
|
// 是否显示总谱
|
|
const selectMusic = data.musics[data.musicIndex];
|
|
const selectMusic = data.musics[data.musicIndex];
|
|
if (selectMusic && selectMusic.isScoreRender) {
|
|
if (selectMusic && selectMusic.isScoreRender) {
|
|
- data.selectMusicInstrumentIndex = 999;
|
|
|
|
|
|
+ if (selectMusic.defaultScoreRender) {
|
|
|
|
+ data.selectMusicInstrumentIndex = 999;
|
|
|
|
+ } else {
|
|
|
|
+ initUserDefaultInstrument();
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- data.selectMusicInstrumentIndex = 0;
|
|
|
|
|
|
+ initUserDefaultInstrument();
|
|
}
|
|
}
|
|
musicIframeLoad();
|
|
musicIframeLoad();
|
|
}}>
|
|
}}>
|