fixed missing form validation before uploading spider file error

This commit is contained in:
marvzhang
2020-01-17 14:12:53 +08:00
parent 128df1c4a2
commit 4a3d48dde6

View File

@@ -55,7 +55,9 @@
:data="uploadForm"
:headers="{Authorization:token}"
:on-success="onUploadSuccess"
:file-list="fileList">
:file-list="fileList"
:before-upload="beforeUpload"
>
<el-button size="small" type="primary" icon="el-icon-upload">
{{$t('Upload')}}
</el-button>
@@ -557,6 +559,17 @@ export default {
// navigate to spider detail
this.$router.push(`/spiders/${res.data._id}`)
},
beforeUpload (file) {
return new Promise((resolve, reject) => {
this.$refs['addCustomizedForm'].validate(res => {
if (res) {
resolve()
} else {
reject(new Error('form validation error'))
}
})
})
},
getTime (str) {
if (!str || str.match('^0001')) return 'NA'
return dayjs(str).format('YYYY-MM-DD HH:mm:ss')