47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
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 (
|
|
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
|
|
store={{ ...this.state.store }}>
|
|
{this.props.children}
|
|
</Authority>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Layout;
|