salary-management-front/pc4mobx/hrmSalary/pages/salary/components/taxDeclarationInfo.js

103 lines
3.3 KiB
JavaScript

/*
* Author: 黎永顺
* name: 报税信息
* Description:
* Date: 2022/12/1
*/
import React, { Component } from "react";
import { WeaBrowser, WeaFormItem, WeaInput, WeaSearchGroup, WeaSelect } from "ecCom";
import { fieldList } from "./constants";
import { taxReturnGetForm } from "../../../apis/taxAgent";
class TaxDeclarationInfo extends Component {
constructor(props) {
super(props);
this.state = {
fieldForm: {
name: "",
dutyParagraph: "",
taxDeclarationRegion: "",
areaNumber: "",
passwordVerifyType: "0",
realNameAccount: "",
realNameAccountPassword: "",
taxOnlinePassword: "",
registrationNo: "",
departmentCode: "",
taxInforVerifiyStatus: ""
},
fieldItem: []
};
}
componentDidMount() {
this.setState({
fieldItem: _.filter(fieldList, it => it.key !== "realNameAccount" && it.key !== "realNameAccountPassword")
}, () => {
this.taxReturnGetForm();
});
}
taxReturnGetForm = () => {
const { taxAgentId } = this.props;
taxReturnGetForm({ taxAgentId }).then((status, data) => {
console.log(data);
});
};
handleChangeValue = (key, value) => {
const { fieldForm } = this.state;
this.setState({
fieldForm: {
...fieldForm,
[key]: value
}
}, () => {
if (key === "passwordVerifyType" && this.state.fieldForm.passwordVerifyType === "2") {
this.setState({
fieldItem: _.filter(fieldList, it => it.key !== "taxOnlinePassword"),
fieldForm: { ...this.state.fieldForm, realNameAccount: "", realNameAccountPassword: "" }
});
} else if (key === "passwordVerifyType" && this.state.fieldForm.passwordVerifyType === "0") {
this.setState({
fieldItem: _.filter(fieldList, it => it.key !== "realNameAccount" && it.key !== "realNameAccountPassword"),
fieldForm: { ...this.state.fieldForm, taxOnlinePassword: "" }
});
}
});
};
render() {
const { fieldItem, fieldForm } = this.state;
return (
<div className="taxDeclarationInfoWrapper">
<WeaSearchGroup col={1} needTigger showGroup>
{
_.map(fieldItem, item => {
const { key, label, type, viewAttr, options = [] } = item;
return <WeaFormItem label={label} labelCol={{ span: 6 }} wrapperCol={{ span: 14 }} key={key}>
{
(type === "TEXT" || type === "PASSWORD") &&
<WeaInput autocomplete="off" value={fieldForm[key]} type={_.lowerCase(type)} viewAttr={viewAttr}
onChange={(v) => this.handleChangeValue(key, v)}/>
}
{
type === "SELECT" &&
<WeaBrowser value={fieldForm[key]} type={58} viewAttr={viewAttr}
onChange={(v) => this.handleChangeValue(key, v)}/>
}
{
type === "RADIO" &&
<WeaSelect detailtype={3} value={fieldForm[key]} options={options} viewAttr={viewAttr}
onChange={(v) => this.handleChangeValue(key, v)}/>
}
</WeaFormItem>;
})
}
</WeaSearchGroup>
</div>
);
}
}
export default TaxDeclarationInfo;