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

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 => { export const mySalaryBillList = params => {
return fetch('/api/bs/hrmsalary/salaryBill/mySalaryBillList', { return fetch("/api/bs/hrmsalary/salaryBill/mySalaryBillList", {
method: 'POST', method: "POST",
mode: 'cors', mode: "cors",
headers: { headers: {
'Content-Type': 'application/json' "Content-Type": "application/json"
}, },
body: JSON.stringify(params) body: JSON.stringify(params)
}).then(res => res.json()) }).then(res => res.json());
}; };
// 社保福利列表 // 社保福利列表
export const welfareList = params => { 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 => { 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 => { 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 React from "react";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { getQueryString } from "../../util/url"; import { getQueryString } from "../../util/url";
import { WeaDialog, WeaError, WeaInput } from "ecCom";
import { Button, message } from "antd";
import Authority from "../mySalary/authority"; import Authority from "../mySalary/authority";
import ComputerTemplate from "../payroll/templatePreview/computerTemplate"; import ComputerTemplate from "../payroll/templatePreview/computerTemplate";
import PhoneTemplate from "../payroll/templatePreview/phoneTemplate"; import PhoneTemplate from "../payroll/templatePreview/phoneTemplate";
import "../payroll/templatePreview/index.less"; import "../payroll/templatePreview/index.less";
import * as API from "../../apis/mySalaryBenefits";
import "./index.less";
@inject("mySalaryStore") @inject("mySalaryStore")
@observer @observer
@ -12,6 +16,8 @@ export default class MobilePayroll extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
visible: false,
authCode: "",
mySalaryBillData: { mySalaryBillData: {
employeeInformation: {}, employeeInformation: {},
salaryTemplate: [] salaryTemplate: []
@ -24,11 +30,43 @@ export default class MobilePayroll extends React.Component {
const type = getQueryString("type"); const type = getQueryString("type");
this.id = getQueryString("id"); this.id = getQueryString("id");
const { mySalaryStore: { init } } = this.props; const { mySalaryStore: { init } } = this.props;
// type !== "phone" && init(false); type !== "phone" && init(false);
init(false); type === "phone" && this.initMobile();
this.getMySalaryBill(this.id); 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) => { getMySalaryBill = (salaryInfoId) => {
const { mySalaryStore: { getMySalaryBill } } = this.props; const { mySalaryStore: { getMySalaryBill } } = this.props;
const params = this.getUrlkey(); const params = this.getUrlkey();
@ -57,7 +95,8 @@ export default class MobilePayroll extends React.Component {
}; };
render() { render() {
const { mySalaryBillData } = this.state; const { mySalaryStore: { clearLoading } } = this.props;
const { mySalaryBillData, visible } = this.state;
const type = getQueryString("type"); const type = getQueryString("type");
const employeeInformation = mySalaryBillData.employeeInformation ? mySalaryBillData.employeeInformation : {}; const employeeInformation = mySalaryBillData.employeeInformation ? mySalaryBillData.employeeInformation : {};
const salaryGroups = mySalaryBillData.salaryGroups ? mySalaryBillData.salaryGroups : []; const salaryGroups = mySalaryBillData.salaryGroups ? mySalaryBillData.salaryGroups : [];
@ -67,18 +106,33 @@ export default class MobilePayroll extends React.Component {
overflowY: "hidden", overflowY: "hidden",
paddingBottom: "20px" 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" ? type === "phone" ?
<div className="templatePreview"> <Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
<div className="contentWrapper"> store={this.props.mySalaryStore}>
<PhoneTemplate <div className="templatePreview">
isPreview <div className="contentWrapper">
isMsgPreview <PhoneTemplate
salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)} isPreview
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []} isMsgPreview
/> salaryTemplateShowSet={JSON.stringify(mySalaryBillData.salaryTemplate)}
salaryItemSet={!_.isEmpty(salaryGroups) ? JSON.stringify([employeeInformation, ...salaryGroups]) : []}
/>
</div>
</div> </div>
</div> </Authority>
: :
<Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`} <Authority ecId={`${this && this.props && this.props.ecId || ""}_Authority@lulowc`}
store={this.props.mySalaryStore}> 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 = { this.state = {
salaryItemSet: [], salaryItemSet: [],
salaryTemplateShowSet: { salaryTemplateShowSet: {
theme:'', theme: "",
background:'', background: "",
textContentPosition: '', textContentPosition: "",
textContent: '' textContent: ""
} }
}; };
} }
componentWillMount() { componentWillMount() {
if(this.props.isPreview) return; if (this.props.isPreview) return;
let salaryTemplateShowSetStr = window.localStorage.getItem("salary-showset"); let salaryTemplateShowSetStr = window.localStorage.getItem("salary-showset");
let salaryItemSetStr = window.localStorage.getItem("salaryItemSet"); let salaryItemSetStr = window.localStorage.getItem("salaryItemSet");
this.setState({ this.setState({
@ -31,18 +31,28 @@ export default class PhoneTemplate extends React.Component {
salaryTemplateShowSet: JSON.parse(salaryTemplateShowSetStr) 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) { componentWillReceiveProps(nextProps) {
if(nextProps.salaryTemplateShowSet !== this.props.salaryTemplateShowSet){ if (nextProps.salaryTemplateShowSet !== this.props.salaryTemplateShowSet) {
this.setState({ this.setState({
salaryItemSet: JSON.parse(nextProps.salaryItemSet), salaryItemSet: JSON.parse(nextProps.salaryItemSet),
salaryTemplateShowSet: JSON.parse(nextProps.salaryTemplateShowSet), salaryTemplateShowSet: JSON.parse(nextProps.salaryTemplateShowSet)
}); });
} }
} }
render() { render() {
const { salaryTemplateShowSet, salaryItemSet }= this.state; const { salaryTemplateShowSet, salaryItemSet } = this.state;
return ( return (
<div className="computerTemplate phoneTemplate"> <div className="computerTemplate phoneTemplate">
<div className="titleWrapper"> <div className="titleWrapper">
@ -57,7 +67,7 @@ export default class PhoneTemplate extends React.Component {
<div className="sobItemDiv" style={{ margin: "20px 10px" }}> <div className="sobItemDiv" style={{ margin: "20px 10px" }}>
{ {
salaryTemplateShowSet.textContentPosition == 1 && salaryTemplateShowSet.textContent salaryTemplateShowSet.textContentPosition == 1 && salaryTemplateShowSet.textContent
} }
</div> </div>
@ -73,7 +83,7 @@ export default class PhoneTemplate extends React.Component {
_.map(group.items, item => { _.map(group.items, item => {
return <tr className="descriptions-row"> return <tr className="descriptions-row">
<th className="descriptions-item-label">{item.name}</th> <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>; </tr>;
}) })
} }

View File

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

View File

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