salary-management-front/pc4mobx/hrmSalary/pages/salaryFile/index.js

448 lines
14 KiB
JavaScript
Raw Normal View History

2022-02-25 09:24:56 +08:00
import React from 'react';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
2022-04-02 17:34:40 +08:00
import { Button, Table, DatePicker, Dropdown, Menu, message } from 'antd';
2022-02-25 09:24:56 +08:00
2022-04-01 10:24:55 +08:00
import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable,
WeaInputSearch, WeaSlideModal, WeaCheckbox, WeaHelpfulTip } from 'ecCom';
2022-02-25 09:24:56 +08:00
import { renderNoright, getSearchs } from '../../util'; // 渲染form数据的方法因为多个页面都会使用所以抽的公共方法在util中
import CustomTab from '../../components/customTab';
import ContentWrapper from '../../components/contentWrapper';
import { columns, dataSource } from './columns';
2022-03-17 17:18:42 +08:00
import ChangeSalaryModal from "./changeSalaryModal"
2022-03-17 17:53:35 +08:00
import EditAgentModal from './editAgentModal';
2022-03-17 18:40:47 +08:00
import SlideModalTitle from '../../components/slideModalTitle'
import SlideSalaryItem from './slideSalaryItem'
2022-03-17 18:57:56 +08:00
import SlideAgent from './slideAgent'
2022-04-01 10:24:55 +08:00
import ImportModal from '../../components/importModal'
2022-04-02 17:34:40 +08:00
import SalaryFileViewSlide from './saralyFileViewSlide'
2022-06-07 09:08:36 +08:00
import CustomPaginationTable from "../../components/customPaginationTable"
2022-03-17 17:18:42 +08:00
2022-02-25 09:24:56 +08:00
const { MonthPicker } = DatePicker;
2022-04-12 18:29:28 +08:00
import "./index.less"
2022-04-25 17:18:58 +08:00
import CustomTable from '../../components/customTable';
2022-04-12 18:29:28 +08:00
2022-04-01 10:24:55 +08:00
@inject('salaryFileStore')
2022-02-25 09:24:56 +08:00
@observer
export default class SalaryFile extends React.Component {
constructor(props) {
super(props);
this.state = {
value: "",
2022-03-17 17:18:42 +08:00
selectedKey: "0",
2022-03-17 17:53:35 +08:00
changeSalaryVisible: false,
2022-03-17 18:40:47 +08:00
editAgentVisible: false,
selectedTab: 0,
2022-04-01 10:24:55 +08:00
editSlideVisible: false,
importType: "",
modalVisiable: false,
2022-04-02 17:34:40 +08:00
step: 0,
recordSlideVisible: false,
2022-04-12 18:29:28 +08:00
selectedRowKeys: [],
2022-04-20 19:24:14 +08:00
showSearchBar: false,
2022-05-10 15:31:13 +08:00
importResult: {},
searchValue: ""
2022-02-25 09:24:56 +08:00
}
2022-06-07 09:08:36 +08:00
this.pageInfo = {current: 1, pageSize: 10}
2022-02-25 09:24:56 +08:00
}
2022-04-01 10:24:55 +08:00
componentWillMount() {
2022-04-02 17:34:40 +08:00
const { salaryFileStore: {doInit} } = this.props;
doInit();
2022-04-01 10:24:55 +08:00
}
// 设置导入步数
setStep(step) {
this.setState({step})
}
// 渲染导入模板附加元素
renderFormComponent() {
return (
<div style={{display: "inline-block"}}>
<WeaCheckbox id="importData" content="导出现有数据" />
<WeaHelpfulTip
width={200}
title="提示:建议先导出现有最新数据,修改后再导入"
placement="topLeft"
/>
</div>
)
}
// 导入预览
handlePreviewImport(params) {
const { salaryFileStore: {importPreview}} = this.props;
params.importType = this.state.importType;
importPreview(params)
}
2022-04-01 13:54:24 +08:00
// 导入档案
handleImportFile(params) {
const { salaryFileStore: {importSalaryArchive}} = this.props;
params.importType = this.state.importType
2022-04-20 19:24:14 +08:00
importSalaryArchive(params).then(data => {
data.errorData = data.errorNotice
this.setState({
importResult: data
})
})
2022-04-01 13:54:24 +08:00
}
// 导入完成按钮操作
handleImportFinish() {
this.setState({modalVisiable: false, step: 0})
}
// 导出全部
handleExportAll() {
const { salaryFileStore: {exportSalaryArchive}} = this.props;
exportSalaryArchive();
}
2022-04-02 17:34:40 +08:00
// 定制列
getColumns() {
const { salaryFileStore: {tableStore}} = this.props;
2022-04-19 10:11:40 +08:00
return tableStore.columns.filter(item => item.display == "true").map(item => {
2022-04-25 16:17:03 +08:00
item.width = item.oldWidth
2022-04-02 17:34:40 +08:00
if(item.dataIndex == "operate") {
item.render = (text, record) => (
2022-04-07 13:39:21 +08:00
<a onClick={() => this.handleEdit(record)}>查看</a>
2022-04-02 17:34:40 +08:00
)
2022-04-25 16:17:03 +08:00
item.fixed = 'right'
} else if(item.dataIndex == "username"){
item.fixed = 'left'
2022-04-02 17:34:40 +08:00
}
return item
})
}
// 编辑行
handleEdit(record) {
2022-04-07 13:39:21 +08:00
this.setState({editSlideVisible: true})
const { salaryFileStore: {setCurrentId}} = this.props;
setCurrentId(record.id)
2022-04-02 17:34:40 +08:00
}
// 显示调整个税扣缴义务人表单
handSildeOptionMenuClick(e) {
2022-04-07 18:35:09 +08:00
const { salaryFileStore: {setEditAgentVisible}} = this.props;
setEditAgentVisible(true)
2022-04-02 17:34:40 +08:00
}
// 查看 Slide 头部操作按钮
renderEditSlideOperate() {
return <div style={{display: "inline-block"}}>
<Dropdown.Button type="primary" overlay={
<Menu onClick={this.handSildeOptionMenuClick.bind(this)}>
<Menu.Item key="1">调整个税扣缴义务人</Menu.Item>
</Menu>
} onClick={() => {this.setState({changeSalaryVisible: true})}}>调薪</Dropdown.Button>
</div>
}
// table选中条目
onSelectChange = selectedRowKeys => {
this.setState({ selectedRowKeys });
};
2022-04-12 18:29:28 +08:00
// 显示影响搜索面板
handleShowSearchBar = () => {
this.setState({
showSearchBar: !this.state.showSearchBar
})
}
2022-04-24 17:52:38 +08:00
// 页面跳转
handlePageChange = (value) => {
const { salaryFileStore: {getTableDatas, form}} = this.props;
2022-06-07 09:08:36 +08:00
this.pageInfo.current = value;
getTableDatas(this.pageInfo)
}
handleShowSizeChange(pageInfo) {
const { salaryFileStore: {getTableDatas, form}} = this.props;
getTableDatas(pageInfo)
2022-04-24 17:52:38 +08:00
}
2022-05-10 15:31:13 +08:00
// 搜索
handleSearch(value) {
const { salaryFileStore: {getTableDatas, form}} = this.props;
2022-05-30 17:30:53 +08:00
getTableDatas({username: value})
2022-05-10 15:31:13 +08:00
}
2022-04-24 17:52:38 +08:00
2022-05-12 17:04:33 +08:00
// 初始化导入参数
handleInitModal() {
const { salaryFileStore: { setPreviewDataSource } } = this.props;
setPreviewDataSource([])
this.setState({
importResult: {}
})
}
2022-02-25 09:24:56 +08:00
render() {
2022-04-01 10:24:55 +08:00
const { salaryFileStore } = this.props;
const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = salaryFileStore;
2022-04-24 17:52:38 +08:00
const { importType, previewColumns, previewDataSource, dataSource, currentId, editAgentVisible, setEditAgentVisible, pageInfo } = salaryFileStore;
2022-04-25 14:32:51 +08:00
2022-04-02 17:34:40 +08:00
const { selectedTab, step, selectedRowKeys } = this.state;
2022-02-25 09:24:56 +08:00
if (!hasRight && !loading) { // 无权限处理
return renderNoright();
}
const rightMenu = [// 右键菜单
{
key: 'BTN_COLUMN',
icon: <i className='icon-coms-Custom' />,
content: '显示列定制',
onClick: this.showColumn
},
];
const collectParams = { // 收藏功能配置
favname: '薪资档案',
favouritetype: 1,
objid: 0,
link: 'wui/index.html#/ns_demo03/index',
importantlevel: 1,
};
const adBtn = [ // 高级搜索内部按钮
<Button type="primary" onClick={doSearch}>搜索</Button>,
<Button type="ghost" onClick={() => form.resetForm()}>重置</Button>,
<Button type="ghost" onClick={() => setShowSearchAd(false)}>取消</Button>,
];
const topTab = [
2022-04-01 13:54:24 +08:00
];
2022-02-25 09:24:56 +08:00
const renderSearchOperationItem = () => {
}
2022-03-17 17:18:42 +08:00
const handleMenuClick = (e) => {
2022-04-19 10:11:40 +08:00
this.setState({importType: e.key, modalVisiable: true, step: 0})
2022-03-17 17:18:42 +08:00
}
const handleMenuClick2 = () => {
2022-04-02 17:34:40 +08:00
const { electedRowKeys } = this.state;
if(selectedRowKeys.length == 0) {
message.warning("未选择条目")
return
}
const { salaryFileStore: {exportSalaryArchive}} = this.props;
exportSalaryArchive(selectedRowKeys.join(","))
2022-03-17 17:18:42 +08:00
}
const menu = (
<Menu onClick={handleMenuClick}>
2022-04-01 10:24:55 +08:00
{
importType.map(item => (
<Menu.Item key={item.id}>{item.content}</Menu.Item>
))
}
2022-03-17 17:18:42 +08:00
</Menu>
);
const menu2 = (
<Menu onClick={handleMenuClick2}>
2022-04-01 13:54:24 +08:00
<Menu.Item key="1">导出所选</Menu.Item>
2022-03-17 17:18:42 +08:00
</Menu>
);
const renderRightOperation = () => {
return (
2022-04-12 18:29:28 +08:00
<div style={{display: "inline-block", position: 'relative'}} className="salaryFileTabWrapper">
2022-04-01 10:24:55 +08:00
<WeaHelpfulTip
style={{marginRight: '10px'}}
width={200}
title="导入按钮使用场景说明\n
1.档案初始化\n
a.初次使用薪酬模块全量导入员工的薪资档案数据\n
b.员工入职导入新入职的员工的薪资档案数据若导入表格中的人员已存在在薪资档案中初始化导入会将档案中该人员的数据清除再导入\n
c.返聘人员使用调薪功能调整薪资档案值或使用调整个税扣缴\n
2.调薪档案中已存在的人员批量调整薪资项目值包括返聘人员的情况\n
3.调整个税扣缴义务人档案中已存在的人员批量调整个税扣缴义务人包括返聘人员的情况\n"
placement="topLeft"
/>
2022-03-17 17:18:42 +08:00
<Dropdown.Button type="primary" style={{marginRight: "10px"}} overlay={menu}>导入</Dropdown.Button>
2022-04-01 13:54:24 +08:00
<Dropdown.Button style={{marginRight: "10px"}} overlay={menu2} onClick={() => {this.handleExportAll()}}>导出全部</Dropdown.Button>
2022-04-02 17:34:40 +08:00
<Button type="default" style={{marginRight: "10px"}} onClick={() => {this.setState({recordSlideVisible: true})}}>调薪记录</Button>
2022-05-10 15:31:13 +08:00
<WeaInputSearch value={this.state.searchValue} onChange={(value) => {this.setState({
searchValue: value
})}} onSearch={(value) => {this.handleSearch(value)}}/>
{/* <Button type="default" onClick={() =>{this.handleShowSearchBar()}}>高级搜索</Button> */}
2022-03-17 17:18:42 +08:00
</div>
)
}
2022-03-17 18:40:47 +08:00
const handleSlideMoreMenuClick = () => {
}
const slideMoreMenu = (
<Menu onClick={handleSlideMoreMenuClick}>
<Menu.Item key="1">导出全部</Menu.Item>
</Menu>
);
const renderCustomOperate = () => {
return (
<div style={{display: "inline-block"}}>
<Dropdown.Button type="primary" overlay={slideMoreMenu}>导出</Dropdown.Button>
<Button type="default">自定义列</Button>
</div>
)
}
2022-04-02 17:34:40 +08:00
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange,
};
2022-02-25 09:24:56 +08:00
return (
<div className="mySalaryBenefitsWrapper">
<WeaRightMenu
datas={rightMenu} // 右键菜单
collectParams={collectParams} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
>
<WeaTop
title="薪资档案" // 文字
icon={<i className='icon-coms-meeting' />} // 左侧图标
iconBgcolor='#F14A2D' // 左侧图标背景色
showDropIcon={true} // 是否显示下拉按钮
dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
>
2022-03-17 17:18:42 +08:00
<CustomTab
searchOperationItem={
renderRightOperation()
}
/>
2022-06-07 09:08:36 +08:00
<CustomPaginationTable
2022-04-25 17:18:58 +08:00
loading={loading}
2022-04-02 17:34:40 +08:00
rowSelection={rowSelection}
columns={this.getColumns()}
dataSource={dataSource}
2022-06-07 09:08:36 +08:00
total={pageInfo.total}
current={pageInfo.pageNum}
pageSize={this.pageInfo.pageSize}
2022-04-25 16:17:03 +08:00
scroll={{x: 2300}}
2022-06-07 09:08:36 +08:00
onPageChange={(value) => {
this.handlePageChange(value)
}}
onShowSizeChange={(current, pageSize) => {
this.pageInfo = {current, pageSize}
this.handleShowSizeChange(this.pageInfo)
}}
2022-04-02 17:34:40 +08:00
/>
2022-02-25 09:24:56 +08:00
</WeaTop>
</WeaRightMenu>
2022-04-01 10:24:55 +08:00
{
this.state.modalVisiable &&
<ImportModal
2022-05-12 17:04:33 +08:00
init={() => {
this.handleInitModal()
}}
2022-04-01 10:24:55 +08:00
params={{}}
2022-04-01 13:54:24 +08:00
columns={previewColumns}
2022-04-01 10:24:55 +08:00
step={step}
setStep={this.setStep.bind(this)}
2022-04-01 13:54:24 +08:00
slideDataSource={previewDataSource}
2022-04-20 19:24:14 +08:00
importResult={this.state.importResult}
2022-04-01 13:54:24 +08:00
onFinish={() => {this.handleImportFinish()}}
2022-04-01 10:24:55 +08:00
previewImport={(params) => {
this.handlePreviewImport(params)
}}
2022-04-01 13:54:24 +08:00
importFile={(params) => {this.handleImportFile(params)}}
2022-04-01 10:24:55 +08:00
templateLink={"/api/bs/hrmsalary/salaryArchive/downloadTemplate?importType=" + this.state.importType}
renderFormComponent={() => {this.renderFormComponent()}}
visiable={this.state.modalVisiable}
onCancel={() => { this.setState({modalVisiable: false})}}
/>
}
2022-03-17 17:18:42 +08:00
{
this.state.changeSalaryVisible && <ChangeSalaryModal
2022-04-07 13:39:21 +08:00
currentId={currentId}
2022-03-17 17:53:35 +08:00
visible={this.state.changeSalaryVisible}
onCancel={() => {this.setState({changeSalaryVisible: false})}}
/>
}
{
2022-04-07 13:39:21 +08:00
editAgentVisible && <EditAgentModal
currentId={currentId}
visible={editAgentVisible}
onCancel={() => {setEditAgentVisible(false)}}
2022-03-17 17:53:35 +08:00
/>
2022-03-17 17:18:42 +08:00
}
2022-03-17 18:40:47 +08:00
2022-05-18 09:21:42 +08:00
{/* 操作记录 */}
2022-03-17 18:40:47 +08:00
{
2022-04-02 17:34:40 +08:00
this.state.recordSlideVisible &&
<WeaSlideModal visible={this.state.recordSlideVisible}
2022-03-17 18:40:47 +08:00
top={0}
width={40}
height={100}
direction={'right'}
measure={'%'}
title={
<SlideModalTitle
subtitle={"操作记录"}
tabs={[{title: '薪资项目', key: 0}, {title: "个税扣缴义务人", key: 1}]}
2022-04-08 09:26:58 +08:00
editable={false}
2022-03-17 18:40:47 +08:00
selectedTab={selectedTab}
customOperate={() => {renderCustomOperate()}}
subItemChange={
(item) => {this.setState({selectedTab: item.key})}
}
/>
}
content={<div>
{
selectedTab == 0 && <SlideSalaryItem />
}
{
2022-03-17 18:57:56 +08:00
selectedTab == 1 && <SlideAgent />
2022-03-17 18:40:47 +08:00
}
</div>}
2022-04-02 17:34:40 +08:00
onClose={() => this.setState({recordSlideVisible: false})}
showMask={true}
closeMaskOnClick={() => this.setState({recordSlideVisible: false})} />
}
{
this.state.editSlideVisible &&
<WeaSlideModal visible={this.state.editSlideVisible}
top={0}
width={40}
height={100}
direction={'right'}
measure={'%'}
title={
<SlideModalTitle
subtitle={"员工薪资档案"}
editable={false}
customOperate={this.renderEditSlideOperate()}
/>
}
2022-04-07 13:39:21 +08:00
content={<SalaryFileViewSlide id={currentId} />}
2022-03-17 18:40:47 +08:00
onClose={() => this.setState({editSlideVisible: false})}
showMask={true}
closeMaskOnClick={() => this.setState({editSlideVisible: false})} />
}
2022-03-17 17:18:42 +08:00
2022-02-25 09:24:56 +08:00
</div>
)
}
}