onItemChange(type, itemValue) {
const { value, onChange } = this.props;
- let index = 4;
- if (type === 'minute') {
- index = 5;
- } else if (type === 'second') {
- index = 6;
+ if (type === 'hour') {
+ value.setHourOfDay(itemValue);
+ } else if (type === 'minute') {
+ value.setMinutes(itemValue);
+ } else {
+ value.setSeconds(itemValue);
}
- value.fields[index] = itemValue;
onChange(value);
},
render() {
const { prefixCls, value } = this.props;
- const timeFields = value.fields;
return (
<div className={`${prefixCls}-combobox`}>
- {this.getHourSelect(timeFields[4])}
- {this.getMinuteSelect(timeFields[5])}
- {this.getSectionSelect(timeFields[6])}
+ {this.getHourSelect(value.getHourOfDay())}
+ {this.getMinuteSelect(value.getMinutes())}
+ {this.getSectionSelect(value.getSeconds())}
</div>
);
},