-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeComponent.jsx
39 lines (36 loc) · 1.25 KB
/
TimeComponent.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { Component } from 'react'
import { TimePicker,Row,Col } from 'antd';
import moment from "moment";
export default class TimeComponent extends Component {
constructor(props) {
super(props);
this.state={
title:"",
type:"Time",
value:"",
format:"HH:mm:ss"
}
}
onChange=(time,timeString)=>{
// let timeNow = moment(timeString, 'HH:mm:ss')
this.props.setData('value',timeString)
}
componentDidUpdate(){
if(!Object.keys(this.props.data).length)
this.props.setAllData(this.state);
}
render(){
return(
<div style={{marginTop:'10px'}}>
{!this.props.viewMode?(<Row>
<Col span={24}>
<Col span={6}>Choose Time</Col>
<Col span={18}>
<TimePicker onChange={this.onChange} defaultValue={!this.props.data.value?moment('00:00:00', this.state.format):moment(this.props.data.value,this.state.format)} format={this.state.format} />
</Col>
</Col>
</Row>):null}
</div>
)
}
}