"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.defaultRefObject = exports["default"] = exports.PAGE_TEMPLATE_APPRAISAL = exports.PAGE_SUBORDINATE_APPRAISAL = exports.PAGE_STATISTICS_APPRAISAL = exports.PAGE_SCORE_APPRAISAL = exports.PAGE_MY_APPRAISAL = exports.PAGE_MANAGE_APPRAISAL = exports.PAGE_LIBRARY_APPRAISAL = exports.PAGE_HELP_APPRAISAL = exports.PAGE_EVALUATE_APPRAISAL = exports.PAGE_DEPART_APPRAISAL = exports.PAGE_DASHBOARD_APPRAISAL = void 0;

var _bsGlobal = require("../../../../utils/bs-global");

var _i18n = require("../../i18n");

var _getLocale = require("../../../../utils/getLocale");

var _index = require("../../components/menu-tree/tree-node/index");

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

var defaultRefObject = {
  menus: [],
  getMenus: function getMenus() {}
};
exports.defaultRefObject = defaultRefObject;

var _ref = (0, _bsGlobal.getBSGlobal)('AssessAdvancedSetting') || {},
    _ref$AssessFunctionSe = _ref.AssessFunctionSetting;

_ref$AssessFunctionSe = _ref$AssessFunctionSe === void 0 ? {} : _ref$AssessFunctionSe;
var StartAssessByDepartmentLeader = _ref$AssessFunctionSe.StartAssessByDepartmentLeader,
    StartAssessByUser = _ref$AssessFunctionSe.StartAssessByUser,
    StartAssessByHrbp = _ref$AssessFunctionSe.StartAssessByHrbp;

var _getUserInfo = (0, _bsGlobal.getUserInfo)(),
    HasSub = _getUserInfo.HasSub,
    IsAssessManager = _getUserInfo.IsAssessManager,
    IsLeader = _getUserInfo.IsLeader,
    IsBoss = _getUserInfo.IsBoss,
    IsRoot = _getUserInfo.IsRoot,
    Role = _getUserInfo.Role,
    IsHrbp = _getUserInfo.IsHrbp;

var performanceManageAuthority = IsAssessManager || IsLeader && StartAssessByDepartmentLeader || StartAssessByUser || IsHrbp && StartAssessByHrbp;
var performanceStatisticsAuthority = IsAssessManager || IsBoss || IsRoot && Role !== 4 || IsLeader || IsHrbp;
var PAGE_MY_APPRAISAL = 'my-appraisal';
exports.PAGE_MY_APPRAISAL = PAGE_MY_APPRAISAL;
var PAGE_EVALUATE_APPRAISAL = 'evaluate-appraisal';
exports.PAGE_EVALUATE_APPRAISAL = PAGE_EVALUATE_APPRAISAL;
var PAGE_SUBORDINATE_APPRAISAL = 'subordinate-appraisal';
exports.PAGE_SUBORDINATE_APPRAISAL = PAGE_SUBORDINATE_APPRAISAL;
var PAGE_DEPART_APPRAISAL = 'depart-appraisal';
exports.PAGE_DEPART_APPRAISAL = PAGE_DEPART_APPRAISAL;
var PAGE_MANAGE_APPRAISAL = 'manage-appraisal';
exports.PAGE_MANAGE_APPRAISAL = PAGE_MANAGE_APPRAISAL;
var PAGE_TEMPLATE_APPRAISAL = 'template-appraisal';
exports.PAGE_TEMPLATE_APPRAISAL = PAGE_TEMPLATE_APPRAISAL;
var PAGE_LIBRARY_APPRAISAL = 'library-appraisal';
exports.PAGE_LIBRARY_APPRAISAL = PAGE_LIBRARY_APPRAISAL;
var PAGE_SCORE_APPRAISAL = 'score-appraisal';
exports.PAGE_SCORE_APPRAISAL = PAGE_SCORE_APPRAISAL;
var PAGE_HELP_APPRAISAL = 'help-appraisal';
exports.PAGE_HELP_APPRAISAL = PAGE_HELP_APPRAISAL;
var PAGE_DASHBOARD_APPRAISAL = 'dashboard-appraisal';
exports.PAGE_DASHBOARD_APPRAISAL = PAGE_DASHBOARD_APPRAISAL;
var PAGE_STATISTICS_APPRAISAL = 'statistics-appraisal';
exports.PAGE_STATISTICS_APPRAISAL = PAGE_STATISTICS_APPRAISAL;

