瀏覽代碼

Merge branch 'feature/0802-instrument' into feature/0429-musicV2

yuanliang 11 月之前
父節點
當前提交
8aff9c21d7
共有 1 個文件被更改,包括 30 次插入26 次删除
  1. 30 26
      src/views/music-library/music-sheet/modal/music-operation.tsx

+ 30 - 26
src/views/music-library/music-sheet/modal/music-operation.tsx

@@ -504,46 +504,50 @@ export default defineComponent({
       for (let index = 0; index < instrumentEle.length; index++) {
         const note = instrumentEle[index]
         let instrumentCode = note.getElementsByTagName('virtual-name')?.[0]?.textContent || ''
-        instrumentCode = instrumentCode.toLocaleLowerCase().trim()
+        instrumentCode = instrumentCode.trim().toLocaleLowerCase()
         if (instrumentCode && !instrumentCodeList.includes(instrumentCode)) {
           instrumentCodeList.push(instrumentCode)
         }
       }
       // 乐器支持多编码,暂不开放
-      // const codeIdMap = new Map<string, []>() as any
-      // state.instrumentData.forEach((data: any) => {
-      //   const codes = data.code.split(/,|,/)
-      //   codes.forEach((code: string) => {
-      //     if (codeIdMap.has(code)) {
-      //       codeIdMap.get(code).push(data.id + '')
-      //     } else {
-      //       const arr = [] as any;
-      //       arr.push(data.id + '')
-      //       codeIdMap.set(code, arr)
-      //     }
-      //     // codeIdMap.set(code, data.id + '')
-      //   })
-      // })
-      // forms.musicalInstrumentIdList = []
-      // instrumentCodeList.forEach((code: string) => {
-      //   if (codeIdMap.has(code)) {
-      //     codeIdMap.get(code).forEach((c: any) => {
-      //       forms.musicalInstrumentIdList.push(c)
-      //     })
-      //   }
-      // })
-      const codeIdMap = new Map<string, string>()
+      const codeIdMap = new Map<string, []>() as any
       state.instrumentData.forEach((data: any) => {
         if (!data.disabled) {
-          codeIdMap.set(data.code.toLocaleLowerCase().trim(), data.id + '')
+          const codes = data.code.split(/[,,]/)
+          codes.forEach((code: string) => {
+            let codeTemp = code.trim().toLowerCase()
+            if (codeIdMap.has(codeTemp)) {
+              codeIdMap.get(codeTemp).push(data.id + '')
+            } else {
+              const arr = [] as any;
+              arr.push(data.id + '')
+              codeIdMap.set(codeTemp, arr)
+            }
+          })
         }
       })
       forms.musicalInstrumentIdList = []
       instrumentCodeList.forEach((code: string) => {
         if (codeIdMap.has(code)) {
-          forms.musicalInstrumentIdList.push(codeIdMap.get(code))
+          codeIdMap.get(code).forEach((c: any) => {
+            if (!forms.musicalInstrumentIdList.includes(c)) {
+              forms.musicalInstrumentIdList.push(c)
+            }
+          })
         }
       })
+      // const codeIdMap = new Map<string, string>()
+      // state.instrumentData.forEach((data: any) => {
+      //   if (!data.disabled) {
+      //     codeIdMap.set(data.code.toLocaleLowerCase().trim(), data.id + '')
+      //   }
+      // })
+      // forms.musicalInstrumentIdList = []
+      // instrumentCodeList.forEach((code: string) => {
+      //   if (codeIdMap.has(code)) {
+      //     forms.musicalInstrumentIdList.push(codeIdMap.get(code))
+      //   }
+      // })
 
       // 声部
       if (forms.musicalInstrumentIdList.length > 0) {