|
@@ -4,7 +4,7 @@
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
* @Date: 2022-12-16 09:42:52
|
|
* @Date: 2022-12-16 09:42:52
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
* @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
|
|
* @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlySet/index.tsx
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
* @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 { BMSTable } from '@/components/BMSTable';
|
|
import { ActionType, ProColumns, ProFormDigit, ProFormInstance } from '@ant-design/pro-components';
|
|
import { ActionType, ProColumns, ProFormDigit, ProFormInstance } from '@ant-design/pro-components';
|
|
import { createFromIconfontCN } from '@ant-design/icons';
|
|
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';
|
|
import { getComputeDate } from '@/pages/Home/service';
|
|
|
|
|
|
@@ -36,6 +36,9 @@ import { getDeepestTreeData } from '@/utils/tooljs';
|
|
|
|
|
|
import { getCurrentCheckStatus } from '@/services/auth';
|
|
import { getCurrentCheckStatus } from '@/services/auth';
|
|
import math, { sparse } from 'mathjs';
|
|
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 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 [treeData, set_treeData] = useState<getTreeDataRespType[]>([]);
|
|
const [tableColumn, set_tableColumn] = useState<ProColumns[]>([]);
|
|
const [tableColumn, set_tableColumn] = useState<ProColumns[]>([]);
|
|
const [currentSelectedTreeNode, set_currentSelectedTreeNode] = useState<any | undefined>();
|
|
const [currentSelectedTreeNode, set_currentSelectedTreeNode] = useState<any | undefined>();
|
|
@@ -103,16 +92,24 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
const [dataSource, set_dataSource] = useState([]);
|
|
const [dataSource, set_dataSource] = useState([]);
|
|
|
|
|
|
const [currentInputRefKeys, set_currentInputRefKeys] = useState<string | undefined>(undefined);
|
|
const [currentInputRefKeys, set_currentInputRefKeys] = useState<string | undefined>(undefined);
|
|
|
|
+ const [tableH, set_tableH] = useState(0);
|
|
|
|
|
|
|
|
|
|
const column: ProColumns[] = [
|
|
const column: ProColumns[] = [
|
|
- {
|
|
|
|
- title: '工号',
|
|
|
|
- dataIndex: 'account',
|
|
|
|
- },
|
|
|
|
|
|
+ // {
|
|
|
|
+ // title: '工号',
|
|
|
|
+ // width:120,
|
|
|
|
+ // fixed: 'left',
|
|
|
|
+ // dataIndex: 'account',
|
|
|
|
+ // },
|
|
{
|
|
{
|
|
title: '姓名',
|
|
title: '姓名',
|
|
|
|
+ width: 120,
|
|
|
|
+ fixed: 'left',
|
|
dataIndex: 'name',
|
|
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 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 已审核
|
|
set_auditType(`${resp}`); //0 未审核 1 已审核
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
const getCurrentCommitStatus = async () => {
|
|
const getCurrentCommitStatus = async () => {
|
|
@@ -152,6 +156,7 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
return {
|
|
return {
|
|
title: item.name,
|
|
title: item.name,
|
|
dataIndex: `${item.code}`,
|
|
dataIndex: `${item.code}`,
|
|
|
|
+ width: 120,
|
|
renderText: (_: any, record: any) => {
|
|
renderText: (_: any, record: any) => {
|
|
if (ifEditMode) {
|
|
if (ifEditMode) {
|
|
return <ProFormDigit noStyle min={-1000000000} fieldProps={{
|
|
return <ProFormDigit noStyle min={-1000000000} fieldProps={{
|
|
@@ -202,14 +207,17 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
set_tableColumn([...column, ..._columns, {
|
|
set_tableColumn([...column, ..._columns, {
|
|
title: '总奖金',
|
|
title: '总奖金',
|
|
dataIndex: 'totalScore',
|
|
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);
|
|
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 () => {
|
|
const saveHandle = async () => {
|
|
|
|
|
|
if (pageData.leftTotal == 0) {
|
|
if (pageData.leftTotal == 0) {
|
|
- const resp = await save(needSaveData);
|
|
|
|
- if(resp){
|
|
|
|
|
|
+ const resp = await save(needSaveData);
|
|
|
|
+ if (resp) {
|
|
message.success('操作成功!');
|
|
message.success('操作成功!');
|
|
set_ifEditMode(false);
|
|
set_ifEditMode(false);
|
|
}
|
|
}
|
|
@@ -397,7 +433,11 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
//tableRef.current?.reload();
|
|
//tableRef.current?.reload();
|
|
|
|
|
|
if (currentComputeDate && currentSelectedTreeNode) {
|
|
if (currentComputeDate && currentSelectedTreeNode) {
|
|
- getCurrentCommitStatus();
|
|
|
|
|
|
+
|
|
|
|
+ if(!ifCheckPage){
|
|
|
|
+ getCurrentCommitStatus();
|
|
|
|
+ }
|
|
|
|
+
|
|
getTableData({});
|
|
getTableData({});
|
|
}
|
|
}
|
|
}, [currentSelectedTreeNode, currentComputeDate]);
|
|
}, [currentSelectedTreeNode, currentComputeDate]);
|
|
@@ -420,6 +460,12 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
}
|
|
}
|
|
}, [treeData]);
|
|
}, [treeData]);
|
|
|
|
|
|
|
|
+ useEffect(()=>{
|
|
|
|
+ if(location.pathname == "/secondaryDistribute/secondaryDitriCheck"){
|
|
|
|
+ set_ifCheckPage(true);
|
|
|
|
+ }else{set_ifCheckPage(false);}
|
|
|
|
+ },[location])
|
|
|
|
+
|
|
let timer: string | number | NodeJS.Timeout | undefined;
|
|
let timer: string | number | NodeJS.Timeout | undefined;
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -430,7 +476,7 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
buildTableData(needSaveData, inputsRefKeys);
|
|
buildTableData(needSaveData, inputsRefKeys);
|
|
}
|
|
}
|
|
}, 300); // 这里的 500 是防抖的时间,单位是毫秒
|
|
}, 300); // 这里的 500 是防抖的时间,单位是毫秒
|
|
-
|
|
|
|
|
|
+
|
|
}, [needSaveData]);
|
|
}, [needSaveData]);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -482,10 +528,6 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (ifEditMode && Object.keys(inputsRef.current).length > 0 && inputsRefKeys.length > 0) {
|
|
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();
|
|
inputsRef.current[`${inputsRefKeys[0]}`].focus();
|
|
set_currentInputRefKeys(inputsRefKeys[0]);
|
|
set_currentInputRefKeys(inputsRefKeys[0]);
|
|
}
|
|
}
|
|
@@ -494,6 +536,12 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
set_tableColumn(column as ProColumns[]);
|
|
set_tableColumn(column as ProColumns[]);
|
|
getCurrentComputeDate();
|
|
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>
|
|
|
|
|
|
<div className='btnGroupWrap'>
|
|
<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>
|
|
|
|
|
|
</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) => {
|
|
summary={(pageData) => {
|
|
const Caculate = ({ colData }: { colData: any }) => {
|
|
const Caculate = ({ colData }: { colData: any }) => {
|
|
|
|
|