import classnames from "classnames"; import Taro from "@tarojs/taro"; import dayjs, { Dayjs } from "dayjs"; import React from "react"; import { Text, View, Block, Image } from "@tarojs/components"; import { DatetimePicker, Popup } from "@antmjs/vantui"; import _ from "lodash"; import { AtCalendarControllerProps, AtCalendarControllerState, } from "../../../../types/calendar"; import "./index.less"; let _currentDate = 0; export default class AtCalendarController extends React.Component { public constructor(props: any) { super(props); this.state = { showDatePicker: false, selectDate: 0, curDate: dayjs(this.props.currentDate).valueOf(), tempDate: 0, }; } onChangeDate = (e) => { e.stopPropagation(); }; onInput = (e) => { _currentDate = e.detail; }; onClickStop = (e) => { e.stopPropagation(); }; onSelectDate = () => { this.props.onSelectDate(_currentDate); this.onPopupClose(); }; onPopupClose = () => { this.setState({ showDatePicker: false }); }; onConfirm(e) { console.log("confirm", e); } openDate = () => { this.setState({ showDatePicker: true, curDate: dayjs(this.props.currentDate).valueOf(), }); }; public render(): JSX.Element { const { generateDate, minDate, maxDate, monthFormat, hideArrow, currentDate, } = this.props; const dayjsDate: Dayjs = dayjs(generateDate); const dayjsMinDate: Dayjs | boolean = !!minDate && dayjs(minDate); const dayjsMaxDate: Dayjs | boolean = !!maxDate && dayjs(maxDate); const isMinMonth: boolean = dayjsMinDate && dayjsMinDate.startOf("month").isSame(dayjsDate); const isMaxMonth: boolean = dayjsMaxDate && dayjsMaxDate.startOf("month").isSame(dayjsDate); const minDateValue: string = dayjsMinDate ? dayjsMinDate.format("YYYY-MM") : ""; const maxDateValue: string = dayjsMaxDate ? dayjsMaxDate.format("YYYY-MM") : ""; let { showDatePicker, curDate } = this.state; _currentDate = curDate; return ( {hideArrow ? null : ( )} {/* */} {/* {dayjsDate.format(monthFormat)} */} {dayjsDate.format("YYYY.MM.DD")} 选择日期 已选择日期 {currentDate} 确定 ); } }