1
- <template >
2
- <a-form @submit =" handleSubmit" :autoFormCreate =" (form) => this.form = form" class =" form" >
3
- <a-row class =" form-row" :gutter =" 16" >
4
- <a-col :lg =" 6" :md =" 12" :sm =" 24" >
5
- <a-form-item
6
- label =" 仓库名"
7
- fieldDecoratorId =" repository.name"
8
- :fieldDecoratorOptions =" {rules: [{ required: true, message: '请输入仓库名称', whitespace: true}]}"
9
- >
10
- <a-input placeholder =" 请输入仓库名称" />
11
- </a-form-item >
12
- </a-col >
13
- <a-col :xl =" {span: 7, offset: 1}" :lg =" {span: 8}" :md =" {span: 12}" :sm =" 24" >
14
- <a-form-item
15
- label =" 仓库域名"
16
- fieldDecoratorId =" repository.domain"
17
- :fieldDecoratorOptions =" {rules: [{ required: true, message: '请输入仓库域名', whitespace: true}, {validator: validate}]}"
18
- >
19
- <a-input addonBefore =" http://" addonAfter =" .com" placeholder =" 请输入" />
20
- </a-form-item >
21
- </a-col >
22
- <a-col :xl =" {span: 9, offset: 1}" :lg =" {span: 10}" :md =" {span: 24}" :sm =" 24" >
23
- <a-form-item
24
- label =" 仓库管理员"
25
- fieldDecoratorId =" repository.manager"
26
- :fieldDecoratorOptions =" {rules: [{ required: true, message: '请选择管理员'}]}"
27
- >
28
- <a-select placeholder =" 请选择管理员" >
29
- <a-select-option value =" 王同学" >王同学</a-select-option >
30
- <a-select-option value =" 李同学" >李同学</a-select-option >
31
- <a-select-option value =" 黄同学" >黄同学</a-select-option >
32
- </a-select >
33
- </a-form-item >
34
- </a-col >
35
- </a-row >
36
- <a-row class =" form-row" :gutter =" 16" >
37
- <a-col :lg =" 6" :md =" 12" :sm =" 24" >
38
- <a-form-item
39
- label =" 审批人"
40
- fieldDecoratorId =" repository.auditor"
41
- :fieldDecoratorOptions =" {rules: [{ required: true, message: '请选择审批员'}]}"
42
- >
43
- <a-select placeholder =" 请选择审批员" >
44
- <a-select-option value =" 王晓丽" >王晓丽</a-select-option >
45
- <a-select-option value =" 李军" >李军</a-select-option >
46
- </a-select >
47
- </a-form-item >
48
- </a-col >
49
- <a-col :xl =" {span: 7, offset: 1}" :lg =" {span: 8}" :md =" {span: 12}" :sm =" 24" >
50
- <a-form-item
51
- label =" 生效日期"
52
- fieldDecoratorId =" repository.effectiveDate"
53
- :fieldDecoratorOptions =" {rules: [{ required: true, message: '请选择生效日期'}]}"
54
- >
55
- <a-range-picker style =" width : 100% " />
56
- </a-form-item >
57
- </a-col >
58
- <a-col :xl =" {span: 9, offset: 1}" :lg =" {span: 10}" :md =" {span: 24}" :sm =" 24" >
59
- <a-form-item
60
- label =" 仓库类型"
61
- fieldDecoratorId =" repository.type"
62
- :fieldDecoratorOptions =" {rules: [{ required: true, message: '请选择仓库类型'}]}"
63
- >
64
- <a-select placeholder =" 请选择仓库类型" >
65
- <a-select-option value =" 公开" >公开</a-select-option >
66
- <a-select-option value =" 私密" >私密</a-select-option >
67
- </a-select >
68
- </a-form-item >
69
- </a-col >
70
- </a-row >
71
- <a-form-item v-if =" showSubmit" >
72
- <a-button htmlType =" submit" >Submit</a-button >
73
- </a-form-item >
74
- </a-form >
75
- </template >
76
-
77
- <script >
78
- export default {
79
- name: " RepositoryForm" ,
80
- props: {
81
- showSubmit: {
82
- type: Boolean ,
83
- default: false
84
- }
85
- },
86
- methods: {
87
- handleSubmit (e ) {
88
- e .preventDefault ()
89
- this .form .validateFields ((err , values ) => {
90
- if (! err) {
91
- this .$notification [' error' ]({
92
- message: ' Received values of form:' ,
93
- description: values
94
- })
95
- }
96
- })
97
- },
98
- validate (rule , value , callback ) {
99
- const regex = / ^ user-(. * )$ /
100
- if (! regex .test (value)) {
101
- callback (' 需要以 user- 开头' )
102
- }
103
- callback ()
104
- }
105
- }
106
- }
107
- </script >
108
-
109
- <style scoped>
110
-
1
+ <template >
2
+ <a-form @submit =" handleSubmit" :form =" form" class =" form" >
3
+ <a-row class =" form-row" :gutter =" 16" >
4
+ <a-col :lg =" 6" :md =" 12" :sm =" 24" >
5
+ <a-form-item label =" 仓库名" >
6
+ <a-input
7
+ placeholder =" 请输入仓库名称"
8
+ v-decorator =" [
9
+ 'repository.name',
10
+ {rules: [{ required: true, message: '请输入仓库名称', whitespace: true}]}
11
+ ]" />
12
+ </a-form-item >
13
+ </a-col >
14
+ <a-col :xl =" {span: 7, offset: 1}" :lg =" {span: 8}" :md =" {span: 12}" :sm =" 24" >
15
+ <a-form-item
16
+ label =" 仓库域名" >
17
+ <a-input
18
+ addonBefore =" http://"
19
+ addonAfter =" .com"
20
+ placeholder =" 请输入"
21
+ v-decorator =" [
22
+ 'repository.domain',
23
+ {rules: [{ required: true, message: '请输入仓库域名', whitespace: true}, {validator: validate}]}
24
+ ]" />
25
+ </a-form-item >
26
+ </a-col >
27
+ <a-col :xl =" {span: 9, offset: 1}" :lg =" {span: 10}" :md =" {span: 24}" :sm =" 24" >
28
+ <a-form-item
29
+ label =" 仓库管理员" >
30
+ <a-select placeholder =" 请选择管理员" v-decorator =" [ 'repository.manager', {rules: [{ required: true, message: '请选择管理员'}]} ]" >
31
+ <a-select-option value =" 王同学" >王同学</a-select-option >
32
+ <a-select-option value =" 李同学" >李同学</a-select-option >
33
+ <a-select-option value =" 黄同学" >黄同学</a-select-option >
34
+ </a-select >
35
+ </a-form-item >
36
+ </a-col >
37
+ </a-row >
38
+ <a-row class =" form-row" :gutter =" 16" >
39
+ <a-col :lg =" 6" :md =" 12" :sm =" 24" >
40
+ <a-form-item
41
+ label =" 审批人" >
42
+ <a-select placeholder =" 请选择审批员" v-decorator =" [ 'repository.auditor', {rules: [{ required: true, message: '请选择审批员'}]} ]" >
43
+ <a-select-option value =" 王晓丽" >王晓丽</a-select-option >
44
+ <a-select-option value =" 李军" >李军</a-select-option >
45
+ </a-select >
46
+ </a-form-item >
47
+ </a-col >
48
+ <a-col :xl =" {span: 7, offset: 1}" :lg =" {span: 8}" :md =" {span: 12}" :sm =" 24" >
49
+ <a-form-item
50
+ label =" 生效日期" >
51
+ <a-range-picker
52
+ style =" width : 100% "
53
+ v-decorator =" [
54
+ 'repository.effectiveDate',
55
+ {rules: [{ required: true, message: '请选择生效日期'}]}
56
+ ]" />
57
+ </a-form-item >
58
+ </a-col >
59
+ <a-col :xl =" {span: 9, offset: 1}" :lg =" {span: 10}" :md =" {span: 24}" :sm =" 24" >
60
+ <a-form-item
61
+ label =" 仓库类型" >
62
+ <a-select
63
+ placeholder =" 请选择仓库类型"
64
+ v-decorator =" [
65
+ 'repository.type',
66
+ {rules: [{ required: true, message: '请选择仓库类型'}]}
67
+ ]" >
68
+ <a-select-option value =" 公开" >公开</a-select-option >
69
+ <a-select-option value =" 私密" >私密</a-select-option >
70
+ </a-select >
71
+ </a-form-item >
72
+ </a-col >
73
+ </a-row >
74
+ <a-form-item v-if =" showSubmit" >
75
+ <a-button htmlType =" submit" >Submit</a-button >
76
+ </a-form-item >
77
+ </a-form >
78
+ </template >
79
+
80
+ <script >
81
+ export default {
82
+ name: " RepositoryForm" ,
83
+ props: {
84
+ showSubmit: {
85
+ type: Boolean ,
86
+ default: false
87
+ }
88
+ },
89
+ data () {
90
+ return {
91
+ form: this .$form .createForm (this )
92
+ }
93
+ },
94
+ methods: {
95
+ handleSubmit (e ) {
96
+ e .preventDefault ()
97
+ this .form .validateFields ((err , values ) => {
98
+ if (! err) {
99
+ this .$notification [' error' ]({
100
+ message: ' Received values of form:' ,
101
+ description: values
102
+ })
103
+ }
104
+ })
105
+ },
106
+ validate (rule , value , callback ) {
107
+ const regex = / ^ user-(. * )$ /
108
+ if (! regex .test (value)) {
109
+ callback (' 需要以 user- 开头' )
110
+ }
111
+ callback ()
112
+ }
113
+ }
114
+ }
115
+ </script >
116
+
117
+ <style scoped>
118
+
111
119
</style >
0 commit comments