chore(Picker): add getEventParams function

This commit is contained in:
chenjiahan 2022-08-28 10:50:49 +08:00
parent c25acb8d46
commit 61ef6b9a98

View File

@ -126,6 +126,11 @@ export default defineComponent({
}
};
const getEventParams = () => ({
selectedValues: selectedValues.value,
selectedOptions: selectedOptions.value,
});
const onChange = (value: Numeric, columnIndex: number) => {
setValue(columnIndex, value);
@ -142,34 +147,21 @@ export default defineComponent({
});
}
emit('change', {
columnIndex,
selectedValues: selectedValues.value,
selectedOptions: selectedOptions.value,
});
emit('change', extend({ columnIndex }, getEventParams()));
};
const onClickOption = (currentOption: PickerOption, columnIndex: number) =>
emit('clickOption', {
columnIndex,
currentOption,
selectedValues: selectedValues.value,
selectedOptions: selectedOptions.value,
});
emit(
'clickOption',
extend({ columnIndex, currentOption }, getEventParams())
);
const confirm = () => {
children.forEach((child) => child.stopMomentum());
emit('confirm', {
selectedValues: selectedValues.value,
selectedOptions: selectedOptions.value,
});
emit('confirm', getEventParams());
};
const cancel = () =>
emit('cancel', {
selectedValues: selectedValues.value,
selectedOptions: selectedOptions.value,
});
const cancel = () => emit('cancel', getEventParams());
const renderColumnItems = () =>
currentColumns.value.map((options, columnIndex) => (