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) { emitValue (val, oldVal) {
if (JSON.stringify(val) !== oldVal) { if (JSON.stringify(val) !== oldVal) {
this.$emit('on-change', this.currentValue, JSON.parse(JSON.stringify(this.selected))); this.$emit('on-change', this.currentValue, JSON.parse(JSON.stringify(this.selected)));
// todo this.dispatch('FormItem', 'on-form-change', {
// this.$dispatch('on-form-change', this.currentValue, JSON.parse(JSON.stringify(this.selected))); value: this.currentValue,
selected: JSON.parse(JSON.stringify(this.selected))
});
} }
} }
}, },

View file

@ -4,10 +4,12 @@
</div> </div>
</template> </template>
<script> <script>
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-checkbox-group'; const prefixCls = 'ivu-checkbox-group';
export default { export default {
name: 'CheckboxGroup', name: 'CheckboxGroup',
mixins: [ Emitter ],
props: { props: {
value: { value: {
type: Array, type: Array,
@ -46,8 +48,7 @@
this.currentValue = data; this.currentValue = data;
this.$emit('input', data); this.$emit('input', data);
this.$emit('on-change', data); this.$emit('on-change', data);
// todo this.dispatch('FormItem', 'on-form-change', data);
// this.$dispatch('on-form-change', data);
} }
}, },
watch: { watch: {

View file

@ -22,10 +22,13 @@
</label> </label>
</template> </template>
<script> <script>
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-checkbox'; const prefixCls = 'ivu-checkbox';
export default { export default {
name: 'Checkbox', name: 'Checkbox',
mixins: [ Emitter ],
props: { props: {
disabled: { disabled: {
type: Boolean, type: Boolean,
@ -106,8 +109,7 @@
this.$parent.change(this.model); this.$parent.change(this.model);
} else { } else {
this.$emit('on-change', checked); this.$emit('on-change', checked);
// todo this.dispatch('FormItem', 'on-form-change', checked);
// this.$dispatch('on-form-change', checked);
} }
}, },
updateModel () { updateModel () {

View file

@ -33,6 +33,7 @@
import clickoutside from '../../directives/clickoutside'; import clickoutside from '../../directives/clickoutside';
import { oneOf } from '../../utils/assist'; import { oneOf } from '../../utils/assist';
import { formatDate, parseDate } from './util'; import { formatDate, parseDate } from './util';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-date-picker'; const prefixCls = 'ivu-date-picker';
@ -138,6 +139,7 @@
}; };
export default { export default {
mixins: [ Emitter ],
components: { iInput, Drop }, components: { iInput, Drop },
directives: { clickoutside }, directives: { clickoutside },
props: { props: {
@ -363,8 +365,7 @@
this.internalValue = ''; this.internalValue = '';
this.currentValue = ''; this.currentValue = '';
this.$emit('on-clear'); this.$emit('on-clear');
// todo this.dispatch('FormItem', 'on-form-change', '');
// this.$dispatch('on-form-change', '');
}, },
showPicker () { showPicker () {
if (!this.picker) { if (!this.picker) {
@ -430,8 +431,7 @@
} }
this.$emit('on-change', newDate); this.$emit('on-change', newDate);
// todo this.dispatch('FormItem', 'on-form-change', newDate);
// this.$dispatch('on-form-change', newDate);
} }
}, },
watch: { watch: {

View file

@ -29,6 +29,7 @@
</template> </template>
<script> <script>
import { oneOf } from '../../utils/assist'; import { oneOf } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-input-number'; const prefixCls = 'ivu-input-number';
const iconPrefixCls = 'ivu-icon'; const iconPrefixCls = 'ivu-icon';
@ -62,6 +63,7 @@
export default { export default {
name: 'InputNumber', name: 'InputNumber',
mixins: [ Emitter ],
props: { props: {
max: { max: {
type: Number, type: Number,
@ -201,8 +203,7 @@
this.currentValue = val; this.currentValue = val;
this.$emit('input', val); this.$emit('input', val);
this.$emit('on-change', val); this.$emit('on-change', val);
// todo this.dispatch('FormItem', 'on-form-change', val);
// this.$dispatch('on-form-change', val);
}); });
}, },
focus () { focus () {

View file

@ -45,11 +45,13 @@
<script> <script>
import { oneOf } from '../../utils/assist'; import { oneOf } from '../../utils/assist';
import calcTextareaHeight from '../../utils/calcTextareaHeight'; import calcTextareaHeight from '../../utils/calcTextareaHeight';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-input'; const prefixCls = 'ivu-input';
export default { export default {
name: 'Input', name: 'Input',
mixins: [ Emitter ],
props: { props: {
type: { type: {
validator (value) { validator (value) {
@ -150,8 +152,7 @@
}, },
handleBlur () { handleBlur () {
this.$emit('on-blur'); this.$emit('on-blur');
// todo this.dispatch('FormItem', 'on-form-blur', this.currentValue);
// this.$dispatch('on-form-blur', this.currentValue);
}, },
handleInput (event) { handleInput (event) {
const value = event.target.value; const value = event.target.value;
@ -168,8 +169,7 @@
this.resizeTextarea(); this.resizeTextarea();
}); });
this.currentValue = value; this.currentValue = value;
// todo this.dispatch('FormItem', 'on-form-change', value);
// this.$dispatch('on-form-change', value);
}, },
resizeTextarea () { resizeTextarea () {
const autosize = this.autosize; const autosize = this.autosize;

View file

@ -5,11 +5,13 @@
</template> </template>
<script> <script>
import { oneOf } from '../../utils/assist'; import { oneOf } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-radio-group'; const prefixCls = 'ivu-radio-group';
export default { export default {
name: 'RadioGroup', name: 'RadioGroup',
mixins: [ Emitter ],
props: { props: {
value: { value: {
type: [String, Number], type: [String, Number],
@ -63,8 +65,7 @@
this.updateValue(); this.updateValue();
this.$emit('input', data.value); this.$emit('input', data.value);
this.$emit('on-change', data.value); this.$emit('on-change', data.value);
// todo this.dispatch('FormItem', 'on-form-change', data.value);
// this.$dispatch('on-form-change', data.value);
} }
}, },
watch: { watch: {

View file

@ -12,10 +12,13 @@
</label> </label>
</template> </template>
<script> <script>
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-radio'; const prefixCls = 'ivu-radio';
export default { export default {
name: 'Radio', name: 'Radio',
mixins: [ Emitter ],
props: { props: {
value: { value: {
type: Boolean, type: Boolean,
@ -87,8 +90,7 @@
} }
if (!this.group) { if (!this.group) {
this.$emit('on-change', checked); this.$emit('on-change', checked);
// todo this.dispatch('FormItem', 'on-form-change', checked);
// this.$dispatch('on-form-change', checked);
} }
}, },
updateValue () { updateValue () {

View file

@ -123,8 +123,7 @@
this.currentValue = value; this.currentValue = value;
this.$emit('input', value); this.$emit('input', value);
this.$emit('on-change', value); this.$emit('on-change', value);
// @todo this.dispatch('FormItem', 'on-form-change', value);
// this.$dispatch('on-form-change', value);
} }
} }
}; };

View file

@ -321,15 +321,13 @@
value: value, value: value,
label: label label: label
}); });
// todo this.dispatch('FormItem', 'on-form-change', {
// this.$dispatch('on-form-change', { value: value,
// value: value, label: label
// label: label });
// });
} else { } else {
this.$emit('on-change', value); this.$emit('on-change', value);
// todo this.dispatch('FormItem', 'on-form-change', value);
// this.$dispatch('on-form-change', value);
} }
} }
} }
@ -358,12 +356,10 @@
if (!init) { if (!init) {
if (this.labelInValue) { if (this.labelInValue) {
this.$emit('on-change', hybridValue); this.$emit('on-change', hybridValue);
// todo this.dispatch('FormItem', 'on-form-change', hybridValue);
// this.$dispatch('on-form-change', hybridValue); } else {
// } else {
this.$emit('on-change', value); this.$emit('on-change', value);
// todo this.dispatch('FormItem', 'on-form-change', value);
// this.$dispatch('on-form-change', value);
} }
} }
} }

View file

@ -48,11 +48,13 @@
import InputNumber from '../../components/input-number/input-number.vue'; import InputNumber from '../../components/input-number/input-number.vue';
import Tooltip from '../../components/tooltip/tooltip.vue'; import Tooltip from '../../components/tooltip/tooltip.vue';
import { getStyle, oneOf } from '../../utils/assist'; import { getStyle, oneOf } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-slider'; const prefixCls = 'ivu-slider';
export default { export default {
name: 'Slider', name: 'Slider',
mixins: [ Emitter ],
components: { InputNumber, Tooltip }, components: { InputNumber, Tooltip },
props: { props: {
min: { min: {
@ -308,8 +310,7 @@
if (!this.dragging) { if (!this.dragging) {
if (this.currentValue !== this.oldSingleValue) { if (this.currentValue !== this.oldSingleValue) {
this.$emit('on-change', this.currentValue); this.$emit('on-change', this.currentValue);
// todo this.dispatch('FormItem', 'on-form-change', this.currentValue);
// this.$dispatch('on-form-change', this.currentValue);
this.oldSingleValue = this.currentValue; this.oldSingleValue = this.currentValue;
} }
} }
@ -322,8 +323,7 @@
this.currentValue = val; this.currentValue = val;
this.setSinglePosition(val); this.setSinglePosition(val);
this.$emit('on-change', this.currentValue); this.$emit('on-change', this.currentValue);
// todo this.dispatch('FormItem', 'on-form-change', this.currentValue);
// this.$dispatch('on-form-change', this.currentValue);
}, },
// for range use first // for range use first
onFirstButtonDown (event) { onFirstButtonDown (event) {
@ -366,8 +366,7 @@
if (!this.firstDragging) { if (!this.firstDragging) {
if (this.currentValue[0] !== this.oldFirstValue) { if (this.currentValue[0] !== this.oldFirstValue) {
this.$emit('on-change', this.currentValue); this.$emit('on-change', this.currentValue);
// todo this.dispatch('FormItem', 'on-form-change', this.currentValue);
// this.$dispatch('on-form-change', this.currentValue);
this.oldFirstValue = this.currentValue[0]; this.oldFirstValue = this.currentValue[0];
} }
} }
@ -417,8 +416,7 @@
if (!this.secondDragging) { if (!this.secondDragging) {
if (this.currentValue[1] !== this.oldSecondValue) { if (this.currentValue[1] !== this.oldSecondValue) {
this.$emit('on-change', this.currentValue); this.$emit('on-change', this.currentValue);
// todo this.dispatch('FormItem', 'on-form-change', this.currentValue);
// this.$dispatch('on-form-change', this.currentValue);
this.oldSecondValue = this.currentValue[1]; this.oldSecondValue = this.currentValue[1];
} }
} }

View file

@ -8,11 +8,13 @@
</template> </template>
<script> <script>
import { oneOf } from '../../utils/assist'; import { oneOf } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-switch'; const prefixCls = 'ivu-switch';
export default { export default {
name: 'Switch', name: 'Switch',
mixins: [ Emitter ],
props: { props: {
value: { value: {
type: Boolean, type: Boolean,
@ -58,8 +60,7 @@
this.currentValue = checked; this.currentValue = checked;
this.$emit('input', checked); this.$emit('input', checked);
this.$emit('on-change', checked); this.$emit('on-change', checked);
// todo this.dispatch('FormItem', 'on-form-change', data.checked);
// this.$dispatch('on-form-change', this.checked);
} }
}, },
watch: { watch: {

View file

@ -44,10 +44,12 @@
import List from './list.vue'; import List from './list.vue';
import Operation from './operation.vue'; import Operation from './operation.vue';
import { t } from '../../locale'; import { t } from '../../locale';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-transfer'; const prefixCls = 'ivu-transfer';
export default { export default {
mixins: [ Emitter ],
render (createElement) { render (createElement) {
function cloneVNode (vnode) { function cloneVNode (vnode) {
@ -256,8 +258,11 @@
this.$refs[opposite].toggleSelectAll(false); this.$refs[opposite].toggleSelectAll(false);
this.$emit('on-change', newTargetKeys, direction, moveKeys); this.$emit('on-change', newTargetKeys, direction, moveKeys);
// todo this.dispatch('FormItem', 'on-form-change', {
// this.$dispatch('on-form-change', newTargetKeys, direction, moveKeys); tarketKeys: newTargetKeys,
direction: direction,
moveKeys: moveKeys
});
}, },
handleLeftCheckedKeysChange (keys) { handleLeftCheckedKeysChange (keys) {
this.leftCheckedKeys = keys; this.leftCheckedKeys = keys;

View file

@ -27,11 +27,13 @@
import UploadList from './upload-list.vue'; import UploadList from './upload-list.vue';
import ajax from './ajax'; import ajax from './ajax';
import { oneOf } from '../../utils/assist'; import { oneOf } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-upload'; const prefixCls = 'ivu-upload';
export default { export default {
name: 'Upload', name: 'Upload',
mixins: [ Emitter ],
components: { UploadList }, components: { UploadList },
props: { props: {
action: { action: {
@ -277,8 +279,7 @@
_file.status = 'finished'; _file.status = 'finished';
_file.response = res; _file.response = res;
// todo this.dispatch('FormItem', 'on-form-change', _file);
// this.$dispatch('on-form-change', _file);
this.onSuccess(res, _file, this.fileList); this.onSuccess(res, _file, this.fileList);
setTimeout(() => { setTimeout(() => {