From 16de38a423a3dbab8ad5b85b6b2ec8adaba61522 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Fri, 13 May 2022 15:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=A5=97=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cumDeduct/editSlideContent.js | 50 +++++++++++------ .../cumSituation/editSlideContent.js | 45 ++++++++++----- .../otherDeduct/editSlideContent.js | 48 ++++++++++------ pc4mobx/hrmSalary/pages/ledger/index.js | 4 +- .../hrmSalary/pages/ledger/salaryItemForm.js | 29 ++++++++-- .../pages/ledger/step3/AddCategoryModal.js | 2 +- .../pages/ledger/step3/canMoveItem.js | 55 ++++++++++++++++++- pc4mobx/hrmSalary/stores/ledger.js | 21 ++++--- 8 files changed, 190 insertions(+), 64 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/editSlideContent.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/editSlideContent.js index 8a4c5f5d..3774fa18 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/editSlideContent.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/editSlideContent.js @@ -30,8 +30,8 @@ export default class EditSlideContent extends React.Component { super(props); this.state = { taxAgentId: "", - startDate: moment(new Date()).format("YYYY-MM"), - endDate: moment(new Date()).format("YYYY-MM"), + startDate: "", + endDate: "", editable: this.props.editable === undefined ? "true": this.props.editable } } @@ -60,6 +60,25 @@ export default class EditSlideContent extends React.Component { getCumDeductDetailList(currentRecord.id, param); } + // 日期格式变化加载数据 + handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) { + let declareMonth = [] + if(startDate != "" && startDate != undefined) { + declareMonth.push(startDate); + } + + if(endDate != "" && endDate != undefined) { + declareMonth.push(endDate); + } + let item = { + taxAgentId: taxAgentId + } + if(declareMonth.length != 0) { + item.declareMonth = declareMonth + } + this.fetchCumDeductDetailList(item) + } + render() { const { taxAgentStore: {taxAgentOption}} = this.props; @@ -76,14 +95,14 @@ export default class EditSlideContent extends React.Component { 申报月份
- { - let startDate = moment(v).format("YYYY-MM") + let startDate = ""; + if(v != "" && v!= undefined) { + startDate = moment(v).format("YYYY-MM") + } this.setState({startDate}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: taxAgentId - }) + this.handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) }} />
@@ -94,12 +113,12 @@ export default class EditSlideContent extends React.Component { { - let endDate = moment(v).format("YYYY-MM") + let endDate = "" + if(v != "" && v!= undefined) { + endDate = moment(v).format("YYYY-MM") + } this.setState({endDate}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: taxAgentId - }) + this.handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) }} />
@@ -114,10 +133,7 @@ export default class EditSlideContent extends React.Component { value={taxAgentId} onChange={v => { this.setState({taxAgentId: v}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: v - }) + this.handleFetchCumDeductDetailList(startDate, endDate, v) }} /> diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/editSlideContent.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/editSlideContent.js index d7e4987b..2fe86804 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/editSlideContent.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/editSlideContent.js @@ -25,13 +25,12 @@ let emptyItem = { @inject('cumSituationStore', "taxAgentStore") @observer export default class EditSlideContent extends React.Component { - constructor(props) { super(props); this.state = { taxAgentId: "", - startDate: moment(new Date()).format("YYYY-MM"), - endDate: moment(new Date()).format("YYYY-MM"), + startDate: "", + endDate: "", editable: this.props.editable === undefined ? "true": this.props.editable } } @@ -61,6 +60,26 @@ export default class EditSlideContent extends React.Component { } + // 日期格式变化加载数据 + handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) { + let declareMonth = [] + if(startDate != "" && startDate != undefined) { + declareMonth.push(startDate); + } + + if(endDate != "" && endDate != undefined) { + declareMonth.push(endDate); + } + let item = { + taxAgentId: taxAgentId + } + if(declareMonth.length != 0) { + item.taxYearMonth = declareMonth + } + this.fetchCumDeductDetailList(item) + } + + render() { const { taxAgentStore: {taxAgentOption}} = this.props; const { cumSituationStore } = this.props; @@ -78,12 +97,12 @@ export default class EditSlideContent extends React.Component {
{ - let startDate = moment(v).format("YYYY-MM") + let startDate = ""; + if(v != "" && v!= undefined) { + startDate = moment(v).format("YYYY-MM") + } this.setState({startDate}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: taxAgentId - }) + this.handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) }} />
@@ -94,12 +113,12 @@ export default class EditSlideContent extends React.Component { { - let endDate = moment(v).format("YYYY-MM") + let endDate = "" + if(v != "" && v!= undefined) { + endDate = moment(v).format("YYYY-MM") + } this.setState({endDate}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: taxAgentId - }) + this.handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) }} /> diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js b/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js index 5027c019..58f3ca02 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js @@ -30,8 +30,8 @@ export default class EditSlideContent extends React.Component { super(props); this.state = { taxAgentId: "", - startDate: moment(new Date()).format("YYYY-MM"), - endDate: moment(new Date()).format("YYYY-MM"), + startDate: "", + endDate: "", editable: this.props.editable === undefined ? "true": this.props.editable } } @@ -60,6 +60,25 @@ export default class EditSlideContent extends React.Component { getOtherDeductDetailList(currentRecord.id, param); } + // 日期格式变化加载数据 + handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) { + let declareMonth = [] + if(startDate != "" && startDate != undefined) { + declareMonth.push(startDate); + } + + if(endDate != "" && endDate != undefined) { + declareMonth.push(endDate); + } + let item = { + taxAgentId: taxAgentId + } + if(declareMonth.length != 0) { + item.declareMonth = declareMonth + } + this.fetchCumDeductDetailList(item) + } + render() { const { taxAgentStore: {taxAgentOption}} = this.props; @@ -78,12 +97,12 @@ export default class EditSlideContent extends React.Component {
{ - let startDate = moment(v).format("YYYY-MM") + let startDate = ""; + if(v != "" && v!= undefined) { + startDate = moment(v).format("YYYY-MM") + } this.setState({startDate}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: taxAgentId - }) + this.handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) }} />
@@ -94,12 +113,12 @@ export default class EditSlideContent extends React.Component { { - let endDate = moment(v).format("YYYY-MM") + let endDate = "" + if(v != "" && v!= undefined) { + endDate = moment(v).format("YYYY-MM") + } this.setState({endDate}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: taxAgentId - }) + this.handleFetchCumDeductDetailList(startDate, endDate, taxAgentId) }} /> @@ -114,10 +133,7 @@ export default class EditSlideContent extends React.Component { value={taxAgentId} onChange={v => { this.setState({taxAgentId: v}) - this.fetchCumDeductDetailList({ - declareMonth: [startDate, endDate], - taxAgentId: v - }) + this.handleFetchCumDeductDetailList(startDate, endDate, v) }} /> diff --git a/pc4mobx/hrmSalary/pages/ledger/index.js b/pc4mobx/hrmSalary/pages/ledger/index.js index 5315efff..576141bd 100644 --- a/pc4mobx/hrmSalary/pages/ledger/index.js +++ b/pc4mobx/hrmSalary/pages/ledger/index.js @@ -152,7 +152,9 @@ export default class Ledger extends React.Component { handleCopySave = (value) => { const { ledgerStore: { doCopy}} = this.props - doCopy(this.state.currentReocrd.id, value) + doCopy(this.state.currentReocrd.id, value).then(() => { + this.setState({copyFormVisible: false}) + }) } handleNew = () => { diff --git a/pc4mobx/hrmSalary/pages/ledger/salaryItemForm.js b/pc4mobx/hrmSalary/pages/ledger/salaryItemForm.js index d07b937c..3c7643a6 100644 --- a/pc4mobx/hrmSalary/pages/ledger/salaryItemForm.js +++ b/pc4mobx/hrmSalary/pages/ledger/salaryItemForm.js @@ -38,7 +38,7 @@ export default class SalaryItemForm extends React.Component { const {ledgerStore: {itemGroups, setItemGroups}} = this.props; let groups = [...itemGroups] groups.map(i => { - if(i.tlitle == item.title) { + if(i.title == item.title) { item.items = dataSource } }) @@ -50,8 +50,9 @@ export default class SalaryItemForm extends React.Component { const { ledgerStore: {itemGroups, setItemGroups} } = this.props; let newItemGroups = [...itemGroups] newItemGroups.map(group => { - group.id = item.id - group.items = dataSource + if(group.id == item.id) { + group.items = dataSource + } }) setItemGroups(newItemGroups) } @@ -61,6 +62,26 @@ export default class SalaryItemForm extends React.Component { this.setState({previewVisible: true}) } + // 修改薪资分类标题回调 + handleItemTitleChange(item, value) { + const { ledgerStore: {itemGroups, setItemGroups} } = this.props; + let newItemGroups = [...itemGroups] + newItemGroups.map(group => { + if(group.id == item.id) { + group.name = value + } + }) + setItemGroups(newItemGroups) + } + + // 删除分类回调 + handleGroupDelete(item) { + const { ledgerStore: {itemGroups, setItemGroups} } = this.props; + let newItemGroups = [...itemGroups] + newItemGroups = newItemGroups.filter(group => group.id !== item.id) + setItemGroups(newItemGroups) + } + render() { const {ledgerStore: {itemGroups, salaryItems, empBrowserList, setAddCategoryVisible, addCategoryVisible}} = this.props; const { previewVisible } = this.state; @@ -99,7 +120,7 @@ export default class SalaryItemForm extends React.Component { if(item.items) { item.items.map(i => {i.key = i.id}) return ( - {this.handleItemDataSourceChange(dataSource, item)}}title={item.name} onChange={(dataSource) => {this.handleCanMoveItemChange(dataSource, item)}}/> + {this.handleItemDataSourceChange(dataSource, item)}} title={item.name} onGroupDelete={() => {this.handleGroupDelete(item)}} onTitleChange={(value) => {this.handleItemTitleChange(item, value)}} onChange={(dataSource) => {this.handleCanMoveItemChange(dataSource, item)}}/> ) } return "" diff --git a/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js b/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js index f2ae0917..b379d503 100644 --- a/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js +++ b/pc4mobx/hrmSalary/pages/ledger/step3/AddCategoryModal.js @@ -8,7 +8,7 @@ export default class AddCategoryModal extends React.Component { constructor(props) { super(props) this.state = { - name: "" + name: this.props.title ? this.props.title : "" } } render() { diff --git a/pc4mobx/hrmSalary/pages/ledger/step3/canMoveItem.js b/pc4mobx/hrmSalary/pages/ledger/step3/canMoveItem.js index 8a1bcade..4743dfb1 100644 --- a/pc4mobx/hrmSalary/pages/ledger/step3/canMoveItem.js +++ b/pc4mobx/hrmSalary/pages/ledger/step3/canMoveItem.js @@ -5,6 +5,7 @@ import { slideStep3Columns } from '../columns' import AddSalaryItemModal from './AddSalaryItemModal' import { inject, observer } from 'mobx-react'; import FormalFormModal from '../../salaryItem/formalFormModal' +import AddCategoryModal from '../step3/AddCategoryModal' @inject('ledgerStore') @observer @@ -35,11 +36,13 @@ export default class CanMoveItem extends React.Component { showContent: true, selectedRowKeys: [], columns, - formalModalVisible: false + formalModalVisible: false, + addCategoryVisible: false } this.formulaId = "" this.record = {} + this.title = "" } // 编辑公式 @@ -95,18 +98,57 @@ export default class CanMoveItem extends React.Component { this.props.onDataSourceChange(dataSource) } + // 编辑分类名称 + handleUpdateCategorySave(name) { + this.props.onTitleChange && this.props.onTitleChange(name) + this.setState({ + addCategoryVisible: false + }) + } + + // 修改分类名称,弹出修改弹出 + handleEditGroupIconClick(title) { + this.title = title + this.setState({addCategoryVisible : true}) + } + + // 删除分类回调 + handleDeleteGroupIconClick() { + Modal.confirm({ + title: '信息确认', + content: '确认删除', + onOk:() => { + this.props.onGroupDelete && this.props.onGroupDelete() + }, + onCancel: () => { + }, + }); + + } + render() { const {ledgerStore: {setAddItemVisible, addItemVisible}} = this.props; - const { selectedRowKeys, formalModalVisible } = this.state; + const { selectedRowKeys, formalModalVisible, addCategoryVisible } = this.state; const rowSelection = { selectedRowKeys, onChange: this.onSelectChange, + getCheckboxProps: (record) => ({ + disabled: !record.canDelete, + }), }; return (
- {this.props.title} + {this.props.title} + { + this.props.title !== "未分类" && + {this.handleEditGroupIconClick(this.props.title)}}/> + {this.handleDeleteGroupIconClick()}}/> + + } + + {this.handleDelete()}}/> { this.setState({addItemVisible: true}) }}/> @@ -138,6 +180,13 @@ export default class CanMoveItem extends React.Component { /> } + {/* 编辑分类名称 */} + { + addCategoryVisible && + {this.handleUpdateCategorySave(value)}} visible={addCategoryVisible} onCancel={() => { + this.setState({addCategoryVisible: false}) + }} /> + }
) } diff --git a/pc4mobx/hrmSalary/stores/ledger.js b/pc4mobx/hrmSalary/stores/ledger.js index bd5954ee..33279240 100644 --- a/pc4mobx/hrmSalary/stores/ledger.js +++ b/pc4mobx/hrmSalary/stores/ledger.js @@ -258,14 +258,19 @@ export class LedgerStore { // 复制 @action doCopy = (id, name) => { - API.duplicateLedger({id, name}).then(res => { - if(res.status) { - message.success("复制成功") - this.getTableDatas({}); - } else { - message.error(res.errormsg || "复制失败") - } + return new Promise((resolve, reject) => { + API.duplicateLedger({id, name}).then(res => { + if(res.status) { + message.success("复制成功") + this.getTableDatas({}); + resolve(); + } else { + message.error(res.errormsg || "复制失败") + reject(); + } + }) }) + } @@ -543,8 +548,6 @@ export class LedgerStore { } }) }) - - } // 调薪计薪规则保存