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

213 lines
7.6 KiB
JavaScript
Raw Normal View History

2024-08-08 18:24:45 +08:00
/*
* 浮动薪酬
* 薪资档案列表
* @Author: 黎永顺
* @Date: 2024/8/8
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
2024-08-13 17:58:28 +08:00
import { inject, observer } from "mobx-react";
2024-10-14 16:02:12 +08:00
import { WeaLocaleProvider, WeaTools } from "ecCom";
2024-08-12 09:24:11 +08:00
import { WeaTableNew } from "comsMobx";
import { message, Modal, Spin } from "antd";
2024-08-08 18:24:45 +08:00
import * as API from "../../../../apis/variableSalary";
2024-10-14 16:02:12 +08:00
import { getSearchs } from "../../../../util";
import { extraConditions } from "../../conditions";
import AdvanceInputBtn from "../advanceInputBtn";
import SearchPannel from "../searchPannel";
2024-08-12 09:24:11 +08:00
import { toJS } from "mobx";
2024-10-14 16:02:12 +08:00
import cs from "classnames";
2024-08-08 18:24:45 +08:00
2024-08-12 09:24:11 +08:00
const WeaTableComx = WeaTableNew.WeaTable;
2024-08-08 18:24:45 +08:00
const getLabel = WeaLocaleProvider.getLabel;
2024-10-14 16:02:12 +08:00
const getKey = WeaTools.getKey;
2024-08-08 18:24:45 +08:00
2024-10-16 14:42:57 +08:00
@inject("baseTableStore") @observer
2024-08-08 18:24:45 +08:00
class Index extends Component {
constructor(props) {
super(props);
this.state = {
2024-10-16 14:42:57 +08:00
pageInfo: { current: 1, pageSize: 10, total: 0 },
loading: false,
dataSource: [],
columns: [],
selectedRowKeys: [],
condtions: [],
showSearchAd: false
2024-08-08 18:24:45 +08:00
};
}
2024-10-14 16:02:12 +08:00
async componentDidMount() {
const { data: taxAgentOption } = await API.getAdminTaxAgentList();
this.setState({
condtions: _.map(extraConditions, item => {
return {
...item, items: _.map(item.items, child => {
if (getKey(child) === "taxAgentIds") {
return {
2024-10-16 14:42:57 +08:00
...child,
label: getLabel(child.lanId, child.label),
2024-10-14 16:02:12 +08:00
options: _.map(taxAgentOption, o => ({ key: o.id, showname: o.content }))
};
}
return { ...child, label: getLabel(child.lanId, child.label) };
})
};
})
}, () => {
const { baseTableStore: { VExtraSalryForm } } = this.props;
VExtraSalryForm.initFormFields(this.state.condtions);
});
2024-08-12 09:24:11 +08:00
window.addEventListener("message", this.handleReceive, false);
window.addEventListener("resize", this.handleResize, false);
2024-08-08 18:24:45 +08:00
this.getVariableSalaryList();
}
2024-08-12 09:24:11 +08:00
componentWillUnmount() {
window.removeEventListener("message", this.handleReceive, false);
window.removeEventListener("resize", this.handleResize, false);
}
2024-08-08 18:24:45 +08:00
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.isQuery !== this.props.isQuery) this.setState({
pageInfo: { ...this.state.pageInfo, current: 1 }
}, () => this.getVariableSalaryList());
}
2024-08-12 09:24:11 +08:00
handleReceive = async ({ data }) => {
const { type, payload: { id, params } = {} } = data;
if (type === "init") {
this.getColumns();
} else if (type === "turn") {
switch (id) {
case "PAGEINFO":
this.setState({
pageInfo: { ...this.state.pageInfo, ...params }
}, () => this.getVariableSalaryList());
break;
2024-10-14 14:20:02 +08:00
case "CHECKBOX":
const { selectedRowKeys } = params;
this.setState({ selectedRowKeys });
break;
2024-08-12 09:24:11 +08:00
case "DEL":
this.handleDelete([params.id]);
break;
2024-10-14 14:20:02 +08:00
case "EDIT":
2024-08-12 09:24:11 +08:00
this.handleView(params.id);
break;
default:
break;
}
}
};
2024-08-08 18:24:45 +08:00
getVariableSalaryList = () => {
2024-10-14 16:02:12 +08:00
const { baseTableStore: { VSalryForm, VExtraSalryForm, getVariableSalaryList } } = this.props;
2024-08-08 18:24:45 +08:00
const { pageInfo } = this.state;
2024-10-14 16:02:12 +08:00
const { taxAgentIds } = VExtraSalryForm.getFormParams(), { departmentIds } = VSalryForm.getFormParams();
2024-08-08 18:24:45 +08:00
this.setState({ loading: true });
2024-08-12 09:24:11 +08:00
getVariableSalaryList({
2024-10-14 16:02:12 +08:00
...pageInfo, ...VSalryForm.getFormParams(), ...VExtraSalryForm.getFormParams(),
2024-10-14 14:20:02 +08:00
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [],
taxAgentIds: _.isEmpty(taxAgentIds) ? [] : taxAgentIds.split(",")
2024-08-12 09:24:11 +08:00
}).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const { pageInfo: result } = data;
const { list: dataSource, pageNum: current, pageSize, total } = result;
this.setState({
2024-10-16 14:42:57 +08:00
pageInfo: { ...pageInfo, current, pageSize, total }, dataSource
});
2024-08-12 09:24:11 +08:00
}
});
2024-08-08 18:24:45 +08:00
};
2024-08-12 09:24:11 +08:00
handleView = (id) => {
API.getVariableSalaryDetail({ id }).then(({ status, data }) => {
if (status) this.props.onViewSalaryFile(data.data);
2024-08-08 18:24:45 +08:00
});
};
2024-08-12 09:24:11 +08:00
handleDelete = (ids) => {
2024-08-08 18:24:45 +08:00
Modal.confirm({
2024-10-16 14:42:57 +08:00
title: getLabel(111, "信息确认"), content: getLabel(111, "确认删除吗?"), onOk: () => {
2024-08-12 09:24:11 +08:00
API.deleteVariableSalary({ ids }).then(({ status, errormsg }) => {
2024-08-08 18:24:45 +08:00
if (status) {
message.success(getLabel(111, "删除成功"));
2024-10-14 14:20:02 +08:00
this.setState({ selectedRowKeys: [] }, () => this.getVariableSalaryList());
2024-08-08 18:24:45 +08:00
} else {
message.error(errormsg);
}
});
}
});
};
2024-08-12 09:24:11 +08:00
getColumns = () => {
const { baseTableStore: { SFTableStore }, showOperateBtn } = this.props;
const columns = _.map(_.filter(toJS(SFTableStore.columns), (item) => item.display === "true"), (it, idx) => ({
2024-10-16 14:42:57 +08:00
dataIndex: it.dataIndex, title: it.title, align: "left", width: 150, ellipsis: true
2024-08-12 09:24:11 +08:00
}));
if (!_.isEmpty(columns)) {
this.postMessageToChild({
2024-10-16 14:42:57 +08:00
columns,
showOperateBtn,
dataSource: this.state.dataSource,
scrollHeight: 95,
pageInfo: this.state.pageInfo,
unitTableType: "variableSalary",
selectedRowKeys: this.state.selectedRowKeys
2024-08-12 09:24:11 +08:00
});
}
return columns;
};
postMessageToChild = (payload = {}) => {
const i18n = {
2024-10-16 14:42:57 +08:00
"操作": getLabel(30585, "操作"),
"编辑": getLabel(111, "编辑"),
"共": getLabel(18609, "共"),
"条": getLabel(18256, "条"),
2024-08-12 09:24:11 +08:00
"删除": getLabel(111, "删除")
};
const childFrameObj = document.getElementById("unitTable");
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
};
2024-10-14 16:02:12 +08:00
openAdvanceSearch = () => this.setState({ showSearchAd: !this.state.showSearchAd });
2024-08-08 18:24:45 +08:00
render() {
2024-10-14 16:02:12 +08:00
const { loading, dataSource, condtions, showSearchAd } = this.state;
const { baseTableStore: { SFTableStore, VExtraSalryForm } } = this.props;
2024-08-12 09:24:11 +08:00
const dom = document.querySelector(".wea-new-top-req-content");
let height = 280;
if (dom && dataSource.length > 0) {
2024-10-14 16:02:12 +08:00
height = (parseFloat(dom.style.height) > 620 && dataSource.length === 10) ? dataSource.length * 46 + 108 : dataSource.length < 10 ? dataSource.length * 46 + 108 : parseFloat(dom.style.height) - 62;
2024-08-12 09:24:11 +08:00
}
2024-10-16 14:42:57 +08:00
return (<React.Fragment>
<div className="extraFormQuery form-dialog-layout">
{getSearchs(VExtraSalryForm, condtions, 2, false, () => this.getVariableSalaryList())}
<AdvanceInputBtn searchType="advance" onOpenAdvanceSearch={() => this.openAdvanceSearch()}
onAdvanceSearch={this.getVariableSalaryList}/>
</div>
<div className={cs("searchAdvanced-condition-container", { "searchAdvanced-condition-hide": !showSearchAd })}>
<SearchPannel onCancel={() => this.setState({ showSearchAd: false })}
2024-10-16 15:23:21 +08:00
onAdSearch={() => {
this.openAdvanceSearch();
this.getVariableSalaryList();
}}/>
2024-10-16 14:42:57 +08:00
</div>
<div style={{ height: height + "px" }}>
<Spin spinning={loading}>
<iframe
style={{ border: 0, width: "100%", height: "100%" }}
// src="http://localhost:7607/#/unitTable"
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/unitTable"
id="unitTable"
/>
</Spin>
</div>
<WeaTableComx style={{ display: "none" }} comsWeaTableStore={SFTableStore} needScroll={true}
columns={this.getColumns()}/>
</React.Fragment>);
2024-08-08 18:24:45 +08:00
}
}
export default Index;