Browse Source

🐞 fix: 调整位置

wolyshaw 3 years ago
parent
commit
058e846351
1 changed files with 20 additions and 6 deletions
  1. 20 6
      src/teacher/music/upload/index.tsx

+ 20 - 6
src/teacher/music/upload/index.tsx

@@ -50,7 +50,9 @@ export default defineComponent({
       midiUrl: '',
       midiLoading: false,
       mp3Url: '',
+      bgmp3Url: '',
       mp3Loading: false,
+      bgmp3Loading: false,
       musicSheetName: '',
       composer: '',
       speed: '',
@@ -156,9 +158,9 @@ export default defineComponent({
             composer: this.composer,
             musicPrice: this.musicPrice,
             background: this.backgroundMp3s.map(item => ({
-              audioFileUrl: this.hasBeat ? '' : item.url,
+              audioFileUrl: this.hasBeat ? '' : this.bgmp3Url,
               track: item.track,
-              metronomeUrl: this.hasBeat ? item.url : ''
+              metronomeUrl: this.hasBeat ? this.bgmp3Url : ''
             }))
           }
         })
@@ -253,6 +255,16 @@ export default defineComponent({
         // this.midiUrl = path
       })
     },
+    naiveBGMp3File() {
+      this.bgmp3Loading = true
+      postMessage({ api: 'chooseFile', content: { type: 'mp3' } }, evt => {
+        this.bgmp3Url
+        // @ts-ignore
+        this.bgmp3Url = evt?.fileUrl || this.bgmp3Url || ''
+        this.bgmp3Loading = false
+        // this.midiUrl = path
+      })
+    },
     fileName(name = '') {
       return name.split('/').pop()
     }
@@ -395,7 +407,7 @@ export default defineComponent({
               <ColField required border={false} title="原音文件">
                 <Field
                   name="url"
-                  modelValue={item.url}
+                  modelValue={this.bgmp3Url}
                   rules={[{ required: true, message: '请选择原音文件' }]}
                   // @ts-ignore
                   vSlots={{
@@ -404,14 +416,16 @@ export default defineComponent({
                         <Button
                           icon={UploadIcon}
                           class={styles.upbtn}
-                          onClick={this.naiveMp3File}
+                          onClick={this.naiveBGMp3File}
                           loading={this.mp3Loading}
                         >
-                          {item.url ? this.fileName(item.url) : '上传文件'}
+                          {this.bgmp3Url
+                            ? this.fileName(this.bgmp3Url)
+                            : '上传文件'}
                         </Button>
                       ) : (
                         <Upload
-                          onUpdate:modelValue={val => (item.url = val)}
+                          onUpdate:modelValue={val => (this.bgmp3Url = val)}
                           accept=".mp3"
                         />
                       )