/*
 * Author: 黎永顺
 * name:历史工资单
 * Description:
 * Date: 2024/1/25
 */
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTools } from "ecCom";
import { MonthRangePicker } from "../reportView/components/statisticalMicroSettingsSlide";
import Payroll from "../mySalaryBenefits/components/payrollTable";
import moment from "moment";
import "./index.less";

const getLabel = WeaLocaleProvider.getLabel;

class Index extends Component {
  constructor(props) {
    super(props);
    this.state = {
      dateRange: [
        moment(new Date()).subtract(1, "year").startOf("year").format("YYYY-MM"),
        moment(new Date()).endOf("year").format("YYYY-MM")
      ]
    };
  }

  render() {
    const { dateRange } = this.state;
    const employeeId = WeaTools.getUrlParams().hrmResourceID;
    return (
      <div className="history-payroll-box">
        <div className="topQuery">
          <span className="title">{getLabel(542604, "薪资所属月")}</span>
          <MonthRangePicker dateRange={dateRange} viewAttr={2}
                            onChange={v => this.setState({ dateRange: v })}/>
        </div>
        <Payroll salaryYearMonth={dateRange} type="mySalaryBillList4Card" employeeId={employeeId}/>
      </div>
    );
  }
}

export default Index;
