class PageOfficUtil { /** * @Description: 转义中文编码(url可识别的参数) * @author zhuguangkui * @param {string} url * @param {Map} parameterMap * @returns {string} * @date * @time */ escapeChineseEncoding(url: string, parameterMap?: Map): string { /*id?:string*/ if (parameterMap) { url = this.getParameterOfUrl(url, parameterMap); } return encodeURI(encodeURI(url)); } /** * @Description: 将参数拼接至url后面 * @author zhuguangkui * @param {string} url * @param {Map} parameterMap * @returns {string} * @date * @time */ getParameterOfUrl(url: string, parameterMap?: Map): string { let connectiveSymbol = ""; if (url.indexOf("?") !== -1) { connectiveSymbol = "&"; } else { connectiveSymbol = "?"; } if (parameterMap) { let mark = 0; parameterMap.forEach(function (val, key) { if (mark === 0) { if (val != null && val !== "null" && val !== "undefined") { url += connectiveSymbol + key + "=" + val; } else { url += connectiveSymbol + key + "="; } } else { if (val != null && val !== "null" && val !== "undefined") { url += "&" + key + "=" + val; } else { url += "&" + key + "="; } } mark++; }); } return url; } /** * @Description: 请求后端pageOffice,发起POBroswer请求 * @author zhuguangkui * @param {string} url * @param map * @date * @time */ openPageOfficePage(url: string, map?: string) { const a = document.createElement("a"); if (!map) { a.href = "javascript:POBrowser.openWindowModeless('" + url + "' ,'width=1100px;height=800px;');"; } else { a.href = "javascript:POBrowser.openWindowModeless('" + url + "' ,'width=1100px;height=800px;' ,'" + map + "');"; } a.target = "_self"; const e = document.createEvent("MouseEvents"); e.initEvent("click", true, true); a.dispatchEvent(e); } } const pageOfficUtil = new PageOfficUtil(); export default pageOfficUtil;