Bladeren bron

添加二次分配审核界面

code4eat 2 jaren geleden
bovenliggende
commit
b596ea02bb

+ 6 - 1
.umirc.ts

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-12-14 14:14:32
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-05-23 13:21:41
+ * @LastEditTime: 2023-05-25 15:21:26
  * @FilePath: /BudgetManaSystem/.umirc.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -304,6 +304,11 @@ export default defineConfig({
           path: '/secondaryDistribute/secondaryDitriComputed',
           component: './secondaryDistribute/secondaryDitriComputed',
         },
+        {
+          name: '二次分配审核',
+          path: '/secondaryDistribute/secondaryDitriCheck',
+          component: './secondaryDistribute/secondaryDitriComputed',
+        },
       ]
     },
   ],

+ 53 - 1
src/access.ts

@@ -1,10 +1,62 @@
-export default (initialState: API.UserInfo) => {
+/*
+ * @Author: code4eat awesomedema@gmail.com
+ * @Date: 2022-12-14 14:14:32
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @LastEditTime: 2023-05-25 15:44:52
+ * @FilePath: /BudgetManaSystem/src/access.ts
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+
+
+
+
+
+interface MenuItem {
+  function: any;
+  path: string;
+  name: string;
+  children?: MenuItem[];
+}
+
+function findMenuItem(menu: MenuItem[], path: string): MenuItem | undefined {
+  for (let i = 0; i < menu.length; i++) {
+      if (menu[i].path === path) {
+          return menu[i];
+      } else if (menu[i].children) {
+          let found = findMenuItem(menu[i].children as MenuItem[], path);
+          if (found) return found;
+      }
+  }
+}
+
+
+
+export default (initialState: { name: string;memuData:any[] }) => {
   // 在这里按照初始化数据定义项目中的权限,统一管理
   // 参考文档 https://next.umijs.org/docs/max/access
+  
+  //console.log({initialState});
+
+  const {memuData} = initialState;
+  
   const canSeeAdmin = !!(
     initialState && initialState.name !== 'dontHaveAccess'
   );
+
+  const whatCanIDoInThisPage = (pagePath:string)=>{
+        if(memuData){
+          const thisPageData = findMenuItem(memuData,pagePath);
+          if(thisPageData){
+            return thisPageData.function?thisPageData.function:[];
+          }
+          return [];
+        }
+  }
+ 
+
   return {
     canSeeAdmin,
+    whatCanIDoInThisPage,
   };
 };

+ 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-05-19 09:42:37
+ * @LastEditTime: 2023-05-25 13:38:55
  * @FilePath: /BudgetManaSystem/src/app.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -432,7 +432,7 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
 
             const _menu = getVFromTree(data, 'contentType');
 
-            setInitialState((t: any) => ({ ...t, spacicalPageParamsType: _menu, userData: JSON.parse(userData as string) }));
+            setInitialState((t: any) => ({ ...t, spacicalPageParamsType: _menu,memuData:data, userData: JSON.parse(userData as string) }));
 
             //return mappingIcon(data);
 

+ 8 - 2
src/components/BMSTable/style.less

@@ -40,7 +40,7 @@
     .bms-ant-table-thead {
         .bms-ant-table-cell {
             border-bottom: none !important;
-            padding: 12px 16px !important;
+            padding: 9px 16px !important;
             //border-top:1px solid #dae2f2 !important ;
             background: rgb(238 243 250 / 100%) !important;
 
@@ -97,7 +97,13 @@
             }
         }
     }
-
+   
+    .bms-ant-table-summary {
+        &>tr>td {
+            padding: 13px 16px !important;
+            border-top: 1px solid #dae2f2 !important;
+        }
+    } 
    
     
 

+ 1 - 3
src/pages/reportCheck/report/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-01-04 14:12:31
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-04-21 11:34:35
+ * @LastEditTime: 2023-05-25 14:59:18
  * @FilePath: /BudgetManaSystem/src/pages/budgetMana/oneBatch/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -55,8 +55,6 @@ const ReportTemplate = () => {
 
   const reportJumphandle = (reportData: any) => {
 
-    console.log({reportData});
-
     let parameter: { [key: string]: any } = {};
     const { redirectParameter = undefined } = reportData;
     const _step = step + 1;

+ 139 - 76
src/pages/secondaryDistribute/secondaryDitriComputed/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-05-24 17:12:52
+ * @LastEditTime: 2023-05-25 15:54:48
  * @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, ProColumns, ProFormDigit, ProFormInstance } from '@ant-design/pro-components';
 import { createFromIconfontCN } from '@ant-design/icons';
-import { commitRequest, getCurrentCommitStatusReq, getSecondaryDistriComputeTableData, getTreeData, getTreeDataRespType, save } from './service';
+import { checkRequest, commitRequest, getCurrentCheckStatusReq, getCurrentCommitStatusReq, getSecondaryDistriComputeTableData, getTreeData, getTreeDataRespType, save } from './service';
 
 import { getComputeDate } from '@/pages/Home/service';
 
@@ -36,6 +36,9 @@ import { getDeepestTreeData } from '@/utils/tooljs';
 
 import { getCurrentCheckStatus } from '@/services/auth';
 import math, { sparse } from 'mathjs';
+import { useParams } from '@umijs/max';
+import { useLocation } from '@umijs/max';
+import { useAccess } from '@umijs/max';
 
 
 
@@ -51,25 +54,11 @@ export type TableListItem = {
 };
 
 
-const useDebounce = (value: string, delay: number) => {
-    const [debouncedValue, setDebouncedValue] = useState(value);
-
-    useEffect(() => {
-        const handler = setTimeout(() => {
-            setDebouncedValue(value);
-        }, delay);
-
-        return () => {
-            clearTimeout(handler);
-        };
-    }, [value, delay]);
-
-    return debouncedValue;
-}
-
-
 const SecondaryDitriComputed: React.FC = () => {
-
+    const location = useLocation();
+    const access = useAccess();
+    const userFunctionInThispage = access.whatCanIDoInThisPage(location.pathname);
+    const [ifCheckPage,set_ifCheckPage] = useState(false); //是否为二次分配审核页面
     const [treeData, set_treeData] = useState<getTreeDataRespType[]>([]);
     const [tableColumn, set_tableColumn] = useState<ProColumns[]>([]);
     const [currentSelectedTreeNode, set_currentSelectedTreeNode] = useState<any | undefined>();
@@ -103,16 +92,24 @@ const SecondaryDitriComputed: React.FC = () => {
     const [dataSource, set_dataSource] = useState([]);
 
     const [currentInputRefKeys, set_currentInputRefKeys] = useState<string | undefined>(undefined);
+    const [tableH, set_tableH] = useState(0);
 
 
     const column: ProColumns[] = [
-        {
-            title: '工号',
-            dataIndex: 'account',
-        },
+        // {
+        //     title: '工号',
+        //     width:120,
+        //     fixed: 'left',
+        //     dataIndex: 'account',
+        // },
         {
             title: '姓名',
+            width: 120,
+            fixed: 'left',
             dataIndex: 'name',
+            renderText(text, record, index, action) {
+                return `${record.name}(${record.account})`
+            },
         },
     ];
 
@@ -130,10 +127,17 @@ const SecondaryDitriComputed: React.FC = () => {
     }
 
     const getCheckStatus = async (computeDate: string) => {
-        const resp = await getCurrentCheckStatus(computeDate);
-        if (resp) {
+    
+        if (!ifCheckPage) {
+            //计算界面
+            const resp = await getCurrentCheckStatus(computeDate);
+            set_auditType(`${resp}`);  //0 未审核 1 已审核
+        } else {
+            //审核界面
+            const resp = await getCurrentCheckStatusReq(computeDate);
             set_auditType(`${resp}`);  //0 未审核 1 已审核
         }
+
     }
 
     const getCurrentCommitStatus = async () => {
@@ -152,6 +156,7 @@ const SecondaryDitriComputed: React.FC = () => {
             return {
                 title: item.name,
                 dataIndex: `${item.code}`,
+                width: 120,
                 renderText: (_: any, record: any) => {
                     if (ifEditMode) {
                         return <ProFormDigit noStyle min={-1000000000} fieldProps={{
@@ -202,14 +207,17 @@ const SecondaryDitriComputed: React.FC = () => {
         set_tableColumn([...column, ..._columns, {
             title: '总奖金',
             dataIndex: 'totalScore',
+            width: 120,
+            fixed: 'right',
         },
-        {
-            title: '状态',
-            dataIndex: 'submitName',
-            renderText(text, record, index, action) {
-                return record.submit == 1 ? text : <span style={{ color: '#FF8C19' }}>{text}</span>
-            },
-        },
+            // {
+            //     title: '状态',
+            //     width:120,
+            //     dataIndex: 'submitName',
+            //     renderText(text, record, index, action) {
+            //         return record.submit == 1 ? text : <span style={{ color: '#FF8C19' }}>{text}</span>
+            //     },
+            // },
         ]);
 
 
@@ -287,26 +295,40 @@ const SecondaryDitriComputed: React.FC = () => {
         });
     }
 
-    const commitBtnhandle = () => {
-        Modal.confirm({
-            title: '注意',
-            okText: '确定',
-            cancelText: '取消',
-            content: `${commitStatus == '1' ? '取消提交' : '提交'}当前选择的核算单元的数据?`,
-            onOk: async () => {
-                const resp = await commitRequest({
-                    computeDate: currentComputeDate as string,
-                    unitCode: currentSelectedTreeNode.code,
-                    type: commitStatus == '1' ? '0' : '1',  //1 提交 0 取消
-                });
-                if (resp) {
-                    message.success('提交成功!');
-                    getTreeReqFunc(currentComputeDate as string);
-                    getCurrentCommitStatus();
-                }
-            }
+    const commitBtnhandle = async () => {
 
-        })
+        if(ifCheckPage){
+            const resp = await checkRequest({
+                computeDate: currentComputeDate as string,
+                auditType: auditType == '1' ? '0' : '1',  //1 审核 0 取消审核
+            });
+            if (resp) {
+                message.success('操作成功!');
+                getTreeReqFunc(currentComputeDate as string);
+                getCheckStatus(currentComputeDate as string);
+            }
+        }else{
+            Modal.confirm({
+                title: '注意',
+                okText: '确定',
+                cancelText: '取消',
+                content: `${commitStatus == '1' ? '取消提交' : '提交'}当前选择的核算单元的数据?`,
+                onOk: async () => {
+                    const resp = await commitRequest({
+                        computeDate: currentComputeDate as string,
+                        unitCode: currentSelectedTreeNode.code,
+                        type: commitStatus == '1' ? '0' : '1',  //1 提交 0 取消
+                    });
+                    if (resp) {
+                        message.success('提交成功!');
+                        getTreeReqFunc(currentComputeDate as string);
+                        getCurrentCommitStatus();
+                    }
+                }
+    
+            })
+        }
+        
     }
 
 
@@ -370,11 +392,25 @@ const SecondaryDitriComputed: React.FC = () => {
         set_treeData(resp);
     }
 
+
+    const handleResize = (e: any) => {
+        const wH = e.target.innerHeight;
+        const tableHeight = wH - 290;
+        set_tableH(tableHeight);
+    }
+
+    function doResize() {
+        setTimeout(() => {
+            const ev: any = new Event('resize');
+            window.dispatchEvent(ev);
+        }, 0)
+    }
+
     const saveHandle = async () => {
 
         if (pageData.leftTotal == 0) {
-            const resp  = await save(needSaveData);
-            if(resp){
+            const resp = await save(needSaveData);
+            if (resp) {
                 message.success('操作成功!');
                 set_ifEditMode(false);
             }
@@ -397,7 +433,11 @@ const SecondaryDitriComputed: React.FC = () => {
         //tableRef.current?.reload();
 
         if (currentComputeDate && currentSelectedTreeNode) {
-            getCurrentCommitStatus();
+            
+            if(!ifCheckPage){
+                getCurrentCommitStatus();
+            }
+            
             getTableData({});
         }
     }, [currentSelectedTreeNode, currentComputeDate]);
@@ -420,6 +460,12 @@ const SecondaryDitriComputed: React.FC = () => {
         }
     }, [treeData]);
 
+    useEffect(()=>{
+         if(location.pathname == "/secondaryDistribute/secondaryDitriCheck"){
+            set_ifCheckPage(true);
+         }else{set_ifCheckPage(false);}
+    },[location])
+
     let timer: string | number | NodeJS.Timeout | undefined;
 
     useEffect(() => {
@@ -430,7 +476,7 @@ const SecondaryDitriComputed: React.FC = () => {
                 buildTableData(needSaveData, inputsRefKeys);
             }
         }, 300); // 这里的 500 是防抖的时间,单位是毫秒
-        
+
     }, [needSaveData]);
 
     useEffect(() => {
@@ -482,10 +528,6 @@ const SecondaryDitriComputed: React.FC = () => {
     useEffect(() => {
         if (ifEditMode && Object.keys(inputsRef.current).length > 0 && inputsRefKeys.length > 0) {
 
-            // if(inputsRef.current[`${inputsRefKeys[0]}`]){
-            //     inputsRef.current[`${inputsRefKeys[0]}`].focus();
-            //     set_currentInputRefKeys(inputsRefKeys[0]);
-            // }
             inputsRef.current[`${inputsRefKeys[0]}`].focus();
             set_currentInputRefKeys(inputsRefKeys[0]);
         }
@@ -494,6 +536,12 @@ const SecondaryDitriComputed: React.FC = () => {
     useEffect(() => {
         set_tableColumn(column as ProColumns[]);
         getCurrentComputeDate();
+        window.addEventListener('resize', (e) => handleResize(e)) //监听窗口大小改变
+        doResize();
+
+        return () => {
+            window.removeEventListener('resize', (e) => handleResize(e))
+        }
     }, []);
 
 
@@ -581,25 +629,40 @@ const SecondaryDitriComputed: React.FC = () => {
                             </div>
 
                             <div className='btnGroupWrap'>
-                                <Popover open={ifShowTip} content={auditType == '1' ? '当前处于审核中,无法操作!' : '当前处于提交中,无法操作!'} >
-                                    <div className={commitStatus != '0' || auditType == '1' ? 'btnGroup disabled' : 'btnGroup'}
-                                        /**
-                                         * 当审核中,三个操作按钮都不可点击
-                                         * 当非审核中,生成和添加不可操作
-                                         */
-                                        onMouseEnter={() => auditType == '0' ? commitStatus == '1' ? set_ifShowTip(true) : set_ifShowTip(false) : set_ifShowTip(true)}
-                                        onMouseLeave={() => set_ifShowTip(false)}
-                                    >
-                                        {!ifEditMode && <span key="1" className='editBtn' onClick={commitStatus == '0' ? () => set_ifEditMode(true) : () => { }}>编辑</span>}
-                                        {ifEditMode && <span key="2" className='editBtn' onClick={commitStatus == '0' ? () => saveHandle() : () => { }}>保存</span>}
-                                        {ifEditMode && <span key="3" className='editBtn' onClick={commitStatus == '0' ? () => set_ifEditMode(false) : () => { }}>取消</span>}
-                                    </div>
-                                </Popover>
-                                <div key="4" className={auditType == '1' ? 'commit disabled' : 'commit'} onClick={() => auditType == '0' ? commitBtnhandle() : () => { }}>{commitStatus == '1' ? '取消提交' : '提交'}</div>
+                                {
+                                !ifCheckPage && (
+                                        //计算界面
+                                        <>
+                                            <Popover open={ifShowTip} content={auditType == '1' ? '当前处于审核中,无法操作!' : '当前处于提交中,无法操作!'} >
+                                                <div className={commitStatus != '0' || auditType == '1' ? 'btnGroup disabled' : 'btnGroup'}
+                                                    /**
+                                                     * 当审核中,三个操作按钮都不可点击
+                                                     * 当非审核中,生成和添加不可操作
+                                                     */
+                                                    onMouseEnter={() => auditType == '0' ? commitStatus == '1' ? set_ifShowTip(true) : set_ifShowTip(false) : set_ifShowTip(true)}
+                                                    onMouseLeave={() => set_ifShowTip(false)}
+                                                >
+                                                    {!ifEditMode && <span key="1" className='editBtn' onClick={commitStatus == '0' ? () => set_ifEditMode(true) : () => { }}>编辑</span>}
+                                                    {ifEditMode && <span key="2" className='editBtn' onClick={commitStatus == '0' ? () => saveHandle() : () => { }}>保存</span>}
+                                                    {ifEditMode && <span key="3" className='editBtn' onClick={commitStatus == '0' ? () => set_ifEditMode(false) : () => { }}>取消</span>}
+                                                </div>
+                                            </Popover>
+                                            <div key="4" className={auditType == '1' ? 'commit disabled' : 'commit'} onClick={() => auditType == '0' ? commitBtnhandle() : () => { }}>{commitStatus == '1' ? '取消提交' : '提交'}</div>
+                                        </>
+                                    )
+                                }
+                                {
+                                    ifCheckPage&&(userFunctionInThispage.findIndex((a:{code:string,name:string})=>a.code == 'audit') != -1) && (
+                                        <div key="4" className={'commit'} onClick={() => commitBtnhandle() }>{auditType == '1' ? '取消审核' : '审核'}</div>
+                                    )
+                                }
+
                             </div>
 
                         </div>
-                        {currentSelectedTreeNode && <BMSTable params={empFilterParams} pagination={false} actionRef={tableRef} rowKey='id' columns={[...tableColumn]} dataSource={dataSource}
+                        {currentSelectedTreeNode && <BMSTable params={empFilterParams} pagination={false} actionRef={tableRef} rowKey='id'
+                            scroll={{ x: 120 * tableColumn.length, y: tableH }}
+                            columns={[...tableColumn]} dataSource={dataSource}
                             summary={(pageData) => {
                                 const Caculate = ({ colData }: { colData: any }) => {
 

+ 25 - 1
src/pages/secondaryDistribute/secondaryDitriComputed/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-05-24 17:11:52
+ * @LastEditTime: 2023-05-25 14:24:52
  * @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlyInfoCheck/service.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -78,6 +78,15 @@ export const getCurrentCommitStatusReq = (params:{
 
 }
 
+//获取当前审核
+export const getCurrentCheckStatusReq = (computeDate:string) => {
+    return request('/performance/second/getAuditStatus', {
+        method: 'GET',
+        params: {computeDate}
+    })
+
+}
+
 
 
 // //生成数据
@@ -113,4 +122,19 @@ export const commitRequest = (data:CommitRequestParamsType) => {
 
 }
 
+//审核请求
+
+export type CheckRequestParamsType = {
+    computeDate:string,
+    auditType:string
+}
+export const checkRequest = (data:CheckRequestParamsType) => {
+ 
+    return request('/performance/second/audit', {
+        method: 'POST',
+        params:data
+    })
+
+}
+
 

+ 0 - 12
src/pages/secondaryDistribute/secondaryDitriComputed/style.less

@@ -247,18 +247,6 @@
                 }
 
             }
-            .BMSTable {
-                .bms-ant-table-content {
-                    table {
-                        .bms-ant-table-summary {
-                            &>tr>td {
-                                padding: 13px 16px !important;
-                                border-top: 1px solid #dae2f2 !important;
-                            }
-                        } 
-                    }
-                }
-            }
         }
     }
 }