salary-management-front/pc4mobx/hrmSalary/pages/taxAgent/editModal.js

178 lines
5.0 KiB
JavaScript
Raw Normal View History

2022-06-02 14:48:55 +08:00
import React from "react";
import { Button } from "antd";
import { WeaDialog, WeaFormItem, WeaSearchGroup, WeaSteps, WeaTab } from "ecCom";
2022-06-02 14:48:55 +08:00
import { WeaSwitch } from "comsMobx";
import PersonalScope from "./personalScope";
2023-03-14 18:14:23 +08:00
import "./index.less";
2022-06-02 14:48:55 +08:00
const titleOuter = {
display: "flex",
justifyContent: "space-between",
alignItems: "center"
2022-06-02 14:48:55 +08:00
};
const left = {
display: "flex",
flexDirection: "column"
2022-06-02 14:48:55 +08:00
};
const stepWrapper = {
padding: "20px 200px"
2022-06-02 14:48:55 +08:00
};
2022-03-02 10:00:54 +08:00
2022-06-02 14:48:55 +08:00
const Step = WeaSteps.Step;
2022-03-02 10:00:54 +08:00
2022-06-02 14:48:55 +08:00
export default class EditModal extends React.Component {
constructor(props) {
super(props);
this.state = {
date: ""
2022-06-02 14:48:55 +08:00
};
}
2022-03-02 10:00:54 +08:00
2022-06-02 14:48:55 +08:00
handleSubmit = () => {
const { onSubmit, btnType, onPrev, devolutionStatus } = this.props;
const { form, formDecentralization } = this.props.taxAgentStore;
2022-06-02 14:48:55 +08:00
if (btnType === "prev") {
onPrev && onPrev();
return;
2022-03-02 10:00:54 +08:00
}
const formExample = devolutionStatus === 1 ? form : formDecentralization;
formExample.validateForm().then((f) => {
2022-06-02 14:48:55 +08:00
if (f.isValid) {
const formData = formExample.getFormParams();
2022-06-02 14:48:55 +08:00
const { adminUserIds, ...extraVal } = formData;
onSubmit &&
onSubmit(devolutionStatus === 1 ? { adminUserIds: adminUserIds.split(","), ...extraVal } : { ...extraVal });
2022-06-02 14:48:55 +08:00
} else {
f.showErrors();
this.setState({ date: new Date() }); // 改变一个state的变量,强制页面刷新
}
});
};
2022-03-02 10:00:54 +08:00
2022-06-02 14:48:55 +08:00
renderEditForm = () => {
const { editConditions, devolutionStatus } = this.props;
const { form, formDecentralization } = this.props.taxAgentStore;
const { isFormInit } = devolutionStatus === 1 ? form : formDecentralization;
2022-06-02 14:48:55 +08:00
let group = [];
isFormInit &&
editConditions.map((c, index) => {
let items = [];
c.items.map((field, idx) => {
items.push({
com: (
<WeaFormItem
ecId={`tasAgent_WeaFormItem@jsxoq6@${index}@${idx}`}
label={`${field.label}`}
labelCol={{ span: `${field.labelcol}` }}
error={devolutionStatus === 1 ? form.getError(field) : formDecentralization.getError(field)}
tipPosition="bottom"
underline
wrapperCol={{ span: `${field.fieldcol}` }}>
<WeaSwitch
ecId={`tasAgent_WeaSwitch@r2lhga@${index}@${idx}`}
fieldConfig={field}
form={devolutionStatus === 1 ? form : formDecentralization}
/>
</WeaFormItem>
),
col: 1
2022-06-02 14:48:55 +08:00
});
});
group.push(
<WeaSearchGroup
ecId={`tasAgent_WeaSearchGroup@3y8h9i@${index}`}
needTigger={false}
title={c.title}
showGroup={c.defaultshow}
items={items}
/>
);
});
2022-06-02 14:48:55 +08:00
return group;
};
2022-06-02 14:48:55 +08:00
render() {
const { date } = this.state;
const {
visible,
title,
current,
btnType,
editType,
editId,
saveloading,
onClose,
onChangeTab,
taxAgentStore,
isChief,
devolutionStatus
2022-06-02 14:48:55 +08:00
} = this.props;
const { form, formDecentralization } = taxAgentStore;
2022-06-02 14:48:55 +08:00
return (
<WeaDialog
onCancel={() => {
devolutionStatus === 1 ? form.resetForm() : formDecentralization.resetForm();
2022-06-02 14:48:55 +08:00
onClose && onClose();
}}
title={
<div style={titleOuter}>
<div style={left}>
<div className="title">{title}</div>
</div>
<div className="right">
{/*总管理权限*/}
{(editType !== "set" && isChief) && (
2022-06-02 14:48:55 +08:00
<Button
type="primary"
onClick={this.handleSubmit}
loading={saveloading}>
{btnType === "save"
? "保存并进入下一步"
: btnType === "prev"
? "上一步"
: "保存"}
2022-06-02 14:48:55 +08:00
</Button>
)}
</div>
</div>
}
2022-07-28 17:16:40 +08:00
initLoadCss
2023-03-14 18:14:23 +08:00
className="taxagentModalWrapper"
2022-06-02 14:48:55 +08:00
visible={visible}
2022-07-28 17:16:40 +08:00
style={{ width: 800, height: 450 }}
2022-06-02 14:48:55 +08:00
hasScroll>
{title.indexOf("编辑") >= 0 && (
<WeaTab
datas={[
{
title: "基础设置",
viewcondition: 0
2022-06-02 14:48:55 +08:00
},
{
title: "人员范围",
viewcondition: 1
}
2022-06-02 14:48:55 +08:00
]}
keyParam="viewcondition" //主键
selectedKey={current}
onChange={(v) => onChangeTab && onChangeTab(v)}
/>
)}
{(btnType === "save" || title.indexOf("编辑") < 0) && (
<div style={stepWrapper}>
<WeaSteps current={current} size="small">
<Step description="基础设置"/>
<Step description="人员范围"/>
2022-06-02 14:48:55 +08:00
</WeaSteps>
</div>
)}
{current == 0 ? (
this.renderEditForm()
) : (
<PersonalScope taxAgentId={editId}/>
2022-06-02 14:48:55 +08:00
)}
</WeaDialog>
);
}
}