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: {
|
|
|
|
|
current: 0, pageSize: 10, total: 0
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
const { pageNum: curren, pageSize, total, list: dataSource } = data;
|
|
|
|
|
this.setState({
|
|
|
|
|
dataSource,
|
|
|
|
|
pageInfo: {
|
|
|
|
|
...pageInfo,
|
|
|
|
|
curren, pageSize, total
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => this.setState({ loading: false }));
|
|
|
|
|
};
|
|
|
|
|
dimensionDelete = (payload) => {
|
|
|
|
|
Modal.confirm({
|
2023-04-17 17:32:16 +08:00
|
|
|
title: getLabel(111, "信息确认"),
|
|
|
|
|
content: getLabel(111, "确认要删除吗?"),
|
2023-04-12 10:47:51 +08:00
|
|
|
onOk: () => {
|
|
|
|
|
dimensionDelete(payload).then(({ status, errormsg }) => {
|
|
|
|
|
if (status) {
|
2023-04-17 17:32:16 +08:00
|
|
|
message.success(getLabel(111, "删除成功"));
|
2023-04-12 10:47:51 +08:00
|
|
|
this.dimensionList();
|
|
|
|
|
} else {
|
2023-04-17 17:32:16 +08:00
|
|
|
message.error(errormsg || getLabel(111, "删除失败"));
|
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-04-17 17:32:16 +08:00
|
|
|
showTotal: total => `${getLabel(111, "共")} ${total} ${getLabel(111, "条")}`,
|
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-04-17 17:32:16 +08:00
|
|
|
{ dataIndex: "dimName", title: getLabel(111, "统计维度") },
|
|
|
|
|
{ dataIndex: "remark", title: getLabel(111, "描述") },
|
|
|
|
|
{ dataIndex: "dimType", title: getLabel(111, "维度类型") },
|
2023-04-12 10:47:51 +08:00
|
|
|
{
|
2023-04-17 17:32:16 +08:00
|
|
|
dataIndex: "operate", title: getLabel(111, "操作"),
|
2023-04-12 10:47:51 +08:00
|
|
|
render: (_, record) => {
|
|
|
|
|
return (
|
|
|
|
|
<span className="space10">
|
2023-04-17 17:32:16 +08:00
|
|
|
<a href="javascript: void(0);" onClick={() => onEdit(record.id)}>{getLabel(111, "编辑")}</a>
|
|
|
|
|
<a href="javascript: void(0);"
|
|
|
|
|
onClick={() => this.dimensionDelete([record.id])}>{getLabel(111, "删除")}</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;
|