Commit 3ad47566a451f3a4231eeac9752edcd24c38d1e3

Authored by 梁灏
1 parent 8df36a0a

update Select

update Select
src/components/select/select.vue
@@ -310,8 +310,13 @@ @@ -310,8 +310,13 @@
310 value: value, 310 value: value,
311 label: label 311 label: label
312 }); 312 });
  313 + this.$dispatch('on-form-change', {
  314 + value: value,
  315 + label: label
  316 + });
313 } else { 317 } else {
314 this.$emit('on-change', value); 318 this.$emit('on-change', value);
  319 + this.$dispatch('on-form-change', value);
315 } 320 }
316 } 321 }
317 } 322 }
@@ -340,8 +345,10 @@ @@ -340,8 +345,10 @@
340 if (!init) { 345 if (!init) {
341 if (this.labelInValue) { 346 if (this.labelInValue) {
342 this.$emit('on-change', hybridValue); 347 this.$emit('on-change', hybridValue);
  348 + this.$dispatch('on-form-change', hybridValue);
343 } else { 349 } else {
344 this.$emit('on-change', value); 350 this.$emit('on-change', value);
  351 + this.$dispatch('on-form-change', value);
345 } 352 }
346 } 353 }
347 } 354 }
src/styles/components/form.less
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 .clearfix(); 35 .clearfix();
36 &-content { 36 &-content {
37 position: relative; 37 position: relative;
38 - line-height: 32px; 38 + //line-height: 32px;
39 font-size: @font-size-small; 39 font-size: @font-size-small;
40 } 40 }
41 41
test/routers/form.vue
@@ -50,6 +50,16 @@ @@ -50,6 +50,16 @@
50 </Checkbox> 50 </Checkbox>
51 </Checkbox-group> 51 </Checkbox-group>
52 </form-item> 52 </form-item>
  53 + <form-item label="select" prop="select">
  54 + <i-select :model.sync="form.select" style="width:200px" clearable>
  55 + <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
  56 + </i-select>
  57 + </form-item>
  58 + <form-item label="select多选" prop="selectm">
  59 + <i-select :model.sync="form.selectm" multiple style="width:260px">
  60 + <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
  61 + </i-select>
  62 + </form-item>
53 <form-item> 63 <form-item>
54 <i-button type="primary" @click="onSubmit('form')">提交</i-button> 64 <i-button type="primary" @click="onSubmit('form')">提交</i-button>
55 </form-item> 65 </form-item>
@@ -61,12 +71,40 @@ @@ -61,12 +71,40 @@
61 props: {}, 71 props: {},
62 data () { 72 data () {
63 return { 73 return {
  74 + cityList: [
  75 + {
  76 + value: 'beijing',
  77 + label: '北京市'
  78 + },
  79 + {
  80 + value: 'shanghai',
  81 + label: '上海市'
  82 + },
  83 + {
  84 + value: 'shenzhen',
  85 + label: '深圳市'
  86 + },
  87 + {
  88 + value: 'hangzhou',
  89 + label: '杭州市'
  90 + },
  91 + {
  92 + value: 'nanjing',
  93 + label: '南京市'
  94 + },
  95 + {
  96 + value: 'chongqing',
  97 + label: '重庆市'
  98 + }
  99 + ],
64 form: { 100 form: {
65 mail: '', 101 mail: '',
66 passwd: '', 102 passwd: '',
67 single: false, 103 single: false,
68 group: '', 104 group: '',
69 - checkboxgroup: [] 105 + checkboxgroup: [],
  106 + select: '',
  107 + selectm: []
70 }, 108 },
71 rules: { 109 rules: {
72 mail: [ 110 mail: [
@@ -97,6 +135,19 @@ @@ -97,6 +135,19 @@
97 { 135 {
98 required: true, message: '至多选择3个', max: 3, type: 'array' 136 required: true, message: '至多选择3个', max: 3, type: 'array'
99 } 137 }
  138 + ],
  139 + select: [
  140 + {
  141 + required: true
  142 + }
  143 + ],
  144 + selectm: [
  145 + {
  146 + required: true, type: 'array'
  147 + },
  148 + {
  149 + min: 2, type: 'array'
  150 + }
100 ] 151 ]
101 } 152 }
102 } 153 }