salary-management-front/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataComp.js

95 lines
2.6 KiB
JavaScript

/*
* Author: 黎永顺
* name: 考勤数据
* Description:
* Date: 2023/2/24
*/
import React, { Component } from "react";
import { WeaTable } from "ecCom";
import { getAttendanceList } from "../../../../apis/attendance";
class AttendanceDataComp extends Component {
constructor(props) {
super(props);
this.state = {
loading: {
query: false
},
dataSource: [],
columns: [],
pageInfo: {
current: 1,
pageSize: 10,
total: 0
}
};
}
componentDidMount() {
this.getAttendanceList();
}
getAttendanceList = (extraPayload) => {
const { loading, pageInfo } = this.state;
const module = { ...pageInfo, ...extraPayload };
this.setState({ loading: { ...loading, query: true } });
getAttendanceList(module).then(({ status, data }) => {
this.setState({ loading: { ...loading, query: false } });
if (status) {
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
this.setState({
pageInfo: { ...pageInfo, current, pageSize, total },
dataSource,
columns
});
}
}).catch(() => this.setState({ loading: { ...loading, query: false } }));
};
render() {
const { dataSource, columns, pageInfo, loading } = this.state;
const { showOperateBtn, salaryYearMonth } = this.props;
const pagination = {
...pageInfo,
showTotal: total => `${total}`,
showQuickJumper: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: (current, pageSize) => {
this.setState({
pageInfo: { ...pageInfo, current, pageSize }
}, () => this.getAttendanceList({ salaryYearMonth: _.compact(salaryYearMonth) }));
},
onChange: current => {
this.setState({
pageInfo: { ...pageInfo, current }
}, () => this.getAttendanceList({ salaryYearMonth: _.compact(salaryYearMonth) }));
}
};
return (
<WeaTable
columns={[
...columns,
{
title: "操作",
width: 120,
dataIndex: "operate",
render: (text, record) => {
return (
<div className="linkWapper">
<a href="javascript: void(0);">查看</a>
{showOperateBtn && <a href="javascript: void(0);">删除</a>}
</div>
);
}
}
]}
dataSource={dataSource}
pagination={pagination}
loading={loading.query}
/>
);
}
}
export default AttendanceDataComp;