Commit 2baba209b73ee5e30103a4a0fbb7d470398e571e

Authored by 梁灏
1 parent b904fd87

update ColorPicker

examples/routers/form.vue
@@ -5,7 +5,8 @@ @@ -5,7 +5,8 @@
5 <AutoComplete v-model="formValidate.name" :data="['Li','Liang','Zhang']" placeholder="请输入姓名"></AutoComplete> 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>-->
  9 + <ColorPicker v-model="formValidate.mail"></ColorPicker>
9 </Form-item> 10 </Form-item>
10 <Form-item label="城市" prop="city"> 11 <Form-item label="城市" prop="city">
11 <Select v-model="formValidate.city" placeholder="请选择所在地"> 12 <Select v-model="formValidate.city" placeholder="请选择所在地">
@@ -72,8 +73,7 @@ @@ -72,8 +73,7 @@
72 { required: true, message: '姓名不能为空', trigger: 'change' } 73 { required: true, message: '姓名不能为空', trigger: 'change' }
73 ], 74 ],
74 mail: [ 75 mail: [
75 - { required: true, message: '邮箱不能为空', trigger: 'blur' },  
76 - { type: 'email', message: '邮箱格式不正确', trigger: 'blur' } 76 + { required: true, message: '邮箱不能为空', trigger: 'change' }
77 ], 77 ],
78 city: [ 78 city: [
79 { required: true, message: '请选择城市', trigger: 'change' } 79 { required: true, message: '请选择城市', trigger: 'change' }
src/components/color-picker/color-picker.vue
@@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
66 import Alpha from './alpha.vue'; 66 import Alpha from './alpha.vue';
67 67
68 import { oneOf } from '../../utils/assist'; 68 import { oneOf } from '../../utils/assist';
  69 + import Emitter from '../../mixins/emitter';
69 70
70 const prefixCls = 'ivu-color-picker'; 71 const prefixCls = 'ivu-color-picker';
71 const inputPrefixCls = 'ivu-input'; 72 const inputPrefixCls = 'ivu-input';
@@ -121,6 +122,7 @@ @@ -121,6 +122,7 @@
121 122
122 export default { 123 export default {
123 name: 'ColorPicker', 124 name: 'ColorPicker',
  125 + mixins: [ Emitter ],
124 components: { Drop, Confirm, RecommendColors, Saturation, Hue, Alpha }, 126 components: { Drop, Confirm, RecommendColors, Saturation, Hue, Alpha },
125 directives: { clickoutside, TransferDom }, 127 directives: { clickoutside, TransferDom },
126 props: { 128 props: {
@@ -344,11 +346,13 @@ @@ -344,11 +346,13 @@
344 const color = this.formatColor; 346 const color = this.formatColor;
345 this.$emit('input', color); 347 this.$emit('input', color);
346 this.$emit('on-change', color); 348 this.$emit('on-change', color);
  349 + this.dispatch('FormItem', 'on-form-change', color);
347 this.handleClose(); 350 this.handleClose();
348 }, 351 },
349 handleClear () { 352 handleClear () {
350 this.$emit('input', ''); 353 this.$emit('input', '');
351 this.$emit('on-change', ''); 354 this.$emit('on-change', '');
  355 + this.dispatch('FormItem', 'on-form-change', '');
352 this.handleClose(); 356 this.handleClose();
353 }, 357 },
354 handleSelectColor (color) { 358 handleSelectColor (color) {