diff --git a/pc4mobx/hrmSalary/apis/payroll.js b/pc4mobx/hrmSalary/apis/payroll.js index c322c94f..01932e6a 100644 --- a/pc4mobx/hrmSalary/apis/payroll.js +++ b/pc4mobx/hrmSalary/apis/payroll.js @@ -206,8 +206,13 @@ export const sendMobileCode = (params) => { return postFetch("/api/bs/hrmsalary/salaryBill/sendMobileCode", params); }; //工资单-验证方式 -export const payrollCheckType = params => { - return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/payrollCheckType", "GET", params); +export const payrollCheckType = async header => { + const res = await fetch(`/api/bs/hrmsalary/salaryBill/payrollCheckType`, { + method: "GET", + mode: "cors", + headers: { "Content-Type": "application/json", ...header } + }); + return await res.json(); }; //工资单-反馈验证 export const feedBackSalaryBill = async params => { diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/checkSecondaryVerifyDialog.js b/pc4mobx/hrmSalary/pages/mobilePayroll/checkSecondaryVerifyDialog.js new file mode 100644 index 00000000..b7a492b5 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/checkSecondaryVerifyDialog.js @@ -0,0 +1,93 @@ +/* + * 工资单查看启用二次验证弹框 + * @Author: 黎永顺 + * @Date: 2025/4/15 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { Component } from "react"; +import { WeaDialog, WeaLocaleProvider } from "ecCom"; +import { WeaForm, WeaSwitch } from "comsMobx"; +import { Button, message } from "antd"; +import * as API from "../../apis/mySalaryBenefits"; +import FormInfo from "../../components/FormInfo"; + +const getLabel = WeaLocaleProvider.getLabel; +const form = new WeaForm(); + +class CheckSecondaryVerifyDialog extends Component { + constructor(props) { + super(props); + this.state = { + loading: false, conditions: [], notSetting: false + }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) this.initForm(); + if (nextProps.visible !== this.props.visible && !nextProps.visible) form.initSecVerifyform(); + } + + initForm = () => { + const { salaryBillToken } = this.props; + API.getSecondAuthForm({ mouldCode: "HRM", itemCode: "SALARY" }, salaryBillToken) + .then(({ conditions, notSetting }) => { + this.setState({ conditions: [{ title: "", items: conditions }], notSetting }, () => { + form.initFormFields(this.state.conditions); + }); + }); + }; + save = () => { + const { salaryBillToken } = this.props; + form.validateForm().then(f => { + if (f.isValid) { + const payload = { ...form.getFormParams() }; + API.doSecondAuth({ ...payload, mouldCode: "HRM", itemCode: "SALARY" }, salaryBillToken) + .then(({ status, checkStatus, checkMsg }) => { + if (status && checkStatus === "1") { + message.success(checkMsg); + this.props.onCancel(this.props.onSuccess); + } else { + message.error(checkMsg); + } + }); + } else { + f.showErrors(); + } + }).catch(() => this.setState({ loading: false })); + }; + + render() { + const { conditions, loading, notSetting } = this.state; + const itemRender = { + authCode: (field, textAreaProps, form, formParams) => { + return ( + + { + notSetting &&
+ {getLabel("111", "您还未设置二次验证密码,请先在系统中设置验证密码")} + {/* this.setState({ pwdSetVisible: true })}>{getLabel("30747", "设置")}*/} +
+ } +
); + } + }; + return ( + {getLabel(111, "确认")} + ]}> +
+ +
+
+ ); + } +} + +export default CheckSecondaryVerifyDialog; + diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js index 69d84928..927ae3ee 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js @@ -14,6 +14,7 @@ import PassSetDialog from "./passSetDialog"; import { ConfirmBtns } from "../mySalary/mySalaryView"; import Content from "../../components/pcTemplate/content"; import MobileTemplate from "../../components/mobileTemplate"; +import CheckSecondaryVerifyDialog from "./checkSecondaryVerifyDialog"; import "../mySalary/index.less"; const getLabel = WeaLocaleProvider.getLabel; @@ -33,7 +34,9 @@ export default class MobilePayroll extends React.Component { employeeInformation: {}, salaryTemplate: [] }, - salaryBillToken: {} + salaryBillToken: {}, + // 统一二次验证 + checkSecVerify: false }; this.id = ""; } @@ -43,17 +46,37 @@ export default class MobilePayroll extends React.Component { this.id = getQueryString("id"); const { mySalaryStore: { init, setMySalaryBill } } = this.props; setMySalaryBill({}); - if (type !== "phone") { - const { data, status } = await payrollCheckType(); - if (status && data === "PWD") { - init(false, () => this.getMySalaryBill(this.id)); - } else { - this.setState({ captchaVisible: true }); - } - } + //统一调用token + type !== "phone" && await this.initPC(); type === "phone" && await this.initMobile(); } + initPC = async () => { + const { mySalaryStore: { setInitEmVerify } } = this.props; + const params = this.getUrlkey(); + const { data } = await salaryBillGetToken({ + id: _.pick(params, ["id"]).id, + recipient: _.pick(params, ["recipient"]).recipient, + salaryCode: _.pick(params, ["salaryCode"]).salaryCode + }); + this.setState({ salaryBillToken: data }, () => { + payrollCheckType(this.state.salaryBillToken).then(({ data, status }) => { + if (status && data === "PWD") { + API.isNeedSecondPwdVerify({ mouldCode: "HRM", itemCode: "SALARY" }, this.state.salaryBillToken) + .then(({ status, isNeedSecondAuth }) => { + if (status && isNeedSecondAuth) { + this.setState({ checkSecVerify: true }); + } else { + this.getMySalaryBill(getQueryString("id")); + setInitEmVerify(); + } + }); + } else { + this.setState({ captchaVisible: true }); + } + }); + }); + }; initMobile = async () => { const { mySalaryStore: { setInitEmVerify } } = this.props; if (window.em) { @@ -179,8 +202,8 @@ export default class MobilePayroll extends React.Component { }; render() { - const { mySalaryStore: { clearLoading, pwdForm } } = this.props; - const { mySalaryBillData, visible, captchaVisible, notSetting, pwdSetVisible } = this.state; + const { mySalaryStore: { clearLoading, pwdForm, setInitEmVerify } } = this.props; + const { salaryBillToken, visible, captchaVisible, notSetting, pwdSetVisible, checkSecVerify } = this.state; const type = getQueryString("type"); if (_.isEmpty(toJS(this.props.mySalaryStore.mySalaryBill))) return
this.setState({ pwdSetVisible: false })}/> + {/*统一外部调用token*/} + this.setState({ checkSecVerify: false }, () => callback && callback())} + onSuccess={() => { + this.getMySalaryBill(getQueryString("id")); + setInitEmVerify(); + }}/> + {/*发送验证码*/} + this.setState({ captchaVisible: false })} + onConfirm={() => this.props.mySalaryStore.setInitEmVerify()} + />
; const { salaryTemplate, salaryGroups, employeeInformation, @@ -243,11 +279,6 @@ export default class MobilePayroll extends React.Component { } - this.setState({ captchaVisible: false })} - onConfirm={() => this.props.mySalaryStore.setInitEmVerify()} - /> ); }