feature/2.15.1.2407.01-浮动薪酬

This commit is contained in:
黎永顺 2024-08-12 14:58:36 +08:00
parent df2283d0f4
commit f05c43d011
8 changed files with 100 additions and 53 deletions

View File

@ -1,3 +1,4 @@
import { WeaTools } from "ecCom";
import { postFetch } from "../util/request";
//浮动薪酬项目列表
@ -41,4 +42,7 @@ export const deleteVariableSalary = params => {
export const getVariableSalaryDetail = params => {
return postFetch("/api/bs/hrmsalary/variableSalary/getDetail", params);
};
// 获取当前管理员下的所有的个税扣缴义务人
export const getAdminTaxAgentList = () => {
return WeaTools.callApi("/api/bs/hrmsalary/siaccount/getAdminTaxAgentList", "get", {});
};

View File

@ -18,7 +18,7 @@ class Index extends Component {
render() {
const { baseTableStore: { VSalryForm }, searchType } = this.props;
return (
<div className="salaryItem-advance-search">
<div className="variable-advance-search">
<WeaInputSearch value={VSalryForm.getFormParams().username}
onChange={v => VSalryForm.updateFields({ username: v })}
onSearch={this.props.onAdvanceSearch}

View File

@ -1,11 +1,11 @@
.salaryItem-advance-search {
.variable-advance-search {
display: flex;
align-items: center;
position: relative;
top: -1.5px;
.wea-advanced-search {
top: 2px;
top: 1px;
left: -1px;
height: 28px;
line-height: 1;

View File

@ -39,16 +39,24 @@ class Index extends Component {
}
initForm = (props) => {
const { baseTableStore: { VSSalaryFileForm }, detail } = props;
API.getCreateForm().then(({ status, data }) => {
const { baseTableStore: { VSSalaryFileForm }, detail, taxAgentOption } = props;
API.getCreateForm().then(({ data }) => {
this.setState({
conditions: [
..._.map(salaryFileConditions, item => ({
...item,
items: _.map(item.items, o => ({
...o, viewAttr: !_.isEmpty(detail) ? 1 : 3, label: getLabel(o.lanId, o.label),
value: detail[getKey(o)] || ""
}))
items: _.map(item.items, o => {
if (getKey(o) === "taxAgentIds") {
return {
...o, viewAttr: !_.isEmpty(detail) ? 1 : 3, label: getLabel(o.lanId, o.label),
options: taxAgentOption, value: detail[getKey(o)] || ""
};
}
return {
...o, viewAttr: !_.isEmpty(detail) ? 1 : 3, label: getLabel(o.lanId, o.label),
value: detail[getKey(o)] || ""
};
})
})),
{
items: _.map(data, o => ({
@ -79,12 +87,11 @@ class Index extends Component {
});
};
convertPayload = (payload) => {
const itemValueList = [];
return _.reduce(_.keys(payload), (pre, cur) => {
if (!_.isNaN(parseInt(cur))) {
const itemValueList = pre.variableItemId || [];
return {
...pre, itemValueList: [...itemValueList, { variableItemId: cur, itemValue: payload[cur] }]
};
itemValueList.push({ variableItemId: cur, itemValue: payload[cur] });
return { ...pre, itemValueList };
}
return { ...pre, [cur]: payload[cur] };
}, {});
@ -94,15 +101,13 @@ class Index extends Component {
VSSalaryFileForm.validateForm().then(f => {
if (f.isValid) {
const payload = VSSalaryFileForm.getFormParams();
console.log(payload, this.convertPayload(payload));
return;
this.setState({ loading: true });
API.createVariableSalary({ ...payload, id })
API.createVariableSalary({ ...this.convertPayload(payload), id })
.then(({ status, errormsg }) => {
this.setState({ loading: false });
if (status) {
message.success(getLabel(30700, "操作成功"));
this.props.onCancel(onSearch());
this.props.onClose(onSearch());
} else {
message.error(errormsg);
}
@ -129,7 +134,7 @@ class Index extends Component {
};
render() {
const { conditions, loading } = this.state;
const { conditions } = this.state;
const { baseTableStore: { VSSalaryFileForm }, onClose } = this.props;
return (<WeaSlideModal
className="variable_salary_file_dialog" {...this.props} direction="right" onClose={() => onClose()}

View File

@ -30,9 +30,9 @@ class Index extends Component {
componentWillReceiveProps(nextProps, nextContext) {
const { importDialog } = this.state;
if (nextProps.visible !== this.props.visible && nextProps.visible) {
const { baseTableStore: { VSalryForm }, salaryMonth } = nextProps;
const { baseTableStore: { VSalryForm }, salaryMonth, taxAgentIds } = nextProps;
const payload = {
salaryMonth, ...VSalryForm.getFormParams(), hasData: importDialog.hasData
salaryMonth, taxAgentIds, ...VSalryForm.getFormParams(), hasData: importDialog.hasData
};
this.setState({ importDialog: { ...importDialog, link: `${importDialog.link}?${convertToUrlString(payload)}` } });
} else {
@ -46,10 +46,12 @@ class Index extends Component {
}
handleImport = (payload) => {
const { salaryMonth } = this.props;
const { salaryMonth, taxAgentIds } = this.props;
const { importDialog } = this.state;
this.setState({ importDialog: { ...importDialog, nextloading: true } });
API.importVariableSalary({ ...payload, salaryMonth }).then(({ data, status }) => {
API.importVariableSalary({
...payload, salaryMonth, taxAgentIds: _.isEmpty(taxAgentIds) ? [] : taxAgentIds.split(",")
}).then(({ data, status }) => {
this.setState({ importDialog: { ...importDialog, nextloading: false } });
if (status) {
this.setState({
@ -73,8 +75,8 @@ class Index extends Component {
content={getLabel(543208, "导出现有数据")}
helpfulTip={getLabel(111, "提示:建议先导出现有最新数据,修改后再导入")}
onChange={val => {
const { baseTableStore: { VSalryForm }, salaryMonth } = this.props;
const payload = { salaryMonth, ...VSalryForm.getFormParams(), hasData: val === "1" };
const { baseTableStore: { VSalryForm }, salaryMonth, taxAgentIds } = this.props;
const payload = { salaryMonth, taxAgentIds, ...VSalryForm.getFormParams(), hasData: val === "1" };
this.setState({
importDialog: {
...importDialog, hasData: val === "1",

View File

@ -65,13 +65,13 @@ class Index extends Component {
}
};
getVariableSalaryList = () => {
const { baseTableStore: { VSalryForm, getVariableSalaryList }, salaryMonth } = this.props;
const { baseTableStore: { VSalryForm, getVariableSalaryList }, salaryMonth, taxAgentIds } = this.props;
const { pageInfo } = this.state;
const { departmentIds } = VSalryForm.getFormParams();
this.setState({ loading: true });
getVariableSalaryList({
...pageInfo, salaryMonth, ...VSalryForm.getFormParams(),
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : []
...pageInfo, salaryMonth, taxAgentIds: _.isEmpty(taxAgentIds) ? [] : taxAgentIds.split(","),
...VSalryForm.getFormParams(), departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : []
}).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
@ -113,7 +113,7 @@ class Index extends Component {
}));
if (!_.isEmpty(columns)) {
this.postMessageToChild({
columns, showOperateBtn, dataSource: this.state.dataSource, scrollHeight: 100,
columns, showOperateBtn, dataSource: this.state.dataSource, scrollHeight: 98,
pageInfo: this.state.pageInfo, unitTableType: "variableSalary"
});
}
@ -135,7 +135,7 @@ class Index extends Component {
const dom = document.querySelector(".wea-new-top-req-content");
let height = 280;
if (dom && dataSource.length > 0) {
height = (parseFloat(dom.style.height) > 620 && dataSource.length === 10) ? dataSource.length * 39 + 113 : dataSource.length < 10 ? dataSource.length * 39 + 113 : parseFloat(dom.style.height) - 16;
height = (parseFloat(dom.style.height) > 620 && dataSource.length === 10) ? dataSource.length * 46 + 108 : dataSource.length < 10 ? dataSource.length * 46 + 108 : parseFloat(dom.style.height) - 16;
}
return (
<React.Fragment>

View File

@ -108,14 +108,26 @@ export const salaryFileConditions = [
{
conditionType: "MONTHPICKER",
domkey: ["salaryMonth"],
fieldcol: 14,
fieldcol: 16,
label: "薪资所属月",
lanId: 111,
labelcol: 6,
labelcol: 8,
value: "",
rules: "required|string",
viewAttr: 3
},
{
conditionType: "SELECT",
domkey: ["taxAgentIds"],
fieldcol: 16,
label: "个税扣缴义务人",
lanId: 111,
labelcol: 8,
value: "",
options: [],
rules: "required|string",
viewAttr: 3
},
{
browserConditionParam: {
completeParams: {},
@ -140,16 +152,16 @@ export const salaryFileConditions = [
},
conditionType: "BROWSER",
domkey: ["employeeId"],
fieldcol: 14,
fieldcol: 16,
label: "人员",
lanId: 111,
labelcol: 6,
labelcol: 8,
value: "",
rules: "required|string",
viewAttr: 3
}
],
title: "", col: 1,
title: "", col: 2,
defaultshow: true
}
];

View File

@ -9,7 +9,8 @@
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaDatePicker, WeaLocaleProvider, WeaReqTop } from "ecCom";
import { WeaDatePicker, WeaLocaleProvider, WeaReqTop, WeaSelect } from "ecCom";
import * as API from "../../apis/variableSalary";
import AdvanceInputBtn from "./components/advanceInputBtn";
import SearchPannel from "./components/searchPannel";
import SalaryItemDialog from "./components/salaryItemDialog";
@ -31,14 +32,27 @@ class Index extends Component {
constructor(props) {
super(props);
this.state = {
selectedKey: "salaryFile", isQuery: false, showSearchAd: false,
salaryMonth: moment(new Date()).format("YYYY-MM"),
SIDialog: { visible: false, title: "", id: "" }, //薪资项目薪资编辑弹框
SFDialog: { visible: false, title: "", detail: {} }, //薪资档案编辑弹框
selectedKey: "salaryFile", isQuery: false, showSearchAd: false, taxAgentIds: "",
salaryMonth: moment(new Date()).format("YYYY-MM"), taxAgentOption: [],
SIDialog: { visible: false, title: "", id: "", taxAgentOption: [] }, //薪资项目薪资编辑弹框
SFDialog: { visible: false, title: "", detail: {}, taxAgentOption: [] }, //薪资档案编辑弹框
SFImpDialog: { visible: false, title: getLabel(24023, "数据导入") }//薪资档案导入
};
}
componentDidMount() {
API.getAdminTaxAgentList().then(({ status, data }) => {
if (status) {
const taxAgentOption = _.map(data, (o, i) => ({ key: String(o.id), showname: o.name }));
this.setState({
taxAgentOption, taxAgentIds: _.map(taxAgentOption, o => o.key).join(","),
SIDialog: { ...this.state.SIDialog, taxAgentOption },
SFDialog: { ...this.state.SFDialog, taxAgentOption }
});
}
});
}
handleAdvanceSearch = () => this.setState({ isQuery: !this.state.isQuery });
openAdvanceSearch = () => this.setState({ showSearchAd: !this.state.showSearchAd });
handleOperate = (type, detail = {}) => {
@ -46,7 +60,7 @@ class Index extends Component {
case "create":
this.setState({
SFDialog: {
visible: true, detail,
...this.state.SFDialog, visible: true, detail,
title: _.isEmpty(detail) ? getLabel(111, "新增薪资档案") : getLabel(111, "查看薪资档案")
}
});
@ -56,8 +70,8 @@ class Index extends Component {
break;
case "export":
const { baseTableStore: { VSalryForm } } = this.props;
const { salaryMonth } = this.state;
const payload = { salaryMonth, ...VSalryForm.getFormParams() };
const { salaryMonth, taxAgentIds } = this.state;
const payload = { salaryMonth, taxAgentIds, ...VSalryForm.getFormParams() };
window.open(`/api/bs/hrmsalary/variableSalary/export?${convertToUrlString(payload)}`, "_blank");
break;
default:
@ -66,29 +80,37 @@ class Index extends Component {
};
render() {
const { selectedKey, SIDialog, SFDialog, SFImpDialog, showSearchAd, isQuery, salaryMonth } = this.state;
const {
selectedKey, SIDialog, SFDialog, SFImpDialog, showSearchAd, isQuery, salaryMonth, taxAgentOption, taxAgentIds
} = this.state;
const { taxAgentStore: { showOperateBtn }, baseTableStore: { VSSalaryItemForm } } = this.props;
const tabs = [
{
title: getLabel(111, "薪资档案"), key: "salaryFile",
title: getLabel(111, "薪资档案"), key: "salaryFile", showDropIcon: showOperateBtn,
dropMenuDatas: showOperateBtn ? [{
key: "export", icon: <i className="icon-coms-export"/>, content: getLabel(111, "导出")
}] : [],
buttons: showOperateBtn ? [
<Button type="primary" onClick={() => this.handleOperate("create")}>{getLabel(111, "新建")}</Button>,
<Button type="ghost" onClick={() => this.handleOperate("import")}>{getLabel(111, "导入")}</Button>,
<Button type="primary" onClick={() => this.handleOperate("export")}>{getLabel(111, "导出")}</Button>,
<WeaDatePicker format="YYYY-MM" value={salaryMonth}
onChange={val => this.setState({ salaryMonth: val }, () => this.handleAdvanceSearch())}/>,
<WeaSelect options={taxAgentOption} style={{ width: 200, display: "flex" }} multiple value={taxAgentIds}
onChange={val => this.setState({ taxAgentIds: val }, () => this.handleAdvanceSearch())}/>,
<AdvanceInputBtn searchType="advance" onOpenAdvanceSearch={() => this.openAdvanceSearch()}
onAdvanceSearch={this.handleAdvanceSearch}/>
] : [
<WeaDatePicker format="YYYY-MM" value={salaryMonth} onChange={val => this.setState({ salaryMonth: val })}/>,
<WeaSelect options={taxAgentOption} style={{ width: 200, display: "flex" }} multiple value={taxAgentIds}
onChange={val => this.setState({ taxAgentIds: val }, () => this.handleAdvanceSearch())}/>,
<AdvanceInputBtn searchType="advance" onOpenAdvanceSearch={() => this.openAdvanceSearch()}
onAdvanceSearch={this.handleAdvanceSearch}/>
],
children: <SalaryFileList {...this.props} salaryMonth={salaryMonth} isQuery={isQuery}
children: <SalaryFileList {...this.props} salaryMonth={salaryMonth} taxAgentIds={taxAgentIds} isQuery={isQuery}
onViewSalaryFile={(data) => this.handleOperate("create", data)}/>
},
{
title: getLabel(111, "薪资项目"), key: "salaryItem",
title: getLabel(111, "薪资项目"), key: "salaryItem", showDropIcon: false, dropMenuDatas: [],
buttons: showOperateBtn ? [
<Button type="primary" onClick={() => this.setState({
SIDialog: { visible: true, id: "", title: getLabel(111, "新增薪资项目") }
@ -108,7 +130,8 @@ class Index extends Component {
iconBgcolor="#F14A2D" tabDatas={tabs} className="variable_salary_wrapper"
buttons={_.find(tabs, o => selectedKey === o.key).buttons} buttonSpace={10}
onChange={selectedKey => this.setState({ selectedKey, SFDialog: { ...SFDialog, visible: false } })}
showDropIcon={false}
showDropIcon={_.find(tabs, o => selectedKey === o.key).showDropIcon} onDropMenuClick={this.handleOperate}
dropMenuDatas={_.find(tabs, o => selectedKey === o.key).dropMenuDatas}
>
<div className={cs("searchAdvanced-condition-container", { "searchAdvanced-condition-hide": !showSearchAd })}>
<SearchPannel onCancel={() => this.setState({ showSearchAd: false })} onAdSearch={this.handleAdvanceSearch}/>
@ -123,10 +146,11 @@ class Index extends Component {
SFDialog: { ...SFDialog, visible: false }
}, () => callback && callback())}/>
{/* 薪资档案导入*/}
<SalaryFileImportDialog {...this.props} {...SFImpDialog} salaryMonth={salaryMonth} onCancel={callback => {
this.setState({ SFImpDialog: { ...SFImpDialog, visible: false } },
() => callback && this.handleAdvanceSearch());
}}/>
<SalaryFileImportDialog {...this.props} {...SFImpDialog} salaryMonth={salaryMonth} taxAgentIds={taxAgentIds}
onCancel={callback => {
this.setState({ SFImpDialog: { ...SFImpDialog, visible: false } },
() => callback && this.handleAdvanceSearch());
}}/>
</WeaReqTop>
);
}