<el-dialog
:close-on-click-modal="false"
:visible.sync="phoneRecordInfo.visible"
:append-to-body="true"
:show-close="false"
width="400px"
class="m-dialog"
>
<div class="body">
<el-form
:before-close="closeDialog"
ref="form"
:model="phoneRecordInfo"
:rules="rules"
:validate-on-rule-change="false"
label-width="100px"
>
<el-form-item>
<el-upload
class="upload-demo"
ref="upload"
action="*****"
:auto-upload="false"
:file-list="phoneRecordInfo.fileList"
:http-request="submitRecord"
>
<el-button slot="trigger" size="small" type="primary">上传通话录音</el-button>
<div slot="tip" class="el-upload__tip">只能上传wav/mp3/amr</div>
</el-upload>
</el-form-item>
</el-form>
</div>
<div slot="footer" class="btn-group">
<span class="u-btn" @click="closeDialog">取消</span>
<span class="u-btn s-important" @click="onSubmit">提交</span>
</div>
</el-dialog>
/**
* 提交通话记录
*/
onSubmit () {
this.$refs['form'].validate((valid) => {
if (valid) {
// 将status改为ready是避免第二次提交不响应问题
this.phoneRecordInfo.fileList[0].status = 'ready'
this.$refs.upload.submit()
}
})
},
submitRecord () {
// 向后台发送请求。。。。。
},
背景:
每次上传文件提交到后台,提交失败之后,再次点击提交无反应,不会请求后端
备注:删除了些不相关的代码
解决方式:
将fileList的status改为ready,每次form验证成功之后进行修改
this.phoneRecordInfo.fileList[0].status = 'ready'