/*
 * Author: 黎永顺
 * name:薪酬统计报薪资明细-高级查询
 * Description:
 * Date: 2024/3/26
 */
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTools } from "ecCom";
import { Button } from "antd";
import { inject, observer } from "mobx-react";
import { getSearchs } from "../../../../util";
import { conditions } from "../../conditions";

const getLabel = WeaLocaleProvider.getLabel;
const getKey = WeaTools.getKey;

@inject("baseTableStore")
@observer
class VariableSalarySearchPannel extends Component {
  constructor(props) {
    super(props);
    this.state = {
      searchConditions: []
    };
  }

  componentDidMount() {
    this.setState({
      searchConditions: _.map(conditions, item => {
        return {
          ...item,
          items: _.map(item.items, child => ({ ...child, label: getLabel(child.lanId, child.label) }))
        };
      })
    }, () => {
      const { baseTableStore: { VSalryForm } } = this.props;
      VSalryForm.initFormFields(this.state.searchConditions);
    });
  }

  render() {
    const { searchConditions } = this.state;
    const { baseTableStore: { VSalryForm } } = this.props;
    return (
      <React.Fragment>
        <div className="wea-advanced-searchsAd">
          {getSearchs(VSalryForm, searchConditions, 2, false)}
        </div>
        <div className="wea-search-buttons">
          <div style={{ textAlign: "center" }}>
            <span style={{ marginLeft: 15 }}>
              <Button type="primary" onClick={this.props.onAdSearch}>{getLabel(388113, "搜索")}</Button>
            </span>
            <span style={{ marginLeft: 15 }}>
              <Button type="ghost" onClick={() => VSalryForm.resetForm()}>{getLabel(2022, "重置")}</Button>
            </span>
            <span style={{ marginLeft: 15 }}>
              <Button type="ghost" onClick={this.props.onCancel}>{getLabel(31129, "取消")}</Button>
            </span>
          </div>
        </div>
      </React.Fragment>
    );
  }
}

export default VariableSalarySearchPannel;

