产品-工资单发放移动端页面权限认证

This commit is contained in:
黎永顺 2023-05-18 09:06:17 +08:00
parent bdcad182a2
commit eecd18cfa5
6 changed files with 132 additions and 36 deletions

View File

@ -1,29 +1,36 @@
import { WeaTools } from 'ecCom';
import { WeaTools } from "ecCom";
// 工资单列表
export const mySalaryBillList = params => {
return fetch('/api/bs/hrmsalary/salaryBill/mySalaryBillList', {
method: 'POST',
mode: 'cors',
return fetch("/api/bs/hrmsalary/salaryBill/mySalaryBillList", {
method: "POST",
mode: "cors",
headers: {
'Content-Type': 'application/json'
},
"Content-Type": "application/json"
},
body: JSON.stringify(params)
}).then(res => res.json())
}).then(res => res.json());
};
// 社保福利列表
export const welfareList = params => {
return WeaTools.callApi('/api/bs/hrmsalary/report/welfare/list', 'GET', params);
return WeaTools.callApi("/api/bs/hrmsalary/report/welfare/list", "GET", params);
};
// 调薪记录列表
export const recordList = params => {
return WeaTools.callApi('/api/bs/hrmsalary/report/record/list', 'GET', params);
return WeaTools.callApi("/api/bs/hrmsalary/report/record/list", "GET", params);
};
// 工资查看详情
export const mySalaryBill = params => {
return WeaTools.callApi('/api/bs/hrmsalary/salaryBill/mySalaryBill', 'GET', params);
};
return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/mySalaryBill", "GET", params);
};
export const isNeedSecondPwdVerify = params => {
return WeaTools.callApi("/api/encrypt/secondauthsetting/isNeedSecondAuth", "POST", params);
};
export const doSecondAuth = params => {
return WeaTools.callApi("/api/encrypt/secondauthsetting/doSecondAuth", "POST", params);
};

View File

