"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.defaultRefObject = exports["default"] = exports.PAGE_UNASSIGNED_DEMOFREE = exports.PAGE_STAFF_ROLES_MANAGEMENT = exports.PAGE_RESERVED_DEMOFREE = exports.PAGE_RECHARGE_STATUS = exports.PAGE_RECHARGE_STATISTICS = exports.PAGE_RECHARGE_LIST = exports.PAGE_PUBLIC_CUSTOMER = exports.PAGE_MY_CUSTOMER = exports.PAGE_LIMIT_CUSTOMER = exports.PAGE_IGNORED_DEMOFREE = exports.PAGE_DUEDATE_ORDER = exports.PAGE_DONE_DEMOFREE = exports.PAGE_CHARTS_DEMOFREE = exports.PAGE_CHARTS = exports.PAGE_ASSIGNED_DEMOFREE = exports.PAGE_ALL_CUSTOMER = exports.ERoleType = void 0;

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 ERoleType;
exports.ERoleType = ERoleType;

(function (ERoleType) {
  ERoleType["Sales"] = "sales";
  ERoleType["Manager"] = "manager";
  ERoleType["Supervisor"] = "supervisor";
  ERoleType["SalesOperation"] = "salesOperation";
  ERoleType["CRM"] = "CRM";
  ERoleType["PublicCustomer"] = "publicCustomer";
  ERoleType["DemoReadOnly"] = "demoReadOnly";
})(ERoleType || (exports.ERoleType = ERoleType = {}));

var demoRole = [ERoleType.Sales, ERoleType.Manager, ERoleType.Supervisor, ERoleType.SalesOperation, ERoleType.DemoReadOnly];
var defaultRefObject = {
  menus: [],
  getMenus: function getMenus() {}
};
exports.defaultRefObject = defaultRefObject;
var PAGE_UNASSIGNED_DEMOFREE = "unassigned";
exports.PAGE_UNASSIGNED_DEMOFREE = PAGE_UNASSIGNED_DEMOFREE;
var PAGE_ASSIGNED_DEMOFREE = "assigned";
exports.PAGE_ASSIGNED_DEMOFREE = PAGE_ASSIGNED_DEMOFREE;
var PAGE_RESERVED_DEMOFREE = "reserved";
exports.PAGE_RESERVED_DEMOFREE = PAGE_RESERVED_DEMOFREE;
var PAGE_DONE_DEMOFREE = "done";
exports.PAGE_DONE_DEMOFREE = PAGE_DONE_DEMOFREE;
var PAGE_IGNORED_DEMOFREE = "ignore";
exports.PAGE_IGNORED_DEMOFREE = PAGE_IGNORED_DEMOFREE;
var PAGE_CHARTS_DEMOFREE = "charts";
exports.PAGE_CHARTS_DEMOFREE = PAGE_CHARTS_DEMOFREE;
var PAGE_ALL_CUSTOMER = "allCustomer";
exports.PAGE_ALL_CUSTOMER = PAGE_ALL_CUSTOMER;
var PAGE_PUBLIC_CUSTOMER = "publicCustomer";
exports.PAGE_PUBLIC_CUSTOMER = PAGE_PUBLIC_CUSTOMER;
var PAGE_LIMIT_CUSTOMER = 'limitCustomer';
exports.PAGE_LIMIT_CUSTOMER = PAGE_LIMIT_CUSTOMER;
var PAGE_MY_CUSTOMER = "myCustomer";
exports.PAGE_MY_CUSTOMER = PAGE_MY_CUSTOMER;
var PAGE_CHARTS = "charts";
exports.PAGE_CHARTS = PAGE_CHARTS;
var PAGE_RECHARGE_LIST = "rechargeList";
exports.PAGE_RECHARGE_LIST = PAGE_RECHARGE_LIST;
var PAGE_DUEDATE_ORDER = "dueDateOrder";
exports.PAGE_DUEDATE_ORDER = PAGE_DUEDATE_ORDER;
var PAGE_RECHARGE_STATISTICS = "rechargeStatistics";
exports.PAGE_RECHARGE_STATISTICS = PAGE_RECHARGE_STATISTICS;
var PAGE_RECHARGE_STATUS = "rechargeStatus";
exports.PAGE_RECHARGE_STATUS = PAGE_RECHARGE_STATUS;
var PAGE_STAFF_ROLES_MANAGEMENT = 'staffManagement';
exports.PAGE_STAFF_ROLES_MANAGEMENT = PAGE_STAFF_ROLES_MANAGEMENT;

