97 lines
3.4 KiB
JavaScript
97 lines
3.4 KiB
JavaScript
|
|
/*
|
||
|
|
* 二次验证密码设置
|
||
|
|
*
|
||
|
|
* @Author: 黎永顺
|
||
|
|
* @Date: 2025/4/17
|
||
|
|
* @Wechat:
|
||
|
|
* @Email: 971387674@qq.com
|
||
|
|
* @description:
|
||
|
|
*/
|
||
|
|
import React, { Component } from "react";
|
||
|
|
import { WeaDialog, WeaLocaleProvider } from "ecCom";
|
||
|
|
import { Button, message } from "antd";
|
||
|
|
import { WeaForm, WeaSwitch } from "comsMobx";
|
||
|
|
import FormInfo from "../../components/FormInfo";
|
||
|
|
import { secondarypwdCondition } from "./conditions";
|
||
|
|
import * as API from "../../apis/mySalaryBenefits";
|
||
|
|
import { RSAEcrypt } from "../../util/RSAUtil";
|
||
|
|
|
||
|
|
const form = new WeaForm();
|
||
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
||
|
|
|
||
|
|
class SecondarypwdVerifyPC extends Component {
|
||
|
|
constructor(props) {
|
||
|
|
super(props);
|
||
|
|
this.state = {
|
||
|
|
src: (window.ecologyContentPath || "") + "/weaver/weaver.file.MakeValidateCode?notneedvalidate=1&isView=1&validatetype=0&validatenum=4",
|
||
|
|
num: 0
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
componentDidMount() {
|
||
|
|
form.initFormFields(secondarypwdCondition);
|
||
|
|
}
|
||
|
|
|
||
|
|
componentWillUnmount() {
|
||
|
|
form.resetForm();
|
||
|
|
}
|
||
|
|
|
||
|
|
save = async () => {
|
||
|
|
form.validateForm().then(f => {
|
||
|
|
if (f.isValid) {
|
||
|
|
const { secondaryPwd1, secondaryPwd2, validatecode } = form.getFormParams();
|
||
|
|
if (secondaryPwd1 !== secondaryPwd2) {
|
||
|
|
form.showError("secondaryPwd2", getLabel(504376, "密码确认不正确!"));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
RSAEcrypt("1", { secondaryPwd1, secondaryPwd2 }).then(RSAParam => {
|
||
|
|
API.saveSecondaryPwd({ ...RSAParam, validatecode }, this.props.salaryBillToken)
|
||
|
|
.then(({ sign, message: msg }) => {
|
||
|
|
if (sign === "1") {
|
||
|
|
message.success(msg);
|
||
|
|
this.props.onCancel();
|
||
|
|
this.props.onSuccess();
|
||
|
|
} else {
|
||
|
|
form.showError("validatecode", msg);
|
||
|
|
this.setState({ num: this.state.num + 1 }, () => {
|
||
|
|
this.setState({ src: `${window.ecologyContentPath || ""}/weaver/weaver.file.MakeValidateCode?notneedvalidate=1&isView=1&validatetype=0&validatenum=4&seriesnum_=${this.state.num}` });
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
f.showErrors();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
render() {
|
||
|
|
const itemRender = {
|
||
|
|
validatecode: (field, textAreaProps, form, formParams) => {
|
||
|
|
return (<React.Fragment>
|
||
|
|
<WeaSwitch fieldConfig={{ ...field, ...textAreaProps }} form={form} formParams={formParams}/>
|
||
|
|
<img
|
||
|
|
style={{ height: 30, cursor: "pointer", position: "absolute", left: "118%" }}
|
||
|
|
src={this.state.src}
|
||
|
|
onClick={() => {
|
||
|
|
this.setState({ num: this.state.num + 1 }, () => {
|
||
|
|
this.setState({ src: `${window.ecologyContentPath || ""}/weaver/weaver.file.MakeValidateCode?notneedvalidate=1&isView=1&validatetype=0&validatenum=4&seriesnum_=${this.state.num}` });
|
||
|
|
});
|
||
|
|
}} alt=""/>
|
||
|
|
</React.Fragment>);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
return (<WeaDialog
|
||
|
|
{...this.props} style={{
|
||
|
|
width: 550, height: _.reduce(secondarypwdCondition, (pre, cur) => (pre += cur.items.length), 0) * 47 + 33
|
||
|
|
}} initLoadCss title={getLabel(111, "二次验证密码设置")} buttons={[
|
||
|
|
<Button type="primary" onClick={this.save}>{getLabel(111, "保存")}</Button>
|
||
|
|
]}>
|
||
|
|
<FormInfo className="form-dialog-layout secondarypwd-form" center={false} itemRender={itemRender} form={form}
|
||
|
|
formFields={secondarypwdCondition}/>
|
||
|
|
</WeaDialog>);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default SecondarypwdVerifyPC;
|