From cd78c9c488698dcb8c669a3e85d2acca597a373f Mon Sep 17 00:00:00 2001
From: 梁灏 <admin@aresn.com>
Date: Thu, 9 Mar 2017 11:14:40 +0800
Subject: [PATCH] some comps support dispatch event to FormItem

---
 src/components/cascader/cascader.vue         |  6 ++++--
 src/components/checkbox/checkbox-group.vue   |  5 +++--
 src/components/checkbox/checkbox.vue         |  6 ++++--
 src/components/date-picker/picker.vue        |  8 ++++----
 src/components/input-number/input-number.vue |  5 +++--
 src/components/input/input.vue               |  8 ++++----
 src/components/radio/radio-group.vue         |  5 +++--
 src/components/radio/radio.vue               |  6 ++++--
 src/components/rate/rate.vue                 |  3 +--
 src/components/select/select.vue             | 20 ++++++++------------
 src/components/slider/slider.vue             | 14 ++++++--------
 src/components/switch/switch.vue             |  5 +++--
 src/components/transfer/transfer.vue         |  9 +++++++--
 src/components/upload/upload.vue             |  5 +++--
 14 files changed, 57 insertions(+), 48 deletions(-)

diff --git a/src/components/cascader/cascader.vue b/src/components/cascader/cascader.vue
index 9ff66e2..6ee7e9f 100644
--- a/src/components/cascader/cascader.vue
+++ b/src/components/cascader/cascader.vue
@@ -162,8 +162,10 @@
             emitValue (val, oldVal) {
                 if (JSON.stringify(val) !== oldVal) {
                     this.$emit('on-change', this.currentValue, JSON.parse(JSON.stringify(this.selected)));
-                    // todo 事件
-//                    this.$dispatch('on-form-change', this.currentValue, JSON.parse(JSON.stringify(this.selected)));
+                    this.dispatch('FormItem', 'on-form-change', {
+                        value: this.currentValue,
+                        selected: JSON.parse(JSON.stringify(this.selected))
+                    });
                 }
             }
         },
diff --git a/src/components/checkbox/checkbox-group.vue b/src/components/checkbox/checkbox-group.vue
index e73b25f..69e198a 100644
--- a/src/components/checkbox/checkbox-group.vue
+++ b/src/components/checkbox/checkbox-group.vue
@@ -4,10 +4,12 @@
     </div>
 </template>
 <script>
