Commit cd78c9c488698dcb8c669a3e85d2acca597a373f
1 parent
7778edfa
some comps support dispatch event to FormItem
some comps support dispatch event to FormItem
Showing
14 changed files
with
57 additions
and
48 deletions
Show diff stats
src/components/cascader/cascader.vue
| ... | ... | @@ -162,8 +162,10 @@ |
| 162 | 162 | emitValue (val, oldVal) { |
| 163 | 163 | if (JSON.stringify(val) !== oldVal) { |
| 164 | 164 | this.$emit('on-change', this.currentValue, JSON.parse(JSON.stringify(this.selected))); |
| 165 | - // todo 事件 | |
| 166 | -// this.$dispatch('on-form-change', this.currentValue, JSON.parse(JSON.stringify(this.selected))); | |
| 165 | + this.dispatch('FormItem', 'on-form-change', { | |
| 166 | + value: this.currentValue, | |
| 167 | + selected: JSON.parse(JSON.stringify(this.selected)) | |
| 168 | + }); | |
| 167 | 169 | } |
| 168 | 170 | } |
| 169 | 171 | }, | ... | ... |
src/components/checkbox/checkbox-group.vue
| ... | ... | @@ -4,10 +4,12 @@ |
| 4 | 4 | </div> |
| 5 | 5 | </template> |
| 6 | 6 | <script> |
| 7 | + import Emitter from '../../mixins/emitter'; | |
| 7 | 8 | const prefixCls = 'ivu-checkbox-group'; |
| 8 | 9 | |
| 9 | 10 | export default { |
| 10 | 11 | name: 'CheckboxGroup', |
| 12 | + mixins: [ Emitter ], | |
| 11 | 13 | props: { |
| 12 | 14 | value: { |
| 13 | 15 | type: Array, |
| ... | ... | @@ -46,8 +48,7 @@ |
| 46 | 48 | this.currentValue = data; |
| 47 | 49 | this.$emit('input', data); |
| 48 | 50 | this.$emit('on-change', data); |
| 49 | - // todo 事件 | |
| 50 | -// this.$dispatch('on-form-change', data); | |
| 51 | + this.dispatch('FormItem', 'on-form-change', data); | |
| 51 | 52 | } |
| 52 | 53 | }, |
| 53 | 54 | watch: { | ... | ... |
src/components/checkbox/checkbox.vue
| ... | ... | @@ -22,10 +22,13 @@ |
| 22 | 22 | </label> |
| 23 | 23 | </template> |
| 24 | 24 | <script> |
| 25 | + import Emitter from '../../mixins/emitter'; | |
| 26 | + | |
| 25 | 27 | const prefixCls = 'ivu-checkbox'; |
| 26 | 28 | |
| 27 | 29 | export default { |
| 28 | 30 | name: 'Checkbox', |
| 31 | + mixins: [ Emitter ], | |
| 29 | 32 | props: { |
| 30 | 33 | disabled: { |
| 31 | 34 | type: Boolean, |
| ... | ... | @@ -106,8 +109,7 @@ |
| 106 | 109 | this.$parent.change(this.model); |
| 107 | 110 | } else { |
| 108 | 111 | this.$emit('on-change', checked); |
| 109 | - // todo 事件 | |
| 110 | -// this.$dispatch('on-form-change', checked); | |
| 112 | + this.dispatch('FormItem', 'on-form-change', checked); | |
| 111 | 113 | } |
| 112 | 114 | }, |
| 113 | 115 | updateModel () { | ... | ... |
src/components/date-picker/picker.vue
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | import clickoutside from '../../directives/clickoutside'; |
| 34 | 34 | import { oneOf } from '../../utils/assist'; |
| 35 | 35 | import { formatDate, parseDate } from './util'; |
| 36 | + import Emitter from '../../mixins/emitter'; | |
| 36 | 37 | |
| 37 | 38 | const prefixCls = 'ivu-date-picker'; |
| 38 | 39 | |
| ... | ... | @@ -138,6 +139,7 @@ |
| 138 | 139 | }; |
| 139 | 140 | |
| 140 | 141 | export default { |
| 142 | + mixins: [ Emitter ], | |
| 141 | 143 | components: { iInput, Drop }, |
| 142 | 144 | directives: { clickoutside }, |
| 143 | 145 | props: { |
| ... | ... | @@ -363,8 +365,7 @@ |
| 363 | 365 | this.internalValue = ''; |
| 364 | 366 | this.currentValue = ''; |
| 365 | 367 | this.$emit('on-clear'); |
| 366 | - // todo 事件 | |
| 367 | -// this.$dispatch('on-form-change', ''); | |
| 368 | + this.dispatch('FormItem', 'on-form-change', ''); | |
| 368 | 369 | }, |
| 369 | 370 | showPicker () { |
| 370 | 371 | if (!this.picker) { |
| ... | ... | @@ -430,8 +431,7 @@ |
| 430 | 431 | } |
| 431 | 432 | |
| 432 | 433 | this.$emit('on-change', newDate); |
| 433 | - // todo 事件 | |
| 434 | -// this.$dispatch('on-form-change', newDate); | |
| 434 | + this.dispatch('FormItem', 'on-form-change', newDate); | |
| 435 | 435 | } |
| 436 | 436 | }, |
| 437 | 437 | watch: { | ... | ... |
src/components/input-number/input-number.vue
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | </template> |
| 30 | 30 | <script> |
| 31 | 31 | import { oneOf } from '../../utils/assist'; |
| 32 | + import Emitter from '../../mixins/emitter'; | |
| 32 | 33 | |
| 33 | 34 | const prefixCls = 'ivu-input-number'; |
| 34 | 35 | const iconPrefixCls = 'ivu-icon'; |
| ... | ... | @@ -62,6 +63,7 @@ |
| 62 | 63 | |
| 63 | 64 | export default { |
| 64 | 65 | name: 'InputNumber', |
| 66 | + mixins: [ Emitter ], | |
| 65 | 67 | props: { |
| 66 | 68 | max: { |
| 67 | 69 | type: Number, |
| ... | ... | @@ -201,8 +203,7 @@ |
| 201 | 203 | this.currentValue = val; |
| 202 | 204 | this.$emit('input', val); |
| 203 | 205 | this.$emit('on-change', val); |
| 204 | - // todo 事件 | |
| 205 | -// this.$dispatch('on-form-change', val); | |
| 206 | + this.dispatch('FormItem', 'on-form-change', val); | |
| 206 | 207 | }); |
| 207 | 208 | }, |
| 208 | 209 | focus () { | ... | ... |
src/components/input/input.vue
| ... | ... | @@ -45,11 +45,13 @@ |
| 45 | 45 | <script> |
| 46 | 46 | import { oneOf } from '../../utils/assist'; |
| 47 | 47 | import calcTextareaHeight from '../../utils/calcTextareaHeight'; |
| 48 | + import Emitter from '../../mixins/emitter'; | |
| 48 | 49 | |
| 49 | 50 | const prefixCls = 'ivu-input'; |
| 50 | 51 | |
| 51 | 52 | export default { |
| 52 | 53 | name: 'Input', |
| 54 | + mixins: [ Emitter ], | |
| 53 | 55 | props: { |
| 54 | 56 | type: { |
| 55 | 57 | validator (value) { |
| ... | ... | @@ -150,8 +152,7 @@ |
| 150 | 152 | }, |
| 151 | 153 | handleBlur () { |
| 152 | 154 | this.$emit('on-blur'); |
| 153 | - // todo 事件 | |
| 154 | -// this.$dispatch('on-form-blur', this.currentValue); | |
| 155 | + this.dispatch('FormItem', 'on-form-blur', this.currentValue); | |
| 155 | 156 | }, |
| 156 | 157 | handleInput (event) { |
| 157 | 158 | const value = event.target.value; |
| ... | ... | @@ -168,8 +169,7 @@ |
| 168 | 169 | this.resizeTextarea(); |
| 169 | 170 | }); |
| 170 | 171 | this.currentValue = value; |
| 171 | - // todo 事件 | |
| 172 | -// this.$dispatch('on-form-change', value); | |
| 172 | + this.dispatch('FormItem', 'on-form-change', value); | |
| 173 | 173 | }, |
| 174 | 174 | resizeTextarea () { |
| 175 | 175 | const autosize = this.autosize; | ... | ... |
src/components/radio/radio-group.vue
| ... | ... | @@ -5,11 +5,13 @@ |
| 5 | 5 | </template> |
| 6 | 6 | <script> |
| 7 | 7 | import { oneOf } from '../../utils/assist'; |
| 8 | + import Emitter from '../../mixins/emitter'; | |
| 8 | 9 | |
| 9 | 10 | const prefixCls = 'ivu-radio-group'; |
| 10 | 11 | |
| 11 | 12 | export default { |
| 12 | 13 | name: 'RadioGroup', |
| 14 | + mixins: [ Emitter ], | |
| 13 | 15 | props: { |
| 14 | 16 | value: { |
| 15 | 17 | type: [String, Number], |
| ... | ... | @@ -63,8 +65,7 @@ |
| 63 | 65 | this.updateValue(); |
| 64 | 66 | this.$emit('input', data.value); |
| 65 | 67 | this.$emit('on-change', data.value); |
| 66 | - // todo 事件 | |
| 67 | -// this.$dispatch('on-form-change', data.value); | |
| 68 | + this.dispatch('FormItem', 'on-form-change', data.value); | |
| 68 | 69 | } |
| 69 | 70 | }, |
| 70 | 71 | watch: { | ... | ... |
src/components/radio/radio.vue
| ... | ... | @@ -12,10 +12,13 @@ |
| 12 | 12 | </label> |
| 13 | 13 | </template> |
| 14 | 14 | <script> |
| 15 | + import Emitter from '../../mixins/emitter'; | |
| 16 | + | |
| 15 | 17 | const prefixCls = 'ivu-radio'; |
| 16 | 18 | |
| 17 | 19 | export default { |
| 18 | 20 | name: 'Radio', |
| 21 | + mixins: [ Emitter ], | |
| 19 | 22 | props: { |
| 20 | 23 | value: { |
| 21 | 24 | type: Boolean, |
| ... | ... | @@ -87,8 +90,7 @@ |
| 87 | 90 | } |
| 88 | 91 | if (!this.group) { |
| 89 | 92 | this.$emit('on-change', checked); |
| 90 | - // todo 事件 | |
| 91 | -// this.$dispatch('on-form-change', checked); | |
| 93 | + this.dispatch('FormItem', 'on-form-change', checked); | |
| 92 | 94 | } |
| 93 | 95 | }, |
| 94 | 96 | updateValue () { | ... | ... |
src/components/rate/rate.vue
src/components/select/select.vue
| ... | ... | @@ -321,15 +321,13 @@ |
| 321 | 321 | value: value, |
| 322 | 322 | label: label |
| 323 | 323 | }); |
| 324 | - // todo 事件 | |
| 325 | -// this.$dispatch('on-form-change', { | |
| 326 | -// value: value, | |
| 327 | -// label: label | |
| 328 | -// }); | |
| 324 | + this.dispatch('FormItem', 'on-form-change', { | |
| 325 | + value: value, | |
| 326 | + label: label | |
| 327 | + }); | |
| 329 | 328 | } else { |
| 330 | 329 | this.$emit('on-change', value); |
| 331 | - // todo 事件 | |
| 332 | -// this.$dispatch('on-form-change', value); | |
| 330 | + this.dispatch('FormItem', 'on-form-change', value); | |
| 333 | 331 | } |
| 334 | 332 | } |
| 335 | 333 | } |
| ... | ... | @@ -358,12 +356,10 @@ |
| 358 | 356 | if (!init) { |
| 359 | 357 | if (this.labelInValue) { |
| 360 | 358 | this.$emit('on-change', hybridValue); |
| 361 | - // todo 事件 | |
| 362 | -// this.$dispatch('on-form-change', hybridValue); | |
| 363 | -// } else { | |
| 359 | + this.dispatch('FormItem', 'on-form-change', hybridValue); | |
| 360 | + } else { | |
| 364 | 361 | this.$emit('on-change', value); |
| 365 | - // todo 事件 | |
| 366 | -// this.$dispatch('on-form-change', value); | |
| 362 | + this.dispatch('FormItem', 'on-form-change', value); | |
| 367 | 363 | } |
| 368 | 364 | } |
| 369 | 365 | } | ... | ... |
src/components/slider/slider.vue
| ... | ... | @@ -48,11 +48,13 @@ |
| 48 | 48 | import InputNumber from '../../components/input-number/input-number.vue'; |
| 49 | 49 | import Tooltip from '../../components/tooltip/tooltip.vue'; |
| 50 | 50 | import { getStyle, oneOf } from '../../utils/assist'; |
| 51 | + import Emitter from '../../mixins/emitter'; | |
| 51 | 52 | |
| 52 | 53 | const prefixCls = 'ivu-slider'; |
| 53 | 54 | |
| 54 | 55 | export default { |
| 55 | 56 | name: 'Slider', |
| 57 | + mixins: [ Emitter ], | |
| 56 | 58 | components: { InputNumber, Tooltip }, |
| 57 | 59 | props: { |
| 58 | 60 | min: { |
| ... | ... | @@ -308,8 +310,7 @@ |
| 308 | 310 | if (!this.dragging) { |
| 309 | 311 | if (this.currentValue !== this.oldSingleValue) { |
| 310 | 312 | this.$emit('on-change', this.currentValue); |
| 311 | - // todo 事件 | |
| 312 | -// this.$dispatch('on-form-change', this.currentValue); | |
| 313 | + this.dispatch('FormItem', 'on-form-change', this.currentValue); | |
| 313 | 314 | this.oldSingleValue = this.currentValue; |
| 314 | 315 | } |
| 315 | 316 | } |
| ... | ... | @@ -322,8 +323,7 @@ |
| 322 | 323 | this.currentValue = val; |
| 323 | 324 | this.setSinglePosition(val); |
| 324 | 325 | this.$emit('on-change', this.currentValue); |
| 325 | - // todo 事件 | |
| 326 | -// this.$dispatch('on-form-change', this.currentValue); | |
| 326 | + this.dispatch('FormItem', 'on-form-change', this.currentValue); | |
| 327 | 327 | }, |
| 328 | 328 | // for range use first |
| 329 | 329 | onFirstButtonDown (event) { |
| ... | ... | @@ -366,8 +366,7 @@ |
| 366 | 366 | if (!this.firstDragging) { |
| 367 | 367 | if (this.currentValue[0] !== this.oldFirstValue) { |
| 368 | 368 | this.$emit('on-change', this.currentValue); |
| 369 | - // todo 事件 | |
| 370 | -// this.$dispatch('on-form-change', this.currentValue); | |
| 369 | + this.dispatch('FormItem', 'on-form-change', this.currentValue); | |
| 371 | 370 | this.oldFirstValue = this.currentValue[0]; |
| 372 | 371 | } |
| 373 | 372 | } |
| ... | ... | @@ -417,8 +416,7 @@ |
| 417 | 416 | if (!this.secondDragging) { |
| 418 | 417 | if (this.currentValue[1] !== this.oldSecondValue) { |
| 419 | 418 | this.$emit('on-change', this.currentValue); |
| 420 | - // todo 事件 | |
| 421 | -// this.$dispatch('on-form-change', this.currentValue); | |
| 419 | + this.dispatch('FormItem', 'on-form-change', this.currentValue); | |
| 422 | 420 | this.oldSecondValue = this.currentValue[1]; |
| 423 | 421 | } |
| 424 | 422 | } | ... | ... |
src/components/switch/switch.vue
| ... | ... | @@ -8,11 +8,13 @@ |
| 8 | 8 | </template> |
| 9 | 9 | <script> |
| 10 | 10 | import { oneOf } from '../../utils/assist'; |
| 11 | + import Emitter from '../../mixins/emitter'; | |
| 11 | 12 | |
| 12 | 13 | const prefixCls = 'ivu-switch'; |
| 13 | 14 | |
| 14 | 15 | export default { |
| 15 | 16 | name: 'Switch', |
| 17 | + mixins: [ Emitter ], | |
| 16 | 18 | props: { |
| 17 | 19 | value: { |
| 18 | 20 | type: Boolean, |
| ... | ... | @@ -58,8 +60,7 @@ |
| 58 | 60 | this.currentValue = checked; |
| 59 | 61 | this.$emit('input', checked); |
| 60 | 62 | this.$emit('on-change', checked); |
| 61 | - // todo 事件 | |
| 62 | -// this.$dispatch('on-form-change', this.checked); | |
| 63 | + this.dispatch('FormItem', 'on-form-change', data.checked); | |
| 63 | 64 | } |
| 64 | 65 | }, |
| 65 | 66 | watch: { | ... | ... |
src/components/transfer/transfer.vue
| ... | ... | @@ -44,10 +44,12 @@ |
| 44 | 44 | import List from './list.vue'; |
| 45 | 45 | import Operation from './operation.vue'; |
| 46 | 46 | import { t } from '../../locale'; |
| 47 | + import Emitter from '../../mixins/emitter'; | |
| 47 | 48 | |
| 48 | 49 | const prefixCls = 'ivu-transfer'; |
| 49 | 50 | |
| 50 | 51 | export default { |
| 52 | + mixins: [ Emitter ], | |
| 51 | 53 | render (createElement) { |
| 52 | 54 | |
| 53 | 55 | function cloneVNode (vnode) { |
| ... | ... | @@ -256,8 +258,11 @@ |
| 256 | 258 | |
| 257 | 259 | this.$refs[opposite].toggleSelectAll(false); |
| 258 | 260 | this.$emit('on-change', newTargetKeys, direction, moveKeys); |
| 259 | - // todo 事件 | |
| 260 | -// this.$dispatch('on-form-change', newTargetKeys, direction, moveKeys); | |
| 261 | + this.dispatch('FormItem', 'on-form-change', { | |
| 262 | + tarketKeys: newTargetKeys, | |
| 263 | + direction: direction, | |
| 264 | + moveKeys: moveKeys | |
| 265 | + }); | |
| 261 | 266 | }, |
| 262 | 267 | handleLeftCheckedKeysChange (keys) { |
| 263 | 268 | this.leftCheckedKeys = keys; | ... | ... |
src/components/upload/upload.vue
| ... | ... | @@ -27,11 +27,13 @@ |
| 27 | 27 | import UploadList from './upload-list.vue'; |
| 28 | 28 | import ajax from './ajax'; |
| 29 | 29 | import { oneOf } from '../../utils/assist'; |
| 30 | + import Emitter from '../../mixins/emitter'; | |
| 30 | 31 | |
| 31 | 32 | const prefixCls = 'ivu-upload'; |
| 32 | 33 | |
| 33 | 34 | export default { |
| 34 | 35 | name: 'Upload', |
| 36 | + mixins: [ Emitter ], | |
| 35 | 37 | components: { UploadList }, |
| 36 | 38 | props: { |
| 37 | 39 | action: { |
| ... | ... | @@ -277,8 +279,7 @@ |
| 277 | 279 | _file.status = 'finished'; |
| 278 | 280 | _file.response = res; |
| 279 | 281 | |
| 280 | - // todo 事件 | |
| 281 | -// this.$dispatch('on-form-change', _file); | |
| 282 | + this.dispatch('FormItem', 'on-form-change', _file); | |
| 282 | 283 | this.onSuccess(res, _file, this.fileList); |
| 283 | 284 | |
| 284 | 285 | setTimeout(() => { | ... | ... |