1515 'no',
1616 {rules: [{ required: true, message: '请输入规则编号' }]}
1717 ]"
18+ :disabled =" true"
1819 ></a-input >
1920 </a-form-item >
2021
3536 hasFeedback
3637 validateStatus =" warning"
3738 >
38- <a-select defaultValue = " 1 " v-decorator =" ['status', {rules: [{ required: true, message: '请选择状态' }]}]" >
39+ <a-select v-decorator =" ['status', {rules: [{ required: true, message: '请选择状态' }], initialValue: '1' }]" >
3940 <a-select-option value =" 1" >Option 1</a-select-option >
4041 <a-select-option value =" 2" >Option 2</a-select-option >
4142 <a-select-option value =" 3" >Option 3</a-select-option >
6768 />
6869 </a-form-item >
6970
71+ <a-form-item
72+ v-bind =" buttonCol"
73+ >
74+ <a-row >
75+ <a-col span =" 6" >
76+ <a-button type =" primary" html-type =" submit" >提交</a-button >
77+ </a-col >
78+ <a-col span =" 10" >
79+ <a-button @click =" handleGoBack" >返回</a-button >
80+ </a-col >
81+ <a-col span =" 8" ></a-col >
82+ </a-row >
83+ </a-form-item >
7084 </a-form >
7185 </div >
7286</template >
@@ -84,19 +98,25 @@ export default {
8498 xs: { span: 24 },
8599 sm: { span: 12 }
86100 },
87- form: null ,
101+ buttonCol: {
102+ wrapperCol: {
103+ xs: { span: 24 },
104+ sm: { span: 12 , offset: 5 }
105+ }
106+ },
107+ form: this .$form .createForm (this ),
88108 id: 0
89109 }
90110 },
91- beforeCreate () {
92- this .form = this .$form .createForm (this )
93- },
94- created () {
95- if (this .$route .params .id ) {
96- this .id = this .$route .params .id
97- }
111+ mounted () {
112+ this .loadEditInfo ()
98113 },
99114 methods: {
115+ handleGoBack () {
116+ // TODO
117+ // 改为动态组件时应该把这个方法派发出去,交由父组件处理
118+ this .$router .back ()
119+ },
100120 handleSubmit () {
101121 const { form: { validateFields } } = this
102122 validateFields ((err , values ) => {
@@ -106,22 +126,16 @@ export default {
106126 }
107127 })
108128 },
109- loadEditInfo () {
110- const { from } = this
129+ loadEditInfo (data ) {
130+ const { form } = this
111131 // ajax
112132 console .log (` 将加载 ${ this .id } 信息到表单` )
113133 new Promise ((resolve ) => {
114134 setTimeout (resolve, 1500 )
115135 }).then (() => {
116- from .setFieldsValue ({ no: ' 1' , callNo: ' 999' })
136+ form .setFieldsValue ({ no: ' 1' , callNo: ' 999' })
117137 })
118138 }
119- },
120- watch: {
121- id (val , oldVal ) {
122- console .log (' val' , val, ' oldVal' , oldVal)
123- this .loadEditInfo ()
124- }
125139 }
126140}
127141 </script >
0 commit comments