|
1
|
<template>
|
|
2
|
<a-card :bordered="false">
|
|
3
|
<a-form-model ref="form" :model="model" :rules="rules" @submit="handleSubmit">
|
|
4
|
<a-row>
|
|
5
|
<a-col :md="24" :sm="24">
|
|
6
7
8
|
<a-form-model-item label="Note" prop="note" :labelCol="{ span: 7 }" :wrapperCol="{ span: 15 }">
<a-input v-model="model.note"/>
</a-form-model-item>
|
|
9
|
</a-col>
|
|
10
11
|
</a-row>
<a-row>
|
|
12
|
<a-col :md="24" :sm="24">
|
|
13
14
|
<a-form-model-item label="Gender" prop="gender" :labelCol="{ span: 7 }" :wrapperCol="{ span: 15 }">
<a-select v-model="model.gender" placeholder="Select a option and change input text above" @change="handleSelectChange">
|
|
15
16
17
|
<a-select-option value="male">male</a-select-option>
<a-select-option value="female">female</a-select-option>
</a-select>
|
|
18
|
</a-form-model-item>
|
|
19
|
</a-col>
|
|
20
21
|
</a-row>
<a-row>
|
|
22
|
<a-col :md="24" :sm="24">
|
|
23
|
<a-form-model-item label="Gender" prop="cascader" :labelCol="{ span: 7 }" :wrapperCol="{ span: 15 }">
|
|
24
|
<a-cascader :options="areaOptions" @change="onChange" :showSearch="{filter}" placeholder="Please select" />
|
|
25
|
</a-form-model-item>
|
|
26
|
</a-col>
|
|
27
|
</a-row>
|
|
28
|
<a-form-model-item :wrapperCol="{ span: 12, offset: 5 }">
|
|
29
|
<a-col :md="24" :sm="24">
|
|
30
|
<a-form-model-item :wrapperCol="{ span: 12, offset: 5 }">
|
|
31
|
<a-button type="primary" htmlType="submit">Submit</a-button>
|
|
32
|
</a-form-model-item>
|
|
33
|
</a-col>
|
|
34
35
|
</a-form-model-item>
</a-form-model>
|
|
36
|
</a-card>
|
|
37
38
39
|
</template>
<script>
|
|
40
|
import { getAction } from '@/api/manage'
|
|
41
|
export default {
|
|
42
|
props: ['sex','name'],
|
|
43
44
45
|
data () {
return {
formLayout: 'horizontal',
|
|
46
47
48
49
50
|
model: {},
rules: {
note: [{required: true, message: 'Please input your note!'}],
gender:[{ required: true, message: 'Please select your gender!' }]
},
|
|
51
|
areaOptions:[]
|
|
52
53
54
55
56
|
}
},
methods: {
handleSubmit (e) {
e.preventDefault()
|
|
57
58
59
60
|
this.$refs.form.validate((ok, err) => {
if (ok) {
console.log('Received values of form: ', this.model)
this.$message.success('succeed!')
|
|
61
62
63
64
65
|
}
})
},
handleSelectChange (value) {
console.log(value)
|
|
66
|
this.model.note = `Hi, ${value === 'male' ? 'man' : 'lady'}!`
|
|
67
|
},
|
|
68
69
70
71
72
73
|
onChange(value, selectedOptions) {
console.log(value, selectedOptions);
},
filter(inputValue, path) {
return (path.some(option => (option.label).toLowerCase().indexOf(inputValue.toLowerCase()) > -1));
},
|
|
74
|
},
|
|
75
|
created (){
|
|
76
77
78
79
|
console.log('============= online href common props ============= ');
console.log('props sex: ',this.sex);
console.log('props name: ',this.name);
|
|
80
|
getAction('/mock/api/area').then((res) => {
|
|
81
82
83
84
|
console.log("------------")
console.log(res)
this.areaOptions = res;
})
|
|
85
86
87
88
89
90
91
92
93
94
95
|
},
watch: {
$route: {
immediate: true,
handler() {
console.log('============= online href $route props ============= ');
let sex = this.$route.query.sex
console.log('$route sex: ', sex);
}
}
},
|
|
96
97
|
}
</script>
|