salary-management-front/pc4mobx/hrmSalary/pages/declare/generateModal.js

152 lines
4.6 KiB
JavaScript
Raw Normal View History

2022-06-07 18:24:05 +08:00
import React from "react";
import {
WeaDatePicker,
WeaDialog,
WeaError,
WeaFormItem,
WeaHelpfulTip,
WeaLocaleProvider,
WeaSelect,
WeaTextarea
} from "ecCom";
2022-07-06 18:11:54 +08:00
import { Button } from "antd";
2022-06-07 18:24:05 +08:00
import { inject, observer } from "mobx-react";
2022-07-06 18:11:54 +08:00
import "./index.less";
2022-03-18 10:38:43 +08:00
const getLabel = WeaLocaleProvider.getLabel;
2022-06-07 18:24:05 +08:00
@inject("declareStore", "taxAgentStore")
2022-04-20 15:28:40 +08:00
@observer
2022-03-18 10:38:43 +08:00
export default class GenerateModal extends React.Component {
2022-06-07 18:24:05 +08:00
constructor(props) {
super(props);
this.state = {
date: "",
2023-02-13 10:41:40 +08:00
taxAgentId: "",
description: "",
2023-02-13 10:41:40 +08:00
loading: false
2022-06-07 18:24:05 +08:00
};
}
2022-04-20 15:28:40 +08:00
2022-06-07 18:24:05 +08:00
// 生成申报表
2023-02-13 10:41:40 +08:00
handleGenerate = () => {
const { declareStore: { saveDeclare } } = this.props;
const { date, taxAgentId, description } = this.state;
if (_.isEmpty(date) && _.isEmpty(taxAgentId)) {
this.refs.weaError.showError();
this.refs.weaError1.showError();
return;
}
if (_.isEmpty(date)) {
this.refs.weaError.showError();
return;
}
if (_.isEmpty(taxAgentId)) {
this.refs.weaError1.showError();
return;
}
2023-02-13 10:41:40 +08:00
this.setState({ loading: true });
saveDeclare({ salaryMonthStr: date, taxAgentId, description }).then(() => {
2023-02-13 10:41:40 +08:00
this.setState({ loading: false });
2022-06-07 18:24:05 +08:00
this.props.onGenerate();
2023-02-13 10:41:40 +08:00
}).catch(() => {
this.setState({ loading: false });
2022-06-07 18:24:05 +08:00
});
2023-02-13 10:41:40 +08:00
};
2022-04-20 15:28:40 +08:00
2022-06-07 18:24:05 +08:00
render() {
2023-02-13 10:41:40 +08:00
const { taxAgentStore: { taxAgentAdminOption } } = this.props;
const { loading } = this.state;
2022-06-07 18:24:05 +08:00
return (
2022-07-06 18:11:54 +08:00
<WeaDialog
2022-06-07 18:24:05 +08:00
visible={this.props.visible}
onCancel={() => this.props.onCancel()}
2022-07-06 18:11:54 +08:00
initLoadCss
className="generateWapper"
title={
<span>
<span>申报</span>
<WeaHelpfulTip
style={{ marginLeft: 8, position: "relative", top: "-1px" }}
width={200}
title="提示:一个薪资所属月下一个个税扣缴义务人的所有核算数据都归档后才可以申报"
placement="topLeft"
/>
</span>
}
2022-07-06 18:11:54 +08:00
buttons={
[<Button
2022-06-07 18:24:05 +08:00
type="primary"
2022-10-26 18:40:25 +08:00
loading={loading}
2023-02-13 10:41:40 +08:00
onClick={this.handleGenerate}>
2022-06-07 18:24:05 +08:00
生成申报表
2022-07-06 18:11:54 +08:00
</Button>]
2022-06-07 18:24:05 +08:00
}>
2022-07-06 18:11:54 +08:00
<div style={{ marginTop: "10px", padding: "20px 20%" }}>
<WeaFormItem
label="薪资所属月"
style={{ marginBottom: 10 }}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<WeaError
2022-07-06 18:11:54 +08:00
style={{ width: "100%" }}
tipPosition="bottom"
ref="weaError"
error="请选择薪资所属月">
<WeaDatePicker
style={{ width: "100%" }}
viewAttr={3}
format="YYYY-MM"
value={this.state.date}
onChange={(value) => {
if (_.isEmpty(value)) this.refs.weaError.showError();
this.setState({ date: value });
}}
/>
</WeaError>
2022-07-06 18:11:54 +08:00
</WeaFormItem>
<WeaFormItem
label="个税扣缴义务人"
style={{ marginBottom: 10 }}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<WeaError
style={{ width: "100%" }}
tipPosition="bottom"
ref="weaError1"
error="请选择个税扣缴义务人">
<WeaSelect
showSearch // 设置select可搜索
viewAttr={3}
options={[{ key: "", showname: "" }, ...taxAgentAdminOption]}
value={this.state.taxAgentId}
onChange={(taxAgentId) => {
if (_.isEmpty(taxAgentId)) this.refs.weaError1.showError();
this.setState({ taxAgentId });
}}
/>
<WeaHelpfulTip
style={{ position: "absolute", bottom: 8, right: -35 }}
width={200}
title="提示:可选择单个个税扣缴义务人进行申报,若不选择,则批量对管理下的所有个税扣缴义务人进行申报;"
placement="topLeft"
/>
</WeaError>
2022-07-06 18:11:54 +08:00
</WeaFormItem>
<WeaFormItem
label={getLabel(536726, "备注")}
style={{ marginBottom: 10 }}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<WeaTextarea
value={this.state.description}
onChange={(description) => this.setState({ description })}
/>
</WeaFormItem>
2022-06-07 18:24:05 +08:00
</div>
2022-07-06 18:11:54 +08:00
</WeaDialog>
2022-06-07 18:24:05 +08:00
);
}
}