package yem.base.common.utils;

import kd.bos.form.IFormView;

import java.util.HashMap;
import java.util.Map;

/**
 * 应用层跳转工具类
 *
 * @description:
 * @author: longh
 * @date: 2021年6月26日上午11:46:54
 */
public class PopAppUtil {

    public static void activatePage(String pageID, IFormView view, Map<String, Object> map) {
        IFormView childView = view.getViewNoPlugin(pageID);
        if ("bos".equals(childView.getFormShowParameter().getServiceAppId())) {
            childView = view.getView(pageID);
        }
        if (childView != null) {
            if (!view.getPageId().equalsIgnoreCase(childView.getPageId())) {
                Map<String, Object> customparameters = (HashMap) map.get("customparameters");
                childView.getFormShowParameter().getCustomParams().remove("messageId");
                childView.getFormShowParameter().getCustomParams().remove("tabType");
                childView.getFormShowParameter().getCustomParams().remove("openPage");
                if (customparameters != null) {
                    if (customparameters.get("messageId") != null) {
                        childView.getFormShowParameter().setCustomParam("messageId", customparameters.get("messageId"));
                    }

                    if (customparameters.get("tabType") != null) {
                        childView.getFormShowParameter().setCustomParam("tabType", customparameters.get("tabType"));
                    }

                    if (customparameters.get("openPage") != null) {
                        childView.getFormShowParameter().setCustomParam("openPage", customparameters.get("openPage"));
                    }
                }

                childView.getFormShowParameter().setHasRight(true);
                childView.activate();
                if ("bos".equals(childView.getFormShowParameter().getServiceAppId())) {
                    childView.updateView();
                }

                view.sendFormAction(childView);
            }
        } else {
            view.showTipNotification("系统已超时，请重新刷新登录!");
        }
    }

}
