From dee1059ca7fd18a9ab9e39e68cfe095ef3cb5c49 Mon Sep 17 00:00:00 2001 From: lys <971387674@qq.com> Date: Thu, 24 Apr 2025 16:38:36 +0800 Subject: [PATCH] release/2.19.1.2501.01 --- .../components/attendanceDataViewSlide.js | 78 ++++++++++++------- .../attendance/components/index.less | 4 +- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataViewSlide.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataViewSlide.js index be64c8e8..2f4804b6 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataViewSlide.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataViewSlide.js @@ -5,9 +5,9 @@ * Date: 2023/3/7 */ import React, { Component } from "react"; -import { WeaInputSearch, WeaLocaleProvider, WeaSlideModal, WeaTable, WeaTop } from "ecCom"; -import { Button } from "antd"; +import { WeaInputSearch, WeaLocaleProvider, WeaSlideModal, WeaTop } from "ecCom"; import { viewAttendQuote } from "../../../../apis/attendance"; +import { Button, Spin } from "antd"; import "./index.less"; const { getLabel } = WeaLocaleProvider; @@ -16,11 +16,31 @@ class AttendanceDataViewSlide extends Component { constructor(props) { super(props); this.state = { - loading: { query: false }, keyword: "", dataSource: [], columns: [], - pageInfo: { current: 1, pageSize: 10, total: 0 } + 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"); @@ -33,19 +53,29 @@ class AttendanceDataViewSlide extends Component { viewAttendQuote = (extraPayload = {}, props) => { const { loading, pageInfo, keyword } = this.state; - const { attendQuoteId } = props; + 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, - columns: _.map(columns, (o, i) => ({ ...o, width: 150, fixed: i === 0 ? "left" : null })) - }); + 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(() => { @@ -60,24 +90,7 @@ class AttendanceDataViewSlide extends Component { render() { const { showOperateBtn, salaryYearMonth, ...extra } = this.props; - const { columns, dataSource, loading, pageInfo, keyword } = this.state; - const pagination = { - ...pageInfo, - showTotal: (total) => `共 ${total} 条`, - pageSizeOptions: ["10", "20", "50", "100"], - showSizeChanger: true, - showQuickJumper: true, - onShowSizeChange: (current, pageSize) => { - this.setState({ - pageInfo: { ...pageInfo, current, pageSize } - }, () => this.viewAttendQuote({}, this.props)); - }, - onChange: (current) => { - this.setState({ - pageInfo: { ...pageInfo, current } - }, () => this.viewAttendQuote({}, this.props)); - } - }; + const { loading, keyword } = this.state; const btns = [ , {getLabel(543376, "考勤周期")}:{salaryYearMonth}
- +
+ +