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

122 lines
3.4 KiB
JavaScript
Raw Normal View History

2023-04-11 13:41:56 +08:00
/*
* Author: 黎永顺
* name: 统计维度管理列表
* Description:
* Date: 2023/4/11
*/
import React, { Component } from "react";
2023-04-17 17:32:16 +08:00
import { WeaLocaleProvider, WeaTable } from "ecCom";
2023-04-12 10:47:51 +08:00
import { message, Modal } from "antd";
import { dimensionDelete, dimensionList } from "../../../apis/statistics";
import "../index.less";
2023-04-17 17:32:16 +08:00
const { getLabel } = WeaLocaleProvider;
2023-04-11 13:41:56 +08:00
class DimensionTable extends Component {
2023-04-12 10:47:51 +08:00
constructor(props) {
super(props);
this.state = {
loading: false,
dataSource: [],
pageInfo: {
2023-04-19 09:29:38 +08:00
current: 1, pageSize: 10, total: 0
2023-04-12 10:47:51 +08:00
}
};
}
componentDidMount() {
this.dimensionList();
}
dimensionList = (extra = {}) => {
const { pageInfo } = this.state;
this.setState({ loading: true });
dimensionList({ ...pageInfo, ...extra }).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
2023-04-19 09:29:38 +08:00
const { pageNum: current, pageSize, total, list: dataSource } = data;
2023-04-12 10:47:51 +08:00
this.setState({
dataSource,
pageInfo: {
...pageInfo,
2023-04-19 09:29:38 +08:00
current, pageSize, total
2023-04-12 10:47:51 +08:00
}
});
}
}).catch(() => this.setState({ loading: false }));
};
dimensionDelete = (payload) => {
Modal.confirm({
2023-08-09 10:35:49 +08:00
title: getLabel(131329, "信息确认"),
content: getLabel(388758, "确认要删除吗?"),
2023-04-12 10:47:51 +08:00
onOk: () => {
dimensionDelete(payload).then(({ status, errormsg }) => {
if (status) {
2023-08-09 10:35:49 +08:00
message.success(getLabel(502230, "删除成功"));
2023-04-12 10:47:51 +08:00
this.dimensionList();
} else {
2023-08-09 10:35:49 +08:00
message.error(errormsg || getLabel(20462, "删除失败"));
2023-04-12 10:47:51 +08:00
}
});
}
});
};
2023-04-11 13:41:56 +08:00
render() {
2023-04-12 10:47:51 +08:00
const { dataSource, loading, pageInfo } = this.state;
const { onEdit } = this.props;
const pagination = {
...pageInfo,
2023-08-09 10:35:49 +08:00
showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`,
2023-04-12 10:47:51 +08:00
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: (current, pageSize) => {
this.setState({
pageInfo: { ...pageInfo, current, pageSize }
}, () => this.dimensionList());
},
onChange: current => {
this.setState({
pageInfo: { ...pageInfo, current }
}, () => this.dimensionList());
}
};
const columns = [
2023-08-09 10:35:49 +08:00
{ dataIndex: "dimName", title: getLabel(506800, "统计维度") },
{ dataIndex: "remark", title: getLabel(433, "描述") },
{ dataIndex: "dimType", title: getLabel(389137, "维度类型") },
2023-04-12 10:47:51 +08:00
{
2023-08-09 10:35:49 +08:00
dataIndex: "operate", title: getLabel(30585, "操作"),
2023-04-12 10:47:51 +08:00
render: (_, record) => {
return (
<span className="space10">
{
record.canEdit &&
2023-08-09 10:35:49 +08:00
<a href="javascript: void(0);" onClick={() => onEdit(record.id)}>{getLabel(501169, "编辑")}</a>
}
{
record.canDelete &&
<a href="javascript: void(0);"
2023-08-09 10:35:49 +08:00
onClick={() => this.dimensionDelete([record.id])}>{getLabel(535052, "删除")}</a>
}
2023-04-12 10:47:51 +08:00
</span>
);
}
}
];
2023-04-11 13:41:56 +08:00
return (
2023-04-12 10:47:51 +08:00
<WeaTable
rowKey="id"
className="dimensionTableWrapper"
dataSource={dataSource}
pagination={pagination}
loading={loading}
columns={columns}
/>
2023-04-11 13:41:56 +08:00
);
}
}
export default DimensionTable;