@choerodon/master
Version:
A package of Master for Choerodon platform.
107 lines (86 loc) • 4.41 kB
JavaScript
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); }); }; }
import { get, has } from '@choerodon/inject';
import { historyPushMenu } from "../../../utils";
import HeaderStore from "../../stores/c7n/HeaderStore";
import MenuStore, { getMenuType } from "../../stores/c7n/MenuStore";
import findFirstLeafMenu from "./findFirstLeafMenu";
export default function handleClickProject(_x, _x2, _x3) {
return _handleClickProject.apply(this, arguments);
}
function _handleClickProject() {
_handleClickProject = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data, history, AppState) {
var _AppState$getUserInfo;
var id, name, organizationId, category, selfEmail, gotoProject;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
gotoProject = function _gotoProject() {
var isOwe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var type = 'project';
HeaderStore.setRecentItem(data); // @ts-ignore
MenuStore.loadMenuData({
type: type,
id: id
}, false, false).then(function (menus) {
var route = '';
var path;
var domain;
if (menus.length) {
var _findFirstLeafMenu = findFirstLeafMenu(menus[0]),
menuRoute = _findFirstLeafMenu.route,
menuDomain = _findFirstLeafMenu.domain; // 如果是欠费 默认跳转到知识库界面
if (isOwe) {
route = '/knowledge/project';
} else {
route = menuRoute;
}
domain = menuDomain;
if (menus[0].subMenus.length) {
MenuStore.setActiveMenu(menus[0].subMenus[0]);
MenuStore.setRootBaseOnActiveMenu();
}
}
path = "".concat(route, "?type=").concat(type, "&id=").concat(id, "&name=").concat(encodeURIComponent(name)).concat(category ? "&category=".concat(category) : '');
if (String(organizationId)) {
path += "&organizationId=".concat(organizationId);
}
if (path) {
// @ts-ignore
var t = getMenuType({
type: type,
id: id
}, false) || 'site';
if (t !== 'user') {
AppState.currentMenuType.type = t;
if (id) {
AppState.currentMenuType.id = id;
}
}
historyPushMenu(history, path, domain);
} // AppState.getProjects();
});
};
id = data.id, name = data.name, organizationId = data.organizationId, category = data.category;
selfEmail = (_AppState$getUserInfo = AppState.getUserInfo) === null || _AppState$getUserInfo === void 0 ? void 0 : _AppState$getUserInfo.email; // 如果是pro或者huawei
if (has('base-pro:preVerifyProject')) {
get('base-pro:preVerifyProject')(id, selfEmail, gotoProject);
} else if (has('base-huawei:preVerifyProject')) {
get('base-huawei:preVerifyProject')(id, selfEmail, gotoProject);
} else {
gotoProject();
}
/**
*
* @param isOwe 是否已欠费
*/
case 4:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _handleClickProject.apply(this, arguments);
}