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

105 lines
3.7 KiB
JavaScript

/*
* pc端接口token弹窗
*
* @Author: 黎永顺
* @Date: 2024/9/18
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { WeaDialog, WeaLocaleProvider } from "ecCom";
import { Button, message } from "antd";
import { getQueryString } from "../../util/url";
import {
doSecondAuth,
getSecondAuthForm,
isNeedSecondPwdVerify,
salaryBillGetToken
} from "../../apis/mySalaryBenefits";
import { payrollCheckType } from "../../apis/payroll";
import { getSearchs } from "../../util";
import { pcConditions } from "./pwdCondtion";
const getLabel = WeaLocaleProvider.getLabel;
class PcInterfaceTokenDialog extends Component {
constructor(props) {
super(props);
this.state = {
visible: false, notSetting: false, conditions: []
};
}
async componentDidMount() {
const { mySalaryStore: { pcForm } } = this.props;
this.setState({
conditions: _.map(pcConditions, o => ({
...o, items: _.map(o.items, k => ({ ...k, label: getLabel(k.lanId, k.label) }))
}))
}, () => pcForm.initFormFields(this.state.conditions));
const { data: result } = await salaryBillGetToken({ uid: getQueryString("recipient") });
const { data, status } = await payrollCheckType({}, result);
this.props.onSetSalaryBillToken && this.props.onSetSalaryBillToken(result);
if (status && data === "PWD") {
isNeedSecondPwdVerify({ mouldCode: "HRM", itemCode: "SALARY" }, result)
.then(({ status, isNeedSecondAuth }) => {
if (status && isNeedSecondAuth) {
this.setState({ visible: true }, () => {
getSecondAuthForm({ mouldCode: "HRM", itemCode: "SALARY" }, result)
.then(({ notSetting }) => {
this.setState({ notSetting });
});
});
} else {
this.props.init && this.props.init();
}
});
} else {
this.props.onCaptcha && this.props.onCaptcha();
}
}
doSecondAuth = () => {
const { mySalaryStore: { pcForm }, salaryBillToken } = this.props;
pcForm.validateForm().then(f => {
if (f.isValid) {
doSecondAuth({ ...pcForm.getFormParams(), mouldCode: "HRM", itemCode: "SALARY" }, salaryBillToken)
.then(({ status, checkStatus, checkMsg }) => {
if (status && checkStatus === "1") {
message.success(checkMsg);
this.setState({ visible: false }, () => this.props.init && this.props.init());
} else {
f.showError("authCode", checkMsg);
this.forceUpdate();
}
});
} else {
f.showErrors();
this.forceUpdate();
}
});
};
render() {
const { visible, notSetting, conditions } = this.state;
const { mySalaryStore: { pcForm, initPcForm } } = this.props;
return (
<WeaDialog title={getLabel(111, "身份验证")} visible={visible} style={{ width: 550 }} initLoadCss
onCancel={() => this.setState({ visible: false }, () => initPcForm())}
bottomLeft={
notSetting && <div className="notSet">
{`${getLabel(508043, "您还未设置二次验证密码")}, ${getLabel(508044, "点击")} `}
<a href="/spa/hrm/index_mobx.html#/main/hrm/password?tabKey=2"
target="_blank">{getLabel(30747, "设置")}</a>
</div>
}
buttons={[<Button type="primary" onClick={this.doSecondAuth}>{getLabel(111, "确认")}</Button>]}>
<div className="form-dialog-layout"> {getSearchs(pcForm, conditions, 1, false)} </div>
</WeaDialog>
);
}
}
export default PcInterfaceTokenDialog;