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

147 lines
6.6 KiB
JavaScript
Raw Normal View History

2024-08-08 14:36:11 +08:00
/*
* 浮动薪酬
*
* @Author: 黎永顺
* @Date: 2024/8/8
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
2024-08-15 15:24:00 +08:00
import { toJS } from "mobx";
2024-10-14 14:20:02 +08:00
import { WeaLoadingGlobal, WeaLocaleProvider, WeaReqTop } from "ecCom";
2024-08-12 14:58:36 +08:00
import * as API from "../../apis/variableSalary";
2024-08-08 14:36:11 +08:00
import AdvanceInputBtn from "./components/advanceInputBtn";
import SalaryItemDialog from "./components/salaryItemDialog";
2024-08-08 17:32:54 +08:00
import SalaryFileDialog from "./components/salaryFileDialog";
import SalaryItemList from "./components/salaryItemList";
2024-08-08 18:24:45 +08:00
import SalaryFileList from "./components/salaryFileList";
2024-08-12 09:24:11 +08:00
import SalaryFileImportDialog from "./components/salaryFileImportDialog";
2024-10-14 14:20:02 +08:00
import { Button, message } from "antd";
2024-08-08 17:32:54 +08:00
import "./index.less";
2024-08-08 14:36:11 +08:00
const getLabel = WeaLocaleProvider.getLabel;
@inject("taxAgentStore", "baseTableStore")
@observer
class Index extends Component {
constructor(props) {
super(props);
this.state = {
2024-10-14 16:02:12 +08:00
selectedKey: "salaryFile", isQuery: false,
2024-10-14 14:20:02 +08:00
SIDialog: { visible: false, title: "", id: "" }, //薪资项目薪资编辑弹框
SFDialog: { visible: false, title: "", detail: {} }, //薪资档案编辑弹框
2024-08-12 09:24:11 +08:00
SFImpDialog: { visible: false, title: getLabel(24023, "数据导入") }//薪资档案导入
2024-08-08 14:36:11 +08:00
};
}
handleAdvanceSearch = () => this.setState({ isQuery: !this.state.isQuery });
2024-08-12 09:24:11 +08:00
handleOperate = (type, detail = {}) => {
2024-10-14 16:02:12 +08:00
const { baseTableStore: { SFTableStore, VSalryForm, VExtraSalryForm } } = this.props;
2024-08-08 17:32:54 +08:00
switch (type) {
case "create":
this.setState({
2024-08-12 09:24:11 +08:00
SFDialog: {
2024-08-12 14:58:36 +08:00
...this.state.SFDialog, visible: true, detail,
2024-10-16 14:42:57 +08:00
title: _.isEmpty(detail) ? getLabel(111, "新增浮动数据") : getLabel(111, "编辑浮动数据")
2024-08-12 09:24:11 +08:00
}
2024-08-08 17:32:54 +08:00
});
break;
2024-08-12 09:24:11 +08:00
case "import":
this.setState({ SFImpDialog: { ...this.state.SFImpDialog, visible: true } });
break;
case "export":
2024-08-15 15:24:00 +08:00
const columns = _.map(_.filter(toJS(SFTableStore.columns), (item) => item.display === "true"), it => it.dataIndex);
2024-10-14 16:02:12 +08:00
const { taxAgentIds } = VExtraSalryForm.getFormParams(), { departmentIds } = VSalryForm.getFormParams();
2024-08-15 16:01:00 +08:00
const payload = {
2024-10-14 16:02:12 +08:00
...VSalryForm.getFormParams(), ...VExtraSalryForm.getFormParams(),
2024-08-15 16:01:00 +08:00
taxAgentIds: !_.isEmpty(taxAgentIds) ? taxAgentIds.split(",") : [],
2024-10-14 14:20:02 +08:00
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [],
columns
2024-08-15 16:01:00 +08:00
};
2024-08-15 15:24:00 +08:00
WeaLoadingGlobal.start();
const promise = API.exportVariableSalary(payload);
2024-08-12 09:24:11 +08:00
break;
2024-08-13 17:58:28 +08:00
case "custom_cols":
SFTableStore.setColSetVisible(true);
SFTableStore.tableColSet(true);
break;
2024-10-14 14:20:02 +08:00
case "batchDel":
const { state: { selectedRowKeys }, handleDelete } = this.salaryListRef.wrappedInstance;
if (_.isEmpty(selectedRowKeys)) {
message.warning(getLabel(111, "请选择数据!"));
return;
}
handleDelete(selectedRowKeys);
break;
2024-08-08 17:32:54 +08:00
default:
break;
}
};
2024-08-08 14:36:11 +08:00
render() {
2024-10-14 16:02:12 +08:00
const { selectedKey, SIDialog, SFDialog, SFImpDialog, isQuery } = this.state;
const { taxAgentStore: { showOperateBtn }, baseTableStore: { VSSalaryItemForm } } = this.props;
2024-08-08 14:36:11 +08:00
const tabs = [
{
title: getLabel(111, "浮动数据"), key: "salaryFile", showDropIcon: true,
2024-08-13 17:58:28 +08:00
dropMenuDatas: showOperateBtn ? [
{ key: "export", icon: <i className="icon-coms-export"/>, content: getLabel(111, "导出") },
{ key: "custom_cols", icon: <i className="icon-coms-Custom"/>, content: getLabel(32535, "显示列定制") }
] : [
{ key: "custom_cols", icon: <i className="icon-coms-Custom"/>, content: getLabel(32535, "显示列定制") }
],
2024-08-08 17:32:54 +08:00
buttons: showOperateBtn ? [
2024-08-12 09:56:58 +08:00
<Button type="primary" onClick={() => this.handleOperate("create")}>{getLabel(111, "新建")}</Button>,
2024-08-08 17:32:54 +08:00
<Button type="ghost" onClick={() => this.handleOperate("import")}>{getLabel(111, "导入")}</Button>,
2024-10-14 16:02:12 +08:00
<Button type="primary" onClick={() => this.handleOperate("batchDel")}>{getLabel(111, "批量删除")}</Button>
] : [],
children: <SalaryFileList {...this.props} isQuery={isQuery} ref={dom => this.salaryListRef = dom}
onViewSalaryFile={(data) => this.handleOperate("create", data)}/>
2024-08-08 14:36:11 +08:00
},
{
title: getLabel(111, "字段管理"), key: "salaryItem", showDropIcon: false, dropMenuDatas: [],
2024-08-08 14:36:11 +08:00
buttons: showOperateBtn ? [
<Button type="primary" onClick={() => this.setState({
2024-08-08 17:32:54 +08:00
SIDialog: { visible: true, id: "", title: getLabel(111, "新增薪资项目") }
2024-08-08 14:36:11 +08:00
})}>{getLabel(111, "新建")}</Button>,
<AdvanceInputBtn onAdvanceSearch={this.handleAdvanceSearch}/>
2024-08-08 17:32:54 +08:00
] : [<AdvanceInputBtn onAdvanceSearch={this.handleAdvanceSearch}/>],
children: <SalaryItemList {...this.props} isQuery={isQuery} onEditSalaryItem={data => this.setState({
SIDialog: { visible: true, id: data.id, title: getLabel(111, "编辑薪资项目") }
}, () => VSSalaryItemForm.updateFields({
name: data.name, dataType: data.dataType
}))}/>
2024-08-08 14:36:11 +08:00
}
];
return (
<WeaReqTop
2024-10-14 14:20:02 +08:00
title={getLabel(111, "浮动数据")} icon={<i className="icon-coms-fa"/>} selectedKey={selectedKey}
2024-08-08 14:36:11 +08:00
iconBgcolor="#F14A2D" tabDatas={tabs} className="variable_salary_wrapper"
buttons={_.find(tabs, o => selectedKey === o.key).buttons} buttonSpace={10}
2024-08-12 09:24:11 +08:00
onChange={selectedKey => this.setState({ selectedKey, SFDialog: { ...SFDialog, visible: false } })}
2024-08-12 14:58:36 +08:00
showDropIcon={_.find(tabs, o => selectedKey === o.key).showDropIcon} onDropMenuClick={this.handleOperate}
dropMenuDatas={_.find(tabs, o => selectedKey === o.key).dropMenuDatas}
2024-08-08 14:36:11 +08:00
>
2024-08-08 17:32:54 +08:00
{_.find(tabs, o => selectedKey === o.key).children}
{/*薪资项目*/}
2024-08-08 14:36:11 +08:00
<SalaryItemDialog {...SIDialog} onSearch={this.handleAdvanceSearch} onCancel={callback => this.setState({
SIDialog: { ...SIDialog, visible: false }
}, () => callback && callback())}/>
2024-08-08 17:32:54 +08:00
{/*薪资档案*/}
<SalaryFileDialog {...SFDialog} onSearch={this.handleAdvanceSearch} onClose={callback => this.setState({
SFDialog: { ...SFDialog, visible: false }
}, () => callback && callback())}/>
2024-08-12 09:24:11 +08:00
{/* 薪资档案导入*/}
2024-10-14 14:20:02 +08:00
<SalaryFileImportDialog {...this.props} {...SFImpDialog} onCancel={callback => {
this.setState({ SFImpDialog: { ...SFImpDialog, visible: false } },
() => callback && this.handleAdvanceSearch());
}}/>
2024-08-08 14:36:11 +08:00
</WeaReqTop>
);
}
}
export default Index;