diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js index 93b46f38..db4f3c2f 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js @@ -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 {
@@ -150,7 +150,6 @@ export default class MobilePayroll extends React.Component {
diff --git a/pc4mobx/hrmSalary/pages/mySalary/mySalaryView.js b/pc4mobx/hrmSalary/pages/mySalary/mySalaryView.js index c5a80327..bda458fb 100644 --- a/pc4mobx/hrmSalary/pages/mySalary/mySalaryView.js +++ b/pc4mobx/hrmSalary/pages/mySalary/mySalaryView.js @@ -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
; + } + const employeeInformation = !_.isEmpty(mySalaryStore) && mySalaryStore.employeeInformation; + const salaryGroups = !_.isEmpty(mySalaryStore) && mySalaryStore.salaryGroups; + const salaryTemplateShowSet = !_.isEmpty(mySalaryStore) && mySalaryStore.salaryTemplate; return ( - +
diff --git a/pc4mobx/hrmSalary/pages/payroll/templatePreview/computerTemplate/index.js b/pc4mobx/hrmSalary/pages/payroll/templatePreview/computerTemplate/index.js index 691ef30d..6f2e68c2 100644 --- a/pc4mobx/hrmSalary/pages/payroll/templatePreview/computerTemplate/index.js +++ b/pc4mobx/hrmSalary/pages/payroll/templatePreview/computerTemplate/index.js @@ -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 {
{ - salaryTemplateShowSet.textContentPosition === "1" && salaryTemplateShowSet.textContent + salaryTemplateShowSet.textContentPosition == 1 && salaryTemplateShowSet.textContent }
@@ -106,7 +106,7 @@ export default class ComputerTemplate extends React.Component {
{ - salaryTemplateShowSet.textContentPosition === "2" && salaryTemplateShowSet.textContent + salaryTemplateShowSet.textContentPosition == 2 && salaryTemplateShowSet.textContent }
diff --git a/pc4mobx/hrmSalary/pages/payroll/templatePreview/phoneTemplate/index.js b/pc4mobx/hrmSalary/pages/payroll/templatePreview/phoneTemplate/index.js index ed72829a..0f85d51d 100644 --- a/pc4mobx/hrmSalary/pages/payroll/templatePreview/phoneTemplate/index.js +++ b/pc4mobx/hrmSalary/pages/payroll/templatePreview/phoneTemplate/index.js @@ -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), diff --git a/pc4mobx/hrmSalary/stores/mySalary.js b/pc4mobx/hrmSalary/stores/mySalary.js index 3e5126d9..61988d5b 100644 --- a/pc4mobx/hrmSalary/stores/mySalary.js +++ b/pc4mobx/hrmSalary/stores/mySalary.js @@ -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; }