2022-09-13 16:39:15 +08:00
|
|
|
|
import React from "react";
|
|
|
|
|
|
import { inject, observer } from "mobx-react";
|
2023-03-16 17:33:06 +08:00
|
|
|
|
import { WeaHelpfulTip, WeaTab } from "ecCom";
|
|
|
|
|
|
import { Button, Spin } from "antd";
|
2022-09-13 16:39:15 +08:00
|
|
|
|
import { getQueryString } from "../../../util/url";
|
2023-03-16 17:33:06 +08:00
|
|
|
|
import { removePropertyCondition } from "../../../util/response";
|
2022-09-13 16:39:15 +08:00
|
|
|
|
import { getSearchs } from "../../../util";
|
2023-04-26 17:27:32 +08:00
|
|
|
|
import { getPayrollDetailList, getPayrollDetailSa, getPayrollInfo } from "../../../apis/payroll";
|
2023-03-16 17:33:06 +08:00
|
|
|
|
import "./index.less";
|
2022-09-13 16:39:15 +08:00
|
|
|
|
|
|
|
|
|
|
@inject("payrollStore")
|
2022-04-16 13:13:41 +08:00
|
|
|
|
@observer
|
|
|
|
|
|
export default class PayrollDetail extends React.Component {
|
2022-09-13 16:39:15 +08:00
|
|
|
|
constructor(props) {
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
this.state = {
|
2023-03-16 17:33:06 +08:00
|
|
|
|
salarySendDetailBaseInfo: {}, loading: false,
|
|
|
|
|
|
condition: [], dataSource: [], columns: [],
|
2023-04-26 17:27:32 +08:00
|
|
|
|
pageInfo: { current: 1, pageSize: 10, total: 0 }
|
2022-09-13 16:39:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-17 14:36:45 +08:00
|
|
|
|
componentWillMount() {
|
|
|
|
|
|
this.getPayrollDetailList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-16 17:33:06 +08:00
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
this.getPayrollInfo();
|
|
|
|
|
|
this.getPayrollDetailSa();
|
|
|
|
|
|
window.addEventListener("message", this.handleReceiveMessage, false);
|
2022-09-13 16:39:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-16 17:33:06 +08:00
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
|
window.removeEventListener("message", this.handleReceiveMessage, false);
|
2022-09-13 16:39:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-16 17:33:06 +08:00
|
|
|
|
handleReceiveMessage = async ({ data }) => {
|
|
|
|
|
|
const { dataSource, columns, pageInfo } = this.state;
|
|
|
|
|
|
const childFrameObj = document.getElementById("atdTable");
|
|
|
|
|
|
const { type, payload } = data;
|
|
|
|
|
|
if (type === "turn") {
|
|
|
|
|
|
const { id, params: { size: pageSize, pageNum: current, total } } = payload;
|
|
|
|
|
|
if (id && id === "PAGEINFO") {
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
pageInfo: {
|
|
|
|
|
|
...pageInfo,
|
|
|
|
|
|
current,
|
|
|
|
|
|
pageSize,
|
|
|
|
|
|
total
|
|
|
|
|
|
}
|
|
|
|
|
|
}, () => this.getPayrollDetailList({ child: id }));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type === "init") {
|
|
|
|
|
|
childFrameObj.contentWindow.postMessage(JSON.stringify({
|
|
|
|
|
|
dataSource,
|
|
|
|
|
|
columns,
|
|
|
|
|
|
pageInfo,
|
2023-04-26 17:27:32 +08:00
|
|
|
|
sumpayload: { salarySendId: getQueryString("id") }
|
2023-03-16 17:33:06 +08:00
|
|
|
|
}), "*");
|
2023-03-17 14:36:45 +08:00
|
|
|
|
this.getPayrollDetailList({ child: type });
|
2023-03-16 17:33:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
getPayrollInfo = () => {
|
|
|
|
|
|
const id = getQueryString("id");
|
|
|
|
|
|
getPayrollInfo({ id }).then(({ status, data }) => {
|
|
|
|
|
|
if (status) {
|
|
|
|
|
|
this.setState({ salarySendDetailBaseInfo: data });
|
|
|
|
|
|
}
|
2022-09-13 16:39:15 +08:00
|
|
|
|
});
|
2023-03-16 17:33:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
getPayrollDetailSa = () => {
|
2022-09-13 16:39:15 +08:00
|
|
|
|
const { payrollStore } = this.props;
|
2023-03-16 17:33:06 +08:00
|
|
|
|
const { detailListConditionForm } = payrollStore;
|
|
|
|
|
|
getPayrollDetailSa().then(({ status, data }) => {
|
|
|
|
|
|
if (status) {
|
|
|
|
|
|
const condition = removePropertyCondition(data.condition);
|
|
|
|
|
|
this.setState({ condition }, () => {
|
|
|
|
|
|
detailListConditionForm.initFormFields(this.state.condition);
|
|
|
|
|
|
});
|
2022-09-13 16:39:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-03-16 17:33:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
getPayrollDetailList = (extra = {}) => {
|
|
|
|
|
|
const childFrameObj = document.getElementById("atdTable");
|
|
|
|
|
|
const { pageInfo } = this.state;
|
|
|
|
|
|
const { child, ...extraParams } = extra;
|
|
|
|
|
|
const salarySendId = getQueryString("id");
|
|
|
|
|
|
const { payrollStore } = this.props;
|
|
|
|
|
|
const { detailListConditionForm: form } = payrollStore;
|
|
|
|
|
|
const payload = { salarySendId, ...pageInfo, ...extraParams, ...form.getFormParams() };
|
|
|
|
|
|
this.setState({ loading: true });
|
|
|
|
|
|
getPayrollDetailList(payload).then(({ status, data }) => {
|
|
|
|
|
|
this.setState({ loading: false });
|
|
|
|
|
|
if (status) {
|
|
|
|
|
|
const { columns, datas: dataSource, pageInfo: pages } = data;
|
|
|
|
|
|
const { pageNum: current, pageSize, total } = pages;
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
dataSource,
|
|
|
|
|
|
columns: _.map(columns, (item, index) => ({
|
|
|
|
|
|
dataIndex: item.column, title: item.text, width: item.width,
|
|
|
|
|
|
fixed: index <= 2 ? "left" : null
|
|
|
|
|
|
})),
|
|
|
|
|
|
pageInfo: { ...pageInfo, current, pageSize, total }
|
|
|
|
|
|
}, () => {
|
2023-04-26 17:27:32 +08:00
|
|
|
|
const { pageInfo, dataSource, columns } = this.state;
|
2023-03-17 14:36:45 +08:00
|
|
|
|
(child === "PAGEINFO" || child === "init") &&
|
2023-03-16 17:33:06 +08:00
|
|
|
|
childFrameObj.contentWindow.postMessage(JSON.stringify({
|
|
|
|
|
|
dataSource,
|
|
|
|
|
|
columns,
|
2023-04-26 17:27:32 +08:00
|
|
|
|
pageInfo,
|
|
|
|
|
|
sumpayload: { salarySendId: getQueryString("id") }
|
2023-03-16 17:33:06 +08:00
|
|
|
|
}), "*");
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(() => this.setState({ loading: false }));
|
|
|
|
|
|
};
|
2022-09-13 16:39:15 +08:00
|
|
|
|
handleExportAll = () => {
|
2023-03-16 17:33:06 +08:00
|
|
|
|
const salarySendId = getQueryString("id");
|
|
|
|
|
|
const url = `${window.location.origin}/api/bs/hrmsalary/salaryBill/send/exportDetailList?salarySendId=${salarySendId}`;
|
2022-09-13 16:39:15 +08:00
|
|
|
|
window.open(url, "_self");
|
|
|
|
|
|
};
|
2023-03-16 17:33:06 +08:00
|
|
|
|
handleSearch = () => this.getPayrollDetailList({ child: "PAGEINFO", current: 1 });
|
2022-09-13 16:39:15 +08:00
|
|
|
|
|
|
|
|
|
|
render() {
|
2023-03-16 17:33:06 +08:00
|
|
|
|
const { salarySendDetailBaseInfo, condition, loading } = this.state;
|
2022-09-13 16:39:15 +08:00
|
|
|
|
const { payrollStore } = this.props;
|
2023-03-16 17:33:06 +08:00
|
|
|
|
const { setDetailListShowSearchAd, detailListShowSearchAd, detailListConditionForm } = payrollStore;
|
|
|
|
|
|
const { salaryMonth, template, sendNum, sendTotal } = salarySendDetailBaseInfo;
|
2022-09-29 15:45:23 +08:00
|
|
|
|
const adBtn = [
|
2023-03-16 17:33:06 +08:00
|
|
|
|
<Button type="primary" onClick={this.handleSearch}>搜索</Button>,
|
|
|
|
|
|
<Button type="ghost" onClick={() => detailListConditionForm.resetForm()}>重置</Button>,
|
|
|
|
|
|
<Button type="ghost" onClick={() => setDetailListShowSearchAd(false)}>取消</Button>
|
2022-09-29 15:45:23 +08:00
|
|
|
|
];
|
2022-09-13 16:39:15 +08:00
|
|
|
|
return (
|
2023-09-01 14:06:32 +08:00
|
|
|
|
<div className="payrollDetail">
|
2022-09-13 16:39:15 +08:00
|
|
|
|
<WeaTab
|
2023-03-16 17:33:06 +08:00
|
|
|
|
searchType={["base", "advanced"]} searchsBasePlaceHolder="请输入姓名"
|
|
|
|
|
|
buttons={[<Button type="primary" onClick={this.handleExportAll}>导出全部</Button>]}
|
|
|
|
|
|
showSearchAd={detailListShowSearchAd} setShowSearchAd={bool => setDetailListShowSearchAd(bool)}
|
|
|
|
|
|
searchsAd={getSearchs(detailListConditionForm, condition, 2)}
|
|
|
|
|
|
buttonsAd={adBtn} onSearch={this.handleSearch}
|
|
|
|
|
|
onSearchChange={v => detailListConditionForm.updateFields({ username: v })}
|
|
|
|
|
|
searchsBaseValue={detailListConditionForm.getFormParams().username}
|
2022-09-13 16:39:15 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<div className="titleBar">
|
|
|
|
|
|
<div className="titleBarLeft">
|
2023-03-16 17:33:06 +08:00
|
|
|
|
<span>薪资所属月:{salaryMonth}</span>
|
2022-09-13 16:39:15 +08:00
|
|
|
|
<WeaHelpfulTip
|
|
|
|
|
|
style={{ marginLeft: "10px", marginRight: "10px" }}
|
|
|
|
|
|
width={200}
|
2023-03-16 17:33:06 +08:00
|
|
|
|
title={<PayrollTips salarySendDetailBaseInfo={salarySendDetailBaseInfo}/>}
|
2022-09-13 16:39:15 +08:00
|
|
|
|
placement="topLeft"
|
|
|
|
|
|
/>
|
2023-03-16 17:33:06 +08:00
|
|
|
|
<span>工资单模板:{template}</span>
|
2022-09-13 16:39:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="titleBarRight">
|
2023-03-16 17:33:06 +08:00
|
|
|
|
<span>已发放:{sendNum}/<span style={{ color: "red" }}>{sendTotal}</span></span>
|
2022-09-13 16:39:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="tableWrapper">
|
2023-03-16 17:33:06 +08:00
|
|
|
|
<Spin spinning={loading}>
|
|
|
|
|
|
<iframe
|
|
|
|
|
|
style={{ border: 0, width: "100%", height: "100%" }}
|
|
|
|
|
|
// src="http://localhost:7607/#/previewTable"
|
|
|
|
|
|
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/previewTable"
|
|
|
|
|
|
id="atdTable"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Spin>
|
2022-09-13 16:39:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2022-09-09 10:29:12 +08:00
|
|
|
|
}
|
2023-03-16 17:33:06 +08:00
|
|
|
|
|
|
|
|
|
|
export const PayrollTips = (props) => {
|
|
|
|
|
|
const { salarySendDetailBaseInfo = {} } = props;
|
|
|
|
|
|
const { salarySobCycle: { salaryCycle, taxCycle, attendCycle, socialSecurityCycle } } = salarySendDetailBaseInfo;
|
|
|
|
|
|
const { fromDate, endDate } = salaryCycle;
|
|
|
|
|
|
const { fromDate: aFromDate, endDate: aEndDate } = attendCycle;
|
|
|
|
|
|
return <div>
|
|
|
|
|
|
<div>薪资周期</div>
|
|
|
|
|
|
<div><span>{fromDate}</span><span>至</span><span>{endDate}</span></div>
|
|
|
|
|
|
<div>税款所属期</div>
|
|
|
|
|
|
<div>{taxCycle}</div>
|
|
|
|
|
|
<div>考勤取值周期</div>
|
|
|
|
|
|
<div><span>{aFromDate}</span><span>至</span><span>{aEndDate}</span></div>
|
|
|
|
|
|
<div>福利台账月份</div>
|
|
|
|
|
|
<div>{`引用的${socialSecurityCycle}福利台账数据`}</div>
|
|
|
|
|
|
</div>;
|
|
|
|
|
|
};
|