import React from 'react' import { Row, Col, Icon, Table, Modal } from 'antd' import { WeaHelpfulTip, WeaInputSearch, WeaBrowser, WeaTable } from 'ecCom' import { inject, observer } from 'mobx-react'; import { dataSource , monthOnMonthColumns, userSureColumns} from './columns' import "./index.less" import { getQueryString } from '../../util/url' import CustomTable from '../../components/customTable' @inject('calculateStore') @observer export default class UserSure extends React.Component { constructor(props) { super(props) this.state = { selectedKey: "0", selectedRowKeys: [], // table 选中项 userListSearchValue: '', } this.id = "" } componentWillMount() { let id = getQueryString("id") this.id = id; const { calculateStore } = this.props; const { salaryacctGetForm, acctemployeeList, reducedemployeeList, getSalarySobCycle } = calculateStore salaryacctGetForm(id) acctemployeeList({salaryAcctRecordId: id, employeeName: this.state.userListSearchValue, current: 1}) reducedemployeeList({salaryAcctRecordId: id, employeeName: this.state.userListSearchValue, current: 1}) getSalarySobCycle(id) } // 添加人员回调 handleUserBrowserChange(ids) { if(ids && ids.length > 0) { let idList = ids.split(","); const { calculateStore: { saveAcctemployee, reducedemployeeList, acctemployeeList, checkTaxAgent }} = this.props; saveAcctemployee(this.id, idList).then(() => { reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) acctemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) checkTaxAgent(this.id) }) } } // 导出 handleExport() { const { calculateStore: { exportReducedEmployee, exportAcctEmployee }} = this.props; if(this.state.selectedKey == 0) { exportAcctEmployee(this.id) } else { exportReducedEmployee(this.id) } } // 批量删除 handleBatchDelete() { const { selectedRowKeys } = this.state; const { calculateStore: { deleteAcctemployee, reducedemployeeList, acctemployeeList } } = this.props; if(selectedRowKeys.length == 0) { message.warning("未选择条目") } Modal.confirm({ title: '信息确认', content: '确认删除', onOk:() => { deleteAcctemployee(this.id, selectedRowKeys).then(() => { reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) acctemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) }) }, onCancel: () => { }, }); } // 人员范围列表 getUserListColumns = () => { const { calculateStore: {acctemployeeListColumns}} = this.props; let columns = [...acctemployeeListColumns] columns.push({ key: "cz", title: "操作", render: (text, record) => { return {this.handleDeleteItem(record)}}>删除 } }) return columns; } // 获取人员列表,添加key getUserListDataSource = () => { const { calculateStore: {acctemployeeListDataSource}} = this.props; return acctemployeeListDataSource.map(item => { item = {...item} item.key = item.id return item }) } // 删除人员 handleDeleteItem = (record) => { const { calculateStore: {deleteAcctemployee}} = this.props; Modal.confirm({ title: '信息确认', content: '确认删除', onOk:() => { deleteAcctemployee(this.id, [record.id]).then(() => { reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) acctemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue,current: 1}) }) }, onCancel: () => { }, }); } // 刷新薪资核算人员的个税扣缴义务人 handleRefresh = () => { const { calculateStore: {refreshTaxAgent, reducedemployeeList, acctemployeeList } } = this.props; refreshTaxAgent(this.id).then(() => { reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) acctemployeeList({salaryAcctRecordId: this.id , employeeName: this.state.userListSearchValue, current: 1}) }) } onSelectChange = selectedRowKeys => { this.setState({ selectedRowKeys, userListSearchValue: "" }); } // 核算人员范围分页 handleUserListPageChange(value) { const { calculateStore: {acctemployeeList}} = this.props; acctemployeeList({acctemployeeList: this.id, employeeName: this.state.userListSearchValue, current: value}) } // 环比减少人员分页 handleReducedemployeeListPageChange(value) { const { calculateStore: { reducedemployeeList }} = this.props; reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: value}) } // 搜索 handleUserListSearch(value) { const { calculateStore: {acctemployeeList, reducedemployeeList}} = this.props; if(this.state.selectedKey == 0) { acctemployeeList({acctemployeeList: this.id, employeeName: value, current: 1}) } else { reducedemployeeList({salaryAcctRecordId: this.id, employeeName: value, current: 1}) } } render() { const { selectedRowKeys } = this.state; const { calculateStore } = this.props; const { calculateBaseForm, acctemployeeListDataSource, acctemployeeListColumns, reducedemployeeListDataSource, reducedemployeeListColumns, baseSalarySobCycle, acctemployeeListPageInfo, loading, reducedemployeeListPageInfo } = calculateStore const rowSelection = { selectedRowKeys, onChange: this.onSelectChange, }; return (