薪资档案的发薪员工页面的调薪记录添加编辑和删除的功能

This commit is contained in:
黎永顺 2022-11-15 15:42:09 +08:00
parent dcb2f5f864
commit a5213cb370
8 changed files with 237 additions and 115 deletions

View File

@ -261,3 +261,33 @@ export const stopSalary = (params) => {
export const getSalaryItemFormByItemId = (params) => {
return WeaTools.callApi('/api/bs/hrmsalary/salaryArchive/getSalaryItemFormBySalaryArchiveItemId', 'GET', params);
}
// 删除薪资项目调薪
export const deleteSalaryItem = (params) => {
return fetch(`/api/bs/hrmsalary/salaryArchive/deleteSalaryItem?salaryArchiveItemId=${params.salaryArchiveItemId}`, {
method: 'GET',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
}).then(res => res.json())
}
export const getSingleSalaryItemInfo = (params) => {
return fetch('/api/bs/hrmsalary/salaryArchive/adjustRecord/getSingleSalaryItemInfo', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json())
}
export const editSingleSalaryItem = (params) => {
return fetch('/api/bs/hrmsalary/salaryArchive/adjustRecord/editSingleSalaryItem', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json())
}

View File

@ -1,33 +1,35 @@
import React from 'react'
import './index.less'
import React from "react";
import "./index.less";
export default class SelectedTab extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedKey: "0"
}
}
constructor(props) {
super(props);
this.state = {
selectedKey: "0"
};
}
handleChange(item) {
this.setState({
selectedKey: item.key
})
this.props.onChange(item)
}
render() {
return (
<div className="selectedTabWrapper">
{
this.props.items.map(item => (
<div className={item.key == this.state.selectedKey ? "selectedTab selectedItem" : "selectedTab"} onClick={() => {
this.handleChange(item)
}}>
{item.name}
</div>
))
}
handleChange(item) {
this.setState({
selectedKey: item.key
});
this.props.onChange(item);
}
render() {
return (
<div className="selectedTabWrapper">
{
this.props.items.map(item => (
<div className={item.key == this.state.selectedKey ? "selectedTab selectedItem" : "selectedTab"}
onClick={() => {
this.handleChange(item);
}}>
{item.name}
</div>
)
}
}
))
}
</div>
);
}
}

View File

