/*
 * Author: 黎永顺
 * name:社保福利方案页面重构-高级搜索面板
 * Description:
 * Date: 2024/2/2
 */
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 { searchConditons } from "../../config";

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

@inject("programmeStore")
@observer
class WelfarePlanAdvanceSearchPannel extends Component {

  componentDidMount() {
    const { programmeStore: { planSearchForm } } = this.props;
    planSearchForm.initFormFields(searchConditons);
  }

  render() {
    const { programmeStore: { planSearchForm } } = this.props;
    return (
      <React.Fragment>
        <div className="wea-advanced-searchsAd">
          {getSearchs(planSearchForm, _.map(searchConditons, item => ({
            ...item, title: getLabel(item.lanId, item.title),
            items: _.map(item.items, o => {
              if (getKey(o) === "paymentTypeEnum") {
                return {
                  ...o, label: getLabel(o.lanId, o.label),
                  options: _.map(o.options, k => ({ ...k, showname: getLabel(k.lanId, k.showname) }))
                };
              }
              return {
                ...o, label: getLabel(o.lanId, o.label)
              };
            })
          })), 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={() => planSearchForm.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 WelfarePlanAdvanceSearchPannel;

