import React from "react"; import { inject, observer } from "mobx-react"; import { Button, DatePicker, message, Modal } from "antd"; import { WeaLocaleProvider, WeaNewScroll, WeaTop } from "ecCom"; 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"; import moment from "moment"; const getLabel = WeaLocaleProvider.getLabel; const { MonthPicker } = DatePicker; @inject("taxAgentStore") @observer export default class Declare extends React.Component { constructor(props) { super(props); this.state = { showWithDrawBtn: false, declarationModalVisible: false, startDate: moment(new Date()).startOf("year").format("YYYY-MM"), endDate: moment(new Date()).startOf("month").format("YYYY-MM"), loading: false, dataSource: [], columns: [], pageInfo: { current: 1, pageSize: 10, total: 0 } }; } componentWillMount() { const { taxAgentStore: { getTaxAgentSelectListAsAdmin } } = this.props; this.getDeclareList(); this.sysConfCodeRule(); getTaxAgentSelectListAsAdmin(); } 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({ columns, dataSource, pageInfo: { ...pageInfo, total, current, pageSize } }); } }).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, "撤回失败")); } }); }; // 日期区间改变事件 handleRangePickerChange = (type, value) => { this.setState({ [type]: value ? moment(value).format("YYYY-MM") : moment().format("YYYY-MM"), pageInfo: { ...this.state.pageInfo, current: 1 } }, () => { this.getDeclareList(); }); }; handleSearch = () => { this.setState({ declarationModalVisible: false }, () => this.getDeclareList()); }; handleDataPageChange = (current, pageSize = 10) => { this.setState({ pageInfo: { ...this.state.pageInfo, current, pageSize } }, () => this.getDeclareList()); }; render() { const { taxAgentStore: { showOperateBtn } } = this.props; const { loading, columns, dataSource, pageInfo, showWithDrawBtn } = this.state; const renderRightOperation = () => { const { startDate, endDate } = this.state; return (