salary-management-front/pc4mobx/hrmSalary/pages/declare/components/declareTablelist/index.js

186 lines
6.4 KiB
JavaScript

/*
* Author: 黎永顺
* name: 个税申报重构-列表
* Description:
* Date: 2023/10/12
*/
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTable } from "ecCom";
import { Dropdown, Menu, message, Modal, Tag } from "antd";
import { getDeclareList, taxdeclarationUpdateIcon, withDrawTaxDeclaration } from "../../../../apis/declare";
import { sysConfCodeRule, sysinfo } from "../../../../apis/ruleconfig";
const getLabel = WeaLocaleProvider.getLabel;
class Index extends Component {
constructor(props) {
super(props);
this.state = {
loading: false, columns: [], dataSource: [], showWithDrawBtn: false,
pageInfo: { current: 1, pageSize: 10, total: 0 }
};
}
componentDidMount() {
this.getDeclareList(this.props);
this.sysConfCodeRule();
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.isRefresh !== this.props.isRefresh) this.getDeclareList(nextProps);
}
sysConfCodeRule = () => {
const { showOperateBtn } = this.props;
sysConfCodeRule({ code: "WITHDRAW_TAX_DECLARATION" }).then(({ status, data }) => {
if (status && data === "1") this.setState({ showWithDrawBtn: data === "1" && showOperateBtn });
});
};
getDeclareList = async (props) => {
const { data: sysData } = await sysinfo();
const { pageInfo } = this.state, { queryParams } = props;
const { dateRange, ...extra } = queryParams;
const [fromSalaryMonth, endSalaryMonth] = dateRange || [];
const params = { fromSalaryMonth: fromSalaryMonth + "-01", endSalaryMonth: endSalaryMonth + "-01", ...extra };
const payload = { ...pageInfo, ...params };
this.setState({ loading: true });
getDeclareList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
let { columns, list: dataSource, pageNum, pageSize, total } = data;
sysData["TAX_DECLARATION_DATE_TYPE"] === "1" && (columns = _.filter(columns, o => o.dataIndex !== "salaryMonth"));
this.setState({
dataSource, pageInfo: { ...pageInfo, pageNum, pageSize, total },
columns: _.map(columns, o => {
const { dataIndex, displayIcon } = o;
let width = "";
switch (dataIndex) {
case "taxAgentName":
case "operateTime":
width = "15%";
break;
case "description":
width = "20%";
break;
default:
width = "10%";
break;
}
if (dataIndex === "taxDeclareStatusDesc") {
return {
...o, width,
render: (text, record) => {
return (<div className="declare-status-box">
{text}
{
displayIcon &&
<span title={getLabel(545219, "该个税申报表对应的核算数据被重新核算")} className="icon-span">
<Tag closable onClose={() => this.handleUpdateicon(record)}>
<i className="icon-coms02-Warning-01"/>
</Tag>
</span>
}
</div>);
}
};
}
return { ...o, width };
})
});
}
}).catch(() => this.setState({ loading: false }));
};
handleUpdateicon = (record) => {
const { id: taxDeclareRecordId } = record;
taxdeclarationUpdateIcon({ taxDeclareRecordId }).then(({ status, errormsg }) => {
this.getDeclareList(this.props);
if (status) {
message.success(getLabel(502230, "删除成功!"));
} else {
message.error(errormsg || getLabel(20462, "删除失败!"));
}
});
};
taxdeclarationDelete = (taxDeclarationId) => {
withDrawTaxDeclaration({ taxDeclarationId }).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(505793, "撤回成功"));
this.getDeclareList(this.props);
} else {
message.error(errormsg);
}
});
};
render() {
const { loading, dataSource, columns, pageInfo, showWithDrawBtn } = this.state;
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.getDeclareList(this.props));
},
onChange: current => {
this.setState({
pageInfo: { ...pageInfo, current }
}, () => this.getDeclareList(this.props));
}
};
return (
<WeaTable
rowKey="id"
dataSource={dataSource} loading={loading}
pagination={pagination} columns={[
...columns,
{
dataIndex: "operate", title: getLabel(30585, "操作"),
width: 170, render: (__, record) => {
const { id } = record;
return <React.Fragment>
<a
href={`${window.ecologyContentPath || ""}/spa/hrmSalary/static/index.html#/main/hrmSalary/declareDetail?id=${id}`}
target="_blank"
>
{getLabel(83110, "查看详情")}
</a>
{
showWithDrawBtn &&
<a
href="javascript:void(0);" style={{ marginLeft: 10 }}
onClick={() => {
Modal.confirm({
title: getLabel(131329, "信息确认"),
content: getLabel(543848, "确认撤回该条数据吗?"),
onOk: () => this.taxdeclarationDelete(id)
});
}}
>
{getLabel(32025, "撤回")}
</a>
}
<Dropdown overlay={
<Menu>
<Menu.Item>
<a href="javascript:void(0)"
onClick={() => this.props.onFilterLog("log", record.id)}>{getLabel(545781, "操作日志")}</a>
</Menu.Item>
</Menu>
}>
<a href="javascript:void(0)" style={{ marginLeft: 10 }}><i className="icon-coms-more"/></a>
</Dropdown>
</React.Fragment>;
}
}
]}
/>
);
}
}
export default Index;