salary-management-front/pc4mobx/hrmSalary/pages/custom-pages/lingyue/components/ly_checkSecondaryVerifyDial...

99 lines
3.5 KiB
JavaScript

/*
* 领悦二开
* 工资单查看启用二次验证弹框
* @Author: 黎永顺
* @Date: 2025/2/14
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaDialog, WeaLocaleProvider } from "ecCom";
import { WeaSwitch } from "comsMobx";
import { Button, message } from "antd";
import FormInfo from "../../../../components/FormInfo";
import * as API from "../../../../apis/mySalaryBenefits";
const getLabel = WeaLocaleProvider.getLabel;
@inject("LYStore")
@observer
class LyCheckSecondaryVerifyDialog 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.initLYForm();
if (nextProps.visible !== this.props.visible && !nextProps.visible) nextProps.LYStore.initSecVerifyform();
}
initLYForm = () => {
const { salaryBillToken } = this.props;
API.getSecondAuthForm({ mouldCode: "HRM", itemCode: "SALARY" }, salaryBillToken)
.then(({ conditions, notSetting }) => {
this.setState({ conditions: [{ title: "", items: conditions }], notSetting }, () => {
const { LYStore: { secVerifyform } } = this.props;
secVerifyform.initFormFields(this.state.conditions);
});
});
};
save = () => {
const { LYStore: { secVerifyform }, salaryBillToken } = this.props;
secVerifyform.validateForm().then(f => {
if (f.isValid) {
const payload = { ...secVerifyform.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, { LYStore: { secVerifyform } } = this.props;
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={secVerifyform} formFields={conditions}/>
</div>
</WeaDialog>
);
}
}
export default LyCheckSecondaryVerifyDialog;