Эх сурвалжийг харах

更新报表数值渲染格式

code4eat 3 сар өмнө
parent
commit
0dbf545381

+ 5 - 5
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: 2024-11-04 17:47:29
+ * @LastEditTime: 2025-04-11 15:50:16
  * @FilePath: /BudgetManaSystem/src/app.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -385,13 +385,13 @@ export function patchClientRoutes({ routes }: { routes: any }) {
         treeLoop(a);
       })
     }
+    
 
   }
 
   treeLoop(routes[0]);
 
-  console.log({routes});
-
+  console.log({ routes });
 }
 
 
@@ -561,8 +561,8 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
 
             const { newTree, firstLeafNode, firstLeafNodePath } = transformTree(_menu);
 
-            console.log({newTree});
-            
+            // console.log({newTree});
+
             return newTree
 
           }

+ 16 - 6
src/components/SQLEditor/index.tsx

@@ -2,12 +2,12 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2024-01-04 13:46:15
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-11-20 17:52:27
+ * @LastEditTime: 2024-12-16 18:00:07
  * @FilePath: /CostAccountingSys/src/components/SQLEditor/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
 import React, { useEffect, useState } from 'react';
-import MonacoEditor from 'react-monaco-editor';
+import MonacoEditor, { monaco } from 'react-monaco-editor';
 import { Form, message, Modal, Input } from 'antd';
 import './style.less';
 import { copyToClipboard } from '@/utils/tooljs';
