huangmp 2 лет назад
Родитель
Сommit
c370c2d0cb
1 измененных файлов с 43 добавлено и 10 удалено
  1. 43 10
      src/components/yuyin-preview/index.vue

+ 43 - 10
src/components/yuyin-preview/index.vue

@@ -13,11 +13,12 @@
       :model="dataForm"
       size="small">
       <el-form-item label="昵称">
-        <el-input v-model="dataForm.cardNote.authorName" :disabled="true"></el-input>
+        <el-input v-model="dataForm.cardNote.authorName"></el-input>
       </el-form-item>
       <el-form-item label="祝福的话语">
-        <el-button type="success" size="mini" :loading="transLoading" @click="translateTxt">翻译</el-button>
-        <el-input v-model="dataForm.cardNote.personalSign" type="textarea" :disabled="true"></el-input>
+        <el-button size="mini" @click="personalSignEdit = !personalSignEdit">编辑</el-button>
+        <el-button v-if="dataForm.cardNote.type === 'AI'" type="success" size="mini" :loading="transLoading" @click="translateTxt">翻译</el-button>
+        <el-input v-model="dataForm.cardNote.personalSign" type="textarea" :disabled="personalSignEdit"></el-input>
       </el-form-item>
       <el-form-item label="翻译文本">
         <el-button type="primary" size="mini" :loading="transLoading" @click="tts">生成语音</el-button>
@@ -25,7 +26,7 @@
         <el-input v-model="dataForm.cardNote.foreignTxt" type="textarea"></el-input>
       </el-form-item>
       <el-form-item label="声音模型">
-        <span>{{dataForm.cardNote.modelName}}</span>
+        <span style="color:red">{{dataForm.cardNote.modelName}}</span>
       </el-form-item>
       <el-row>
         <el-col :span="dataForm.cardNote.type === 'AI' ? 12 : 8">
@@ -38,6 +39,7 @@
         </el-col>
         <el-col :span="dataForm.cardNote.type === 'AI' ? 12 : 8">
           <el-form-item label="语音内容">
+            <el-button size="mini" @click="changeAudio">更换音频</el-button>
             <br/>
             <video v-if="dataForm.cardNote.audioUrl"
               style="width: 300px; height: 210px"
@@ -56,21 +58,28 @@
         </el-col>
       </el-row>
       <el-form-item>
-        <div style="width: 100%; text-align: center;" v-if="!dataForm.cardNote.type === 'AI'">
-          <el-button type="primary" size="large" @click="repairVideo">转换语音</el-button>
-          <el-button type="success" size="large" @click="confirmChangeVideo">确认修改</el-button>
+        <div style="width: 100%; text-align: center;">
+          <el-button v-if="!(dataForm.cardNote.type === 'AI')" type="primary" size="large" @click="repairVideo">转换语音</el-button>
+          <el-button v-if="!(dataForm.cardNote.type === 'AI')" type="success" size="large" @click="confirmChangeVideo">确认更换</el-button>
+          <el-button type="success" size="large" @click="onSave">保存</el-button>
         </div>
       </el-form-item>
     </el-form>
+    <audio-box v-if="audioBoxVisible" ref="audioBox" @refreshPic="refreshAudio"></audio-box>
   </el-dialog>
-
 </template>
 
 <script>
+  import AudioBox from '@/components/AudioBox'
   export default {
+    components: {
+      AudioBox
+    },
     name: "YuyinPreview",
     data() {
       return {
+        personalSignEdit: true,
+        audioBoxVisible: false,
         visible: false,
         dataForm:{cardNote:{}, qrNoteMapping:{}},
         newAudioUrl: null,
@@ -81,6 +90,29 @@
     mounted() {
     },
     methods: {
+      changeAudio(){
+        this.audioBoxVisible = true
+        this.$nextTick(() => {
+          this.$refs.audioBox.init(1)
+        })
+      },
+      refreshAudio(filePath){
+        this.newAudioUrl = filePath;
+      },
+      onSave(){
+        this.$http({
+          url: this.$http.adornUrl('/cardNote'),
+          method: 'PUT',
+          data: this.$http.adornData(this.dataForm.cardNote)
+        }).then(({ data }) =>{
+          if(data){
+            this.visible = false;
+            this.$message.success("保存成功")
+          }else{
+            this.$message.error("保存失败")
+          }
+        })
+      },
       syncTTS(){
         this.$http({
           url: this.$http.adornUrl('/qrNoteMapping/getAIAudio'),
@@ -159,7 +191,8 @@
         });
       },
       confirmChangeVideo(){
-        this.$confirm('确定要保存新语音吗?', '提示', {
+        this.dataForm.cardNote.audioUrl = this.newAudioUrl;
+        /*this.$confirm('确定要保存新语音吗?', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning'
@@ -176,7 +209,7 @@
               this.$message.error("转换失败")
             }
           })
-        });
+        });*/
       },
       closeDialog(){
         this.visible = false