| | |
| | | </el-form-item> |
| | | <el-form-item label="语音:" prop="audioFile" required> |
| | | <el-upload v-model="form.audioFile" :action="uploadUrl" :limit="1" accept="audio/*" :on-success="uploadSuccess" |
| | | :file-list="audioList"> |
| | | :on-remove="handleRemove" :file-list="audioList"> |
| | | <el-button size="small" type="primary">点击上传</el-button> |
| | | <el-button v-if="form.audioFile" size="small" type="primary" @click.stop="audioPlay(form.audioFile)">{{ |
| | | audioInstance ? '暂停' : '试听' }}</el-button> |
| | | </el-upload> |
| | | </el-form-item> |
| | | <el-form-item label="选项:" required> |
| | |
| | | dialog: false, |
| | | question: null, |
| | | loading: false |
| | | } |
| | | }, |
| | | audioInstance: null |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | handleRemove() { |
| | | this.form.audioFile = '' |
| | | }, |
| | | audioPlay(url) { |
| | | if (this.audioInstance) { |
| | | this.audioInstance.pause(); |
| | | this.audioInstance = null; |
| | | } else { |
| | | this.audioInstance = new Audio('/api/files/' + url); |
| | | this.audioInstance.play(); |
| | | } |
| | | }, |
| | | uploadSuccess(response) { |
| | | this.form.audioFile = response.data.url; |
| | | this.form.originalFile = response.data.name; |