/* * Author: 黎永顺 * name: 个税申报重构- 申报 * Description: * Date: 2023/10/12 */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; import { WeaDialog, WeaLocaleProvider, WeaTools } from "ecCom"; import { Button, message } from "antd"; import { getSearchs } from "../../../../util"; import { saveDeclare } from "../../../../apis/declare"; import { declareConditions } from "./condition"; import { postFetch } from "../../../../util/request"; import * as API from "../../../../apis/ruleconfig"; const getKey = WeaTools.getKey; const getLabel = WeaLocaleProvider.getLabel; @inject("declareStore") @observer class Index extends Component { constructor(props) { super(props); this.state = { conditions: [], loading: false }; } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) this.getTaxAgentSelectListAsAdmin(nextProps); if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.declareStore.initDeclareForm(); } getTaxAgentSelectListAsAdmin = async (props) => { const { data: sysinfo } = await API.sysinfo(); const { declareStore: { declareForm } } = props; postFetch("/api/bs/hrmsalary/taxAgent/listAuth", { filterType: "ADMIN_DATA" }) .then(({ status, data }) => { if (status) { this.setState({ conditions: _.map(declareConditions, item => ({ ...item, items: _.map(item.items, o => { if (getKey(o) === "taxAgentId") { return { ...o, label: getLabel(o.lanId, o.label), options: _.map(data, g => ({ key: String(g.id), showname: g.name })) // helpfulTitle: getLabel(563420, "提示:可选择单个个税扣缴义务人进行申报,若不选择,则批量对管理下的所有个税扣缴义务人进行申报;") }; } else if (getKey(o) === "salaryMonthStr") { return { ...o, label: sysinfo["TAX_DECLARATION_DATE_TYPE"] === "1" ? getLabel(111, "税款所属期") : getLabel(111, "薪资所属月") }; } return { ...o, label: getLabel(o.lanId, o.label) }; }) })) }, () => declareForm.initFormFields(this.state.conditions)); } }); }; save = () => { const { declareStore: { declareForm } } = this.props; declareForm.validateForm().then(f => { if (f.isValid) { const payload = declareForm.getFormParams(); this.setState({ loading: true }); saveDeclare({ ...payload, taxCycle: `${payload.salaryMonthStr}-01`, salaryDate: `${payload.salaryMonthStr}-01` }).then(({ status, errormsg }) => { this.setState({ loading: false }); if (status) { message.success(getLabel(30700, "操作成功")); this.props.onCancel("refresh"); } else { message.error(errormsg); } }).catch(() => this.setState({ loading: false })); } else { f.showErrors(); } }); }; render() { const { conditions, loading } = this.state; const { declareStore: { declareForm } } = this.props; return ( {getLabel(543618, "生成申报表")} ]} >
{getSearchs(declareForm, conditions, 1, false)}
); } } export default Index;