"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"] = void 0;

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

var _Filter = _interopRequireDefault(require("./Filter"));

var _Item = _interopRequireDefault(require("./Item"));

var _styledComponents = require("./styledComponents");

var _requestV = require("../../utils/request-v1");

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

var _pop = _interopRequireDefault(require("../../components-v1/pop"));

var _constant = require("./constant");

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

var _tools = require("../../utils/tools");

require("./index.css");

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; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

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; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

var pageSize = 20;

function parseUser(toUser) {
  if (!toUser || JSON.stringify(toUser) === '{}') return {};
  return {
    Name: toUser.name,
    Id: toUser.userId,
    DepartmentId: 0,
    Email: toUser.email,
    UserAvatar: toUser.avatar,
    Department: ''
  };
} // ChangeOKR 是伴随父组件的出现而出现的， 构造阶段就已经有所有的数据


var ChangeOkr = /*#__PURE__*/function (_PureComponent) {
  _inherits(ChangeOkr, _PureComponent);

  var _super = _createSuper(ChangeOkr);

  // 切换对齐目标弹层 40011
  // 关联对齐目标弹层 40001
  function ChangeOkr(p) {
    var _this;

    _classCallCheck(this, ChangeOkr);

    _this = _super.call(this, p);

    _initialiseProps.call(_assertThisInitialized(_this));

    var toUser = p.toUser;
    var user = parseUser(toUser); // 从这里放数据 关键是也没有啊

    _this.state = {
      year: null,
      status: null,
      cycle: null,
      type: null,
      users: JSON.stringify(user) === '{}' ? [] : [user],
      // 构造之后这里还是空的
      departments: [],
      data: [],
      keywords: '',
      loadingMore: false,
      isEnd: false,
      nextPage: 1,
      selected: undefined,
      remembered: true,
      // 点击记住选择 刷新页面后 首次加载这里应该是记住选择
      selectOkr: {},
      toUserId: (0, _bsGlobal.getUserInfo)().Id // 当前操作人

    }; // this.props.eventBridge.trigger('filterUsersChange',JSON.parse(JSON.stringify([user])))

    return _this;
  }

  _createClass(ChangeOkr, [{
    key: "componentDidUpdate",
    value: function componentDidUpdate(p) {
      if (p.toUser.userId != this.props.toUser.userId) {
        var toUser = this.props.toUser;
        var user = parseUser(toUser);
        this.setState({
          users: [user],
          data: [],
          keywords: ''
        });
      }
    }
  }, {
    key: "getCondition",
    value: function getCondition() {
      var _this2 = this;

      var toUser = this.props.toUser;
      var user = parseUser(toUser); // 从这里放数据 关键是也没有啊
      // 首次加载的时候 需要把 cycle 通过 cycleType 与 yqmNum 合并出来

      var url = (0, _requestV.getApiUrl)("customizequery/condition/get?dataKey=".concat(this.DATA_KEY, "&pageId=").concat(this.PAGE_ID));
      (0, _requestV.taker)(url, 'GET').then(function (res) {
        // condition 设置完筛选条件 然后再调用 getData()
        if (res.Code === 1) {
          var _res$Data = res.Data,
              cycleType = _res$Data.cycleType,
              yqmNum = _res$Data.yqmNum,
              annualNum = _res$Data.annualNum,
              status = _res$Data.status,
              users = _res$Data.users;
          var okrType = res.Data.okrType;
          var cycle;
          cycleType || '';

          if (cycleType === 1 || cycleType === -1) {
            cycle = "".concat(cycleType);
          } else {
            cycle = cycleType ? "".concat(cycleType, ",").concat(yqmNum) : null;
          }

          var year = annualNum || null; // status = status || 0;

          okrType = okrType === undefined ? null : okrType;

          if (!_this2.KRSetting.OkrTypeSetting) {
            okrType = null;
          }

          if (!users || !users.length) {
            _this2.setState({
              cycle: cycle,
              year: year,
              status: status,
              type: okrType,
              users: JSON.stringify(user) === '{}' ? [] : [user],
              keywords: '',
              nextPage: 1
            }, function () {
              return _this2.getListData();
            });
          } else {
            _this2.setState({
              cycle: cycle,
              year: year,
              status: status,
              type: okrType,
              users: _toConsumableArray(users).map(function (_ref) {
                var email = _ref.email,
                    id = _ref.id,
                    name = _ref.name;
                return {
                  Name: name,
                  Id: id,
                  DepartmentId: 0,
                  Email: email,
                  Department: '',
                  UserAvatar: '',
                  keywords: '',
                  nextPage: 1
                };
              })
            }, function () {
              return _this2.getListData();
            });
          }
        }
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;

      var _this$state = this.state,
          year = _this$state.year,
          cycle = _this$state.cycle,
          status = _this$state.status,
          type = _this$state.type,
          users = _this$state.users,
          data = _this$state.data,
          selected = _this$state.selected,
          loadingMore = _this$state.loadingMore,
          isEnd = _this$state.isEnd,
          departments = _this$state.departments,
          keywords = _this$state.keywords,
          remembered = _this$state.remembered; // container

      var _this$props = this.props,
          className = _this$props.className,
          okrPopType = _this$props.okrPopType,
          parentId = _this$props.parentId,
          hideCancelBtn = _this$props.hideCancelBtn,
          alilgn = _this$props.alilgn,
          autoAdjust = _this$props.autoAdjust;
      var activeItem = selected || {
        workId: parentId
      };

      if (activeItem.mileStoneId) {
        activeItem.workId = 0;
      }

      return /*#__PURE__*/_react["default"].createElement(_pop["default"], {
        ref: function ref(r) {
          return _this3.pop = r;
        },
        align: alilgn,
        autoAdjust: autoAdjust,
        onBeforeShow: this.onBeforeShow,
        onAfterShow: this.onAfterShow,
        onBeforeHide: this.onBeforeShow,
        cover: true,
        className: "okr-panel-changeOkrPop ".concat(className) // transitionName='okr-panel-changeOkrPop'
        // container={container ? container : document.querySelector('.pg-tmpl-honour-scroll')}

      }, /*#__PURE__*/_react["default"].createElement(_styledComponents.Wrapper, {
        okrPopType: okrPopType
      }, /*#__PURE__*/_react["default"].createElement(_styledComponents.Header, null, (0, _constant.getPopType)()[okrPopType], /*#__PURE__*/_react["default"].createElement("i", {
        className: "tu-icon-close",
        style: {
          cursor: 'pointer'
        },
        onClick: this.hide
      })), /*#__PURE__*/_react["default"].createElement(_styledComponents.Body, null, /*#__PURE__*/_react["default"].createElement(_Filter["default"], {
        year: year,
        departments: departments,
        status: status // @ts-ignore
        ,
        cycle: cycle,
        okrPopType: okrPopType,
        type: type,
        users: users,
        remembered: remembered,
        onChange: this.handleFilterChange,
        onUserChange: this.handleAddFilterUsers
      }), /*#__PURE__*/_react["default"].createElement(_styledComponents.List, {
        ref: function ref(r) {
          return _this3.list = r;
        }
      }, data.map(function (d) {
        return /*#__PURE__*/_react["default"].createElement(_Item["default"], {
          data: d,
          keywords: keywords,
          active: activeItem,
          onSelect: function onSelect(data) {
            return _this3.handleSelect(data);
          },
          isShowKr: okrPopType === 1
        });
      }), !!data.length && !isEnd && /*#__PURE__*/_react["default"].createElement(_styledComponents.LoadMore, null, /*#__PURE__*/_react["default"].createElement("a", {
        onClick: function onClick() {
          return _this3.getListData(true);
        }
      }, loadingMore ? "".concat((0, _getLocale.getLocale)('Mod_loading'), "\u2026") : (0, _getLocale.getLocale)('OKR_MyO_Butt_Loadmore'), /*#__PURE__*/_react["default"].createElement("i", {
        className: "tu-icon-arrow-down"
      }))), !!data.length && isEnd && /*#__PURE__*/_react["default"].createElement(_styledComponents.NoMore, null, (0, _getLocale.getLocale)('Mod_Nomore'), "\uFF5E"))), /*#__PURE__*/_react["default"].createElement(_styledComponents.Footer, null, okrPopType === 1 && parentId !== 0 && !hideCancelBtn && /*#__PURE__*/_react["default"].createElement(_styledComponents.Button, {
        type: "confirm",
        onClick: this.handleUnConnect
      }, (0, _getLocale.getLocale)('OKR_MyO_Text_Cancel')), /*#__PURE__*/_react["default"].createElement(_styledComponents.ButtonGroup, null, /*#__PURE__*/_react["default"].createElement(_styledComponents.Button, {
        onClick: this.hide
      }, (0, _getLocale.getLocale)('Mod_Cancel')), /*#__PURE__*/_react["default"].createElement(_styledComponents.Button, {
        style: {
          marginLeft: 15
        },
        disabled: !selected && parentId === 0,
        type: "confirm",
        onClick: this.handleConfirm
      }, (0, _getLocale.getLocale)('OKR_MyO_Butt_Determine'))))));
    }
  }]);

  return ChangeOkr;
}(_react.PureComponent);

exports["default"] = ChangeOkr;
ChangeOkr.defaultProps = {
  parentId: 0
};

var _initialiseProps = function _initialiseProps() {
  var _this4 = this;

  this.PAGE_ID = this.props.okrPopType === 1 ? 40001 : 40011;
  this.DATA_KEY = "62_".concat((0, _bsGlobal.getUserInfo)().Id);
  this.KRSetting = (0, _bsGlobal.getBSGlobal)('OkrAdvancedSetting').KRSetting;
  this.page = 1;
  this.moveX = 0;
  this.pending = false;

  this.show = function (node, moveX) {
    _this4.moveX = moveX;

    _this4.pop.show(node);

    _this4.getCondition(); // if (this.props.okrPopType == 1) {
    // }

  };

  this.hide = function () {
    var _this4$props = _this4.props,
        parentId = _this4$props.parentId,
        okrPopType = _this4$props.okrPopType;

    if (parentId === 0 && okrPopType === 1) {
      _this4.setState({
        selected: undefined
      });
    }

    if (okrPopType === 1) {
      _this4.setState({
        keywords: '',
        nextPage: 1
      });
    }

    _this4.pop.hide();
  };

  this.handleAddFilterUsers = function (u, d) {
    _this4.setState({
      users: u,
      departments: d,
      nextPage: 1
    }, _this4.getListData);

    _this4.setState({
      remembered: false
    });
  };

  this.onBeforeShow = function () {
    var p = document.querySelector('.okr-panel-changeOkrPop'); // @ts-ignore

    p && (p.style.transform = "translate(".concat(_this4.moveX, "px,-20px) scale(0)"));
  };

  this.onAfterShow = function () {
    var p = document.querySelector('.okr-panel-changeOkrPop'); // @ts-ignore

    p && (p.style.transform = 'translate(0,0) scale(1)');
  };

  this.handleFilterChange = function (propName, value) {
    var _this4$setState;

    if (propName === 'clear') {
      _this4.setState({
        users: [],
        departments: [],
        nextPage: 1,
        year: null,
        status: null,
        cycle: null,
        type: null,
        remembered: false
      }, function () {
        _this4.getListData();
      });

      return;
    }

    _this4.setState((_this4$setState = {}, _defineProperty(_this4$setState, propName, value), _defineProperty(_this4$setState, "nextPage", 1), _defineProperty(_this4$setState, "remembered", false), _this4$setState), _this4.getListData);

    if (propName === 'remembered' && value) {
      _this4.setState(_defineProperty({}, propName, value));

      _this4.saveCondition(_this4.state.users, _this4.state.departments);

      return;
    }

    if (propName === 'remembered' && !value) {
      _this4.setState(_defineProperty({}, propName, value));

      _this4.deleteCondition();
    }
  };

  this.saveCondition = function (users, depts) {
    var url = (0, _requestV.getApiUrl)('customizequery/condition/save');
    var departmentIdsArr = depts.map(function (item) {
      return item.Id;
    });
    var _this4$state = _this4.state,
        year = _this4$state.year,
        cycle = _this4$state.cycle,
        status = _this4$state.status,
        type = _this4$state.type;
    var data = {
      dataKey: _this4.DATA_KEY,
      // 用户ID_项目ID_里程碑ID
      pageId: _this4.PAGE_ID,
      //	列表页Id
      startTime: '',
      // 开始时间
      endTime: '',
      //	结束时间
      departmentIds: departmentIdsArr.join(','),
      //	部门id
      userObjects: [{
        Id: '',
        Name: '',
        Email: '',
        Relation: 0
      }],
      // 用户id
      scope: '',
      //范围
      categoryIds: '',
      // 分类
      sortType: '',
      // 排序
      annualNum: year,
      // 0 -1 undefined 1999
      status: status,
      okrType: type,
      cycleType: cycle ? "".concat(cycle).split(',')[0] : null,
      yqmNum: cycle ? "".concat(cycle).split(',')[1] : null
    };
    data.userObjects = [];
    users.forEach(function (item) {
      data.userObjects.push({
        Id: "".concat(item.Id),
        Name: item.Name,
        Email: item.Email,
        Relation: 0
      });
    });
    (0, _requestV.taker)(url, 'POST', data);
  };

  this.deleteCondition = function () {
    var url = (0, _requestV.getApiUrl)("customizequery/condition/delete?dataKey=".concat(_this4.DATA_KEY, "&pageId=").concat(_this4.PAGE_ID));
    (0, _requestV.taker)(url, 'DELETE', {});
  };

  this.scollListToTop = function () {
    if (_this4.list) {
      _this4.list.scrollTop = 0;
    }
  };

  this.getListData = /*#__PURE__*/function () {
    var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(isLoading) {
      var _this4$state2, keywords, type, users, departments, data, nextPage, toUserId, _this4$state3, status, cycle, year, _this4$props2, okrPopType, _this4$props2$include, includeCreateFailApprovalOkr, url;

      return regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              if (!_this4.pending) {
                _context.next = 2;
                break;
              }

              return _context.abrupt("return");

            case 2:
              _this4$state2 = _this4.state, keywords = _this4$state2.keywords, type = _this4$state2.type, users = _this4$state2.users, departments = _this4$state2.departments, data = _this4$state2.data, nextPage = _this4$state2.nextPage, toUserId = _this4$state2.toUserId;
              _this4$state3 = _this4.state, status = _this4$state3.status, cycle = _this4$state3.cycle, year = _this4$state3.year;
              _this4$props2 = _this4.props, okrPopType = _this4$props2.okrPopType, _this4$props2$include = _this4$props2.includeCreateFailApprovalOkr, includeCreateFailApprovalOkr = _this4$props2$include === void 0 ? false : _this4$props2$include;
              cycle = cycle || '-1';
              year = year || -1;
              status = status || 0;
              url = (0, _requestV.getApiUrl)('okr/search');
              _this4.pending = true;

              if (isLoading) {
                _this4.page++;

                _this4.setState({
                  loadingMore: true
                });
              } else {
                _this4.page = 1;
              }

              (0, _requestV.taker)(url, 'POST', {
                // 优秀！

                /**
                 * pageNum: 0
                 * pageSize: 20
                 */
                cycleType: "".concat(cycle).split(',')[0],
                yqmNum: "".concat(cycle).split(',')[1] || 0,
                // 如果是 undefined 就控制成 0 说明没有第二条件
                annualNum: year,
                pageNum: nextPage === 0 ? 1 : _this4.page,
                // pageNum 最小是1
                pageSize: pageSize,
                status: status,
                keywords: keywords,
                okrType: type === -1 ? '' : type,
                orderType: 1,
                // 13:按人员排序 1按照创建时间最晚排序
                departmentIds: departments.map(function (d) {
                  return d.Id;
                }).join(','),
                userIds: users.map(function (u) {
                  return u.Id;
                }).join(','),
                searchKr: okrPopType,
                // 是否搜索KR：默认为0-不搜索，1-只有对齐目标弹层可以搜索KR
                toUserId: toUserId,
                includeCreateFailApprovalOkr: includeCreateFailApprovalOkr
              }).then(function (res) {
                _this4.pending = false;
                var resData = res && res.Data && res.Data.works || [];
                var isRefresh = _this4.page === 1;

                _this4.setState({
                  nextPage: res.Data.nextPage,
                  loadingMore: false,
                  data: isRefresh ? resData : [].concat(_toConsumableArray(data), _toConsumableArray(resData)),
                  isEnd: res.Data.nextPage === 0
                }, function () {
                  // console.log(this.state.data)
                  if (isRefresh) {
                    _this4.scollListToTop();
                  }
                });
              })["catch"](function () {
                _this4.pending = false;
                var loadingMore = _this4.state.loadingMore;

                if (loadingMore) {
                  _this4.setState({
                    loadingMore: false
                  });
                }
              });

            case 12:
            case "end":
              return _context.stop();
          }
        }
      }, _callee);
    }));

    return function (_x) {
      return _ref2.apply(this, arguments);
    };
  }();

  this.handleSelect = function (data) {
    // @ts-ignore
    var selectData = data.selectData,
        okrInfo = data.okrInfo;
    var selected = _this4.state.selected;

    if (selectData.mileStoneId) {
      selectData.workIdCopy = selectData.workId;
      selectData.workId = 0;
    }

    if (selected && (selectData.workId && selected.workId && selectData.workId === selected.workId || selectData.mileStoneId && selected.mileStoneId && selectData.mileStoneId === selected.mileStoneId)) return;

    _this4.setState({
      selected: selectData,
      selectOkr: okrInfo
    });
  };

  this.handleConfirm = function () {
    var _this4$state4 = _this4.state,
        selected = _this4$state4.selected,
        selectOkr = _this4$state4.selectOkr;
    var _this4$props3 = _this4.props,
        onConfirm = _this4$props3.onConfirm,
        parentId = _this4$props3.parentId;
    var parentType = selected && selected.mileStoneId ? 2 : 1; // 临时注入

    var data = _objectSpread(_objectSpread({}, selected), {}, {
      _okrInfo: selectOkr
    }); // _okrInfo 为选中O信息，如果当前选中的是kr，okrinfo 则为kr所属的O


    data.parentType = parentType;
    data.workName = (0, _tools.htmlToText)(data.workName);

    if (selected && (selected.workId || selected.mileStoneId) !== parentId) {
      onConfirm(data);
    }

    _this4.hide();
  };

  this.handleUnConnect = function () {
    var onConfirm = _this4.props.onConfirm; // 取消关联对齐目标

    onConfirm({
      workId: 0,
      workName: '',
      mileStoneId: 0,
      mileStoneName: '',
      parentType: 0
    });

    _this4.setState({
      selected: {
        workId: 0,
        workName: ''
      }
    });

    _this4.hide();
  };
};