import React from "react";
import { WeaHelpfulTip, WeaLocaleProvider } from "ecCom";
import { Button, Dropdown, Menu } from "antd";
import AdvanceInputBtn from "../components/advanceInputBtn";

const getLabel = WeaLocaleProvider.getLabel;

export const tabCondition = [
  {
    color: "#000000",
    groupid: "PENDING",
    showcount: true,
    title: "待定薪",
    viewcondition: "pending"
  },
  {
    color: "#000000",
    groupid: "FIXED",
    showcount: true,
    title: "发薪员工",
    viewcondition: "fixed"
  },
  {
    color: "#000000",
    groupid: "SUSPEND",
    showcount: true,
    title: "待停薪",
    viewcondition: "suspend"
  },
  {
    color: "#000000",
    groupid: "STOP",
    showcount: true,
    title: "停薪员工",
    viewcondition: "stop"
  },
  {
    color: "#000000",
    groupid: "EXT",
    showcount: true,
    title: "非系统人员",
    viewcondition: "ext"
  }
];
export const tabList = [
  { viewcondition: "pending", title: "待定薪", lanId: 542689, showcount: true, groupid: "PENDING" },
  { viewcondition: "fixed", title: "发薪员工", lanId: 544638, showcount: true, groupid: "FIXED" },
  { viewcondition: "suspend", title: "待停薪", lanId: 542691, showcount: true, groupid: "SUSPEND" },
  { viewcondition: "stop", title: "停薪员工", lanId: 544637, showcount: true, groupid: "STOP" },
  { viewcondition: "ext", title: "非系统人员", lanId: 542679, showcount: true, groupid: "EXT" }
];
export const renderReqBtns = (selectedKey, salaryImportTypes, onSalaryOpts, showOperateBtn) => {
  let reqBtns = [
    <Button type="primary" onClick={() => onSalaryOpts("IMPORT")}>{getLabel(32935, "导入")}</Button>,
    <AdvanceInputBtn
      onOpenAdvanceSearch={() => onSalaryOpts("OPEN")} onAdvanceSearch={() => onSalaryOpts("SEARCH")}
    />
  ];
  switch (selectedKey) {
    case "pending":
      !showOperateBtn && reqBtns.shift();
      showOperateBtn && reqBtns.splice(1, 0, <Dropdown.Button type="ghost" style={{ marginRight: "10px" }}
                                                              onClick={() => onSalaryOpts("ALL-GO-TO-FIXED")}
                                                              overlay={<Menu
                                                                onClick={({ key }) => onSalaryOpts(key)}>
                                                                <Menu.Item
                                                                  key="ADD-TO-SALARYPAYMENT">{getLabel(543305, "批量设为发薪员工")}</Menu.Item>
                                                                <Menu.Item
                                                                  key="DEL-PENDITNG-TO-DO">{getLabel(543186, "批量删除待办")}</Menu.Item>
                                                              </Menu>}>{getLabel(543304, "全部设为发薪人员")}</Dropdown.Button>);
      break;
    case "suspend":
      !showOperateBtn && reqBtns.shift();
      showOperateBtn && reqBtns.splice(1, 0, <Dropdown.Button type="ghost" style={{ marginRight: "10px" }}
                                                              onClick={() => onSalaryOpts("FULL-SALARY-SUSPENSION")}
                                                              overlay={<Menu
                                                                onClick={({ key }) => onSalaryOpts(key)}>
                                                                <Menu.Item
                                                                  key="SALARY-SUSPENSION">{getLabel(543724, "批量停薪")}</Menu.Item>
                                                                <Menu.Item
                                                                  key="DEL-SUSPEND-TO-DO">{getLabel(543186, "批量删除待办")}</Menu.Item>
                                                              </Menu>}>{getLabel(543326, "全部停薪")}</Dropdown.Button>);
      break;
    case "fixed":
    case "ext":
      reqBtns.shift();
      showOperateBtn && reqBtns.unshift(
        <Dropdown overlay={
          <Menu className="dropdownMenuWrapper" onClick={({ key }) => onSalaryOpts("IMPORT", key)}>
            {salaryImportTypes.map((item) => (
              <Menu.Item key={item.id}>{item.content}</Menu.Item>
            ))}
          </Menu>
        }>
          <Button type="primary">{getLabel(32935, "导入")}</Button>
        </Dropdown>
      );
      showOperateBtn && reqBtns.unshift(<WeaHelpfulTip
        width={300} placement="topLeft"
        title={<HelpfulDiv/>}
      />);
      break;
    case "stop":
      reqBtns.shift();
      showOperateBtn && reqBtns.unshift(<Button type="primary"
                                                onClick={() => onSalaryOpts("CANCEL-SALARY-SUSPENSION")}>{getLabel(543307, "批量取消停薪")}</Button>);
      break;
    default:
      break;
  }
  return reqBtns;
};
export const renderDropMenuDatas = (selectedKey, showOperateBtn) => {
  let menus = [{
    key: "custom_cols",
    icon: <i className="icon-coms-Custom"/>,
    content: getLabel(32535, "显示列定制")
  }, {
    key: "log",
    icon: <i className="iconfont icon-caozuorizhi32"/>,
    content: getLabel(545781, "操作日志")
  }];
  switch (selectedKey) {
    case "pending":
      menus = [
        // {
        //   key: "ADD-TO-SALARYPAYMENT",
        //   icon: <i className="icon-coms-BatchEditing-Hot"/>,
        //   content: getLabel(543305, "批量设为发薪员工")
        // },
        // {
        //   key: "DEL-PENDITNG-TO-DO",
        //   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 "fixed":
      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 "suspend":
      menus = [
        // {
        //   key: "FULL-SALARY-SUSPENSION",
        //   icon: <i className="icon-coms02-all"/>,
        //   content: getLabel(543326, "全部停薪")
        // },
        // {
        //   key: "SALARY-SUSPENSION",
        //   icon: <i className="icon-coms-BatchEditing-Hot"/>,
        //   content: getLabel(543724, "批量停薪")
        // },
        // {
        //   key: "DEL-SUSPEND-TO-DO",
        //   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 "stop":
      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;
    default:
      break;
  }
  return showOperateBtn ? menus : _.filter(menus, o => o.key === "custom_cols");
};

export const salaryFileSearchConditions = [
  {
    items: [
      {
        conditionType: "INPUT",
        domkey: ["username"],
        fieldcol: 16,
        label: getLabel(25034, "姓名"),
        labelcol: 8,
        value: "",
        viewAttr: 2
      },
      {
        browserConditionParam: {
          completeParams: {},
          conditionDataParams: {},
          dataParams: {},
          destDataParams: {},
          hasAddBtn: false,
          hasAdvanceSerach: false,
          idSeparator: ",",
          isAutoComplete: 1,
          isDetail: 0,
          isMultCheckbox: false,
          isSingle: false,
          icon: "icon-coms-hrm",
          linkUrl: "",
          pageSize: 10,
          quickSearchName: "",
          replaceDatas: [],
          title: "",
          type: "164",
          viewAttr: 2
        },
        colSpan: 1,
        conditionType: "BROWSER",
        domkey: ["subcompanyIds"],
        fieldcol: 16,
        label: getLabel(33553, "分部"),
        labelcol: 8,
        viewAttr: 2
      },
      {
        browserConditionParam: {
          completeParams: {},
          conditionDataParams: {},
          dataParams: {},
          destDataParams: {},
          hasAddBtn: false,
          hasAdvanceSerach: false,
          idSeparator: ",",
          isAutoComplete: 1,
          isDetail: 0,
          isMultCheckbox: false,
          isSingle: false,
          icon: "icon-coms-hrm",
          linkUrl: "",
          pageSize: 10,
          quickSearchName: "",
          replaceDatas: [],
          title: "",
          type: "57",
          viewAttr: 2
        },
        conditionType: "BROWSER",
        domkey: ["departmentIds"],
        fieldcol: 16,
        label: getLabel(27511, "部门"),
        labelcol: 8,
        viewAttr: 2
      },
      {
        browserConditionParam: {
          completeParams: {},
          conditionDataParams: {},
          dataParams: {},
          destDataParams: {},
          hasAddBtn: false,
          hasAdvanceSerach: false,
          idSeparator: ",",
          isAutoComplete: 1,
          isDetail: 0,
          isMultCheckbox: false,
          isSingle: false,
          icon: "icon-coms-hrm",
          linkUrl: "",
          pageSize: 10,
          quickSearchName: "",
          replaceDatas: [],
          title: "",
          type: "24",
          viewAttr: 2
        },
        conditionType: "BROWSER",
        domkey: ["positionIds"],
        fieldcol: 16,
        label: getLabel(6086, "岗位"),
        labelcol: 8,
        viewAttr: 2
      },
      {
        conditionType: "SELECT",
        domkey: ["statuses"],
        fieldcol: 16,
        label: getLabel(382300, "人员状态"),
        labelcol: 8,
        options: [],
        multiple: true,
        viewAttr: 2
      },
      {
        conditionType: "SELECT",
        domkey: ["taxAgentIds"],
        fieldcol: 16,
        label: getLabel(537996, "个税扣缴义务人"),
        labelcol: 8,
        multiple: true,
        options: [],
        viewAttr: 2
      },
      {
        conditionType: "INPUT",
        domkey: ["workcode"],
        fieldcol: 16,
        label: getLabel(1933, "工号"),
        labelcol: 8,
        value: "",
        viewAttr: 2
      },
      {
        conditionType: "RANGEPICKER",
        domkey: ["payStartDateStartDateStr", "payStartDateEndDateStr"],
        fieldcol: 16,
        label: getLabel(542346, "起始发薪日期"),
        labelcol: 8,
        value: "",
        viewAttr: 2
      },
      {
        conditionType: "RANGEPICKER",
        domkey: ["payEndDateStartDateStr", "payEndDateEndDateStr"],
        fieldcol: 16,
        label: getLabel(542347, "最后发薪日期"),
        labelcol: 8,
        value: "",
        viewAttr: 2
      },
      {
        conditionType: "RANGEPICKER",
        domkey: ["adjustSalaryStartDate", "adjustSalaryEndDate"],
        fieldcol: 16,
        label: getLabel(111, "调薪日期"),
        labelcol: 8,
        value: "",
        viewAttr: 2
      }
    ],
    defaultshow: true,
    title: getLabel(1361, "基本信息"),
    col: 2
  }
];
export const salaryFilesConditions = [
  {
    defaultshow: true, title: getLabel(1361, "基本信息"),
    col: 3, lanId: 1361,
    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: 111,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["hiredate"],
        fieldcol: 14,
        label: "入职时间",
        lanId: 1908,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["mobile"],
        fieldcol: 14,
        label: "手机号",
        lanId: 125238,
        labelcol: 10,
        value: "",
        viewAttr: 1
      },
      {
        colSpan: 3,
        conditionType: "INPUT",
        domkey: ["taxAgent"],
        fieldcol: 14,
        label: "个税扣缴义务人",
        lanId: 537996,
        labelcol: 10,
        value: "",
        viewAttr: 1
      }
    ]
  },
  {
    defaultshow: true, title: getLabel(543329, "发薪设置"),
    col: 1,lanId: 543329,
    items: [
      {
        colSpan: 1,
        conditionType: "DATEPICKER",
        domkey: ["payStartDate"],
        fieldcol: 16,
        label: "起始发薪日期",
        lanId: 542346,
        labelcol: 8,
        value: "",
        rules: "required|string",
        viewAttr: 3
      },
      {
        colSpan: 1,
        conditionType: "DATEPICKER",
        domkey: ["payEndDate"],
        fieldcol: 16,
        label: "最后发薪日期",
        lanId: 542347,
        labelcol: 8,
        value: "",
        viewAttr: 2
      }
    ]
  },
  {
    defaultshow: true, title: getLabel(538004, "薪资档案"),
    titleHelpful: getLabel(543330, "提示：显示已生效的最新数据"),
    titleHelpfulLanId: 543330,
    col: 2, salaryFile: true,lanId: 538004,
    items: []
  }
];
const HelpfulDiv = () => {
  return <div className="helpWrapper">
    <span>{getLabel(544742, "导入按钮使用场景说明：")}</span>
    <span>{getLabel(544743, "1.档案初始化：")}</span>
    <span className="pl10">
      <span>{getLabel(544744, "a.初次使用薪酬模块，全量导入员工的薪资档案数据；")}</span>
      <span>{getLabel(544745, "b.员工入职，导入新入职的员工的薪资档案数据（若导入表格中的人员已存在在薪资档案中，初始化导入会将档案中该人员的数据清除再导入）；")}</span>
      <span>{getLabel(544746, "c.返聘人员使用调薪功能调整薪资档案值或使用调整个税扣缴；")}</span>
    </span>
    <span>{getLabel(545755, "2.调薪：档案中已存在的人员批量调整薪资项目值（包括返聘人员的情况）；")}</span>
    {/*<span>{getLabel(545756, "3.调整个税扣缴义务人：档案中已存在的人员批量调整个税扣缴义务人（包括返聘人员的情况）；")}</span>*/}
  </div>;
};
