import React from "react";
import {
  WeaCheckbox,
  WeaFormItem,
  WeaHelpfulTip,
  WeaInputNumber,
  WeaLocaleProvider,
  WeaSearchGroup,
  WeaTools
} from "ecCom";
import { WeaSwitch } from "comsMobx";
import { Button, Dropdown, Menu } from "antd";
import AdvanceInputBtn from "./components/advanceInputBtn";
import { CancelHelpfulDiv, HelpfulDiv } from "./components/welfareTip";

const getKey = WeaTools.getKey;
const getLabel = WeaLocaleProvider.getLabel;
//批量操作列表
export const welfareTypeEnum = {
  social: "SOCIAL_SECURITY",
  fund: "ACCUMULATION_FUND",
  other: "OTHER"
};
export const optTypeEnum = [
  //批量增员
  {
    key: "batchStaffIncrease",
    type: "addToPay",
    payload: null
  },
  // 待增员-批量删除待办
  {
    key: "batchDeleteTodolist",
    type: "delToDo",
    payload: { runStatus: "4" }
  },
  // 待减员-批量删除待办
  {
    key: "batchDeleteTodolistStayDel",
    type: "delToDoStay",
    payload: { runStatus: "3" }
  },
  //批量减员
  {
    key: "batchReduction",
    type: "stayDelToStop",
    payload: null
  },
  //批量取消停缴
  {
    key: "batchCancellationOfSuspended",
    type: "cancelStop",
    payload: null
  }
];
export const tabList = [
  { viewcondition: "1", title: "待增员", lanId: 542711, showcount: true, groupid: "stayAdd" },
  { viewcondition: "2,3", title: "在缴员工", lanId: 542504, showcount: true, groupid: "paying" },
  { viewcondition: "3", title: "待减员", lanId: 542713, showcount: true, groupid: "stayDel" },
  { viewcondition: "4,5", title: "停缴员工", lanId: 542505, showcount: true, groupid: "stopPay" },
  { viewcondition: "ext", title: "非系统人员", lanId: 542679, showcount: true, groupid: "ext" }
];
export const welfareTipList = [
  {
    viewcondition: "1",
    list: [
      {
        lanId: 544349,
        title: "1、个税扣缴义务人变更进入【待增员】的，保留所有最新版本数据；若修改了数据再增员则修改的数据作为新版本保存；"
      },
      {
        lanId: 544350,
        title: "2、维护好员工的社保福利档案数据后，点击【增员】，数据会进入【在缴员工】；"
      },
      {
        lanId: 544351,
        title: "3、若不需给该员工缴纳，可点击【删除待办】进入【停缴员工】；进入【停缴员工】后，可以点击【取消停缴】再次进入【待增员】；"
      },
      {
        lanId: 544352,
        title: "4、不管起始缴纳月维护到哪个月，都可以进行增员，不影响核算判断；若维护了最后缴纳月，且小于等于当前月，则增员失败；"
      },
      {
        lanId: 544353,
        title: "5、增员失败情况：①终止缴纳月小于等于当前月；②方案或起始缴纳月未维护；"
      }
    ]
  },
  {
    viewcondition: "2,3",
    list: [
      {
        lanId: 544358,
        title: "1、需缴纳社保福利的员工维护在【在缴员工】；"
      },
      {
        lanId: 544359,
        title: "2、可使用更新导入，调整档案数据；"
      },
      {
        lanId: 544360,
        title: "3、若维护了最后缴纳月且小于等于当前月，则自动进入【待减员】；"
      },
      {
        lanId: 544361,
        title: "4、核算人员范围为，【在缴员工】中的起始缴纳月和最后缴纳月区间包含当前月的人员；"
      }
    ]
  },
  {
    viewcondition: "3",
    list: [
      {
        lanId: 544355,
        title: "1、数据进入【待减员】规则：①员工的人事状态属性从在职变成非在职，且在【在缴员工】里；②【在缴员工】里档案维护了缴纳终止月且小于等于当前月；③个税扣缴义务人发生调整；"
      },
      {
        lanId: 544356,
        title: "2、【待减员】为是否不再缴纳的待办状态，数据是从【在缴员工】中复制的，若不处理列表中的待办数据，也不影响社保福利核算；【待减员】维护的数据和【在缴员工】数据是同步的；"
      },
      {
        lanId: 544357,
        title: "3、点击【减员】前先维护最后缴纳月，所有有起始缴纳月的福利项的最后缴纳月都小于等于当前月且无未归档的核算数据的档案才能减员成功，减员成功后数据进入【停缴员工】；"
      }
    ]
  },
  {
    viewcondition: "4,5",
    list: [
      {
        lanId: 544354,
        title: "1、不需要缴纳社保福利的员工，保存在【停缴员工】；"
      }
    ]
  },
  {
    viewcondition: "ext",
    list: []
  }
];
export const renderDropMenuDatas = (selectedKey, getLabel, showOperateBtn) => {
  let menus = [{
    key: "record",
    icon: <i className="iconfont icon-caozuorizhi32"/>,
    content: getLabel(111, "基数调整记录")
  }, {
    key: "log",
    icon: <i className="iconfont icon-caozuorizhi32"/>,
    content: getLabel(545781, "操作日志")
  }];
  if (showOperateBtn) {
    switch (selectedKey) {
      case "1":
        menus = [
          // {
          //   key: "fullStaffIncrease",
          //   icon: <i className="iconfont icon-quanbu"/>,
          //   content: getLabel(543185, "全量增员")
          // },
          // {
          //   key: "batchStaffIncrease",
          //   icon: <i className="iconfont icon-piliangcaozuo"/>,
          //   content: getLabel(543187, "批量增员")
          // },
          // {
          //   key: "batchDeleteTodolist",
          //   icon: <i className="iconfont icon-piliangshanchu"/>,
          //   content: getLabel(543186, "批量删除待办")
          // },
          {
            key: "exportAll",
            icon: <i className="iconfont icon-daochu"/>,
            content: getLabel(81272, "导出全部")
          },
          {
            key: "exportSelected",
            icon: <i className="iconfont icon-piliangdaochu"/>,
            content: getLabel(512938, "导出选中")
          },
          ...menus
        ];
        break;
      case "2,3":
        menus = [
          {
            key: "exportAll",
            icon: <i className="iconfont icon-daochu"/>,
            content: getLabel(81272, "导出全部")
          },
          {
            key: "exportSelected",
            icon: <i className="iconfont icon-piliangdaochu"/>,
            content: getLabel(512938, "导出选中")
          },
          ...menus
        ];
        break;
      case "3":
        menus = [
          // {
          //   key: "fullReduction",
          //   icon: <i className="iconfont icon-quanbu"/>,
          //   content: getLabel(543189, "全量减员")
          // },
          // {
          //   key: "batchReduction",
          //   icon: <i className="iconfont icon-piliangcaozuo"/>,
          //   content: getLabel(543188, "批量减员")
          // },
          // {
          //   key: "batchDeleteTodolistStayDel",
          //   icon: <i className="iconfont icon-piliangshanchu"/>,
          //   content: getLabel(543186, "批量删除待办")
          // },
          {
            key: "exportAll",
            icon: <i className="iconfont icon-daochu"/>,
            content: getLabel(81272, "导出全部")
          },
          {
            key: "exportSelected",
            icon: <i className="iconfont icon-piliangdaochu"/>,
            content: getLabel(512938, "导出选中")
          },
          ...menus
        ];
        break;
      case "4,5":
        menus = [
          // {
          //   key: "batchCancellationOfSuspended",
          //   icon: <i className="iconfont icon-piliangcaozuo"/>,
          //   content: getLabel(543190, "批量取消停缴")
          // },
          {
            key: "exportAll",
            icon: <i className="iconfont icon-daochu"/>,
            content: getLabel(81272, "导出全部")
          },
          {
            key: "exportSelected",
            icon: <i className="iconfont icon-piliangdaochu"/>,
            content: getLabel(512938, "导出选中")
          },
          ...menus
        ];
        break;
      default:
        break;
    }
  }
  return menus;
};
export const renderReqBtns = (selectedKey, getLabel, onOpenAdvanceSearch, onAdvanceSearch, onDropMenuClick, showOperateBtn) => {
  let reqBtns = showOperateBtn ? [
    <Button type="primary" onClick={() => onDropMenuClick("import")}>{getLabel(32935, "导入")}</Button>,
    <AdvanceInputBtn onOpenAdvanceSearch={onOpenAdvanceSearch} onAdvanceSearch={onAdvanceSearch}/>
  ] : [<AdvanceInputBtn onOpenAdvanceSearch={onOpenAdvanceSearch} onAdvanceSearch={onAdvanceSearch}/>];
  if (showOperateBtn) {
    switch (selectedKey) {
      case "1":
        showOperateBtn && reqBtns.splice(1, 0, <Dropdown.Button type="ghost" style={{ marginRight: "10px" }}
                                                                onClick={() => onDropMenuClick("fullStaffIncrease")}
                                                                overlay={<Menu
                                                                  onClick={({ key }) => onDropMenuClick(key)}>
                                                                  <Menu.Item
                                                                    key="batchStaffIncrease">{getLabel(543187, "批量增员")}</Menu.Item>
                                                                  <Menu.Item
                                                                    key="batchDeleteTodolist">{getLabel(543186, "批量删除待办")}</Menu.Item>
                                                                </Menu>}>{getLabel(543185, "全量增员")}</Dropdown.Button>);
        reqBtns.unshift(<WeaHelpfulTip
          width={300} placement="topLeft"
          title={
            <span>
            {getLabel(544348, "提示：缴纳月份区间包含起始缴纳月，不包含最后缴纳月； 若员工离职时还未增员进入在缴员工，则数据会自动清除，因此若确认缴纳，请及时维护档案数据并增员操作。若清除后还需缴纳，需先在个税扣缴义务人菜单将员工按离职状态添加回来，会重新出现在待增员。")}
          </span>
          }
        />);
        break;
      case "3":
        reqBtns.shift();
        showOperateBtn && reqBtns.splice(0, 0, <Dropdown.Button type="primary" style={{ marginRight: "10px" }}
                                                                onClick={() => onDropMenuClick("fullReduction")}
                                                                overlay={<Menu
                                                                  onClick={({ key }) => onDropMenuClick(key)}>
                                                                  <Menu.Item
                                                                    key="batchReduction">{getLabel(543188, "批量减员")}</Menu.Item>
                                                                  <Menu.Item
                                                                    key="batchDeleteTodolistStayDel">{getLabel(543186, "批量删除待办")}</Menu.Item>
                                                                </Menu>}>{getLabel(543189, "全量减员")}</Dropdown.Button>);
        reqBtns.unshift(<WeaHelpfulTip
          width={300} placement="topLeft"
          title={HelpfulDiv}
        />);
        break;
      case "4,5":
        reqBtns.shift();
        showOperateBtn && reqBtns.splice(0, 0, <Button type="primary" style={{ marginRight: "10px" }}
                                                       onClick={() => onDropMenuClick("batchCancellationOfSuspended")}>{getLabel(543190, "批量取消停缴")}</Button>);
        reqBtns.unshift(<WeaHelpfulTip
          width={300} placement="topLeft"
          title={CancelHelpfulDiv}
        />);
        break;
      default:
        break;
    }
  }
  return reqBtns;
};
export const logConditions = [
  {
    items: [
      {
        colSpan: 1,
        conditionType: "BROWSER",
        browserConditionParam: {
          completeParams: {},
          conditionDataParams: {},
          dataParams: {},
          destDataParams: {},
          hasAddBtn: false,
          hasAdvanceSerach: true,
          idSeparator: ",",
          isAutoComplete: 1,
          isDetail: 0,
          isMultCheckbox: false,
          isSingle: true,
          linkUrl: "/hrm/resource/HrmResource.jsp?id=",
          pageSize: 10,
          quickSearchName: "",
          replaceDatas: [],
          title: "",
          type: "1"
        },
        domkey: ["employeeId"],
        fieldcol: 17,
        label: "对象",
        lanId: 106,
        labelcol: 7,
        value: ""
      },
      {
        colSpan: 1,
        conditionType: "BROWSER",
        browserConditionParam: {
          completeParams: {},
          conditionDataParams: {},
          dataParams: {},
          destDataParams: {},
          hasAddBtn: false,
          hasAdvanceSerach: true,
          idSeparator: ",",
          isAutoComplete: 1,
          isDetail: 0,
          isMultCheckbox: false,
          isSingle: true,
          linkUrl: "/hrm/resource/HrmResource.jsp?id=",
          pageSize: 10,
          quickSearchName: "",
          replaceDatas: [],
          title: "",
          type: "1"
        },
        domkey: ["operator"],
        fieldcol: 17,
        label: "操作人",
        lanId: 111,
        labelcol: 7,
        value: ""
      }
    ],
    defaultshow: true
  }
];
export const getLogSearchsForm = (form, condition, onSearch = () => void (0)) => {
  const { isFormInit } = form;
  const formParams = form.getFormParams();
  let group = [];
  isFormInit && condition && condition.map(c => {
    let items = [];
    c.items.map(fields => {
      items.push({
        com: (
          <WeaFormItem
            label={`${fields.label}`} labelCol={{ span: `${fields.labelcol}` }}
            wrapperCol={{ span: `${fields.fieldcol}` }} error={form.getError(fields)}
            tipPosition="bottom"
          >
            <WeaSwitch fieldConfig={fields} form={form} formParams={formParams}/>
            {
              getKey(fields) === "operator" &&
              <Button type="primary" onClick={onSearch}
                      style={{ position: "absolute", right: "-70px", top: "0" }}>{getLabel(388113, "搜索")}</Button>
            }
          </WeaFormItem>),
        colSpan: 1
      });
    });
    group.push(
      <WeaSearchGroup col={4} needTigger={true} title={c.title} showGroup={c.defaultshow} items={items} center={false}
      />);
  });
  return group;
};
export const welfareConditions = [
  {
    defaultshow: true,
    title: "basic",
    col: 3,
    items: [
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["username"],
        fieldcol: 14,
        label: "姓名",
        lanId: 25034,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["department"],
        fieldcol: 14,
        label: "部门",
        lanId: 27511,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["position"],
        fieldcol: 14,
        label: "岗位",
        lanId: 6086,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["telephone"],
        fieldcol: 14,
        label: "手机号",
        lanId: 125238,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["hiredate"],
        fieldcol: 14,
        label: "入职日期",
        lanId: 1516,
        labelcol: 10,
        value: "",
        viewAttr: 1
      }
    ]
  },
  {
    defaultshow: true,
    title: "taxAgent",
    col: 1,
    items: [
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["paymentOrganization"],
        fieldcol: 16,
        label: "个税扣缴义务人",
        lanId: 537996,
        labelcol: 8,
        value: "",
        options: [],
        viewAttr: 1
      }
    ]
  },
  {
    defaultshow: true,
    title: "social", typename: "SOCIAL_SECURITY",
    col: 2, showPaid: true,
    items: [
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["socialSchemeId"],
        fieldcol: 14,
        label: "社保方案名称",
        lanId: 111,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["socialUnderTake"],
        fieldcol: 14,
        label: "社保个人实际承担方",
        lanId: 111,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "MONTHPICKER",
        domkey: ["socialStartTime"],
        fieldcol: 14,
        label: "社保起始缴纳月",
        lanId: 542507,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["schemeAccount"],
        fieldcol: 14,
        label: "社保账号",
        lanId: 81594,
        labelcol: 10,
        value: "",
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "MONTHPICKER",
        domkey: ["socialEndTime"],
        fieldcol: 14,
        label: "社保最后缴纳月",
        lanId: 542508,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      }
    ]
  },
  {
    defaultshow: true,
    title: "fund", typename: "ACCUMULATION_FUND",
    col: 2, showPaid: true,
    items: [
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["fundSchemeId"],
        fieldcol: 14,
        label: "公积金方案名称",
        lanId: 111,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["fundUnderTake"],
        fieldcol: 14,
        label: "公积金个人实际承担方",
        lanId: 111,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "MONTHPICKER",
        domkey: ["fundStartTime"],
        fieldcol: 14,
        label: "公积金起始缴纳月",
        lanId: 542509,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["fundAccount"],
        fieldcol: 14,
        label: "公积金账号",
        lanId: 542268,
        labelcol: 10,
        value: "",
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "MONTHPICKER",
        domkey: ["fundEndTime"],
        fieldcol: 14,
        label: "公积金最后缴纳月",
        lanId: 542510,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["supplementFundAccount"],
        fieldcol: 14,
        label: "补充公积金账号",
        lanId: 542270,
        labelcol: 10,
        value: "",
        viewAttr: 2
      }
    ]
  },
  {
    defaultshow: true,
    title: "others", typename: "OTHER",
    col: 2, showPaid: true,
    items: [
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["otherSchemeId"],
        fieldcol: 14,
        label: "其它福利名称",
        lanId: 111,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "SELECT",
        domkey: ["otherUnderTake"],
        fieldcol: 14,
        label: "其它福利个人实际承担方",
        lanId: 111,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "MONTHPICKER",
        domkey: ["otherStartTime"],
        fieldcol: 14,
        label: "其他福利起始缴纳月",
        lanId: 542511,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      },
      {
        colSpan: 3,
        conditionType: "MONTHPICKER",
        domkey: ["otherEndTime"],
        fieldcol: 14,
        label: "其他福利最后缴纳月",
        lanId: 542512,
        labelcol: 10,
        value: "",
        options: [],
        viewAttr: 2
      }
    ]
  }
];
export const getWelfareSearchsForm = (
  form, condition, onChange = () => void (0),
  onNoPaymentChange = () => void (0), onExtraChange = () => void (0), onSameChange = () => void (0),
  payload, extraFormField, showOperateBtn) => {
  const CustomComponent = ({ type }) => {
    const value = payload[type].nonPayment ? payload[type].nonPayment.toString() : "";
    return <WeaCheckbox
      value={value} content={getLabel(543196, "暂不缴纳")}
      onChange={v => onNoPaymentChange(type, v)}
      disabled={runStatuses === "4,5" || !showOperateBtn}
    />;
  };
  const { socialBase, fundBase, otherBase, runStatuses } = extraFormField;
  const { isFormInit } = form;
  const formParams = form.getFormParams();
  let group = [];
  isFormInit && condition && condition.map(c => {
    let items = [];
    c.items.map(fields => {
      items.push({
        com: (
          <WeaFormItem
            label={`${fields.label}`} labelCol={{ span: `${fields.labelcol}` }}
            wrapperCol={{ span: `${fields.fieldcol}` }} error={form.getError(fields)}
            tipPosition="bottom"
          >
            <WeaSwitch fieldConfig={fields} form={form} formParams={formParams} onChange={onChange}/>
          </WeaFormItem>),
        colSpan: 1,
        hide: fields.hide
      });
    });
    !_.isEmpty(items) && group.push(
      <WeaSearchGroup col={c.col} needTigger={true} showGroup={c.defaultshow} items={items} center={false}
                      title={c.title}
                      customComponent={c.showPaid ? <CustomComponent type={c.typename}/> : <span></span>}
                      className={c.col === 3 ? "basic-welfare-info-wrapper" : (c.col === 2 || c.items.length > 1) ? "twoColumns-welfare-info-wrapper" : ""}
      />);
  });
  return _.reduce(group, (pre, cur) => {
    if (cur.props.title === getLabel(543194, "社保基础信息") && _.every(socialBase.items, o => o.items.length > 0)) {
      if (!_.isNil(socialBase.comItems) && _.every(socialBase.comItems, o => o.items.length > 0)) {
        return [
          ...pre, cur,
          <BenefitBaseComponent
            dataSource={_.map(socialBase.items, o => ({ ...o, title: `${o.title}（${getLabel(500201, "个人")}）` }))}
            value={payload} onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
            showOperateBtn={showOperateBtn}
          />,
          <BenefitBaseComponent
            dataSource={_.map(socialBase.comItems, o => ({
              ...o, title: `${o.title}（${getLabel(1851, "公司")}）`,
              items: _.map(o.items, g => ({ ...g, domkey: [`${getKey(g)}_com`] }))
            }))}
            value={payload} onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
            showOperateBtn={showOperateBtn}
          />
        ];
      } else {
        return [...pre, cur,
          <BenefitBaseComponent dataSource={socialBase.items} value={payload}
                                onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
                                showOperateBtn={showOperateBtn}
          />];
      }
    } else if (cur.props.title === getLabel(543197, "公积金基础信息") && _.every(fundBase.items, o => o.items.length > 0)) {
      if (!_.isNil(fundBase.comItems) && _.every(fundBase.comItems, o => o.items.length > 0)) {
        return [
          ...pre, cur,
          <BenefitBaseComponent
            dataSource={_.map(fundBase.items, o => ({ ...o, title: `${o.title}（${getLabel(500201, "个人")}）` }))}
            value={payload} onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
            showOperateBtn={showOperateBtn}
          />,
          <BenefitBaseComponent
            dataSource={_.map(fundBase.comItems, o => ({
              ...o, title: `${o.title}（${getLabel(1851, "公司")}）`,
              items: _.map(o.items, g => ({ ...g, domkey: [`${getKey(g)}_com`] }))
            }))}
            value={payload} onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
            showOperateBtn={showOperateBtn}
          />
        ];
      } else {
        return [...pre, cur,
          <BenefitBaseComponent dataSource={fundBase.items} value={payload} onChange={onExtraChange}
                                onSameChange={onSameChange} runStatuses={runStatuses}
                                showOperateBtn={showOperateBtn}
          />];
      }
    } else if (cur.props.title === getLabel(543198, "其他福利基础信息") && _.every(otherBase.items, o => o.items.length > 0)) {
      if (!_.isNil(otherBase.comItems) && _.every(otherBase.comItems, o => o.items.length > 0)) {
        return [
          ...pre, cur,
          <BenefitBaseComponent
            dataSource={_.map(otherBase.items, o => ({ ...o, title: `${o.title}（${getLabel(500201, "个人")}）` }))}
            value={payload} onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
            showOperateBtn={showOperateBtn}
          />,
          <BenefitBaseComponent
            dataSource={_.map(otherBase.comItems, o => ({
              ...o, title: `${o.title}（${getLabel(1851, "公司")}）`,
              items: _.map(o.items, g => ({ ...g, domkey: [`${getKey(g)}_com`] }))
            }))}
            value={payload} onChange={onExtraChange} onSameChange={onSameChange} runStatuses={runStatuses}
            showOperateBtn={showOperateBtn}
          />
        ];
      } else {
        return [...pre, cur,
          <BenefitBaseComponent dataSource={otherBase.items} value={payload} onChange={onExtraChange}
                                onSameChange={onSameChange} runStatuses={runStatuses}
                                showOperateBtn={showOperateBtn}
          />];
      }
    }
    return [...pre, cur];
  }, []);
};

