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

94 lines
3.2 KiB
JavaScript

/*
* pc端工资单查看启用二次验证弹框
* @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.resetForm();
}
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;