|
|
@@ -12,7 +12,8 @@ import { fetchPostObj, fetchGet } from '../../../utils/common/fetchRequest'
|
|
|
import { message } from 'antd'
|
|
|
import { Toast } from 'antd-mobile'
|
|
|
import { API } from '../../../configs/api.config'
|
|
|
-
|
|
|
+import { saveScheduleState } from '../../../redux/actions/scheduleState'
|
|
|
+import moment from 'moment'
|
|
|
import './schedule-page.less'
|
|
|
|
|
|
class SchedulePage extends Component {
|
|
|
@@ -24,6 +25,7 @@ class SchedulePage extends Component {
|
|
|
punchClockData: {},
|
|
|
noticeMatterData: [],
|
|
|
calendarData: [],
|
|
|
+ currentDate: new Date().format('yyyy-MM-dd'),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -41,11 +43,15 @@ class SchedulePage extends Component {
|
|
|
}
|
|
|
|
|
|
render () {
|
|
|
- let { punchClockData, noticeMatterData, calendarData } = this.state
|
|
|
-
|
|
|
+ let { scheduleState: { punchClockData, noticeMatterData, calendarData, currentDate } } = this.props
|
|
|
return (
|
|
|
<div className='schedule-root'>
|
|
|
- <CommonCalendar clickBlankPanel={this.clickBlankPanel} clickDate={this.clickDate} calendarData={calendarData}/>
|
|
|
+ <CommonCalendar
|
|
|
+ clickBlankPanel={this.clickBlankPanel}
|
|
|
+ clickDate={this.clickDate}
|
|
|
+ calendarData={calendarData}
|
|
|
+ currentDate={currentDate}
|
|
|
+ />
|
|
|
<PunchClock punchClockData={punchClockData}/>
|
|
|
<NoticeMatter noticeMatterData={noticeMatterData}/>
|
|
|
</div>
|
|
|
@@ -53,18 +59,18 @@ class SchedulePage extends Component {
|
|
|
}
|
|
|
|
|
|
clickDate = (date) => {
|
|
|
- let nowDate = new Date().format('yyyy-MM-dd')
|
|
|
Toast.loading('加载中', 0)
|
|
|
fetchPostObj(API.APPCOMMON_DAILYTASK, {
|
|
|
data: date,
|
|
|
}).then(response => {
|
|
|
Toast.hide()
|
|
|
- this.setState({
|
|
|
+ saveScheduleState({
|
|
|
noticeMatterData: response.data.noticeMatterData,
|
|
|
punchClockData: response.data.punchClockData,
|
|
|
+ currentDate: date,
|
|
|
})
|
|
|
if (!isObjEmpty(response.data.calendarData)) {
|
|
|
- this.setState({
|
|
|
+ saveScheduleState({
|
|
|
calendarData: response.data.calendarData,
|
|
|
})
|
|
|
}
|
|
|
@@ -85,10 +91,8 @@ class SchedulePage extends Component {
|
|
|
data: date,
|
|
|
}).then(response => {
|
|
|
Toast.hide()
|
|
|
- this.setState({
|
|
|
+ saveScheduleState({
|
|
|
calendarData: response.data.calendarData,
|
|
|
- noticeMatterData: response.data.noticeMatterData,
|
|
|
- punchClockData: response.data.punchClockData,
|
|
|
})
|
|
|
}).catch(error => {
|
|
|
Toast.hide()
|
|
|
@@ -101,27 +105,33 @@ class SchedulePage extends Component {
|
|
|
}
|
|
|
|
|
|
getdailyData = () => {
|
|
|
- Toast.loading('正在获取数据', 0)
|
|
|
- fetchGet(API.APPCOMMON_DAILYTASKTOTAL)
|
|
|
- .then(response => {
|
|
|
+ // 判断缓存中是否有数据,若有数据则部发起请求
|
|
|
+ let { scheduleState: { punchClockData, noticeMatterData, calendarData } } = this.props
|
|
|
+ if (isObjEmpty(punchClockData) || isObjEmpty(calendarData)) {
|
|
|
+ Toast.loading('正在获取数据', 0)
|
|
|
+ fetchGet(API.APPCOMMON_DAILYTASKTOTAL)
|
|
|
+ .then(response => {
|
|
|
+ Toast.hide()
|
|
|
+ saveScheduleState({
|
|
|
+ calendarData: response.data.calendarData,
|
|
|
+ noticeMatterData: response.data.noticeMatterData,
|
|
|
+ punchClockData: response.data.punchClockData,
|
|
|
+ })
|
|
|
+ }).catch(error => {
|
|
|
Toast.hide()
|
|
|
- this.setState({
|
|
|
- calendarData: response.data.calendarData,
|
|
|
- noticeMatterData: response.data.noticeMatterData,
|
|
|
- punchClockData: response.data.punchClockData,
|
|
|
- })
|
|
|
- }).catch(error => {
|
|
|
- Toast.hide()
|
|
|
- if (typeof error === 'string') {
|
|
|
- message.error(error)
|
|
|
- } else {
|
|
|
- message.error('待办事项获取失败')
|
|
|
- }
|
|
|
- })
|
|
|
+ if (typeof error === 'string') {
|
|
|
+ message.error(error)
|
|
|
+ } else {
|
|
|
+ message.error('待办事项获取失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-let mapStateToProps = (state) => ({})
|
|
|
+let mapStateToProps = (state) => ({
|
|
|
+ scheduleState: state.scheduleState,
|
|
|
+})
|
|
|
|
|
|
export default connect(mapStateToProps)(SchedulePage)
|