|
@@ -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,
|