2024-03-26 17:07:21 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* name:薪资明细列表
|
|
|
|
|
* Description:
|
|
|
|
|
* Date: 2024/3/26
|
|
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import { inject, observer } from "mobx-react";
|
|
|
|
|
import { WeaTableNew } from "comsMobx";
|
2024-11-07 16:06:48 +08:00
|
|
|
import { WeaLoadingGlobal, WeaLocaleProvider, WeaSelect } from "ecCom";
|
2024-03-26 17:07:21 +08:00
|
|
|
import { message, Spin } from "antd";
|
|
|
|
|
import { getIframeParentHeight } from "../../../util";
|
|
|
|
|
import { sysConfCodeRule } from "../../../apis/ruleconfig";
|
2024-10-11 17:06:54 +08:00
|
|
|
import CustomTransferDialog from "../../../components/CustomBrowser/components/customTransferDialog";
|
2024-11-07 16:06:48 +08:00
|
|
|
import SalaryDetailsTempDialog from "./salaryDetailsTempDialog";
|
2024-11-07 09:23:46 +08:00
|
|
|
import { MonthRangePicker } from "../../reportView/components/statisticalMicroSettingsSlide";
|
|
|
|
|
import AdvanceInputBtn from "../components/advanceInputBtn";
|
|
|
|
|
import SearchPannel from "../components/searchPannel";
|
2024-10-11 17:06:54 +08:00
|
|
|
import * as API from "../../../apis/statistics";
|
2024-11-07 09:23:46 +08:00
|
|
|
import cs from "classnames";
|
2024-03-26 17:07:21 +08:00
|
|
|
import "../index.less";
|
|
|
|
|
|
|
|
|
|
const WeaTableComx = WeaTableNew.WeaTable;
|
|
|
|
|
const { getLabel } = WeaLocaleProvider;
|
|
|
|
|
|
|
|
|
|
@inject("attendanceStore")
|
|
|
|
|
@observer
|
|
|
|
|
class SalaryDetails extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
2024-11-07 16:06:48 +08:00
|
|
|
loading: false, dataSource: [], columns: [], selectedRowKeys: [], tempPageList: [],
|
|
|
|
|
pageInfo: { current: 1, pageSize: 10, total: 0 }, payload: {}, templateId: "",
|
|
|
|
|
showTotalCell: false, updateSum: true, tempDialog: { visible: false, setting: [] },
|
2024-10-11 17:06:54 +08:00
|
|
|
transferDialog: {
|
2024-10-12 10:07:36 +08:00
|
|
|
visible: false, searchParamsKey: "name", dataParams: { page: "salary_details_report" }, saveLoading: false,
|
2024-11-07 16:06:48 +08:00
|
|
|
completeURL: "", convertDatasource: datas => {
|
2024-10-12 10:07:36 +08:00
|
|
|
return {
|
2024-11-07 16:06:48 +08:00
|
|
|
listDatas: _.map(datas.setting, o => ({ id: o.id || o.column, name: o.name || o.text })),
|
2024-10-12 10:07:36 +08:00
|
|
|
checked: this.converCheckedCol(datas)
|
|
|
|
|
};
|
2024-11-07 16:06:48 +08:00
|
|
|
},
|
|
|
|
|
type: "default"
|
2024-10-11 17:06:54 +08:00
|
|
|
}
|
2024-03-26 17:07:21 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.getSalaryList(this.props);
|
2024-11-07 16:06:48 +08:00
|
|
|
this.getPageListTemplatelist();
|
2024-03-26 17:07:21 +08:00
|
|
|
window.addEventListener("message", this.handleReceive, false);
|
2024-11-07 16:06:48 +08:00
|
|
|
window.addEventListener("resize", () => this.setState({
|
|
|
|
|
transferDialog: { ...this.state.transferDialog, cancel: true }
|
|
|
|
|
}, () => this.forceUpdate()), false);
|
2024-03-26 17:07:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
2024-03-27 10:11:30 +08:00
|
|
|
if (nextProps.isQuery !== this.props.isQuery) this.setState({
|
2024-06-14 16:33:26 +08:00
|
|
|
pageInfo: { ...this.state.pageInfo, current: 1 }, updateSum: true
|
2024-03-27 10:11:30 +08:00
|
|
|
}, () => this.getSalaryList(nextProps));
|
2024-03-26 17:07:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
window.removeEventListener("message", this.handleReceive, false);
|
2024-11-07 16:06:48 +08:00
|
|
|
window.removeEventListener("message", () => this.setState({
|
|
|
|
|
transferDialog: { ...this.state.transferDialog, cancel: true }
|
|
|
|
|
}, () => this.forceUpdate()), false);
|
2024-03-26 17:07:21 +08:00
|
|
|
this.setState(({ selectedRowKeys: [] }));
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 16:06:48 +08:00
|
|
|
getPageListTemplatelist = () => {
|
|
|
|
|
API.getPageListTemplatelist({ page: "salary_details_report" }).then(({ status, data }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
this.setState({
|
|
|
|
|
tempPageList: _.map(data, o => ({ key: String(o.id), showname: o.name })),
|
|
|
|
|
templateId: String(_.find(data, o => !!o.checked).id)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2024-03-26 17:07:21 +08:00
|
|
|
handleReceive = ({ data }) => {
|
|
|
|
|
const { type, payload: { id, params } = {} } = data;
|
|
|
|
|
const { pageInfo } = this.state;
|
|
|
|
|
if (type === "init") {
|
|
|
|
|
this.getColumns();
|
|
|
|
|
} else if (type === "turn") {
|
|
|
|
|
if (id === "PAGEINFO") {
|
|
|
|
|
const { pageNum: current, size: pageSize } = params;
|
2024-05-24 09:57:35 +08:00
|
|
|
this.setState({
|
|
|
|
|
pageInfo: { ...pageInfo, current, pageSize },
|
2024-06-14 16:33:26 +08:00
|
|
|
updateSum: false
|
2024-05-24 09:57:35 +08:00
|
|
|
}, () => this.getSalaryList(this.props));
|
2024-03-26 17:07:21 +08:00
|
|
|
} else if (id === "CHECKBOX") {
|
|
|
|
|
const { selectedRowKeys: checkBox } = params;
|
2024-05-24 09:57:35 +08:00
|
|
|
this.setState({ selectedRowKeys: checkBox, updateSum: false });
|
2024-03-26 17:07:21 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
postMessageToChild = (payload) => {
|
|
|
|
|
const i18n = {
|
|
|
|
|
"共": getLabel(18609, "共"), "条": getLabel(18256, "条"),
|
|
|
|
|
"总计": getLabel(523, "总计")
|
|
|
|
|
};
|
|
|
|
|
const childFrameObj = document.getElementById("atdTable");
|
|
|
|
|
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
|
|
|
|
|
};
|
|
|
|
|
getSalaryList = (props) => {
|
2024-10-12 10:07:36 +08:00
|
|
|
const { attendanceStore: { salaryDetailSearchForm, tableStore }, dateRange } = props || this.props;
|
2024-03-26 17:07:21 +08:00
|
|
|
const [startDateStr, endDateStr] = dateRange;
|
|
|
|
|
const { taxAgentIds, subcompanyIds, departmentIds, ...extra } = salaryDetailSearchForm.getFormParams();
|
2024-10-12 10:07:36 +08:00
|
|
|
const { pageInfo, transferDialog } = this.state;
|
2024-03-26 17:07:21 +08:00
|
|
|
const payload = {
|
|
|
|
|
taxAgentIds: taxAgentIds ? taxAgentIds.split(",") : [],
|
|
|
|
|
departmentIds: departmentIds ? departmentIds.split(",") : [],
|
|
|
|
|
subcompanyIds: subcompanyIds ? subcompanyIds.split(",") : [],
|
|
|
|
|
...extra, ...pageInfo, startDateStr, endDateStr
|
|
|
|
|
};
|
|
|
|
|
this.setState({ loading: true });
|
|
|
|
|
API.getSalaryList(payload).then(async ({ status, data }) => {
|
2024-05-10 16:33:02 +08:00
|
|
|
// API.getSalaryListSum(payload),
|
|
|
|
|
const [{ data: confCode }] = await Promise.all([sysConfCodeRule({ code: "OPEN_ACCT_RESULT_SUM" })]);
|
2024-03-26 17:07:21 +08:00
|
|
|
this.setState({ loading: false });
|
|
|
|
|
if (status) {
|
2024-11-07 16:06:48 +08:00
|
|
|
const { columns, dataKey, pageInfo: pageparams } = data;
|
2024-03-26 17:07:21 +08:00
|
|
|
const { list: dataSource, pageNum: current, total, pageSize } = pageparams;
|
|
|
|
|
this.setState({
|
2024-11-07 16:06:48 +08:00
|
|
|
columns, dataSource, pageInfo: { ...pageInfo, current, total, pageSize }, payload,
|
2024-10-12 10:07:36 +08:00
|
|
|
showTotalCell: confCode === "1", transferDialog: { ...transferDialog, cancel: false }
|
2024-03-26 17:07:21 +08:00
|
|
|
}, () => tableStore.getDatas(dataKey.datas));
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => this.setState({ loading: false }));
|
|
|
|
|
};
|
|
|
|
|
handleExportSalaryList = (key) => {
|
2024-11-07 16:06:48 +08:00
|
|
|
let { selectedRowKeys, payload, columns } = this.state;
|
2024-03-26 17:07:21 +08:00
|
|
|
if (key === "SELECTED" && selectedRowKeys.length === 0) {
|
|
|
|
|
message.warning(getLabel(543345, "请选择需要导出的数据!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
WeaLoadingGlobal.start();
|
2024-06-26 10:02:45 +08:00
|
|
|
const promise = API.exportSalaryList({
|
2024-11-07 16:06:48 +08:00
|
|
|
...payload, ids: key === "SELECTED" ? selectedRowKeys : [], columns: _.map(columns, o => o.column)
|
2024-06-26 10:02:45 +08:00
|
|
|
});
|
2024-03-26 17:07:21 +08:00
|
|
|
};
|
|
|
|
|
getColumns = () => {
|
2024-11-07 16:06:48 +08:00
|
|
|
const {
|
|
|
|
|
columns, dataSource, pageInfo, selectedRowKeys, showTotalCell, payload, updateSum, transferDialog
|
|
|
|
|
} = this.state;
|
2024-05-10 16:33:02 +08:00
|
|
|
const sumRowlistUrl = showTotalCell ? "/api/bs/hrmsalary/report/statistics/employee/salaryListSum" : "";
|
2024-10-12 10:07:36 +08:00
|
|
|
if (!_.isEmpty(columns) && !transferDialog.visible && !transferDialog.cancel) {
|
2024-03-26 17:07:21 +08:00
|
|
|
this.postMessageToChild({
|
2024-05-24 09:57:35 +08:00
|
|
|
dataSource, pageInfo, selectedRowKeys, showTotalCell, calcDetail: true, tableScrollHeight: 154,
|
|
|
|
|
sumRowlistUrl, payload: { ...payload, updateSum },
|
2024-03-26 17:07:21 +08:00
|
|
|
columns: _.map(columns, (it, idx) => ({
|
2024-11-07 16:06:48 +08:00
|
|
|
dataIndex: it.column, title: it.text, calcDetail: true,
|
|
|
|
|
width: (it.dataIndex === "taxAgent" || it.dataIndex === "salarySob") ? 176 : it.width,
|
2024-03-26 17:07:21 +08:00
|
|
|
fixed: (idx === 1 || idx === 0 || idx === 2) ? "left" : "",
|
|
|
|
|
ellipsis: true
|
|
|
|
|
}))
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return [];
|
|
|
|
|
};
|
2024-11-07 16:06:48 +08:00
|
|
|
handleSetDefCols = () => this.setState({
|
|
|
|
|
transferDialog: {
|
|
|
|
|
...this.state.transferDialog, completeURL: "/api/bs/hrmsalary/common/pageList/get/setting", visible: true
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-10-12 10:07:36 +08:00
|
|
|
converCheckedCol = (data) => {
|
2024-11-07 16:06:48 +08:00
|
|
|
return _.reduce(data.checked || [], (pre, cur) => {
|
2024-10-12 10:07:36 +08:00
|
|
|
const item = _.find(data.setting, k => k.id === cur);
|
|
|
|
|
if (!_.isEmpty(item)) return [...pre, item];
|
|
|
|
|
return pre;
|
|
|
|
|
}, []);
|
|
|
|
|
};
|
|
|
|
|
savePageListSetting = (values) => {
|
2024-11-07 16:06:48 +08:00
|
|
|
const { transferDialog, tempDialog } = this.state, { type } = transferDialog;
|
|
|
|
|
if (type === "temp") {
|
|
|
|
|
this.setState({
|
|
|
|
|
tempDialog: { ...tempDialog, visible: true, setting: _.map(values, o => o.id) },
|
|
|
|
|
transferDialog: { ...this.state.transferDialog, visible: false, cancel: true, type: "default" }
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-10-12 10:07:36 +08:00
|
|
|
const payload = {
|
|
|
|
|
page: "salary_details_report",
|
|
|
|
|
setting: _.map(values, o => o.id)
|
|
|
|
|
};
|
|
|
|
|
this.setState({ transferDialog: { ...this.state.transferDialog, saveLoading: true } });
|
|
|
|
|
API.savePageListSetting(payload).then(({ status, errormsg }) => {
|
|
|
|
|
this.setState({ transferDialog: { ...this.state.transferDialog, saveLoading: false } });
|
|
|
|
|
if (status) {
|
|
|
|
|
message.success(getLabel(111, "操作成功!"));
|
2024-11-07 16:06:48 +08:00
|
|
|
this.setState({
|
|
|
|
|
transferDialog: { ...this.state.transferDialog, visible: false, type: "default" }
|
|
|
|
|
}, () => this.getSalaryList());
|
2024-10-12 10:07:36 +08:00
|
|
|
} else {
|
|
|
|
|
message.error(errormsg);
|
2024-10-11 17:13:19 +08:00
|
|
|
}
|
|
|
|
|
});
|
2024-10-11 17:06:54 +08:00
|
|
|
};
|
2024-11-07 16:06:48 +08:00
|
|
|
handelAddTemp = () => this.setState({
|
|
|
|
|
transferDialog: {
|
|
|
|
|
...this.state.transferDialog, visible: true, type: "temp",
|
|
|
|
|
completeURL: "/api/bs/hrmsalary/common/pageList/template/get"
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
changePageListTemplate = (templateId) => {
|
|
|
|
|
this.setState({ templateId }, () => {
|
|
|
|
|
API.changePageListTemplate({ page: "salary_details_report", templateId }).then(({ status, errormsg }) => {
|
|
|
|
|
if (status) {
|
|
|
|
|
message.success(getLabel(111, "操作成功!"));
|
|
|
|
|
this.getSalaryList();
|
|
|
|
|
} else {
|
|
|
|
|
message.error(errormsg);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
2024-03-26 17:07:21 +08:00
|
|
|
|
|
|
|
|
render() {
|
2024-11-07 16:06:48 +08:00
|
|
|
const { loading, dataSource, transferDialog, tempDialog, tempPageList, templateId } = this.state;
|
2024-11-07 09:23:46 +08:00
|
|
|
const { attendanceStore: { tableStore }, dateRange, showSearchAd } = this.props;
|
|
|
|
|
return (<React.Fragment>
|
|
|
|
|
<div className="query-div">
|
2024-11-07 16:06:48 +08:00
|
|
|
<WeaSelect style={{ width: 200 }} hasAddBtn options={tempPageList} addOnClick={this.handelAddTemp} showSearch
|
|
|
|
|
optionFilterProp="children" value={templateId} onChange={this.changePageListTemplate}/>
|
2024-11-07 09:23:46 +08:00
|
|
|
<MonthRangePicker dateRange={dateRange} viewAttr={2} onChange={this.props.onChange}/>
|
2024-11-07 16:06:48 +08:00
|
|
|
<AdvanceInputBtn onOpenAdvanceSearch={() => this.setState({
|
|
|
|
|
transferDialog: { ...this.state.transferDialog, cancel: true }
|
|
|
|
|
}, () => this.props.handleOpenAdvanceSearch())} onAdvanceSearch={this.props.handleAdvanceSearch}/>
|
2024-11-07 09:23:46 +08:00
|
|
|
</div>
|
|
|
|
|
<div className={cs("searchAdvanced-condition-container", { "searchAdvanced-condition-hide": !showSearchAd })}>
|
2024-11-07 16:06:48 +08:00
|
|
|
<SearchPannel onCancel={() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
transferDialog: { ...this.state.transferDialog, cancel: true }
|
|
|
|
|
}, () => this.props.onCancel());
|
|
|
|
|
}} onAdSearch={this.props.onAdSearch}/>
|
2024-11-07 09:23:46 +08:00
|
|
|
</div>
|
|
|
|
|
<div className="table-layout"
|
2024-11-07 16:06:48 +08:00
|
|
|
style={{ height: getIframeParentHeight(".wea-new-top-req-content", dataSource.length, 70) + "px" }}>
|
2024-11-07 09:23:46 +08:00
|
|
|
<Spin spinning={loading}>
|
|
|
|
|
<iframe
|
|
|
|
|
style={{ border: 0, width: "100%", height: "100%" }}
|
|
|
|
|
// src="http://localhost:7607/#/calcTable"
|
|
|
|
|
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/calcTable"
|
|
|
|
|
id="atdTable"
|
|
|
|
|
/>
|
|
|
|
|
</Spin>
|
|
|
|
|
<WeaTableComx
|
|
|
|
|
style={{ display: "none" }}
|
|
|
|
|
comsWeaTableStore={tableStore}
|
|
|
|
|
needScroll={true}
|
|
|
|
|
columns={this.getColumns()}
|
2024-03-26 17:07:21 +08:00
|
|
|
/>
|
2024-11-07 16:06:48 +08:00
|
|
|
{/*默认显示列,薪资模板列表*/}
|
2024-11-07 09:23:46 +08:00
|
|
|
<CustomTransferDialog {...transferDialog} onChange={this.savePageListSetting}
|
|
|
|
|
onCancel={() => this.setState({
|
2024-11-07 16:06:48 +08:00
|
|
|
transferDialog: {
|
|
|
|
|
...transferDialog, completeURL: "", visible: false, cancel: true, type: "default"
|
|
|
|
|
}
|
2024-11-07 09:23:46 +08:00
|
|
|
})}/>
|
2024-11-07 16:06:48 +08:00
|
|
|
{/*薪资明细模板设置*/}
|
|
|
|
|
<SalaryDetailsTempDialog {...tempDialog} onSuccess={this.getPageListTemplatelist}
|
|
|
|
|
onCancel={callback => this.setState({
|
|
|
|
|
tempDialog: { ...tempDialog, visible: false, setting: [] }
|
|
|
|
|
}, () => callback && callback())}/>
|
2024-11-07 09:23:46 +08:00
|
|
|
</div>
|
|
|
|
|
</React.Fragment>
|
2024-03-26 17:07:21 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SalaryDetails;
|