form.vue
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<el-dialog :close-on-click-modal="false" title="新增ip" width="500px" :visible.sync="visible">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="40px">
<el-form-item label="ip" prop="ip">
<el-input
type="textarea"
:autosize="{ minRows: 6, maxRows: 6}"
placeholder="支持多条批量录入,ip间用英文逗号间隔"
v-model="form.ip">
</el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="doCancel">取消</el-button>
<el-button type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import {
addBlack
} from '@/api/risk'
export default {
name: 'AdForm',
data () {
return {
visible: false,
form: {
ip: '',
type: 1,
},
rules: {
ip: [
{ required: true, message: '请输入ip', trigger: 'blur' }
]
}
}
},
methods: {
// 打开弹出窗
show (row) {
this.form = {
ip: '',
type: 1,
}
this.visible = true
},
// 取消
doCancel () {
this.visible = false
},
// 提交
doSubmit () {
this.$refs['form'].validate((valid) => {
if (valid) {
addBlack(this.form).then(res => {
this.$message({
message: '新增成功',
type: 'success'
})
this.$emit('reset')
this.visible = false
}).catch(err => {
this.visible = false
})
}
})
}
}
}
</script>