diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js index cd2c9c44..766594f7 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js @@ -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 - + ; - } + }; // 选择表单字段 - 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 (
{ @@ -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 && { - this.handleAdd(fieldDate); - }} - onCancel={() => { - this.setState({ - selectFieldVisible: false - }); - }} - /> - } + this.setState({ addHeadFields: { ...addHeadFields, visible: false } })} + onAdd={(salaryItemIds) => this.setState({ + addHeadFields: { + ...addHeadFields, + visible: false + }, + modalParam: { + ...modalParam, + salaryItemIds: salaryItemIds.join(",") + } + })} + />
); } diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/addHeaderFieldsModal.js b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/addHeaderFieldsModal.js new file mode 100644 index 00000000..66b00e4c --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/addHeaderFieldsModal.js @@ -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 ( + this.props.onAdd(itemsCheckeds)}>{getLabel(111, "添加")}, + + ]} + bottomLeft={} + > + { + _.map(dataSource, item => { + const { salarySobItemGroupName, salaryItems, salarySobItemGroupId } = item; + const value = _.every(salaryItems, it => !!it.checked) ? "1" : "0"; + return this.handleSelectGroupAll(salarySobItemGroupId, val)}/>}> + + { + !_.isEmpty(salaryItems) ? + _.map(salaryItems, it => { + const { salaryItemId, salaryItemName, checked } = it; + return + this.setState({ itemsCheckeds: _.xorWith(itemsCheckeds, [salaryItemId], _.isEqual) })}/> + ; + }) : 暂无数据 + } + + ; + }) + } + + ); + } +} + +export default AddHeaderFieldsModal; diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/index.less b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/index.less new file mode 100644 index 00000000..1de6458c --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/index.less @@ -0,0 +1,11 @@ +.addHeaderFieldsWrapper { + .wea-search-group { + .wea-title { + padding-left: 0 !important; + } + + .wea-content { + padding: 8px 16px 0; + } + } +} diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/editSalaryDetail.js b/pc4mobx/hrmSalary/pages/calculateDetail/editSalaryDetail.js index 075c55a1..2051451d 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/editSalaryDetail.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/editSalaryDetail.js @@ -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 {
基本信息 - +
-
{ !_.isEmpty(acctresultDetailForm.employeeInfos) && @@ -123,69 +113,9 @@ export default class EditSalaryDetail extends React.Component { /> } { - selectedKey === "0" && -
-
- 输入项 -
- - { - acctresultDetailForm.inputItems && acctresultDetailForm.inputItems.map((item, index) => { - const len = acctresultDetailForm.inputItems.length; - return ( - - - {item.salaryItemName} - { - this.handleItemValueChange(item.salaryItemName, value, "inputItems"); - }}/> - - - ); - }) - } - -
-
-
- - 公式项 - - -
- - { - acctresultDetailForm.formulaItems && acctresultDetailForm.formulaItems.map((item, index) => { - const len = acctresultDetailForm.formulaItems.length; - return ( - - - {item.salaryItemName} - { - this.handleItemValueChange(item.salaryItemName, value, "formulaItems"); - }}/> - - - ); - }) - } - -
-
-
+ selectedKey === "0" && _.map(itemsByGroup, item => { + return ; + }) } { selectedKey === "1" && diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/index.less b/pc4mobx/hrmSalary/pages/calculateDetail/index.less index 7cbb9b42..f821272b 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/index.less +++ b/pc4mobx/hrmSalary/pages/calculateDetail/index.less @@ -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) { diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/issuedAndReissueTable.js b/pc4mobx/hrmSalary/pages/calculateDetail/issuedAndReissueTable.js index f18e620f..666c774a 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/issuedAndReissueTable.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/issuedAndReissueTable.js @@ -40,7 +40,7 @@ class IssuedAndReissueTable extends Component { } }, { - dataIndex: "salaryBackItemFormula", + dataIndex: "itemFormulaContent", title: 核算公式 { + return {text}; + } + }, + { + dataIndex: "resultValue", + title: + {getLabel(111, "项目值")} + + , + width: "20%", + render: (text, record) => { + const { canEdit, dataType } = record; + return dataType === "number" ? onChangeIssueReissueValue(record.salaryItemId, value, "itemsByGroup", salarySobItemGroupId)} + /> : onChangeIssueReissueValue(record.salaryItemId, value, "itemsByGroup", salarySobItemGroupId)} + />; + } + }, + { + dataIndex: "itemFormulaContent", + title: + {getLabel(111, "核算公式")} + + , + width: "65%", + render: (text, record) => { + return {_.isNil(text) ? "输入" : text}; + } + } + ]; + return ( + + + + ); + } +} + +export default PayrollItemsTable; diff --git a/pc4mobx/hrmSalary/stores/calculate.js b/pc4mobx/hrmSalary/stores/calculate.js index c5fb9a94..f842d9f0 100644 --- a/pc4mobx/hrmSalary/stores/calculate.js +++ b/pc4mobx/hrmSalary/stores/calculate.js @@ -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