import React, { Component } from "react"; import { inject, observer } from "mobx-react"; import Authority from "../../mySalary/authority"; import { salaryacctAcctresultCheckAuth } from "../../../apis/calculate"; @inject("taxAgentStore") @observer class Layout extends Component { constructor(props) { super(props); this.state = { store: { loading: false, hasRight: false } }; } componentDidMount() { this.salaryacctAcctresultCheckAuth(); } salaryacctAcctresultCheckAuth = () => { const { taxAgentStore: { getPermission } } = this.props; this.setState({ store: { ...this.state.store, loading: true } }); getPermission().then(({ data }) => { const { isOpenDevolution } = data; if (isOpenDevolution) { const { routeParams: { salaryAcctRecordId } } = this.props; salaryacctAcctresultCheckAuth({ salaryAcctRecordId }).then(({ status, data }) => { this.setState({ store: { ...this.state.store, loading: false, hasRight: status && data } }); }); } else { this.setState({ store: { ...this.state.store, loading: false, hasRight: true } }); } }).catch(() => this.setState({ store: { ...this.state.store, loading: false } })); }; render() { return ( {this.props.children} ); } } export default Layout;