/**
 * 简单的DWBG8B4D数据拆分演示
 * 直接在BaseReport.vue中处理
 */

// 在BaseReport.vue的script部分添加这个函数
function splitDWBG8B4DForTabs(reportData) {
  const result = []

  reportData.forEach(item => {
    if (item.data.apiID === 'DWBG8B4D') {
      // 将DWBG8B4D拆分成多个独立的tab
      const dwbgData = item.data.data

      // 报告概览
      result.push({
        data: {
          apiID: 'DWBG8B4D_Overview',
          data: {
            baseInfo: dwbgData.baseInfo,
            checkSuggest: dwbgData.checkSuggest,
            fraudScore: dwbgData.fraudScore,
            creditScore: dwbgData.creditScore,
            verifyRule: dwbgData.verifyRule,
            fraudRule: dwbgData.fraudRule,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 规则风险提示
      result.push({
        data: {
          apiID: 'DWBG8B4D_RiskWarningTab',
          data: {
            riskWarning: dwbgData.riskWarning,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 要素核查
      result.push({
        data: {
          apiID: 'DWBG8B4D_ElementVerification',
          data: {
            sfzeysFlag: dwbgData.elementVerificationDetail?.sfzeysFlag || 0,
            personCheckDetails: dwbgData.elementVerificationDetail?.personCheckDetails || {},
            sjsysFlag: dwbgData.elementVerificationDetail?.sjsysFlag || 0,
            phoneCheckDetails: dwbgData.elementVerificationDetail?.phoneCheckDetails || {},
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 运营商核验
      result.push({
        data: {
          apiID: 'DWBG8B4D_Identity',
          data: {
            inTime: dwbgData.standLiveInfo?.inTime || '',
            phoneVailRiskFlag: dwbgData.elementVerificationDetail?.phoneVailRiskFlag || 0,
            phoneVailRisks: dwbgData.elementVerificationDetail?.phoneVailRisks || {},
            belongRiskFlag: dwbgData.elementVerificationDetail?.belongRiskFlag || 0,
            belongRisks: dwbgData.elementVerificationDetail?.belongRisks || {},
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 公安重点人员检验
      result.push({
        data: {
          apiID: 'DWBG8B4D_RiskWarning',
          data: {
            highRiskFlag: dwbgData.elementVerificationDetail?.highRiskFlag || 0,
            keyPersonCheckList: dwbgData.elementVerificationDetail?.keyPersonCheckList || {},
            antiFraudInfo: dwbgData.elementVerificationDetail?.antiFraudInfo || {},
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 逾期风险
      result.push({
        data: {
          apiID: 'DWBG8B4D_OverdueRisk',
          data: {
            overdueRiskProduct: dwbgData.overdueRiskProduct,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 法院曝光台信息
      result.push({
        data: {
          apiID: 'DWBG8B4D_CourtInfo',
          data: {
            multCourtInfo: dwbgData.multCourtInfo,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 借贷评估
      result.push({
        data: {
          apiID: 'DWBG8B4D_LoanEvaluation',
          data: {
            loanEvaluationVerificationDetail: dwbgData.loanEvaluationVerificationDetail,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 租赁风险评估
      result.push({
        data: {
          apiID: 'DWBG8B4D_LeasingRisk',
          data: {
            leasingRiskAssessment: dwbgData.leasingRiskAssessment,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })

      // 关联风险监督
      result.push({
        data: {
          apiID: 'DWBG8B4D_RiskSupervision',
          data: {
            riskSupervision: dwbgData.riskSupervision,
            success: dwbgData.success,
            timestamp: dwbgData.timestamp
          }
        }
      })
    } else {
      // 其他数据直接添加
      result.push(item)
    }
  })

  return result
}

export { splitDWBG8B4DForTabs }