@ -8,13 +8,12 @@ import StandingBook from "./pages/socialSecurityBenefits/standingBook";
import StandingBookDetail from "./pages/socialSecurityBenefits/standingBookDetail";
import StandingBookOfflineComparison from "./pages/socialSecurityBenefits/standingBookOfflineComparison";
import SalaryItem from "./pages/salaryItem";
import SalaryFile from "./pages/salaryFile";
import PayrollFiles from "./pages/payrollFiles";
import CumDeduct from "./pages/dataAcquisition/cumDeduct";
import OtherDeduct from "./pages/dataAcquisition/otherDeduct";
import CumSituation from "./pages/dataAcquisition/cumSituation";
import Attendance from "./pages/dataAcquisition/attendance";
import SpecialAddDeduction from './pages/dataAcquisition/specialAddDeduction';
import SpecialAddDeduction from "./pages/dataAcquisition/specialAddDeduction";
import Ledger from "./pages/ledger";
import Calculate from "./pages/calculate";
import Payroll from "./pages/payroll";
@ -28,10 +27,10 @@ import PlaceOnFileDetail from "./pages/calculateDetail/placeOnFileDetail";
import CompareDetail from "./pages/calculateDetail/compareDetail";
import GenerateDeclarationDetail from "./pages/declare/generateDeclarationDetail";
import TemplatePreview from "./pages/payroll/templatePreview";
import MobilePayroll from './pages/mobilePayroll';
import SysConfig from './pages/sysConfig';
import RuleConfig from './pages/ruleConfig';
import Appconfig from './pages/appConfig';
import MobilePayroll from "./pages/mobilePayroll";
import SysConfig from "./pages/sysConfig";
import RuleConfig from "./pages/ruleConfig";
import Appconfig from "./pages/appConfig";
import stores from "./stores";
import "./style/index";
@ -84,14 +83,14 @@ const Routes = (
path="hrmSalary"
onEnter={getLocaleLabel}
component={Home}>
<Route key="mySalary" path="mySalary" component={MySalary} />
<Route key="mySalary" path="mySalary" component={MySalary}/>
<Route
key="socialSecurityBenefits"
path="socialSecurityBenefits"
component={SocialSecurityBenefits}>
<Route key="programme" path="programme" component={Programme} />
<Route key="archives" path="archives" component={Archives} />
<Route key="standingBook" path="standingBook" component={StandingBook} />
<Route key="programme" path="programme" component={Programme}/>
<Route key="archives" path="archives" component={Archives}/>
<Route key="standingBook" path="standingBook" component={StandingBook}/>
<Route
key="standingBookDetail"
path="standingBookDetail"
@ -103,20 +102,20 @@ const Routes = (
component={StandingBookOfflineComparison}
/>
</Route>
<Route key="salaryItem" path="salaryItem" component={SalaryItem} />
<Route key="salaryFile" path="salaryFile" component={PayrollFiles} />
<Route key="salaryItem" path="salaryItem" component={SalaryItem}/>
<Route key="salaryFile" path="salaryFile" component={PayrollFiles}/>
<Route
key="dataAcquisition"
path="dataAcquisition"
component={DataAcquisition}>
<Route key="cumDeduct" path="cumDeduct" component={CumDeduct} />
<Route key="otherDeduct" path="otherDeduct" component={OtherDeduct} />
<Route key="cumSituation" path="cumSituation" component={CumSituation} />
<Route key="attendance" path="attendance" component={Attendance} />
<Route key="specialAddDeduction" path="specialAddDeduction" component={SpecialAddDeduction} />
<Route key="cumDeduct" path="cumDeduct" component={CumDeduct}/>
<Route key="otherDeduct" path="otherDeduct" component={OtherDeduct}/>
<Route key="cumSituation" path="cumSituation" component={CumSituation}/>
<Route key="attendance" path="attendance" component={Attendance}/>
<Route key="specialAddDeduction" path="specialAddDeduction" component={SpecialAddDeduction}/>
</Route>
<Route key="ledger" path="ledger" component={Ledger} />
<Route key="calculate" path="calculate" component={Calculate} />
<Route key="ledger" path="ledger" component={Ledger}/>
<Route key="calculate" path="calculate" component={Calculate}/>
<Route
key="calculateDetail"
path="calculateDetail"
@ -127,33 +126,31 @@ const Routes = (
path="placeOnFileDetail"
component={PlaceOnFileDetail}
/>
<Route key="compareDetail" path="compareDetail" component={CompareDetail} />
<Route key="payroll" path="payroll" component={Payroll} />
<Route key="payrollGrant" path="payrollGrant" component={PayrollGrant} />
<Route key="payrollDetail" path="payrollDetail" component={PayrollDetail} />
<Route key="compareDetail" path="compareDetail" component={CompareDetail}/>
<Route key="payroll" path="payroll" component={Payroll}/>
<Route key="payrollGrant" path="payrollGrant" component={PayrollGrant}/>
<Route key="payrollDetail" path="payrollDetail" component={PayrollDetail}/>
<Route
key="templatePreview"
path="templatePreview"
component={TemplatePreview}
/>
<Route key="declare" path="declare" component={Declare} />
<Route key="declare" path="declare" component={Declare}/>
<Route
key="generateDeclarationDetail"
path="generateDeclarationDetail"
component={GenerateDeclarationDetail}
/>
<Route key="taxRate" path="taxRate" component={TaxRate} />
<Route key="taxAgent" path="taxAgent" component={TaxAgent} />
<Route key="mobilepayroll" path="mobilepayroll" component={MobilePayroll} />
<Route key="sysconfig" path="sysconfig" component={SysConfig} />
<Route key="sysconfig-1" path="sysconfig-1" component={RuleConfig} />
<Route key="appconfig" path="appconfig" component={Appconfig} />
<Route key="taxRate" path="taxRate" component={TaxRate}/>
<Route key="taxAgent" path="taxAgent" component={TaxAgent}/>
<Route key="mobilepayroll" path="mobilepayroll" component={MobilePayroll}/>
<Route key="sysconfig" path="sysconfig" component={SysConfig}/>
<Route key="sysconfig-1" path="sysconfig-1" component={RuleConfig}/>
<Route key="appconfig" path="appconfig" component={Appconfig}/>
</Route>
);
module.exports = {
Route: Routes,
store: stores,
store: stores
};

View File

@ -19,7 +19,8 @@ import {
WeaSlideModal,
WeaTab,
WeaTable,
WeaTop
WeaTop,
WeaPopoverHrm
} from "ecCom";
import { WeaTableNew } from "comsMobx";
import { Button, Dropdown, Menu, message, Modal, Popover } from "antd";
@ -412,7 +413,21 @@ class Index extends Component {
// }
// },
...columns], (item, index) => {
if (item.dataIndex === "operate") {
if (item.dataIndex === "username") {
return {
...item,
width: item.oldWidth,
render: (text, record) => {
return <a
href={`javaScript:openhrm(${record.employeeId});`}
onClick={e => window.pointerXY(e)}
title={text}
>
{text}
</a>;
}
};
}else if (item.dataIndex === "operate") {
return {
...item,
fixed: "right",
@ -693,7 +708,6 @@ class Index extends Component {
className="payrollFilesTab"
keyParam="viewcondition" //主键
countParam="groupid" //数量
// autoCalculateWidth={true}
leftStyle={{ paddingRight: $(".payrollFilesTab-right").width() }}
selectedKey={selectedKey}
onChange={this.handleChangeTab}
@ -721,6 +735,8 @@ class Index extends Component {
rowSelection={rowSelection}
scroll={{ x: 1200 }}
/>
{/*人员卡片*/}
<WeaPopoverHrm/>
<WeaTableComx
style={{ display: "none" }}
comsWeaTableStore={tableStore}

View File

@ -1,12 +1,10 @@
import React from "react";
import { Button, Col, message, Row, Select } from "antd";
import { Button, Col, message, Row } from "antd";
import { WeaDatePicker, WeaDialog, WeaInput, WeaSelect, WeaTable } from "ecCom";
import { inject, observer } from "mobx-react";
import moment from "moment";
import "./index.less";
const { Option } = Select;
@inject("salaryFileStore")
@observer
export default class ChangeSalaryModal extends React.Component {
@ -14,6 +12,7 @@ export default class ChangeSalaryModal extends React.Component {
super(props);
this.state = {
inited: false,
canOperator: false,
selectedRowKeys: [],
salaryArchiveItems: [
{
@ -44,8 +43,6 @@ export default class ChangeSalaryModal extends React.Component {
handleSalaryItemChange(item, value) {
const { salaryFileStore: { getSalaryItemAdjustBeforeValue } } = this.props;
const { salaryArchiveItems } = this.state;
// alert("item.id : "+ item.id)
// alert(JSON.stringify({salaryArchiveId: this.props.currentId, salaryItemId: item.id}))
getSalaryItemAdjustBeforeValue({ salaryArchiveId: this.props.currentId, salaryItemId: value }).then((data) => {
let dataSource = [...salaryArchiveItems];
dataSource.map(i => {
@ -76,7 +73,8 @@ export default class ChangeSalaryModal extends React.Component {
// 解析Columns
getColumns() {
const { salaryFileStore: { salaryItemChangeForm } } = this.props;
const { canOperator } = this.state;
const { salaryFileStore: { salaryItemChangeForm }, recordId } = this.props;
const { salaryItemList } = salaryItemChangeForm;
let { columns } = salaryItemChangeForm;
return columns.map(item => {
@ -88,7 +86,7 @@ export default class ChangeSalaryModal extends React.Component {
<WeaSelect
value={text}
style={{ width: 150 }}
viewAttr={3}
viewAttr={!recordId ? 3 : 1}
options={
!_.isEmpty(salaryItemList) ? [{ key: "", showname: "" }, ...salaryItemList] : [{
key: "",
@ -102,9 +100,14 @@ export default class ChangeSalaryModal extends React.Component {
item.title = <span>{item.title}</span>;
item.render = (text, record) => {
return (
<WeaInput style={{ width: "150px" }} viewAttr={3} value={text} onChange={(value) => {
this.handleSalaryAfterItemChange(record, value);
}}/>
<WeaInput
style={{ width: "150px" }}
viewAttr={((recordId && canOperator) || !recordId) ? 3 : 1}
value={text}
onChange={(value) => {
this.handleSalaryAfterItemChange(record, value);
}}
/>
);
};
}
@ -145,6 +148,7 @@ export default class ChangeSalaryModal extends React.Component {
request.adjustReason = data.adjustReason;
request.description = data.description;
this.setState({
canOperator: data.canOperator,
salaryArchiveItems: data.dataSource,
inited: true,
request
@ -161,7 +165,7 @@ export default class ChangeSalaryModal extends React.Component {
// 保存
handleSave() {
const { salaryFileStore: { saveSalaryItem, fetchSingleSalaryItemList, getArchiveForm } } = this.props;
const { salaryFileStore: { saveSalaryItem, editSingleSalaryItem, fetchSingleSalaryItemList, getArchiveForm }, recordId } = this.props;
let saveRequest = { ...this.state.request };
const { salaryArchiveItems } = this.state;
if (salaryArchiveItems.length === 0) {
@ -174,11 +178,19 @@ export default class ChangeSalaryModal extends React.Component {
result.adjustValue = item.adjustAfter;
return result;
});
saveSalaryItem(saveRequest).then(() => {
getArchiveForm(this.props.currentId);
fetchSingleSalaryItemList({ salaryArchiveId: this.props.currentId });
this.props.onCancel();
});
if (!recordId) {
saveSalaryItem(saveRequest).then(() => {
getArchiveForm(this.props.currentId);
fetchSingleSalaryItemList({ salaryArchiveId: this.props.currentId });
this.props.onCancel();
});
} else {
editSingleSalaryItem({ ...saveRequest, salaryArchiveItemId: recordId }).then(() => {
getArchiveForm(this.props.currentId);
fetchSingleSalaryItemList({ salaryArchiveId: this.props.currentId });
this.props.onCancel();
});
}
}
onSelectChange = selectedRowKeys => {
@ -199,8 +211,8 @@ export default class ChangeSalaryModal extends React.Component {
};
render() {
const { salaryFileStore: { salaryItemChangeForm } } = this.props;
const { request, salaryArchiveItems, selectedRowKeys } = this.state;
const { salaryFileStore: { salaryItemChangeForm }, recordId } = this.props;
const { request, salaryArchiveItems, selectedRowKeys, canOperator } = this.state;
const { effectiveTime, adjustReason, description } = request;
const rowSelection = {
@ -209,8 +221,10 @@ export default class ChangeSalaryModal extends React.Component {
};
return (
<WeaDialog
title="调薪" style={{ width: 800 }}
initLoadCss visible={this.props.visible}
title="调薪"
style={{ width: 800 }}
initLoadCss
visible={this.props.visible}
onCancel={() => {
this.props.onCancel();
}}
@ -224,7 +238,7 @@ export default class ChangeSalaryModal extends React.Component {
<Col span={6}>生效日期</Col>
<Col span={18}>
<WeaDatePicker
viewAttr={3}
viewAttr={((recordId && canOperator) || !recordId) ? 3 : 1}
format="yyyy-MM-dd"
style={{ width: "200px" }}
value={effectiveTime}
@ -240,7 +254,7 @@ export default class ChangeSalaryModal extends React.Component {
<WeaSelect
value={adjustReason}
style={{ width: 200 }}
viewAttr={3}
viewAttr={((recordId && canOperator) || !recordId) ? 3 : 1}
onChange={(value) => this.handleChange({ adjustReason: value })}
options={
!_.isEmpty(salaryItemChangeForm.adjustReasonList) ?
@ -257,10 +271,10 @@ export default class ChangeSalaryModal extends React.Component {
说明
</Col>
<Col span={18}>
<WeaInput
style={{ width: "200px" }}
value={description}
viewAttr={((recordId && canOperator) || !recordId) ? 3 : 1}
onChange={value => {
this.handleChange({ description: value });
}}
@ -271,27 +285,37 @@ export default class ChangeSalaryModal extends React.Component {
<div className="contentWrapper">
<div className="contentTitleWrapper" style={{ height: "40px", lineHeight: "40px" }}>
<span className="contentTitle" style={{ fontSize: "14px", color: "#666" }}>调薪明细</span>
<div className="rightIconWrapper" style={{ display: "inline-block", float: "right" }}>
<Button type="primary"
size="small"
disabled={salaryArchiveItems.length === 1}
onClick={() => {
this.handleRemoveClick();
}}
><span className="icon-coms-form-delete-hot" title="删除"></span></Button>
<Button type="primary"
size="small"
onClick={() => {
this.handleAddItemClick();
}}
><span className="icon-coms-Add-to-hot" title="添加"></span></Button>
</div>
{
!recordId &&
<div className="rightIconWrapper" style={{ display: "inline-block", float: "right" }}>
<Button
type="primary"
size="small"
disabled={salaryArchiveItems.length === 1}
onClick={() => {
this.handleRemoveClick();
}}
><span className="icon-coms-form-delete-hot" title="删除"></span></Button>
<Button
type="primary"
size="small"
onClick={() => {
this.handleAddItemClick();
}}
><span className="icon-coms-Add-to-hot" title="添加"></span></Button>
</div>
}
</div>
<div className="tableWrapper">
{
this.state.inited &&
<WeaTable rowSelection={rowSelection} dataSource={salaryArchiveItems} columns={this.getColumns()} pagination={false}/>
<WeaTable
rowSelection={!recordId ? rowSelection : null}
dataSource={salaryArchiveItems}
columns={this.getColumns()}
pagination={false}
/>
}
</div>
</div>

View File

@ -1,7 +1,9 @@
import React from "react";
import { Menu, Popover, message } from "antd";
import { WeaTable } from "ecCom";
import { inject, observer } from "mobx-react";
import ChangeSalaryModal from "./changeSalaryModal";
import { deleteSalaryItem } from '../../apis/archive';
@inject("salaryFileStore")
@observer
@ -16,12 +18,12 @@ export default class SalaryItemChangeList extends React.Component {
}
componentWillMount() {
const { salaryFileStore: { fetchSingleSalaryItemList }, id } = this.props;
const { salaryFileStore: { fetchSingleSalaryItemList } } = this.props;
this.searchParams = { salaryArchiveId: this.props.id, current: 1 };
fetchSingleSalaryItemList(this.searchParams);
}
handleEdit(record) {
handleEdit = (record) => {
this.setState({
recordId: record.id
}, () => {
@ -29,15 +31,48 @@ export default class SalaryItemChangeList extends React.Component {
changeSalaryVisible: true
});
});
}
};
deleteSalaryItem = (salaryArchiveItemId) => {
const { salaryFileStore: { fetchSingleSalaryItemList } } = this.props;
deleteSalaryItem({ salaryArchiveItemId }).then(({status, errormsg}) => {
if(status){
message.success("删除成功")
this.searchParams = { salaryArchiveId: this.props.id, current: 1 };
fetchSingleSalaryItemList(this.searchParams);
}else{
message.error(errormsg || "删除失败")
}
});
};
// 获取Columns
getColumns() {
const { salaryFileStore: { singleSalaryItemList } } = this.props;
const { salaryFileStore: { singleSalaryItemList }, selectedKey } = this.props;
let columns = [];
if (singleSalaryItemList.columns) {
columns = [...singleSalaryItemList.columns];
}
if (selectedKey === "fixed") {
columns = [...columns, {
dataIndex: "operate",
title: "操作",
fixed: "right",
width: 100,
render: (text, record) => {
return <div className="optWrapper">
<a href="javascript:void(0);" className="mr10" onClick={() => this.handleEdit(record)}>编辑</a>
<Popover
overlayClassName="moreIconWrapper"
placement="bottomRight"
content={<Menu onClick={(e) => this.deleteSalaryItem(record.id)}>
<Menu.Item key="delete">删除</Menu.Item>
</Menu>} title="">
<i className="icon-coms-more"/>
</Popover>
</div>;
}
}];
}
return columns;
}
@ -57,6 +92,7 @@ export default class SalaryItemChangeList extends React.Component {
dataSource={singleSalaryItemList.list ? singleSalaryItemList.list : []}
columns={this.getColumns()}
border
scroll={{ x: 500 }}
pagination={{
onChange: (value) => {
this.handlePageChange(value);

View File

@ -67,7 +67,7 @@ export default class SalaryFileViewSlide extends React.Component {
const { payEndDate, payStartDate } = result;
onChangePaySetParams({ payEndDate, payStartDate });
});
fetchSingleSalaryItemList({ salaryArchiveId: this.props.id });
// fetchSingleSalaryItemList({ salaryArchiveId: this.props.id });
}
// tab页签切换回调
@ -189,7 +189,7 @@ export default class SalaryFileViewSlide extends React.Component {
>
{
this.state.selectedTab === "0" ?
<SalaryItemChangeList id={this.props.id}/> :
<SalaryItemChangeList id={this.props.id} selectedKey={selectedKey}/> :
<TaxAgentChangeList id={this.props.id}/>
}
</WeaSearchGroup>

View File

@ -205,7 +205,7 @@ export class salaryFileStore {
// 获取详情
@action
getArchiveForm = (salaryArchiveId) => {
return new Promise((resolve, reject)=>{
return new Promise((resolve, reject) => {
API.getArchiveForm({ salaryArchiveId }).then(res => {
if (res.status) {
this.detailForm = res.data;
@ -216,7 +216,7 @@ export class salaryFileStore {
reject();
}
});
})
});
};
// 个税义务人表单
@ -323,6 +323,7 @@ export class salaryFileStore {
salaryItemChangeForm.description = resData.salaryArchiveItemForm.description;
salaryItemChangeForm.adjustReason = resData.salaryArchiveItemForm.adjustReason;
salaryItemChangeForm.canOperator = resData.canOperator;
return salaryItemChangeForm;
};
@ -469,7 +470,24 @@ export class salaryFileStore {
}
});
});
};
@action("编辑调薪")
editSingleSalaryItem = (params) => {
return new Promise((resolve, reject) => {
if (!this.validateSaveSalaryForm(params)) {
reject("校验失败");
return;
}
API.editSingleSalaryItem(params).then(res => {
if (res.status) {
message.success("保存成功");
resolve();
} else {
message.error(res.errormsg || "保存失败");
reject();
}
});
});
};
// 调整=薪资项目调整-获取调整前的值
@ -491,7 +509,7 @@ export class salaryFileStore {
@action
getSalaryItemFormByItemId = (id) => {
return new Promise((resolve, reject) => {
API.getSalaryItemFormByItemId({ salaryArchiveItemId: id }).then(res => {
API.getSingleSalaryItemInfo({ id: id }).then(res => {
if (res.status) {
this.salaryItemChangeForm = this.convertForm(res.data);
resolve(this.salaryItemChangeForm);
@ -501,7 +519,6 @@ export class salaryFileStore {
}
});
});
};
@action("停薪")