diff --git a/pc4mobx/hrmSalary/apis/payroll.js b/pc4mobx/hrmSalary/apis/payroll.js index fdef4e0e..5f800d68 100644 --- a/pc4mobx/hrmSalary/apis/payroll.js +++ b/pc4mobx/hrmSalary/apis/payroll.js @@ -210,8 +210,13 @@ export const checkMobileCode = (params, header = {}) => { return postFetch("/api/bs/hrmsalary/salaryBill/checkMobileCode", params, header); }; //工资单-验证方式 -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 => { diff --git a/pc4mobx/hrmSalary/components/captchaModal/index.js b/pc4mobx/hrmSalary/components/captchaModal/index.js index b7e3bdd7..d1a60ffb 100644 --- a/pc4mobx/hrmSalary/components/captchaModal/index.js +++ b/pc4mobx/hrmSalary/components/captchaModal/index.js @@ -36,7 +36,7 @@ class Index extends Component { handleSendCaptcha = () => { this.setState({ loading: true }); - sendMobileCode({ id: this.props.id }).then(({ status, data }) => { + sendMobileCode({ id: this.props.id }, this.props.salaryBillToken).then(({ status, data }) => { if (status) { this.timeRef = setInterval(() => { const { time } = this.state; @@ -61,14 +61,15 @@ class Index extends Component { f.showErrors(); return; } - checkMobileCode({ id: this.props.id, mobileCode: this.state.captcha }).then(({ status, errormsg }) => { - if (status) { - this.props.onCancel(); - this.props.onConfirm(); - } else { - message.error(errormsg); - } - }); + checkMobileCode({ id: this.props.id, mobileCode: this.state.captcha }, this.props.salaryBillToken) + .then(({ status, errormsg }) => { + if (status) { + this.props.onCancel(); + this.props.onConfirm(); + } else { + message.error(errormsg); + } + }); }; render() { diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/checkSecondaryVerifyDialog.js b/pc4mobx/hrmSalary/pages/mobilePayroll/checkSecondaryVerifyDialog.js new file mode 100644 index 00000000..980fb316 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/checkSecondaryVerifyDialog.js @@ -0,0 +1,105 @@ +/* + * 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"; +import LoginVerifyPC from "./loginVerifyPC"; +import SecondarypwdVerifyPC from "./secondarypwdVerifyPC"; + +const getLabel = WeaLocaleProvider.getLabel; +const form = new WeaForm(); + +class CheckSecondaryVerifyDialog extends Component { + constructor(props) { + super(props); + this.state = { + loading: false, conditions: [], notSetting: false, loginVerify: false, secondaryVerify: 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, loginVerify, secondaryVerify + } = this.state, { salaryBillToken } = this.props; + const itemRender = { + authCode: (field, textAreaProps, form, formParams) => { + return ( + + { + notSetting &&
+ {getLabel("111", "您还未设置二次验证密码,点击")} + this.setState({ loginVerify: true })}>{getLabel("30747", "设置")} +
+ } +
); + } + }; + return ( + {getLabel(111, "确认")} + ]}> +
+ +
+ {/*登录密码验证弹框*/} + this.setState({ loginVerify: false })} + onSetPwdSet={() => this.setState({ secondaryVerify: true })}/> + {/*二次密码设置*/} + this.setState({ secondaryVerify: false })} + onSuccess={this.initForm}/> +
+ ); + } +} + +export default CheckSecondaryVerifyDialog; + diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js index 372ede86..575b47d3 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js @@ -16,18 +16,22 @@ import MobileTemplate from "../../components/mobileTemplate"; import SecondaryVerify from "./secondaryVerify"; import LoginVerify from "./loginVerify"; import SecondarypwdVerify from "./secondarypwdVerify"; +import CheckSecondaryVerifyDialog from "./checkSecondaryVerifyDialog"; import "../mySalary/index.less"; const getLabel = WeaLocaleProvider.getLabel; -@inject("mySalaryStore") @observer +@inject("mySalaryStore") +@observer export default class MobilePayroll extends React.Component { constructor(props) { super(props); this.state = { visible: false, captchaVisible: false, loginVisible: false, pwdSetVisible: false, mySalaryBillData: { employeeInformation: {}, salaryTemplate: [] }, - salaryBillToken: {} + salaryBillToken: {}, + // 统一二次验证 + checkSecVerify: false }; this.id = ""; } @@ -37,14 +41,37 @@ export default class MobilePayroll extends React.Component { this.id = getQueryString("id"); const { mySalaryStore: { init, setMySalaryBill } } = this.props; setMySalaryBill({}); - const { data, status } = await payrollCheckType(); - if (status && data === "PWD") { - type !== "phone" ? init(false, () => this.getMySalaryBill(this.id)) : await this.initMobile(); - } 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) { @@ -65,15 +92,21 @@ export default class MobilePayroll extends React.Component { salaryCode: _.pick(params, ["salaryCode"]).salaryCode }); this.setState({ salaryBillToken: data }, () => { - API.isNeedSecondPwdVerify({ mouldCode: "HRM", itemCode: "SALARY" }, this.state.salaryBillToken) - .then(({ status, isNeedSecondAuth }) => { - if (status && isNeedSecondAuth) { - this.setState({ visible: true }); - } else { - this.getMySalaryBill(getQueryString("id")); - setInitEmVerify(); - } - }); + 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({ visible: true }); + } else { + this.getMySalaryBill(getQueryString("id")); + setInitEmVerify(); + } + }); + } else { + this.setState({ captchaVisible: true }); + } + }); }); } }; @@ -138,7 +171,7 @@ export default class MobilePayroll extends React.Component { render() { const { mySalaryStore: { setInitEmVerify } } = this.props, { - captchaVisible, visible, loginVisible, pwdSetVisible + captchaVisible, visible, loginVisible, pwdSetVisible, checkSecVerify } = this.state; const type = getQueryString("type"); if (_.isEmpty(toJS(this.props.mySalaryStore.mySalaryBill))) return @@ -152,11 +185,19 @@ export default class MobilePayroll extends React.Component { onSetPwdSet={() => this.setState({ loginVisible: false, pwdSetVisible: true })}/>} {pwdSetVisible && this.setState({ pwdSetVisible: false }, () => this.initMobile())}/>} + {/*统一外部调用token*/} + this.setState({ checkSecVerify: false }, () => callback && callback())} + onSuccess={() => { + this.getMySalaryBill(getQueryString("id")); + setInitEmVerify(); + }}/> {/*发送验证码*/} { captchaVisible && this.setState({ captchaVisible: false })} onConfirm={() => { setInitEmVerify(); @@ -200,4 +241,4 @@ export default class MobilePayroll extends React.Component { } ); } -} +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/index.less b/pc4mobx/hrmSalary/pages/mobilePayroll/index.less index 9fd7d4d6..6e78c87e 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/index.less +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/index.less @@ -168,3 +168,13 @@ position: relative; border-left: 1px solid #ddd; } + +.secondarypwd-form { + .wea-form-cell-wrapper { + & > div:last-child { + .ant-col-16 { + width: 37.5% !important; + } + } + } +} diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/loginVerifyPC.js b/pc4mobx/hrmSalary/pages/mobilePayroll/loginVerifyPC.js new file mode 100644 index 00000000..b9d0db85 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/loginVerifyPC.js @@ -0,0 +1,72 @@ +/* + * 二次验证 + * 登录密码验证 + * @Author: 黎永顺 + * @Date: 2025/4/23 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { Component } from "react"; +import { WeaDialog, WeaLocaleProvider } from "ecCom"; +import { WeaForm } from "comsMobx"; +import { Button } from "antd"; +import FormInfo from "../../components/FormInfo"; +import { loginCondition } from "./pwdCondtion"; +import { RSAEcrypt } from "../../util/RSAUtil"; +import * as API from "../../apis/mySalaryBenefits"; + +const form = new WeaForm(); +const getLabel = WeaLocaleProvider.getLabel; + +class LoginVerifyPC extends Component { + constructor(props) { + super(props); + this.state = { loading: false }; + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.visible !== this.props.visible && nextProps.visible) { + form.initFormFields(loginCondition); + } else { + form.resetForm(); + } + } + + save = async () => { + form.validateForm().then(f => { + if (f.isValid) { + RSAEcrypt("1", { ...form.getFormParams() }, this.props.salaryBillToken) + .then(RSAParam => { + API.checkPassword({ ...RSAParam }).then(({ result }) => { + if (result) { + this.props.onCancel(); + this.props.onSetPwdSet(); + } else { + form.showError("password", getLabel(504343, "登录密码错误")); + } + }); + }); + } else { + f.showErrors(); + } + }); + }; + + render() { + const { loading } = this.state; + return ( + (pre += cur.items.length), 0) * 47 + 33 }} + initLoadCss title={getLabel(111, "请先输入登录密码")} buttons={[ + + ]}> + + + ); + } +} + +export default LoginVerifyPC; diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/secondarypwdVerifyPC.js b/pc4mobx/hrmSalary/pages/mobilePayroll/secondarypwdVerifyPC.js new file mode 100644 index 00000000..fd139ae7 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/secondarypwdVerifyPC.js @@ -0,0 +1,96 @@ +/* + * 二次验证密码设置 + * + * @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 ( + + { + 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=""/> + ); + } + }; + return ( (pre += cur.items.length), 0) * 47 + 33 + }} initLoadCss title={getLabel(111, "二次验证密码设置")} buttons={[ + + ]}> + + ); + } +} + +export default SecondarypwdVerifyPC;