From ae3ee29592f95965bac83bee47928aa1ecc0c75b Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Thu, 5 May 2022 12:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=80=E6=9C=9F=E7=B4=AF=E8=AE=A1=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/calculate.js | 4 ++ .../components/progressModal/index.js | 17 +++++ .../hrmSalary/pages/calculateDetail/index.js | 62 +++++++++++++++++-- .../pages/calculateDetail/salaryDetail.js | 4 +- .../dataAcquisition/cumSituation/index.js | 4 +- pc4mobx/hrmSalary/stores/calculate.js | 25 +++++++- 6 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 pc4mobx/hrmSalary/components/progressModal/index.js diff --git a/pc4mobx/hrmSalary/apis/calculate.js b/pc4mobx/hrmSalary/apis/calculate.js index 59b1819a..bd42edd9 100644 --- a/pc4mobx/hrmSalary/apis/calculate.js +++ b/pc4mobx/hrmSalary/apis/calculate.js @@ -472,4 +472,8 @@ export const exportComparisonResult = (salaryAcctRecordId) => { })) } +// 核算进度条 +export const getCalculateProgress = (id) => { + return WeaTools.callApi('/api/bs/hrmsalary/progress/getRate?cacheKey=ACCT_PROGRESS_' + id, 'get', {}); +} diff --git a/pc4mobx/hrmSalary/components/progressModal/index.js b/pc4mobx/hrmSalary/components/progressModal/index.js new file mode 100644 index 00000000..64ba0d3a --- /dev/null +++ b/pc4mobx/hrmSalary/components/progressModal/index.js @@ -0,0 +1,17 @@ +import React from 'react' +import { Modal } from 'antd' +import { WeaProgress } from 'ecCom' + +export default class ProgressModal extends React.Component { + render() { + return ( +
+ {this.props.onCancel()}} footer={null}> +
+ +
+
+
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/index.js b/pc4mobx/hrmSalary/pages/calculateDetail/index.js index a050f3dd..43add5ff 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/index.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/index.js @@ -3,10 +3,11 @@ import UserSure from './userSure' import { inject, observer } from 'mobx-react'; import CustomTab from '../../components/customTab' import SalaryDetail from './salaryDetail' -import { Button, Menu, Dropdown, Modal } from 'antd' +import { Button, Menu, Dropdown, Modal, message } from 'antd' import { WeaInputSearch } from "ecCom" import { getQueryString } from '../../util/url' import AcctResultImportModal from './acctResult/importModal/acctResultImportModal'; +import ProgressModal from '../../components/progressModal' @inject('calculateStore') @observer @@ -16,9 +17,12 @@ export default class CalculateDetail extends React.Component { this.state = { selectedKey: "0", fieldData: {}, - acctResultImportVisiable: false + acctResultImportVisiable: false, + progressVisible: false, + progress: 0 } this.id = "" + this.timer } componentWillMount() { @@ -33,13 +37,43 @@ export default class CalculateDetail extends React.Component { // 核算点击事件 handleAccount() { const { calculateStore } = this.props; - const { acctresultAccounting, acctResultList } = calculateStore; + const { acctresultAccounting, acctResultList, getCalculateProgress } = calculateStore; Modal.confirm({ title: "信息确认", content: "点击核算,公式项将按照公式逻辑核算,核算结果将覆盖原数据", onOk: () => { + this.setState({progress: 0}) acctresultAccounting(this.id).then(() => { - acctResultList(this.id) + this.setState({ + progressVisible: true + }) + if(this.timer) { + clearInterval(this.timer) + } + this.timer = setInterval(() => { + getCalculateProgress(this.id).then(data => { + let progress = data.progress + console.log("progress: " + progress) + if(progress == 1 && this.timer) { + clearInterval(this.timer) + this.timer = null + this.setState({ + progressVisible: false + }) + message.success("核算完成") + acctResultList(this.id) + } else if(!data.status) { + clearInterval(this.timer) + this.timer = null + this.setState({ + progressVisible: false + }) + message.success(data.message) + } + this.setState({progress: Number(progress) * 100}) + }) + }, 300) + }) }, onCancel() {} @@ -74,8 +108,17 @@ export default class CalculateDetail extends React.Component { acctResultList(this.id, value) } + componentWillUnmount() { + // 清除轮询 + if(this.timer) { + clearInterval(this.timer) + } + } + render() { const { selectedKey, modalParam, acctResultImportVisiable } = this.state; + const { calculateStore } = this.props; + const { calculateProgress } = calculateStore const menu = ( @@ -142,8 +185,15 @@ export default class CalculateDetail extends React.Component { id={this.id} /> } - - + { + this.state.progressVisible && { + this.setState({progressVisible: false, progress: 0}) + }} + progress={this.state.progress} + /> + } ) } diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js b/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js index 47bca6bc..d1618c57 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js @@ -123,11 +123,11 @@ export default class SalaryDetail extends React.Component { style={{marginLeft: "10px"}} width={200} title={`薪资周期\n - ${baseSalarySobCycle.salaryCycle.fromDate}至${baseSalarySobCycle.salaryCycle.endDate}\n + ${baseSalarySobCycle.salaryCycle && baseSalarySobCycle.salaryCycle.fromDate}至${baseSalarySobCycle.salaryCycle && baseSalarySobCycle.salaryCycle.endDate}\n 税款所属期\n ${baseSalarySobCycle.taxCycle}\n 考勤取值周期\n - ${baseSalarySobCycle.attendCycle.fromDate}至${baseSalarySobCycle.attendCycle.endDate}\n + ${baseSalarySobCycle.attendCycle && baseSalarySobCycle.attendCycle.fromDate}至${baseSalarySobCycle.attendCycle && baseSalarySobCycle.attendCycle.endDate}\n 福利台账月份\n 引用${baseSalarySobCycle.socialSecurityCycle}的福利台账数据`} placement="topLeft" diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js index 744402a3..a2cacf13 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js @@ -66,7 +66,7 @@ export default class CumSituation extends React.Component { width={200} onChange={v => { this.setState({monthValue: v}) - getTableDatas({ declareMonth: [v], taxAgentId }) + getTableDatas({ taxYearMonth: [v], taxAgentId }) }} /> @@ -89,7 +89,7 @@ export default class CumSituation extends React.Component { value={taxAgentId} onChange={v => { this.setState({taxAgentId: v}) - getTableDatas({ taxAgentId: v, declareMonth: [monthValue]}) + getTableDatas({ taxAgentId: v, taxYearMonth: [monthValue]}) }} /> } diff --git a/pc4mobx/hrmSalary/stores/calculate.js b/pc4mobx/hrmSalary/stores/calculate.js index 39a9d7f0..5553538f 100644 --- a/pc4mobx/hrmSalary/stores/calculate.js +++ b/pc4mobx/hrmSalary/stores/calculate.js @@ -54,6 +54,9 @@ export class calculateStore { @observable comparisonPreviewDataSource = []; // 线下对比列表数据 @observable comparisonImportAcctResult = {}; // 导入结果 + // ** 核算进度 ** + @observable calculateProgress = 0; + // 编辑薪资表单数据 @action @@ -274,7 +277,7 @@ export class calculateStore { return new Promise((resolve, reject) => { API.acctresultAccounting({salaryAcctRecordId}).then(res => { if(res.status) { - message.success("核算成功") + // message.success("核算成功") resolve(); } else { message.error(res.errormsg || "核算失败") @@ -543,4 +546,24 @@ export class calculateStore { exportComparisonResult = (salaryAcctRecordId) => { API.exportComparisonResult(salaryAcctRecordId) } + + // 核算进度条 + @action + getCalculateProgress = (id) => { + return new Promise((resolve, reject) => { + API.getCalculateProgress(id).then(res => { + if(res.status) { + let progress = 0; + try { + progress = Number(res.data.progress) * 100 + } catch(err) { + } + resolve(res.data) + } else { + message.error(res.errormsg || "获取失败") + reject() + } + }) + }) + } } \ No newline at end of file