feature/2.9.42310.01-薪资核算页面重构
This commit is contained in:
parent
3fe4ede887
commit
93d996c79f
|
|
@ -7,12 +7,14 @@
|
|||
import React, { Component } from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { WeaLocaleProvider, WeaTop } from "ecCom";
|
||||
import { Button } from "antd";
|
||||
import { Button, message, Modal } from "antd";
|
||||
import moment from "moment";
|
||||
import CalculateQuery from "./components/calculateQuery";
|
||||
import CalculateTablelist from "./components/calculateTablelist";
|
||||
import CalculateDialog from "./components/calculateDialog";
|
||||
import { backCalculate, deleteSalaryacct, fileSalaryAcct, reAccounting } from "../../apis/calculate";
|
||||
import "./index.less";
|
||||
import ProgressModal from "../../components/progressModal";
|
||||
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
|
||||
|
|
@ -28,10 +30,12 @@ class Calculate extends Component {
|
|||
moment(new Date()).startOf("year").format("YYYY-MM"),
|
||||
moment(new Date()).startOf("month").format("YYYY-MM")
|
||||
]
|
||||
},
|
||||
isRefresh: false,
|
||||
}, isRefresh: false,
|
||||
progressModule: { visible: false, progress: 0, title: getLabel(111, "正在归档中请稍后") },
|
||||
calcDaialog: { visible: false, title: "" }
|
||||
};
|
||||
this.timer = null;
|
||||
this.handleDebounce = null;
|
||||
}
|
||||
|
||||
renderCalculateOpts = () => {
|
||||
|
|
@ -51,21 +55,151 @@ class Calculate extends Component {
|
|||
];
|
||||
return !showOperateBtn ? calculateOpts.slice(1) : calculateOpts;
|
||||
};
|
||||
handleCalcOpts = ({ key }, record) => {
|
||||
const { isRefresh, progressModule } = this.state, { id } = record;
|
||||
switch (key) {
|
||||
case "0":
|
||||
//核算
|
||||
window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/calculate/${id}`);
|
||||
break;
|
||||
case "1":
|
||||
//删除
|
||||
Modal.confirm({
|
||||
title: getLabel(131329, "信息确认"),
|
||||
content: getLabel(543231, "确认删除本条数据吗?"),
|
||||
onOk: () => {
|
||||
deleteSalaryacct([id]).then(({ status, errormsg }) => {
|
||||
if (status) {
|
||||
message.success(getLabel(502230, "删除成功!"));
|
||||
this.setState({ isRefresh: !isRefresh });
|
||||
} else {
|
||||
message.error(errormsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "2":
|
||||
//归档
|
||||
if (!this.handleDebounce) {
|
||||
this.handleDebounce = _.debounce(() => {
|
||||
if (this.timer) clearInterval(this.timer);
|
||||
this.setState({ progressModule: { ...progressModule, visible: true } });
|
||||
this.timer = setInterval(() => {
|
||||
if (progressModule.progress === 100 && this.timer) {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
this.setState({
|
||||
progressModule: { ...progressModule, visible: false, progress: 0 },
|
||||
isRefresh: !isRefresh
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
progressModule: { ...progressModule, progress: progressModule.progress + 1 }
|
||||
});
|
||||
}, 800);
|
||||
fileSalaryAcct({ id }).then(({ status, errormsg }) => {
|
||||
if (status) {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
this.setState({
|
||||
progressModule: { ...progressModule, visible: false, progress: 0 },
|
||||
isRefresh: !isRefresh
|
||||
});
|
||||
message.success(getLabel(503690, "归档成功"));
|
||||
} else {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
this.setState({
|
||||
progressModule: { ...progressModule, visible: false, progress: 0 }
|
||||
});
|
||||
message.error(errormsg);
|
||||
}
|
||||
});
|
||||
this.handleDebounce = null;
|
||||
}, 500);
|
||||
}
|
||||
this.handleDebounce();
|
||||
break;
|
||||
case "3":
|
||||
//查看详情
|
||||
window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/placeOnFileDetail?id=${id}`);
|
||||
break;
|
||||
case "4":
|
||||
//重新核算
|
||||
if (!this.handleDebounce) {
|
||||
this.handleDebounce = _.debounce(() => {
|
||||
reAccounting({ salaryAcctRecordId: id }).then(({ status, errormsg }) => {
|
||||
if (status) {
|
||||
message.success(getLabel(30700, "操作成功!"));
|
||||
this.setState({ isRefresh: !isRefresh });
|
||||
} else {
|
||||
message.error(errormsg);
|
||||
}
|
||||
});
|
||||
this.handleDebounce = null;
|
||||
}, 500);
|
||||
}
|
||||
this.handleDebounce();
|
||||
break;
|
||||
case "5":
|
||||
//回算
|
||||
Modal.confirm({
|
||||
title: getLabel(131329, "信息确认"),
|
||||
content: getLabel(543538, "确定回算吗?回算后,正常核算的数据会被覆盖,正常核算的工资单不能继续发放或撤回!"),
|
||||
onOk: () => {
|
||||
if (!this.handleDebounce) {
|
||||
this.handleDebounce = _.debounce(() => {
|
||||
backCalculate({ salaryAcctRecordId: id }).then(({ status, errormsg }) => {
|
||||
if (status) {
|
||||
message.success(getLabel(544367, "回算成功!"));
|
||||
this.setState({ isRefresh: !isRefresh });
|
||||
} else {
|
||||
message.error(errormsg);
|
||||
}
|
||||
});
|
||||
this.handleDebounce = null;
|
||||
}, 500);
|
||||
}
|
||||
this.handleDebounce();
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { queryParams, isRefresh, calcDaialog } = this.state;
|
||||
const { queryParams, isRefresh, calcDaialog, progressModule } = this.state;
|
||||
return (
|
||||
<WeaTop title={getLabel(538011, "薪资核算")} icon={<i className="icon-coms-fa"/>} iconBgcolor="#F14A2D"
|
||||
buttons={this.renderCalculateOpts()} className="calculate-main-layout"
|
||||
>
|
||||
<div className="calculate-body">
|
||||
<CalculateTablelist queryParams={queryParams} isRefresh={isRefresh}/>
|
||||
<CalculateTablelist queryParams={queryParams} isRefresh={isRefresh} onCalcOpts={this.handleCalcOpts}/>
|
||||
<CalculateDialog {...calcDaialog}
|
||||
onCancel={(bool, id) => this.setState({
|
||||
calcDaialog: { ...calcDaialog, visible: false },
|
||||
isRefresh: bool === "refresh" ? !isRefresh : isRefresh
|
||||
}, () => bool === "refresh" && window.open(`/spa/hrmSalary/static/index.html#/main/hrmSalary/calculate/${id}`))}
|
||||
/>
|
||||
{/* 归档进度条*/}
|
||||
{
|
||||
progressModule.visible &&
|
||||
<ProgressModal
|
||||
{...progressModule}
|
||||
onCancel={() => {
|
||||
this.setState({
|
||||
progressModule: {
|
||||
...progressModule,
|
||||
visible: false,
|
||||
progress: 0
|
||||
}
|
||||
}, () => clearInterval(this.timer));
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
</WeaTop>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -76,13 +76,14 @@ class Index extends Component {
|
|||
return <React.Fragment>
|
||||
{
|
||||
_.map(operate.slice(0, 2), f => (
|
||||
<a href="javascript:void(0);" style={{ marginRight: 10 }}>{f.text}</a>
|
||||
<a href="javascript:void(0);" style={{ marginRight: 10 }}
|
||||
onClick={() => this.props.onCalcOpts({ key: f.index }, record)}>{f.text}</a>
|
||||
))
|
||||
}
|
||||
{
|
||||
!_.isEmpty(operate.slice(2)) &&
|
||||
<Dropdown
|
||||
overlay={<Menu>
|
||||
overlay={<Menu onClick={(e) => this.props.onCalcOpts(e, record)}>
|
||||
{
|
||||
_.map(operate.slice(2), g => (<Menu.Item key={g.index}>{g.text}</Menu.Item>))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue