2022-08-04 17:07:09 +08:00
|
|
|
import React from "react";
|
2022-11-03 20:38:57 +08:00
|
|
|
import { Button, Col, Row } from "antd";
|
2022-08-04 17:07:09 +08:00
|
|
|
import { inject, observer } from "mobx-react";
|
2022-09-13 16:39:15 +08:00
|
|
|
import { WeaDatePicker, WeaDialog, WeaError, WeaInput, WeaSelect } from "ecCom";
|
2022-08-04 17:07:09 +08:00
|
|
|
import { notNull } from "../../util/validate";
|
|
|
|
|
import "./index.less";
|
|
|
|
|
|
2022-04-19 10:11:40 +08:00
|
|
|
|
2022-08-04 17:07:09 +08:00
|
|
|
@inject("calculateStore")
|
2022-04-19 10:11:40 +08:00
|
|
|
@observer
|
|
|
|
|
export default class baseFormModal extends React.Component {
|
2022-08-04 17:07:09 +08:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
salaryMonthStr: "",
|
|
|
|
|
inited: false,
|
|
|
|
|
selectOptions: [],
|
|
|
|
|
salarySob: "",
|
2022-11-03 20:38:57 +08:00
|
|
|
description: "",
|
|
|
|
|
loading: false
|
2022-08-04 17:07:09 +08:00
|
|
|
};
|
|
|
|
|
}
|
2022-04-19 10:11:40 +08:00
|
|
|
|
2022-08-04 17:07:09 +08:00
|
|
|
componentWillMount() {
|
|
|
|
|
const { calculateStore } = this.props;
|
|
|
|
|
const { salaryacctGetForm } = calculateStore;
|
|
|
|
|
salaryacctGetForm().then(data => {
|
|
|
|
|
this.setState({
|
|
|
|
|
inited: true,
|
2022-09-13 16:39:15 +08:00
|
|
|
selectOptions: _.isEmpty(data.salarySobs) ? [{ key: "", showname: "" }] : [{
|
|
|
|
|
key: "",
|
|
|
|
|
showname: ""
|
|
|
|
|
}, ..._.map(data.salarySobs, it => ({ key: String(it.id), showname: it.name }))]
|
2022-08-04 17:07:09 +08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleSelectChange(value) {
|
|
|
|
|
this.setState({
|
|
|
|
|
salarySob: value
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-04-19 10:11:40 +08:00
|
|
|
|
2022-08-04 17:07:09 +08:00
|
|
|
// 保存回调
|
|
|
|
|
handleSave() {
|
|
|
|
|
if (!this.validate()) {
|
|
|
|
|
return;
|
2022-04-19 10:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
2022-08-04 17:07:09 +08:00
|
|
|
let params = {
|
|
|
|
|
salaryMonthStr: this.state.salaryMonthStr,
|
|
|
|
|
salarySobId: this.state.salarySob,
|
|
|
|
|
description: this.state.description
|
|
|
|
|
};
|
|
|
|
|
const { calculateStore: { saveBasic } } = this.props;
|
2022-11-03 20:38:57 +08:00
|
|
|
this.setState({ loading: true });
|
2022-08-04 17:07:09 +08:00
|
|
|
saveBasic(params).then((id) => {
|
2022-11-03 20:38:57 +08:00
|
|
|
this.setState({ loading: false });
|
2022-08-04 17:07:09 +08:00
|
|
|
this.props.onCancel();
|
|
|
|
|
this.props.onRefresh();
|
|
|
|
|
window.open("/spa/hrmSalary/static/index.html#/main/hrmSalary/calculateDetail?id=" + id);
|
2022-11-03 20:38:57 +08:00
|
|
|
}).catch(()=>{
|
|
|
|
|
this.setState({ loading: false });
|
|
|
|
|
})
|
2022-08-04 17:07:09 +08:00
|
|
|
}
|
2022-04-19 10:11:40 +08:00
|
|
|
|
2022-08-04 17:07:09 +08:00
|
|
|
validate() {
|
2022-09-13 16:39:15 +08:00
|
|
|
if (!notNull(this.state.salaryMonthStr) && !notNull(this.state.salarySob)) {
|
|
|
|
|
this.refs.weaError.showError();
|
|
|
|
|
this.refs.weaError1.showError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-08-04 17:07:09 +08:00
|
|
|
if (!notNull(this.state.salaryMonthStr)) {
|
2022-09-13 16:39:15 +08:00
|
|
|
this.refs.weaError.showError();
|
2022-08-04 17:07:09 +08:00
|
|
|
return false;
|
|
|
|
|
} else if (!notNull(this.state.salarySob)) {
|
2022-09-13 16:39:15 +08:00
|
|
|
this.refs.weaError1.showError();
|
2022-08-04 17:07:09 +08:00
|
|
|
return false;
|
2022-04-19 10:11:40 +08:00
|
|
|
}
|
2022-08-04 17:07:09 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-19 10:11:40 +08:00
|
|
|
|
2022-08-04 17:07:09 +08:00
|
|
|
render() {
|
2022-11-03 20:38:57 +08:00
|
|
|
const { description, loading } = this.state;
|
2022-08-04 17:07:09 +08:00
|
|
|
return (
|
2022-09-13 16:39:15 +08:00
|
|
|
<WeaDialog
|
2022-08-04 17:07:09 +08:00
|
|
|
title="核算"
|
2022-09-13 16:39:15 +08:00
|
|
|
initLoadCss
|
|
|
|
|
className="dataList-wrapper"
|
2022-08-04 17:07:09 +08:00
|
|
|
visible={this.props.visible}
|
2022-09-13 16:39:15 +08:00
|
|
|
style={{ width: 600 }}
|
2022-08-04 17:07:09 +08:00
|
|
|
onCancel={() => {
|
|
|
|
|
this.props.onCancel();
|
|
|
|
|
}}
|
2022-11-03 20:38:57 +08:00
|
|
|
buttons={[
|
|
|
|
|
<Button
|
|
|
|
|
loading={loading}
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
this.handleSave();
|
|
|
|
|
}}
|
|
|
|
|
>保存</Button>
|
|
|
|
|
]}
|
2022-08-04 17:07:09 +08:00
|
|
|
>
|
2022-11-18 16:26:15 +08:00
|
|
|
<Row className="formItem">
|
2022-09-13 16:39:15 +08:00
|
|
|
<Col span={8}>薪酬所属月</Col>
|
2022-08-04 17:07:09 +08:00
|
|
|
<Col span={16}>
|
2022-09-13 16:39:15 +08:00
|
|
|
<WeaError
|
2022-08-04 17:07:09 +08:00
|
|
|
style={{ width: "100%" }}
|
2022-09-13 16:39:15 +08:00
|
|
|
tipPosition="bottom"
|
|
|
|
|
ref="weaError"
|
|
|
|
|
error="请选择薪酬所属月">
|
|
|
|
|
<WeaDatePicker
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
format="yyyy-MM"
|
|
|
|
|
viewAttr={3}
|
|
|
|
|
value={this.state.salaryMonthStr}
|
|
|
|
|
onChange={value => {
|
2022-11-03 20:38:57 +08:00
|
|
|
if (value === "") this.refs.weaError.showError();
|
2022-09-13 16:39:15 +08:00
|
|
|
this.setState({
|
|
|
|
|
salaryMonthStr: value
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</WeaError>
|
2022-08-04 17:07:09 +08:00
|
|
|
</Col>
|
|
|
|
|
</Row>
|
2022-04-19 10:11:40 +08:00
|
|
|
|
2022-11-18 16:26:15 +08:00
|
|
|
<Row className="formItem">
|
2022-09-13 16:39:15 +08:00
|
|
|
<Col span={8}>核算账套</Col>
|
2022-08-04 17:07:09 +08:00
|
|
|
<Col span={16}>
|
|
|
|
|
{
|
2022-09-13 16:39:15 +08:00
|
|
|
this.state.inited &&
|
|
|
|
|
<WeaError
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
tipPosition="bottom"
|
|
|
|
|
ref="weaError1"
|
|
|
|
|
error="请选择账套">
|
|
|
|
|
<WeaSelect
|
|
|
|
|
viewAttr={3}
|
|
|
|
|
options={this.state.selectOptions}
|
|
|
|
|
onChange={(value) => {
|
2022-11-03 20:38:57 +08:00
|
|
|
if (value === "") this.refs.weaError1.showError();
|
|
|
|
|
this.handleSelectChange(value);
|
2022-09-13 16:39:15 +08:00
|
|
|
}}
|
|
|
|
|
value={this.state.salarySob} style={{ width: "100%" }}/>
|
|
|
|
|
</WeaError>
|
2022-08-04 17:07:09 +08:00
|
|
|
}
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
|
2022-11-18 16:26:15 +08:00
|
|
|
<Row className="formItem">
|
2022-08-04 17:07:09 +08:00
|
|
|
<Col span={8}>备注</Col>
|
|
|
|
|
<Col span={16}>
|
|
|
|
|
<WeaInput value={description} onChange={(value) => this.setState({ description: value })}/>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
2022-09-13 16:39:15 +08:00
|
|
|
</WeaDialog>
|
2022-08-04 17:07:09 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|