salary-management-front/pc4mobx/hrmSalary/pages/payroll/payrollGrant/payrollGrantModal.js

181 lines
7.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react'
import { WeaInputSearch, WeaHelpfulTip, WeaTable } from "ecCom"
import { payrollGrantColumns, dataSource } from "../columns"
import { Menu, Button,Table, Modal, Dropdown,message } from "antd"
import { inject, observer } from 'mobx-react';
@inject('payrollStore')
@observer
export default class payrollGrantModal extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedRowKeys: [],
current: 1,
searchValue: ""
}
}
// 撤回
handleWithdraw(record) {
const { payrollStore } = this.props;
const { withdrawPayroll, batchSendInfoList } = payrollStore;
withdrawPayroll({
ids: [record.id],
salarySendId: this.props.sendId
}).then(() => {
batchSendInfoList({salarySendId: this.props.sendId})
})
}
// 发送
handleGrant(record) {
const { payrollStore } = this.props;
const { grantPayroll, batchSendInfoList } = payrollStore;
grantPayroll({
ids: [record.id],
salarySendId: this.props.sendId
}).then(() => {
batchSendInfoList({salarySendId: this.props.sendId})
})
}
componentWillMount() {
const { payrollStore: { batchSendInfoList } } = this.props;
batchSendInfoList({salarySendId: this.props.sendId})
}
getColumns() {
const { payrollStore } = this.props;
const { canGrantColumns } = payrollStore
if(!canGrantColumns) {
return []
}
return canGrantColumns.map(item => {
let result = {}
result.title = item.text;
result.dataIndex = item.column;
result.key = item.column;
result.width = item.width;
if(result.key == "operation") {
result.render = (text,record) => {
if(text == 'ALREADYSEND') {
return (
<a onClick={() => {this.handleWithdraw(record)}}>撤回</a>
)
} else {
return (
<a onClick={() => {this.handleGrant(record)}}>发送</a>
)
}
}
} else {
result.dataIndex = item.column;
}
return result;
})
}
onSelectChange = (value) => {
this.setState({
selectedRowKeys: value
})
}
// 发放
fetchGrantPayRoll(payload) {
const { payrollStore: { grantPayroll }} = this.props;
grantPayroll(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.fetchGrantPayRoll({ids: selectedRowKeys, salarySendId: this.props.sendId})
}
handleGrantAll() {
this.fetchGrantPayRoll({salarySendId: this.props.sendId})
}
handleSearch(value) {
const { payrollStore: { batchSendInfoList } } = this.props;
batchSendInfoList({salarySendId: this.props.sendId, keyword: value, current: this.state.current})
}
// 分页
handleDataPageChange(value) {
this.setState({current: value})
const { payrollStore: { batchSendInfoList } } = this.props;
batchSendInfoList({salarySendId: this.props.sendId, current: value})
}
render() {
const menu = (
<Menu onClick={(e) => this.handleMenuClick(e)}>
<Menu.Item key="1">发放所选</Menu.Item>
</Menu>
);
const {payrollStore} = this.props;
const { salarySendDetailBaseInfo, canGrantDataSource, canGrantPageInfo } = payrollStore;
const { selectedRowKeys } = this.state;
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange.bind(this),
};
return (
<Modal width={800} visible={this.props.visible} onCancel={() => {this.props.onCancel()}}>
<div style={{padding: "0px 10px", height: "47px", lineHeight: "47px"}}>
<span style={{fontSize: "14px", color: '#666'}}>批量发放</span>
<div style={{float: "right", marginRight: "40px"}}>
<Dropdown.Button type="primary" style={{marginRight: "10px"}} overlay={menu} onClick={() => {this.handleGrantAll()}}>全部发放</Dropdown.Button>
<WeaInputSearch value={this.state.searchValue} onChange={(value) => {this.setState({searchValue: value})}} onSearch={(value) => {this.handleSearch(value)}}/>
</div>
</div>
<div style={{height: "40px", lineHeight: "40px"}}>
<div className="titleBarLeft">
<span>薪资所属月{salarySendDetailBaseInfo.salaryMonth && salarySendDetailBaseInfo.salaryMonth.year}-{salarySendDetailBaseInfo.salaryMonth && salarySendDetailBaseInfo.salaryMonth.monthValue}</span>
<WeaHelpfulTip
style={{marginLeft: '10px', marginRight: "10px"}}
width={200}
title={`薪资周期\n
${salarySendDetailBaseInfo.salarySobCycle && salarySendDetailBaseInfo.salarySobCycle.salaryCycle && salarySendDetailBaseInfo.salarySobCycle.salaryCycle.fromDate}${salarySendDetailBaseInfo.salarySobCycle && salarySendDetailBaseInfo.salarySobCycle.salaryCycle && salarySendDetailBaseInfo.salarySobCycle.salaryCycle.endDate}\n
税款所属期\n
${salarySendDetailBaseInfo.salarySobCycle && salarySendDetailBaseInfo.salarySobCycle.taxCycle}\n
考勤取值周期\n
${salarySendDetailBaseInfo.salarySobCycle && salarySendDetailBaseInfo.salarySobCycle.attendCycle && salarySendDetailBaseInfo.salarySobCycle.attendCycle.fromDate}${salarySendDetailBaseInfo.salarySobCycle && salarySendDetailBaseInfo.salarySobCycle.attendCycle && salarySendDetailBaseInfo.salarySobCycle.attendCycle.endDate}\n
福利台账月份\n
引用${salarySendDetailBaseInfo.salarySobCycle && salarySendDetailBaseInfo.salarySobCycle.socialSecurityCycle}的福利台账数据`}
placement="topLeft"
/>
<span>工资单模板{salarySendDetailBaseInfo.template}</span>
</div>
</div>
<div style={{marginTop: "10px", height: "500px", overflowY: "scroll"}}>
<WeaTable rowSelection={rowSelection} dataSource={canGrantDataSource} columns={this.getColumns()}
pagination={{
onChange: (value) => {this.handleDataPageChange(value)},
total: canGrantPageInfo.total,
current: canGrantPageInfo.pageNum,
showTotal: (total) => `${total}`,
}}
/>
</div>
</Modal>
)
}
}