/*
* Author: 黎永顺
* Description: 正常缴纳月份
* Date: 2022-04-20 08:56:08
* LastEditTime: 2022-04-22 19:06:46
*/
import React, { Component } from "react";
import { Icon, Tooltip, Button, message, Modal } from "antd";
import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import { WeaBrowser, WeaTable, WeaPopoverHrm, WeaDialog } from "ecCom";
import { getSearchs } from "../../../../util";
import _ from "lodash";
import "./index.less";
@inject("standingBookStore")
@observer
export default class NormalIndex extends Component {
constructor(props) {
super(props);
this.state = {
date: "",
current: 1,
selectedRowKeys: [],
addProps: {
title: "",
visible: false,
},
tableData: {
list: [],
columns: [],
total: 0,
},
};
}
componentDidMount() {
const { billMonth, selectedKey } = this.props;
const { current } = this.state;
selectedKey === "1"
? this.getNormalList({ billMonth, current })
: this.getSupplementaryList({ billMonth, current });
}
componentWillReceiveProps(nextProps) {
if (nextProps.selectedKey != this.props.selectedKey) {
const { billMonth } = nextProps;
const { current } = this.state;
nextProps.selectedKey === "1"
? this.getNormalList({ billMonth, current })
: this.getSupplementaryList({ billMonth, current });
}
}
handleSave = () => {
const { siaccountCommonSave, siaccountSupplementarySave, form } =
this.props.standingBookStore;
const { billMonth, selectedKey } = this.props;
if (selectedKey === "1") {
const { includes, excludes } = form.getFormParams();
const payload = {
billMonth,
includes: includes.split(","),
excludes: _.isEmpty(excludes) ? excludes.split(",") : [],
};
siaccountCommonSave(payload).then(() => {
message.success("添加成功");
this.getNormalList({ billMonth, current: this.state.current });
this.setState({
addProps: {
...this.state.addProps,
title: "",
visible: false,
},
});
});
} else {
form.validateForm().then((f) => {
if (f.isValid) {
const {
includes,
billMonth: billMonthList,
excludes,
projects,
} = form.getFormParams();
const payload = {
billMonth,
billMonthList: billMonthList.split(","),
includes: includes.split(","),
excludes: excludes.split(","),
projects: projects.split(","),
};
siaccountSupplementarySave(payload).then(() => {
message.success("添加成功");
this.getSupplementaryList({
billMonth,
current: this.state.current,
});
this.setState({
addProps: {
...this.state.addProps,
title: "",
visible: false,
},
});
});
} else {
f.showErrors();
this.setState({ date: new Date() }); // 改变一个state的变量,强制页面刷新
}
});
}
};
getNormalList = (payload = {}) => {
const { getNormalList } = this.props.standingBookStore;
getNormalList({ ...payload }).then(({ list, columns = [], total }) => {
columns = _.map(
_.filter(columns, (it) => it.dataIndex !== "id"),
(it) => {
if (it.dataIndex === "employeeId") {
it = {
...it,
width: 150,
fixed: "left",
render: (text, r) => {
const { userName, employeeId } = r;
return (