/* * 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 ( window.pointerXY(e)} title={userName}> {userName} ); }, }; } return { ...it, title: , width: 150, }; } ); this.setState({ tableData: { list, columns, total, }, }); }); }; getSupplementaryList = (payload = {}) => { const { getSupplementaryList } = this.props.standingBookStore; getSupplementaryList({ ...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 ( window.pointerXY(e)} title={userName}> {userName} ); }, }; } return { ...it, title: ( ), width: 150, }; } ); this.setState({ tableData: { list, columns, total, }, }); } ); }; onSelectChange = (selectedRowKeys) => { this.setState({ selectedRowKeys }); }; handleBatchDelete = () => { const { siaccountCommonDelete } = this.props.standingBookStore; const { list } = this.state.tableData; const { selectedRowKeys } = this.state; const { billMonth, selectedKey } = this.props; if (_.isEmpty(selectedRowKeys)) { message.warning("未勾选数据!"); } else { const includes = _.map( _.filter(list, (it) => selectedRowKeys.includes(it.id)), (item) => item.employeeId ); Modal.confirm({ title: "确认信息", content: "确认删除勾选的数据吗?", onOk: () => { siaccountCommonDelete({ billMonth, includes }).then(() => { message.success("删除成功"); this.setState({ selectedRowKeys: [] }); selectedKey === "1" ? this.getNormalList({ billMonth, current: this.state.current }) : this.getSupplementaryList({ billMonth, current: this.state.current, }); }); }, onCancel: () => {}, }); } }; handleAdd = () => { const { siaccountCommonForm, querySupplementaryForm } = this.props.standingBookStore; const { billMonth, selectedKey } = this.props; if (selectedKey === "1") { siaccountCommonForm(); } else { querySupplementaryForm(); } this.setState({ addProps: { ...this.state.addProps, title: "添加缴纳人员", visible: true, }, }); }; render() { const { remarks, billMonth, selectedKey } = this.props; const { selectedRowKeys, addProps, date } = this.state; const { loading, form, condition, saveLoading } = this.props.standingBookStore; let { list, columns, total } = this.state.tableData; const rowSelection = { selectedRowKeys, onChange: this.onSelectChange, }; const pagination = { total, current: this.state.current, showTotal: (total) => `共 ${total} 条`, onChange: (current) => { this.setState({ current }); selectedKey === "1" ? this.getNormalList({ billMonth, current }) : this.getSupplementaryList({ billMonth, current, }); }, }; return (
{selectedKey === "1" && (
账单月份 {billMonth}
备注: {remarks}
)}
{addProps.visible && ( this.setState({ addProps: { ...addProps, title: "", visible: false, }, }) } buttons={[ , , ]}> {getSearchs(form, toJS(condition), 1)} )} {selectedKey === "3" && ( )} {selectedKey === "1" && } console.log("多人力", ids, names, datas) } isSingle={false} />
{/* table */}
); } }