salary-management-front/pc4mobx/hrmSalary/pages/mobilePayroll/index.js

77 lines
2.4 KiB
JavaScript

import React from "react";
import { inject, observer } from "mobx-react";
import { getQueryString } from "../../util/url";
import Authority from "../mySalary/authority";
import ComputerTemplate from "../payroll/templatePreview/computerTemplate";
import PhoneTemplate from "../payroll/templatePreview/phoneTemplate";
import "../payroll/templatePreview/index.less";
@inject("mySalaryStore")
@observer
export default class MobilePayroll extends React.Component {
constructor(props) {
super(props);
this.state= {
mySalaryBillData: {
employeeInformation: {}
}
};
this.id = "";
}
componentWillMount() {
this.id = getQueryString("id");
const { mySalaryStore: { init } } = this.props;
init();
this.getMySalaryBill(this.id);
}
getMySalaryBill = (id) => {
const { mySalaryStore: { getMySalaryBill } } = this.props;
getMySalaryBill(id).then(result => {
this.setState({
mySalaryBillData: result
})
})
}
render() {
const { mySalaryBillData }= this.state;
const type = getQueryString("type");
const employeeInformation = mySalaryBillData.employeeInformation ? mySalaryBillData.employeeInformation : {};
const salaryGroups = mySalaryBillData.salaryGroups ? mySalaryBillData.salaryGroups : [];
return (
<div className="computerTemplate" style={{
height: "100%",
overflowY: "hidden",
paddingBottom: "20px"
}}>
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
store={this.props.mySalaryStore}>
<div className="templatePreview">
<div className="contentWrapper">
{
type === "phone" ?
<PhoneTemplate
isPreview
isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/> :
<ComputerTemplate
isPreview
isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/>
}
</div>
</div>
</Authority>
</div>
);
}
}