index.vue
2.23 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
<div>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item label="文档标题" prop="docTitle">
<a-input
v-model="form.docTitle"
/>
</a-form-model-item>
<a-form-model-item label="文档地址" prop="docUrl">
<a-input
v-model="form.docUrl"
/>
</a-form-model-item>
<a-form-model-item label="文档描述" prop="docDescription">
<a-input v-model="form.docDescription" type="textarea" />
</a-form-model-item>
<a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" @click="onSubmit">
创建
</a-button>
<a-button style="margin-left: 10px;" @click="resetForm">
重置
</a-button>
<a-button style="margin-left: 10px;" @click="closeForm">
关闭
</a-button>
</a-form-model-item>
</a-form-model>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: '',
data () {
return {
labelCol: { span: 4 },
wrapperCol: { span: 14 },
form: {
docTitle: '',
docUrl: '',
docDescription: '',
},
rules: {
docTitle: [
{ required: true, message: '请输入文档名称', trigger: 'blur' },
{ min: 1, max: 30, message: '请输入字符1~50之间', trigger: 'blur' },
],
docUrl: [{ required: true, message: '请输入文档地址', trigger: 'blur' }],
docDescription: [{ required: true, message: '请输入文档描述', trigger: 'blur' }],
},
}
},
mounted () {
},
methods: {
onSubmit() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
console.log(this.form)
this.api.documentation.create(this.form).then(res => {
console.log(res)
this.$message.success('添加成功')
this.closeForm()
})
} else {
return false;
}
});
},
resetForm() {
this.$refs.ruleForm.resetFields();
},
closeForm() {
this.to(-1)
}
}
}
</script>
<style scoped lang="scss"></style>