From be6aadbe7e513f15c9f7f3ecf75c591b9755c0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Wed, 7 Jun 2023 11:08:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E5=B7=A5=E8=B5=84?= =?UTF-8?q?=E5=8D=95=E5=8F=91=E6=94=BE=E6=B7=BB=E5=8A=A0=E5=8F=91=E6=94=BE?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BB=A5=E5=8F=8A=E6=B7=BB=E5=8A=A0=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/payroll.js | 4 + .../pages/payroll/payrollGrant/index.js | 150 +++++++++++++++--- .../pages/payroll/stepForm/baseInformForm.js | 2 +- pc4mobx/hrmSalary/stores/payroll.js | 18 +-- 4 files changed, 142 insertions(+), 32 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/payroll.js b/pc4mobx/hrmSalary/apis/payroll.js index 58c2ec3d..eaf11a11 100644 --- a/pc4mobx/hrmSalary/apis/payroll.js +++ b/pc4mobx/hrmSalary/apis/payroll.js @@ -12,6 +12,10 @@ export const getPayrollList = params => { body: JSON.stringify(params) }).then(res => res.json()); }; +// 工资单发放进度条 +export const getPayrollIssuanceProgressBar = (id) => { + return WeaTools.callApi("/api/bs/hrmsalary/progress/getRate?cacheKey=SALARY_GRANT_PROGRESS_" + id, "get", {}); +}; //工资单-获取table提示信息 export const getPayrollInfo = params => { diff --git a/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js b/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js index 71327ee1..3a3b42f1 100644 --- a/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js +++ b/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js @@ -1,14 +1,17 @@ import React from "react"; import { inject, observer } from "mobx-react"; import { toJS } from "mobx"; -import { WeaDropdown, WeaHelpfulTip, WeaTab, WeaTop } from "ecCom"; +import { WeaDropdown, WeaHelpfulTip, WeaLocaleProvider, WeaTab, WeaTop } from "ecCom"; import { Button, Dropdown, Menu, message } from "antd"; import "./index.less"; import { getQueryString } from "../../../util/url"; import { getSearchs, renderLoading } from "../../../util"; import CustomPaginationTable from "../../../components/customPaginationTable"; import PayrollPartTable from "./payrollPartTable"; +import { getPayrollIssuanceProgressBar } from "../../../apis/payroll"; +import ProgressModal from "../../../components/progressModal"; +const getLabel = WeaLocaleProvider.getLabel; const { ButtonSelect } = WeaDropdown; @inject("payrollStore") @@ -20,6 +23,8 @@ export default class PayrollGrant extends React.Component { selectedRowKeys: [], currentId: "", selectedKey: "0", + progressVisible: false, + progress: 0, payrollPartModalParams: { visible: false, title: "工资单发放", @@ -28,6 +33,7 @@ export default class PayrollGrant extends React.Component { } }; this.pageInfo = { current: 1, pageSize: 10 }; + this.timer = null; } componentWillMount() { @@ -66,6 +72,7 @@ export default class PayrollGrant extends React.Component { // 发放 handleGrant = (record) => { + this.setState({ progress: 0 }); const { payrollStore } = this.props; const { currentId, selectedKey } = this.state; const { grantPayroll, getInfoList } = payrollStore; @@ -73,14 +80,39 @@ export default class PayrollGrant extends React.Component { ...record, salarySendId: currentId }).then(() => { - getInfoList({ - salarySendId: currentId, - isGranted: selectedKey !== "0", - current: this.pageInfo.current, - pageSize: this.pageInfo.pageSize + this.setState({ progressVisible: true }); + if (this.timer) clearInterval(this.timer); + this.timer = setInterval(() => { + getPayrollIssuanceProgressBar(currentId).then(({ data, status }) => { + let progress = data.progress; + if (progress === 1 && this.timer) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressVisible: false, + progress: 0 + }); + message.success(getLabel(111, "发放成功")); + getInfoList({ + salarySendId: currentId, + isGranted: selectedKey !== "0", + current: this.pageInfo.current, + pageSize: this.pageInfo.pageSize - }); - this.handleClose(); + }); + this.handleClose(); + } else if (!data.status) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressVisible: false, + progress: 0 + }); + message.error(data.message); + } + this.setState({ progress: Number(progress) * 100 }); + }); + }, 1000); }); }; @@ -159,6 +191,7 @@ export default class PayrollGrant extends React.Component { }; // 全部发送 handleGrantAll = () => { + this.setState({ progress: 0 }); const { payrollStore } = this.props; const { currentId, selectedKey } = this.state; const { grantPayroll, getInfoList } = payrollStore; @@ -166,22 +199,73 @@ export default class PayrollGrant extends React.Component { ids: [], salarySendId: currentId }).then(() => { - getInfoList({ - salarySendId: currentId, - isGranted: selectedKey !== "0" - }); + this.setState({ progressVisible: true }); + if (this.timer) clearInterval(this.timer); + this.timer = setInterval(() => { + getPayrollIssuanceProgressBar(currentId).then(({ data, status }) => { + let progress = data.progress; + if (progress === 1 && this.timer) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressVisible: false, + progress: 0 + }); + message.success(getLabel(111, "发放成功")); + getInfoList({ + salarySendId: currentId, + isGranted: selectedKey !== "0" + }); + } else if (!data.status) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressVisible: false, + progress: 0 + }); + message.error(data.message); + } + this.setState({ progress: Number(progress) * 100 }); + }); + }, 1000); }); }; // 发放所选 fetchGrantPayRoll = (payload) => { + this.setState({ progress: 0 }); const { selectedKey, currentId } = this.state; const { payrollStore: { grantPayroll, getInfoList } } = this.props; grantPayroll(payload).then(() => { - getInfoList({ - salarySendId: currentId, - isGranted: selectedKey !== "0" - }); - this.setState({ selectedRowKeys: [] }); + this.setState({ progressVisible: true }); + if (this.timer) clearInterval(this.timer); + this.timer = setInterval(() => { + getPayrollIssuanceProgressBar(currentId).then(({ data, status }) => { + let progress = data.progress; + if (progress === 1 && this.timer) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressVisible: false, + progress: 0 + }); + message.success(getLabel(111, "发放成功")); + getInfoList({ + salarySendId: currentId, + isGranted: selectedKey !== "0" + }); + this.setState({ selectedRowKeys: [] }); + } else if (!data.status) { + clearInterval(this.timer); + this.timer = null; + this.setState({ + progressVisible: false, + progress: 0 + }); + message.error(data.message); + } + this.setState({ progress: Number(progress) * 100 }); + }); + }, 1000); }); }; @@ -218,7 +302,7 @@ export default class PayrollGrant extends React.Component { const { payrollStore } = this.props; const { salaryGrantTableStore: columns, salarySendDetailBaseInfo } = payrollStore; const notShowGrantOrWithdraw = salarySendDetailBaseInfo.haveBackCalc === 1 && salarySendDetailBaseInfo.salaryAcctType === "0"; - return [ + return _.map([ ...toJS(columns), { title: "操作", @@ -226,7 +310,7 @@ export default class PayrollGrant extends React.Component { dataIndex: "", display: true, render: (text, record) => { - if (record.sendStatus === "已发放" && !notShowGrantOrWithdraw) { + if (record.sendStatus === "1" && !notShowGrantOrWithdraw) { return ( { + if (item.dataIndex === "sendStatus") { + return { + ...item, + render: (text, record) => { + return {record.sendStatus === "0" ? getLabel(111, "未发放") : record.sendStatus === "1" ? getLabel(111, "已发放") : getLabel(111, "已撤回")}; + } + }; + } + return { ...item }; + }); }; getSearchsAdQuick() { @@ -284,7 +378,7 @@ export default class PayrollGrant extends React.Component { { key: "SELECT", show: "发放所选", selected: false }, { key: "PART", show: "部分发放", selected: false } ]} - btnProps={{loading: btnLoading}} + btnProps={{ loading: btnLoading }} btnOnClick={this.sendPayroll} menuOnClick={(key) => this.sendPayroll(key)} />, @@ -298,7 +392,7 @@ export default class PayrollGrant extends React.Component { { key: "recallSelected", show: "撤回所选", selected: false }, { key: "partialWithdrawal", show: "部分撤回", selected: false } ]} - btnProps={{loading: btnLoading}} + btnProps={{ loading: btnLoading }} btnOnClick={this.withdrawalPayroll} menuOnClick={(key) => this.withdrawalPayroll(key)} />, @@ -505,6 +599,18 @@ export default class PayrollGrant extends React.Component { onWithdraw={this.handleWithdraw} onGrant={this.handleGrant} /> + { + this.state.progressVisible && + { + this.setState({ progressVisible: false, progress: 0 }); + clearInterval(this.timer); + this.timer = null; + }} + progress={this.state.progress} + /> + } ); } diff --git a/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js b/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js index 84521793..f57f0b21 100644 --- a/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js +++ b/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js @@ -156,7 +156,7 @@ export default class BaseInformForm extends React.Component { - this.hanldeChange({ msgStatus: value === "1" })}/> diff --git a/pc4mobx/hrmSalary/stores/payroll.js b/pc4mobx/hrmSalary/stores/payroll.js index 7a31dbd4..d6d3be81 100644 --- a/pc4mobx/hrmSalary/stores/payroll.js +++ b/pc4mobx/hrmSalary/stores/payroll.js @@ -508,17 +508,17 @@ export class payrollStore { @action grantPayroll = (params = {}) => { return new Promise((resolve, reject) => { - message.destroy(); - message.loading("正在发放中...", 0); + // message.destroy(); + // message.loading("正在发放中...", 0); this.btnLoading = true; - WeaLoadingGlobal.start(); + // WeaLoadingGlobal.start(); API.grantPayroll(params).then(res => { this.btnLoading = false; - WeaLoadingGlobal.end(); - WeaLoadingGlobal.destroy(); - message.destroy(); + // WeaLoadingGlobal.end(); + // WeaLoadingGlobal.destroy(); + // message.destroy(); if (res.status) { - message.success("发送成功"); + // message.success("发送成功"); resolve(); } else { message.error(res.errormsg || "发送失败"); @@ -526,8 +526,8 @@ export class payrollStore { } }).catch(() => { this.btnLoading = false - WeaLoadingGlobal.end(); - WeaLoadingGlobal.destroy(); + // WeaLoadingGlobal.end(); + // WeaLoadingGlobal.destroy(); }); }); }; From c15fc127d28122dede6b23b41c88f992d508286d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Wed, 7 Jun 2023 15:35:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E5=B7=A5=E8=B5=84?= =?UTF-8?q?=E5=8D=95=E5=8F=91=E6=94=BE=E6=B7=BB=E5=8A=A0=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js | 6 +++--- pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js b/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js index 3a3b42f1..aae01241 100644 --- a/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js +++ b/pc4mobx/hrmSalary/pages/payroll/payrollGrant/index.js @@ -92,7 +92,7 @@ export default class PayrollGrant extends React.Component { progressVisible: false, progress: 0 }); - message.success(getLabel(111, "发放成功")); + message.success(data.message); getInfoList({ salarySendId: currentId, isGranted: selectedKey !== "0", @@ -211,7 +211,7 @@ export default class PayrollGrant extends React.Component { progressVisible: false, progress: 0 }); - message.success(getLabel(111, "发放成功")); + message.success(data.message); getInfoList({ salarySendId: currentId, isGranted: selectedKey !== "0" @@ -248,7 +248,7 @@ export default class PayrollGrant extends React.Component { progressVisible: false, progress: 0 }); - message.success(getLabel(111, "发放成功")); + message.success(data.message); getInfoList({ salarySendId: currentId, isGranted: selectedKey !== "0" diff --git a/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js b/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js index f57f0b21..69ebf94e 100644 --- a/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js +++ b/pc4mobx/hrmSalary/pages/payroll/stepForm/baseInformForm.js @@ -33,6 +33,7 @@ export default class BaseInformForm extends React.Component { }, ...toJS(data.salarySobOptions)], request: { ...data.templateBaseData, + msgStatus: !this.props.id ? "1" : data.templateBaseData.msgStatus, reissueRule: data.templateBaseData.replenishRule ? "1" : "0", ...JSON.parse(templateBaseData) } @@ -156,7 +157,7 @@ export default class BaseInformForm extends React.Component { - this.hanldeChange({ msgStatus: value === "1" })}/>