import React, {Component, CSSProperties} from "react"; import {Calendar} from "antd"; import moment from "moment"; import {getPropertyValue, getUrlParam, onClickNewTag} from "../../utils"; interface Prop { data : any; style : CSSProperties; } interface State { date : any ; } export default class RiLi extends Component{ state : State = { date : RiLi.getInitData(this.props), } static getInitData=(prop:Prop):any=>{ const fm : string = getPropertyValue(prop.data.data.data.config.config,"输出格式"); const key : string = getPropertyValue(prop.data.data.data.config.config,"初始值"); if(key==""){ return moment(); } const urlParam : any = getUrlParam(); const initValue : string = urlParam[key]; if(!initValue){ return moment(); } try { return moment(initValue,fm); }catch (e:any){ return moment(); } } showAlert = (str:string)=>{ // alert(str); } render(){ const {style} =this.props; const {date} = this.state; const fm = getPropertyValue(this.props.data.data.data.config.config,"输出格式"); return ( { const newMonth : number = d.month()+1; const newYear : number = d.year(); const newDay : number = d.date(); const now : any = date; const currentDay : number = now.date(); const currentMonth : number = now.month() + 1; const currentYear : number = now.year() ; this.showAlert(` newMonth = ${newMonth} | current=${currentMonth} \n newYear = ${newYear} | currentYear=${currentYear} \n newDay = ${newDay} | currentDay=${currentDay} \n `) if(currentDay == newDay && (newMonth!=currentMonth || newYear != currentYear)){ // 这种状态就只是单纯的切换年月,无需完成跳转 this.showAlert("这种状态就只是单纯的切换年月,无需完成跳转") this.setState({date : d}) return ; } this.showAlert("完成跳转") this.setState({date : d}) const value = d.format(fm) const settings = this.props.data.data.data.config.config; onClickNewTag(settings ,{"_value":value,...getUrlParam()}) }}/> ) } }