Эх сурвалжийг харах

添加计算状态的轮询

code4eat 2 жил өмнө
parent
commit
3a346d7248

+ 2 - 2
src/app.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-12-14 14:14:32
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-02-20 15:42:53
+ * @LastEditTime: 2023-03-06 17:03:27
  * @FilePath: /BudgetManaSystem/src/app.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -60,7 +60,7 @@ export async function getInitialState(): Promise<{ name?: string,isCollapsed:boo
 
 export const request: RequestConfig = {
   // 统一的请求设定
-  timeout:100000,
+  timeout:100000000,
   headers: { 'X-Requested-With': 'XMLHttpRequest' },
 
   // 错误处理: umi@3 的错误处理方案。

+ 58 - 30
src/pages/budgetMana/monthlyDataCheck/index.tsx

@@ -4,7 +4,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-12-16 09:42:52
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-03-02 16:07:41
+ * @LastEditTime: 2023-03-07 17:28:56
  * @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlySet/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -24,7 +24,7 @@ import closeIcon from '../../../../static/treenode_collapse.png';
 import { BMSTable } from '@/components/BMSTable';
 import { ActionType, ModalForm, ProColumns, ProColumnType, ProForm, ProFormDependency, ProFormDigit, ProFormInstance, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
 import { createFromIconfontCN } from '@ant-design/icons';
-import { addTableData, checkMonthlyReq, delTableDataRequest, downloadTemplateReq, editCheckProject, editManaIndexTableData, editTableData, editTableSalaryRequest, generateCheckProjectTableData, getCheckProjectTableData, getCostData, getDepLists, getEmps, getHesuanUnits, getIncomeData, getManaIndexGroup, getManaIndexTableData, getNoCheckTableData, getPageCheckStatus, getProjects, getSalaryInfoTableData, importMonthlyperformanceRelaFiles } from './service';
+import { addTableData, checkMonthlyReq, delTableDataRequest, downloadTemplateReq, editCheckProject, editManaIndexTableData, editTableData, editTableSalaryRequest, generateCheckProjectTableData, getCheckItemCalcStatus, getCheckProjectTableData, getCostData, getDepLists, getEmps, getHesuanUnits, getIncomeData, getManaIndexGroup, getManaIndexTableData, getNoCheckTableData, getPageCheckStatus, getProjects, getSalaryInfoTableData, importMonthlyperformanceRelaFiles } from './service';
 import { TransferDirection } from 'antd/es/transfer';
 
 import editIcon from '../../../../static/editIcon.png';
@@ -432,6 +432,33 @@ const MonthlyDataCheck: React.FC = () => {
         set_currentSelectedTabKey(activeKey);
     }
 
+    //获取核算单元树结构
+    const getCheckUnitTreeDataFunc = async (computeDate: string) => {
+        const resp = await getTreeData(computeDate);
+        if (resp) {
+            set_treeData(resp);
+        }
+    }
+
+
+    const getCalcStatus =async () => {
+        const resp = await getCheckItemCalcStatus(currentComputeDate as string,'ASSESSMENT');
+        if(resp){
+           if(resp.calculating){
+            //继续计算
+            set_loading(true);
+            return false
+           }else{
+            //计算已完成
+            set_loading(false);
+            return true
+           }
+        }else{
+           tableRef.current?.reload();
+           return true
+        }
+   }
+
     const getTableData = async (type: '1' | '2' | '3' | '4' | '5' | '6', params: any, sort: any, filter: any) => {
 
         if (currentComputeDate) {
@@ -466,20 +493,29 @@ const MonthlyDataCheck: React.FC = () => {
                 }
             }
             if (type == '3') {
-                const resp = await getCheckProjectTableData({
-                    computeDate: currentComputeDate,
-                    unitCode: currentSelectedTreeNode.code,
-                    ...params
-                });
-                if (resp) {
-                    return {
-                        data: resp.list,
-                        success: true,
-                        total: resp.totalCount,
-                        pageSize: resp.pageSize,
-                        totalPage: resp.totalPage,
+
+                const ifCalcCompleted = await getCalcStatus(); // 检查计算状态
+
+                console.log({ifCalcCompleted});
+
+                if(ifCalcCompleted){
+                    //计算完和未计算
+
+                    const resp = await getCheckProjectTableData({
+                        computeDate: currentComputeDate,
+                        unitCode: currentSelectedTreeNode.code,
+                        ...params
+                    });
+                    if (resp) {
+                        return {
+                            data: resp.list,
+                            success: true,
+                            total: resp.totalCount,
+                            pageSize: resp.pageSize,
+                            totalPage: resp.totalPage,
+                        }
                     }
-                }
+                }  
             }
             if (type == '4') {
                 if (currentSelectedManaGroup) {
@@ -622,6 +658,8 @@ const MonthlyDataCheck: React.FC = () => {
     };
 
 
+
+
     interface RecordType {
         key: string;
         title: string;
@@ -675,16 +713,6 @@ const MonthlyDataCheck: React.FC = () => {
     }
 
 
-    //获取核算单元树结构
-    const getCheckUnitTreeDataFunc = async (computeDate: string) => {
-        const resp = await getTreeData(computeDate);
-        if (resp) {
-            set_treeData(resp);
-        }
-    }
-
-
-
 
     const dataList: any[] = [];
 
@@ -757,7 +785,7 @@ const MonthlyDataCheck: React.FC = () => {
          * index 获取的表格类型下标
          */
 
-        if (index == 3) {
+        if (index == 3&&!loading) {
             Modal.confirm({
                 title: '注意',
                 cancelText: '',
@@ -1553,16 +1581,16 @@ const MonthlyDataCheck: React.FC = () => {
                                                             </div>
                                                         </div>
                                                         <Popover open={ifShowTip} content={'当前处于审核中,无法操作!'} >
-                                                            <div className={auditType == '1' ? 'btnGroup disabled' : 'btnGroup'}
+                                                            <div className={auditType == '1'||loading ? 'btnGroup disabled' : 'btnGroup'}
                                                                 onMouseEnter={() => auditType == '0' ? set_ifShowTip(false) : set_ifShowTip(true)}
                                                                 onMouseLeave={() => set_ifShowTip(false)}
                                                             >
-                                                                <span key="1" onClick={auditType == '0' ? () => generateFunc(3, true) : () => { }}>获取单个</span>
-                                                                <span key="2" onClick={auditType == '0' ? () => generateFunc(3) : () => { }}>获取所有</span>
+                                                                <span key="1" onClick={auditType == '0'? () => generateFunc(3, true) : () => { }}>获取单个</span>
+                                                                <span key="2" onClick={auditType == '0'? () => generateFunc(3) : () => { }}>获取所有</span>
                                                             </div>
                                                         </Popover>
                                                     </div>
-                                                    {currentComputeDate && <BMSTable actionRef={tableRef} loading={{ spinning: loading, tip: '正在计算数据...' }} rowKey='id' params={tableDataFilterParams} columns={auditType == '0' ? [...tableColumn, {
+                                                    {currentComputeDate && <BMSTable actionRef={tableRef} loading={{ spinning: loading, tip: '正在计算数据...' }} polling={loading?120000:undefined}  rowKey='id' params={tableDataFilterParams} columns={auditType == '0' ? [...tableColumn, {
                                                         title: '数值',
                                                         dataIndex: 'value',
                                                         key: 'value',

+ 11 - 1
src/pages/budgetMana/monthlyDataCheck/service.ts

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-12-21 11:13:51
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-02-21 10:39:04
+ * @LastEditTime: 2023-03-07 16:57:56
  * @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlyInfoCheck/service.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -424,6 +424,16 @@ export const getPageCheckStatus = (computeDate: string) => {
 
 }
 
+//获取考核项目计算状态
+
+export const getCheckItemCalcStatus = (computeDate: string,code:string) => {
+    return request('/performance/kpi/getComputeStatus', {
+        method: 'GET',
+        params: { computeDate,code }
+    })
+
+}
+
 //审核绩效数据
 export const checkMonthlyReq = (computeDate: string, auditType: string) => {
     return request('/performance/kpi/audit', {