|
@@ -4,7 +4,7 @@
|
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
|
* @Date: 2022-12-16 09:42:52
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
- * @LastEditTime: 2023-05-26 14:46:52
|
|
|
+ * @LastEditTime: 2023-06-06 13:23:15
|
|
|
* @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlySet/index.tsx
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
@@ -16,7 +16,7 @@ import BMSPagecontainer from '@/components/BMSPageContainer';
|
|
|
import { useEffect, useRef, useState } from 'react';
|
|
|
import './style.less';
|
|
|
|
|
|
-import { TreeProps, Input, Modal, message, Popover, Table, Switch } from 'antd';
|
|
|
+import { TreeProps, Input, Modal, message, Popover, Table, Switch, Tooltip } from 'antd';
|
|
|
import { DataNode } from 'antd/es/tree';
|
|
|
|
|
|
import expandedIcon from '../../../../static/treenode_open.png';
|
|
@@ -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 { checkRequest, commitRequest, getCurrentCheckStatusReq, getCurrentCommitStatusReq, getSecondaryDistriComputeTableData, getTreeData, getTreeDataRespType, save } from './service';
|
|
|
+import { checkCurrentRequest, checkRequest, commitRequest, getCurrentCheckStatusReq, getCurrentCommitStatusReq, getCurrentUnitCheckStatusReq, getSecondaryDistriComputeTableData, getTreeData, getTreeDataRespType, save } from './service';
|
|
|
|
|
|
import { getComputeDate } from '@/pages/Home/service';
|
|
|
|
|
@@ -39,12 +39,13 @@ import math, { sparse } from 'mathjs';
|
|
|
import { useParams } from '@umijs/max';
|
|
|
import { useLocation } from '@umijs/max';
|
|
|
import { useAccess } from '@umijs/max';
|
|
|
-import { values } from 'lodash';
|
|
|
+import { getParamsData } from '@/pages/setting/baseSetting/paramsMana/service';
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
const SearchIcon = createFromIconfontCN({
|
|
|
- scriptUrl: '//at.alicdn.com/t/c/font_1927152_g1njmm1kh7b.js',
|
|
|
+ scriptUrl: '',
|
|
|
});
|
|
|
|
|
|
|
|
@@ -61,6 +62,7 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
const userFunctionInThispage = access.whatCanIDoInThisPage(location.pathname);
|
|
|
const [ifCheckPage, set_ifCheckPage] = useState(false); //是否为二次分配审核页面
|
|
|
const [treeData, set_treeData] = useState<getTreeDataRespType[]>([]);
|
|
|
+ const [treeDataDefault, set_treeDataDefault] = useState<getTreeDataRespType[]>([]);
|
|
|
const [tableColumn, set_tableColumn] = useState<ProColumns[]>([]);
|
|
|
const [currentSelectedTreeNode, set_currentSelectedTreeNode] = useState<any | undefined>();
|
|
|
|
|
@@ -80,6 +82,8 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
|
|
|
const [auditType, set_auditType] = useState('0'); //审核状态
|
|
|
|
|
|
+ const [currentUnitAuditType,set_currentUnitAuditType] = useState('0'); //当前单元审核状态
|
|
|
+
|
|
|
const tableRef = useRef<ActionType>();
|
|
|
|
|
|
const [needSaveData, set_needSaveData] = useState<any | undefined>(undefined);
|
|
@@ -94,6 +98,8 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
|
|
|
const [currentInputRefKeys, set_currentInputRefKeys] = useState<string | undefined>(undefined);
|
|
|
const [tableH, set_tableH] = useState(0);
|
|
|
+ const [currentTreeDataFilter, set_currentTreeDataFilter] = useState({ name: '全部单元', code: 0 });
|
|
|
+ const [treeFilterVisible, set_treeFilterVisible] = useState(false);
|
|
|
|
|
|
|
|
|
const column: ProColumns[] = [
|
|
@@ -143,6 +149,11 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ const getCurrentUnitCheckStatus = async () => {
|
|
|
+ const resp = await getCurrentUnitCheckStatusReq(currentComputeDate as string,currentSelectedTreeNode.code);
|
|
|
+ set_currentUnitAuditType(`${resp}`); //0 未审核 1 已审核
|
|
|
+ }
|
|
|
+
|
|
|
const getCurrentCommitStatus = async () => {
|
|
|
if (currentSelectedTreeNode) {
|
|
|
const resp = await getCurrentCommitStatusReq({
|
|
@@ -185,7 +196,7 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
return a
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
set_needSaveData({ ...needSaveData, userList: updatedUserList })
|
|
|
},
|
|
|
onChange(value) {
|
|
@@ -210,8 +221,9 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
return a
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- set_needSaveData({ ...needSaveData, userList: updatedUserList })
|
|
|
+
|
|
|
+ set_needSaveData({ ...needSaveData, userList: updatedUserList });
|
|
|
+
|
|
|
const index = inputsRefKeys ? inputsRefKeys.findIndex(a => a == `${record.account}-${item.code}`) : -1;
|
|
|
//console.log({index,input:inputsRef.current,inputsRefKeys});
|
|
|
const nextInput = inputsRefKeys ? inputsRef.current[inputsRefKeys[index + 1]] : null;
|
|
@@ -251,8 +263,6 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
}
|
|
|
|
|
|
const getTableData = async (params: any) => {
|
|
|
- // console.log({ currentSelectedTreeNode });
|
|
|
- // console.log({ params, sort, filter });
|
|
|
|
|
|
if (currentSelectedTreeNode && currentComputeDate) {
|
|
|
const resp = await getSecondaryDistriComputeTableData({
|
|
@@ -271,19 +281,6 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
|
|
|
|
|
|
|
|
|
- const confirmGenerateHandle = async () => {
|
|
|
- // const resp = await generateDataRequest({
|
|
|
- // computeDate: currentComputeDate as string,
|
|
|
- // unitCode: currentSelectedTreeNode.code
|
|
|
- // });
|
|
|
- // if (resp) {
|
|
|
- // message.success('生成数据成功');
|
|
|
- // tableRef.current?.reload();
|
|
|
- // } else {
|
|
|
- // message.success('生成数据错误!');
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
const buildTableData = (resp: any, inputsRefKeys?: string[]) => {
|
|
|
const { title, userList } = resp;
|
|
|
const _columns = gennerateColumns(resp, inputsRefKeys);
|
|
@@ -309,31 +306,91 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
set_dataSource(data)
|
|
|
}
|
|
|
|
|
|
- const generateFunc = () => {
|
|
|
+ const checkIfCommit = (type: number) => {
|
|
|
+ //检查当前单元是否提交
|
|
|
+ if (type == 1) {
|
|
|
+ if (!currentSelectedTreeNode.map) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
|
|
|
- let msg = '生成操作会覆盖已有的数据,是否继续?';
|
|
|
- Modal.confirm({
|
|
|
- title: '注意',
|
|
|
- okText: '确定',
|
|
|
- cancelText: '取消',
|
|
|
- content: msg,
|
|
|
- onOk: () => confirmGenerateHandle()
|
|
|
+ }
|
|
|
+ if (type == 2) {
|
|
|
+ if (!currentSelectedTreeNode.map) {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- const commitBtnhandle = async () => {
|
|
|
+ const commitBtnhandle = async (type?: number) => {
|
|
|
+ /**
|
|
|
+ * type 1 单个 2 全部
|
|
|
+ * 提交界面不需要type
|
|
|
+ */
|
|
|
+
|
|
|
+ const handle = async () => {
|
|
|
+ if (type == 1) {
|
|
|
+ //审核单个
|
|
|
+ const resp = await checkCurrentRequest({
|
|
|
+ computeDate: currentComputeDate as string,
|
|
|
+ auditType: auditType == '1' ? '0' : '1', //1 审核 0 取消审核
|
|
|
+ unitCode: currentSelectedTreeNode.code
|
|
|
+ });
|
|
|
+ if (resp) {
|
|
|
+ message.success('操作成功!');
|
|
|
+ getTreeReqFunc(currentComputeDate as string);
|
|
|
+ getCurrentUnitCheckStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- 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);
|
|
|
+ if (type == 2) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ifCheckPage && type) {
|
|
|
+ const checkCondition = await getParamsData({ pageSize: 500 });
|
|
|
+ if (checkCondition) {
|
|
|
+ const needParamsVal = checkCondition.list.filter(a => a.code == '1664510428258115584'); //判断未提交是否可以审核
|
|
|
+ if (needParamsVal.length > 0) {
|
|
|
+ if (needParamsVal[0].value == '1') {
|
|
|
+ //需要提交后才可以审核
|
|
|
+ //console.log(checkIfCommit(type));
|
|
|
+ if (checkIfCommit(type)) {
|
|
|
+ handle();
|
|
|
+ }else{
|
|
|
+ Modal.confirm({
|
|
|
+ title: '注意',
|
|
|
+ okText: '确定',
|
|
|
+ cancelText: '取消',
|
|
|
+ content: '当前核算单元未提交,请提交后再审核?'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (checkIfCommit(type)) {
|
|
|
+ handle();
|
|
|
+ }else{
|
|
|
+ Modal.confirm({
|
|
|
+ title: '注意',
|
|
|
+ okText: '确定',
|
|
|
+ cancelText: '取消',
|
|
|
+ content: '当前核算单元未提交,是否继续审核?',
|
|
|
+ onOk:()=>handle()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
if (pageData.leftTotal == 0) {
|
|
|
Modal.confirm({
|
|
@@ -404,6 +461,48 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
setAutoExpandParent(true);
|
|
|
}
|
|
|
|
|
|
+ //左侧树结构筛选
|
|
|
+ const changeTreeDataFilter = (obj: any) => {
|
|
|
+
|
|
|
+ set_currentTreeDataFilter(obj);
|
|
|
+ set_treeFilterVisible(false);
|
|
|
+
|
|
|
+ interface Node {
|
|
|
+ map: boolean;
|
|
|
+ child?: Node[];
|
|
|
+ }
|
|
|
+
|
|
|
+ function filterNodes(node: Node): Node | null {
|
|
|
+ if (node.map === (obj.code == 1 ? false : true) && (!node.child || node.child.length === 0)) {
|
|
|
+ return node; // 如果节点map为false并且是叶子节点,返回该节点
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Array.isArray(node.child)) {
|
|
|
+ // 对每个子节点递归执行此过程
|
|
|
+ let child = node.child.map(filterNodes).filter((n): n is Node => n !== null);
|
|
|
+ if (child.length > 0) {
|
|
|
+ // 如果有任何子节点的map属性为false,返回包含这些子节点的新节点
|
|
|
+ return { ...node, child: child };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果节点map为true,或者所有子节点的map都为true,返回null
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.code == 0) {
|
|
|
+ set_treeData(treeDataDefault);
|
|
|
+ } else {
|
|
|
+ const result = treeDataDefault.map(a => {
|
|
|
+ return filterNodes(a);
|
|
|
+ });
|
|
|
+
|
|
|
+ set_treeData(result.filter(b => b != null) as any);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
const onExpand = (newExpandedKeys: React.Key[]) => {
|
|
|
setExpandedKeys(newExpandedKeys);
|
|
@@ -426,6 +525,7 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
const getTreeReqFunc = async (computeDate: string) => {
|
|
|
const resp = await getTreeData(computeDate);
|
|
|
set_treeData(resp);
|
|
|
+ set_treeDataDefault(resp);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -497,7 +597,7 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
} else { set_ifCheckPage(false); }
|
|
|
}, [location])
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (needSaveData) {
|
|
@@ -573,6 +673,16 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
|
|
|
return (
|
|
|
<div className='SecondaryDitriComputed'>
|
|
|
+ {
|
|
|
+ treeFilterVisible && (
|
|
|
+ <div className='selecterList'>
|
|
|
+ <div onClick={() => changeTreeDataFilter({ name: '全部单元', code: 0 })} className={currentTreeDataFilter.code == 0 ? 'list on' : 'list'}>全部单元</div>
|
|
|
+ <div onClick={() => changeTreeDataFilter({ name: '未提交', code: 1 })} className={currentTreeDataFilter.code == 1 ? 'list on' : 'list'}>未提交</div>
|
|
|
+ <div onClick={() => changeTreeDataFilter({ name: '已提交', code: 2 })} className={currentTreeDataFilter.code == 2 ? 'list on' : 'list'}>已提交</div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
<div className='leftTree'>
|
|
|
<div className='search'>
|
|
|
<Input
|
|
@@ -580,13 +690,15 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
placeholder="请输入类目名称"
|
|
|
size='small'
|
|
|
allowClear
|
|
|
-
|
|
|
- style={{ marginBottom: 16 }}
|
|
|
+ style={{ width: 158 }}
|
|
|
onChange={onTreeSearchKeyChange}
|
|
|
suffix={
|
|
|
<SearchIcon type='iconsousuo' />
|
|
|
}
|
|
|
/>
|
|
|
+ <Tooltip placement="top" title={currentTreeDataFilter.name}>
|
|
|
+ <div className={currentTreeDataFilter.code == 0 ? 'filter' : currentTreeDataFilter.code == 1 ? 'filter orange' : 'filter blue'} onClick={() => set_treeFilterVisible(true)}></div>
|
|
|
+ </Tooltip>
|
|
|
</div>
|
|
|
{
|
|
|
treeData && treeData.length > 0 && currentSelectedTreeNode && (
|
|
@@ -599,7 +711,9 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
autoExpandParent={autoExpandParent}
|
|
|
selectedKeys={[currentSelectedTreeNode.code]}
|
|
|
blockNode={true}
|
|
|
+
|
|
|
icon={() => null}
|
|
|
+
|
|
|
titleRender={
|
|
|
(nodeData: any) => {
|
|
|
const strTitle = nodeData.name as string;
|
|
@@ -668,19 +782,22 @@ const SecondaryDitriComputed: React.FC = () => {
|
|
|
onMouseEnter={() => auditType == '0' ? commitStatus == '1' ? set_ifShowTip(true) : set_ifShowTip(false) : set_ifShowTip(true)}
|
|
|
onMouseLeave={() => set_ifShowTip(false)}
|
|
|
>
|
|
|
- {!ifEditMode && <span key="1" className='cancel' onClick={commitStatus == '0' && auditType != '1' ? () => set_ifEditMode(true) : () => { }}>编辑</span>}
|
|
|
- {ifEditMode && <span key="3" className='cancel' onClick={commitStatus == '0' ? () => set_ifEditMode(false) : () => { }}>取消</span>}
|
|
|
- {ifEditMode && <span key="2" className='editBtn' onClick={commitStatus == '0' && auditType != '1' ? () => saveHandle() : () => { }}>保存</span>}
|
|
|
-
|
|
|
+ {!ifEditMode && <span className='cancel' onClick={commitStatus == '0' && auditType != '1' ? () => set_ifEditMode(true) : () => { }}>编辑</span>}
|
|
|
+ {ifEditMode && <span className='cancel' onClick={commitStatus == '0' ? () => set_ifEditMode(false) : () => { }}>取消</span>}
|
|
|
+ {ifEditMode && <span className='editBtn' onClick={commitStatus == '0' && auditType != '1' ? () => saveHandle() : () => { }}>保存</span>}
|
|
|
+
|
|
|
</div>
|
|
|
</Popover>
|
|
|
- {!ifEditMode && <div key="4" className={auditType == '1' ? 'commit disabled' : 'commit'} onClick={() => auditType == '0' ? commitBtnhandle() : () => { }}>{commitStatus == '1' ? '取消提交' : '提交'}</div>}
|
|
|
+ {!ifEditMode && <div key="" 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>
|
|
|
+ ifCheckPage && userFunctionInThispage && (userFunctionInThispage.findIndex((a: { code: string, name: string }) => a.code == 'audit') != -1) && (
|
|
|
+ <>
|
|
|
+ <div className={'commit gray'} onClick={() => commitBtnhandle(1)}>{currentUnitAuditType == '1' ? '取消审核单个' : '审核单个'}</div>
|
|
|
+ <div className={'commit'} onClick={() => commitBtnhandle(2)}>{auditType == '1' ? '取消审核全部' : '审核全部'}</div>
|
|
|
+ </>
|
|
|
)
|
|
|
}
|
|
|
|