个税申报表页面分页bug
This commit is contained in:
parent
3368f121fd
commit
473ce9e204
|
|
@ -1,72 +1,95 @@
|
|||
import React from "react";
|
||||
import CustomTab from "../../components/customTab";
|
||||
import { Button } from "antd";
|
||||
import "./index.less";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { getQueryString } from "../../util/url";
|
||||
import CustomPaginationTable from "../../components/customPaginationTable";
|
||||
import * as API from "../../apis/declare";
|
||||
import { Button } from "antd";
|
||||
import UnifiedTable from "../../components/UnifiedTable";
|
||||
import "./index.less";
|
||||
|
||||
@inject("declareStore")
|
||||
@inject("taxAgentStore")
|
||||
@observer
|
||||
export default class GenerateDeclarationDetail extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.id = getQueryString("id");
|
||||
this.pageInfo = { current: 1, pageSize: 10 };
|
||||
this.state = {
|
||||
loading: false,
|
||||
dataSource: [],
|
||||
columns: [],
|
||||
pageInfo: { current: 1, pageSize: 10, total: 0 },
|
||||
declareInfo: {}
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const { declareStore: { getDetailList, getDeclareInfo } } = this.props;
|
||||
getDetailList(this.id);
|
||||
getDeclareInfo(this.id);
|
||||
this.getDetailList();
|
||||
this.getDeclareInfo();
|
||||
}
|
||||
|
||||
// 导出
|
||||
handleExport() {
|
||||
const url = `${window.location.origin}/api/bs/hrmsalary/taxdeclaration/export?taxDeclarationId=${this.id}`;
|
||||
window.open(url, "_self");
|
||||
}
|
||||
|
||||
getColumns() {
|
||||
const { declareStore: { datailColumns } } = this.props;
|
||||
let columns = [...datailColumns];
|
||||
return columns.map(item => {
|
||||
item = { ...item };
|
||||
item.width = "150px";
|
||||
if (item.dataIndex == "employeeName") {
|
||||
item.fixed = "left";
|
||||
getDetailList = () => {
|
||||
const { pageInfo } = this.state;
|
||||
const payload = {
|
||||
...pageInfo, taxDeclarationIdStr: getQueryString("id")
|
||||
};
|
||||
this.setState({ loading: true });
|
||||
API.getDetailList(payload).then(({ status, data }) => {
|
||||
this.setState({ loading: false });
|
||||
if (status) {
|
||||
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
|
||||
this.setState({
|
||||
dataSource,
|
||||
pageInfo: {
|
||||
...pageInfo,
|
||||
current, pageSize, total
|
||||
},
|
||||
columns: _.map(_.filter(columns, it => it.dataIndex !== "jobNum"), item => {
|
||||
if (item.dataIndex === "username") {
|
||||
return {
|
||||
...item,
|
||||
render: (text, record) => {
|
||||
return <a className="ellipsis"
|
||||
href={`javaScript:openhrm(${record.employeeId});`}
|
||||
onClick={e => window.pointerXY(e)}
|
||||
title={text}
|
||||
>
|
||||
{text}
|
||||
</a>;
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
render: (text) => {
|
||||
return <span className="ellipsis" title={text}>{text}</span>;
|
||||
}
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
handlePageChange() {
|
||||
const { declareStore: { getDetailList, getDeclareInfo } } = this.props;
|
||||
getDetailList(this.id, this.pageInfo);
|
||||
}
|
||||
|
||||
};
|
||||
getDeclareInfo = () => {
|
||||
API.getDeclareInfo({ taxDeclarationId: getQueryString("id") }).then(({ status, data: declareInfo }) => {
|
||||
if (status) this.setState({ declareInfo });
|
||||
});
|
||||
};
|
||||
// 导出
|
||||
handleExport = () => {
|
||||
const url = `${window.location.origin}/api/bs/hrmsalary/taxdeclaration/export?taxDeclarationId=${getQueryString("id")}`;
|
||||
window.open(url, "_self");
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
declareStore: {
|
||||
detailDataSource,
|
||||
detailTableStore,
|
||||
declareInfo,
|
||||
datailColumns,
|
||||
detailPageInfo
|
||||
}
|
||||
} = this.props;
|
||||
const { declareInfo, loading, pageInfo, columns, dataSource } = this.state;
|
||||
const { taxAgentStore: { showOperateBtn } } = this.props;
|
||||
|
||||
const renderRightOperation = () => {
|
||||
return (
|
||||
<div style={{ display: "inline-block" }}>
|
||||
<Button type="primary" onClick={() => {
|
||||
this.handleExport();
|
||||
}}>导出</Button>
|
||||
<Button type="primary" onClick={this.handleExport}>导出</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const renderLeftOperation = () => {
|
||||
return (
|
||||
<div style={{ display: "inline-block", lineHeight: "47px" }}>
|
||||
|
|
@ -75,32 +98,37 @@ export default class GenerateDeclarationDetail extends React.Component {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
const pagination = {
|
||||
...pageInfo,
|
||||
showTotal: (total) => `共 ${total} 条`,
|
||||
pageSizeOptions: ["10", "20", "50", "100"],
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
onShowSizeChange: (current, pageSize) => {
|
||||
this.setState({
|
||||
pageInfo: { ...pageInfo, current, pageSize }
|
||||
}, () => this.getDetailList());
|
||||
},
|
||||
onChange: (current) => {
|
||||
this.setState({
|
||||
pageInfo: { ...pageInfo, current }
|
||||
}, () => this.getDetailList());
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="generateDeclarationDetail">
|
||||
<CustomTab
|
||||
searchOperationItem={
|
||||
renderRightOperation()
|
||||
}
|
||||
leftOperation={
|
||||
renderLeftOperation()
|
||||
}
|
||||
searchOperationItem={showOperateBtn && renderRightOperation()}
|
||||
leftOperation={renderLeftOperation()}
|
||||
/>
|
||||
<div className="tableWrapper">
|
||||
<CustomPaginationTable
|
||||
dataSource={detailDataSource}
|
||||
columns={this.getColumns()}
|
||||
total={detailPageInfo.total}
|
||||
current={detailPageInfo.pageNum}
|
||||
pageSize={this.pageInfo.pageSize}
|
||||
scroll={{ x: 2300 }}
|
||||
onPageChange={(value) => {
|
||||
this.pageInfo.current = value;
|
||||
this.handlePageChange();
|
||||
}}
|
||||
onShowSizeChange={(current, pageSize) => {
|
||||
this.pageInfo = { current, pageSize };
|
||||
this.handlePageChange();
|
||||
}}
|
||||
<UnifiedTable
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={dataSource}
|
||||
pagination={pagination}
|
||||
loading={loading}
|
||||
xWidth={columns.length * 120}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,11 @@ export default class Declare extends React.Component {
|
|||
if (status) {
|
||||
const { columns, list: dataSource, total, pageNum: current, pageSize } = data;
|
||||
this.setState({
|
||||
columns, dataSource, total, current, pageSize
|
||||
columns, dataSource,
|
||||
pageInfo: {
|
||||
...pageInfo,
|
||||
total, current, pageSize
|
||||
}
|
||||
});
|
||||
}
|
||||
}).catch(() => this.setState({ loading: false }));
|
||||
|
|
@ -67,9 +71,11 @@ export default class Declare extends React.Component {
|
|||
};
|
||||
handleDataPageChange = (current, pageSize = 10) => {
|
||||
this.setState({
|
||||
...this.state.pageInfo,
|
||||
current,
|
||||
pageSize
|
||||
pageInfo: {
|
||||
...this.state.pageInfo,
|
||||
current,
|
||||
pageSize
|
||||
}
|
||||
}, () => this.getDeclareList());
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue