264 lines
8.9 KiB
JavaScript
264 lines
8.9 KiB
JavaScript
/*
|
|
* 薪酬二开项目
|
|
* 列表
|
|
* @Author: 黎永顺
|
|
* @Date: 2024/8/22
|
|
* @Wechat:
|
|
* @Email: 971387674@qq.com
|
|
* @description:
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLoadingGlobal, WeaLocaleProvider } from "ecCom";
|
|
import { message, Modal, Spin } from "antd";
|
|
import * as API from "../../../../apis/custom-apis/lingyue";
|
|
import GenerateDataDialog from "./generateDataDialog";
|
|
import GenerateVouchersDialog from "./generateVouchersDialog";
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
const interfaceType = {
|
|
"salarySum": {
|
|
list: API.getLYSalaryReportList,
|
|
sum: API.getLYSalaryReportListSum,
|
|
export: API.exportSalaryReport,
|
|
batchDel: API.batchDeleteSalaryReport,
|
|
allDel: API.deleteAllSalaryReport
|
|
}, "socialFundSum": {
|
|
list: API.getLYSIReportList,
|
|
sum: API.getLYSIReportGenerateListSum,
|
|
export: API.exportSIReport,
|
|
batchDel: API.batchDeleteSIReport,
|
|
allDel: API.deleteAllSIReport
|
|
}, "fundSum": {
|
|
list: API.getLYFundReportList,
|
|
sum: API.getLYFundReportGenerateListSum,
|
|
export: API.exportFundReport,
|
|
batchDel: API.batchDeleteFundReport,
|
|
allDel: API.deleteAllFundReport
|
|
}
|
|
};
|
|
|
|
class List extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
dataSource: [],
|
|
columns: [],
|
|
pageInfo: { current: 1, pageSize: 10, total: 0 },
|
|
loading: false,
|
|
selectedRowKeys: [],
|
|
sumDataSource: {},
|
|
payload: {},
|
|
visible: false,
|
|
voucherDialog: { visible: false, ffgsqcLabel: props.ffgsqcLabel, type: props.type }
|
|
};
|
|
this.handleDebounce = null;
|
|
}
|
|
|
|
componentDidMount() {
|
|
window.addEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
window.removeEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.isQuery !== this.props.isQuery) this.setState({
|
|
pageInfo: { ...this.state.pageInfo, current: 1 }
|
|
}, () => this.getLYList());
|
|
}
|
|
|
|
handleReceive = ({ data }) => {
|
|
const { pageInfo } = this.state;
|
|
const { type, payload: { id, params } = {} } = data;
|
|
if (type === "init") {
|
|
this.getLYList();
|
|
} else if (type === "turn") {
|
|
switch (id) {
|
|
case "PAGEINFO":
|
|
this.setState({ pageInfo: { ...pageInfo, ...params } }, () => this.getLYList(false));
|
|
break;
|
|
case "CHECKBOX":
|
|
const { selectedRowKeys } = params;
|
|
this.setState({ selectedRowKeys });
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
postMessageToChild = (payload = {}) => {
|
|
const i18n = {
|
|
"共": getLabel(18609, "共"), "条": getLabel(18256, "条"), "总计": getLabel(523, "总计")
|
|
};
|
|
const childFrameObj = document.getElementById("unitTable");
|
|
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
|
|
};
|
|
|
|
getLYList = (isSum = true) => {
|
|
const { query, type, onInit } = this.props, { pageInfo, selectedRowKeys } = this.state;
|
|
const payload = {
|
|
...pageInfo, ...query, ffgsqc: query.ffgsqc ? query.ffgsqc.split(",") : [],
|
|
fycdgsqc: query.fycdgsqc ? query.fycdgsqc.split(",") : [],
|
|
ffStatus: query.ffStatus ? query.ffStatus.split(",") : [],
|
|
jtStatus: query.jtStatus ? query.jtStatus.split(",") : []
|
|
};
|
|
this.setState({ loading: true });
|
|
interfaceType[type]["list"](payload).then(async ({ status, data, errormsg }) => {
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
const { data: { sumRow: sumDataSource } } = isSum ? await interfaceType[type]["sum"](payload) : { data: { sumRow: this.state.sumDataSource } };
|
|
const { columns, data: result } = data;
|
|
const { list: dataSource, pageNum: current, pageSize, total } = result;
|
|
this.setState({
|
|
pageInfo: { ...pageInfo, current, pageSize, total },
|
|
voucherDialog: { ...this.state.voucherDialog, ...query },
|
|
dataSource,
|
|
columns,
|
|
sumDataSource,
|
|
payload
|
|
}, () => {
|
|
onInit();
|
|
this.postMessageToChild({
|
|
dataSource,
|
|
pageInfo: this.state.pageInfo,
|
|
selectedRowKeys,
|
|
unitTableType: "custom_lingyue",
|
|
columns: traverseCols(columns),
|
|
showTotalCell: true,
|
|
sumDataSource: this.state.sumDataSource,
|
|
scrollHeight: !_.isEmpty(dataSource) ? 195 : 0
|
|
});
|
|
});
|
|
} else {
|
|
message.warning(errormsg);
|
|
}
|
|
});
|
|
};
|
|
handleOperate = (key) => {
|
|
const { payload, selectedRowKeys } = this.state;
|
|
const { type, query, ffgsqcLabel } = this.props;
|
|
switch (key) {
|
|
case "GENERATE":
|
|
this.setState({ visible: true });
|
|
break;
|
|
case "GENERATEVOUCHER":
|
|
const { ffgsqc } = query;
|
|
if (!ffgsqc) {
|
|
message.warning(getLabel(111, `${ffgsqcLabel}参数不能为空`));
|
|
return;
|
|
}
|
|
this.setState({ voucherDialog: { ...this.state.voucherDialog, visible: true } });
|
|
break;
|
|
case "EXPORTALL":
|
|
WeaLoadingGlobal.start();
|
|
const promise = interfaceType[type]["export"](payload);
|
|
break;
|
|
case "ALLDEL":
|
|
const { salaryMonth } = query;
|
|
Modal.confirm({
|
|
title: getLabel(111, "确认信息"), content: getLabel(111, "确认全部删除吗?"), onOk: () => {
|
|
interfaceType[type]["allDel"]({ salaryMonth }).then(({ status, errormsg }) => {
|
|
if (status) {
|
|
message.success(getLabel(111, "操作成功!"));
|
|
this.setState({
|
|
selectedRowKeys: [], pageInfo: { ...this.state.pageInfo, current: 1 }
|
|
}, () => {
|
|
this.props.onChangeReport && this.props.onChangeReport();
|
|
this.getLYList();
|
|
});
|
|
} else {
|
|
message.error(errormsg);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
break;
|
|
case "BATCHDEL":
|
|
if (_.isEmpty(selectedRowKeys)) {
|
|
message.warning("未勾选数据!");
|
|
return;
|
|
}
|
|
Modal.confirm({
|
|
title: getLabel(111, "确认信息"), content: getLabel(388758, "确认要删除吗?"), onOk: () => {
|
|
interfaceType[type]["batchDel"]({ ids: selectedRowKeys }).then(({ status, errormsg }) => {
|
|
if (status) {
|
|
message.success(getLabel(111, "操作成功!"));
|
|
const { pageInfo } = this.state, { current, pageSize, total } = pageInfo;
|
|
const totalPage = Math.ceil((total - selectedRowKeys.length) / pageSize);
|
|
this.setState({
|
|
selectedRowKeys: [],
|
|
pageInfo: { ...this.state.pageInfo, current: current > totalPage ? totalPage : current }
|
|
}, () => {
|
|
this.props.onChangeReport && this.props.onChangeReport();
|
|
this.getLYList();
|
|
});
|
|
} else {
|
|
message.error(errormsg);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const { loading, dataSource, visible, voucherDialog } = this.state;
|
|
const { type } = this.props;
|
|
const dom = document.querySelector(".wea-new-top-content");
|
|
let height = 307.53;
|
|
if (dom && dataSource.length > 0) {
|
|
height = (parseFloat(dom.style.height) > 620 && dataSource.length === 10) ? dataSource.length * 47 + 204.53 : dataSource.length < 10 ? dataSource.length * 47 + 204.53 : parseFloat(dom.style.height) - 32;
|
|
}
|
|
return (<div className="custom_lingyue_list" style={{ height }}>
|
|
<Spin spinning={loading}>
|
|
<iframe
|
|
style={{ border: 0, width: "100%", height: "100%" }}
|
|
// src="http://localhost:7607/#/unitTable"
|
|
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/unitTable"
|
|
id="unitTable"
|
|
/>
|
|
</Spin>
|
|
<GenerateDataDialog type={type} visible={visible} onCancel={() => this.setState({ visible: false })}
|
|
onSearch={() => {
|
|
this.props.onChangeReport && this.props.onChangeReport();
|
|
this.getLYList();
|
|
}}/>
|
|
<GenerateVouchersDialog {...voucherDialog} onCancel={() => this.setState({
|
|
voucherDialog: { ...this.state.voucherDialog, visible: false }
|
|
}, () => this.getLYList())}/>
|
|
</div>);
|
|
}
|
|
}
|
|
|
|
export default List;
|
|
|
|
export const traverseCols = arr => {
|
|
return _.map(arr, item => {
|
|
if (!_.isEmpty(item.children)) {
|
|
return {
|
|
title: item.text,
|
|
width: item.width,
|
|
ellipsis: true,
|
|
dataIndex: item.column,
|
|
children: traverseCols(item.children),
|
|
fixed: item.fixed || false,
|
|
align: "center"
|
|
};
|
|
} else {
|
|
return {
|
|
title: item.text,
|
|
width: item.width,
|
|
fixed: item.fixed || false,
|
|
dataIndex: item.column,
|
|
ellipsis: true,
|
|
align: "center"
|
|
};
|
|
}
|
|
});
|
|
};
|
|
|