some comps support dispatch event to FormItem

some comps support dispatch event to FormItem
This commit is contained in:
梁灏 2017-03-09 11:14:40 +08:00
parent 7778edfa02
commit cd78c9c488
14 changed files with 57 additions and 48 deletions

View file

@ -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))
});
}
}
},

View file

@ -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: {

View file

@ -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 () {

View file

@ -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: {

View file

@ -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 () {

View file

@ -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;

View file

@ -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: {

View file

@ -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 () {

View file

@ -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);
}
}
};

View file

@ -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);
}
}
}

View file

@ -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];
}
}

View file

@ -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: {

View file

@ -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;

View file

@ -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(() => {