import React,{Component} from 'react'; import style from './index.less'; import config from '@config/index.js'; import Notify from '../Notify/index.js'; class NumberUnitPan extends Component{ constructor(props){ super(props); this.state = { value:'' } this.handleSelect = this.handleSelect.bind(this); } handleSelect(e){ e.stopPropagation(); const text = e.target.innerText; const preValue = this.state.value; if(+text==0 && !preValue){//第一位不能是0 Notify.info("请输入正确时间"); return false; } const value = this.props.toClear?'':this.state.value; //键盘输入替换已有的值 const onSelect = this.props.handleSelect; this.setState({ value: value+text }); onSelect&&onSelect(value+text); } handleClear(e){ e.stopPropagation(); const onSelect = this.props.handleSelect; this.setState({ value: '' }); onSelect&&onSelect(''); } handleClose(e){ e.stopPropagation(); //关闭弹窗 const {onClose} = this.props; onClose&&onClose(); } handleBack(e){ e.stopPropagation(); // const value = this.state.value; const value = this.props.value; const len = value.length-1; if(len<0){ return; } const onSelect = this.props.handleSelect; const text = value.substring(0,len); this.setState({ value:text }); onSelect&&onSelect(text); } render(){ // const select = this.handleSelect.bind(this); const {show} = this.props; //table onBlur阻止冒泡是为了修复multSpread中数字键盘点击触发最外层数字组件onBlur事件 return
e.stopPropagation()} style={{display:show?'table':'none'}}>
1 2 3 /
4 5 6 回退
7 8 9 清空
. 0 确定
{config.timeUnit.minute} {config.timeUnit.hour} {config.timeUnit.day}
{config.timeUnit.week} {config.timeUnit.month} {config.timeUnit.year}
} } export default NumberUnitPan;