From b17bf10327c55ff90244c97d04c220aa0f7df447 Mon Sep 17 00:00:00 2001 From: lys <971387674@qq.com> Date: Mon, 6 Jan 2025 17:23:12 +0800 Subject: [PATCH] =?UTF-8?q?custom-=E6=97=AD=E5=8C=96=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/custom-apis/xhc.js | 11 +- .../pages/custom-pages/xhc/conditions.js | 9 ++ .../custom-pages/xhc/departmentReport.js | 135 ++++++++++++++++-- .../pages/custom-pages/xhc/index.less | 16 +++ 4 files changed, 156 insertions(+), 15 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/custom-apis/xhc.js b/pc4mobx/hrmSalary/apis/custom-apis/xhc.js index 07651b9f..14c6c216 100644 --- a/pc4mobx/hrmSalary/apis/custom-apis/xhc.js +++ b/pc4mobx/hrmSalary/apis/custom-apis/xhc.js @@ -1,6 +1,15 @@ -import { postFetch } from "../../util/request"; +import { postExportFetch, postFetch } from "../../util/request"; // 旭化成-报表查询 export const getxhcDepartmentReport = (params) => { return postFetch("/api/bs/hrmsalary/salaryacct/xhcDepartmentReport/list", params); }; +// 旭化成-报表合计行 +export const getxhcDepartmentReportSum = (params) => { + return postFetch("/api/bs/hrmsalary/salaryacct/xhcDepartmentReport/sum", params); +}; +// 旭化成-报表导出 +export const exportXhcDepartmentReport = (params) => { + return postExportFetch("/api/bs/hrmsalary/salaryacct/xhcDepartmentReport/export", params); +}; + diff --git a/pc4mobx/hrmSalary/pages/custom-pages/xhc/conditions.js b/pc4mobx/hrmSalary/pages/custom-pages/xhc/conditions.js index 0d77632a..f824a741 100644 --- a/pc4mobx/hrmSalary/pages/custom-pages/xhc/conditions.js +++ b/pc4mobx/hrmSalary/pages/custom-pages/xhc/conditions.js @@ -1,6 +1,15 @@ export const xhcConditions = [ { items: [ + { + conditionType: "INPUT", + domkey: ["salaryMonth"], + fieldcol: 18, + label: "薪资所属月", + labelcol: 6, + value: "", + viewAttr: 2 + }, { browserConditionParam: { completeParams: {}, diff --git a/pc4mobx/hrmSalary/pages/custom-pages/xhc/departmentReport.js b/pc4mobx/hrmSalary/pages/custom-pages/xhc/departmentReport.js index 32254bbd..31839c39 100644 --- a/pc4mobx/hrmSalary/pages/custom-pages/xhc/departmentReport.js +++ b/pc4mobx/hrmSalary/pages/custom-pages/xhc/departmentReport.js @@ -1,10 +1,13 @@ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; -import { WeaLocaleProvider, WeaTop } from "ecCom"; +import { WeaLoadingGlobal, WeaLocaleProvider, WeaTop } from "ecCom"; import FormInfo from "../../../components/FormInfo"; import { xhcConditions } from "./conditions"; import * as API from "../../../apis/custom-apis/xhc"; -import { Button } from "antd"; +import { MonthRangePicker } from "../../reportView/components/statisticalMicroSettingsSlide"; +import moment from "moment"; +import { WeaSwitch } from "comsMobx"; +import { Button, Spin } from "antd"; import "./index.less"; const getLabel = WeaLocaleProvider.getLabel; @@ -12,32 +15,136 @@ const getLabel = WeaLocaleProvider.getLabel; @inject("XHCStore") @observer class DepartmentReport extends Component { + constructor(props) { + super(props); + this.state = { + dataSource: [], columns: [], loading: false, queryData: { + fromDate: moment(new Date()).subtract(6, "month").startOf("month").format("YYYY-MM-DD"), + toDate: moment(new Date()).add(6, "month").startOf("month").format("YYYY-MM-DD"), + subCompanyIds: [], departmentIds: [] + } + }; + } + componentDidMount() { const { XHCStore: { form } } = this.props; form.initFormFields(xhcConditions); - this.getxhcDepartmentReport(); + window.addEventListener("message", this.handleReceive, false); } + componentWillUnmount() { + window.removeEventListener("message", this.handleReceive, false); + } + + handleReceive = async ({ data }) => { + const { type } = data; + if (type === "init") this.getxhcDepartmentReport(); + }; + getxhcDepartmentReport = () => { - const { XHCStore: { form } } = this.props, { subCompanyIds, departmentIds } = form.getFormParams(); - const payload = { - subCompanyIds: subCompanyIds ? subCompanyIds.split(",") : [], - departmentIds: departmentIds ? departmentIds.split(",") : [] - }; - API.getxhcDepartmentReport(payload).then(({ status, data }) => { + const { queryData } = this.state; + this.setState({ loading: true }); + API.getxhcDepartmentReport({ ...queryData }).then(({ status, data }) => { + this.setState({ loading: false }); if (status) { - console.log(data); + const { data: dataSource, column } = data; + this.setState({ + dataSource: _.map(dataSource, (o, i) => ({ ...o, id: i + 1 })), + columns: [{ dataIndex: "id", title: getLabel(111, "序号"), width: 60 }, ..._.map(column, o => ({ + dataIndex: o.column, title: o.text, width: o.width + }))] + }, () => { + this.postMessageToChild({ + columns: this.state.columns, dataSource: this.state.dataSource, unitTableType: "-999", + scrollHeight: 95, showRowSelection: false, showTotalCell: true + }); + }); + this.getxhcDepartmentReportSum({ + columns: this.state.columns, dataSource: this.state.dataSource, unitTableType: "-999", + scrollHeight: 95, showRowSelection: false, showTotalCell: true + }); } }); }; + getxhcDepartmentReportSum = (payload) => { + const { queryData } = this.state; + API.getxhcDepartmentReportSum(queryData).then(({ status, data }) => { + if (status) { + const { sumRow: sumDataSource } = data; + this.postMessageToChild({ ...payload, sumDataSource }); + } + }); + }; + postMessageToChild = (payload = {}) => { + const i18n = { "总计": getLabel(523, "总计") }; + const childFrameObj = document.getElementById("unitTable"); + childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*"); + }; + handleExport = () => { + const { queryData } = this.state; + WeaLoadingGlobal.start(); + const promise = API.exportXhcDepartmentReport(queryData); + }; render() { - const { XHCStore: { form } } = this.props; + const { XHCStore: { form } } = this.props, { queryData, dataSource, loading } = this.state, { + fromDate, toDate + } = queryData; + const dateRange = [moment(fromDate).format("YYYY-MM"), moment(toDate).format("YYYY-MM")]; + const dom = document.querySelector(".wea-new-top-content"); + let height = 280; + if (dom && dataSource.length > 0) height = parseFloat(dom.style.height) - 88; + const itemRender = { + salaryMonth: (field, textAreaProps, form, formParams) => { + return (