Files
tyc-uniapp_V2/src/report-ui/split/splitDWBG6A2C.js
2026-05-21 14:51:06 +08:00

312 lines
8.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 司南报告(DWBG6A2C)数据拆分工具
* 将完整的司南报告数据拆分成多个独立的模块用于在不同的tab中显示
*/
/**
* 将DWBG6A2C数据拆分为多个独立的tab模块
* @param {Array} reportData - 原始报告数据数组
* @returns {Array} 拆分后的模块数组
*/
export function splitDWBG6A2CForTabs(reportData) {
// 查找DWBG6A2C数据
const dwbg6a2cData = reportData.find(item => item.data?.apiID === 'DWBG6A2C');
if (!dwbg6a2cData || !dwbg6a2cData.data?.data) {
return reportData; // 如果没有找到DWBG6A2C数据返回原数据
}
const originalData = dwbg6a2cData.data.data;
const baseTimestamp = dwbg6a2cData.data.timestamp;
// 创建拆分后的模块数组
const splitModules = [];
// 1. 基本信息
// if (originalData.baseInfo) {
// splitModules.push({
// data: {
// apiID: 'DWBG6A2C_BaseInfo',
// data: {
// baseInfo: originalData.baseInfo
// },
// success: true,
// timestamp: baseTimestamp
// }
// });
// }
// 2. 身份信息核验
if (originalData.standLiveInfo) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_StandLiveInfo',
data: {
standLiveInfo: originalData.standLiveInfo
},
success: true,
timestamp: baseTimestamp
}
});
}
// 3. 命中风险标注
if (originalData.riskPoint) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_RiskPoint',
data: {
riskPoint: originalData.riskPoint
},
success: true,
timestamp: baseTimestamp
}
});
}
// 4. 公安重点人员核验
if (originalData.securityInfo) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_SecurityInfo',
data: {
securityInfo: originalData.securityInfo
},
success: true,
timestamp: baseTimestamp
}
});
}
// 5. 涉赌涉诈人员核验
if (originalData.antiFraudInfo) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_AntiFraudInfo',
data: {
antiFraudInfo: originalData.antiFraudInfo
},
success: true,
timestamp: baseTimestamp
}
});
}
// 6. 风险名单
if (originalData.riskList) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_RiskList',
data: {
riskList: originalData.riskList
},
success: true,
timestamp: baseTimestamp
}
});
}
// 7. 历史借贷行为
if (originalData.applicationStatistics) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_ApplicationStatistics',
data: {
applicationStatistics: originalData.applicationStatistics
},
success: true,
timestamp: baseTimestamp
}
});
}
// 8. 近24个月放款情况
if (originalData.lendingStatistics) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_LendingStatistics',
data: {
lendingStatistics: originalData.lendingStatistics
},
success: true,
timestamp: baseTimestamp
}
});
}
// 9. 履约情况
if (originalData.performanceStatistics) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_PerformanceStatistics',
data: {
performanceStatistics: originalData.performanceStatistics
},
success: true,
timestamp: baseTimestamp
}
});
}
// 10. 历史逾期记录
if (originalData.overdueRecord) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_OverdueRecord',
data: {
overdueRecord: originalData.overdueRecord
},
success: true,
timestamp: baseTimestamp
}
});
}
// 11. 授信详情
if (originalData.creditDetail && Object.keys(originalData.creditDetail).length > 0) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_CreditDetail',
data: {
creditDetail: originalData.creditDetail
},
success: true,
timestamp: baseTimestamp
}
});
}
// 12. 租赁行为
if (originalData.rentalBehavior) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_RentalBehavior',
data: {
rentalBehavior: originalData.rentalBehavior
},
success: true,
timestamp: baseTimestamp
}
});
}
// 13. 关联风险监督
if (originalData.riskSupervision) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_RiskSupervision',
data: {
riskSupervision: originalData.riskSupervision
},
success: true,
timestamp: baseTimestamp
}
});
}
// 14. 法院风险信息
if (originalData.judiciaRiskInfos && originalData.judiciaRiskInfos.length > 0) {
splitModules.push({
data: {
apiID: 'DWBG6A2C_CourtRiskInfo',
data: {
judiciaRiskInfos: originalData.judiciaRiskInfos
},
success: true,
timestamp: baseTimestamp
}
});
}
// 移除原始的DWBG6A2C数据添加拆分后的模块
const otherData = reportData.filter(item => item.data?.apiID !== 'DWBG6A2C');
return [...otherData, ...splitModules];
}
/**
* 格式化风险等级描述
* @param {string} level - 风险等级
* @returns {object} 包含颜色和文本的对象
*/
export function formatRiskLevel(level) {
const riskLevels = {
'0': { color: 'text-green-600', bg: 'bg-green-100', text: '无风险', icon: '✅' },
'1': { color: 'text-red-600', bg: 'bg-red-100', text: '有风险', icon: '⚠️' },
'A': { color: 'text-yellow-600', bg: 'bg-yellow-100', text: '较低风险', icon: '⚠️' },
'B': { color: 'text-orange-600', bg: 'bg-orange-100', text: '低风险', icon: '⚠️' },
'C': { color: 'text-red-600', bg: 'bg-red-100', text: '中风险', icon: '🚨' },
'D': { color: 'text-red-700', bg: 'bg-red-200', text: '高风险', icon: '🚨' }
};
return riskLevels[level] || { color: 'text-gray-600', bg: 'bg-gray-100', text: '未知', icon: '❓' };
}
/**
* 格式化手机号码状态
* @param {number} status - 状态码
* @returns {object} 包含颜色和文本的对象
*/
export function formatPhoneStatus(status) {
const statusMap = {
'-1': { color: 'text-gray-600', bg: 'bg-gray-100', text: '未查得', icon: '❓' },
'0': { color: 'text-red-600', bg: 'bg-red-100', text: '空号', icon: '❌' },
'1': { color: 'text-green-600', bg: 'bg-green-100', text: '实号', icon: '✅' },
'2': { color: 'text-orange-600', bg: 'bg-orange-100', text: '停机', icon: '⏸️' },
'3': { color: 'text-gray-600', bg: 'bg-gray-100', text: '库无', icon: '❓' },
'4': { color: 'text-yellow-600', bg: 'bg-yellow-100', text: '沉默号', icon: '😴' },
'5': { color: 'text-red-600', bg: 'bg-red-100', text: '风险号', icon: '⚠️' }
};
return statusMap[status.toString()] || { color: 'text-gray-600', bg: 'bg-gray-100', text: '未知', icon: '❓' };
}
/**
* 格式化身份核验结果
* @param {string} result - 核验结果
* @returns {object} 包含颜色和文本的对象
*/
export function formatVerificationResult(result) {
const resultMap = {
'0': { color: 'text-green-600', bg: 'bg-green-100', text: '一致', icon: '✅' },
'1': { color: 'text-red-600', bg: 'bg-red-100', text: '不一致或不存在', icon: '❌' }
};
return resultMap[result] || { color: 'text-gray-600', bg: 'bg-gray-100', text: '未知', icon: '❓' };
}
/**
* 格式化在网时长
* @param {string} inTime - 在网时长代码
* @returns {object} 包含颜色和文本的对象
*/
export function formatInTime(inTime) {
const timeMap = {
'0': { color: 'text-red-600', bg: 'bg-red-100', text: '0-3个月', icon: '📱' },
'3': { color: 'text-orange-600', bg: 'bg-orange-100', text: '3-6个月', icon: '📱' },
'6': { color: 'text-yellow-600', bg: 'bg-yellow-100', text: '6-12个月', icon: '📱' },
'12': { color: 'text-blue-600', bg: 'bg-blue-100', text: '12-24个月', icon: '📱' },
'24': { color: 'text-green-600', bg: 'bg-green-100', text: '24个月以上', icon: '📱' },
'99': { color: 'text-gray-600', bg: 'bg-gray-100', text: '状态异常', icon: '⚠️' },
'-1': { color: 'text-gray-600', bg: 'bg-gray-100', text: '查无记录', icon: '❓' }
};
return timeMap[inTime] || { color: 'text-gray-600', bg: 'bg-gray-100', text: '未知', icon: '❓' };
}
/**
* 检查是否有风险数据
* @param {Object} data - 数据对象
* @returns {boolean} 是否有风险
*/
export function hasRiskData(data) {
if (!data) return false;
// 检查对象中是否有非0值
return Object.values(data).some(value => {
if (typeof value === 'number') return value > 0;
if (typeof value === 'string') return value !== '0' && value !== '-' && value !== '';
return false;
});
}