custom-旭化成

This commit is contained in:
lys 2025-01-06 17:23:12 +08:00
parent c3ea99d974
commit b17bf10327
4 changed files with 156 additions and 15 deletions

View File

@ -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);
};

View File

@ -1,6 +1,15 @@
export const xhcConditions = [
{
items: [
{
conditionType: "INPUT",
domkey: ["salaryMonth"],
fieldcol: 18,
label: "薪资所属月",
labelcol: 6,
value: "",
viewAttr: 2
},
{
browserConditionParam: {
completeParams: {},

View File

@ -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 (<div className="mounth-range">
<MonthRangePicker dateRange={dateRange} viewAttr={2}
onChange={([start, end]) => this.setState({
queryData: {
...queryData,
fromDate: moment(start).startOf("month").format("YYYY-MM-DD"),
toDate: moment(end).startOf("month").format("YYYY-MM-DD")
}
}, () => this.getxhcDepartmentReport())}/>
</div>);
},
subCompanyIds: (field, textAreaProps, form, formParams) => {
return (<WeaSwitch fieldConfig={{ ...field, ...textAreaProps }} form={form} formParams={formParams}
onChange={() => {
const subCompanyIds = form.getFormParams().subCompanyIds;
this.setState({
queryData: {
...queryData, subCompanyIds: subCompanyIds ? subCompanyIds.split(",") : []
}
}, () => this.getxhcDepartmentReport());
}}/>);
},
departmentIds: (field, textAreaProps, form, formParams) => {
return (<WeaSwitch fieldConfig={{ ...field, ...textAreaProps }} form={form} formParams={formParams}
onChange={() => {
const departmentIds = form.getFormParams().departmentIds;
this.setState({
queryData: {
...queryData, departmentIds: departmentIds ? departmentIds.split(",") : []
}
}, () => this.getxhcDepartmentReport());
}}/>);
}
};
return (<WeaTop
title={getLabel(111, "报表管理")} buttonSpace={10} className="xhc_report"
title={getLabel(111, "部门工资汇总表")} buttonSpace={10} className="xhc_report"
icon={<i className="icon-coms-fa"/>} iconBgcolor="#F14A2D"
buttons={[<Button type="primary">{getLabel(17416, "导出")}</Button>]}>
<FormInfo center={false} form={form} formFields={xhcConditions} colCount={3}/>
buttons={[<Button type="primary" onClick={this.handleExport}>{getLabel(17416, "导出")}</Button>]}>
<FormInfo center={false} form={form} formFields={xhcConditions} colCount={3} itemRender={itemRender}/>
<div style={{ height: height + "px" }}>
<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>
</div>
</WeaTop>);
}
}

View File

@ -1,4 +1,8 @@
.xhc_report {
.ant-spin-nested-loading, .ant-spin-container {
height: 100%;
}
.wea-new-top-content {
background: #f6f6f6;
padding: 8px 16px 0 16px;
@ -6,5 +10,17 @@
.wea-search-group {
margin-bottom: 8px;
background: #FFF;
}
.mounth-range {
.rangePickerBox {
display: flex;
align-items: center;
}
.label {
color: #999;
}
}
}