Commit 6e1733ea by kokoroli

fix: fix Edit.vue bug

parent 67c4eebf
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
'no', 'no',
{rules: [{ required: true, message: '请输入规则编号' }]} {rules: [{ required: true, message: '请输入规则编号' }]}
]" ]"
:disabled="true"
></a-input> ></a-input>
</a-form-item> </a-form-item>
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
hasFeedback hasFeedback
validateStatus="warning" validateStatus="warning"
> >
<a-select defaultValue="1" v-decorator="['status', {rules: [{ required: true, message: '请选择状态' }]}]"> <a-select v-decorator="['status', {rules: [{ required: true, message: '请选择状态' }], initialValue: '1'}]">
<a-select-option value="1">Option 1</a-select-option> <a-select-option value="1">Option 1</a-select-option>
<a-select-option value="2">Option 2</a-select-option> <a-select-option value="2">Option 2</a-select-option>
<a-select-option value="3">Option 3</a-select-option> <a-select-option value="3">Option 3</a-select-option>
...@@ -67,6 +68,19 @@ ...@@ -67,6 +68,19 @@
/> />
</a-form-item> </a-form-item>
<a-form-item
v-bind="buttonCol"
>
<a-row>
<a-col span="6">
<a-button type="primary" html-type="submit">提交</a-button>
</a-col>
<a-col span="10">
<a-button @click="handleGoBack">返回</a-button>
</a-col>
<a-col span="8"></a-col>
</a-row>
</a-form-item>
</a-form> </a-form>
</div> </div>
</template> </template>
...@@ -84,19 +98,25 @@ export default { ...@@ -84,19 +98,25 @@ export default {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 12 } sm: { span: 12 }
}, },
form: null, buttonCol: {
wrapperCol: {
xs: { span: 24 },
sm: { span: 12, offset: 5 }
}
},
form: this.$form.createForm(this),
id: 0 id: 0
} }
}, },
beforeCreate () { mounted () {
this.form = this.$form.createForm(this) this.loadEditInfo()
},
created () {
if (this.$route.params.id) {
this.id = this.$route.params.id
}
}, },
methods: { methods: {
handleGoBack () {
// TODO
// 改为动态组件时应该把这个方法派发出去,交由父组件处理
this.$router.back()
},
handleSubmit () { handleSubmit () {
const { form: { validateFields } } = this const { form: { validateFields } } = this
validateFields((err, values) => { validateFields((err, values) => {
...@@ -106,22 +126,16 @@ export default { ...@@ -106,22 +126,16 @@ export default {
} }
}) })
}, },
loadEditInfo () { loadEditInfo (data) {
const { from } = this const { form } = this
// ajax // ajax
console.log(`将加载 ${this.id} 信息到表单`) console.log(`将加载 ${this.id} 信息到表单`)
new Promise((resolve) => { new Promise((resolve) => {
setTimeout(resolve, 1500) setTimeout(resolve, 1500)
}).then(() => { }).then(() => {
from.setFieldsValue({ no: '1', callNo: '999' }) form.setFieldsValue({ no: '1', callNo: '999' })
}) })
} }
},
watch: {
id (val, oldVal) {
console.log('val', val, 'oldVal', oldVal)
this.loadEditInfo()
}
} }
} }
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment