salary-management-front/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataViewSlide.js

134 lines
5.3 KiB
JavaScript
Raw Normal View History

2023-03-07 14:47:47 +08:00
/*
* Author: 黎永顺
* name: 考勤引用数据查看
* Description:
* Date: 2023/3/7
*/
import React, { Component } from "react";
2025-04-24 16:38:36 +08:00
import { WeaInputSearch, WeaLocaleProvider, WeaSlideModal, WeaTop } from "ecCom";
2023-03-07 14:47:47 +08:00
import { viewAttendQuote } from "../../../../apis/attendance";
2025-04-24 16:38:36 +08:00
import { Button, Spin } from "antd";
2023-03-07 14:47:47 +08:00
import "./index.less";
const { getLabel } = WeaLocaleProvider;
2023-03-07 14:47:47 +08:00
class AttendanceDataViewSlide extends Component {
constructor(props) {
super(props);
this.state = {
2025-04-24 16:38:36 +08:00
loading: { query: false }, keyword: "", dataSource: [], pageInfo: { current: 1, pageSize: 10, total: 0 }
2023-03-07 14:47:47 +08:00
};
}
2025-04-24 16:38:36 +08:00
componentDidMount() {
window.addEventListener("message", this.handleReceive, false);
}
componentWillUnmount() {
window.removeEventListener("message", this.handleReceive, false);
}
handleReceive = async ({ data }) => {
const { type, payload: { id, params } = {} } = data;
if (type === "turn") {
switch (id) {
case "PAGEINFO":
this.setState({ pageInfo: { ...this.state.pageInfo, ...params } }, () => this.viewAttendQuote());
break;
default:
break;
}
}
};
2023-03-07 14:47:47 +08:00
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) {
document.querySelector(".attendanceRefWrapper").classList.add("zIndex0-attendance");
this.viewAttendQuote({}, nextProps);
} else if (nextProps.visible !== this.props.visible && !nextProps.visible) {
document.querySelector(".attendanceRefWrapper").classList.remove("zIndex0-attendance");
2024-08-07 14:05:32 +08:00
this.setState({ pageInfo: { current: 1, pageSize: 10, total: 0 } });
}
2023-03-07 14:47:47 +08:00
}
viewAttendQuote = (extraPayload = {}, props) => {
const { loading, pageInfo, keyword } = this.state;
2025-04-24 16:38:36 +08:00
const { attendQuoteId } = props || this.props;
2023-03-07 14:47:47 +08:00
this.setState({ loading: { ...loading, query: true } });
viewAttendQuote({ ...pageInfo, attendQuoteId, keyword, ...extraPayload }).then(({ status, data }) => {
this.setState({ loading: { ...loading, query: false } });
if (status) {
const { columns, list: dataSource, pageNum: current, pageSize, total } = data.pageInfo;
this.setState({
2025-04-24 16:38:36 +08:00
pageInfo: { ...pageInfo, current, pageSize, total }, dataSource
}, () => this.postMessageToChild({
pageInfo: this.state.pageInfo, dataSource, showRowSelection: false, unitTableType: "attendanceView",
columns: _.map(columns, (o, i) => ({ ...o, width: 150, fixed: i === 0 ? "left" : false }))
}));
2023-03-07 14:47:47 +08:00
}
}).catch(() => this.setState({ loading: { ...loading, query: false } }));
};
2025-04-24 16:38:36 +08:00
postMessageToChild = (payload = {}) => {
const i18n = {
"操作": getLabel(30585, "操作"), "编辑": getLabel(111, "编辑"), "共": getLabel(18609, "共"),
"条": getLabel(18256, "条")
};
const childFrameObj = document.getElementById("attendanceViewTable");
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
};
2023-03-07 14:47:47 +08:00
handleExportAttendQuote = () => {
if (!this.handleDebounce) {
this.handleDebounce = _.debounce(() => {
const { attendQuoteId } = this.props;
const url = `${window.location.origin}/api/bs/hrmsalary/attendQuote/export?attendQuoteId=${attendQuoteId}`;
window.open(url, "_self");
this.handleDebounce = null;
}, 500);
}
this.handleDebounce();
};
render() {
const { showOperateBtn, salaryYearMonth, ...extra } = this.props;
2025-04-24 16:38:36 +08:00
const { loading, keyword } = this.state;
const btns = [
<Button type="primary" onClick={this.handleExportAttendQuote}>{getLabel(81272, "导出全部")}</Button>,
<WeaInputSearch
value={keyword} placeholder={getLabel(543380, "请输入姓名/部门/工号/手机号")}
onChange={keyword => this.setState({ keyword })}
onSearch={() => this.viewAttendQuote({ current: 1 }, this.props)}
/>
];
2023-03-07 14:47:47 +08:00
return (
<WeaSlideModal {...extra} className="attendanceSlideWrapper"
top={0} height={100} width={800} measureT="%" measureX="px" measureY="%" direction="right"
title={
<WeaTop title={getLabel(525196, "考勤数据")} icon={<i className="icon-coms-fa"/>}
iconBgcolor="#F14A2D"
buttons={showOperateBtn ? btns : btns.slice(1)}/>
}
content={
<div className="attendance-slide-body">
<div className="attendance-tb-tip">
<div>{getLabel(543376, "考勤周期")}{salaryYearMonth}</div>
<div></div>
</div>
2025-04-24 16:38:36 +08:00
<div style={{ height: `calc(100% - 40px)` }}>
<Spin spinning={loading.query}>
<iframe
style={{ border: 0, width: "100%", height: "100%" }}
// src="http://localhost:7607/#/unitTable"
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/unitTable"
id="attendanceViewTable"
/>
</Spin>
</div>
</div>
}
2023-03-07 14:47:47 +08:00
/>
);
}
}
export default AttendanceDataViewSlide;