2025-12-16 12:33:02 +08:00
|
|
|
// 案件类型映射表
|
|
|
|
|
export const lawsuitTypeMap = {
|
2026-01-04 17:59:28 +08:00
|
|
|
sxbzxr: {
|
|
|
|
|
text: "失信被执行",
|
|
|
|
|
color: "text-red-600 bg-red-50",
|
|
|
|
|
darkColor: "bg-red-500",
|
|
|
|
|
riskLevel: "high", // 高风险
|
|
|
|
|
},
|
|
|
|
|
xgbzxr: {
|
|
|
|
|
text: "限高被执行",
|
|
|
|
|
color: "text-orange-600 bg-orange-50",
|
|
|
|
|
darkColor: "bg-orange-500",
|
|
|
|
|
riskLevel: "high", // 高风险
|
|
|
|
|
},
|
|
|
|
|
criminal: {
|
|
|
|
|
text: "刑事案件",
|
|
|
|
|
color: "text-red-600 bg-red-50",
|
|
|
|
|
darkColor: "bg-red-500",
|
|
|
|
|
riskLevel: "high", // 高风险
|
|
|
|
|
},
|
|
|
|
|
civil: {
|
|
|
|
|
text: "民事案件",
|
|
|
|
|
color: "text-blue-600 bg-blue-50",
|
|
|
|
|
darkColor: "bg-blue-500",
|
|
|
|
|
riskLevel: "medium", // 中风险
|
|
|
|
|
},
|
|
|
|
|
administrative: {
|
|
|
|
|
text: "行政案件",
|
|
|
|
|
color: "text-purple-600 bg-purple-50",
|
|
|
|
|
darkColor: "bg-purple-500",
|
|
|
|
|
riskLevel: "medium", // 中风险
|
|
|
|
|
},
|
|
|
|
|
implement: {
|
|
|
|
|
text: "执行案件",
|
|
|
|
|
color: "text-orange-600 bg-orange-50",
|
|
|
|
|
darkColor: "bg-orange-500",
|
|
|
|
|
riskLevel: "medium", // 中风险
|
|
|
|
|
},
|
|
|
|
|
bankrupt: {
|
|
|
|
|
text: "强制清算与破产案件",
|
|
|
|
|
color: "text-rose-600 bg-rose-50",
|
|
|
|
|
darkColor: "bg-rose-500",
|
|
|
|
|
riskLevel: "high", // 高风险
|
|
|
|
|
},
|
|
|
|
|
preservation: {
|
|
|
|
|
text: "非诉保全审查",
|
|
|
|
|
color: "text-amber-600 bg-amber-50",
|
|
|
|
|
darkColor: "bg-amber-500",
|
|
|
|
|
riskLevel: "low", // 低风险
|
|
|
|
|
},
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 案件类型文本
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getCaseTypeText = (type) => {
|
|
|
|
|
return lawsuitTypeMap[type]?.text || "其他案件";
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 案件类型颜色
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getCaseTypeColor = (type) => {
|
|
|
|
|
return lawsuitTypeMap[type]?.color || "text-gray-600 bg-gray-50";
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 案件类型深色
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getCaseTypeDarkColor = (type) => {
|
|
|
|
|
return lawsuitTypeMap[type]?.darkColor || "bg-gray-500";
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 格式化日期显示
|
2026-01-04 17:59:28 +08:00
|
|
|
export const formatDate = (dateStr) => {
|
|
|
|
|
if (!dateStr) return "—";
|
|
|
|
|
// 转换YYYY-MM-DD为年月日格式
|
|
|
|
|
if (dateStr.includes("-")) {
|
|
|
|
|
const parts = dateStr.split("-");
|
|
|
|
|
if (parts.length === 3) {
|
|
|
|
|
return `${parts[0]}年${parts[1]}月${parts[2]}日`;
|
|
|
|
|
}
|
2025-12-16 12:33:02 +08:00
|
|
|
}
|
2026-01-04 17:59:28 +08:00
|
|
|
return dateStr; // 如果不是标准格式则返回原始字符串
|
|
|
|
|
};
|
|
|
|
|
// 格式化金额显示(单位:元)
|
|
|
|
|
export const formatLawsuitMoney = (money) => {
|
|
|
|
|
if (!money) return "—";
|
2025-12-16 12:33:02 +08:00
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
const value = parseFloat(money);
|
|
|
|
|
if (isNaN(value)) return "—";
|
2025-12-16 12:33:02 +08:00
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
// 直接显示原始金额(元)
|
2025-12-16 12:33:02 +08:00
|
|
|
return (
|
2026-01-04 17:59:28 +08:00
|
|
|
value.toLocaleString("zh-CN", {
|
|
|
|
|
minimumFractionDigits: 0,
|
|
|
|
|
maximumFractionDigits: 2,
|
|
|
|
|
}) + " 元"
|
|
|
|
|
);
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
// 获取案件状态样式
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getCaseStatusClass = (status) => {
|
|
|
|
|
if (!status) return "bg-gray-100 text-gray-500";
|
|
|
|
|
|
|
|
|
|
if (status.includes("已结") || status.includes("已办结")) {
|
|
|
|
|
return "bg-green-50 text-green-600";
|
|
|
|
|
} else if (status.includes("执行中") || status.includes("审理中")) {
|
|
|
|
|
return "bg-blue-50 text-blue-600";
|
|
|
|
|
} else if (status.includes("未执行")) {
|
|
|
|
|
return "bg-amber-50 text-amber-600";
|
|
|
|
|
} else {
|
|
|
|
|
return "bg-gray-100 text-gray-500";
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 获取企业状态对应的样式
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getStatusClass = (status) => {
|
|
|
|
|
if (!status) return "bg-gray-100 text-gray-500";
|
|
|
|
|
|
|
|
|
|
if (status.includes("注销") || status.includes("吊销")) {
|
|
|
|
|
return "bg-red-50 text-red-600";
|
|
|
|
|
} else if (status.includes("存续") || status.includes("在营")) {
|
|
|
|
|
return "bg-green-50 text-green-600";
|
|
|
|
|
} else if (status.includes("筹建") || status.includes("新设")) {
|
|
|
|
|
return "bg-blue-50 text-blue-600";
|
|
|
|
|
} else {
|
|
|
|
|
return "bg-yellow-50 text-yellow-600";
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 格式化资本金额显示
|
|
|
|
|
export const formatCapital = (capital, currency) => {
|
2026-01-04 17:59:28 +08:00
|
|
|
if (!capital) return "—";
|
|
|
|
|
|
|
|
|
|
// 检查是否包含"万"字或需要显示为万元
|
|
|
|
|
let unit = "";
|
|
|
|
|
let value = parseFloat(capital);
|
|
|
|
|
|
|
|
|
|
// 处理原始数据中可能带有的单位
|
|
|
|
|
if (typeof capital === "string" && capital.includes("万")) {
|
|
|
|
|
unit = "万";
|
|
|
|
|
// 提取数字部分
|
|
|
|
|
const numMatch = capital.match(/[\d.]+/);
|
|
|
|
|
value = numMatch ? parseFloat(numMatch[0]) : 0;
|
|
|
|
|
} else if (value >= 10000) {
|
|
|
|
|
// 大额数字转换为万元显示
|
|
|
|
|
value = value / 10000;
|
|
|
|
|
unit = "万";
|
|
|
|
|
}
|
2025-12-16 12:33:02 +08:00
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
// 格式化数字,保留两位小数(如果有小数部分)
|
|
|
|
|
const formattedValue = value.toLocaleString("zh-CN", {
|
|
|
|
|
minimumFractionDigits: 0,
|
|
|
|
|
maximumFractionDigits: 2,
|
|
|
|
|
});
|
2025-12-16 12:33:02 +08:00
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
return `${formattedValue}${unit} ${currency || "人民币"}`;
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 获取涉诉风险等级
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getRiskLevel = (lawsuitInfo) => {
|
|
|
|
|
if (!lawsuitInfo) {
|
|
|
|
|
return {
|
|
|
|
|
level: "low",
|
|
|
|
|
text: "低风险",
|
|
|
|
|
color: "text-green-600 bg-green-50",
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
// 失信被执行人是最高风险
|
|
|
|
|
if (lawsuitInfo.sxbzxr && lawsuitInfo.sxbzxr.length > 0) {
|
|
|
|
|
return {
|
|
|
|
|
level: "high",
|
|
|
|
|
text: "高风险",
|
|
|
|
|
color: "text-red-600 bg-red-50",
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
// 限高被执行人是最高风险
|
|
|
|
|
if (lawsuitInfo.xgbzxr && lawsuitInfo.xgbzxr.length > 0) {
|
|
|
|
|
return {
|
|
|
|
|
level: "high",
|
|
|
|
|
text: "高风险",
|
|
|
|
|
color: "text-red-600 bg-red-50",
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
// 有涉诉数据的风险级别
|
|
|
|
|
if (lawsuitInfo.data && Object.keys(lawsuitInfo.data).length > 0) {
|
|
|
|
|
// 检查是否有未结案的案件
|
|
|
|
|
const data = lawsuitInfo.data;
|
|
|
|
|
if (data.count && data.count_wei_total && data.count_wei_total > 0) {
|
|
|
|
|
return {
|
|
|
|
|
level: "medium",
|
|
|
|
|
text: "中风险",
|
|
|
|
|
color: "text-amber-600 bg-amber-50",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 只有已结案的为低中风险
|
|
|
|
|
return {
|
|
|
|
|
level: "low-medium",
|
|
|
|
|
text: "低中风险",
|
|
|
|
|
color: "text-yellow-600 bg-yellow-50",
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
2026-01-04 17:59:28 +08:00
|
|
|
level: "low",
|
|
|
|
|
text: "低风险",
|
|
|
|
|
color: "text-green-600 bg-green-50",
|
|
|
|
|
};
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 获取涉诉案件统计
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getLawsuitStats = (lawsuitInfo) => {
|
|
|
|
|
if (!lawsuitInfo) return null;
|
|
|
|
|
|
|
|
|
|
const stats = {
|
|
|
|
|
total: 0,
|
|
|
|
|
types: [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 统计各类型案件数量
|
|
|
|
|
Object.keys(lawsuitTypeMap).forEach((type) => {
|
|
|
|
|
let count = 0;
|
|
|
|
|
|
|
|
|
|
if (type === "sxbzxr") {
|
|
|
|
|
count =
|
|
|
|
|
lawsuitInfo.sxbzxr && lawsuitInfo.sxbzxr.length > 0
|
|
|
|
|
? lawsuitInfo.sxbzxr.length
|
|
|
|
|
: 0;
|
|
|
|
|
} else if (type === "xgbzxr") {
|
|
|
|
|
count =
|
|
|
|
|
lawsuitInfo.xgbzxr && lawsuitInfo.xgbzxr.length > 0
|
|
|
|
|
? lawsuitInfo.xgbzxr.length
|
|
|
|
|
: 0;
|
|
|
|
|
} else if (
|
|
|
|
|
lawsuitInfo.data &&
|
|
|
|
|
lawsuitInfo.data[type] &&
|
|
|
|
|
Object.keys(lawsuitInfo.data[type]).length > 0
|
|
|
|
|
) {
|
|
|
|
|
const typeData = lawsuitInfo.data[type];
|
|
|
|
|
count =
|
|
|
|
|
typeData.cases && typeData.cases.length
|
|
|
|
|
? typeData.cases.length
|
|
|
|
|
: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
stats.total += count;
|
|
|
|
|
stats.types.push({
|
|
|
|
|
type,
|
|
|
|
|
count,
|
|
|
|
|
name: getCaseTypeText(type),
|
|
|
|
|
color: getCaseTypeColor(type),
|
|
|
|
|
darkColor: getCaseTypeDarkColor(type),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return stats;
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 获取案件类型优先级顺序
|
|
|
|
|
export const getCaseTypePriority = () => {
|
2026-01-04 17:59:28 +08:00
|
|
|
return [
|
|
|
|
|
"sxbzxr", // 失信被执行人(最高风险)
|
|
|
|
|
"xgbzxr", // 限高被执行人
|
|
|
|
|
"criminal", // 刑事案件
|
|
|
|
|
"civil", // 民事案件
|
|
|
|
|
"administrative", // 行政案件
|
|
|
|
|
"implement", // 执行案件
|
|
|
|
|
"bankrupt", // 强制清算与破产案件
|
|
|
|
|
"preservation", // 非诉保全审查
|
|
|
|
|
];
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
|
|
|
|
// 根据案件类型获取风险等级
|
2026-01-04 17:59:28 +08:00
|
|
|
export const getCaseTypeRiskLevel = (caseType) => {
|
|
|
|
|
const typeInfo = lawsuitTypeMap[caseType];
|
|
|
|
|
if (!typeInfo) {
|
|
|
|
|
return {
|
|
|
|
|
level: "low",
|
|
|
|
|
text: "低风险",
|
|
|
|
|
color: "text-green-600 bg-green-50",
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
const riskLevelMap = {
|
|
|
|
|
high: {
|
|
|
|
|
text: "高风险",
|
|
|
|
|
color: "text-red-600 bg-red-50",
|
|
|
|
|
},
|
|
|
|
|
medium: {
|
|
|
|
|
text: "中风险",
|
|
|
|
|
color: "text-amber-600 bg-amber-50",
|
|
|
|
|
},
|
|
|
|
|
low: {
|
|
|
|
|
text: "低风险",
|
|
|
|
|
color: "text-green-600 bg-green-50",
|
|
|
|
|
},
|
|
|
|
|
};
|
2025-12-16 12:33:02 +08:00
|
|
|
|
2026-01-04 17:59:28 +08:00
|
|
|
return {
|
|
|
|
|
level: typeInfo.riskLevel,
|
|
|
|
|
...riskLevelMap[typeInfo.riskLevel],
|
|
|
|
|
};
|
|
|
|
|
};
|