@@ -92,10 +92,20 @@ const SQLEditor: React.FC<SQLEditorProps> = ({ name, label, rules, form, width =
         editor.focus();
     };
     
-    const handleEditorWillMount = (monaco: any) => {
-        // 绑定事件确保粘贴未被拦截
-        monaco.editor.onDidPaste(() => {
-            console.log('Pasted content');
+    // const handleEditorWillMount = (monaco: any) => {
+    //     // 绑定事件确保粘贴未被拦截
+    //     monaco.editor.onDidPaste(() => {
+    //         console.log('Pasted content');
+    //     });
+    // };
+    const handleEditorWillMount = (monacoInstance: typeof monaco) => {
+        // 监听编辑器的粘贴事件
+        monacoInstance.editor.onDidCreateEditor((editor) => {
+          editor.onDidChangeModelContent((event) => {
+            if (event.isFlush) {
+              console.log('Pasted content detected!');
+            }
+          });
         });
     };
 

+ 3 - 2
src/global.less

@@ -116,9 +116,10 @@ textarea {
         }
         .cost-ant-modal-body {
             max-height: 570px;
-            // overflow-y: scroll;
-            // overflow-x: hidden;
+            overflow-y: scroll;
+            overflow-x: hidden;
             padding: 0;
+            padding-left: 4px;
 
             .cost-ant-modal-confirm-body-wrapper {
                 .cost-ant-modal-confirm-body {

+ 28 - 9
src/pages/baseSetting/costAllocationSet/allocationParamsMap/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-08-12 10:56:07
+ * @LastEditTime: 2025-02-06 15:59:31
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -19,7 +19,7 @@ import { ActionType, ProFormDependency, ProFormInstance, ProFormText, ProFormSel
 import { ModalForm } from '@ant-design/pro-form'
 import { ProColumns } from '@ant-design/pro-table';
 import { Input, message, Popconfirm, Tag, Tabs } from 'antd';
-import { Key, useEffect, useRef, useState } from 'react';
+import { Key, SetStateAction, useEffect, useRef, useState } from 'react';
 
 import 'moment/locale/zh-cn';
 import locale from 'antd/es/date-picker/locale/zh_CN';
@@ -212,9 +212,20 @@ export default function AllocationParamsMap() {
     const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => {
 
         const [ifDisable, setIfDisable] = useState(false);
-        let needDisableIds: any[] = [];
+        const [needDisableIds,set_needDisableIds] = useState<any[]>([]);
+
         let accountingIds: Key[] = record.accountingIdList?record.accountingIdList.map((a:string)=>Number(a)):[];
 
+        useEffect(()=>{
+            if(type == 'EDIT'&&needDisableIds.length>0){
+                if (needDisableIds.includes(record.responsibilityId)) {
+                    setIfDisable(false);
+                } else {
+                    setIfDisable(true);
+                }
+            }
+        },[needDisableIds])
+
         return (
             <ModalForm
                 title={`${type == 'EDIT' ? '编辑' : '新增'}成本分摊参数对应`}
@@ -222,7 +233,7 @@ export default function AllocationParamsMap() {
                 formRef={formRef}
                 initialValues={type == 'EDIT' ? {
                     ...record,
-                    accountings:record.accountingIdList?record.accountingIdList.map((a:string)=>Number(a)):[],
+                    accountings:(record.accountingIdList)?record.accountingIdList.map((a:string)=>Number(a)):[],
                 } : {}}
                 trigger={
                     type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
@@ -244,6 +255,7 @@ export default function AllocationParamsMap() {
                         },
                     ]}
                     fieldProps={{
+                        showSearch:true,
                         onChange: async (val, option: any) => {
                             const { } = option;
                             const resp = await getResponsibilityCenterSelecterList();
@@ -255,7 +267,6 @@ export default function AllocationParamsMap() {
                                 }
                             }
 
-
                             if (needDisableIds.includes(val)) {
                                 setIfDisable(false);
                             } else {
@@ -278,15 +289,23 @@ export default function AllocationParamsMap() {
                         //     }
                         // ]
                         if (resp) {
-                            return resp.map((item: any) => {
+                            let tempArr:any[] = [];
+                            const result =  resp.map((item: any) => {
                                 if (item.calcType == 1) {
-                                    needDisableIds.push(item.id);
+                                    tempArr.push(item.id);
                                 }
                                 return ({
                                     label: item.responsibilityName,
                                     value: item.id,
                                 })
-                            })
+                            });
+                            set_needDisableIds((prevIds) => {
+                                if (prevIds.length === tempArr.length && prevIds.every((id, index) => id === tempArr[index])) {
+                                    return prevIds;  // 保持原来的引用,不触发更新
+                                }
+                                return tempArr;
+                            });
+                            return result
                         }
                         return []
                     }}
@@ -313,7 +332,7 @@ export default function AllocationParamsMap() {
                     fieldProps={{
                         showSearch: true,
                         multiple: true,
-                        maxTagCount:3,
+                        maxTagCount:'responsive',
                         maxTagPlaceholder:'...',
                         treeCheckable: true,
                         treeNodeFilterProp: 'accountingName',

+ 96 - 14
src/pages/baseSetting/otherItemSet/departmentCostCalc/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-12-05 15:11:20
+ * @LastEditTime: 2025-05-13 11:12:48
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -151,11 +151,9 @@ function processTree(originalData: any[]) {
         // 如果当前节点有profitList,处理它
         if (newNode.profitList && Array.isArray(newNode.profitList)) {
             newNode.profitList.forEach((profit: any) => {
-                // 添加新的键值对到新节点
-                newNode[`${profit.reportId}`] = formatMoneyNumber(profit.value);
+                // 添加新的键值对到新节点,保持原始值的精度
+                newNode[`${profit.reportId}`] = profit.value;
             });
-            // 如果不需要保留profitList,可以删除
-            // delete newNode.profitList;
         }
 
         // 如果节点有子节点,递归处理子节点
@@ -169,10 +167,10 @@ function processTree(originalData: any[]) {
 
 // 递归函数,用于处理多层级标题
 function generateColumns(item: any, titleIndex = 0, title: string, hideRatioColumns = false) {
-    // 检查是否需要隐藏"占比"列,如果title包含"占比",且hideRatioColumns为true,则返回null
-    if (hideRatioColumns && item[`${title}`].includes('占比')) {
-        return null;
-    }
+    // // 检查是否需要隐藏"占比"列,如果title包含"占比",且hideRatioColumns为true,则返回null
+    // if (hideRatioColumns && item[`${title}`].includes('占比')) {
+    //     return null;
+    // }
 
     const column: any = title == 'responsibilityName' ? {
         title: item[`${title}`],
@@ -182,7 +180,33 @@ function generateColumns(item: any, titleIndex = 0, title: string, hideRatioColu
         ellipsis: true,
         renderText(num: number, record: any) {
             if (item.responsibilityCode.indexOf('amount') != -1) {
-                return formatMoneyNumber(num);
+                const { permil, decimalPlace, dataType } = record;
+                if (typeof num === 'number' && !isNaN(num)) {
+                    // 根据 dataType 判断渲染类型
+                    if (dataType === 2) {
+                        // 百分比类型
+                        return `${(num * 100).toFixed(decimalPlace || 2)}%`;
+                    } else {
+                        // 数值类型 (dataType === 1 或未定义)
+                        // 根据 permil 字段决定是否使用千位分隔符
+                        const useGrouping = permil === 1;
+
+                        // 解析 decimalPlace 字段,如果无效或未定义,则默认为2
+                        let fractionDigits = parseInt(decimalPlace, 10);
+                        if (isNaN(fractionDigits) || fractionDigits < 0) {
+                            fractionDigits = 2; // 默认保留两位小数
+                        }
+
+                        return num.toLocaleString('en-US', {
+                            minimumFractionDigits: fractionDigits,
+                            maximumFractionDigits: fractionDigits,
+                            useGrouping: useGrouping
+                        });
+                    }
+                } else {
+                    // 对于非数字或 null/undefined,返回空
+                    return '';
+                }
             } else {
                 return num;
             }
@@ -193,6 +217,38 @@ function generateColumns(item: any, titleIndex = 0, title: string, hideRatioColu
         dataIndex: `${item[`reportId`]}`,
         key: `${item[`reportId`]}`,
         align: 'right',
+        // 新增:根据 dataType 渲染不同格式
+        renderText(num: string) {
+            // 使用 parseFloat 来保持数字精度
+            const value = parseFloat(num);
+            const { permil, decimalPlace, dataType } = item;
+        
+            // 检查 value 是否为有效数字
+            if (typeof value === 'number' && !isNaN(value)) {
+                if (dataType === 2) {
+                    // 百分比类型,保留 decimalPlace 位小数
+                    return `${(value * 100).toFixed(decimalPlace || 2)}%`;
+                } else {
+                    // 数值类型 (dataType === 1 或未定义)
+                    // 根据 permil 字段决定是否使用千位分隔符
+                    const useGrouping = permil === 1;
+                    // 解析 decimalPlace 字段,如果无效或未定义,则默认为2
+                    let fractionDigits = parseInt(decimalPlace, 10);
+                    if (isNaN(fractionDigits) || fractionDigits < 0) {
+                        fractionDigits = 2; // 默认保留两位小数
+                    }
+                    // 返回格式化后的数字
+                    return value.toLocaleString('en-US', {
+                        minimumFractionDigits: fractionDigits,
+                        maximumFractionDigits: fractionDigits,
+                        useGrouping: useGrouping
+                    });
+                }
+            } else {
+                // 非数字或 null/undefined 返回空
+                return '';
+            }
+        },
     };
 
     // 递归处理子列
@@ -300,11 +356,37 @@ export default function DepartmentCostCalc() {
             align: 'right',
             dataIndex: 'amount',
             renderText(num, record) {
-                const { calcType } = record;
+                const { calcType, permil, decimalPlace, dataType } = record;
                 if (record.children && calcType == '0') {
                     return <React.Fragment></React.Fragment>
                 } else {
-                    return formatMoneyNumber(num);
+                    // 检查 num 是否是有效数字
+                    if (typeof num === 'number' && !isNaN(num)) {
+                        // 根据 dataType 判断渲染类型
+                        if (dataType === 2) {
+                            // 百分比类型
+                            return `${(num * 100).toFixed(decimalPlace || 2)}%`;
+                        } else {
+                            // 数值类型 (dataType === 1 或未定义)
+                            // 根据 permil 字段决定是否使用千位分隔符
+                            const useGrouping = permil === 1;
+
+                            // 解析 decimalPlace 字段,如果无效或未定义,则默认为2
+                            let fractionDigits = parseInt(decimalPlace, 10);
+                            if (isNaN(fractionDigits) || fractionDigits < 0) {
+                                fractionDigits = 2; // 默认保留两位小数
+                            }
+
+                            return num.toLocaleString('en-US', {
+                                minimumFractionDigits: fractionDigits,
+                                maximumFractionDigits: fractionDigits,
+                                useGrouping: useGrouping
+                            });
+                        }
+                    } else {
+                        // 对于非数字或 null/undefined,返回空
+                        return '';
+                    }
                 }
             },
         },
@@ -314,11 +396,11 @@ export default function DepartmentCostCalc() {
             hideInTable: !ifShowPercent,
             dataIndex: 'percent',
             renderText(num, record) {
-                const { calcType } = record;
+                const { calcType, decimalPlace } = record;
                 if (record.children && calcType == '0') {
                     return <React.Fragment></React.Fragment>
                 } else {
-                    return num != null ? `${((num * 100).toFixed(2))}%` : num
+                    return num != null ? `${((num * 100).toFixed(decimalPlace))}%` : num
                 }
 
             },

+ 69 - 17
src/pages/baseSetting/otherItemSet/reportItemSet/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-11-08 11:54:36
+ * @LastEditTime: 2025-05-12 14:59:43
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -15,10 +15,10 @@ import { KCIMTable } from '@/components/KCIMTable';
 import { createFromIconfontCN } from '@ant-design/icons';
 
 
-import { ActionType, ProFormDependency, ProFormInstance, ProFormText, ProFormSelect, ProFormDigit } from '@ant-design/pro-components';
+import { ActionType, ProFormDependency, ProFormInstance, ProFormText, ProFormSelect, ProFormDigit, ProFormRadio } from '@ant-design/pro-components';
 import { ModalForm, ProFormTextArea } from '@ant-design/pro-form'
 import { ProColumns } from '@ant-design/pro-table';
-import { Modal, message, Popconfirm, Form, Tabs, Switch } from 'antd';
+import { Modal, message, Popconfirm, Form, Tabs, Switch, Row, Col } from 'antd';
 import { Key, useEffect, useRef, useState } from 'react';
 
 import 'moment/locale/zh-cn';
@@ -95,7 +95,7 @@ const openRule = () => {
                 对应的是分摊的责任中心,放射科,功能科等
                 <div></div>
                 <span>对应分摊层级:</span>
-                对应的是分摊的层级,如“护理”分摊层级,“医技”分摊层级。
+                对应的是分摊的层级,如"护理"分摊层级,"医技"分摊层级。
                 <div></div>
                 <span>小计:</span>
                 是对第一层下的所有项目的合计计算。
@@ -139,9 +139,9 @@ export default function ReportItemSet() {
         {
             title: '计算方式',
             dataIndex: 'calcType',
-            renderText:(num, record) => {
-                const temp = calcTypes.filter((a)=>a.code == num);
-                return temp.length>0?temp[0].name:''
+            renderText: (num, record) => {
+                const temp = calcTypes.filter((a) => a.code == num);
+                return temp.length > 0 ? temp[0].name : ''
             },
 
         },
@@ -212,7 +212,7 @@ export default function ReportItemSet() {
             width: 60,
             dataIndex: 'hide',
             renderText: (_: any, record: any) => {
-                return <Switch  size='small' checked={_ == 1} onChange={(bool) => updateTable({...record,hide:bool?1:0},'EDIT')} />
+                return <Switch size='small' checked={_ == 1} onChange={(bool) => updateTable({ ...record, hide: bool ? 1 : 0 }, 'EDIT')} />
             }
         },
         {
@@ -366,7 +366,9 @@ export default function ReportItemSet() {
                 calcFormula,
                 isLoss: formVal.isLoss ? 1 : 0,
                 reportType: Number(reportType),
-                parentId
+                parentId,
+                decimalPlace:formVal.decimalPlace,
+                permil: formVal.dataType === 1 ? (formVal.permil ? 1 : 0) : 0,
             }
 
             const resp = await addData(result);
@@ -380,7 +382,7 @@ export default function ReportItemSet() {
         }
         if (type == 'EDIT') {
             try {
-                const { reportName, sort, calcType = 0, calcFormula = '', isLoss, parentId, id, fraction, costType, description,hide } = formVal;
+                const { reportName, sort, calcType = 0, calcFormula = '', isLoss, parentId, id, fraction, costType, description, hide, dataType, decimalPlace, permil } = formVal;
                 const result = {
                     id,
                     parentId,
@@ -393,7 +395,10 @@ export default function ReportItemSet() {
                     costType,
                     isLoss: isLoss ? 1 : 0,
                     description,
-                    hide
+                    hide,
+                    dataType,
+                    decimalPlace:decimalPlace,
+                    permil: dataType === 1 ? (permil ? 1 : 0) : 0,
                 };
                 const resp = await editData(result);
                 if (resp) {
@@ -427,11 +432,12 @@ export default function ReportItemSet() {
         return (
             <ModalForm
                 title={type == 'COPY' ? '复制' : `${type == 'EDIT' ? '编辑' : '新增'}报表`}
-                width={350}
+                width={380}
                 formRef={formRef}
                 initialValues={type == 'EDIT' ? {
-                    ...record
-                } : {}}
+                    ...record,
+                    permil: record.dataType === 1 ? !!record.permil : false,
+                } : { dataType: 1, decimalPlaces: 2, permil: false }}
                 trigger={
                     type == 'EDIT' ? <a key="edit" >编辑</a> : type == 'ADDCHILD' ? <a className='add'>添加</a> : type == 'COPY' ? <span className='copy' style={{ marginRight: 8 }}>复制</span> : <span className='add'>新增</span>
                 }
@@ -472,7 +478,7 @@ export default function ReportItemSet() {
                                         name="calcType"
                                         label="计算类型"
                                         options={[
-                                            ...(calcTypes.map((a)=>({label:a.name,value:Number(a.code)})))
+                                            ...(calcTypes.map((a) => ({ label: a.name, value: Number(a.code) })))
                                         ]}
                                         placeholder="请选择状态"
                                         rules={[{ required: true, message: '请选择计算类型!' }]}
@@ -507,7 +513,7 @@ export default function ReportItemSet() {
                                                     label="损益标志"
                                                     valuePropName="checked"
                                                 >
-                                                    <Switch />
+                                                    <Switch size='small' />
                                                 </Form.Item>
                                             ) : (
                                                 <></>
@@ -537,6 +543,52 @@ export default function ReportItemSet() {
                                 placeholder="请选择"
                                 rules={[{ required: true, message: '请选择占比计算类型!' }]}
                             />
+                            <ProFormRadio.Group
+                                name="dataType"
+                                label="数据格式"
+                                options={[
+                                    { label: '数值', value: 1 },
+                                    { label: '百分比', value: 2 },
+                                ]}
+                                rules={[{ required: true }]}
+                            />
+                            <ProFormDependency name={['dataType']}>
+                                {({ dataType }) => {
+                                    return dataType === 1 ? (
+                                        <>
+                                            <Row gutter={16}>
+                                                <Col span={12}>
+                                                    <ProFormDigit
+                                                        label="小数位数"
+                                                        name="decimalPlace"
+                                                        min={0}
+                                                        max={10}
+                                                        fieldProps={{ precision: 0 }}
+                                                        rules={[{ required: true, message: '请输入小数位数!' }]}
+                                                    />
+                                                </Col>
+                                                <Col span={12}>
+                                                    <Form.Item
+                                                        label="是否需要千分号"
+                                                        name="permil"
+                                                        valuePropName="checked"
+                                                        style={{ marginBottom: '24px' }}
+                                                    >
+                                                        <Switch size='small' />
+                                                    </Form.Item>
+                                                </Col>
+                                            </Row>
+                                        </>
+                                    ) : <ProFormDigit
+                                        label="小数位数"
+                                        name="decimalPlace"
+                                        min={0}
+                                        max={10}
+                                        fieldProps={{ precision: 0 }}
+                                        rules={[{ required: true, message: '请输入小数位数!' }]}
+                                    />;
+                                }}
+                            </ProFormDependency>
                             <ProFormTextArea
                                 label="说明"
                                 placeholder='请输入'
@@ -585,7 +637,7 @@ export default function ReportItemSet() {
         const fetchData = async () => {
             const { systemId } = JSON.parse(localStorage.getItem('currentSelectedTab') as string);
             const resp = await getDicDataBySysId(systemId, 'REPORT_ITEM_CALC_TYPE');
-            setCalcTypes(resp?.dataVoList??[]);  // 假设 resp 返回的是一个键值对
+            setCalcTypes(resp?.dataVoList ?? []);
         };
         fetchData();
         getTabs();

+ 24 - 5
src/pages/costAccounting/calcPageTemplate/columns.tsx

@@ -849,7 +849,9 @@ export const afterCostShareSearch: ProColumns[] = [
         dataIndex: 'amount',
         align:'right',
         renderText(num, record, index, action) {
-            return formatMoneyNumber(num);
+            const { decimalPlace, permil } = record;
+            const shouldUseThousandSeparator = permil === 1;
+            return formatMoneyNumber(num, { decimalPlaces: decimalPlace, useThousandSeparator: shouldUseThousandSeparator });
         },
     },
 
@@ -918,10 +920,27 @@ export const wholeHospCostCalculate: ProColumns[] = [
         align:'right',
         dataIndex: 'amount',
         renderText(num, record, index, action) {
-            const { children,calcType } = record;
-            // 有 children 时返回 null,否则格式化金额
-            return (children && children.length > 0 && calcType == '0' )? <React.Fragment></React.Fragment> : formatMoneyNumber(num);
+            const { decimalPlace, permil, dataType, children, calcType } = record;
+            // 有 children 且 calcType 为 0 时返回空
+            if (children && children.length > 0 && calcType === '0') {
+                return <React.Fragment></React.Fragment>;
+            }
             
+            // 根据 dataType 处理数据
+            if (dataType === 2) {
+                // 百分比类型
+                if (typeof num === 'number' && !isNaN(num)) {
+                    return `${(num * 100).toFixed(decimalPlace || 2)}%`;
+                }
+                return num;
+            } else {
+                // 数值类型
+                const formatOptions = {
+                    decimalPlaces: decimalPlace !== undefined ? decimalPlace : 2,
+                    useThousandSeparator: permil === 1
+                };
+                return formatMoneyNumber(num, formatOptions);
+            }
         },
     },
     {
@@ -930,7 +949,7 @@ export const wholeHospCostCalculate: ProColumns[] = [
         align:'right',
         dataIndex: 'percent',
         renderText(num, record) {
-            const { children,calcType } = record;
+            const { children, calcType } = record;
             // 有 children 时返回 null,否则格式化百分比
             return (children && children.length > 0 && calcType == '0') ? <React.Fragment></React.Fragment> : formatToPercentage(num);
         },

+ 17 - 3
src/pages/costAccounting/calcPageTemplate/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-12-05 15:06:14
+ * @LastEditTime: 2025-05-13 13:45:50
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -565,10 +565,24 @@ export default function calcPageTemplate() {
           } else {
             if (params.calcPageKey == 'wholeHospCostCalculate') {
               if (key == 'amount') {
-                _temp[`${key}`] = (item[`${key}`] != undefined || item[`${key}`] != null) ? formatMoneyNumber(item[`${key}`]) : item[`${key}`];
+                const { decimalPlace, permil, dataType, children, calcType } = item;
+                if (children && children.length > 0 && calcType === '0') {
+                  _temp[`${key}`] = '';
+                } else if (dataType === 2) {
+                  _temp[`${key}`] = typeof item[`${key}`] === 'number' && !isNaN(item[`${key}`]) ? 
+                    `${(item[`${key}`] * 100).toFixed(decimalPlace || 2)}%` : 
+                    item[`${key}`];
+                } else {
+                  const formatOptions = {
+                    decimalPlaces: decimalPlace !== undefined ? decimalPlace : 2,
+                    useThousandSeparator: permil === 1
+                  };
+                  _temp[`${key}`] = formatMoneyNumber(item[`${key}`], formatOptions);
+                }
               }
               if (key == 'percent') {
-                _temp[`${key}`] = (item[`${key}`] != undefined || item[`${key}`] != null) ? formatToPercentage(item[`${key}`]) : item[`${key}`];
+                const { children, calcType } = item;
+                _temp[`${key}`] = (children && children.length > 0 && calcType === '0') ? '' : formatToPercentage(item[`${key}`]);
               }
             } else {
               _temp[`${key}`] = item[`${key}`];

+ 2 - 2
src/pages/costAccounting/calcPageTemplate/service.ts

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 16:31:27
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-12-05 14:58:45
+ * @LastEditTime: 2024-12-11 14:16:08
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/service.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -387,7 +387,7 @@ export const downloadTemplateReq = (pathStr: string,data:any) => {
       )
       const link = document.createElement('a')
       // 设置导出的文件名称
-      link.download = `${filename}` + '.xls'
+      link.download = `${filename}`
       link.style.display = 'none'
       link.href = objectUrl
       link.click()

+ 8 - 12
src/pages/costLibraryManagement/projectCostManagement/chargeItemsMana/components/setting.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2024-02-21 13:32:53
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-06-12 11:21:53
+ * @LastEditTime: 2025-01-08 16:22:26
  * @FilePath: /CostAccountingSys/src/pages/costLibraryManagement/projectCostManagement/chargeItemsMana/components/setting.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -234,7 +234,7 @@ export const Setting = (props: any) => {
                 }
             }
 
-            const resp = await addDrawerTableData({...result,departmentCode:formVal.departmentCode}, currentTabKey as number);
+            const resp = await addDrawerTableData({...result,departmentCode:record.departmentCode}, currentTabKey as number);
             if (resp) {
                 //tableRef.current?.reload();
                 getTableData(`${currentTabKey}`);
@@ -278,7 +278,7 @@ export const Setting = (props: any) => {
                     }
                 }
 
-                const resp = await editDrawerTableData({ ...result, id: formVal.id,departmentCode:formVal.departmentCode }, currentTabKey);
+                const resp = await editDrawerTableData({ ...result, id: formVal.id,departmentCode:record.departmentCode }, currentTabKey);
                 if (resp) {
                     //tableRef.current?.reload();
                     getTableData(`${currentTabKey}`);
@@ -319,14 +319,14 @@ export const Setting = (props: any) => {
                 colProps={{ span: 24 }}
                 grid
             >
-                <ProFormSelect
+                {/* <ProFormSelect
                     name="departmentCode"
                     label="科室:"
                     placeholder="请输入"
                     request={fetchAllDepartments}
                     fieldProps={{labelInValue:false}}
                     rules={[{ required: false, message: '科室不能为空!' }]}
-                />
+                /> */}
                 {
                     currentTabKey == 1 && (
                         <ProFormSelect
@@ -537,8 +537,8 @@ export const Setting = (props: any) => {
                 onFinish={(keys, rows) => tableSelecterCommit(keys, rows)}
             />
             <div className="header">
-                <div className="title">{record?record.standItemName:'项目'}</div>
-                <div className="btnGroup">
+                <div className="title">{record?`${record.name}(${record.departmentName})`:'项目'}</div>
+                <div className="btnGroup">  
                     <a className="back" onClick={() => onVisibleChange(false)}>返回</a>
                     {(currentTabKey != '4' && currentTabKey != '5') && <UpDataActBtn key={'act'} record={record} type='ADD' currentTabKey={Number(currentTabKey)} />}
                     {(currentTabKey == '4' || currentTabKey == '5') && <a className='add' onClick={() => set_tableSelecterVisible(true)}>添加</a>}
@@ -580,11 +580,7 @@ export const Setting = (props: any) => {
 
                     } : false}
                     tableAlertRender={false}
-                    columns={[{
-                        title: '科室',
-                        width:120,
-                        dataIndex: 'departmentName',
-                    },...columns]}
+                    columns={[...columns]}
                     actionRef={tableRef} rowKey='id'
                     dataSource={dataSource}
                 />

+ 2 - 2
src/pages/costLibraryManagement/projectCostManagement/standardProjectMana/drawer.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-11-15 15:34:36
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-10-15 15:33:47
+ * @LastEditTime: 2025-01-08 16:42:17
  * @FilePath: /CostAccountingSys/src/pages/costLibraryManagement/projectCostManagement/standardProjectMana/drawer.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -420,7 +420,7 @@ const DrawerActBtn = ({ record,onVisibleChange }: { record: any,onVisibleChange?
         >
             <div className='standardProjectMana_drawer'>
                 <div className='topbar'>
-                    <div className='title'>{`成本设置`}</div>
+                    <div className='title'>{record?.name}</div>
                     <div className='btnGroup'>
                         <span className='cancel' onClick={() => onCancel()}>返回</span>
                         <UpDataActBtn key={'act'} record={record} type='ADD' currentTabKey={currentTabKey} />

+ 12 - 9
src/pages/costLibraryManagement/reportMana/reportColumnMana/UpDateActBtn.tsx

@@ -1,6 +1,6 @@
 import { KCIMTable } from "@/components/KCIMTable";
 import SQLEditor from "@/components/SQLEditor";
-import { FormInstance, ModalForm, ProColumns, ProFormDependency, ProFormDigit, ProFormInstance, ProFormRadio, ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-components";
+import { FormInstance, ModalForm, ProColumns, ProFormDependency, ProFormDigit, ProFormInstance, ProFormRadio, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea } from "@ant-design/pro-components";
 import { useEffect, useRef, useState } from "react";
 import { addData, editData, getReportListTableData, getReportListType } from "./service";
 import { Form, Switch, Input, message } from 'antd'
@@ -138,9 +138,9 @@ const UpDateActBtn: React.FC<UpDataActBtnProps> = ({ record, type, tableRef, onU
             const { list } = resp;
             if (list.length > 1) {
                 const result = list.filter((a) => a.code == columnCode);
-                set_initialValues(result[0]);
+                set_initialValues({...result[0],permil:result[0].permil == '1'?true:false});
             } else {
-                set_initialValues(list[0]);
+                set_initialValues({...list[0],permil:list[0].permil == '1'?true:false});
             }
         }
 
@@ -181,7 +181,7 @@ const UpDateActBtn: React.FC<UpDataActBtnProps> = ({ record, type, tableRef, onU
                         initialValues={initialValues}
                         onOpenChange={bool=>setIsModalVisible(bool)}
                         onFinish={(val) => {
-                            return updateTable(type == 'EDIT' ? (record.request?{...val,id:initialValues.id, sql: val.sql ? val.sql : ''}:{ ...record, ...val, sql: val.sql ? val.sql : '', }) : { ...val }, type);
+                            return updateTable(type == 'EDIT' ? (record.request?{...val,id:initialValues.id, sql: val.sql ? val.sql : ''}:{ ...record, ...val, sql: val.sql ? val.sql : '',permil:record.permil == '1'?true:false }) : { ...val }, type);
                         }}
                         colProps={{ span: 24 }}
 
@@ -254,12 +254,15 @@ const UpDateActBtn: React.FC<UpDataActBtnProps> = ({ record, type, tableRef, onU
                                                         />
                                                         {
                                                             dataType == 3 && (
-                                                                <>
-                                                                    <Form.Item name='permil'>
+                                                                <div style={{display:'inline-flex',flexDirection:'row',justifyContent:'center',alignItems:'center'}}>
+                                                                    {/* <Form.Item name='permil'>
                                                                         <Switch size='small' style={{ marginTop: 26, marginLeft: 8 }} />
-                                                                    </Form.Item>
-                                                                    <span style={{ marginTop: 23, marginLeft: 4 }}>千分号</span>
-                                                                </>
+                                                                    </Form.Item> */}
+                                                                    <ProFormSwitch colProps={{span:8}} fieldProps={{
+                                                                        size:'small',
+                                                                    }} noStyle name='permil' />
+                                                                    <span style={{ marginLeft: 8 }}>千分号</span>
+                                                                </div>
                                                             )
                                                         }
                                                     </div>

+ 1 - 0
src/pages/costLibraryManagement/reportMana/reportColumnMana/service.ts

@@ -14,6 +14,7 @@ import { request } from 'umi';
 //获取table列表数据
 
 export type ReportListTableDataType = {
+  permil: string;
   id: number,
   hospId: number,
   code: number,

+ 22 - 7
src/pages/departmentCostCheck/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-12-05 15:11:30
+ * @LastEditTime: 2025-05-13 10:26:40
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -94,7 +94,19 @@ const transformData = (data: any[]) => {
     const transformEntry = (entry: any, computeDate: string) => {
         if (!entry) return {};
         const transformedEntry = { ...entry };
-        transformedEntry[`${computeDate}_amount`] = entry.amount != null ? formatMoneyNumber(entry.amount) : null;
+        
+        // 根据 dataType 处理金额
+        if (entry.dataType === 2) {
+            // 百分比类型
+            transformedEntry[`${computeDate}_amount`] = entry.amount != null ? `${((entry.amount * 100).toFixed(entry.decimalPlace || 2))}%` : null;
+        } else {
+            // 数值类型 (dataType === 1 或未定义)
+            transformedEntry[`${computeDate}_amount`] = entry.amount != null ? formatMoneyNumber(entry.amount, {
+                decimalPlaces: entry.decimalPlace,
+                useThousandSeparator: Boolean(entry.permil)
+            }) : null;
+        }
+        
         transformedEntry[`${computeDate}_percent`] = entry.percent != null ? `${((entry.percent * 100).toFixed(2))}%` : null;
         return transformedEntry;
     };
@@ -172,7 +184,7 @@ const transformData = (data: any[]) => {
         nodes.forEach((node) => {
             computeDates.forEach((date) => {
                 if (!node.hasOwnProperty(`${date}_amount`)) {
-                    node[`${date}_amount`] = node.amount != null ? formatMoneyNumber(node.amount) : null;
+                    node[`${date}_amount`] = node.amount != null ? formatMoneyNumber(node.amount,{decimalPlaces:node.decimalPlace,useThousandSeparator:Boolean(node.permil)}) : null;
                 }
                 if (!node.hasOwnProperty(`${date}_percent`)) {
                     node[`${date}_percent`] = node.percent != null ? `${((node.percent * 100).toFixed(2))}%` : null;
@@ -369,6 +381,9 @@ export default function DepartmentCostCalc() {
                     data: realData,
                     success: true,
                 }
+            }else{
+                generateDataColumns([])
+                set_dataSource([]);
             }
         }
 
@@ -393,7 +408,7 @@ export default function DepartmentCostCalc() {
                         key: 'amount',
                         align: 'right',
                         renderText(num: number, record: any) {
-                            return formatMoneyNumber(num)
+                            return formatMoneyNumber(num,{decimalPlaces:record.decimalPlace,useThousandSeparator:Boolean(record.permil)})
                         }
                     }
                 ])
@@ -403,7 +418,7 @@ export default function DepartmentCostCalc() {
                     reportType: currentTabKey,
                     responsibilityCode: currentSelectedRespon.responsibilityCode
                 });
-
+                
                 return {
                     data: resp ? resp : [],
                     success: true,
@@ -504,10 +519,10 @@ export default function DepartmentCostCalc() {
                                     projectName: paramIndex === 0 ? dataItem.alias : '',
                                     projectNameRowSpan: paramIndex === 0 ? dataItemRowSpan : 0,
                                     shareParam: param.shareParamName,
-                                    shareAmount: formatMoneyNumber(param.shareParamAmount),
+                                    shareAmount: formatMoneyNumber(param.shareParamAmount,{decimalPlaces:param.decimalPlace,useThousandSeparator:Boolean(param.permil)}),
                                     shareParamValue: param.shareParamNum,
                                     shareParamRate: param.shareParamRate,
-                                    amount: formatMoneyNumber(param.shareParamValue),
+                                    amount: formatMoneyNumber(param.shareParamValue,{decimalPlaces:param.decimalPlace,useThousandSeparator:Boolean(param.permil)}),
                                 });
                             });
                             currentRow++;

+ 90 - 56
src/pages/departmentMenzhuCostCalc/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-12-06 17:06:53
+ * @LastEditTime: 2025-05-13 11:28:30
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -144,29 +144,7 @@ function searchTree(tree: any[], searchTerm: string) {
     return results;
 }
 
-function processTree(originalData: any[]) {
-    return originalData.map(node => {
-        // 深复制当前节点
-        const newNode = JSON.parse(JSON.stringify(node));
 
-        // 如果当前节点有profitList,处理它
-        if (newNode.profitList && Array.isArray(newNode.profitList)) {
-            newNode.profitList.forEach((profit: any) => {
-                // 添加新的键值对到新节点
-                newNode[`${profit.reportId}`] = formatMoneyNumber(profit.value);
-            });
-            // 如果不需要保留profitList,可以删除
-            // delete newNode.profitList;
-        }
-
-        // 如果节点有子节点,递归处理子节点
-        if (node.child && Array.isArray(node.child)) {
-            newNode.children = processTree(node.child);
-        }
-
-        return newNode;
-    });
-}
 
 // 递归函数,用于处理多层级标题
 function generateColumns(item: any, titleIndex = 0) {
@@ -201,10 +179,14 @@ const transformData = (data: any[]) => {
     // 转换单个条目
     const transformEntry = (entry: any, type: string) => {
         if (!entry) return {};
-        const transformedEntry = { ...entry };
-        transformedEntry[`${type}_currentAmount`] = entry.currentAmount != null ? formatMoneyNumber(entry.currentAmount) : null;
-        transformedEntry[`${type}_preMonthAmount`] = entry.preMonthAmount != null ? formatMoneyNumber(entry.preMonthAmount) : null;
-        transformedEntry[`${type}_preYearAmount`] = entry.preYearAmount != null ? formatMoneyNumber(entry.preYearAmount) : null;
+        const transformedEntry = { ...entry }; // 完整复制 entry 以包含 decimalPlace 和 permil
+        const formatOptions = {
+            decimalPlaces: entry.decimalPlace, // 使用 entry 中的 decimalPlace
+            useThousandSeparator: entry.permil, // 使用 entry 中的 permil
+        };
+        transformedEntry[`${type}_currentAmount`] = entry.currentAmount != null ? formatMoneyNumber(entry.currentAmount, formatOptions) : null;
+        transformedEntry[`${type}_preMonthAmount`] = entry.preMonthAmount != null ? formatMoneyNumber(entry.preMonthAmount, formatOptions) : null;
+        transformedEntry[`${type}_preYearAmount`] = entry.preYearAmount != null ? formatMoneyNumber(entry.preYearAmount, formatOptions) : null;
         transformedEntry[`${type}_preMonthPercent`] = entry.preMonthPercent != null ? entry.preMonthPercent : null;
         transformedEntry[`${type}_preYearPercent`] = entry.preYearPercent != null ? entry.preYearPercent : null;
         return transformedEntry;
@@ -282,14 +264,18 @@ const transformData = (data: any[]) => {
     const fillMissingMonths = (nodes: any[], medicalTypes: string[]) => {
         nodes.forEach((node) => {
             medicalTypes.forEach((type) => {
+                const formatOptions = {
+                    decimalPlaces: node.decimalPlace, // 使用 node 中的 decimalPlace
+                    useThousandSeparator: node.permil, // 使用 node 中的 permil
+                };
                 if (!node.hasOwnProperty(`${type}_currentAmount`)) {
-                    node[`${type}_currentAmount`] = node.currentAmount != null ? formatMoneyNumber(node.currentAmount) : null;
+                    node[`${type}_currentAmount`] = node.currentAmount != null ? formatMoneyNumber(node.currentAmount, formatOptions) : null;
                 }
                 if (!node.hasOwnProperty(`${type}_preMonthAmount`)) {
-                    node[`${type}_preMonthAmount`] = node.preMonthAmount != null ? formatMoneyNumber(node.preMonthAmount) : null;
+                    node[`${type}_preMonthAmount`] = node.preMonthAmount != null ? formatMoneyNumber(node.preMonthAmount, formatOptions) : null;
                 }
                 if (!node.hasOwnProperty(`${type}_preYearAmount`)) {
-                    node[`${type}_preYearAmount`] = node.preYearAmount != null ? formatMoneyNumber(node.preYearAmount) : null;
+                    node[`${type}_preYearAmount`] = node.preYearAmount != null ? formatMoneyNumber(node.preYearAmount, formatOptions) : null;
                 }
 
                 if (!node.hasOwnProperty(`${type}_preMonthPercent`)) {
@@ -394,12 +380,29 @@ export default function DepartmentCostCalc() {
                     children: [
                         {
                             title: '本期',
-                            dataIndex: `${data.medicalType}_currentAmount`, // This is used for the main title
+                            dataIndex: `${data.medicalType}_currentAmount`,
                             key: `${data.medicalType}_currentAmount`,
                             align:'right',
-                            render: (num: number, record: { calcType: any; }) => {
-                                const { calcType } = record;
-                                return calcType === 0 ? <React.Fragment></React.Fragment> : formatMoneyNumber(num);
+                            render: (num: number, record: { calcType: any; decimalPlace?: number; permil?: boolean; dataType?: number; }) => {
+                                const { calcType, decimalPlace, permil, dataType } = record;
+                                if (calcType === 0) return <React.Fragment></React.Fragment>;
+                                
+                                const formatOptions = {
+                                    decimalPlaces: decimalPlace !== undefined ? decimalPlace : 2,
+                                    useThousandSeparator: permil !== undefined ? permil : true,
+                                };
+                                
+                                if (dataType === 2) {
+                                    if (typeof num === 'string') {
+                                        if (num === '-' || num === '') {
+                                            return num;
+                                        }
+                                    } else if (num === null || num === undefined) {
+                                        return num;
+                                    }
+                                    return `${formatMoneyNumber(num, formatOptions)}%`;
+                                }
+                                return formatMoneyNumber(num, formatOptions);
                             },
                         },
                         {
@@ -407,9 +410,26 @@ export default function DepartmentCostCalc() {
                             align:'right',
                             dataIndex: `${data.medicalType}_preMonthAmount`,
                             key: `${data.medicalType}_preMonthAmount`,
-                            render: (num: number, record: { calcType: any; }) => {
-                                const { calcType } = record;
-                                return calcType === 0 ? <React.Fragment></React.Fragment> : formatMoneyNumber(num);
+                            render: (num: number, record: { calcType: any; decimalPlace?: number; permil?: boolean; dataType?: number; }) => {
+                                const { calcType, decimalPlace, permil, dataType } = record;
+                                if (calcType === 0) return <React.Fragment></React.Fragment>;
+                                
+                                const formatOptions = {
+                                    decimalPlaces: decimalPlace !== undefined ? decimalPlace : 2,
+                                    useThousandSeparator: permil !== undefined ? permil : true,
+                                };
+                                
+                                if (dataType === 2) {
+                                    if (typeof num === 'string') {
+                                        if (num === '-' || num === '') {
+                                            return num;
+                                        }
+                                    } else if (num === null || num === undefined) {
+                                        return num;
+                                    }
+                                    return `${formatMoneyNumber(num, formatOptions)}%`;
+                                }
+                                return formatMoneyNumber(num, formatOptions);
                             },
                         },
                         {
@@ -418,14 +438,13 @@ export default function DepartmentCostCalc() {
                             dataIndex: `${data.medicalType}_preMonthPercent`,
                             key: `${data.medicalType}_preMonthPercent`,
                             renderText(text: string, record: any) {
-
                                 const { calcType } = record;
-                                if (calcType == 0) {
-                                    return <React.Fragment></React.Fragment>
-                                } else {
-                                    const isNegative = text?text.startsWith('-') && text.includes('%'):false;
-                                    return isNegative?<span style={{color:'#00BF8F'}}>{text}</span>:text
-                              }
+                                if (calcType === 0) return <React.Fragment></React.Fragment>;
+                                
+                                if (!text) return null;
+                                
+                                const isNegative = text.startsWith('-') && text.includes('%');
+                                return isNegative ? <span style={{color:'#00BF8F'}}>{text}</span> : text;
                             },
                         },
                         {
@@ -433,9 +452,26 @@ export default function DepartmentCostCalc() {
                             align:'right',
                             dataIndex: `${data.medicalType}_preYearAmount`,
                             key: `${data.medicalType}_preYearAmount`,
-                            render: (num: number, record: { calcType: any; }) => {
-                                const { calcType } = record;
-                                return calcType === 0 ? <React.Fragment></React.Fragment> : formatMoneyNumber(num);
+                            render: (num: number, record: { calcType: any; decimalPlace?: number; permil?: boolean; dataType?: number; }) => {
+                                const { calcType, decimalPlace, permil, dataType } = record;
+                                if (calcType === 0) return <React.Fragment></React.Fragment>;
+                                
+                                const formatOptions = {
+                                    decimalPlaces: decimalPlace !== undefined ? decimalPlace : 2,
+                                    useThousandSeparator: permil !== undefined ? permil : true,
+                                };
+                                
+                                if (dataType === 2) {
+                                    if (typeof num === 'string') {
+                                        if (num === '-' || num === '') {
+                                            return num;
+                                        }
+                                    } else if (num === null || num === undefined) {
+                                        return num;
+                                    }
+                                    return `${formatMoneyNumber(num, formatOptions)}%`;
+                                }
+                                return formatMoneyNumber(num, formatOptions);
                             },
                         },
                         {
@@ -444,15 +480,13 @@ export default function DepartmentCostCalc() {
                             dataIndex: `${data.medicalType}_preYearPercent`,
                             key: `${data.medicalType}_preYearPercent`,
                             renderText(text: string, record: any) {
-
                                 const { calcType } = record;
-                                if (calcType == 0) {
-                                    return <React.Fragment></React.Fragment>
-                                } else {
-                                    const isNegative = text?text.startsWith('-') && text.includes('%'):false;
-                                    return isNegative?<span style={{color:'#00BF8F'}}>{text}</span>:text
-                                }
-
+                                if (calcType === 0) return <React.Fragment></React.Fragment>;
+                                
+                                if (!text) return null;
+                                
+                                const isNegative = text.startsWith('-') && text.includes('%');
+                                return isNegative ? <span style={{color:'#00BF8F'}}>{text}</span> : text;
                             },
                         }
                     ]
@@ -930,7 +964,7 @@ export default function DepartmentCostCalc() {
     useEffect(() => {
 
         if (currentSelectedRespon) {
-
+            console.log({currentSelectedRespon});
             set_tableDataFilterParams({
                 ...tableDataFilterParams,
                 responsibilityCode: currentSelectedRespon.responsibilityCode,

+ 12 - 12
src/pages/reportExport/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: 2024-11-15 14:31:22
+ * @LastEditTime: 2025-02-27 17:09:22
  * @FilePath: /BudgetManaSystem/src/pages/budgetMana/oneBatch/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -171,7 +171,7 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
     if (!openProcessModal) {
       set_loading(true);
     }
-  
+
 
     if (!params.reportCode || (JSON.stringify(prevParams) === JSON.stringify(params))) {
       // 参数相同,不执行请求
@@ -255,7 +255,7 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
                 return <Dropdown menu={{ items }}>
                   <a onClick={(e) => e.preventDefault()}>
                     <Space>
-                      {(item.dataType && item.dataType == 3 && _) && formatMoneyNumber(Number(Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2)))}
+                      {((item.dataType && item.dataType == 3 && _) && item.permil) ? formatMoneyNumber(Number(Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2))) :(item.dataType && item.dataType == 3 && _) && Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2)}
                       {(item.dataType && item.dataType == 2 && _ && typeof _ == 'number') && `${(_ * 100).toFixed(item.decimalPlace ? item.decimalPlace : 2)}%`}
                       {(item.dataType != 2 && item.dataType != 3) && _}
                       <DownOutlined />
@@ -264,17 +264,17 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
                 </Dropdown>
               } else {
                 return <a className='active' onClick={() => reportJumphandle({ ...item.redirectData[0], ...record })}>
-                  {(item.dataType && item.dataType == 3 && _) && formatMoneyNumber(Number(Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2)))}
+                  {((item.dataType && item.dataType == 3 && _) && item.permil) ? formatMoneyNumber(Number(Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2))) : (item.dataType && item.dataType == 3 && _) && Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2)}
                   {(item.dataType && item.dataType == 2 && _ && typeof _ == 'number') && `${(_ * 100).toFixed(item.decimalPlace ? item.decimalPlace : 2)}%`}
                   {(item.dataType != 2 && item.dataType != 3) && _}
                 </a>
               }
-            }
-
+            }            
             return <span >
-              {(item.dataType && item.dataType == 3 && _) && formatMoneyNumber(Number(Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2)))}
+              {((item.dataType && item.dataType == 3 && _)) && item.permil?formatMoneyNumber(Number(Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2))):(item.dataType && item.dataType == 3)&&Number(_).toFixed(item.decimalPlace ? item.decimalPlace : 2)}
               {(item.dataType && item.dataType == 2 && _ && typeof _ == 'number') && `${(_ * 100).toFixed(item.decimalPlace ? item.decimalPlace : 2)}%`}
-              {(item.dataType != 2 && item.dataType != 3) && _}
+              {(item.dataType != 2 && item.dataType != 3)?_:''}
+              
             </span>
           }
 
@@ -296,7 +296,7 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
         });
 
 
-        return { ...item, ...rowData, id: Math.random(), columns }
+        return { id: Math.random(),...item, ...rowData, columns }
       });
 
       const exportdata = assignmentData.map((item: any) => {
@@ -461,7 +461,7 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
         return acc;
       }, {});
 
-      set_tableDataFilterParams({ ...tableDataFilterParams, parameter: { ...( tableDataFilterParams.parameter), ...searchObject } });
+      set_tableDataFilterParams({ ...tableDataFilterParams, parameter: { ...(tableDataFilterParams.parameter), ...searchObject } });
 
       return newObj
     }
@@ -524,7 +524,7 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
         acc[curr.columnIndex] = '';
         return acc;
       }, {});
-      set_tableDataFilterParams({ ...tableDataFilterParams, parameter: { ...(reportCode ? tableDataFilterParams?.parameter : {}), compute_date: currentComputeDate,...searchObject } });
+      set_tableDataFilterParams({ ...tableDataFilterParams, parameter: { ...(reportCode ? tableDataFilterParams?.parameter : {}), compute_date: currentComputeDate, ...searchObject } });
     }
   }, [currentComputeDate]);
 
@@ -578,7 +578,7 @@ const ReportExport = ({ reportCode, propsParams, tableScrollH }: { reportCode: s
           {(currentComputeDate && !reportCode) && (<div className='search'>
             <span>核算年月:</span>
             <DatePicker
-              disabled={breadCrumbList.length>1}
+              disabled={breadCrumbList.length > 1}
               onChange={(data, dateString) => {
                 set_currentComputeDate(dateString);
                 setInitialState((s: any) => ({ ...s, computeDate: dateString }))

+ 26 - 7
src/utils/format.ts

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-12-14 14:14:32
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-09-06 15:31:56
+ * @LastEditTime: 2025-04-30 14:52:04
  * @FilePath: /BudgetManaSystem/src/utils/format.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -11,15 +11,34 @@ export function trim(str: string) {
   return str.trim();
 }
 
+// 定义金额格式化选项的接口
+interface FormatMoneyOptions {
+  decimalPlaces?: number;       // 指定小数位数
+  useThousandSeparator?: boolean; // 是否使用千分号
+}
+
 //金额数字转换
-export function formatMoneyNumber(num: number) {
-  if (typeof num !== 'number' || isNaN(num)) {
-    return num;
+export function formatMoneyNumber(num: number | string | undefined | null, options?: FormatMoneyOptions) {
+  if (num === undefined || num === null || num === '') {
+    return '-'; // 对于空值或未定义值,返回 "-"
+  }
+
+  const numberToFormat = Number(num);
+  if (isNaN(numberToFormat)) {
+    return String(num); // 如果转换后不是有效数字,则返回原始字符串形式
   }
+
+  // 默认小数位数为2,除非在选项中指定
+  const minimumFractionDigits = options?.decimalPlaces !== undefined ? options.decimalPlaces : 2;
+  const maximumFractionDigits = options?.decimalPlaces !== undefined ? options.decimalPlaces : 2;
+  // 默认使用千分号,除非在选项中明确设置为 false
+  const useGrouping = options?.useThousandSeparator === true;
+
   return new Intl.NumberFormat('en-US', {
-    minimumFractionDigits: 2,
-    maximumFractionDigits: 2,
-  }).format(num);
+    minimumFractionDigits: minimumFractionDigits,
+    maximumFractionDigits: maximumFractionDigits,
+    useGrouping: useGrouping, // 控制是否使用千分号
+  }).format(numberToFormat);
 }
 
 

+ 1 - 0
src/utils/tableToMultiHeaderExcel.ts

@@ -19,6 +19,7 @@ type Merge = {
 };
 
 
+
 function getMaxDepth(columns: Column[]): number {
     let maxDepth = 0;
     for (const column of columns) {