salary-management-front/pc4mobx/hrmSalary/pages/ledger/slideRefereUser.js

100 lines
3.9 KiB
JavaScript
Raw Normal View History

2022-03-16 10:41:38 +08:00
import React from 'react';
2022-03-25 16:41:59 +08:00
import { inject, observer } from 'mobx-react';
2022-03-16 10:41:38 +08:00
import { Icon, Table } from 'antd';
import { WeaInputSearch } from "ecCom"
import { slideStep2Columns, dataSource } from './columns'
2022-03-25 16:41:59 +08:00
import AddUserModal from './addUserModal'
2022-03-16 10:41:38 +08:00
2022-03-25 16:41:59 +08:00
@inject('ledgerStore')
@observer
2022-03-16 10:41:38 +08:00
export default class SlideRefereUser extends React.Component {
2022-03-25 16:41:59 +08:00
constructor(props) {
super(props)
this.state = {
addUserModalVisible: false,
selectedRowKeys: [],
searchValue: ""
}
}
handleTabClick(tab) {
const { ledgerStore: {setIncludeType, getLedgerPersonRangeInclude, salarySobId, getLedgerPersonRangeExclude}} = this.props;
setIncludeType(tab)
if(tab == 1) {
getLedgerPersonRangeInclude({salarySobId: salarySobId})
} else {
getLedgerPersonRangeExclude({salarySobId: salarySobId})
}
}
componentWillMount() {
const { ledgerStore: {getLedgerPersonRangeInclude, salarySobId}} = this.props;
getLedgerPersonRangeInclude({salarySobId: salarySobId})
}
onSelectChange = selectedRowKeys => {
this.setState({ selectedRowKeys });
2022-04-07 18:35:09 +08:00
}
2022-03-25 16:41:59 +08:00
handleTabDelete = () => {
const {ledgerStore: {deleteLedgerPersonRange}} = this.props;
if(this.state.selectedRowKeys.length == 0) {
message.warning("未选择条目")
return
}
deleteLedgerPersonRange(this.state.selectedRowKeys)
}
handleSearch = (value) => {
const { ledgerStore: {includeType, salarySobId, getLedgerPersonRangeInclude, getLedgerPersonRangeExclude}} = this.props;
if(includeType == 1) {
2022-03-28 10:53:19 +08:00
getLedgerPersonRangeInclude({salarySobId: salarySobId, targetName: value})
2022-03-25 16:41:59 +08:00
} else {
2022-03-28 10:53:19 +08:00
getLedgerPersonRangeExclude({salarySobId: salarySobId, targetName: value})
2022-03-25 16:41:59 +08:00
}
}
2022-03-16 10:41:38 +08:00
render() {
2022-03-25 16:41:59 +08:00
const { ledgerStore: {includeType, userTableStore, addUserModalVisible, setAddUserModalVisible}} = this.props;
let { columns, list} = userTableStore
const { selectedRowKeys } = this.state
columns = columns || []
list = list || []
list.map(item => item.key = item.id)
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange,
};
2022-03-16 10:41:38 +08:00
return (
<div className="slideRefereUser">
<div className="refereUserHeader">
2022-03-25 16:41:59 +08:00
<div className="headerLeft"><span className={includeType == 1 ? "selectedCrumbs" : "tabItem"} onClick={() => {this.handleTabClick(1)}}>关联人员范围</span> {' '} | {' '} <span className={includeType == 0 ? "selectedCrumbs" : "tabItem"} onClick={() => {this.handleTabClick(0)}}></span></div>
<WeaInputSearch className="searchInput" value={this.state.searchValue} onChange={(value) => {this.setState({searchValue: value})}} onSearch={(value) => {this.handleSearch(value)}}/>
2022-03-16 10:41:38 +08:00
<div className="headerIcon">
2022-03-25 16:41:59 +08:00
<Icon className="iconItem" type="minus-square" onClick={() => {this.handleTabDelete()}}/>
<Icon className="iconItem" type="plus-square" onClick={() => {setAddUserModalVisible(true)}}/>
2022-03-16 10:41:38 +08:00
</div>
</div>
<div>
2022-03-25 16:41:59 +08:00
<Table rowSelection={rowSelection} dataSource={list} columns={columns} pagination={{
total: userTableStore.total,
2022-05-30 17:30:53 +08:00
showTotal: (total) => `${total}`,
2022-03-25 16:41:59 +08:00
current: userTableStore.pageNum
}}/>
2022-03-16 10:41:38 +08:00
</div>
2022-03-25 16:41:59 +08:00
{
addUserModalVisible && <AddUserModal
visible={addUserModalVisible}
onCancel={() => {setAddUserModalVisible(false)}}
/>
}
2022-03-16 10:41:38 +08:00
</div>
)
}
}