"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.lableTypeMap = exports.isOpenWorkManage = exports.isOpenOkrManage = exports.isOpenLabel = exports.formatDateStr = void 0;
exports.momentDate = momentDate;
exports.workStatus = exports.timeFormat = exports.preCls = exports.okrStatus = void 0;

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

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

var preCls = 'titaui-task-relation';
exports.preCls = preCls;
var isOpenOkrManage = (0, _bsGlobal.getAppHead)('113'); // 开通OKR

exports.isOpenOkrManage = isOpenOkrManage;
var isOpenWorkManage = (0, _bsGlobal.getAppHead)('112'); // 开通项目

exports.isOpenWorkManage = isOpenWorkManage;
var TaskAdvancedSetting = (0, _bsGlobal.getBSGlobal)('TaskAdvancedSetting');
var isOpenLabel = TaskAdvancedSetting === null || TaskAdvancedSetting === void 0 ? void 0 : TaskAdvancedSetting.TaskPlanSetting.TaskLabel; // 开启分类

exports.isOpenLabel = isOpenLabel;
var lableTypeMap = {
  // 分类的类型（4：项目 17：普通分类 62:目标
  okr: 62,
  kr: 62,
  work: 4,
  milestone: 4,
  lable: 17
};
exports.lableTypeMap = lableTypeMap;

var strFormat = function strFormat(num) {
  if (num < 10) {
    return '0' + num;
  }

  return num;
};

var timeFormat = function timeFormat(NowDate) {
  var date = new Date(NowDate);
  var y = date.getFullYear(); // 年

  var m = date.getMonth() + 1; // 月

  var d = date.getDate(); // 日

  return "".concat(y, "/").concat(strFormat(m), "/").concat(strFormat(d));
};

exports.timeFormat = timeFormat;

var formatDateStr = function formatDateStr(str) {
  str = timeFormat(str);
  var currentYear = new Date().getFullYear();

  if (str.indexOf(currentYear) !== -1) {
    return str.substr(5);
  }

  return str;
};

exports.formatDateStr = formatDateStr;

var okrStatus = function okrStatus(key) {
  // 分类的类型（4：项目 17：普通分类 62:目标
  var label = (0, _getLocale.getLocale)('OKR_MyO_E_From_AllStates');

  switch (Number(key)) {
    case 1:
      label = (0, _getLocale.getLocale)('Per_MyRe_text_Inprogress');
      break;

    case 2:
      label = (0, _getLocale.getLocale)('Pro_page_Sta_Completed');
      break;

    case 3:
      label = (0, _getLocale.getLocale)('OKR_MyO_E_From_Delayed');
      break;

    case 4:
      label = (0, _getLocale.getLocale)('OKR_MyO_E_From_Cancelled');
      break;

    case 5:
      label = (0, _getLocale.getLocale)('OKR_MyO_E_From_Notaccepted');
      break;

    case 6:
      label = (0, _getLocale.getLocale)('OKR_MyO_E_From_Suspended');
      break;

    case 0:
      label = (0, _getLocale.getLocale)('OKR_MyO_E_From_NotStarted');
      break;

    default:
      break;
  }

  return label;
};

exports.okrStatus = okrStatus;

var workStatus = function workStatus() {
  return {
    1: (0, _getLocale.getLocale)('Per_MyRe_text_Inprogress'),
    2: (0, _getLocale.getLocale)('OKR_MyO_E_From_Completed')
  };
};

exports.workStatus = workStatus;

function momentDate(date) {
  var reg = new RegExp('年|月|日', 'g');
  return date.replace(reg, '/').slice(0, -1);
}