var AppraisalMenus = /*#__PURE__*/function () {
  function AppraisalMenus() {
    _classCallCheck(this, AppraisalMenus);

    this.menus = [{
      icon: 'kaohe',
      label: _i18n.locale.menu_myass,
      key: PAGE_MY_APPRAISAL,
      href: '#/performance?reactRouterName=self',
      isShow: true
    }, {
      icon: 'mypingjia',
      label: _i18n.locale.menu_evaluated_ass,
      key: PAGE_EVALUATE_APPRAISAL,
      href: '#/performance?reactRouterName=evaluated',
      isShow: true
    }, {
      icon: 'caidan-xiashu',
      label: _i18n.locale.menu_subordinate_ass,
      key: PAGE_SUBORDINATE_APPRAISAL,
      href: '#/performance?reactRouterName=subordinate',
      isShow: HasSub
    }, {
      icon: 'bumen',
      label: _i18n.locale.menu_department_ass,
      key: PAGE_DEPART_APPRAISAL,
      href: '#/performance?reactRouterName=department',
      isShow: IsLeader || IsHrbp
    }, {
      icon: '',
      label: _i18n.locale.menu_management_ass,
      key: 'manage-appraisal-group',
      type: _index.GROUP_NAME_NODE,
      href: '',
      isShow: performanceManageAuthority || performanceStatisticsAuthority
    }, {
      icon: 'uniEA10',
      label: _i18n.locale.menu_template_ass,
      key: PAGE_TEMPLATE_APPRAISAL,
      type: _index.MENU_ASSESS_TEMPLATE,
      href: '#/performance?reactRouterName=template',
      isShow: performanceManageAuthority
    }, {
      icon: 'untitled',
      label: _i18n.locale.menu_management_ass,
      key: PAGE_MANAGE_APPRAISAL,
      type: _index.MENU_ASSESS_MANAGE,
      href: '#/performance?reactRouterName=manage',
      isShow: performanceManageAuthority
    }, {
      icon: 'yibiao',
      label: _i18n.locale.menu_dashboard_ass,
      key: PAGE_DASHBOARD_APPRAISAL,
      href: '#/performance?reactRouterName=dashboard',
      isShow: performanceStatisticsAuthority
    }, {
      icon: 'baobiao',
      label: _i18n.locale.menu_statistics_ass,
      key: PAGE_STATISTICS_APPRAISAL,
      href: '#/performance?reactRouterName=report',
      isShow: performanceStatisticsAuthority
    }, {
      icon: '',
      label: _i18n.locale.menu_basesetting,
      key: 'base-appraisal-group',
      type: _index.GROUP_NAME_NODE,
      href: '',
      isShow: performanceManageAuthority || IsAssessManager
    }, {
      icon: 'ZBmuban',
      label: _i18n.locale.menu_library_ass,
      key: PAGE_LIBRARY_APPRAISAL,
      href: '#/performance?reactRouterName=templateLibrary',
      isShow: performanceManageAuthority
    }, {
      icon: 'PF-shezhi',
      label: _i18n.locale.menu_score_ass,
      key: PAGE_SCORE_APPRAISAL,
      href: '#/performance?reactRouterName=setting',
      isShow: IsAssessManager
    }, {
      icon: 'KH-help',
      label: _i18n.locale.menu_help_ass,
      key: PAGE_HELP_APPRAISAL,
      href: '#/performance?reactRouterName=help',
      isShow: IsAssessManager
    }];
    this.newMenus = {
      myPerformance: [{
        icon: 'kaohe',
        label: _i18n.locale.menu_myass,
        key: PAGE_MY_APPRAISAL,
        href: '#/performance/my?reactRouterName=self',
        isShow: true
      }, {
        icon: 'mypingjia',
        label: _i18n.locale.menu_evaluated_ass,
        key: PAGE_EVALUATE_APPRAISAL,
        href: '#/performance/my?reactRouterName=evaluated',
        isShow: true
      }, {
        icon: 'caidan-xiashu',
        label: _i18n.locale.menu_subordinate_ass,
        key: PAGE_SUBORDINATE_APPRAISAL,
        href: '#/performance/my?reactRouterName=subordinate',
        isShow: HasSub
      }, {
        icon: 'bumen',
        label: _i18n.locale.menu_department_ass,
        key: PAGE_DEPART_APPRAISAL,
        href: '#/performance/my?reactRouterName=department',
        isShow: IsLeader || IsHrbp
      }],
      performanceManage: [{
        icon: 'uniEA10',
        label: _i18n.locale.menu_template_ass,
        key: PAGE_TEMPLATE_APPRAISAL,
        type: _index.MENU_ASSESS_TEMPLATE,
        href: '#/performance/manage?reactRouterName=template',
        isShow: performanceManageAuthority
      }, {
        icon: 'untitled',
        label: _i18n.locale.menu_management_ass,
        key: PAGE_MANAGE_APPRAISAL,
        type: _index.MENU_ASSESS_MANAGE,
        href: '#/performance/manage?reactRouterName=manage',
        isShow: performanceManageAuthority
      }, {
        icon: '',
        label: _i18n.locale.menu_basesetting,
        key: 'base-appraisal-group',
        type: _index.GROUP_NAME_NODE,
        href: '',
        isShow: performanceManageAuthority || IsAssessManager
      }, {
        icon: 'ZBmuban',
        label: _i18n.locale.menu_library_ass,
        key: PAGE_LIBRARY_APPRAISAL,
        href: '#/performance/manage?reactRouterName=templateLibrary',
        isShow: performanceManageAuthority
      }, {
        icon: 'PF-shezhi',
        label: _i18n.locale.menu_score_ass,
        key: PAGE_SCORE_APPRAISAL,
        href: '#/performance/manage?reactRouterName=setting',
        isShow: IsAssessManager
      }, {
        icon: 'KH-help',
        label: _i18n.locale.menu_help_ass,
        key: PAGE_HELP_APPRAISAL,
        href: "#/performance/manage?reactRouterName=help",
        isShow: IsAssessManager
      }],
      performanceDashboard: [{
        icon: 'yibiao',
        label: _i18n.locale.menu_dashboard_ass,
        key: 'dashboard-appraisal',
        href: '#/performance/dashboard?reactRouterName=dashboard',
        isShow: performanceStatisticsAuthority
      }, {
        icon: 'baobiao',
        label: _i18n.locale.menu_statistics_ass,
        key: 'statistics-appraisal',
        href: '#/performance/dashboard?reactRouterName=report',
        isShow: performanceStatisticsAuthority
      }]
    };
  }

  _createClass(AppraisalMenus, [{
    key: "getMenus",
    value: function getMenus() {
      var isUseNewMenu = window.BSGlobal.isUseNewMenu;
      var menus = this.menus;

      if (isUseNewMenu) {
        var hash = window.location.hash.split('?')[0] || '';

        if (hash) {
          if (hash.includes('performance/my')) {
            menus = this.newMenus.myPerformance;
          } else if (hash.includes('performance/manage')) {
            menus = this.newMenus.performanceManage;
          } else {
            menus = this.newMenus.performanceDashboard;
          }
        }
      }

      return this.formateToTreeNodeData(menus);
    } // eslint-disable-next-line class-methods-use-this

  }, {
    key: "formateToTreeNodeData",
    value: function formateToTreeNodeData(menus) {
      var treeNodes = [];

      for (var i = 0; i < menus.length; i += 1) {
        var menu = menus[i];

        if (menu.isShow) {
          treeNodes.push({
            key: "".concat(menu.key),
            title: (0, _getLocale.getLocale)(menu.label) ? (0, _getLocale.getLocale)(menu.label) : menu.label,
            data: menu,
            isLeaf: true,
            children: [],
            nodeType: menu.type || _index.MENU_ITEM_NOE
          });
        }
      }

      return treeNodes;
    }
  }]);

  return AppraisalMenus;
}();

exports["default"] = AppraisalMenus;