feature/工资单查看接口添加Token

This commit is contained in:
黎永顺 2024-09-18 16:33:07 +08:00
parent 1c1aac66d7
commit e2c6ac6114
5 changed files with 153 additions and 14 deletions

View File

@ -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 => {

View File

@ -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 (
<WeaDialog title={getLabel(111, "身份验证")} visible={visible} style={{ width: 550 }} initLoadCss
onCancel={() => this.setState({ visible: false }, () => initPcForm())}
bottomLeft={
notSetting && <div className="notSet">
{`${getLabel(508043, "您还未设置二次验证密码")}, ${getLabel(508044, "点击")} `}
<a href="/spa/hrm/index_mobx.html#/main/hrm/password?tabKey=2"
target="_blank">{getLabel(30747, "设置")}</a>
</div>
}
buttons={[<Button type="primary" onClick={this.doSecondAuth}>{getLabel(111, "确认")}</Button>]}>
<div className="form-dialog-layout"> {getSearchs(pcForm, conditions, 1, false)} </div>
</WeaDialog>
);
}
}
export default PcInterfaceTokenDialog;

View File

@ -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 <div>
<WeaDialog
@ -199,6 +200,15 @@ export default class MobilePayroll extends React.Component {
}
</WeaDialog>
<PassSetDialog form={pwdForm} visible={pwdSetVisible} onCancel={() => this.setState({ pwdSetVisible: false })}/>
{/* PC端接口token验证*/}
{type !== "phone" &&
<PCInterfaceTokenDialog {...this.props} salaryBillToken={salaryBillToken}
onSetSalaryBillToken={salaryBillToken => this.setState({ salaryBillToken })}
onCaptcha={() => this.setState({ captchaVisible: true })}
init={() => {
setInitEmVerify();
this.getMySalaryBill(getQueryString("id"));
}}/>}
</div>;
const {
salaryTemplate, salaryGroups, employeeInformation,

View File

@ -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
}
];

View File

@ -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;