import React from "react"; import { RouterCompProps, TtmplConfig, } from "../tmpl/interface"; import HCDataSource from "../tmpl/hc-data-source"; import withRouter from "../routable/withroute"; import ActTree from "../tree/act-tree"; import { Card, message } from "antd"; export interface TtmplRouteProps extends RouterCompProps { layoutRootPath?: string; treeTop?: number, } export interface TtmplRouteState { ttmplConfig?: TtmplConfig; } class TtmplRoute extends React.PureComponent { static defaultProps = { basePath: "", }; state = { ttmplConfig: undefined, }; async componentDidMount() { this.loadData(); } get computedLayoutPath() { const { layoutRootPath } = this.props; if (layoutRootPath !== undefined) return `/${layoutRootPath}`; return ""; } onRoute = (path) => { this.props.navigate(path); }; getMenuId = () => { const { searchParams } = this.props; let menuId = searchParams.get("menuId"); return menuId; }; getServerKey = () => { // 获取serverKey const { searchParams } = this.props; let serverKey = searchParams.get("serverKey"); return serverKey || null; }; loadData = async () => { const { params } = this.props; const { sourceId } = params; const serverKey = this.getServerKey(); let ttmplConfig: TtmplConfig = await HCDataSource.requestTtmplConfig(serverKey, sourceId); // debugger; if (ttmplConfig.type == "1M") {//此处待优化。不建议支持 message.error("不支持的配置树。请联系管理员!") // this.props.navigate( // `${this.computedLayoutPath}/${ttmplConfig.id}/act-table` // ); } else { this.setState({ ttmplConfig: { ...ttmplConfig }, }); } }; async componentDidUpdate(prevProps) { const { location, params } = this.props; const { sourceId } = params; let { sourceId: preSourceId } = prevProps.params; if (sourceId && preSourceId && sourceId == preSourceId) { return; } await this.loadData(); } render() { const { treeTop } = this.props; const { ttmplConfig } = this.state; const serverKey = this.getServerKey(); if (!ttmplConfig) { return ; } else { return ( <> ); } } } export default withRouter(TtmplRoute);