From e2c6ac61147461c1020a2f23eb47a1437a780ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Wed, 18 Sep 2024 16:33:07 +0800 Subject: [PATCH] =?UTF-8?q?feature/=E5=B7=A5=E8=B5=84=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0Token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/payroll.js | 9 +- .../mobilePayroll/PCInterfaceTokenDialog.js | 104 ++++++++++++++++++ .../hrmSalary/pages/mobilePayroll/index.js | 32 ++++-- .../pages/mobilePayroll/pwdCondtion.js | 19 ++++ pc4mobx/hrmSalary/stores/mySalary.js | 3 +- 5 files changed, 153 insertions(+), 14 deletions(-) create mode 100644 pc4mobx/hrmSalary/pages/mobilePayroll/PCInterfaceTokenDialog.js diff --git a/pc4mobx/hrmSalary/apis/payroll.js b/pc4mobx/hrmSalary/apis/payroll.js index 48fcecb2..69f3e5c2 100644 --- a/pc4mobx/hrmSalary/apis/payroll.js +++ b/pc4mobx/hrmSalary/apis/payroll.js @@ -206,8 +206,13 @@ export const sendMobileCode = (params) => { return postFetch("/api/bs/hrmsalary/salaryBill/sendMobileCode", params); }; //工资单-验证方式 -export const payrollCheckType = params => { - return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/payrollCheckType", "GET", params); +export const payrollCheckType = (params, header) => { + return fetch(`/api/bs/hrmsalary/salaryBill/payrollCheckType`, { + method: "GET", + mode: "cors", + headers: { "Content-Type": "application/json", ...header } + }).then(res => res.json()); + // return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/payrollCheckType", "GET", params); }; //工资单-反馈验证 export const feedBackSalaryBill = params => { diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/PCInterfaceTokenDialog.js b/pc4mobx/hrmSalary/pages/mobilePayroll/PCInterfaceTokenDialog.js new file mode 100644 index 00000000..400ee9b5 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/PCInterfaceTokenDialog.js @@ -0,0 +1,104 @@ +/* + * 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 ( + this.setState({ visible: false }, () => initPcForm())} + bottomLeft={ + notSetting &&
+ {`${getLabel(508043, "您还未设置二次验证密码")}, ${getLabel(508044, "点击")} `} + {getLabel(30747, "设置")} +
+ } + buttons={[]}> +
{getSearchs(pcForm, conditions, 1, false)}
+
+ ); + } +} + +export default PcInterfaceTokenDialog; diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js index 2fa560c3..0efd4a33 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js @@ -8,9 +8,10 @@ import Authority from "../mySalary/authority"; import "../payroll/templatePreview/index.less"; import * as API from "../../apis/mySalaryBenefits"; import { salaryBillGetToken } from "../../apis/mySalaryBenefits"; -import { confirmSalaryBill, feedBackSalaryBill, payrollCheckType } from "../../apis/payroll"; +import { confirmSalaryBill, feedBackSalaryBill } from "../../apis/payroll"; import CaptchaModal from "../../components/captchaModal"; import PassSetDialog from "./passSetDialog"; +import PCInterfaceTokenDialog from "./PCInterfaceTokenDialog"; import { ConfirmBtns } from "../mySalary/mySalaryView"; import Content from "../../components/pcTemplate/content"; import MobileTemplate from "../../components/mobileTemplate"; @@ -43,14 +44,14 @@ export default class MobilePayroll extends React.Component { this.id = getQueryString("id"); const { mySalaryStore: { init, setMySalaryBill } } = this.props; setMySalaryBill({}); - if (type !== "phone") { - const { data, status } = await payrollCheckType(); - if (status && data === "PWD") { - init(false, () => this.getMySalaryBill(this.id)); - } else { - this.setState({ captchaVisible: true }); - } - } + // if (type !== "phone") { + // const { data, status } = await payrollCheckType(); + // if (status && data === "PWD") { + // init(false, () => this.getMySalaryBill(this.id)); + // } else { + // this.setState({ captchaVisible: true }); + // } + // } type === "phone" && await this.initMobile(); } @@ -173,8 +174,8 @@ export default class MobilePayroll extends React.Component { }; render() { - const { mySalaryStore: { clearLoading, pwdForm } } = this.props; - const { mySalaryBillData, visible, captchaVisible, notSetting, pwdSetVisible } = this.state; + const { mySalaryStore: { clearLoading, pwdForm, setInitEmVerify } } = this.props; + const { salaryBillToken, visible, captchaVisible, notSetting, pwdSetVisible } = this.state; const type = getQueryString("type"); if (_.isEmpty(toJS(this.props.mySalaryStore.mySalaryBill))) return
this.setState({ pwdSetVisible: false })}/> + {/* PC端接口token验证*/} + {type !== "phone" && + this.setState({ salaryBillToken })} + onCaptcha={() => this.setState({ captchaVisible: true })} + init={() => { + setInitEmVerify(); + this.getMySalaryBill(getQueryString("id")); + }}/>}
; const { salaryTemplate, salaryGroups, employeeInformation, diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js b/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js index 5cb571e6..8ecb152f 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js @@ -74,3 +74,22 @@ export const condition = [ defaultshow: true } ]; +export const pcConditions = [ + { + items: [ + { + conditionType: "PASSWORD", + domkey: ["authCode"], + fieldcol: 12, + label: "二次验证密码", + lanId: 111, + labelcol: 6, + rules: "required|string", + otherParams: { autocomplete: "off" }, + viewAttr: 3 + } + ], + title: "", + defaultshow: true + } +]; diff --git a/pc4mobx/hrmSalary/stores/mySalary.js b/pc4mobx/hrmSalary/stores/mySalary.js index eaad7374..fb55553f 100644 --- a/pc4mobx/hrmSalary/stores/mySalary.js +++ b/pc4mobx/hrmSalary/stores/mySalary.js @@ -14,6 +14,7 @@ const { TableStore } = WeaTableNew; export class MySalaryStore { @observable tableStore = new TableStore(); // new table @observable form = new WeaForm(); // nrew 一个form + @observable pcForm = new WeaForm(); // new 一个密码验证form @observable pwdForm = new WeaForm(); // new 一个密码验证form @observable condition = []; // 存储后台得到的form数据 @observable hasRight = false; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据 @@ -34,7 +35,7 @@ export class MySalaryStore { @observable recordListDataSource = []; @observable recordListPageInfo = {}; @observable myBillPageInfo = {}; - + @action initPcForm = () => this.pcForm = new WeaForm(); @action clear = () => { this.loading = true; this.hasRight = false;