diff --git a/pc4mobx/hrmSalary/pages/declare/generateDeclarationDetail.js b/pc4mobx/hrmSalary/pages/declare/generateDeclarationDetail.js index b72af3c1..cdfe5a73 100644 --- a/pc4mobx/hrmSalary/pages/declare/generateDeclarationDetail.js +++ b/pc4mobx/hrmSalary/pages/declare/generateDeclarationDetail.js @@ -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 window.pointerXY(e)} + title={text} + > + {text} + ; + } + }; + } + return { + ...item, + render: (text) => { + return {text}; + } + }; + }) + }); } - 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 (
- +
); }; - const renderLeftOperation = () => { return (
@@ -75,32 +98,37 @@ export default class GenerateDeclarationDetail extends React.Component {
); }; + 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 (
- { - this.pageInfo.current = value; - this.handlePageChange(); - }} - onShowSizeChange={(current, pageSize) => { - this.pageInfo = { current, pageSize }; - this.handlePageChange(); - }} +
diff --git a/pc4mobx/hrmSalary/pages/declare/index.js b/pc4mobx/hrmSalary/pages/declare/index.js index b0ec9c95..b56d1f1a 100644 --- a/pc4mobx/hrmSalary/pages/declare/index.js +++ b/pc4mobx/hrmSalary/pages/declare/index.js @@ -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()); };