/* * Author: 黎永顺 * name: 考勤引用数据查看 * Description: * Date: 2023/3/7 */ import React, { Component } from "react"; import { WeaInputSearch, WeaLocaleProvider, WeaSlideModal, WeaTop } from "ecCom"; import { viewAttendQuote } from "../../../../apis/attendance"; import { Button, Spin } from "antd"; import "./index.less"; const { getLabel } = WeaLocaleProvider; class AttendanceDataViewSlide extends Component { constructor(props) { super(props); this.state = { loading: { query: false }, keyword: "", dataSource: [], pageInfo: { current: 1, pageSize: 10, total: 0 } }; } 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; } } }; 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"); this.setState({ pageInfo: { current: 1, pageSize: 10, total: 0 } }); } } viewAttendQuote = (extraPayload = {}, props) => { const { loading, pageInfo, keyword } = this.state; const { attendQuoteId } = props || this.props; 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({ 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 })) })); } }).catch(() => this.setState({ loading: { ...loading, query: false } })); }; 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 }), "*"); }; 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; const { loading, keyword } = this.state; const btns = [ , this.setState({ keyword })} onSearch={() => this.viewAttendQuote({ current: 1 }, this.props)} /> ]; return ( } iconBgcolor="#F14A2D" buttons={showOperateBtn ? btns : btns.slice(1)}/> } content={
{getLabel(543376, "考勤周期")}:{salaryYearMonth}