salary-management-front/pc4mobx/hrmSalary/pages/analysisOfSalaryStatistics/components/reportList.js

136 lines
4.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Author: 黎永顺
* name: 统计表
* Description:
* Date: 2023/4/17
*/
import React, { Component } from "react";
import { WeaAlertPage, WeaLocaleProvider } from "ecCom";
import { Button, Col, Dropdown, Menu, message, Modal, Row } from "antd";
import {
reportStatisticsReportDelete,
reportStatisticsReportList,
statisticsReportDuplicate
} from "../../../apis/statistics";
import "../index.less";
const { getLabel } = WeaLocaleProvider;
class ReportList extends Component {
constructor(props) {
super(props);
this.state = {
dataSource: []
};
}
componentDidMount() {
this.reportStatisticsReportList();
}
handleOptsClick = ({ key }, id, dimensionId) => {
const { reportName = "" } = this.props;
if (key === "delete") {
this.reportStatisticsReportDelete(id.split(","));
} else if (key === "edit") {
this.props.onEdit("addReport", id);
} else if (key === "copy") {
statisticsReportDuplicate({ id }).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(30700, "操作成功!"));
this.reportStatisticsReportList({ reportName });
} else {
message.error(errormsg);
}
});
} else if (key === "log") {
this.props.onFilterLog(key, id);
}
};
reportStatisticsReportDelete = (payload) => {
Modal.confirm({
title: getLabel(111, "信息确认"),
content: getLabel(111, "确认删除本条数据吗?"),
onOk: () => {
const { reportName = "" } = this.props;
reportStatisticsReportDelete(payload).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(111, "删除成功"));
this.reportStatisticsReportList({ reportName });
} else {
message.error(errormsg || getLabel(111, "删除失败"));
}
});
}
});
};
reportStatisticsReportList = (payload = {}) => {
reportStatisticsReportList(payload).then(({ status, data: dataSource }) => {
if (status) {
this.setState({ dataSource });
}
});
};
/*
* Author: 黎永顺
* Description: 报表查看
* Params:
* Date: 2023/4/20
*/
handleGoReportView = (id) => {
window.open(`${window.location.origin}/spa/hrmSalary/static/index.html#/main/hrmSalary/reportView?id=${id}`);
};
render() {
const { dataSource } = this.state;
return (
<Row gutter={16} className="reportRow">
{
_.isEmpty(dataSource) ? <WeaAlertPage icon="icon-coms-blank" iconSize={100}>
<div>暂无数据</div>
</WeaAlertPage> :
_.map(dataSource, it => {
const { reportName, dimension, id, dimensionId, isShare } = it;
return <Col className="gutter-row" span={6} onClick={() => this.handleGoReportView(id)}>
<div className="card-item">
<div className="cardLeft"><i className="icon-coms-fa"/></div>
<div className="cardCenter">
<span className="reportName">{reportName}</span>
<div className="dimension">
<div className="label">{getLabel(111, "统计维度")}</div>
<div className="value">{dimension}</div>
</div>
</div>
<div className="cardRight">
{
!isShare &&
<Dropdown overlay={
<Menu onClick={e => this.handleOptsClick(e, id, dimensionId)}>
<Menu.Item key="edit">{getLabel(111, "编辑")}</Menu.Item>
<Menu.Item key="copy">{getLabel(77, "复制")}</Menu.Item>
<Menu.Item key="delete">{getLabel(111, "删除")}</Menu.Item>
<Menu.Item key="log">{getLabel(545781, "操作日志")}</Menu.Item>
</Menu>
}>
<Button type="ghost"><i className="icon-coms-more"/></Button>
</Dropdown>
}
</div>
{
isShare &&
<div className="ant-ribbon ant-ribbon-placement-end">
<span className="ant-ribbon-text">{getLabel(111, "被分享")}</span>
<div className="ant-ribbon-corner"></div>
</div>
}
</div>
</Col>;
})
}
</Row>
);
}
}
export default ReportList;