Merge branch 'feature/V2-薪资核算编辑分类' into develop

This commit is contained in:
黎永顺 2023-05-18 09:58:07 +08:00
commit 7e4afc4017
8 changed files with 287 additions and 220 deletions

View File

@ -2,8 +2,8 @@ import React from "react";
import ImportModal from "../../../../components/importModal";
import { Badge, Button, message } from "antd";
import { inject, observer } from "mobx-react";
import SelectFieldModal from "./selectFieldModal";
import { getQueryString } from "../../../../util/url";
import AddHeaderFieldsModal from "./addHeaderFieldsModal";
@inject("calculateStore", "standingBookStore")
@observer
@ -16,7 +16,10 @@ export default class AcctResultImportModal extends React.Component {
salaryItemIds: ""
},
step: 0,
selectFieldVisible: false
selectFieldVisible: false,
addHeadFields: {
visible: false, itemsByGroup: []
}
};
}
@ -24,11 +27,6 @@ export default class AcctResultImportModal extends React.Component {
const { id } = this.props;
if (id) {
this.getImportField();
// let modalParam = { ...this.state.modalParam };
// modalParam.salaryAcctRecordId = id;
// this.setState({
// modalParam
// });
} else {
this.setState({
modalParam: { ...this.state.modalParam, salaryAcctRecordId: "123" }
@ -36,18 +34,31 @@ export default class AcctResultImportModal extends React.Component {
}
}
getImportField=()=>{
getImportField = () => {
const { calculateStore: { getImportField }, id } = this.props;
const { addHeadFields } = this.props;
getImportField(id).then(data => {
this.setState({
modalParam:{
addHeadFields: {
...addHeadFields,
itemsByGroup: _.map(data.itemsByGroup, item => {
return {
...item,
salaryItems: _.map(item.salaryItems, it => ({
...it,
checked: false
}))
};
})
},
modalParam: {
...this.state.modalParam,
salaryAcctRecordId: id,
salaryItemIds: data.checkItems.join(",")
}
});
});
}
};
// 获取模板
handleAccResultTemplateLink() {
@ -98,58 +109,22 @@ export default class AcctResultImportModal extends React.Component {
}
// 渲染第一步表单
renderFormComponent() {
renderFormComponent = () => {
return <Badge
count={!_.isEmpty(this.state.modalParam.salaryItemIds) ? this.state.modalParam.salaryItemIds.split(",").length : 0}>
<Button onClick={() => {
this.handleSelectedField();
}}>请选择表单字段</Button>
<Button onClick={this.handleSelectedField}>请选择表单字段</Button>
</Badge>;
}
};
// 选择表单字段
handleSelectedField() {
handleSelectedField = () => {
this.setState({
selectFieldVisible: true
addHeadFields: {
...this.state.addHeadFields,
visible: true
}
});
}
// 添加表头字段
handleAdd(fieldDate) {
let salaryItemIdsList = [];
if (!_.isEmpty(fieldDate.formulaItems)) {
fieldDate.formulaItems.map(item => {
if (item.checked) {
salaryItemIdsList.push(item.salaryItemId);
}
});
}
if (!_.isEmpty(fieldDate.inputItems)) {
fieldDate.inputItems.map(item => {
if (item.checked) {
salaryItemIdsList.push(item.salaryItemId);
}
});
}
if (!_.isEmpty(fieldDate.sqlItems)) {
fieldDate.sqlItems.map(item => {
if (item.checked) {
salaryItemIdsList.push(item.salaryItemId);
}
});
}
let salaryItemIds = "";
if (salaryItemIdsList.length > 0) {
salaryItemIds = salaryItemIdsList.join(",");
}
let modalParam = { ...this.state.modalParam };
modalParam.salaryItemIds = salaryItemIds;
this.setState({
modalParam
});
this.props.onAdd(fieldDate);
}
};
// 初始化Import数据
handleImportModalInit() {
@ -197,7 +172,7 @@ export default class AcctResultImportModal extends React.Component {
importInsuranceAcctDetail,
importBalanceInsuranceDetail
} = standingBookStore;
const { step, selectFieldVisible, modalParam } = this.state;
const { step, modalParam, addHeadFields } = this.state;
return (
<div>
{
@ -223,7 +198,7 @@ export default class AcctResultImportModal extends React.Component {
!isStandingBook ?
fetchImportAcctResult(params) :
standingBookType === "difference" ?
importBalanceInsuranceDetail({...params, billMonth}) :
importBalanceInsuranceDetail({ ...params, billMonth }) :
importInsuranceAcctDetail(params);
}}
templateLink={() => {
@ -236,23 +211,19 @@ export default class AcctResultImportModal extends React.Component {
}}
/>
}
{
selectFieldVisible && <SelectFieldModal
isStandingBook={isStandingBook}
standingBookType={standingBookType}
id={this.props.id}
visible={selectFieldVisible}
fieldData={this.props.fieldData}
onAdd={(fieldDate) => {
this.handleAdd(fieldDate);
}}
onCancel={() => {
this.setState({
selectFieldVisible: false
});
}}
/>
}
<AddHeaderFieldsModal {...addHeadFields} selectItems={modalParam.salaryItemIds}
onCancel={() => this.setState({ addHeadFields: { ...addHeadFields, visible: false } })}
onAdd={(salaryItemIds) => this.setState({
addHeadFields: {
...addHeadFields,
visible: false
},
modalParam: {
...modalParam,
salaryItemIds: salaryItemIds.join(",")
}
})}
/>
</div>
);
}

View File

@ -0,0 +1,105 @@
/*
* Author: 黎永顺
* name: 表头字段添加
* Description:
* Date: 2023/5/17
*/
import React, { Component } from "react";
import { Button, Col, Row } from "antd";
import { WeaCheckbox, WeaDialog, WeaLocaleProvider, WeaSearchGroup } from "ecCom";
import "./index.less";
const { getLabel } = WeaLocaleProvider;
class AddHeaderFieldsModal extends Component {
constructor(props) {
super(props);
this.state = {
itemsCheckeds: [],
showOnlyChecked: false
};
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) {
this.setState({
itemsCheckeds: nextProps.selectItems ? _.map(nextProps.selectItems.split(","), it => Number(it)) : []
});
}
}
handleShowOnlyChecked = (showOnlyChecked) => this.setState({ showOnlyChecked: !!Number(showOnlyChecked) });
handleSelectGroupAll = (groupId, checked) => {
const { itemsCheckeds } = this.state;
const { itemsByGroup } = this.props;
_.map(itemsByGroup, item => {
if (item.salarySobItemGroupId === groupId) {
if (!!Number(checked)) {
this.setState({
itemsCheckeds: [...itemsCheckeds, ..._.map(item.salaryItems, child => child.salaryItemId)]
});
} else {
this.setState({
itemsCheckeds: _.differenceWith(itemsCheckeds, _.map(item.salaryItems, child => child.salaryItemId), _.isEqual)
});
}
}
});
};
render() {
const { showOnlyChecked, itemsCheckeds } = this.state;
const { itemsByGroup } = this.props;
let dataSource = _.map(itemsByGroup, item => {
return {
...item,
salaryItems: _.map(item.salaryItems, child => {
return { ...child, checked: itemsCheckeds.includes(child.salaryItemId) };
})
};
});
if (showOnlyChecked) {
dataSource = _.map(dataSource, item => {
return { ...item, salaryItems: _.filter(item.salaryItems, it => !!it.checked) };
});
}
return (
<WeaDialog
{...this.props} hasScroll initLoadCss
scalable title={getLabel(111, "添加表头字段")}
style={{ width: 700, height: 484 }} className="addHeaderFieldsWrapper"
buttons={[
<Button type="primary" onClick={() => this.props.onAdd(itemsCheckeds)}>{getLabel(111, "添加")}</Button>,
<Button type="ghost" onClick={this.props.onCancel}>{getLabel(111, "取消")}</Button>
]}
bottomLeft={<WeaCheckbox content={getLabel(111, "只显示已选中字段")}
onChange={this.handleShowOnlyChecked}/>}
>
{
_.map(dataSource, item => {
const { salarySobItemGroupName, salaryItems, salarySobItemGroupId } = item;
const value = _.every(salaryItems, it => !!it.checked) ? "1" : "0";
return <WeaSearchGroup showGroup needTigger
title={<WeaCheckbox content={salarySobItemGroupName} value={value}
onChange={(val) => this.handleSelectGroupAll(salarySobItemGroupId, val)}/>}>
<Row gutter={16}>
{
!_.isEmpty(salaryItems) ?
_.map(salaryItems, it => {
const { salaryItemId, salaryItemName, checked } = it;
return <Col span={8} style={{ marginBottom: 16 }}>
<WeaCheckbox content={salaryItemName} value={checked ? "1" : "0"}
onChange={() => this.setState({ itemsCheckeds: _.xorWith(itemsCheckeds, [salaryItemId], _.isEqual) })}/>
</Col>;
}) : <Col span={24} style={{ minHeight: 20, padding: "5%", textAlign: "center" }}>暂无数据</Col>
}
</Row>
</WeaSearchGroup>;
})
}
</WeaDialog>
);
}
}
export default AddHeaderFieldsModal;

View File

@ -0,0 +1,11 @@
.addHeaderFieldsWrapper {
.wea-search-group {
.wea-title {
padding-left: 0 !important;
}
.wea-content {
padding: 8px 16px 0;
}
}
}

View File

@ -1,10 +1,9 @@
import React from "react";
import { WeaHelpfulTip, WeaInput, WeaTab } from "ecCom";
import { WeaHelpfulTip, WeaTab } from "ecCom";
import IssuedAndReissueTable from "./issuedAndReissueTable";
import { Col, Row } from "antd";
import PayrollItemsTable from "./payrollItemsTable";
import { inject, observer } from "mobx-react";
import { toJS } from "mobx";
import cs from "classnames";
import "./index.less";
@inject("calculateStore")
@ -22,25 +21,23 @@ export default class EditSalaryDetail extends React.Component {
acctresultDetail(this.props.id);
}
handleItemValueChange = (field, value, isInput) => {
console.log(field, value, isInput);
handleItemValueChange = (field, value, isInput, groupId) => {
const { calculateStore: { acctresultDetailForm, setAcctresultDetailForm } } = this.props;
let form = { ...acctresultDetailForm };
if (isInput === "inputItems") {
form.inputItems = acctresultDetailForm.inputItems.map(item => {
item = { ...item };
if (item.salaryItemName === field) {
item.resultValue = value;
if (isInput === "itemsByGroup") {
form.itemsByGroup = acctresultDetailForm.itemsByGroup.map(item => {
if (item.salarySobItemGroupId === groupId) {
return {
...item,
salaryItems: _.map(item.salaryItems, it => {
if (it.salaryItemId === field) {
return { ...it, resultValue: value };
}
return { ...it };
})
};
}
return item;
});
} else if (isInput === "formulaItems") {
form.formulaItems = acctresultDetailForm.formulaItems.map(item => {
item = { ...item };
if (item.salaryItemName === field) {
item.resultValue = value;
}
return item;
return { ...item };
});
} else if (isInput === "issuedAndReissueItems") {
form.issuedAndReissueItems = acctresultDetailForm.issuedAndReissueItems.map(item => {
@ -53,7 +50,6 @@ export default class EditSalaryDetail extends React.Component {
}
setAcctresultDetailForm(form);
};
renderTableTr = (data, isInput) => {
const tables = [];
const len = data.length;
@ -77,10 +73,10 @@ export default class EditSalaryDetail extends React.Component {
return tables;
};
render() {
const { calculateStore: { acctresultDetailForm } } = this.props;
const { selectedKey } = this.state;
const { itemsByGroup = [] } = toJS(acctresultDetailForm);
const topTab = [
{
title: "正常工资薪金所得",
@ -96,14 +92,8 @@ export default class EditSalaryDetail extends React.Component {
<div className="detailItemWrapper">
<div>
<span className="itemTitle">基本信息</span>
<WeaHelpfulTip
style={{ marginLeft: "10px" }}
width={200}
title="根据账套设置显示"
placement="topLeft"
/>
<WeaHelpfulTip style={{ marginLeft: "10px" }} title="提示:基本信息根据账套设置显示" placement="topLeft"/>
</div>
<div className="itemContent">
{
!_.isEmpty(acctresultDetailForm.employeeInfos) &&
@ -123,69 +113,9 @@ export default class EditSalaryDetail extends React.Component {
/>
}
{
selectedKey === "0" &&
<div>
<div className="detailItemWrapper">
<span className="itemTitle">输入项</span>
<div className="itemContent">
<Row>
{
acctresultDetailForm.inputItems && acctresultDetailForm.inputItems.map((item, index) => {
const len = acctresultDetailForm.inputItems.length;
return (
<Col span={8}>
<Row>
<Col span={12}
className={cs("itemLabel", { "borderB-none": Math.ceil((index + 1) / 3) === len / 3 })}>{item.salaryItemName}</Col>
<Col span={12} className={cs("itemValue", {
"borderB-none": Math.ceil((index + 1) / 3) === len / 3,
"borderR-none": (index + 1) % 3 === 0
})}><WeaInput value={item.resultValue} disabled={!item.canEdit} onChange={(value) => {
this.handleItemValueChange(item.salaryItemName, value, "inputItems");
}}/></Col>
</Row>
</Col>
);
})
}
</Row>
</div>
</div>
<div className="detailItemWrapper">
<span className="itemTitle">
<span>公式项</span>
<WeaHelpfulTip
style={{ marginLeft: "10px" }}
width={200}
title="提示:修改后,若点击核算,将按照公式核算,覆盖修改的数据"
placement="topLeft"
/>
</span>
<div className="itemContent">
<Row>
{
acctresultDetailForm.formulaItems && acctresultDetailForm.formulaItems.map((item, index) => {
const len = acctresultDetailForm.formulaItems.length;
return (
<Col span={8}>
<Row>
<Col span={12}
className={cs("itemLabel", { "borderB-none": Math.ceil((index + 1) / 3) === len / 3 })}>{item.salaryItemName}</Col>
<Col span={12} className={cs("itemValue", {
"borderB-none": Math.ceil((index + 1) / 3) === len / 3,
"borderR-none": (index + 1) % 3 === 0
})}><WeaInput value={item.resultValue} disabled={!item.canEdit} onChange={(value) => {
this.handleItemValueChange(item.salaryItemName, value, "formulaItems");
}}/></Col>
</Row>
</Col>
);
})
}
</Row>
</div>
</div>
</div>
selectedKey === "0" && _.map(itemsByGroup, item => {
return <PayrollItemsTable {...item} onChangeIssueReissueValue={this.handleItemValueChange}/>;
})
}
{
selectedKey === "1" &&

View File

@ -80,8 +80,7 @@
}
.editSalaryDetail {
padding: 20px;
padding-bottom: 40px;
padding: 20px 20px 40px;
.detailItemWrapper {
.itemTitle {
@ -127,43 +126,15 @@
}
}
}
& > .ant-row {
border: 1px solid rgba(0, 0, 0, .06);
}
.itemLabel {
background-color: #fafafa;
padding: 12px 6px;
height: 45px;
display: flex;
align-items: center;
justify-content: flex-start;
border-right: 1px solid rgba(0, 0, 0, .06);
border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.borderB-none {
border-bottom: none !important;
}
.borderR-none {
border-right: none !important;
}
.itemValue {
padding: 12px 6px;
display: flex;
align-items: center;
height: 45px;
border-right: 1px solid rgba(0, 0, 0, .06);
border-bottom: 1px solid rgba(0, 0, 0, .06);
}
}
}
.itemRow {
line-height: 40px;
.wea-search-group {
padding: 0 !important;
.wea-title {
padding: 0 !important;
}
}
}
@ -254,7 +225,6 @@
z-index: 99;
top: 10px !important;
}
}
@media (min-width: 1260px) {

View File

@ -40,7 +40,7 @@ class IssuedAndReissueTable extends Component {
}
},
{
dataIndex: "salaryBackItemFormula",
dataIndex: "itemFormulaContent",
title: <span>
<span style={{ marginRight: 8 }}>核算公式</span>
<WeaHelpfulTip

View File

@ -0,0 +1,83 @@
/*
* Author: 黎永顺
* name: 薪资项目表格
* Description:
* Date: 2023/5/16
*/
import React, { Component } from "react";
import { WeaHelpfulTip, WeaInput, WeaInputNumber, WeaLocaleProvider, WeaSearchGroup, WeaTable } from "ecCom";
const { getLabel } = WeaLocaleProvider;
class PayrollItemsTable extends Component {
render() {
const {
salarySobItemGroupId,
salarySobItemGroupName,
salaryItems: dataSource,
onChangeIssueReissueValue
} = this.props;
const columns = [
{
dataIndex: "salaryItemName",
title: getLabel(111, "薪资项目"),
width: "15%",
render: (text) => {
return <span className="tdEllipsis" title={text}>{text}</span>;
}
},
{
dataIndex: "resultValue",
title: <span>
<span style={{ marginRight: 8 }}>{getLabel(111, "项目值")}</span>
<WeaHelpfulTip
title={getLabel(111, "1.若薪资项目有公式,手动编辑项目值后,则默认将手动编辑的项目值锁定;点击锁定图标,解锁手动编辑的项目值,公式生效,点击保存按照公式重新核算;重新核算后,不显示解锁图标。")}
placement="top" width={250}
/>
</span>,
width: "20%",
render: (text, record) => {
const { canEdit, dataType } = record;
return dataType === "number" ? <WeaInputNumber
disabled={!canEdit}
min={0}
precision={2}
value={text || 0}
onChange={(value) => onChangeIssueReissueValue(record.salaryItemId, value, "itemsByGroup", salarySobItemGroupId)}
/> : <WeaInput
disabled={!canEdit}
value={text}
onChange={(value) => onChangeIssueReissueValue(record.salaryItemId, value, "itemsByGroup", salarySobItemGroupId)}
/>;
}
},
{
dataIndex: "itemFormulaContent",
title: <span>
<span style={{ marginRight: 8 }}>{getLabel(111, "核算公式")}</span>
<WeaHelpfulTip
title={getLabel(111, "若薪资项目有公式,且项目值手动编辑修改过并点击锁定图标,则公式失效;若解除锁定,则项目公式重新生效;")}
placement="top" width={250}
/>
</span>,
width: "65%",
render: (text, record) => {
return <span className="tdEllipsis" title={text}>{_.isNil(text) ? "输入" : text}</span>;
}
}
];
return (
<WeaSearchGroup title={salarySobItemGroupName} showGroup needTigger>
<WeaTable
rowKey="salaryItemId"
dataSource={dataSource}
columns={columns}
bordered
pagination={false}
/>
</WeaSearchGroup>
);
}
}
export default PayrollItemsTable;

View File

@ -3,7 +3,6 @@ import { message } from "antd";
import { WeaForm, WeaTableNew } from "comsMobx";
import * as API from "../apis/calculate";
import { backCalculate } from "../apis/calculate";
const { TableStore } = WeaTableNew;
@ -487,28 +486,26 @@ export class calculateStore {
// 薪资结果-编辑表单保存
@action
saveAcctResult = (recordId) => {
let inputItems = this.acctresultDetailForm.inputItems.map(item => {
const itemsByGroupItems = _.reduce(this.acctresultDetailForm.itemsByGroup, (pre, cur) => {
return [
...pre,
..._.map(cur.salaryItems, it => {
return {
salaryItemId: it.salaryItemId,
resultValue: it.resultValue
};
})
];
}, []);
const issuedAndReissueItems = this.acctresultDetailForm.issuedAndReissueItems.map(item => {
let record = {};
record.salaryItemId = item.salaryItemId;
record.resultValue = item.resultValue;
return record;
});
let formulaItems = this.acctresultDetailForm.formulaItems.map(item => {
let record = {};
record.salaryItemId = item.salaryItemId;
record.resultValue = item.resultValue;
return record;
});
let issuedAndReissueItems = this.acctresultDetailForm.issuedAndReissueItems.map(item => {
let record = {};
record.salaryItemId = item.salaryItemId;
record.resultValue = item.resultValue;
return record;
});
let items = inputItems.concat(formulaItems).concat(issuedAndReissueItems);
let items = itemsByGroupItems.concat(issuedAndReissueItems);
let params = {
salaryAcctEmpId: recordId,
items