+    import Emitter from '../../mixins/emitter';
     const prefixCls = 'ivu-checkbox-group';
 
     export default {
         name: 'CheckboxGroup',
+        mixins: [ Emitter ],
         props: {
             value: {
                 type: Array,
@@ -46,8 +48,7 @@
                 this.currentValue = data;
                 this.$emit('input', data);
                 this.$emit('on-change', data);
-                // todo 事件
-//                this.$dispatch('on-form-change', data);
+                this.dispatch('FormItem', 'on-form-change', data);
             }
         },
         watch: {
diff --git a/src/components/checkbox/checkbox.vue b/src/components/checkbox/checkbox.vue
index c9b1869..7915219 100644
--- a/src/components/checkbox/checkbox.vue
+++ b/src/components/checkbox/checkbox.vue
@@ -22,10 +22,13 @@
     </label>
 </template>
 <script>
+    import Emitter from '../../mixins/emitter';
+
     const prefixCls = 'ivu-checkbox';
 
     export default {
         name: 'Checkbox',
+        mixins: [ Emitter ],
         props: {
             disabled: {
                 type: Boolean,
@@ -106,8 +109,7 @@
                     this.$parent.change(this.model);
                 } else {
                     this.$emit('on-change', checked);
-                    // todo 事件
-//                    this.$dispatch('on-form-change', checked);
+                    this.dispatch('FormItem', 'on-form-change', checked);
                 }
             },
             updateModel () {
diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue
index 6abbfb2..1513f9c 100644
--- a/src/components/date-picker/picker.vue
+++ b/src/components/date-picker/picker.vue
@@ -33,6 +33,7 @@
     import clickoutside from '../../directives/clickoutside';
     import { oneOf } from '../../utils/assist';
     import { formatDate, parseDate } from './util';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-date-picker';
 
@@ -138,6 +139,7 @@
     };
 
     export default {
+        mixins: [ Emitter ],
         components: { iInput, Drop },
         directives: { clickoutside },
         props: {
@@ -363,8 +365,7 @@
                 this.internalValue = '';
                 this.currentValue = '';
                 this.$emit('on-clear');
-                // todo 事件
-//                this.$dispatch('on-form-change', '');
+                this.dispatch('FormItem', 'on-form-change', '');
             },
             showPicker () {
                 if (!this.picker) {
@@ -430,8 +431,7 @@
                 }
 
                 this.$emit('on-change', newDate);
-                // todo 事件
-//                this.$dispatch('on-form-change', newDate);
+                this.dispatch('FormItem', 'on-form-change', newDate);
             }
         },
         watch: {
diff --git a/src/components/input-number/input-number.vue b/src/components/input-number/input-number.vue
index 199dd87..cf36224 100644
--- a/src/components/input-number/input-number.vue
+++ b/src/components/input-number/input-number.vue
@@ -29,6 +29,7 @@
 </template>
 <script>
     import { oneOf } from '../../utils/assist';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-input-number';
     const iconPrefixCls = 'ivu-icon';
@@ -62,6 +63,7 @@
 
     export default {
         name: 'InputNumber',
+        mixins: [ Emitter ],
         props: {
             max: {
                 type: Number,
@@ -201,8 +203,7 @@
                     this.currentValue = val;
                     this.$emit('input', val);
                     this.$emit('on-change', val);
-                    // todo 事件
-//                    this.$dispatch('on-form-change', val);
+                    this.dispatch('FormItem', 'on-form-change', val);
                 });
             },
             focus () {
diff --git a/src/components/input/input.vue b/src/components/input/input.vue
index 33982e2..8f6b4d6 100644
--- a/src/components/input/input.vue
+++ b/src/components/input/input.vue
@@ -45,11 +45,13 @@
 <script>
     import { oneOf } from '../../utils/assist';
     import calcTextareaHeight from '../../utils/calcTextareaHeight';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-input';
 
     export default {
         name: 'Input',
+        mixins: [ Emitter ],
         props: {
             type: {
                 validator (value) {
@@ -150,8 +152,7 @@
             },
             handleBlur () {
                 this.$emit('on-blur');
-                // todo 事件
-//                this.$dispatch('on-form-blur', this.currentValue);
+                this.dispatch('FormItem', 'on-form-blur', this.currentValue);
             },
             handleInput (event) {
                 const value = event.target.value;
@@ -168,8 +169,7 @@
                     this.resizeTextarea();
                 });
                 this.currentValue = value;
-                // todo 事件
-//                this.$dispatch('on-form-change', value);
+                this.dispatch('FormItem', 'on-form-change', value);
             },
             resizeTextarea () {
                 const autosize = this.autosize;
diff --git a/src/components/radio/radio-group.vue b/src/components/radio/radio-group.vue
index c4d598a..49349c4 100644
--- a/src/components/radio/radio-group.vue
+++ b/src/components/radio/radio-group.vue
@@ -5,11 +5,13 @@
 </template>
 <script>
     import { oneOf } from '../../utils/assist';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-radio-group';
 
     export default {
         name: 'RadioGroup',
+        mixins: [ Emitter ],
         props: {
             value: {
                 type: [String, Number],
@@ -63,8 +65,7 @@
                 this.updateValue();
                 this.$emit('input', data.value);
                 this.$emit('on-change', data.value);
-                // todo 事件
-//                this.$dispatch('on-form-change', data.value);
+                this.dispatch('FormItem', 'on-form-change', data.value);
             }
         },
         watch: {
diff --git a/src/components/radio/radio.vue b/src/components/radio/radio.vue
index 9ac207f..db253f4 100644
--- a/src/components/radio/radio.vue
+++ b/src/components/radio/radio.vue
@@ -12,10 +12,13 @@
     </label>
 </template>
 <script>
+    import Emitter from '../../mixins/emitter';
+
     const prefixCls = 'ivu-radio';
 
     export default {
         name: 'Radio',
+        mixins: [ Emitter ],
         props: {
             value: {
                 type: Boolean,
@@ -87,8 +90,7 @@
                 }
                 if (!this.group) {
                     this.$emit('on-change', checked);
-                    // todo 事件
-//                    this.$dispatch('on-form-change', checked);
+                    this.dispatch('FormItem', 'on-form-change', checked);
                 }
             },
             updateValue () {
diff --git a/src/components/rate/rate.vue b/src/components/rate/rate.vue
index 6d611ce..abd74ba 100644
--- a/src/components/rate/rate.vue
+++ b/src/components/rate/rate.vue
@@ -123,8 +123,7 @@
                 this.currentValue = value;
                 this.$emit('input', value);
                 this.$emit('on-change', value);
-                // @todo
-//                 this.$dispatch('on-form-change', value);
+                this.dispatch('FormItem', 'on-form-change', value);
             }
         }
     };
diff --git a/src/components/select/select.vue b/src/components/select/select.vue
index f1184ce..88050bf 100644
--- a/src/components/select/select.vue
+++ b/src/components/select/select.vue
@@ -321,15 +321,13 @@
                                 value: value,
                                 label: label
                             });
-                            // todo 事件
-//                            this.$dispatch('on-form-change', {
-//                                value: value,
-//                                label: label
-//                            });
+                            this.dispatch('FormItem', 'on-form-change', {
+                                value: value,
+                                label: label
+                            });
                         } else {
                             this.$emit('on-change', value);
-                            // todo 事件
-//                            this.$dispatch('on-form-change', value);
+                            this.dispatch('FormItem', 'on-form-change', value);
                         }
                     }
                 }
@@ -358,12 +356,10 @@
                     if (!init) {
                         if (this.labelInValue) {
                             this.$emit('on-change', hybridValue);
-                            // todo 事件
-//                            this.$dispatch('on-form-change', hybridValue);
-//                        } else {
+                            this.dispatch('FormItem', 'on-form-change', hybridValue);
+                        } else {
                             this.$emit('on-change', value);
-                            // todo 事件
-//                            this.$dispatch('on-form-change', value);
+                            this.dispatch('FormItem', 'on-form-change', value);
                         }
                     }
                 }
diff --git a/src/components/slider/slider.vue b/src/components/slider/slider.vue
index 365fa11..1531ad2 100644
--- a/src/components/slider/slider.vue
+++ b/src/components/slider/slider.vue
@@ -48,11 +48,13 @@
     import InputNumber from '../../components/input-number/input-number.vue';
     import Tooltip from '../../components/tooltip/tooltip.vue';
     import { getStyle, oneOf } from '../../utils/assist';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-slider';
 
     export default {
         name: 'Slider',
+        mixins: [ Emitter ],
         components: { InputNumber, Tooltip },
         props: {
             min: {
@@ -308,8 +310,7 @@
                     if (!this.dragging) {
                         if (this.currentValue !== this.oldSingleValue) {
                             this.$emit('on-change', this.currentValue);
-                            // todo 事件
-//                            this.$dispatch('on-form-change', this.currentValue);
+                            this.dispatch('FormItem', 'on-form-change', this.currentValue);
                             this.oldSingleValue = this.currentValue;
                         }
                     }
@@ -322,8 +323,7 @@
                 this.currentValue = val;
                 this.setSinglePosition(val);
                 this.$emit('on-change', this.currentValue);
-                // todo 事件
-//                this.$dispatch('on-form-change', this.currentValue);
+                this.dispatch('FormItem', 'on-form-change', this.currentValue);
             },
             // for range use first
             onFirstButtonDown (event) {
@@ -366,8 +366,7 @@
                     if (!this.firstDragging) {
                         if (this.currentValue[0] !== this.oldFirstValue) {
                             this.$emit('on-change', this.currentValue);
-                            // todo 事件
-//                            this.$dispatch('on-form-change', this.currentValue);
+                            this.dispatch('FormItem', 'on-form-change', this.currentValue);
                             this.oldFirstValue = this.currentValue[0];
                         }
                     }
@@ -417,8 +416,7 @@
                     if (!this.secondDragging) {
                         if (this.currentValue[1] !== this.oldSecondValue) {
                             this.$emit('on-change', this.currentValue);
-                            // todo 事件
-//                            this.$dispatch('on-form-change', this.currentValue);
+                            this.dispatch('FormItem', 'on-form-change', this.currentValue);
                             this.oldSecondValue = this.currentValue[1];
                         }
                     }
diff --git a/src/components/switch/switch.vue b/src/components/switch/switch.vue
index 8e54682..6ade16c 100644
--- a/src/components/switch/switch.vue
+++ b/src/components/switch/switch.vue
@@ -8,11 +8,13 @@
 </template>
 <script>
     import { oneOf } from '../../utils/assist';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-switch';
 
     export default {
         name: 'Switch',
+        mixins: [ Emitter ],
         props: {
             value: {
                 type: Boolean,
@@ -58,8 +60,7 @@
                 this.currentValue = checked;
                 this.$emit('input', checked);
                 this.$emit('on-change', checked);
-                // todo 事件
-//                this.$dispatch('on-form-change', this.checked);
+                this.dispatch('FormItem', 'on-form-change', data.checked);
             }
         },
         watch: {
diff --git a/src/components/transfer/transfer.vue b/src/components/transfer/transfer.vue
index d7284c7..fd8d1b7 100644
--- a/src/components/transfer/transfer.vue
+++ b/src/components/transfer/transfer.vue
@@ -44,10 +44,12 @@
     import List from './list.vue';
     import Operation from './operation.vue';
     import { t } from '../../locale';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-transfer';
 
     export default {
+        mixins: [ Emitter ],
         render (createElement) {
 
             function cloneVNode (vnode) {
@@ -256,8 +258,11 @@
 
                 this.$refs[opposite].toggleSelectAll(false);
                 this.$emit('on-change', newTargetKeys, direction, moveKeys);
-                // todo 事件
-//                this.$dispatch('on-form-change', newTargetKeys, direction, moveKeys);
+                this.dispatch('FormItem', 'on-form-change', {
+                    tarketKeys: newTargetKeys,
+                    direction: direction,
+                    moveKeys: moveKeys
+                });
             },
             handleLeftCheckedKeysChange (keys) {
                 this.leftCheckedKeys = keys;
diff --git a/src/components/upload/upload.vue b/src/components/upload/upload.vue
index 232889d..e2af151 100644
--- a/src/components/upload/upload.vue
+++ b/src/components/upload/upload.vue
@@ -27,11 +27,13 @@
     import UploadList from './upload-list.vue';
     import ajax from './ajax';
     import { oneOf } from '../../utils/assist';
+    import Emitter from '../../mixins/emitter';
 
     const prefixCls = 'ivu-upload';
 
     export default {
         name: 'Upload',
+        mixins: [ Emitter ],
         components: { UploadList },
         props: {
             action: {
@@ -277,8 +279,7 @@
                     _file.status = 'finished';
                     _file.response = res;
 
-                    // todo 事件
-//                    this.$dispatch('on-form-change', _file);
+                    this.dispatch('FormItem', 'on-form-change', _file);
                     this.onSuccess(res, _file, this.fileList);
 
                     setTimeout(() => {
--
libgit2 0.21.4