135 lines
4.5 KiB
JavaScript
135 lines
4.5 KiB
JavaScript
/*
|
||
* Author: 黎永顺
|
||
* name: 统计表
|
||
* Description:
|
||
* Date: 2023/4/17
|
||
*/
|
||
import React, { Component } from "react";
|
||
import { WeaLocaleProvider } from "ecCom";
|
||
import { Button, Col, Dropdown, Menu, message, Modal, Row } from "antd";
|
||
import {
|
||
reportStatisticsReportDelete,
|
||
reportStatisticsReportList,
|
||
statisticsReportDuplicate
|
||
} from "../../../apis/statistics";
|
||
import "../index.less";
|
||
|
||
const SubMenu = Menu.SubMenu;
|
||
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(131329, "信息确认"),
|
||
content: getLabel(543231, "确认删除本条数据吗?"),
|
||
onOk: () => {
|
||
const { reportName = "" } = this.props;
|
||
reportStatisticsReportDelete(payload).then(({ status, errormsg }) => {
|
||
if (status) {
|
||
message.success(getLabel(502230, "删除成功"));
|
||
this.reportStatisticsReportList({ reportName });
|
||
} else {
|
||
message.error(errormsg || getLabel(20462, "删除失败"));
|
||
}
|
||
});
|
||
}
|
||
});
|
||
};
|
||
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) ? <div className="empty">{getLabel(83553, "暂无数据")}</div> :
|
||
_.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(506800, "统计维度")}:</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(501169, "编辑")}</Menu.Item>
|
||
<Menu.Item key="copy">{getLabel(77, "复制")}</Menu.Item>
|
||
<Menu.Item key="delete">{getLabel(535052, "删除")}</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;
|