var DemoMenuData = /*#__PURE__*/function () {
  function DemoMenuData(roleList, showCompeteCustomer) {
    _classCallCheck(this, DemoMenuData);

    this.roleList = roleList;
    this.showDemo = this.roleList.some(function (role) {
      return demoRole.includes(role);
    });
    this.isManager = this.roleList.includes(ERoleType.Manager);
    this.showCompeteCustomer = showCompeteCustomer;
    this.menus = [{
      icon: "kaohe",
      label: "任务状态",
      key: "demofree",
      href: this.isManager ? "#/demofree/list?selected=unassigned" : "#/demofree/list?selected=assigned",
      isShow: this.showDemo,
      children: [{
        icon: "",
        label: "未分配",
        key: "unassigned",
        href: "#/demofree/list?selected=unassigned",
        isShow: this.isManager
      }, {
        icon: "",
        label: "已分配",
        key: "assigned",
        href: "#/demofree/list?selected=assigned",
        isShow: this.showDemo
      }, {
        icon: "",
        label: "已预约",
        key: "reserved",
        href: "#/demofree/list?selected=reserved",
        isShow: this.showDemo
      }, {
        icon: "",
        label: "已完成",
        key: "done",
        href: "#/demofree/list?selected=done",
        isShow: this.showDemo
      }, {
        icon: "",
        label: "已忽略",
        key: "ignore",
        href: "#/demofree/list?selected=ignore",
        isShow: this.isManager
      }]
    }, {
      icon: "KH-help",
      label: "公海资源",
      key: "customer",
      href: "#/demofree/customer/public",
      isShow: this.roleList.some(function (role) {
        return [ERoleType.SalesOperation, ERoleType.Manager, ERoleType.PublicCustomer].includes(role);
      }),
      children: [{
        icon: "",
        label: "全部客户",
        key: PAGE_ALL_CUSTOMER,
        href: "#/demofree/customer/all",
        isShow: this.roleList.some(function (role) {
          return [ERoleType.SalesOperation, ERoleType.Manager].includes(role);
        })
      }, {
        icon: "",
        label: "公海资源",
        key: PAGE_PUBLIC_CUSTOMER,
        href: "#/demofree/customer/public",
        isShow: this.roleList.some(function (role) {
          return [ERoleType.SalesOperation, ERoleType.Manager].includes(role);
        })
      }, {
        icon: "",
        label: "限时资源",
        key: PAGE_LIMIT_CUSTOMER,
        href: "#/demofree/customer/limit",
        isShow: this.roleList.some(function (role) {
          return [ERoleType.SalesOperation, ERoleType.Manager, ERoleType.PublicCustomer].includes(role);
        }) && this.showCompeteCustomer
      }, {
        icon: "",
        label: "我的资源",
        key: PAGE_MY_CUSTOMER,
        href: "#/demofree/customer/my",
        isShow: this.roleList.some(function (role) {
          return [ERoleType.SalesOperation, ERoleType.Manager, ERoleType.PublicCustomer].includes(role);
        })
      }]
    }, {
      icon: "PF-shezhi",
      label: "客户续费",
      key: "recharge",
      href: "#/demofree/recharge",
      isShow: this.roleList.some(function (role) {
        return [ERoleType.CRM, ERoleType.Manager].includes(role);
      }),
      children: [{
        icon: "",
        label: "客户",
        key: PAGE_RECHARGE_LIST,
        href: "#/demofree/recharge/list",
        isShow: this.roleList.some(function (role) {
          return [ERoleType.CRM, ERoleType.Manager].includes(role);
        })
      }, {
        icon: "",
        label: "到期订单",
        key: PAGE_DUEDATE_ORDER,
        href: "#/demofree/recharge/order",
        isShow: this.roleList.some(function (role) {
          return [ERoleType.CRM, ERoleType.Manager].includes(role);
        })
      }]
    }, {
      icon: "setting",
      label: "人员管理",
      key: "management",
      href: "#/demofree/management",
      isShow: this.isManager,
      children: [{
        icon: "",
        label: "员工列表",
        key: PAGE_STAFF_ROLES_MANAGEMENT,
        href: "#/demofree/management",
        isShow: this.isManager
      }]
    }];
  }

  _createClass(DemoMenuData, [{
    key: "getMenus",
    value: function getMenus() {
      var menus = this.formateToTreeNodeData(this.menus);
      return menus;
    }
  }, {
    key: "formateToTreeNodeData",
    value: function formateToTreeNodeData(menus) {
      var treeNodes = [];

      for (var i = 0; i < menus.length; i += 1) {
        var menu = menus[i];
        var hasChildren = !!(menu.children && menu.children.length);
        var isLeaf = menu.isLeaf !== undefined ? menu.isLeaf : !hasChildren;
        var nodeType = menu.type;
        if (!nodeType) nodeType = !isLeaf ? _index.PARENT_MENU_NODE : _index.SUB_MENU_ITEM_NOE;

        if (menu.isShow) {
          treeNodes.push({
            key: "".concat(menu.key),
            title: menu.label,
            data: menu,
            isLeaf: isLeaf,
            children: this.formateToTreeNodeData(menu.children || []),
            nodeType: nodeType
          });
        }
      }

      return treeNodes;
    }
  }]);

  return DemoMenuData;
}();

exports["default"] = DemoMenuData;