/*
 * Author: 黎永顺
 * name: 人员信息确认-基础信息
 * Description:
 * Date: 2023/9/13
 */
import React, { Component } from "react";
import { WeaHelpfulTip, WeaLocaleProvider, WeaSearchGroup } from "ecCom";
import SalaryMonthTip from "../salaryMonthTip";
import { getSalarySobCycle, salaryacctGetForm } from "../../../../../apis/calculate";
import { Col, Row } from "antd";
import "./index.less";

const getLabel = WeaLocaleProvider.getLabel;

class BaseInfo extends Component {
  constructor(props) {
    super(props);
    this.state = {
      salaryInfo: {}, salarySobCycle: {}
    };
  }

  componentDidMount() {
    const promise = this.init();
  }

  init = async () => {
    const { routeParams: { salaryAcctRecordId } } = this.props;
    const [salaryInfo, salarySobCycle] = await Promise.all([salaryacctGetForm({ id: salaryAcctRecordId }), getSalarySobCycle({ salaryAcctRecordId })]);
    if (salaryInfo.status && salarySobCycle.status) {
      this.setState({
        salaryInfo: salaryInfo.data, salarySobCycle: salarySobCycle.data
      });
    }
  };

  render() {
    const { salaryInfo, salarySobCycle } = this.state;
    const { formDTO } = salaryInfo || {};
    return (
      <WeaSearchGroup title={getLabel(82743, "基础信息")} needTigger showGroup className="docalc-baseinfo-layout">
        <Row type="flex" className="docalc-baseinfo">
          <Col span={12}>
            <Row>
              <Col span={6}>
                <span className="label">{getLabel(542604, "薪资所属月")}</span>
                <WeaHelpfulTip
                  width={200} placement="topLeft"
                  title={<SalaryMonthTip {...salarySobCycle}/>}
                  style={{ marginLeft: 10 }}
                />
              </Col>
              <Col span={18}><span className="value">{formDTO && formDTO.salaryMonth}</span></Col>
            </Row>
          </Col>
          <Col span={12}>
            <Row>
              <Col span={6}><span className="label">{getLabel(519146, "核算账套")}</span></Col>
              <Col span={18}><span className="value">{formDTO && formDTO.salarySobName}</span></Col>
            </Row>
          </Col>
          <Col span={24}>
            <Row>
              <Col span={3}><span className="label">{getLabel(536726, "备注")}</span></Col>
              <Col span={21}><span className="value">{formDTO && formDTO.description}</span></Col>
            </Row>
          </Col>
        </Row>
      </WeaSearchGroup>
    );
  }
}

export default BaseInfo;
