产品-工资单发放查看页面空白的问题处理

This commit is contained in:
黎永顺 2023-06-29 14:59:24 +08:00
parent a56b2ffd70
commit dc27a3e491
5 changed files with 39 additions and 32 deletions

View File

@ -33,11 +33,10 @@ export default class MobilePayroll extends React.Component {
const type = getQueryString("type");
this.id = getQueryString("id");
const { mySalaryStore: { init } } = this.props;
this.getMySalaryBill(this.id);
const { data, status } = await payrollCheckType();
if (type !== "phone") {
if (status && data === "PWD") {
init(false);
init(false, () => this.getMySalaryBill(this.id));
} else {
this.setState({ captchaVisible: true });
}
@ -48,13 +47,14 @@ export default class MobilePayroll extends React.Component {
initMobile = () => {
const { mySalaryStore: { setInitEmVerify } } = this.props;
// if (window.em) {
API.isNeedSecondPwdVerify({ mouldCode: "HRM", itemCode: "SALARY" }).then(({ status, isNeedSecondAuth }) => {
if (status && isNeedSecondAuth) {
this.setState({ visible: true });
} else {
setInitEmVerify();
}
});
API.isNeedSecondPwdVerify({ mouldCode: "HRM", itemCode: "SALARY" }).then(({ status, isNeedSecondAuth }) => {
if (status && isNeedSecondAuth) {
this.setState({ visible: true });
} else {
this.getMySalaryBill(getQueryString("id"));
setInitEmVerify();
}
});
// } else {
// setInitEmVerify();
// }
@ -72,6 +72,7 @@ export default class MobilePayroll extends React.Component {
message.success(checkMsg);
setInitEmVerify();
this.setState({ visible: false });
this.getMySalaryBill(getQueryString("id"));
} else {
message.error(checkMsg);
}
@ -136,7 +137,6 @@ export default class MobilePayroll extends React.Component {
<div className="contentWrapper">
<PhoneTemplate
isPreview
isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/>
@ -150,7 +150,6 @@ export default class MobilePayroll extends React.Component {
<div className="contentWrapper">
<ComputerTemplate
isPreview
isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : JSON.stringify([])}
/>

View File

@ -6,7 +6,6 @@
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import Authority from "./authority";
import ComputerTemplate from "../payroll/templatePreview/computerTemplate";
import { payrollCheckType } from "../../apis/payroll";
@ -19,35 +18,43 @@ class MySalaryView extends Component {
constructor(props) {
super(props);
this.state = {
captchaVisible: false
captchaVisible: false,
mySalaryStore: {}
};
}
async componentDidMount() {
const { mySalaryStore: { getMySalaryBill, init }, params: { salaryInfoId } } = this.props;
const { mySalaryStore: { init, getMySalaryBill }, params: { salaryInfoId } } = this.props;
const { data, status } = await payrollCheckType();
if (status && data === "PWD") {
init(false);
init(false, () => {
getMySalaryBill(Number(salaryInfoId)).then(data => {
this.setState({ mySalaryStore: data });
});
});
} else {
this.setState({ captchaVisible: true });
}
getMySalaryBill(Number(salaryInfoId));
}
render() {
const { captchaVisible } = this.state;
const { mySalaryStore, params: { salaryInfoId } } = this.props;
const { mySalaryBill } = mySalaryStore;
const employeeInformation = mySalaryBill.employeeInformation && toJS(mySalaryBill.employeeInformation);
const salaryGroups = mySalaryBill.salaryGroups && toJS(mySalaryBill.salaryGroups);
const { captchaVisible, mySalaryStore } = this.state;
const { params: { salaryInfoId } } = this.props;
if (_.isEmpty(mySalaryStore)) {
return <div></div>;
}
const employeeInformation = !_.isEmpty(mySalaryStore) && mySalaryStore.employeeInformation;
const salaryGroups = !_.isEmpty(mySalaryStore) && mySalaryStore.salaryGroups;
const salaryTemplateShowSet = !_.isEmpty(mySalaryStore) && mySalaryStore.salaryTemplate;
return (
<React.Fragment>
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`} store={mySalaryStore}>
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
store={this.props.mySalaryStore}>
<div style={{ height: "100%", overflow: "auto" }}>
<div className="templatePreview">
<ComputerTemplate
isPreview isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBill.salaryTemplate)}
salaryTemplateShowSet={salaryTemplateShowSet ? JSON.stringify(salaryTemplateShowSet) : []}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/>
</div>

View File

@ -31,7 +31,7 @@ export default class ComputerTemplate extends React.Component {
}
componentDidMount() {
if(this.props.isMsgPreview && this.props.salaryItemSet){
if (this.props.isMsgPreview && this.props.salaryItemSet) {
this.setState({
salaryItemSet: JSON.parse(this.props.salaryItemSet),
salaryTemplateShowSet: JSON.parse(this.props.salaryTemplateShowSet)
@ -55,7 +55,7 @@ export default class ComputerTemplate extends React.Component {
const rowNum = 3;
const sumRows = len % rowNum;
const sumRowMod = len / rowNum;
const rows = (sumRows == 0 ? sumRowMod : sumRowMod + 1);
const rows = (sumRows == 0 ? sumRowMod : parseInt(sumRowMod.toString()) + 1);
for (let j = 0; j < rows; j++) {
let iLen = (j + 1) * rowNum;
iLen = iLen > len ? len : iLen;
@ -86,7 +86,7 @@ export default class ComputerTemplate extends React.Component {
<div className="sobItemDiv" style={{ margin: "20px 10px" }}>
{
salaryTemplateShowSet.textContentPosition === "1" && salaryTemplateShowSet.textContent
salaryTemplateShowSet.textContentPosition == 1 && salaryTemplateShowSet.textContent
}
</div>
@ -106,7 +106,7 @@ export default class ComputerTemplate extends React.Component {
</div>
<div style={{ margin: "20px 10px" }}>
{
salaryTemplateShowSet.textContentPosition === "2" && salaryTemplateShowSet.textContent
salaryTemplateShowSet.textContentPosition == 2 && salaryTemplateShowSet.textContent
}
</div>
</div>

View File

@ -33,7 +33,7 @@ export default class PhoneTemplate extends React.Component {
}
componentDidMount() {
// && window.em
// && window.em
if (this.props.isMsgPreview && this.props.salaryItemSet) {
this.setState({
salaryItemSet: JSON.parse(this.props.salaryItemSet),

View File

@ -49,29 +49,30 @@ export class MySalaryStore {
@action setMySalaryBill = (mySalaryBill) => {
this.mySalaryBill = mySalaryBill;
};
@action init = async (isRoot = true) => {
@action init = async (isRoot = true, callback) => {
this.clear();
//1.check is need second verify
if (window.doCheckSecondaryVerify4ec) {
window.doCheckSecondaryVerify4ec({ mouldCode: "HRM", itemCode: "SALARY" }, (data) => this.getData({
...data,
isRoot
isRoot, callback
}));
} else {
//4.loaddata
this.getData({ status: "1", token: "", isRoot });
this.getData({ status: "1", token: "", isRoot, callback });
}
};
@action
getData = async (params = {}) => {
if (_.isEmpty(params)) return;
const { status, isRoot, token } = params;
const { status, isRoot, token, callback } = params;
if (status == "1") {
// Object.assign(this._reqParams, { token });
// this.getFormData({ viewAttr: 1 });
this.hasRight = true;
isRoot && this.mySalaryBillList([moment().startOf("year").format("YYYY-MM"), moment().format("YYYY-MM")]);
callback && callback();
} else {
this.hasRight = false;
}