salary-management-front/pc4mobx/hrmSalary/pages/custom-pages/liante/cbsDetail/pushedDetailList.js

98 lines
3.2 KiB
JavaScript

/*
* CBS推送详情
* 未推送列表
* @Author: 黎永顺
* @Date: 2025/5/9
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTable } from "ecCom";
import * as API from "../../../../apis/custom-apis/liante";
const getLabel = WeaLocaleProvider.getLabel;
class PushedDetailList extends Component {
constructor(props) {
super(props);
this.state = {
loading: false, columns: [], dataSource: [],
pageInfo: { current: 1, pageSize: 10, total: 0 }
};
}
componentDidMount() {
this.getPushCBSInfoList();
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.selectedKey !== this.props.selectedKey) {
this.setState({
columns: [], dataSource: [], pageInfo: { current: 1, pageSize: 10, total: 0 }
}, () => this.getPushCBSInfoList(nextProps));
}
if (nextProps.isQuery !== this.props.isQuery) this.getPushCBSInfoList(nextProps);
}
getPushCBSInfoList = (props) => {
const { pageInfo } = this.state, {
selectedKey: pushStatus, params
} = props || this.props, { salaryCbsId } = params;
const payload = { ...pageInfo, pushStatus, salaryCbsId };
this.setState({ loading: true });
API.getPushCBSInfoList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
this.setState({
dataSource, pageInfo: { current, pageSize, total },
columns: [...columns, {
dataIndex: "options", title: getLabel(30585, "操作"),
width: 80, render: (_, record) => (<React.Fragment>
<a href="javascript:void(0);" onClick={() => this.props.pushDataToCBS([record.id], false)}>
{getLabel(111, "推送")}
</a>
</React.Fragment>)
}]
});
}
});
};
render() {
const { dataSource, columns, pageInfo, loading } = this.state, {
selectedKey, selectedRowKeys, setSelectedRowKeys
} = this.props;
const pagination = {
...pageInfo,
showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`,
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: (current, pageSize) => {
this.setState({
pageInfo: { ...pageInfo, current, pageSize }
}, () => this.getPushCBSInfoList());
},
onChange: current => {
this.setState({
pageInfo: { ...pageInfo, current }
}, () => this.getPushCBSInfoList());
}
};
const rowSelection = {
selectedRowKeys, onChange: setSelectedRowKeys
};
return (<div className="CBSDetailList">
<WeaTable
rowKey="id" scroll={{ x: 1200, y: "calc(100vh - 240px)" }}
dataSource={dataSource} loading={loading} pagination={pagination}
rowSelection={selectedKey !== "1" ? rowSelection : null}
columns={selectedKey === "1" ? _.filter(columns, o => o.dataIndex !== "options") : columns}/>
</div>);
}
}
export default PushedDetailList;