@ -1,10 +1,14 @@
import React from "react";
import { inject, observer } from "mobx-react";
import { getQueryString } from "../../util/url";
import { WeaDialog, WeaError, WeaInput } from "ecCom";
import { Button, message } from "antd";
import Authority from "../mySalary/authority";
import ComputerTemplate from "../payroll/templatePreview/computerTemplate";
import PhoneTemplate from "../payroll/templatePreview/phoneTemplate";
import "../payroll/templatePreview/index.less";
import * as API from "../../apis/mySalaryBenefits";
import "./index.less";
@inject("mySalaryStore")
@observer
@ -12,6 +16,8 @@ export default class MobilePayroll extends React.Component {
constructor(props) {
super(props);
this.state = {
visible: false,
authCode: "",
mySalaryBillData: {
employeeInformation: {},
salaryTemplate: []
@ -24,11 +30,43 @@ export default class MobilePayroll extends React.Component {
const type = getQueryString("type");
this.id = getQueryString("id");
const { mySalaryStore: { init } } = this.props;
// type !== "phone" && init(false);
init(false);
type !== "phone" && init(false);
type === "phone" && this.initMobile();
this.getMySalaryBill(this.id);
}
initMobile = () => {
const { mySalaryStore: { setInitEmVerify } } = this.props;
if (window.em) {
API.isNeedSecondPwdVerify({ mouldCode: "HRM", itemCode: "SALARY" }).then(({ status, isNeedSecondAuth }) => {
if (status && isNeedSecondAuth) {
this.setState({ visible: true });
} else {
setInitEmVerify();
}
});
} else {
setInitEmVerify();
}
};
doSecondAuth = () => {
const { mySalaryStore: { setInitEmVerify } } = this.props;
if (!this.state.authCode) {
this.refs.weaError.showError();
return;
}
API.doSecondAuth({
authCode: this.state.authCode, mouldCode: "HRM", itemCode: "SALARY"
}).then(({ status, checkStatus, checkMsg }) => {
if (status && checkStatus === "1") {
message.success(checkMsg);
setInitEmVerify();
this.setState({ visible: false });
} else {
message.error(checkMsg);
}
});
};
getMySalaryBill = (salaryInfoId) => {
const { mySalaryStore: { getMySalaryBill } } = this.props;
const params = this.getUrlkey();
@ -57,7 +95,8 @@ export default class MobilePayroll extends React.Component {
};
render() {
const { mySalaryBillData } = this.state;
const { mySalaryStore: { clearLoading } } = this.props;
const { mySalaryBillData, visible } = this.state;
const type = getQueryString("type");
const employeeInformation = mySalaryBillData.employeeInformation ? mySalaryBillData.employeeInformation : {};
const salaryGroups = mySalaryBillData.salaryGroups ? mySalaryBillData.salaryGroups : [];
@ -67,18 +106,33 @@ export default class MobilePayroll extends React.Component {
overflowY: "hidden",
paddingBottom: "20px"
}}>
<WeaDialog
onCancel={() => this.setState({ visible: false }, () => clearLoading())}
title="请输入二次验证密码" visible={visible} initLoadCss
className="verifyWrapper"
hasScroll buttons={[
<Button type="primary" size="small" onClick={this.doSecondAuth}>确定</Button>
]}
>
<WeaError tipPosition="bottom" ref="weaError" error="此项必填">
<WeaInput value={this.state.authCode} onChange={authCode => this.setState({ authCode })}/>
</WeaError>
</WeaDialog>
{
type === "phone" ?
<div className="templatePreview">
<div className="contentWrapper">
<PhoneTemplate
isPreview
isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/>
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
store={this.props.mySalaryStore}>
<div className="templatePreview">
<div className="contentWrapper">
<PhoneTemplate
isPreview
isMsgPreview
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/>
</div>
</div>
</div>
</Authority>
:
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
store={this.props.mySalaryStore}>

View File

@ -0,0 +1,17 @@
.verifyWrapper {
.ant-modal-content {
width: 80vw !important;
.ant-modal-body {
padding: 10% !important;
.wea-dialog-body, .wea-new-scroll {
height: 75px !important;
.wea-error {
width: 100%;
}
}
}
}
}

View File

@ -13,17 +13,17 @@ export default class PhoneTemplate extends React.Component {
this.state = {
salaryItemSet: [],
salaryTemplateShowSet: {
theme:'',
background:'',
textContentPosition: '',
textContent: ''
theme: "",
background: "",
textContentPosition: "",
textContent: ""
}
};
}
componentWillMount() {
if(this.props.isPreview) return;
if (this.props.isPreview) return;
let salaryTemplateShowSetStr = window.localStorage.getItem("salary-showset");
let salaryItemSetStr = window.localStorage.getItem("salaryItemSet");
this.setState({
@ -31,18 +31,28 @@ export default class PhoneTemplate extends React.Component {
salaryTemplateShowSet: JSON.parse(salaryTemplateShowSetStr)
});
}
componentDidMount() {
if (this.props.isMsgPreview && this.props.salaryItemSet && window.em) {
this.setState({
salaryItemSet: JSON.parse(this.props.salaryItemSet),
salaryTemplateShowSet: JSON.parse(this.props.salaryTemplateShowSet)
});
}
}
componentWillReceiveProps(nextProps) {
if(nextProps.salaryTemplateShowSet !== this.props.salaryTemplateShowSet){
if (nextProps.salaryTemplateShowSet !== this.props.salaryTemplateShowSet) {
this.setState({
salaryItemSet: JSON.parse(nextProps.salaryItemSet),
salaryTemplateShowSet: JSON.parse(nextProps.salaryTemplateShowSet),
salaryTemplateShowSet: JSON.parse(nextProps.salaryTemplateShowSet)
});
}
}
render() {
const { salaryTemplateShowSet, salaryItemSet }= this.state;
const { salaryTemplateShowSet, salaryItemSet } = this.state;
return (
<div className="computerTemplate phoneTemplate">
<div className="titleWrapper">
@ -57,7 +67,7 @@ export default class PhoneTemplate extends React.Component {
<div className="sobItemDiv" style={{ margin: "20px 10px" }}>
{
salaryTemplateShowSet.textContentPosition == 1 && salaryTemplateShowSet.textContent
salaryTemplateShowSet.textContentPosition == 1 && salaryTemplateShowSet.textContent
}
</div>
@ -73,7 +83,7 @@ export default class PhoneTemplate extends React.Component {
_.map(group.items, item => {
return <tr className="descriptions-row">
<th className="descriptions-item-label">{item.name}</th>
<td className="descriptions-item-content">{item.salaryItemValue || '-'}</td>
<td className="descriptions-item-content">{item.salaryItemValue || "-"}</td>
</tr>;
})
}

View File

@ -30,8 +30,8 @@ const Home = props => props.children;
class Root extends React.Component {
componentWillMount() {
top.$(".ant-message").remove();
allStore.taxAgentStore.getPermission();
if(window.location.hash.indexOf("payroll")!== -1){
window.location.hash.indexOf("mobilepayroll") === -1 && allStore.taxAgentStore.getPermission();
if (window.location.hash.indexOf("payroll") !== -1) {
window.localStorage.removeItem("template-basedata");
window.localStorage.removeItem("salary-showset");
}

View File

@ -4,7 +4,7 @@ import { WeaForm, WeaLogView, WeaTableNew } from "comsMobx";
import { WeaLocaleProvider } from "ecCom";
import moment from "moment";
import * as API from "../apis/mySalaryBenefits"; // 引入API接口文件
import * as API from "../apis/mySalaryBenefits";
const { LogStore } = WeaLogView;
const getLabel = WeaLocaleProvider.getLabel;
@ -37,6 +37,14 @@ export class MySalaryStore {
this.loading = true;
this.hasRight = false;
};
@action clearLoading = () => {
this.loading = false;
this.hasRight = false;
};
@action setInitEmVerify = () => {
this.loading = false;
this.hasRight = true;
};
@action setMySalaryBill = (mySalaryBill) => {
this.mySalaryBill = mySalaryBill;
};