/*
 * Author: 黎永顺
 * name: 基础设置
 * Description:
 * Date: 2022/11/29
 */
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { decentralizationConditions, editConditions } from "../../taxAgent/editConditions";
import { getSearchs } from "../../../util";

@inject("taxAgentStore")
@observer
class BaseSettings extends Component {

  componentDidMount() {

  }

  render() {
    const { taxAgentStore: { salarytaxAgentForm }, decentralization, isChief } = this.props;
    return (
      <div className="baseSettingWrapper form-dialog-layout">
        {
          decentralization === "0" ?
            getSearchs(salarytaxAgentForm, convertConditon(decentralizationConditions, !isChief), 1, false) :
            getSearchs(salarytaxAgentForm, convertConditon(editConditions, !isChief), 1, false)
        }
      </div>
    );
  }
}

export default BaseSettings;

export const convertConditon = (condition, bool) => {
  return _.map(condition, item => {
    return {
      ...item,
      items: _.map(item.items, child => {
        return {
          ...child,
          viewAttr: bool ? 1 : child.viewAttr
        };
      })
    };
  });
};
