"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _table = _interopRequireDefault(require("../components/table"));

require("./index.css");

var _openData = require("../../../utils/open-data");

var _groupInterface = require("../groupInterface");

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

var _reactTooltip = _interopRequireDefault(require("react-tooltip"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var preCls = "user-group-page";

function _default(props) {
  var tableData = props.tableData,
      pageNum = props.pageNum,
      setPageNum = props.setPageNum,
      total = props.total,
      rowSelected = props.rowSelected,
      setRowSelected = props.setRowSelected;

  var _getUrl = function _getUrl(userId) {
    return "//".concat(window.location.host, "/").concat((0, _groupInterface.getUserInfo)().Id, "/indexV2?toUserId=").concat(userId, "#/EmployeeInfo");
  };

  var columns = [{
    title: (0, _getLocale.getLocale)("Mod_UserName"),
    dataIndex: "name",
    key: "name",
    render: function render(text, data) {
      return /*#__PURE__*/_react["default"].createElement("span", {
        className: (0, _classnames["default"])("".concat(preCls, "__name-td"))
      }, /*#__PURE__*/_react["default"].createElement("a", {
        href: _getUrl(data.id),
        target: (0, _groupInterface.isWx)() ? "_blank" : "",
        rel: "noreferrer"
      }, /*#__PURE__*/_react["default"].createElement(_openData.OpenUserName, {
        id: data.id,
        name: data.name
      })), data.profile ? /*#__PURE__*/_react["default"].createElement("span", null, "(", data.profile, ")") : undefined);
    }
  }, {
    title: "手机号",
    dataIndex: "mobile",
    key: "mobile"
  }, {
    title: "邮箱",
    dataIndex: "email",
    key: "email",
    render: function render(text, data) {
      return /*#__PURE__*/_react["default"].createElement("span", {
        className: (0, _classnames["default"])("".concat(preCls, "__email-td"))
      }, /*#__PURE__*/_react["default"].createElement("span", {
        "data-tip": text,
        "data-effect": "solid"
      }, text), /*#__PURE__*/_react["default"].createElement(_reactTooltip["default"], null));
    }
  }, {
    title: (0, _getLocale.getLocale)("Mod_Department"),
    dataIndex: "departmentName",
    key: "departmentName",
    render: function render(text, data) {
      return /*#__PURE__*/_react["default"].createElement(_openData.OpenDepartmentName, {
        id: data.departmentId,
        name: data.departmentName
      });
    }
  }];
  if (!tableData || !tableData.length) return /*#__PURE__*/_react["default"].createElement("span", null);
  var rowSelection = {
    rowSelected: rowSelected,
    setRowSelected: setRowSelected
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__table"))
  }, /*#__PURE__*/_react["default"].createElement(_table["default"], {
    columns: columns,
    tableData: tableData,
    pageNum: pageNum,
    setPageNum: setPageNum,
    total: total,
    rowSelection: rowSelection
  }));
}