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

217 lines
7.5 KiB
JavaScript
Raw Normal View History

2022-06-07 18:24:05 +08:00
import React from "react";
import { inject, observer } from "mobx-react";
import { Button, DatePicker, message, Modal } from "antd";
import { WeaLocaleProvider, WeaNewScroll, WeaTop } from "ecCom";
2022-06-07 18:24:05 +08:00
import CustomTab from "../../components/customTab";
import CustomTable from "../../components/customTable";
import GenerateModal from "./generateModal";
import { getDeclareList, withDrawTaxDeclaration } from "../../apis/declare";
import { sysConfCodeRule } from "../../apis/ruleconfig";
2022-06-07 18:24:05 +08:00
import moment from "moment";
2022-02-25 09:24:56 +08:00
const getLabel = WeaLocaleProvider.getLabel;
const { MonthPicker } = DatePicker;
2023-02-13 10:41:40 +08:00
@inject("taxAgentStore")
2022-02-25 09:24:56 +08:00
@observer
2022-03-10 10:58:26 +08:00
export default class Declare extends React.Component {
2022-02-25 09:24:56 +08:00
constructor(props) {
super(props);
this.state = {
showWithDrawBtn: false,
2022-04-20 15:28:40 +08:00
declarationModalVisible: false,
startDate: moment(new Date()).startOf("year").format("YYYY-MM"),
2023-02-13 10:41:40 +08:00
endDate: moment(new Date()).startOf("month").format("YYYY-MM"),
loading: false,
dataSource: [],
columns: [],
pageInfo: {
current: 1,
pageSize: 10,
total: 0
2022-03-18 10:38:43 +08:00
}
2023-02-13 10:41:40 +08:00
};
2022-02-25 09:24:56 +08:00
}
2022-04-20 15:28:40 +08:00
componentWillMount() {
2023-02-13 10:41:40 +08:00
const { taxAgentStore: { getTaxAgentSelectListAsAdmin } } = this.props;
this.getDeclareList();
this.sysConfCodeRule();
2022-07-06 18:11:54 +08:00
getTaxAgentSelectListAsAdmin();
2022-04-20 15:28:40 +08:00
}
2023-02-13 10:41:40 +08:00
getDeclareList = () => {
const { pageInfo, startDate: fromSalaryMonthStr, endDate: endSalaryMonthStr } = this.state;
const payload = {
fromSalaryMonthStr, endSalaryMonthStr,
...pageInfo
};
this.setState({ loading: true });
getDeclareList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const { columns, list: dataSource, total, pageNum: current, pageSize } = data;
this.setState({
2023-03-29 14:29:05 +08:00
columns, dataSource,
pageInfo: {
...pageInfo,
total, current, pageSize
}
2023-02-13 10:41:40 +08:00
});
}
}).catch(() => this.setState({ loading: false }));
};
sysConfCodeRule = () => {
sysConfCodeRule({ code: "WITHDRAW_TAX_DECLARATION" }).then(({ status, data }) => {
if (status && data === "1") this.setState({ showWithDrawBtn: data === "1" });
});
};
withDrawTaxDeclaration = (taxDeclarationId) => {
withDrawTaxDeclaration({ taxDeclarationId }).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(111, "撤回成功"));
this.getDeclareList();
} else {
message.error(errormsg || getLabel(111, "撤回失败"));
}
});
};
2022-04-25 10:03:07 +08:00
// 日期区间改变事件
2023-02-13 10:41:40 +08:00
handleRangePickerChange = (type, value) => {
2022-04-20 15:28:40 +08:00
this.setState({
2023-02-13 10:41:40 +08:00
[type]: value ? moment(value).format("YYYY-MM") : moment().format("YYYY-MM"),
pageInfo: { ...this.state.pageInfo, current: 1 }
}, () => {
2023-02-13 10:41:40 +08:00
this.getDeclareList();
2022-06-07 18:24:05 +08:00
});
2023-02-13 10:41:40 +08:00
};
handleSearch = () => {
this.setState({ declarationModalVisible: false }, () => this.getDeclareList());
};
handleDataPageChange = (current, pageSize = 10) => {
this.setState({
2023-03-29 14:29:05 +08:00
pageInfo: {
...this.state.pageInfo,
current,
pageSize
}
2023-02-13 10:41:40 +08:00
}, () => this.getDeclareList());
};
2022-06-07 09:08:36 +08:00
2022-02-25 09:24:56 +08:00
render() {
2023-02-13 10:41:40 +08:00
const { taxAgentStore: { showOperateBtn } } = this.props;
const { loading, columns, dataSource, pageInfo, showWithDrawBtn } = this.state;
2022-03-18 10:38:43 +08:00
const renderRightOperation = () => {
const { startDate, endDate } = this.state;
2022-06-07 18:24:05 +08:00
return (
<div style={{ display: "inline-block" }}>
<MonthPicker
value={startDate}
disabledDate={(current) => {
return current && endDate && current.getTime() > new Date(endDate).getTime();
}}
format="YYYY-MM"
onChange={(val) => this.handleRangePickerChange("startDate", val)}
/>
<span className="to" style={{ margin: "0 10px" }}></span>
<MonthPicker
value={endDate}
disabledDate={(current) => {
return current && startDate && current.getTime() < new Date(startDate).getTime();
}}
format="YYYY-MM"
onChange={(val) => this.handleRangePickerChange("endDate", val)}
2022-06-07 18:24:05 +08:00
/>
2022-06-21 14:27:16 +08:00
{
showOperateBtn &&
<Button
type="primary"
style={{ marginLeft: "10px", position: "relative", top: "-2px" }}
2022-06-21 14:27:16 +08:00
onClick={() => {
this.setState({ declarationModalVisible: true });
}}>
生成申报单
</Button>
}
2022-06-07 18:24:05 +08:00
</div>
);
};
2022-03-18 10:38:43 +08:00
2022-02-25 09:24:56 +08:00
return (
<div className="mySalaryBenefitsWrapper">
2023-02-13 10:41:40 +08:00
<WeaTop title="个税申报表" icon={<i className="icon-coms-fa"/>}
iconBgcolor="#F14A2D" showDropIcon={false}
2022-02-25 09:24:56 +08:00
>
2022-12-01 14:28:30 +08:00
<CustomTab searchOperationItem={renderRightOperation()}/>
2023-02-13 10:41:40 +08:00
<div className="tableWrapper">
<WeaNewScroll height="100%">
<CustomTable
loading={loading}
columns={[
...columns,
{
title: "操作",
dataIndex: "operate",
render: (text, record) => {
return (
<React.Fragment>
<a href="javascript:void(0);"
onClick={() => {
window.open(
"/spa/hrmSalary/static/index.html#/main/hrmSalary/generateDeclarationDetail?id=" +
record.id
);
}}>
查看
</a>
{
showWithDrawBtn &&
<a
href="javascript:void(0);" style={{ marginLeft: 10 }}
onClick={() => {
Modal.confirm({
title: getLabel(111, "信息确认"),
content: getLabel(111, "确认撤回该条数据吗?"),
onOk: () => this.withDrawTaxDeclaration(record.id)
});
}}
>
{getLabel(111, "撤回")}
</a>
}
</React.Fragment>
2023-02-13 10:41:40 +08:00
);
}
}
]}
dataSource={dataSource}
pagination={{
onChange: (value) => {
this.handleDataPageChange(value);
},
total: pageInfo.total,
showTotal: (total) => `${total}`,
current: pageInfo.current,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
showQuickJumper: true,
pageSize: pageInfo.pageSize,
onShowSizeChange: (current, pageSize) => {
this.handleDataPageChange(current, pageSize);
}
}}
/>
</WeaNewScroll>
</div>
2022-12-01 14:28:30 +08:00
</WeaTop>
2022-06-07 18:24:05 +08:00
{this.state.declarationModalVisible && (
<GenerateModal
2023-02-13 10:41:40 +08:00
onGenerate={this.handleSearch}
2022-06-07 18:24:05 +08:00
visible={this.state.declarationModalVisible}
2023-02-13 10:41:40 +08:00
onCancel={() => this.setState({ declarationModalVisible: false })}
2022-03-18 10:38:43 +08:00
/>
2022-06-07 18:24:05 +08:00
)}
2022-02-25 09:24:56 +08:00
</div>
2022-06-07 18:24:05 +08:00
);
2022-02-25 09:24:56 +08:00
}
}