240 lines
8.9 KiB
JavaScript
240 lines
8.9 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 报送信息-编辑、新增弹框
|
|
* Description:
|
|
* Date: 2023/8/14
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLocaleProvider, WeaSlideModal } from "ecCom";
|
|
import { Button, Col, message, Modal, Row } from "antd";
|
|
import { inject, observer } from "mobx-react";
|
|
import { declareConditions } from "../constants";
|
|
import { getSearchs } from "../../../util";
|
|
import { getQueryString } from "../../../util/url";
|
|
import { employeedeclareGetForm, getEmployeeSave } from "../../../apis/declare";
|
|
|
|
const { getLabel } = WeaLocaleProvider;
|
|
|
|
@inject("employeeDeclareStore")
|
|
@observer
|
|
class EmployeeDeclareDetailSchemaEditDialog extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
loading: false,
|
|
eConditions: []
|
|
};
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.visible !== this.props.visible && nextProps.visible) this.employeedeclareGetForm(nextProps);
|
|
}
|
|
|
|
employeedeclareGetForm = (props) => {
|
|
employeedeclareGetForm(_.pick(props, ["id"])).then(({ status, data }) => {
|
|
if (status) {
|
|
this.setState({
|
|
eConditions: _.map(declareConditions, it => {
|
|
return {
|
|
...it,
|
|
items: _.map(it.items, child => {
|
|
if (child.domkey[0] === "employmentStatus") {
|
|
return {
|
|
...child,
|
|
value: _.take(props.employmentStatusList)[0].enum,
|
|
options: _.map(props.employmentStatusList, it => ({
|
|
key: it.enum,
|
|
showname: getLabel(it.labelId, it.defaultLabel)
|
|
}))
|
|
};
|
|
} else if (child.domkey[0] === "employmentType") {
|
|
return {
|
|
...child,
|
|
value: _.take(props.employmentTypeList)[0].enum,
|
|
options: _.map(props.employmentTypeList, it => ({
|
|
key: it.enum,
|
|
showname: getLabel(it.labelId, it.defaultLabel)
|
|
}))
|
|
};
|
|
} else if (child.domkey[0] === "gender") {
|
|
return {
|
|
...child,
|
|
value: "MALE",
|
|
options: [
|
|
{ key: "MALE", showname: getLabel(111, "男") },
|
|
{ key: "FEMALE", showname: getLabel(111, "女") }
|
|
]
|
|
};
|
|
} else if (child.domkey[0] === "employeeType") {
|
|
return {
|
|
...child,
|
|
viewAttr: props.id ? 1 : 3,
|
|
options: [
|
|
{ key: "ORGANIZATION", showname: getLabel(30042, "人员") }
|
|
]
|
|
};
|
|
}
|
|
if (child.conditionType === "SELECT" && child.domkey[0] !== "gender" && child.domkey[0] !== "employmentStatus" && child.domkey[0] !== "employmentType") {
|
|
return {
|
|
...child,
|
|
options: [
|
|
{ key: "ON", showname: getLabel(538048, "是") },
|
|
{ key: "OFF", showname: getLabel(111, "否") }
|
|
]
|
|
};
|
|
}
|
|
return { ...child };
|
|
})
|
|
};
|
|
})
|
|
}, () => {
|
|
const { data: result, columns } = data;
|
|
const { employeeDeclareStore: { declareForm } } = this.props;
|
|
declareForm.initFormFields(this.state.eConditions);
|
|
const filedKes = _.map(columns, it => it.dataIndex);
|
|
_.map(filedKes, item => {
|
|
if (item === "disability" || item === "lonelyOld" || item === "martyrDependents") {
|
|
declareForm.updateFields({ [item]: result[item] || "OFF" });
|
|
} else if (item === "deductExpenses") {
|
|
declareForm.updateFields({ [item]: result[item] || "ON" });
|
|
} else if (item === "gender") {
|
|
declareForm.updateFields({ [item]: result[item] || "MALE" });
|
|
} else if (item === "employmentStatus") {
|
|
declareForm.updateFields({ [item]: result[item] || _.take(props.employmentStatusList)[0].enum });
|
|
} else if (item === "employmentType") {
|
|
declareForm.updateFields({ [item]: result[item] || _.take(props.employmentTypeList)[0].enum });
|
|
} else if (item === "cardType") {
|
|
declareForm.updateFields({ [item]: "居民身份证" });
|
|
} else if (item === "employee") {
|
|
const [employeeData] = result[item] || [];
|
|
!_.isEmpty(employeeData) && declareForm.updateFields({
|
|
employeeType: {
|
|
value: [employeeData._entityType, [employeeData.id, employeeData.name, [{
|
|
id: employeeData.id,
|
|
lastname: employeeData.name
|
|
}]]],
|
|
valueSpan: ["employeeId"]
|
|
}
|
|
});
|
|
} else {
|
|
declareForm.updateFields({ [item]: result[item] || "" });
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
onChange = (res) => {
|
|
const { eConditions } = this.state;
|
|
const { employeeDeclareStore: { declareForm } } = this.props;
|
|
const key = Object.keys(res)[0];
|
|
const value = res[key].value;
|
|
console.log(132, res, declareForm.getFormParams());
|
|
switch (key) {
|
|
case "employmentStatus":
|
|
this.setState({
|
|
eConditions: _.map(eConditions, it => {
|
|
return {
|
|
...it,
|
|
items: _.map(it.items, child => {
|
|
if (child.domkey[0] === "dismissDate") {
|
|
return {
|
|
...child,
|
|
viewAttr: value === "ABNORMAL" ? 3 : 2
|
|
};
|
|
}
|
|
return { ...child };
|
|
})
|
|
};
|
|
})
|
|
}, () => {
|
|
console.log(150, this.state.eConditions);
|
|
declareForm.initFormFields(this.state.eConditions);
|
|
});
|
|
break;
|
|
case "employmentType":
|
|
this.setState({
|
|
eConditions: _.map(eConditions, it => {
|
|
return {
|
|
...it,
|
|
items: _.map(it.items, child => {
|
|
if (child.domkey[0] === "employmentDate") {
|
|
return {
|
|
...child,
|
|
viewAttr: value !== "OTHER" ? 3 : 2
|
|
};
|
|
}
|
|
return { ...child };
|
|
})
|
|
};
|
|
})
|
|
}, () => {
|
|
declareForm.initFormFields(this.state.eConditions);
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
|
|
handleSubmit = () => {
|
|
const { employeeDeclareStore: { declareForm: form } } = this.props;
|
|
form.validateForm().then(f => {
|
|
if (f.isValid) {
|
|
const { employmentType, employmentDate, employmentStatus, dismissDate, ...params } = form.getFormParams();
|
|
if ((employmentType !== "OTHER" && !employmentDate) || (employmentStatus === "ABNORMAL" && !dismissDate)) {
|
|
Modal.warning({
|
|
title: getLabel(131329, "信息确认"),
|
|
content: getLabel(518702, "必要信息不完整,红色*为必填项!")
|
|
});
|
|
return;
|
|
}
|
|
const payload = {
|
|
...form.getFormParams(), id: this.props.id,
|
|
cardType: "RESIDENT_IDENTITY_CARDS", //暂时写死身份证类型
|
|
taxAgentId: getQueryString("id"),
|
|
taxCycle: this.props.taxCycle
|
|
};
|
|
this.setState({ loading: true });
|
|
getEmployeeSave(payload).then(({ status, errormsg }) => {
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
message.success(getLabel(22619, "保存成功!"));
|
|
this.props.onClose("true");
|
|
} else {
|
|
message.error(errormsg || getLabel(22620, "保存失败!"));
|
|
}
|
|
}).catch(() => this.setState({ loading: false }));
|
|
} else {
|
|
f.showErrors();
|
|
}
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { eConditions, loading } = this.state;
|
|
const { employeeDeclareStore: { declareForm: form }, title = "" } = this.props;
|
|
return (
|
|
<WeaSlideModal
|
|
{...this.props}
|
|
top={0} measureT="%"
|
|
width={800} measureX="px"
|
|
height={100} measureY="%"
|
|
direction="right"
|
|
title={(<Row className="declareSchemeDialogTitle" type="flex">
|
|
<Col span={12} className="declareSchemeDialogTitle-left">
|
|
<div className="icon-circle-base"><i className="icon-coms-fa"/></div>
|
|
<span className="title">{title || getLabel(111, "本月新增数据")}</span>
|
|
</Col>
|
|
<Col span={12} className="declareSchemeDialogTitle-right">
|
|
<Button type="primary" onClick={this.handleSubmit} loading={loading}>{getLabel(537558, "保存")}</Button>
|
|
</Col>
|
|
</Row>)}
|
|
content={(<div className="declareSchemeDialog">{getSearchs(form, eConditions, 1, false, this.onChange)}</div>)}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default EmployeeDeclareDetailSchemaEditDialog;
|