import React from 'react' import { WeaInputSearch, WeaHelpfulTip, WeaTable } from "ecCom" import { payrollGrantColumns, dataSource } from "../columns" import { Menu, Button,Table, Modal, Dropdown } from "antd" import { inject, observer } from 'mobx-react'; @inject('payrollStore') @observer export default class PayrollWithdrawModal extends React.Component { constructor(props) { super(props); this.state = { selectedRowKeys: [], current: 1, } } componentWillMount() { const { payrollStore } = this.props const { batchWithdrawInfoList } = payrollStore batchWithdrawInfoList({salarySendId:this.props.sendId}) } // 撤回 handleWithdraw(record) { const { payrollStore } = this.props; const { withdrawPayroll, batchWithdrawInfoList } = payrollStore; withdrawPayroll({ ids: [record.id], salarySendId: this.props.sendId }).then(() => { batchWithdrawInfoList({salarySendId:this.props.sendId}) }) } // 发送 handleGrant(record) { const { payrollStore } = this.props; const { grantPayroll,batchWithdrawInfoList } = payrollStore; grantPayroll({ ids: [record.id], salarySendId: this.props.sendId }).then(() => { batchWithdrawInfoList({salarySendId:this.props.sendId}) }) } getColumns() { const { payrollStore } = this.props; const { canWidthdrawColumns } = payrollStore if(!canWidthdrawColumns) { return [] } return canWidthdrawColumns.map(item => { let result = {} result.title = item.text; result.key = item.column; result.dataIndex = item.column; result.width = item.width; if(result.key == "operation") { result.render = (text,record) => { if(text == 'ALREADYSEND') { return ( {this.handleWithdraw(record)}}>撤回 ) } else { return ( {this.handleGrant(record)}}>发送 ) } } } else { result.dataIndex = item.column; } return result; }) } onSelectChange = (value) => { this.setState({ selectedRowKeys: value }) } // 撤回 fetchWithdrawPayroll(payload) { const { payrollStore: { grantPayroll, withdrawPayroll }} = this.props; withdrawPayroll(payload).then(() => { const { payrollStore: {getInfoList}} = this.props; getInfoList({ salarySendId:this.props.sendId }) this.props.onCancel && this.props.onCancel() }) } handleMenuClick(e) { const { selectedRowKeys } = this.state; const { payrollStore: { grantPayroll }} = this.props; if(selectedRowKeys.length == 0) { message.warning("未选择条目"); return } this.fetchWithdrawPayroll({ids: selectedRowKeys, salarySendId: this.props.sendId}) } handleWithdrawAll() { this.fetchWithdrawPayroll({salarySendId: this.props.sendId}) } // 分页 handleDataPageChange(value) { this.setState({current: value}) const { payrollStore } = this.props const { batchWithdrawInfoList } = payrollStore batchWithdrawInfoList({salarySendId:this.props.sendId, current: value}) } handleSearch(value) { const { payrollStore: { batchWithdrawInfoList } } = this.props; batchWithdrawInfoList({salarySendId: this.props.sendId, keyword: value, current: this.state.current}) } render() { const menu = (
); const {payrollStore} = this.props; const { salarySendDetailBaseInfo, canWidthdrawColumns, canWithdrawDataSource, canWithdrawPageInfo } = payrollStore; const { selectedRowKeys } = this.state; const rowSelection = { selectedRowKeys, onChange: this.onSelectChange.bind(this), }; return (