const BenefitBaseComponent = (props) => {
  const { dataSource, value, onChange, onSameChange, runStatuses, showOperateBtn } = props;
  return <React.Fragment>
    {
      _.map(dataSource, item => {
        const { title, items } = item;
        return <WeaSearchGroup
          items={_.map(items, child => ({
            com: <WeaFormItem label={child.label} labelCol={{ span: 10 }} wrapperCol={{ span: 14 }}>
              <WeaInputNumber
                value={value[getKey(child)] || (child.min !== "0.000" ? child.min : 0)} precision={2}
                // min={(child.min !== "0.000" && value.welBaseAutoAdjust) ? parseFloat(child.min) : -999999999999999}
                // max={(child.max !== "0.000" && value.welBaseAutoAdjust) ? parseFloat(child.max) : 999999999999999}
                onChange={v => onChange(getKey(child), v)}
                viewAttr={(runStatuses === "4,5" || !showOperateBtn) ? 1 : 2}
              />
            </WeaFormItem>
          }))}
          customComponent={<div className="welfare-same-box">
            <span>{getLabel(543195, "各项福利基数一致")}</span>
            <WeaInputNumber style={{ width: 100 }} onBlur={v => onSameChange(items, v)}
                            disabled={runStatuses === "4,5" || !showOperateBtn} precision={2}/>
          </div>}
          title={title} col={2} showGroup className="twoColumns-welfare-info-wrapper"
        />;
      })
    }
  </React.Fragment>;
};
