Commit 7af00356a9d8d80c06366f639791982ee2757a68
1 parent
fed3e09d
update AutoComplete
Showing
4 changed files
with
8 additions
and
3 deletions
Show diff stats
examples/routers/auto-complete.vue
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | ] | 30 | ] |
31 | }, | 31 | }, |
32 | hc (v) { | 32 | hc (v) { |
33 | - console.log(v) | 33 | +// console.log(v) |
34 | }, | 34 | }, |
35 | fm (value, item) { | 35 | fm (value, item) { |
36 | return item.toUpperCase().indexOf(value.toUpperCase()) !== -1; | 36 | return item.toUpperCase().indexOf(value.toUpperCase()) !== -1; |
examples/routers/form.vue
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80"> | 2 | <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80"> |
3 | <Form-item prop="name"> | 3 | <Form-item prop="name"> |
4 | <span slot="label"><Icon type="ionic"></Icon></span> | 4 | <span slot="label"><Icon type="ionic"></Icon></span> |
5 | - <Input v-model="formValidate.name" placeholder="请输入姓名"></Input> | 5 | + <AutoComplete v-model="formValidate.name" :data="['Li','Liang','Zhang']" placeholder="请输入姓名"></AutoComplete> |
6 | </Form-item> | 6 | </Form-item> |
7 | <Form-item label="邮箱" prop="mail"> | 7 | <Form-item label="邮箱" prop="mail"> |
8 | <Input v-model="formValidate.mail" placeholder="请输入邮箱"></Input> | 8 | <Input v-model="formValidate.mail" placeholder="请输入邮箱"></Input> |
@@ -56,6 +56,7 @@ | @@ -56,6 +56,7 @@ | ||
56 | export default { | 56 | export default { |
57 | data () { | 57 | data () { |
58 | return { | 58 | return { |
59 | + name: '', | ||
59 | formValidate: { | 60 | formValidate: { |
60 | name: '', | 61 | name: '', |
61 | mail: '', | 62 | mail: '', |
@@ -68,7 +69,7 @@ | @@ -68,7 +69,7 @@ | ||
68 | }, | 69 | }, |
69 | ruleValidate: { | 70 | ruleValidate: { |
70 | name: [ | 71 | name: [ |
71 | - { required: true, message: '姓名不能为空', trigger: 'blur' } | 72 | + { required: true, message: '姓名不能为空', trigger: 'change' } |
72 | ], | 73 | ], |
73 | mail: [ | 74 | mail: [ |
74 | { required: true, message: '邮箱不能为空', trigger: 'blur' }, | 75 | { required: true, message: '邮箱不能为空', trigger: 'blur' }, |
src/components/auto-complete/auto-complete.vue
@@ -36,9 +36,11 @@ | @@ -36,9 +36,11 @@ | ||
36 | import iOption from '../select/option.vue'; | 36 | import iOption from '../select/option.vue'; |
37 | import iInput from '../input/input.vue'; | 37 | import iInput from '../input/input.vue'; |
38 | import { oneOf } from '../../utils/assist'; | 38 | import { oneOf } from '../../utils/assist'; |
39 | + import Emitter from '../../mixins/emitter'; | ||
39 | 40 | ||
40 | export default { | 41 | export default { |
41 | name: 'AutoComplete', | 42 | name: 'AutoComplete', |
43 | + mixins: [ Emitter ], | ||
42 | components: { iSelect, iOption, iInput }, | 44 | components: { iSelect, iOption, iInput }, |
43 | props: { | 45 | props: { |
44 | value: { | 46 | value: { |
@@ -103,6 +105,7 @@ | @@ -103,6 +105,7 @@ | ||
103 | this.$refs.select.query = val; | 105 | this.$refs.select.query = val; |
104 | this.$emit('input', val); | 106 | this.$emit('input', val); |
105 | this.$emit('on-change', val); | 107 | this.$emit('on-change', val); |
108 | + this.dispatch('FormItem', 'on-form-change', val); | ||
106 | } | 109 | } |
107 | }, | 110 | }, |
108 | methods: { | 111 | methods: { |
src/components/select/select.vue
@@ -685,6 +685,7 @@ | @@ -685,6 +685,7 @@ | ||
685 | 685 | ||
686 | this.$on('on-select-selected', (value) => { | 686 | this.$on('on-select-selected', (value) => { |
687 | if (this.model === value) { | 687 | if (this.model === value) { |
688 | + if (this.autoComplete) this.$emit('on-change', value); | ||
688 | this.hideMenu(); | 689 | this.hideMenu(); |
689 | } else { | 690 | } else { |
690 | if (this.multiple) { | 691 | if (this.multiple) { |