import React from 'react'; import DefCustomPage from "./def-custom-page"; import {TmplInterface,ProgramConfig} from "../index"; import Units from "../units"; import withRouter from "../routable/withroute"; export interface CustomPageRouterProps extends TmplInterface.RouterCompProps { }; export interface CustomPageRouterStat { }; /** * 返回的对象是自定义页面的名称映射到对应的自定义页面对象 * 只有在这里定义后,对应的页面才可以被页面渲染 * 对象的key即自定义页面的名称 * value是自定义页面的对象类名(需要继承CustomPage类) */ // export const CUSTOM_PAGE_MAP = { // '/def' : DefCustomPage, // '/lab-overview':LabsOverview, // '/lab-courses':LabsCourses, // 'labroom001':LabWelcome, // } /** * 自定义页面的路径映射 */ class CustomPageRouter extends React.PureComponent { goBackToLtmpl=()=>{ const { sourceId,} = this.props.match.params; const {basePath}=this.props; let url=`${basePath?basePath+'/':""}/${sourceId}/act-table?menuId=${this.getMenuId()}`; let mainCode=this.getMainCode(); if(mainCode){ url=url+`&mainCode=${mainCode}`; } this.props.navigate(url); } getMainCode = () => { const {searchParams} = this.props; return searchParams.get("mainCode"); } getMenuId=()=>{ const {searchParams} = this.props; let menuId = searchParams.get('menuId'); return menuId; } render() { // console.log("CustomPageRouter",this.props); let pageName = this.props.params.pageName; let search = this.props.location.search; let criteriaData = Units.transQueryStrToParams(search,null); let Page = ProgramConfig.getCustomPage("/" + pageName) || DefCustomPage; return React.createElement(Page, {...this.props.params,goBack:this.goBackToLtmpl, ...criteriaData}); } } export default withRouter(CustomPageRouter);