salary-management-front/pc4mobx/hrmSalary/pages/declare/generateDeclarationDetail.js

105 lines
3.9 KiB
JavaScript
Raw Normal View History

2022-07-06 18:11:54 +08:00
import React from "react";
import { inject, observer } from "mobx-react";
2025-01-03 15:49:53 +08:00
import { WeaLocaleProvider, WeaTable, WeaTop } from "ecCom";
2022-07-06 18:11:54 +08:00
import { getQueryString } from "../../util/url";
2023-03-29 14:29:05 +08:00
import * as API from "../../apis/declare";
import { Button } from "antd";
import "./index.less";
2022-03-18 10:38:43 +08:00
2025-01-03 15:49:53 +08:00
const { getLabel } = WeaLocaleProvider;
2023-03-29 14:29:05 +08:00
@inject("taxAgentStore")
2022-04-20 15:28:40 +08:00
@observer
2022-03-18 10:38:43 +08:00
export default class GenerateDeclarationDetail extends React.Component {
2022-07-06 18:11:54 +08:00
constructor(props) {
super(props);
2023-03-29 14:29:05 +08:00
this.state = {
2025-01-03 15:49:53 +08:00
loading: false, dataSource: [], columns: [], declareInfo: {},
pageInfo: { current: 1, pageSize: 10, total: 0 }
2023-03-29 14:29:05 +08:00
};
2022-07-06 18:11:54 +08:00
}
2022-04-20 15:28:40 +08:00
2025-01-03 17:14:33 +08:00
componentDidMount() {
2023-03-29 14:29:05 +08:00
this.getDetailList();
this.getDeclareInfo();
2022-07-06 18:11:54 +08:00
}
2022-06-07 09:08:36 +08:00
2023-03-29 14:29:05 +08:00
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({
2025-01-03 15:49:53 +08:00
dataSource, pageInfo: { ...pageInfo, current, pageSize, total },
2023-03-29 14:29:05 +08:00
columns: _.map(_.filter(columns, it => it.dataIndex !== "jobNum"), item => {
if (item.dataIndex === "username") {
return {
2025-01-03 15:49:53 +08:00
...item, width: 180,
render: (text, record) => (<a className="ellipsis" href={`javaScript:openhrm(${record.employeeId});`}
onClick={e => window.pointerXY(e)}
title={text}>{text}</a>)
2023-03-29 14:29:05 +08:00
};
}
return {
2025-01-03 15:49:53 +08:00
...item, width: (item.dataIndex === "cardType" || item.dataIndex === "cardNum") ? 180 : 100,
render: (text) => (<span className="ellipsis" title={text}>{text}</span>)
2023-03-29 14:29:05 +08:00
};
})
});
2022-07-06 18:11:54 +08:00
}
});
2023-03-29 14:29:05 +08:00
};
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");
};
2025-01-03 15:49:53 +08:00
renderTitle = () => {
const { declareInfo } = this.state;
return (<React.Fragment>
<span>{getLabel(111, "薪资所属月")}{declareInfo.salaryMonth}</span>
<span style={{ marginLeft: "10px" }}>{getLabel(111, "个税扣缴义务人")}{declareInfo.taxAgentName}</span>
</React.Fragment>);
};
2022-06-07 09:08:36 +08:00
2022-07-06 18:11:54 +08:00
render() {
2025-01-03 15:49:53 +08:00
const { loading, pageInfo, columns, dataSource } = this.state;
2023-03-29 14:29:05 +08:00
const { taxAgentStore: { showOperateBtn } } = this.props;
2025-01-03 15:49:53 +08:00
const buttons = showOperateBtn ? [<Button type="primary"
onClick={this.handleExport}>{getLabel(111, "导出全部")}</Button>] : [];
2023-03-29 14:29:05 +08:00
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());
}
};
2025-01-03 15:49:53 +08:00
return (<WeaTop title={this.renderTitle()} icon={<i className="icon-coms-fa"/>} iconBgcolor="#F14A2D"
buttons={buttons}>
<div className="declare-detail-table-container">
<WeaTable columns={columns} dataSource={dataSource} pagination={pagination} loading={loading}
2025-01-03 15:50:59 +08:00
scroll={{ x: 1200, y: `calc(100vh - 186px)` }}/>
2022-07-06 18:11:54 +08:00
</div>
2025-01-03 15:49:53 +08:00
</WeaTop>);
2022-07-06 18:11:54 +08:00
}
}