|
@@ -0,0 +1,650 @@
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+ * @Author: code4eat awesomedema@gmail.com
|
|
|
+ * @Date: 2022-12-16 09:42:52
|
|
|
+ * @LastEditors: code4eat awesomedema@gmail.com
|
|
|
+ * @LastEditTime: 2023-05-24 17:12:52
|
|
|
+ * @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlySet/index.tsx
|
|
|
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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 { DataNode } from 'antd/es/tree';
|
|
|
+
|
|
|
+import expandedIcon from '../../../../static/treenode_open.png';
|
|
|
+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 { getComputeDate } from '@/pages/Home/service';
|
|
|
+
|
|
|
+
|
|
|
+import 'dayjs/locale/zh-cn';
|
|
|
+import React from 'react';
|
|
|
+import DirectoryTree from 'antd/es/tree/DirectoryTree';
|
|
|
+import { getDeepestTreeData } from '@/utils/tooljs';
|
|
|
+
|
|
|
+import { getCurrentCheckStatus } from '@/services/auth';
|
|
|
+import math, { sparse } from 'mathjs';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const SearchIcon = createFromIconfontCN({
|
|
|
+ scriptUrl: '//at.alicdn.com/t/c/font_1927152_g1njmm1kh7b.js',
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export type TableListItem = {
|
|
|
+ key: number;
|
|
|
+ name: string;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+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 [treeData, set_treeData] = useState<getTreeDataRespType[]>([]);
|
|
|
+ const [tableColumn, set_tableColumn] = useState<ProColumns[]>([]);
|
|
|
+ const [currentSelectedTreeNode, set_currentSelectedTreeNode] = useState<any | undefined>();
|
|
|
+
|
|
|
+ const [currentComputeDate, set_currentComputeDate] = useState<string | undefined>();
|
|
|
+
|
|
|
+ const [ifShowTip, set_ifShowTip] = useState(false);
|
|
|
+
|
|
|
+ const [commitStatus, set_commitStatus] = useState('0'); //提交状态
|
|
|
+
|
|
|
+ const [empFilterParams, set_empFilterParams] = useState<any | undefined>(undefined);
|
|
|
+
|
|
|
+ const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
|
|
+ const [searchValue, setSearchValue] = useState('');
|
|
|
+ const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
|
+
|
|
|
+ const [ifEditMode, set_ifEditMode] = useState(false);
|
|
|
+
|
|
|
+ const [auditType, set_auditType] = useState('0'); //审核状态
|
|
|
+
|
|
|
+ const tableRef = useRef<ActionType>();
|
|
|
+
|
|
|
+ const [needSaveData, set_needSaveData] = useState<any | undefined>(undefined);
|
|
|
+
|
|
|
+ const [inputsRefKeys, set_inputsRefKeys] = useState<string[]>([]);
|
|
|
+
|
|
|
+ const inputsRef = useRef<{ [key: string]: any }>({});
|
|
|
+
|
|
|
+ const [pageData, set_pageData] = useState({ total: 0, completedTotal: 0, leftTotal: 0 });
|
|
|
+
|
|
|
+ const [dataSource, set_dataSource] = useState([]);
|
|
|
+
|
|
|
+ const [currentInputRefKeys, set_currentInputRefKeys] = useState<string | undefined>(undefined);
|
|
|
+
|
|
|
+
|
|
|
+ const column: ProColumns[] = [
|
|
|
+ {
|
|
|
+ title: '工号',
|
|
|
+ dataIndex: 'account',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '姓名',
|
|
|
+ dataIndex: 'name',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ const onSelect: TreeProps['onSelect'] = (selectedKeys, info) => {
|
|
|
+ // console.log('selected', selectedKeys, info);
|
|
|
+ const { node } = info;
|
|
|
+ set_currentSelectedTreeNode(node);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ const getCurrentComputeDate = async () => {
|
|
|
+ const resp = await getComputeDate();
|
|
|
+ set_currentComputeDate(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ const getCheckStatus = async (computeDate: string) => {
|
|
|
+ const resp = await getCurrentCheckStatus(computeDate);
|
|
|
+ if (resp) {
|
|
|
+ set_auditType(`${resp}`); //0 未审核 1 已审核
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const getCurrentCommitStatus = async () => {
|
|
|
+ if (currentSelectedTreeNode) {
|
|
|
+ const resp = await getCurrentCommitStatusReq({
|
|
|
+ computeDate: currentComputeDate as string,
|
|
|
+ unitCode: currentSelectedTreeNode.code
|
|
|
+ });
|
|
|
+ set_commitStatus(`${resp}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const gennerateColumns = (data: { title: any; userList: any; }, inputsRefKeys?: string[]) => {
|
|
|
+ const { title } = data;
|
|
|
+ const _columns = title.map((item: any, index: number) => {
|
|
|
+ return {
|
|
|
+ title: item.name,
|
|
|
+ dataIndex: `${item.code}`,
|
|
|
+ renderText: (_: any, record: any) => {
|
|
|
+ if (ifEditMode) {
|
|
|
+ return <ProFormDigit noStyle min={-1000000000} fieldProps={{
|
|
|
+ ref: ref => {
|
|
|
+ inputsRef.current[`${record.account}-${item.code}`] = ref;
|
|
|
+ //console.log({ref});
|
|
|
+ },
|
|
|
+ onPressEnter: (event) => {
|
|
|
+ if (event.code === 'Enter') {
|
|
|
+ event.preventDefault();
|
|
|
+ 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;
|
|
|
+ if (nextInput) {
|
|
|
+ inputsRefKeys && set_currentInputRefKeys(inputsRefKeys[index + 1]);
|
|
|
+ nextInput.focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onFocus: () => set_currentInputRefKeys(`${record.account}-${item.code}`),
|
|
|
+ defaultValue: _, onChange(value) {
|
|
|
+ //if(!value)return;
|
|
|
+ const updatedUserList = needSaveData.userList.map((a: any) => {
|
|
|
+ if (a.account == record.account) {
|
|
|
+ const arr = a.itemValue.map((b: any) => {
|
|
|
+ if (b.code == item.code) {
|
|
|
+ return { ...b, value: value ? value : 0 } //value有为undefined的可能
|
|
|
+ } else {
|
|
|
+ return b
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return { ...a, itemValue: arr }
|
|
|
+ } else {
|
|
|
+ return a
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ set_needSaveData({ ...needSaveData, userList: updatedUserList })
|
|
|
+
|
|
|
+ },
|
|
|
+ }} width={80} />
|
|
|
+ } else {
|
|
|
+ return <span style={{ display: 'inline-block', width: 80 }}>{_}</span>
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+ set_tableColumn([...column, ..._columns, {
|
|
|
+ title: '总奖金',
|
|
|
+ dataIndex: 'totalScore',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'submitName',
|
|
|
+ renderText(text, record, index, action) {
|
|
|
+ return record.submit == 1 ? text : <span style={{ color: '#FF8C19' }}>{text}</span>
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const getTableData = async (params: any) => {
|
|
|
+ // console.log({ currentSelectedTreeNode });
|
|
|
+ // console.log({ params, sort, filter });
|
|
|
+
|
|
|
+ if (currentSelectedTreeNode && currentComputeDate) {
|
|
|
+ const resp = await getSecondaryDistriComputeTableData({
|
|
|
+ computeDate: currentComputeDate,
|
|
|
+ unitCode: currentSelectedTreeNode.code,
|
|
|
+ ...params,
|
|
|
+ });
|
|
|
+ if (resp) {
|
|
|
+ set_needSaveData(resp);
|
|
|
+ //buildTableData(resp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return []
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+ const data = userList.map((item: any) => {
|
|
|
+ let total = 0;
|
|
|
+ let rowData: { [key: string]: any } = {};
|
|
|
+
|
|
|
+ item.itemValue.forEach((b: any) => {
|
|
|
+ const needTitle = title.filter((a: any) => a.code == b.code);
|
|
|
+ if (needTitle.length > 0) {
|
|
|
+ rowData[`${needTitle[0].code}`] = b.value
|
|
|
+ }
|
|
|
+ total = total + b.value;
|
|
|
+ });
|
|
|
+
|
|
|
+ return { ...item, ...rowData, id: Math.random(), _columns, totalScore: Number(total.toFixed(2)) }
|
|
|
+ });
|
|
|
+
|
|
|
+ const compeltedTotal = data.reduce((prev: any, cur: any) => prev + cur.totalScore, 0);
|
|
|
+ const leftTotal = resp.totalBonus - compeltedTotal;
|
|
|
+ set_pageData({ ...pageData, total: resp.totalBonus.toFixed(2), completedTotal: compeltedTotal.toFixed(2), leftTotal: Number(leftTotal.toFixed(2)) });
|
|
|
+
|
|
|
+ set_dataSource(data)
|
|
|
+ }
|
|
|
+
|
|
|
+ const generateFunc = () => {
|
|
|
+
|
|
|
+ let msg = '生成操作会覆盖已有的数据,是否继续?';
|
|
|
+ Modal.confirm({
|
|
|
+ title: '注意',
|
|
|
+ okText: '确定',
|
|
|
+ cancelText: '取消',
|
|
|
+ content: msg,
|
|
|
+ onOk: () => confirmGenerateHandle()
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 dataList: any[] = [];
|
|
|
+
|
|
|
+ const getParentKey = (key: React.Key, tree: any[]): React.Key => {
|
|
|
+ let parentKey: React.Key;
|
|
|
+ for (let i = 0; i < tree.length; i++) {
|
|
|
+ const node = tree[i];
|
|
|
+ if (node.child) {
|
|
|
+ if (node.child.some((item: { code: React.Key; }) => item.code === key)) {
|
|
|
+ parentKey = node.code;
|
|
|
+ } else if (getParentKey(key, node.child)) {
|
|
|
+ parentKey = getParentKey(key, node.child);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return parentKey!;
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ const onTreeSearchKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
+
|
|
|
+ const { value } = e.target;
|
|
|
+ const newExpandedKeys = dataList
|
|
|
+ .map((item) => {
|
|
|
+ if (item.name.indexOf(value) > -1) {
|
|
|
+ return getParentKey(item.code, treeData);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+
|
|
|
+ const b = newExpandedKeys.filter((item, i, self) => item && self.indexOf(item) === i);
|
|
|
+
|
|
|
+ setExpandedKeys(newExpandedKeys as React.Key[]);
|
|
|
+ setSearchValue(value);
|
|
|
+ setAutoExpandParent(true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ const onExpand = (newExpandedKeys: React.Key[]) => {
|
|
|
+ setExpandedKeys(newExpandedKeys);
|
|
|
+ setAutoExpandParent(false);
|
|
|
+ };
|
|
|
+
|
|
|
+ const generateList = (data: getTreeDataRespType[]) => {
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ const node = data[i];
|
|
|
+ const { code, name } = node;
|
|
|
+ dataList.push({ code: code, name: name });
|
|
|
+ if (node.child) {
|
|
|
+ generateList(node.child);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ generateList(treeData as any);
|
|
|
+
|
|
|
+
|
|
|
+ const getTreeReqFunc = async (computeDate: string) => {
|
|
|
+ const resp = await getTreeData(computeDate);
|
|
|
+ set_treeData(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ const saveHandle = async () => {
|
|
|
+
|
|
|
+ if (pageData.leftTotal == 0) {
|
|
|
+ const resp = await save(needSaveData);
|
|
|
+ if(resp){
|
|
|
+ message.success('操作成功!');
|
|
|
+ set_ifEditMode(false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Modal.confirm({
|
|
|
+ title: '提交时需有单元的剩余分配金额必须是0'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+
|
|
|
+ if (currentComputeDate) {
|
|
|
+ getTreeReqFunc(currentComputeDate);
|
|
|
+ getCheckStatus(currentComputeDate);
|
|
|
+ }
|
|
|
+ }, [currentComputeDate]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ //tableRef.current?.reload();
|
|
|
+
|
|
|
+ if (currentComputeDate && currentSelectedTreeNode) {
|
|
|
+ getCurrentCommitStatus();
|
|
|
+ getTableData({});
|
|
|
+ }
|
|
|
+ }, [currentSelectedTreeNode, currentComputeDate]);
|
|
|
+
|
|
|
+ //console.log({inputsRef,inputsRefKeys});
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ //初始化左侧树结构数据后
|
|
|
+
|
|
|
+ if (treeData?.length > 0) {
|
|
|
+ if (!currentSelectedTreeNode) {
|
|
|
+ if (treeData[0].child && treeData[0].child.length > 0) {
|
|
|
+ const [node, nodeParent] = getDeepestTreeData(treeData[0], 'child');
|
|
|
+
|
|
|
+ set_currentSelectedTreeNode(node);
|
|
|
+ setExpandedKeys([nodeParent.code]);
|
|
|
+ getCurrentCommitStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, [treeData]);
|
|
|
+
|
|
|
+ let timer: string | number | NodeJS.Timeout | undefined;
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ //根据输入行的值重新计算
|
|
|
+ clearTimeout(timer);
|
|
|
+ timer = setTimeout(function () {
|
|
|
+ if (needSaveData) {
|
|
|
+ buildTableData(needSaveData, inputsRefKeys);
|
|
|
+ }
|
|
|
+ }, 300); // 这里的 500 是防抖的时间,单位是毫秒
|
|
|
+
|
|
|
+ }, [needSaveData]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (dataSource && Object.keys(inputsRef.current).length > 0) {
|
|
|
+ currentInputRefKeys && inputsRef.current[currentInputRefKeys].focus();
|
|
|
+ }
|
|
|
+ }, [dataSource])
|
|
|
+
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (auditType == '1') {
|
|
|
+ //当审核中时,禁掉所有操作
|
|
|
+ set_commitStatus('1');
|
|
|
+ }
|
|
|
+ }, [auditType]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+
|
|
|
+ let keys: string[] = [];
|
|
|
+
|
|
|
+ if (ifEditMode && needSaveData) {
|
|
|
+ //获取所有输入框的ref key
|
|
|
+ const { userList } = needSaveData;
|
|
|
+ userList.forEach((a: any) => {
|
|
|
+ a.itemValue.forEach((b: any) => {
|
|
|
+ keys.push(`${a.account}-${b.code}`)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ set_inputsRefKeys(keys);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (needSaveData) {
|
|
|
+ if (ifEditMode) {
|
|
|
+ gennerateColumns(needSaveData, keys)
|
|
|
+ } else {
|
|
|
+ gennerateColumns(needSaveData)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ifEditMode) {
|
|
|
+ set_currentInputRefKeys(undefined);
|
|
|
+ getTableData({}); //重新拉数据
|
|
|
+ }
|
|
|
+
|
|
|
+ }, [ifEditMode]);
|
|
|
+
|
|
|
+ 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]);
|
|
|
+ }
|
|
|
+ }, [inputsRef, inputsRefKeys])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ set_tableColumn(column as ProColumns[]);
|
|
|
+ getCurrentComputeDate();
|
|
|
+ }, []);
|
|
|
+
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className='SecondaryDitriComputed'>
|
|
|
+ <div className='leftTree'>
|
|
|
+ <div className='search'>
|
|
|
+ <Input
|
|
|
+ className='searchInput'
|
|
|
+ placeholder="请输入类目名称"
|
|
|
+ size='small'
|
|
|
+ allowClear
|
|
|
+
|
|
|
+ style={{ marginBottom: 16 }}
|
|
|
+ onChange={onTreeSearchKeyChange}
|
|
|
+ suffix={
|
|
|
+ <SearchIcon type='iconsousuo' />
|
|
|
+ }
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ {
|
|
|
+ treeData && treeData.length > 0 && currentSelectedTreeNode && (
|
|
|
+ <DirectoryTree
|
|
|
+ fieldNames={{ title: 'name', key: 'code', children: 'child' }}
|
|
|
+ rootStyle={{ height: '100%', paddingBottom: 50, overflowY: 'scroll', overflowX: 'hidden' }}
|
|
|
+ onSelect={onSelect}
|
|
|
+ onExpand={onExpand}
|
|
|
+ expandedKeys={expandedKeys}
|
|
|
+ autoExpandParent={autoExpandParent}
|
|
|
+ selectedKeys={[currentSelectedTreeNode.code]}
|
|
|
+ blockNode={true}
|
|
|
+ icon={() => null}
|
|
|
+ titleRender={
|
|
|
+ (nodeData: any) => {
|
|
|
+ const strTitle = nodeData.name as string;
|
|
|
+ const index = strTitle.indexOf(searchValue);
|
|
|
+ const beforeStr = strTitle.substring(0, index);
|
|
|
+ const afterStr = strTitle.slice(index + searchValue.length);
|
|
|
+ const title =
|
|
|
+ index > -1 ? (
|
|
|
+ <span>
|
|
|
+ {beforeStr}
|
|
|
+ <span className="site-tree-search-value" style={{ color: 'red', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{searchValue}</span>
|
|
|
+ {afterStr}
|
|
|
+ </span>
|
|
|
+ ) : (
|
|
|
+ <span className='strTitle'>{strTitle}</span>
|
|
|
+ );
|
|
|
+ return <div style={{
|
|
|
+ display: 'flex', flexDirection: 'row',
|
|
|
+ width: '100%',
|
|
|
+ justifyContent: 'space-between', alignItems: 'center', height: 32,
|
|
|
+ borderRadius: '4px',
|
|
|
+ overflow: 'hidden',
|
|
|
+ color: '#17181A',
|
|
|
+ textOverflow: 'ellipsis',
|
|
|
+ whiteSpace: 'nowrap'
|
|
|
+
|
|
|
+ }}>
|
|
|
+ {title}
|
|
|
+ {!nodeData.map && <span className={nodeData.unitType ? 'point lastChild' : 'point'}></span>}
|
|
|
+ </div>
|
|
|
+ }
|
|
|
+ }
|
|
|
+ defaultSelectedKeys={[treeData[0].child[0].code]}
|
|
|
+ treeData={treeData as unknown as DataNode[]}
|
|
|
+ // treeData={treeDataNew}
|
|
|
+ switcherIcon={(props: any) => {
|
|
|
+ const { expanded } = props;
|
|
|
+ return !expanded ? <img style={{ width: 20, height: 20, position: 'relative', top: 5 }} src={expandedIcon} /> : <img style={{ width: 20, height: 20, position: 'relative', top: 5 }} src={closeIcon} />
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ {/* <div style={{width:16,height:'92vh',background:'#F5F7FA'}}></div> */}
|
|
|
+ <div className='rightContent'>
|
|
|
+ <BMSPagecontainer title={`核算年月:${currentComputeDate}`} ghost>
|
|
|
+ <div className='tabContent'>
|
|
|
+ <div className='tableToolbar'>
|
|
|
+ <div className='search'>
|
|
|
+ <span className='total'>可分配总额: <i>{pageData.total}</i></span>
|
|
|
+ <span className='compelted'>已分配总额: <i>{pageData.completedTotal}</i></span>
|
|
|
+ <span className='left'>剩余分配总额: <i>{pageData.leftTotal}</i></span>
|
|
|
+ </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>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ {currentSelectedTreeNode && <BMSTable params={empFilterParams} pagination={false} actionRef={tableRef} rowKey='id' columns={[...tableColumn]} dataSource={dataSource}
|
|
|
+ summary={(pageData) => {
|
|
|
+ const Caculate = ({ colData }: { colData: any }) => {
|
|
|
+
|
|
|
+ const { dataIndex } = colData;
|
|
|
+
|
|
|
+ const total = pageData.reduce((prev, cur) => {
|
|
|
+ return prev + cur[`${dataIndex}`]
|
|
|
+ }, 0);
|
|
|
+ if (dataIndex != 'account' && dataIndex != 'name' && dataIndex != 'submitName') {
|
|
|
+ return (
|
|
|
+ <span>{Number(total.toFixed(2))}</span>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (dataIndex == 'name') {
|
|
|
+ return <span>合计</span>
|
|
|
+ }
|
|
|
+ return <></>
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Table.Summary fixed>
|
|
|
+ <Table.Summary.Row>
|
|
|
+ {
|
|
|
+ tableColumn.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <Table.Summary.Cell key={index} index={index} align='left' rowSpan={1} >
|
|
|
+ <Caculate colData={item} />
|
|
|
+ </Table.Summary.Cell >
|
|
|
+
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </Table.Summary.Row>
|
|
|
+ </Table.Summary>
|
|
|
+ );
|
|
|
+ }}
|
|
|
+ />}
|
|
|
+ </div>
|
|
|
+ </BMSPagecontainer>
|
|
|
+ </div >
|
|
|
+ </div >
|
|
|
+ );
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+export default SecondaryDitriComputed;
|