93 lines
3.1 KiB
JavaScript
93 lines
3.1 KiB
JavaScript
/*
|
|
* 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 { getTaxAgentSelectListAsAdmin } from "../../../../apis/taxAgent";
|
|
import { saveDeclare } from "../../../../apis/declare";
|
|
import { declareConditions } from "./condition";
|
|
|
|
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 = (props) => {
|
|
const { declareStore: { declareForm } } = props;
|
|
getTaxAgentSelectListAsAdmin().then(({ status, data }) => {
|
|
if (status) {
|
|
this.setState({
|
|
conditions: _.map(declareConditions, item => ({
|
|
...item,
|
|
items: _.map(item.items, o => {
|
|
if (getKey(o) === "taxAgentId") {
|
|
return {
|
|
...o, options: _.map(data, g => ({ key: g.id, showname: g.content }))
|
|
// helpfulTitle: getLabel(563420, "提示:可选择单个个税扣缴义务人进行申报,若不选择,则批量对管理下的所有个税扣缴义务人进行申报;")
|
|
};
|
|
}
|
|
return { ...o };
|
|
})
|
|
}))
|
|
}, () => 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 }).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 (
|
|
<WeaDialog
|
|
{...this.props} style={{ width: 500 }} initLoadCss
|
|
buttons={[
|
|
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(543618, "生成申报表")}</Button>
|
|
]}
|
|
>
|
|
<div className="declare-dialog-layout">{getSearchs(declareForm, conditions, 1, false)}</div>
|
|
</WeaDialog>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Index;
|