|
@@ -2,7 +2,7 @@
|
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
|
* @Date: 2023-01-04 14:12:31
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
- * @LastEditTime: 2023-07-06 13:54:58
|
|
|
+ * @LastEditTime: 2023-07-14 18:17:36
|
|
|
* @FilePath: /BudgetManaSystem/src/pages/budgetMana/oneBatch/index.tsx
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
@@ -12,16 +12,21 @@ import BMSPagecontainer from '@/components/BMSPageContainer'
|
|
|
import { BMSTable } from '@/components/BMSTable';
|
|
|
import { getComputeDate } from '@/pages/Home/service';
|
|
|
import { ActionType, ProColumns } from '@ant-design/pro-components';
|
|
|
-import { message, Modal, Popover, Table, Tabs } from 'antd';
|
|
|
+import { message, Modal, Popover, Table, Tabs, Button } from 'antd';
|
|
|
import { useEffect, useRef, useState } from 'react';
|
|
|
-import { caculate, checkRequest, getCurrentCheckStatus, getData, getZhileiList } from './service';
|
|
|
+import { caculate, checkRequest, getCheckType, getCurrentCheckStatus, getCurrentZhileiCheckStatus, getData, getZhileiList } from './service';
|
|
|
|
|
|
|
|
|
import './style.less';
|
|
|
|
|
|
|
|
|
-import { create, all } from 'mathjs'
|
|
|
+import { create, all, number } from 'mathjs'
|
|
|
import exportTableToExcel from '@/utils/tableToExcel';
|
|
|
+import { convertToColumns } from '@/utils/tooljs';
|
|
|
+
|
|
|
+import * as XLSX from 'xlsx';
|
|
|
+import exportTableToMultiExcel from '@/utils/tableToMultiHeaderExcel';
|
|
|
+
|
|
|
|
|
|
const config = {
|
|
|
number: 'number',
|
|
@@ -30,22 +35,188 @@ const config = {
|
|
|
const math = create(all, config as any);
|
|
|
|
|
|
|
|
|
+type JsonStructure = {
|
|
|
+ code: string;
|
|
|
+ name: string;
|
|
|
+ expand?: number;
|
|
|
+ childTitle?: JsonStructure[];
|
|
|
+};
|
|
|
+
|
|
|
+type Column = {
|
|
|
+ title: string | JSX.Element;
|
|
|
+ dataIndex: string;
|
|
|
+ key: string;
|
|
|
+ ellipsis: boolean;
|
|
|
+ width: number;
|
|
|
+ children?: Column[];
|
|
|
+};
|
|
|
+
|
|
|
+const mockData = [
|
|
|
+ {
|
|
|
+ "code": "1",
|
|
|
+ "name": "单元绩效点值1",
|
|
|
+ "sort": 1,
|
|
|
+ "redirect": false,
|
|
|
+ "expand": 1,
|
|
|
+ "childTitle": [
|
|
|
+ {
|
|
|
+ "code": "2-1",
|
|
|
+ "name": "单元绩效点值2",
|
|
|
+ "sort": 1,
|
|
|
+ "redirect": false,
|
|
|
+ "expand": 0,
|
|
|
+ "childTitle": [
|
|
|
+ {
|
|
|
+ "code": "3",
|
|
|
+ "name": "单元绩效点值3",
|
|
|
+ "sort": 1,
|
|
|
+ "redirect": false,
|
|
|
+ "expand": 1,
|
|
|
+ "childTitle": []
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "code": "2-2",
|
|
|
+ "name": "单元绩效点值2",
|
|
|
+ "sort": 1,
|
|
|
+ "redirect": false,
|
|
|
+ "expand": 1,
|
|
|
+ "childTitle": [
|
|
|
+ {
|
|
|
+ "code": "3-1",
|
|
|
+ "name": "单元绩效点值3-1",
|
|
|
+ "sort": 1,
|
|
|
+ "redirect": false,
|
|
|
+ "expand": 1,
|
|
|
+ "childTitle": []
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "code": "3-2",
|
|
|
+ "name": "单元绩效点值3-2",
|
|
|
+ "sort": 1,
|
|
|
+ "redirect": false,
|
|
|
+ "expand": 1,
|
|
|
+ "childTitle": []
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "code": "4",
|
|
|
+ "name": "单元管理绩效",
|
|
|
+ "sort": 2,
|
|
|
+ "redirect": false
|
|
|
+ },
|
|
|
+]
|
|
|
+
|
|
|
+const mockColumns = [
|
|
|
+ {
|
|
|
+ dataIndex: "unitName",
|
|
|
+ ellipsis: true,
|
|
|
+ fixed: "left",
|
|
|
+ key: "unitName",
|
|
|
+ title: "核算单元",
|
|
|
+ width: 140
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "key-23",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-23",
|
|
|
+ title: "单元管理绩效",
|
|
|
+ width: 200
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "key-1646350087779131392",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-1646350087779131392",
|
|
|
+ title: "核算年月",
|
|
|
+ width: 200
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "key-1679019958216040448",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-1679019958216040448",
|
|
|
+ title: "临床诊察积分奖金",
|
|
|
+ width: 200,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ dataIndex: "key-6",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-6",
|
|
|
+ title: "临床诊察积分-节假日奖金",
|
|
|
+ width: 200,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ dataIndex: "key-4",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-4",
|
|
|
+ title: "临床诊察积分-节假日",
|
|
|
+ width: 200
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "key-5",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-5",
|
|
|
+ title: "临床诊察积分-节假日点值",
|
|
|
+ width: 200
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "key-3",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-3",
|
|
|
+ title: "临床诊察积分-工作日奖金",
|
|
|
+ width: 200,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ dataIndex: "key-1",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-1",
|
|
|
+ title: "临床诊察积分-工作日",
|
|
|
+ width: 200
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "key-2",
|
|
|
+ ellipsis: true,
|
|
|
+ key: "key-2",
|
|
|
+ title: "临床诊察积分-工作日点值",
|
|
|
+ width: 200
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: "totalScore",
|
|
|
+ ellipsis: true,
|
|
|
+ fixed: "right",
|
|
|
+ key: "totalScore",
|
|
|
+ title: "总奖金",
|
|
|
+ width: 140
|
|
|
+ }
|
|
|
+]
|
|
|
|
|
|
+let checkStatusArr:number[] = []
|
|
|
|
|
|
const OneBatch = () => {
|
|
|
|
|
|
|
|
|
const [tableColumn, set_tableColumn] = useState<ProColumns[] | any[]>([]);
|
|
|
|
|
|
+ const [columnsForExcel, set_columnsForExcel] = useState<ProColumns[] | any[]>([]);
|
|
|
+
|
|
|
const [tableData, set_tableData] = useState<any[]>([]);
|
|
|
|
|
|
const [currentComputeDate, set_currentComputeDate] = useState<string | undefined>();
|
|
|
|
|
|
const [currentTabKey, set_currentTabKey] = useState('1');
|
|
|
|
|
|
- const [tabs,set_Tabs] = useState<{
|
|
|
- name: any;value:string
|
|
|
-}[]>([]);
|
|
|
+ const [tabs, set_Tabs] = useState<{
|
|
|
+ name: any; value: string
|
|
|
+ }[]>([]);
|
|
|
|
|
|
const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>({ reportCode: undefined });
|
|
|
|
|
@@ -56,7 +227,12 @@ const OneBatch = () => {
|
|
|
const tableRef = useRef<ActionType>();
|
|
|
|
|
|
const [tableH, set_tableH] = useState(0);
|
|
|
- const [reportTitle,set_reportTitle] = useState('');
|
|
|
+ const [reportTitle, set_reportTitle] = useState('');
|
|
|
+ const [checkType, set_checkType] = useState<string | undefined>(undefined); // 一次分配审核模式,1职类一起审核 2职类分开审核
|
|
|
+
|
|
|
+ const [disAccount,set_disAccount] = useState(false);
|
|
|
+
|
|
|
+ //const [checkStatusArr,set_checkStatusArr] = useState<number[]>([]);
|
|
|
|
|
|
|
|
|
const onTabChange = (activeKey: string) => {
|
|
@@ -64,9 +240,57 @@ const OneBatch = () => {
|
|
|
set_tableDataFilterParams({
|
|
|
...tableDataFilterParams,
|
|
|
reportCode: activeKey
|
|
|
- })
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const [expandedkeys, set_expandedkeys] = useState<string[]>([]);
|
|
|
+
|
|
|
+ const convertToColumnsFunc = (json: JsonStructure[], ifRender?: boolean, level: number = 1): Column[] => {
|
|
|
+ return json.map((item) => {
|
|
|
+ let column: Column = {
|
|
|
+ title: item.name,
|
|
|
+ dataIndex: `key-${item.code}`,
|
|
|
+ key: `key-${item.code}`,
|
|
|
+ ellipsis: true,
|
|
|
+ width: 200,
|
|
|
+ };
|
|
|
+
|
|
|
+ const isExpanded = expandedkeys.includes(item.code);
|
|
|
+
|
|
|
+ if (item.expand === 1 && item.childTitle && item.childTitle.length > 0) {
|
|
|
+
|
|
|
+ column.title = ifRender ? (
|
|
|
+ <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'center', alignContent: 'center' }}>
|
|
|
+ <span style={{ display: 'inline-block', maxWidth: '80%', minWidth: 140, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{item.name}</span>
|
|
|
+ <div className='expandIcon' onClick={() => {
|
|
|
+ if (isExpanded) {
|
|
|
+ let _expandedkeys = [...expandedkeys];
|
|
|
+ _expandedkeys.splice(expandedkeys.findIndex(a => a == item.code), 1);
|
|
|
+ set_expandedkeys([..._expandedkeys]);
|
|
|
+ } else {
|
|
|
+ set_expandedkeys([...expandedkeys, item.code]);
|
|
|
+ }
|
|
|
+ }}>
|
|
|
+ {isExpanded ? '-' : '+'}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ) : item.name;
|
|
|
+
|
|
|
+ if (isExpanded) {
|
|
|
+ column.children = convertToColumnsFunc(item.childTitle, ifRender, level + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return column;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ tableRef.current?.reload();
|
|
|
+ }, [expandedkeys])
|
|
|
+
|
|
|
+
|
|
|
const getTableData = async (params: any, sort: any, filter: any) => {
|
|
|
|
|
|
const { reportCode = 1 } = params;
|
|
@@ -78,22 +302,19 @@ const OneBatch = () => {
|
|
|
|
|
|
if (resp) {
|
|
|
|
|
|
- const { title, assignmentData,reportName } = resp;
|
|
|
- const columns = title.map((item: any) => {
|
|
|
- return {
|
|
|
- title: item.name,
|
|
|
- dataIndex: `key-${item.code}`,
|
|
|
- key: `key-${item.code}`,
|
|
|
- width: 140,
|
|
|
+ const { title, assignmentData, reportName } = resp;
|
|
|
+ const columns = convertToColumnsFunc(title, true);
|
|
|
+ const columnsForExcel = convertToColumnsFunc(title, false);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
set_tableColumn([{
|
|
|
title: '核算单元',
|
|
|
dataIndex: 'unitName',
|
|
|
key: 'unitName',
|
|
|
width: 140,
|
|
|
fixed: 'left',
|
|
|
+ ellipsis: true
|
|
|
|
|
|
}, ...columns, {
|
|
|
title: '总奖金',
|
|
@@ -101,9 +322,33 @@ const OneBatch = () => {
|
|
|
key: 'totalScore',
|
|
|
width: 140,
|
|
|
fixed: 'right',
|
|
|
+ ellipsis: true
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+
|
|
|
+ set_columnsForExcel([{
|
|
|
+ title: '核算单元',
|
|
|
+ dataIndex: 'unitName',
|
|
|
+ key: 'unitName',
|
|
|
+ width: 140,
|
|
|
+ fixed: 'left',
|
|
|
+ ellipsis: true
|
|
|
+
|
|
|
+ }, ...columnsForExcel, {
|
|
|
+ title: '总奖金',
|
|
|
+ dataIndex: 'totalScore',
|
|
|
+ key: 'totalScore',
|
|
|
+ width: 140,
|
|
|
+ fixed: 'right',
|
|
|
+ ellipsis: true
|
|
|
|
|
|
}]);
|
|
|
|
|
|
+ // set_tableColumn([...mockColumns]);
|
|
|
+ // set_columnsForExcel([...mockColumns]);
|
|
|
+
|
|
|
+
|
|
|
const data = assignmentData.map((item: any) => {
|
|
|
|
|
|
let rowData: { [key: string]: any } = {};
|
|
@@ -136,10 +381,13 @@ const OneBatch = () => {
|
|
|
|
|
|
const checkHandle = async (type: string) => {
|
|
|
|
|
|
+ if (!checkType) return;
|
|
|
+
|
|
|
const resp = await checkRequest({
|
|
|
computeDate: currentComputeDate as string,
|
|
|
auditType: type == '0' ? '1' : '0', //审核类型 1审核 0取消审核
|
|
|
- });
|
|
|
+ reportCode: checkType == '2' ? currentTabKey : undefined
|
|
|
+ }, checkType);
|
|
|
|
|
|
if (resp) {
|
|
|
if (type == '0') {
|
|
@@ -151,18 +399,19 @@ const OneBatch = () => {
|
|
|
set_auditType('0');
|
|
|
}
|
|
|
}
|
|
|
+ return resp;
|
|
|
}
|
|
|
|
|
|
const getCurrentComputeDate = async () => {
|
|
|
const resp = await getComputeDate();
|
|
|
set_currentComputeDate(resp);
|
|
|
}
|
|
|
-
|
|
|
- const getTabList =async () => {
|
|
|
- const resp = await getZhileiList();
|
|
|
- if(resp){
|
|
|
- set_Tabs(resp.list);
|
|
|
- }
|
|
|
+
|
|
|
+ const getTabList = async () => {
|
|
|
+ const resp = await getZhileiList();
|
|
|
+ if (resp) {
|
|
|
+ set_Tabs(resp.list);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -174,11 +423,25 @@ const OneBatch = () => {
|
|
|
}
|
|
|
|
|
|
|
|
|
- const getCheckStatus = async (computeDate: string) => {
|
|
|
- const resp = await getCurrentCheckStatus(computeDate);
|
|
|
- if (resp) {
|
|
|
- set_auditType(`${resp}`); //0 未审核 1 已审核
|
|
|
+ const getCheckStatus = async (computeDate: string,code?:string) => {
|
|
|
+
|
|
|
+ if (checkType == '1') {
|
|
|
+ const resp = await getCurrentCheckStatus(computeDate);
|
|
|
+ if (resp) {
|
|
|
+ set_auditType('1'); //0 未审核 1 已审核
|
|
|
+ } else {
|
|
|
+ set_auditType('0');
|
|
|
+ }
|
|
|
}
|
|
|
+ if (checkType == '2') {
|
|
|
+ const resp = await getCurrentZhileiCheckStatus(computeDate,code?code:currentTabKey);
|
|
|
+ if (resp) {
|
|
|
+ set_auditType('1'); //0 未审核 1 已审核
|
|
|
+ } else {
|
|
|
+ set_auditType('0');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
const generateFunc = () => {
|
|
@@ -194,47 +457,9 @@ const OneBatch = () => {
|
|
|
}
|
|
|
|
|
|
const exportHandle = () => {
|
|
|
- let headers: { [key: string]: any } = {};
|
|
|
- let data: any[] = [];
|
|
|
- let summary: { [key: string]: any } = {};
|
|
|
-
|
|
|
- tableColumn.forEach(a => {
|
|
|
- if(a.hideInTable != 1){
|
|
|
- headers[`${a.dataIndex}`] = a.title;
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- tableData.forEach(b => {
|
|
|
- let _temp: { [key: string]: any } = {};
|
|
|
- Object.keys(headers).forEach(key => {
|
|
|
- _temp[`${key}`] = b[`${key}`]
|
|
|
- });
|
|
|
- data.push(_temp);
|
|
|
- });
|
|
|
-
|
|
|
- tableColumn.forEach(a => {
|
|
|
- if(a.dataIndex == 'unitName'){
|
|
|
- summary[`unitName`] = '合计';
|
|
|
- }else{
|
|
|
- const calArr = tableData.map(b=>b[`${a.dataIndex}`]);
|
|
|
- const total = calArr.reduce((prev, cur) => {
|
|
|
- //return prev + cur[`${dataIndex}`]
|
|
|
- if (typeof cur == 'number') {
|
|
|
- return math.add(prev, cur);
|
|
|
- }
|
|
|
- }, 0);
|
|
|
- summary[`${a.dataIndex}`] = total;
|
|
|
- }
|
|
|
- });
|
|
|
+ exportTableToMultiExcel(tableData, columnsForExcel as any, reportTitle, true);
|
|
|
|
|
|
- //console.log({headers,tableData,data,summary});
|
|
|
-
|
|
|
- const excelTableData = [
|
|
|
- ...data,
|
|
|
- summary
|
|
|
- ];
|
|
|
-
|
|
|
- exportTableToExcel(excelTableData,headers,reportTitle);
|
|
|
}
|
|
|
|
|
|
const handleResize = (e: any) => {
|
|
@@ -243,6 +468,13 @@ const OneBatch = () => {
|
|
|
set_tableH(tableHeight);
|
|
|
}
|
|
|
|
|
|
+ const getCheckTypeHandle = async () => {
|
|
|
+ const resp = await getCheckType();
|
|
|
+ if (resp && resp.list.length > 0) {
|
|
|
+ set_checkType(resp.list[0].value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function doResize() {
|
|
|
setTimeout(() => {
|
|
|
const ev: any = new Event('resize');
|
|
@@ -250,18 +482,45 @@ const OneBatch = () => {
|
|
|
}, 0)
|
|
|
}
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
- if(tabs.length>0){
|
|
|
+ useEffect(() => {
|
|
|
+ if (tabs.length > 0) {
|
|
|
set_currentTabKey(tabs[0].value);
|
|
|
}
|
|
|
- },[tabs])
|
|
|
+ }, [tabs]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (currentComputeDate && checkType == '2') {
|
|
|
+ getCheckStatus(currentComputeDate as string);
|
|
|
+ }
|
|
|
+ }, [currentTabKey]);
|
|
|
+
|
|
|
+
|
|
|
+ useEffect(()=>{
|
|
|
+ if(checkType == '2'){
|
|
|
+ checkStatusArr = [];
|
|
|
+ tabs.forEach(async (item)=>{
|
|
|
+ const resp = await getCurrentZhileiCheckStatus(currentComputeDate as string,item.value);
|
|
|
+
|
|
|
+ checkStatusArr.push(resp);
|
|
|
+
|
|
|
+ if(checkStatusArr.length == tabs.length){
|
|
|
+ const total = [...checkStatusArr].reduce((prev,cur)=>prev+cur,0);
|
|
|
+ total>0?set_disAccount(true):set_disAccount(false)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },[auditType]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (currentComputeDate) {
|
|
|
+ if (currentComputeDate && checkType) {
|
|
|
getCheckStatus(currentComputeDate);
|
|
|
}
|
|
|
- }, [currentComputeDate]);
|
|
|
+ }, [currentComputeDate, checkType]);
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -269,6 +528,7 @@ const OneBatch = () => {
|
|
|
window.addEventListener('resize', (e) => handleResize(e)) //监听窗口大小改变
|
|
|
doResize();
|
|
|
getTabList();
|
|
|
+ getCheckTypeHandle();
|
|
|
|
|
|
return () => {
|
|
|
window.removeEventListener('resize', (e) => handleResize(e))
|
|
@@ -280,11 +540,11 @@ const OneBatch = () => {
|
|
|
<BMSPagecontainer className='OneBatch' title={`核算年月:${currentComputeDate}`}>
|
|
|
<div className='btnGroup'>
|
|
|
<Popover open={ifShowTip} content={'当前处于审核中,无法操作!'} >
|
|
|
- <div style={{display:'flex',flexDirection:'row',alignItems:'center'}}>
|
|
|
- <div className={auditType == '0' ? 'caculateBtn' : 'caculateBtn disabled'}
|
|
|
+ <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
+ <div className={(auditType == '0'&&!disAccount) ? 'caculateBtn' : 'caculateBtn disabled'}
|
|
|
onMouseEnter={() => auditType == '0' ? set_ifShowTip(false) : set_ifShowTip(true)}
|
|
|
onMouseLeave={() => set_ifShowTip(false)}
|
|
|
- onClick={() => auditType == '0' ? generateFunc() : () => { }}>计算</div>
|
|
|
+ onClick={() => (auditType == '0'&&!disAccount) ? generateFunc() : () => { }}>计算</div>
|
|
|
<div className={auditType == '0' ? 'caculateBtn' : 'caculateBtn disabled'}
|
|
|
onMouseEnter={() => auditType == '0' ? set_ifShowTip(false) : set_ifShowTip(true)}
|
|
|
onMouseLeave={() => set_ifShowTip(false)}
|
|
@@ -298,19 +558,25 @@ const OneBatch = () => {
|
|
|
defaultActiveKey='1'
|
|
|
onChange={onTabChange}
|
|
|
items={[
|
|
|
- ...tabs.map(a=>({label:a.name,key:a.value}))
|
|
|
+ ...tabs.map(a => ({ label: a.name, key: a.value }))
|
|
|
]}
|
|
|
/>
|
|
|
<div className='tabContent'>
|
|
|
- {currentComputeDate && <BMSTable actionRef={tableRef} rowKey='unitCode' pagination={false} columns={tableColumn as ProColumns[]}
|
|
|
+ {currentComputeDate && <BMSTable actionRef={tableRef} rowKey='unitCode' bordered pagination={false} columns={tableColumn as ProColumns[]}
|
|
|
params={tableDataFilterParams}
|
|
|
- scroll={{ x: 140 * 10, y: tableH }}
|
|
|
+ scroll={{ x: 140 * tableColumn.length, y: tableH }}
|
|
|
request={(params, sort, filter) => getTableData(params, sort, filter)}
|
|
|
|
|
|
summary={(pageData) => {
|
|
|
const Caculate = ({ colData }: { colData: any }) => {
|
|
|
|
|
|
- const { dataIndex } = colData;
|
|
|
+ const { dataIndex, children } = colData;
|
|
|
+
|
|
|
+ if (children) {
|
|
|
+ return children.map((child: any, index: number) => (
|
|
|
+ <Caculate key={index} colData={child} />
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
const total = pageData.reduce((prev, cur) => {
|
|
|
//return prev + cur[`${dataIndex}`]
|
|
@@ -319,25 +585,30 @@ const OneBatch = () => {
|
|
|
}
|
|
|
}, 0);
|
|
|
|
|
|
- return dataIndex == "unitName" ? <div style={{textAlign:'left'}}>合计</div>:(
|
|
|
+ return dataIndex == "unitName" ? <div style={{ textAlign: 'left' }}>合计</div> : (
|
|
|
//<span>{typeof total == 'number'?math.format(total, {precision: 14}) : '合计'}</span>
|
|
|
- <span style={{textAlign:'left'}}>{typeof total == 'number' ? Number(total.toFixed(4)) : '-'}</span>
|
|
|
+ <span style={{ textAlign: 'left' }}>{typeof total == 'number' ? Number(total.toFixed(4)) : '-'}</span>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ const renderSummaryRow = (columns: any[]): React.ReactNode[] => {
|
|
|
+ return columns.map((colData, index) => {
|
|
|
+ if (colData.children) {
|
|
|
+ return renderSummaryRow(colData.children);
|
|
|
+ } else {
|
|
|
+ return (
|
|
|
+ <Table.Summary.Cell key={index} index={index} align='center' rowSpan={1}>
|
|
|
+ <Caculate colData={colData} />
|
|
|
+ </Table.Summary.Cell>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<Table.Summary fixed>
|
|
|
<Table.Summary.Row>
|
|
|
- {
|
|
|
- tableColumn.map((item, index) => {
|
|
|
- return (
|
|
|
- <Table.Summary.Cell key={index} index={index} align='center' rowSpan={1} >
|
|
|
- <Caculate colData={item} />
|
|
|
- </Table.Summary.Cell >
|
|
|
- )
|
|
|
- })
|
|
|
- }
|
|
|
+ {renderSummaryRow(tableColumn)}
|
|
|
</Table.Summary.Row>
|
|
|
</Table.Summary>
|
|
|
);
|