feature/2.19.1.2501.01-PC端Token验证

This commit is contained in:
lys 2025-04-15 16:54:11 +08:00
parent 51d9c58888
commit 83607e1c0d
3 changed files with 147 additions and 18 deletions

View File

@ -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 => {

View File

@ -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 (<React.Fragment>
<WeaSwitch fieldConfig={{ ...field, ...textAreaProps }} form={form} formParams={formParams}/>
{
notSetting && <div style={{ clear: "both", paddingTop: 10 }}>
{getLabel("111", "您还未设置二次验证密码,请先在系统中设置验证密码")}
{/*<a href="javascript:void(0);"*/}
{/* onClick={() => this.setState({ pwdSetVisible: true })}>{getLabel("30747", "设置")}</a>*/}
</div>
}
</React.Fragment>);
}
};
return (
<WeaDialog
{...this.props} style={{ width: 550, height: notSetting ? 80 + 26 : 80 }} initLoadCss
title={getLabel(111, "身份验证")} buttons={[
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(111, "确认")}</Button>
]}>
<div className="form-dialog-layout">
<FormInfo className="form-dialog-layout" center={false} itemRender={itemRender}
form={form} formFields={conditions}/>
</div>
</WeaDialog>
);
}
}
export default CheckSecondaryVerifyDialog;

View File

@ -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 <div>
<WeaDialog
@ -205,6 +228,19 @@ export default class MobilePayroll extends React.Component {
}
</WeaDialog>
<PassSetDialog form={pwdForm} visible={pwdSetVisible} onCancel={() => this.setState({ pwdSetVisible: false })}/>
{/*统一外部调用token*/}
<CheckSecondaryVerifyDialog visible={checkSecVerify} salaryBillToken={salaryBillToken}
onCancel={(callback) => this.setState({ checkSecVerify: false }, () => callback && callback())}
onSuccess={() => {
this.getMySalaryBill(getQueryString("id"));
setInitEmVerify();
}}/>
{/*发送验证码*/}
<CaptchaModal
visible={captchaVisible} id={getQueryString("id")}
onCancel={() => this.setState({ captchaVisible: false })}
onConfirm={() => this.props.mySalaryStore.setInitEmVerify()}
/>
</div>;
const {
salaryTemplate, salaryGroups, employeeInformation,
@ -243,11 +279,6 @@ export default class MobilePayroll extends React.Component {
</div>
</Authority>
}
<CaptchaModal
visible={captchaVisible} id={getQueryString("id")}
onCancel={() => this.setState({ captchaVisible: false })}
onConfirm={() => this.props.mySalaryStore.setInitEmVerify()}
/>
</React.Fragment>
);
}