import React, { Component } from "react";
import { Col, DatePicker, Row } from "antd";
import { observer } from "mobx-react";
import * as config from "../../config";
import moment from "moment";
import "moment/locale/zh-cn";
import locale from "antd/es/date-picker/locale/zh_CN";
import { stores_Context } from "../../config";
// 用于日期选择,计算上一时间段、同比时间等
class DatePickerCharts extends Component {
static contextType = stores_Context;
constructor(props) {
super(props);
}
render() {
const { date_picker_store } = this.context;
return (
{
date_picker_store.onChange_dataPicker(e);
if (typeof this.props.onChange === 'function') {
this.props.onChange(e);
}
}
}
ranges={{
本周: [moment().startOf("week"), moment().endOf("week")],
上周: [moment().startOf("week").subtract(7, "days"), moment().endOf("week").subtract(7, "days")],
本月: [moment().startOf("month"), moment().endOf("month")],
上个月: [moment().subtract(1, "months").startOf("month"), moment(new Date()).subtract(1, "months").endOf("month")],
近7天: [moment().subtract(7, "days"), moment()],
近30天: [moment().subtract(30, "days"), moment()],
近三个月: [moment().subtract(2, "month").startOf("month"), moment().endOf("month")],
今年: [moment().startOf("year"), moment().endOf("year")],
去年: [moment().subtract(1, "year").startOf("year"), moment().subtract(1, "year").endOf("year")],
}}
/>
{this.props.hide_vs ? (
""
) : (
)}
);
}
}
export default observer(DatePickerCharts);