This commit is contained in:
2026-02-08 16:56:41 +08:00
parent 9e0b38a6d5
commit 3eb3636b22
109 changed files with 6603 additions and 2118 deletions

View File

@@ -52,6 +52,11 @@ const props = defineProps({
type: Object,
required: true,
default: () => ({})
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
@@ -61,7 +66,7 @@ const labels = periodKeys.map(key => PERIOD_MAP[key].label)
// 总申请次数图表配置
const chartOption = computed(() => {
const data = periodKeys.map(key => {
const counts = getApplicationCounts(props.data, key)
const counts = getApplicationCounts(props.data, key, props.dimension)
return counts.total
})
@@ -90,7 +95,7 @@ const chartOption = computed(() => {
type: 'category',
data: labels,
axisLabel: {
fontSize: 10,
fontSize: 16,
color: '#6b7280',
rotate: 45
},
@@ -103,7 +108,7 @@ const chartOption = computed(() => {
yAxis: {
type: 'value',
axisLabel: {
fontSize: 11,
fontSize: 16,
color: '#6b7280',
formatter: '{value} 次'
},
@@ -137,11 +142,11 @@ const chartOption = computed(() => {
// 特殊时段(周末 / 夜间)图表配置
const specialChartOption = computed(() => {
const weekendData = periodKeys.map(key => {
const s = getSpecialPeriodCounts(props.data, key)
const s = getSpecialPeriodCounts(props.data, key, props.dimension)
return s.weekend || 0
})
const nightData = periodKeys.map(key => {
const s = getSpecialPeriodCounts(props.data, key)
const s = getSpecialPeriodCounts(props.data, key, props.dimension)
return s.night || 0
})
@@ -163,7 +168,7 @@ const specialChartOption = computed(() => {
data: ['周末申请次数', '夜间申请次数'],
top: '5%',
textStyle: {
fontSize: 12
fontSize: 14
}
},
grid: {
@@ -177,7 +182,7 @@ const specialChartOption = computed(() => {
type: 'category',
data: labels,
axisLabel: {
fontSize: 10,
fontSize: 16,
color: '#6b7280',
rotate: 45
},
@@ -190,7 +195,7 @@ const specialChartOption = computed(() => {
yAxis: {
type: 'value',
axisLabel: {
fontSize: 11,
fontSize: 16,
color: '#6b7280',
formatter: '{value} 次'
},

View File

@@ -1,22 +1,18 @@
<template>
<div class="card application-total-section">
<div class="rounded-lg border border-gray-200 pb-2 mb-4">
<div class="flex items-center mb-4 p-4">
<span class="font-bold text-gray-800">申请总次数 (银行+非银) {{ totalCount }}</span>
</div>
<div class="mt-4">
<!-- Tab切换 -->
<div class="mb-6">
<div class="">
<LTitle title="申请总次数详情" />
<div class="bg-white px-4 py-2">
<van-tabs v-model:active="activeTab" color="var(--color-primary)">
<van-tab v-for="(period, index) in periods" :key="period.key" :title="period.label">
<div class="p-4">
<div class="p-4 pb-0">
<!-- 银行机构 -->
<BankInstitutionSection :data="data" :period="period.key" />
<BankInstitutionSection :data="data" :period="period.key" :dimension="dimension" />
<!-- 非银机构 -->
<NBankInstitutionSection :data="data" :period="period.key" />
<NBankInstitutionSection :data="data" :period="period.key" :dimension="dimension" />
</div>
</van-tab>
</van-tabs>
@@ -28,9 +24,8 @@
</template>
<script setup>
import { computed, ref } from 'vue'
import { ref } from 'vue'
import LTitle from '@/components/LTitle.vue'
import { getApplicationCounts, PERIOD_MAP } from '../utils/dataParser'
import BankInstitutionSection from './BankInstitutionSection.vue'
import NBankInstitutionSection from './NBankInstitutionSection.vue'
@@ -39,6 +34,11 @@ const props = defineProps({
type: Object,
required: true,
default: () => ({})
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
@@ -52,12 +52,6 @@ const periods = [
{ key: 'm6', label: '6个月' },
{ key: 'm12', label: '12个月' }
]
// 计算总申请次数12个月
const totalCount = computed(() => {
const counts = getApplicationCounts(props.data, 'm12')
return counts.total
})
</script>
<style lang="scss" scoped>
@@ -89,7 +83,7 @@ const totalCount = computed(() => {
.application-total-section :deep(.van-tab) {
color: #999999 !important;
font-size: 14px !important;
font-size: 16px !important;
font-weight: 400 !important;
border-right: unset !important;
background-color: transparent !important;

View File

@@ -0,0 +1,71 @@
<template>
<div class="card rounded-lg border border-gray-200 pb-2 mb-2">
<div class="px-4 pt-4">
<LTitle title="借贷意向申请情况与建议" />
</div>
<div class="px-2 pb-4">
<!-- 银行类机构申请情况 -->
<Remark
v-if="remarks.bankSituation"
:title="'银行类机构申请情况'"
:content="remarks.bankSituation"
:default-expanded="true"
/>
<!-- 银行类机构申请建议 -->
<Remark
:title="'银行类机构申请建议'"
:content="remarks.bankAdvice"
:default-expanded="false"
/>
<!-- 非银行类机构申请情况 -->
<Remark
v-if="remarks.nbankSituation"
:title="'非银行类机构申请情况'"
:content="remarks.nbankSituation"
:default-expanded="true"
/>
<!-- 非银行类机构申请建议 -->
<Remark
:title="'非银行类机构申请建议'"
:content="remarks.nbankAdvice"
:default-expanded="false"
/>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
import LTitle from '@/components/LTitle.vue'
import Remark from '@/components/Remark.vue'
import { getApplyRemarks } from '../utils/dataParser'
const props = defineProps({
data: {
type: Object,
required: true,
default: () => ({}),
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id',
},
})
const remarks = computed(() => {
return getApplyRemarks(props.data || {}, props.dimension)
})
</script>
<style scoped>
.card {
background: #ffffff;
}
</style>

View File

@@ -1,5 +1,5 @@
<template>
<div class="mb-6">
<div class="">
<LTitle title="银行机构申请分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
@@ -8,8 +8,9 @@
</div>
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
<div class="space-y-2">
<div v-for="(item, index) in detailList" :key="index" class="flex justify-between items-center text-sm">
<div class="space-y-0 mb-2 rounded-lg overflow-hidden">
<div v-for="(item, index) in detailList" :key="index"
:class="['flex justify-between items-center text-lg py-3 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
@@ -17,8 +18,13 @@
<span class="text-[#333333] font-bold">{{ item.value }}</span>
</div>
</div>
</div>
</div>
<!-- 银行类机构申请情况近1年 / 近3个月仅在12个月tab下展示 -->
<Remark class="mt-8 mb-8" v-if="period === 'm12' && applyRemarks.bankSituation" :title="'银行类机构申请情况'"
:content="applyRemarks.bankSituation" :default-expanded="true" />
</template>
<script setup>
@@ -33,7 +39,8 @@ import {
LegendComponent
} from 'echarts/components'
import LTitle from '@/components/LTitle.vue'
import { getBankApplicationDetails, FIELD_LABELS } from '../utils/dataParser'
import Remark from '@/components/Remark.vue'
import { getBankApplicationDetails, FIELD_LABELS, getApplyRemarks } from '../utils/dataParser'
// 注册ECharts组件
use([
@@ -53,6 +60,11 @@ const props = defineProps({
period: {
type: String,
required: true
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
@@ -69,7 +81,14 @@ const COLORS = [
]
// 获取银行机构申请详情
const bankDetails = computed(() => getBankApplicationDetails(props.data, props.period))
const bankDetails = computed(() =>
getBankApplicationDetails(props.data, props.period, props.dimension)
)
// 申请情况与建议(使用整体数据 + 当前维度)
const applyRemarks = computed(() => {
return getApplyRemarks(props.data || {}, props.dimension)
})
// 计算银行机构总次数
const bankTotal = computed(() => {
@@ -103,7 +122,7 @@ const pieChartOption = computed(() => {
top: 'center',
textStyle: {
color: '#999',
fontSize: 14
fontSize: 16
}
}
}
@@ -121,7 +140,7 @@ const pieChartOption = computed(() => {
style: {
text: '银行机构',
fill: '#111827',
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
},
},
@@ -148,7 +167,7 @@ const pieChartOption = computed(() => {
},
label: {
show: true,
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
color: '#333'
}

View File

@@ -1,5 +1,5 @@
<template>
<div class="mb-6">
<div class="">
<LTitle title="银行机构申请机构数分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
@@ -8,8 +8,9 @@
</div>
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
<div class="space-y-2">
<div v-for="(item, index) in detailList" :key="index" class="flex justify-between items-center text-sm">
<div class="space-y-0 mb-2 rounded-lg overflow-hidden">
<div v-for="(item, index) in detailList" :key="index"
:class="['flex justify-between items-center text-lg py-3 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
@@ -19,6 +20,10 @@
</div>
</div>
</div>
<!-- 银行类机构申请建议仅在12个月tab下展示 -->
<Remark class="mt-8 mb-8" v-if="period === 'm12' && applyRemarks.bankAdvice" :title="'银行类机构申请建议'"
:content="applyRemarks.bankAdvice" :default-expanded="true" />
</template>
<script setup>
@@ -33,7 +38,8 @@ import {
LegendComponent
} from 'echarts/components'
import LTitle from '@/components/LTitle.vue'
import { getBankOrgDetails, FIELD_LABELS } from '../utils/dataParser'
import Remark from '@/components/Remark.vue'
import { getBankOrgDetails, FIELD_LABELS, getApplyRemarks } from '../utils/dataParser'
// 注册ECharts组件
use([
@@ -53,6 +59,11 @@ const props = defineProps({
period: {
type: String,
required: true
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
@@ -69,7 +80,14 @@ const COLORS = [
]
// 获取银行机构数详情
const bankOrgs = computed(() => getBankOrgDetails(props.data, props.period))
const bankOrgs = computed(() =>
getBankOrgDetails(props.data, props.period, props.dimension)
)
// 申请情况与建议(使用整体数据 + 当前维度)
const applyRemarks = computed(() => {
return getApplyRemarks(props.data || {}, props.dimension)
})
// 计算银行机构总数
const bankTotal = computed(() => {
@@ -103,7 +121,7 @@ const pieChartOption = computed(() => {
top: 'center',
textStyle: {
color: '#999',
fontSize: 14
fontSize: 16
}
}
}
@@ -121,7 +139,7 @@ const pieChartOption = computed(() => {
style: {
text: '银行机构',
fill: '#111827',
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
},
},
@@ -148,7 +166,7 @@ const pieChartOption = computed(() => {
},
label: {
show: true,
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
color: '#333'
}

View File

@@ -3,17 +3,17 @@
<div class="rounded-lg border border-gray-200 pb-2 mb-4">
<div class="mt-4">
<!-- Tab切换 -->
<div class="mb-6">
<div class="">
<LTitle title="申请机构总数详情" />
<div class="bg-white px-4 py-2">
<van-tabs v-model:active="activeTab" color="var(--color-primary)">
<van-tab v-for="(period, index) in periods" :key="period.key" :title="period.label">
<div class="p-4">
<div class="p-4 pb-0">
<!-- 银行机构 -->
<BankOrgSection :data="data" :period="period.key" />
<BankOrgSection :data="data" :period="period.key" :dimension="dimension" />
<!-- 非银机构 -->
<NBankOrgSection :data="data" :period="period.key" />
<NBankOrgSection :data="data" :period="period.key" :dimension="dimension" />
</div>
</van-tab>
</van-tabs>
@@ -25,9 +25,8 @@
</template>
<script setup>
import { computed, ref } from 'vue'
import { ref } from 'vue'
import LTitle from '@/components/LTitle.vue'
import { getBankOrgDetails, getNBankOrgDetails } from '../utils/dataParser'
import BankOrgSection from './BankOrgSection.vue'
import NBankOrgSection from './NBankOrgSection.vue'
@@ -36,6 +35,11 @@ const props = defineProps({
type: Object,
required: true,
default: () => ({})
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
@@ -49,15 +53,6 @@ const periods = [
{ key: 'm6', label: '6个月' },
{ key: 'm12', label: '12个月' }
]
// 计算总机构数12个月
const totalCount = computed(() => {
const bankOrgs = getBankOrgDetails(props.data, 'm12')
const nbankOrgs = getNBankOrgDetails(props.data, 'm12')
const bankTotal = Object.values(bankOrgs).reduce((sum, val) => sum + (val || 0), 0)
const nbankTotal = Object.values(nbankOrgs).reduce((sum, val) => sum + (val || 0), 0)
return bankTotal + nbankTotal
})
</script>
<style lang="scss" scoped>
@@ -89,7 +84,7 @@ const totalCount = computed(() => {
.institution-total-section :deep(.van-tab) {
color: #999999 !important;
font-size: 14px !important;
font-size: 16px !important;
font-weight: 400 !important;
border-right: unset !important;
background-color: transparent !important;

View File

@@ -1,28 +1,41 @@
<template>
<div class="mb-6">
<LTitle title="非银机构申请分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
<div class="h-64 mb-4">
<v-chart class="chart-container" :option="pieChartOption" autoresize />
</div>
<div class="nbank-institution-section">
<div class="bg-white px-4 py-2">
<van-tabs v-model:active="activeTab" color="var(--color-primary)">
<van-tab v-for="(period, index) in periods" :key="period.key" :title="period.label">
<div class="p-4 pb-0">
<LTitle title="非银机构申请分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
<div class="h-64 mb-4">
<v-chart class="chart-container" :option="getPieChartOption(period.key)" autoresize />
</div>
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
<div class="space-y-2">
<div v-for="(item, index) in detailList" :key="index" class="flex justify-between items-center text-sm">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
<div class="space-y-0 mb-2 rounded-lg overflow-hidden">
<div v-for="(item, index) in getDetailList(period.key)" :key="index"
:class="['flex justify-between items-center text-lg py-3 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
</div>
<span class="text-[#333333] font-bold">{{ item.value }}</span>
</div>
</div>
</div>
<!-- 非银行类机构申请情况近1年 / 近3个月仅在12个月tab下展示 -->
<Remark class="mt-8 mb-0" v-if="period.key === 'm12' && applyRemarks.nbankSituation" :title="'非银行类机构申请情况'"
:content="applyRemarks.nbankSituation" :default-expanded="true" />
</div>
<span class="text-[#333333] font-bold">{{ item.value }}</span>
</div>
</div>
</van-tab>
</van-tabs>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
import { computed, ref } from 'vue'
import VChart from 'vue-echarts'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
@@ -33,7 +46,8 @@ import {
LegendComponent
} from 'echarts/components'
import LTitle from '@/components/LTitle.vue'
import { getNBankApplicationDetails, FIELD_LABELS } from '../utils/dataParser'
import Remark from '@/components/Remark.vue'
import { getNBankApplicationDetails, FIELD_LABELS, getApplyRemarks } from '../utils/dataParser'
// 注册ECharts组件
use([
@@ -52,10 +66,27 @@ const props = defineProps({
},
period: {
type: String,
required: true
required: false,
default: 'm12'
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
const activeTab = ref(5) // 默认显示12个月
const periods = [
{ key: 'd7', label: '7天' },
{ key: 'd15', label: '15天' },
{ key: 'm1', label: '1个月' },
{ key: 'm3', label: '3个月' },
{ key: 'm6', label: '6个月' },
{ key: 'm12', label: '12个月' }
]
// 颜色映射表(与图表保持一致)
const COLORS = [
'#2B79EE',
@@ -68,18 +99,14 @@ const COLORS = [
'#6B7280',
]
// 获取非银机构申请详情
const nbankDetails = computed(() => getNBankApplicationDetails(props.data, props.period))
// 计算非银机构总次数
const nbankTotal = computed(() => {
const details = nbankDetails.value
return Object.values(details).reduce((sum, val) => sum + (val || 0), 0)
// 申请情况与建议(使用整体数据 + 当前维度)
const applyRemarks = computed(() => {
return getApplyRemarks(props.data || {}, props.dimension)
})
// 详细列表(包含所有项,包含 0 次)
const detailList = computed(() => {
const details = nbankDetails.value
// 获取指定时间段的详细列表
const getDetailList = (period) => {
const details = getNBankApplicationDetails(props.data, period, props.dimension)
const labels = FIELD_LABELS.nbank
return Object.entries(details)
@@ -89,11 +116,11 @@ const detailList = computed(() => {
value: value || 0,
color: COLORS[index % COLORS.length],
}))
})
}
// 饼图配置
const pieChartOption = computed(() => {
const list = detailList.value
// 获取指定时间段的饼图配置
const getPieChartOption = (period) => {
const list = getDetailList(period)
if (!list || list.length === 0) {
return {
@@ -103,7 +130,7 @@ const pieChartOption = computed(() => {
top: 'center',
textStyle: {
color: '#999',
fontSize: 14
fontSize: 16
}
}
}
@@ -121,7 +148,7 @@ const pieChartOption = computed(() => {
style: {
text: '非银机构',
fill: '#111827',
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
},
},
@@ -148,7 +175,7 @@ const pieChartOption = computed(() => {
},
label: {
show: true,
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
color: '#333'
}
@@ -163,7 +190,7 @@ const pieChartOption = computed(() => {
}
]
}
})
}
</script>
<style lang="scss" scoped>
@@ -171,4 +198,56 @@ const pieChartOption = computed(() => {
width: 100%;
height: 100%;
}
.nbank-institution-section :deep(.van-tabs) {
border: unset !important;
}
.nbank-institution-section :deep(.van-tabs__wrap) {
height: 32px !important;
background-color: transparent !important;
padding: 0 !important;
border-bottom: 1px solid #DDDDDD !important;
}
.nbank-institution-section :deep(.van-tabs__nav) {
background-color: transparent !important;
gap: 0 !important;
height: 32px !important;
border: unset !important;
}
.nbank-institution-section :deep(.van-tabs__nav--card) {
border: unset !important;
}
.nbank-institution-section :deep(.van-tab) {
color: #999999 !important;
font-size: 16px !important;
font-weight: 400 !important;
border-right: unset !important;
background-color: transparent !important;
border-radius: unset !important;
max-width: 80px !important;
}
.nbank-institution-section :deep(.van-tab--card) {
color: #999999 !important;
border-right: unset !important;
background-color: transparent !important;
border-radius: unset !important;
}
.nbank-institution-section :deep(.van-tab--active) {
color: var(--van-theme-primary) !important;
background-color: unset !important;
}
.nbank-institution-section :deep(.van-tabs__line) {
height: 4px !important;
border-radius: 1px !important;
background-color: var(--van-theme-primary) !important;
width: 20px;
border-radius: 14px;
}
</style>

View File

@@ -1,28 +1,41 @@
<template>
<div class="mb-6">
<LTitle title="非银机构申请机构数分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
<div class="h-64 mb-4">
<v-chart class="chart-container" :option="pieChartOption" autoresize />
</div>
<div class="nbank-org-section">
<div class="bg-white px-4 py-2">
<van-tabs v-model:active="activeTab" color="var(--color-primary)">
<van-tab v-for="(period, index) in periods" :key="period.key" :title="period.label">
<div class="p-4 pb-0">
<LTitle title="非银机构申请机构数分布" />
<div class="mt-4">
<!-- 饼图宽度占满 -->
<div class="h-64 mb-4">
<v-chart class="chart-container" :option="getPieChartOption(period.key)" autoresize />
</div>
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
<div class="space-y-2">
<div v-for="(item, index) in detailList" :key="index" class="flex justify-between items-center text-sm">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
<!-- 详细列表在图表下方展示所有项并带颜色标识 -->
<div class="space-y-0 mb-2 rounded-lg overflow-hidden">
<div v-for="(item, index) in getDetailList(period.key)" :key="index"
:class="['flex justify-between items-center text-lg py-3 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
</div>
<span class="text-[#333333] font-bold">{{ item.value }}</span>
</div>
</div>
</div>
<!-- 非银行类机构申请建议仅在12个月tab下展示 -->
<Remark class="mt-8 mb-0" v-if="period.key === 'm12' && applyRemarks.nbankAdvice" :title="'非银行类机构申请建议'"
:content="applyRemarks.nbankAdvice" :default-expanded="true" />
</div>
<span class="text-[#333333] font-bold">{{ item.value }}</span>
</div>
</div>
</van-tab>
</van-tabs>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
import { computed, ref } from 'vue'
import VChart from 'vue-echarts'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
@@ -33,7 +46,8 @@ import {
LegendComponent
} from 'echarts/components'
import LTitle from '@/components/LTitle.vue'
import { getNBankOrgDetails, FIELD_LABELS } from '../utils/dataParser'
import Remark from '@/components/Remark.vue'
import { getNBankOrgDetails, FIELD_LABELS, getApplyRemarks } from '../utils/dataParser'
// 注册ECharts组件
use([
@@ -52,10 +66,27 @@ const props = defineProps({
},
period: {
type: String,
required: true
required: false,
default: 'm12'
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
const activeTab = ref(5) // 默认显示12个月
const periods = [
{ key: 'd7', label: '7天' },
{ key: 'd15', label: '15天' },
{ key: 'm1', label: '1个月' },
{ key: 'm3', label: '3个月' },
{ key: 'm6', label: '6个月' },
{ key: 'm12', label: '12个月' }
]
// 颜色映射表(与图表保持一致)
const COLORS = [
'#2B79EE',
@@ -68,18 +99,14 @@ const COLORS = [
'#6B7280',
]
// 获取非银机构数详情
const nbankOrgs = computed(() => getNBankOrgDetails(props.data, props.period))
// 计算非银机构总数
const nbankTotal = computed(() => {
const orgs = nbankOrgs.value
return Object.values(orgs).reduce((sum, val) => sum + (val || 0), 0)
// 申请情况与建议(使用整体数据 + 当前维度)
const applyRemarks = computed(() => {
return getApplyRemarks(props.data || {}, props.dimension)
})
// 详细列表(包含所有项,包含 0 家)
const detailList = computed(() => {
const orgs = nbankOrgs.value
// 获取指定时间段的详细列表
const getDetailList = (period) => {
const orgs = getNBankOrgDetails(props.data, period, props.dimension)
const labels = FIELD_LABELS.nbank
return Object.entries(orgs)
@@ -89,11 +116,11 @@ const detailList = computed(() => {
value: value || 0,
color: COLORS[index % COLORS.length],
}))
})
}
// 饼图配置
const pieChartOption = computed(() => {
const list = detailList.value
// 获取指定时间段的饼图配置
const getPieChartOption = (period) => {
const list = getDetailList(period)
if (!list || list.length === 0) {
return {
@@ -103,7 +130,7 @@ const pieChartOption = computed(() => {
top: 'center',
textStyle: {
color: '#999',
fontSize: 14
fontSize: 16
}
}
}
@@ -121,7 +148,7 @@ const pieChartOption = computed(() => {
style: {
text: '非银机构',
fill: '#111827',
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
},
},
@@ -148,7 +175,7 @@ const pieChartOption = computed(() => {
},
label: {
show: true,
fontSize: 14,
fontSize: 16,
fontWeight: 'bold',
color: '#333'
}
@@ -163,7 +190,7 @@ const pieChartOption = computed(() => {
}
]
}
})
}
</script>
<style lang="scss" scoped>
@@ -171,4 +198,56 @@ const pieChartOption = computed(() => {
width: 100%;
height: 100%;
}
.nbank-org-section :deep(.van-tabs) {
border: unset !important;
}
.nbank-org-section :deep(.van-tabs__wrap) {
height: 32px !important;
background-color: transparent !important;
padding: 0 !important;
border-bottom: 1px solid #DDDDDD !important;
}
.nbank-org-section :deep(.van-tabs__nav) {
background-color: transparent !important;
gap: 0 !important;
height: 32px !important;
border: unset !important;
}
.nbank-org-section :deep(.van-tabs__nav--card) {
border: unset !important;
}
.nbank-org-section :deep(.van-tab) {
color: #999999 !important;
font-size: 16px !important;
font-weight: 400 !important;
border-right: unset !important;
background-color: transparent !important;
border-radius: unset !important;
max-width: 80px !important;
}
.nbank-org-section :deep(.van-tab--card) {
color: #999999 !important;
border-right: unset !important;
background-color: transparent !important;
border-radius: unset !important;
}
.nbank-org-section :deep(.van-tab--active) {
color: var(--van-theme-primary) !important;
background-color: unset !important;
}
.nbank-org-section :deep(.van-tabs__line) {
height: 4px !important;
border-radius: 1px !important;
background-color: var(--van-theme-primary) !important;
width: 20px;
border-radius: 14px;
}
</style>

View File

@@ -8,8 +8,9 @@
</div>
<!-- 详细列表与图表颜色一致包含 0 次的类型 -->
<div class="space-y-2 px-4 pb-4">
<div v-for="item in detailList" :key="item.key" class="flex items-center justify-between text-sm">
<div class="space-y-0 px-4 pb-4 rounded-lg overflow-hidden">
<div v-for="(item, index) in detailList" :key="item.key"
:class="['flex items-center justify-between text-lg py-3 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<div class="flex items-center">
<span class="w-2 h-2 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
<span class="text-gray-600">{{ item.label }}</span>
@@ -52,6 +53,11 @@ const props = defineProps({
type: Object,
required: true,
default: () => ({})
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id'
}
})
@@ -79,7 +85,8 @@ const detailList = computed(() => {
const labels = FIELD_LABELS.bank || {}
return TYPE_KEYS.map((key, index) => {
const field = `${PREFIX}_id_${key}_allnum`
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
const field = `${PREFIX}_${dimKey}_${key}_allnum`
const value = getValue(v[field]) || 0
return {
@@ -121,7 +128,7 @@ const chartOption = computed(() => {
type: 'category',
data: categories,
axisLabel: {
fontSize: 10,
fontSize: 13,
color: '#6b7280',
rotate: 30
},
@@ -134,7 +141,7 @@ const chartOption = computed(() => {
yAxis: {
type: 'value',
axisLabel: {
fontSize: 11,
fontSize: 16,
color: '#6b7280',
formatter: '{value} 次'
},
@@ -170,15 +177,4 @@ const chartOption = computed(() => {
width: 100%;
height: 100%;
}
</style>
{
"cells": [],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
</style>

View File

@@ -3,34 +3,15 @@
<div class="rounded-lg border border-gray-200 p-4 space-y-3">
<LTitle title="近期集中申请提示" />
<div v-if="hasAnyData" class="space-y-2 text-sm text-gray-700">
<div class="flex justify-between">
<span>最近在银行连续申请次数</span>
<span class="font-bold text-[#111827]">{{ bankCons }} </span>
</div>
<div class="flex justify-between">
<span>最近在银行连续申请天数</span>
<span class="font-bold text-[#111827]">{{ bankDays }} </span>
</div>
<div class="flex justify-between">
<span>最近在非银连续申请次数</span>
<span class="font-bold text-[#111827]">{{ nbankCons }} </span>
</div>
<div class="flex justify-between">
<span>最近在非银连续申请天数</span>
<span class="font-bold text-[#111827]">{{ nbankDays }} </span>
</div>
<div class="flex justify-between">
<span>距最近一次在银行机构申请</span>
<span class="font-bold text-[#111827]">{{ bankGap }} </span>
</div>
<div class="flex justify-between">
<span>距最近一次在非银机构申请</span>
<span class="font-bold text-[#111827]">{{ nbankGap }} </span>
<div v-if="hasAnyData" class="space-y-0 text-lg text-gray-700 rounded-lg overflow-hidden">
<div v-for="(item, index) in dataItems" :key="item.label"
:class="['flex justify-between py-3 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<span>{{ item.label }}</span>
<span class="font-bold text-[#111827]">{{ item.value }}</span>
</div>
</div>
<div v-else class="text-sm text-gray-400">
<div v-else class="text-base text-gray-400">
暂未查询到明显的近期集中申请行为
</div>
</div>
@@ -48,15 +29,38 @@ const props = defineProps({
required: true,
default: () => ({}),
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id',
},
})
const bankCons = computed(() => getValue(props.data?.als_lst_id_bank_consnum))
const bankDays = computed(() => getValue(props.data?.als_lst_id_bank_csinteday))
const nbankCons = computed(() => getValue(props.data?.als_lst_id_nbank_consnum))
const nbankDays = computed(() => getValue(props.data?.als_lst_id_nbank_csinteday))
const bankCons = computed(() => {
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
return getValue(props.data?.[`als_lst_${dimKey}_bank_consnum`])
})
const bankDays = computed(() => {
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
return getValue(props.data?.[`als_lst_${dimKey}_bank_csinteday`])
})
const nbankCons = computed(() => {
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
return getValue(props.data?.[`als_lst_${dimKey}_nbank_consnum`])
})
const nbankDays = computed(() => {
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
return getValue(props.data?.[`als_lst_${dimKey}_nbank_csinteday`])
})
const bankGap = computed(() => getValue(props.data?.als_lst_id_bank_inteday))
const nbankGap = computed(() => getValue(props.data?.als_lst_id_nbank_inteday))
const bankGap = computed(() => {
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
return getValue(props.data?.[`als_lst_${dimKey}_bank_inteday`])
})
const nbankGap = computed(() => {
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
return getValue(props.data?.[`als_lst_${dimKey}_nbank_inteday`])
})
const hasAnyData = computed(() => {
return (
@@ -68,6 +72,18 @@ const hasAnyData = computed(() => {
(nbankGap.value || 0) > 0
)
})
// 数据项列表
const dataItems = computed(() => {
return [
{ label: '最近在银行连续申请次数', value: `${bankCons.value}` },
{ label: '最近在银行连续申请天数', value: `${bankDays.value}` },
{ label: '最近在非银连续申请次数', value: `${nbankCons.value}` },
{ label: '最近在非银连续申请天数', value: `${nbankDays.value}` },
{ label: '距最近一次在银行机构申请', value: `${bankGap.value}` },
{ label: '距最近一次在非银机构申请', value: `${nbankGap.value}` }
]
})
</script>
<style scoped>
@@ -75,5 +91,3 @@ const hasAnyData = computed(() => {
background: #ffffff;
}
</style>

View File

@@ -0,0 +1,69 @@
<template>
<div class="card rounded-lg border border-gray-200 pb-2 mb-2">
<div class="px-4 pt-4 pb-4">
<LTitle title="风险汇总" />
<div class="space-y-0 mt-3 rounded-lg overflow-hidden">
<div v-for="(risk, index) in riskSummary" :key="risk.label"
:class="['flex justify-between items-center text-lg py-4 px-4', index % 2 === 0 ? 'bg-primary-50' : 'bg-white']">
<span class="text-gray-600">{{ risk.label }}</span>
<span class="font-semibold text-xl" :class="getRiskClass(risk.value)">{{ risk.value }}</span>
</div>
</div>
</div>
<!-- 风险汇总解读 -->
<Remark :content="riskRemark" title="风险解读" :default-expanded="true" />
</div>
</template>
<script setup>
import { computed } from 'vue'
import LTitle from '@/components/LTitle.vue'
import Remark from '@/components/Remark.vue'
import { getRiskSummary, generateRiskRemark } from '../utils/dataParser'
const props = defineProps({
data: {
type: Object,
required: true,
default: () => ({}),
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id',
},
})
// 风险汇总
const riskSummary = computed(() => {
return getRiskSummary(props.data || {}, props.dimension)
})
// 风险汇总解读文本
const riskRemark = computed(() => {
return generateRiskRemark(riskSummary.value)
})
// 根据风险等级返回对应的样式类
const getRiskClass = (level) => {
switch (level) {
case '无风险':
return 'text-green-600'
case '低风险':
return 'text-blue-600'
case '中风险':
return 'text-amber-600'
case '高风险':
return 'text-red-600'
default:
return 'text-gray-600'
}
}
</script>
<style scoped>
.card {
background: #ffffff;
}
</style>

View File

@@ -1,21 +1,35 @@
<template>
<div class="card rounded-lg border border-gray-200 pb-2 mb-2">
<div class="flex items-center mb-4 p-4">
<span class="font-bold text-gray-800">借贷申请统计概览</span>
<div class="flex items-center justify-between mb-4 px-4 pt-4">
<LTitle title="统计概览" />
<!-- 维度切换按钮组 -->
<div class="inline-flex rounded-full overflow-hidden text-base">
<button class="px-4 py-1 border border-[#2B79EE] rounded-l-full"
:class="dimension === 'id' ? 'bg-[#2B79EE] text-white' : 'bg-white text-[#2B79EE]'"
@click="$emit('update:dimension', 'id')">
身份证匹配
</button>
<button class="px-4 py-1 border border-[#2B79EE] border-l-0 rounded-r-full"
:class="dimension === 'cell' ? 'bg-[#2B79EE] text-white' : 'bg-white text-[#2B79EE]'"
@click="$emit('update:dimension', 'cell')">
手机号匹配
</button>
</div>
</div>
<div class="grid grid-cols-2 gap-4 px-4 pb-4">
<div v-for="item in items" :key="item.label"
class="bg-blue-50 rounded-lg p-3 text-center border border-[#2B79EE1A]">
<div class="text-xl font-bold text-[#111827]">
<div class="text-2xl font-bold text-[#111827]">
{{ item.value }}
<span class="text-xs text-gray-500 ml-1">{{ item.unit }}</span>
<span class="text-base text-gray-500 ml-1">{{ item.unit }}</span>
</div>
<div class="text-xs text-gray-600 mt-1">
<div class="text-base text-gray-600 mt-1">
{{ item.label }}
</div>
</div>
</div>
</div>
</template>
<script setup>
@@ -28,26 +42,34 @@ const props = defineProps({
required: true,
default: () => ({}),
},
// 维度id身份证 / cell手机号
dimension: {
type: String,
default: 'id',
},
})
const items = computed(() => {
const v = props.data || {}
// 近12个月申请次数总/银行/非银)
const m12 = getApplicationCounts(v, 'm12')
const m12 = getApplicationCounts(v, 'm12', props.dimension)
// 近12个月申请机构总数银行+非银)
const bankOrgs = getBankOrgDetails(v, 'm12')
const nbankOrgs = getNBankOrgDetails(v, 'm12')
const bankOrgs = getBankOrgDetails(v, 'm12', props.dimension)
const nbankOrgs = getNBankOrgDetails(v, 'm12', props.dimension)
const bankOrgTotal = Object.values(bankOrgs || {}).reduce((sum, val) => sum + (val || 0), 0)
const nbankOrgTotal = Object.values(nbankOrgs || {}).reduce((sum, val) => sum + (val || 0), 0)
const orgTotal = bankOrgTotal + nbankOrgTotal
// 近12个月周末 / 夜间申请次数(银行+非银)
const dimKey = props.dimension === 'cell' ? 'cell' : 'id'
const weekendTotal =
Number(v.als_m12_id_bank_week_allnum || 0) + Number(v.als_m12_id_nbank_week_allnum || 0)
Number(v[`als_m12_${dimKey}_bank_week_allnum`] || 0) +
Number(v[`als_m12_${dimKey}_nbank_week_allnum`] || 0)
const nightTotal =
Number(v.als_m12_id_bank_night_allnum || 0) + Number(v.als_m12_id_nbank_night_allnum || 0)
Number(v[`als_m12_${dimKey}_bank_night_allnum`] || 0) +
Number(v[`als_m12_${dimKey}_nbank_night_allnum`] || 0)
return [
{ label: '总申请次数', value: m12.total || 0, unit: '次' },

View File

@@ -1,35 +1,39 @@
<template>
<div class="flex flex-col gap-4">
<!-- 统计概览小模块 -->
<SummaryApplyStats :data="variableValue" />
<!-- 统计概览小模块内部自带维度切换按钮 -->
<SummaryApplyStats v-model:dimension="activeDimension" :data="variableValue" />
<!-- 申请次数 -->
<ApplicationCountSection :data="variableValue" />
<ApplicationCountSection :data="variableValue" :dimension="activeDimension" />
<!-- 产品类型申请分布 -->
<ProductTypeDistributionSection :data="variableValue" />
<ProductTypeDistributionSection :data="variableValue" :dimension="activeDimension" />
<!-- 近期集中申请提示 -->
<RecentIntensiveApplicationSection :data="variableValue" />
<RecentIntensiveApplicationSection :data="variableValue" :dimension="activeDimension" />
<!-- 申请总次数 (银行+非银) -->
<ApplicationTotalSection :data="variableValue" />
<ApplicationTotalSection :data="variableValue" :dimension="activeDimension" />
<!-- 申请机构总数 (银行+非银) -->
<InstitutionTotalSection :data="variableValue" />
<InstitutionTotalSection :data="variableValue" :dimension="activeDimension" />
<!-- 风险汇总 -->
<RiskSummarySection :data="variableValue" :dimension="activeDimension" />
</div>
</template>
<script setup>
import { computed } from 'vue'
import { computed, ref } from 'vue'
import { useRiskNotifier } from '@/composables/useRiskNotifier'
import { extractVariableValue } from './utils/dataParser'
import { extractVariableValue, getRiskSummary } from './utils/dataParser'
import ApplicationCountSection from './components/ApplicationCountSection.vue'
import ApplicationTotalSection from './components/ApplicationTotalSection.vue'
import InstitutionTotalSection from './components/InstitutionTotalSection.vue'
import SummaryApplyStats from './components/SummaryApplyStats.vue'
import ProductTypeDistributionSection from './components/ProductTypeDistributionSection.vue'
import RecentIntensiveApplicationSection from './components/RecentIntensiveApplicationSection.vue'
import RiskSummarySection from './components/RiskSummarySection.vue'
const props = defineProps({
data: {
@@ -51,6 +55,9 @@ const props = defineProps({
},
})
// 当前维度id身份证 / cell手机号
const activeDimension = ref('id')
// 获取数据
const rawData = computed(() => props.data?.data || props.data || {})
@@ -58,8 +65,10 @@ const rawData = computed(() => props.data?.data || props.data || {})
const variableValue = computed(() => extractVariableValue(rawData.value))
// 计算风险评分0-100分分数越高越安全
// 基于 RiskSummarySection 中汇总的各个机构类型风险等级计算,权重较高
const riskScore = computed(() => {
const data = variableValue.value
const dimension = activeDimension.value
if (!data || Object.keys(data).length === 0) {
return 100 // 无数据视为最安全
@@ -67,45 +76,31 @@ const riskScore = computed(() => {
let score = 100 // 初始满分
// 近7天申请次数评估
const d7Total = parseInt(data.als_d7_id_bank_allnum || 0) + parseInt(data.als_d7_id_nbank_allnum || 0)
if (d7Total > 5) {
score -= 20 // 近7天申请过多
} else if (d7Total > 3) {
score -= 10
}
// 获取各机构类型的风险汇总近12个月
const riskSummary = getRiskSummary(data, dimension)
// 近15天申请次数评估
const d15Total = parseInt(data.als_d15_id_bank_allnum || 0) + parseInt(data.als_d15_id_nbank_allnum || 0)
if (d15Total > 10) {
score -= 15
} else if (d15Total > 5) {
score -= 8
}
// 近1个月申请次数评估
const m1Total = parseInt(data.als_m1_id_bank_allnum || 0) + parseInt(data.als_m1_id_nbank_allnum || 0)
if (m1Total > 15) {
score -= 20
} else if (m1Total > 8) {
score -= 10
}
// 近3个月申请次数评估
const m3Total = parseInt(data.als_m3_id_bank_allnum || 0) + parseInt(data.als_m3_id_nbank_allnum || 0)
if (m3Total > 20) {
score -= 15
} else if (m3Total > 10) {
score -= 8
}
// 近6个月申请次数评估
const m6Total = parseInt(data.als_m6_id_bank_allnum || 0) + parseInt(data.als_m6_id_nbank_allnum || 0)
if (m6Total > 30) {
score -= 10
} else if (m6Total > 15) {
score -= 5
}
// 根据风险汇总计算扣分,权重较高
// 高风险:每个扣 15 分(权重高)
// 中风险:每个扣 8 分
// 低风险:每个扣 3 分
// 无风险:不扣分
riskSummary.forEach((risk) => {
switch (risk.value) {
case '高风险':
score -= 50 // 高风险权重高,扣分较多
break
case '中风险':
score -= 30
break
case '低风险':
score -= 8
break
case '无风险':
default:
// 无风险不扣分
break
}
})
// 确保分数在10-100范围内
return Math.max(10, Math.min(100, score))

View File

@@ -1,6 +1,6 @@
/**
* 数据解析工具函数
* 用于解析借贷申请验证A的返回数据
* 用于解析借贷意向验证A的返回数据
*/
/**
@@ -53,19 +53,20 @@ export const PERIOD_MAP = {
/**
* 获取申请次数(按时间段)
*/
export function getApplicationCounts(variableValue, period) {
export function getApplicationCounts(variableValue, period, dimension = "id") {
const { prefix } = PERIOD_MAP[period];
const dimKey = dimension === "cell" ? "cell" : "id";
// 计算总申请次数(所有类型的申请次数之和)
const types = [
"id_pdl_allnum", // 线上小额现金贷
"id_caon_allnum", // 线上现金分期
"id_rel_allnum", // 信用卡(类信用卡)
"id_caoff_allnum", // 线下现金分期
"id_cooff_allnum", // 线下消费分期
"id_af_allnum", // 汽车金融
"id_coon_allnum", // 线上消费分期
"id_oth_allnum", // 其他
`${dimKey}_pdl_allnum`, // 线上小额现金贷
`${dimKey}_caon_allnum`, // 线上现金分期
`${dimKey}_rel_allnum`, // 信用卡(类信用卡)
`${dimKey}_caoff_allnum`, // 线下现金分期
`${dimKey}_cooff_allnum`, // 线下消费分期
`${dimKey}_af_allnum`, // 汽车金融
`${dimKey}_coon_allnum`, // 线上消费分期
`${dimKey}_oth_allnum`, // 其他
];
let total = 0;
@@ -75,11 +76,12 @@ export function getApplicationCounts(variableValue, period) {
});
// 银行机构申请次数
const bankTotal = getValue(variableValue[`${prefix}_id_bank_allnum`]) || 0;
const bankTotal =
getValue(variableValue[`${prefix}_${dimKey}_bank_allnum`]) || 0;
// 非银机构申请次数
const nbankTotal =
getValue(variableValue[`${prefix}_id_nbank_allnum`]) || 0;
getValue(variableValue[`${prefix}_${dimKey}_nbank_allnum`]) || 0;
// 如果计算出的total为0则使用银行+非银的总和
const finalTotal = total > 0 ? total : bankTotal + nbankTotal;
@@ -94,17 +96,22 @@ export function getApplicationCounts(variableValue, period) {
/**
* 获取特殊时段(周末/夜间)申请次数(按时间段,银行+非银)
*/
export function getSpecialPeriodCounts(variableValue, period) {
export function getSpecialPeriodCounts(
variableValue,
period,
dimension = "id"
) {
const { prefix } = PERIOD_MAP[period];
const dimKey = dimension === "cell" ? "cell" : "id";
const weekendBank =
getValue(variableValue[`${prefix}_id_bank_week_allnum`]) || 0;
getValue(variableValue[`${prefix}_${dimKey}_bank_week_allnum`]) || 0;
const weekendNbank =
getValue(variableValue[`${prefix}_id_nbank_week_allnum`]) || 0;
getValue(variableValue[`${prefix}_${dimKey}_nbank_week_allnum`]) || 0;
const nightBank =
getValue(variableValue[`${prefix}_id_bank_night_allnum`]) || 0;
getValue(variableValue[`${prefix}_${dimKey}_bank_night_allnum`]) || 0;
const nightNbank =
getValue(variableValue[`${prefix}_id_nbank_night_allnum`]) || 0;
getValue(variableValue[`${prefix}_${dimKey}_nbank_night_allnum`]) || 0;
return {
weekend: weekendBank + weekendNbank,
@@ -115,88 +122,116 @@ export function getSpecialPeriodCounts(variableValue, period) {
/**
* 获取银行机构申请次数详情
*/
export function getBankApplicationDetails(variableValue, period) {
export function getBankApplicationDetails(
variableValue,
period,
dimension = "id"
) {
const { prefix } = PERIOD_MAP[period];
const dimKey = dimension === "cell" ? "cell" : "id";
return {
pdl: getValue(variableValue[`${prefix}_id_pdl_allnum`]), // 线上小额现金贷
caon: getValue(variableValue[`${prefix}_id_caon_allnum`]), // 线上现金分期
rel: getValue(variableValue[`${prefix}_id_rel_allnum`]), // 信用卡(类信用卡)
caoff: getValue(variableValue[`${prefix}_id_caoff_allnum`]), // 线下现金分期
cooff: getValue(variableValue[`${prefix}_id_cooff_allnum`]), // 线下消费分期
af: getValue(variableValue[`${prefix}_id_af_allnum`]), // 汽车金融
coon: getValue(variableValue[`${prefix}_id_coon_allnum`]), // 线上消费分期
oth: getValue(variableValue[`${prefix}_id_oth_allnum`]), // 其他
bank: getValue(variableValue[`${prefix}_id_bank_allnum`]), // 银行机构申请
tra: getValue(variableValue[`${prefix}_id_bank_tra_allnum`]), // 传统银行申请
ret: getValue(variableValue[`${prefix}_id_bank_ret_allnum`]), // 网络零售银行申请
pdl: getValue(variableValue[`${prefix}_${dimKey}_pdl_allnum`]), // 线上小额现金贷
caon: getValue(variableValue[`${prefix}_${dimKey}_caon_allnum`]), // 线上现金分期
rel: getValue(variableValue[`${prefix}_${dimKey}_rel_allnum`]), // 信用卡(类信用卡)
caoff: getValue(variableValue[`${prefix}_${dimKey}_caoff_allnum`]), // 线下现金分期
cooff: getValue(variableValue[`${prefix}_${dimKey}_cooff_allnum`]), // 线下消费分期
af: getValue(variableValue[`${prefix}_${dimKey}_af_allnum`]), // 汽车金融
coon: getValue(variableValue[`${prefix}_${dimKey}_coon_allnum`]), // 线上消费分期
oth: getValue(variableValue[`${prefix}_${dimKey}_oth_allnum`]), // 其他
bank: getValue(variableValue[`${prefix}_${dimKey}_bank_allnum`]), // 银行机构申请
tra: getValue(variableValue[`${prefix}_${dimKey}_bank_tra_allnum`]), // 传统银行申请
ret: getValue(variableValue[`${prefix}_${dimKey}_bank_ret_allnum`]), // 网络零售银行申请
};
}
/**
* 获取非银机构申请次数详情
*/
export function getNBankApplicationDetails(variableValue, period) {
export function getNBankApplicationDetails(
variableValue,
period,
dimension = "id"
) {
const { prefix } = PERIOD_MAP[period];
const dimKey = dimension === "cell" ? "cell" : "id";
return {
nbank: getValue(variableValue[`${prefix}_id_nbank_allnum`]), // 非银机构
p2p: getValue(variableValue[`${prefix}_id_nbank_p2p_allnum`]), // 改制机构
mc: getValue(variableValue[`${prefix}_id_nbank_mc_allnum`]), // 小贷机构
ca: getValue(variableValue[`${prefix}_id_nbank_ca_allnum`]), // 现金类分期机构
cf: getValue(variableValue[`${prefix}_id_nbank_cf_allnum`]), // 消费类分期机构
com: getValue(variableValue[`${prefix}_id_nbank_com_allnum`]), // 代偿类分期机构
oth: getValue(variableValue[`${prefix}_id_nbank_oth_allnum`]), // 其他申请
nsloan: getValue(variableValue[`${prefix}_id_nbank_nsloan_allnum`]), // 持牌网络小贷机构
autofin: getValue(variableValue[`${prefix}_id_nbank_autofin_allnum`]), // 持牌汽车金融机构
sloan: getValue(variableValue[`${prefix}_id_nbank_sloan_allnum`]), // 持牌小贷机构
cons: getValue(variableValue[`${prefix}_id_nbank_cons_allnum`]), // 持牌消费金融机构
finlea: getValue(variableValue[`${prefix}_id_nbank_finlea_allnum`]), // 持牌融资租赁机构
else: getValue(variableValue[`${prefix}_id_nbank_else_allnum`]), // 其他申请
nbank: getValue(variableValue[`${prefix}_${dimKey}_nbank_allnum`]), // 非银机构
p2p: getValue(variableValue[`${prefix}_${dimKey}_nbank_p2p_allnum`]), // 改制机构
mc: getValue(variableValue[`${prefix}_${dimKey}_nbank_mc_allnum`]), // 小贷机构
ca: getValue(variableValue[`${prefix}_${dimKey}_nbank_ca_allnum`]), // 现金类分期机构
cf: getValue(variableValue[`${prefix}_${dimKey}_nbank_cf_allnum`]), // 消费类分期机构
com: getValue(variableValue[`${prefix}_${dimKey}_nbank_com_allnum`]), // 代偿类分期机构
oth: getValue(variableValue[`${prefix}_${dimKey}_nbank_oth_allnum`]), // 其他申请
nsloan: getValue(
variableValue[`${prefix}_${dimKey}_nbank_nsloan_allnum`]
), // 持牌网络小贷机构
autofin: getValue(
variableValue[`${prefix}_${dimKey}_nbank_autofin_allnum`]
), // 持牌汽车金融机构
sloan: getValue(
variableValue[`${prefix}_${dimKey}_nbank_sloan_allnum`]
), // 持牌小贷机构
cons: getValue(variableValue[`${prefix}_${dimKey}_nbank_cons_allnum`]), // 持牌消费金融机构
finlea: getValue(
variableValue[`${prefix}_${dimKey}_nbank_finlea_allnum`]
), // 持牌融资租赁机构
else: getValue(variableValue[`${prefix}_${dimKey}_nbank_else_allnum`]), // 其他申请
};
}
/**
* 获取银行机构申请机构数详情
*/
export function getBankOrgDetails(variableValue, period) {
export function getBankOrgDetails(variableValue, period, dimension = "id") {
const { prefix } = PERIOD_MAP[period];
const dimKey = dimension === "cell" ? "cell" : "id";
return {
pdl: getValue(variableValue[`${prefix}_id_pdl_orgnum`]),
caon: getValue(variableValue[`${prefix}_id_caon_orgnum`]),
rel: getValue(variableValue[`${prefix}_id_rel_orgnum`]),
caoff: getValue(variableValue[`${prefix}_id_caoff_orgnum`]),
cooff: getValue(variableValue[`${prefix}_id_cooff_orgnum`]),
af: getValue(variableValue[`${prefix}_id_af_orgnum`]),
coon: getValue(variableValue[`${prefix}_id_coon_orgnum`]),
oth: getValue(variableValue[`${prefix}_id_oth_orgnum`]),
bank: getValue(variableValue[`${prefix}_id_bank_orgnum`]),
tra: getValue(variableValue[`${prefix}_id_bank_tra_orgnum`]),
ret: getValue(variableValue[`${prefix}_id_bank_ret_orgnum`]),
pdl: getValue(variableValue[`${prefix}_${dimKey}_pdl_orgnum`]),
caon: getValue(variableValue[`${prefix}_${dimKey}_caon_orgnum`]),
rel: getValue(variableValue[`${prefix}_${dimKey}_rel_orgnum`]),
caoff: getValue(variableValue[`${prefix}_${dimKey}_caoff_orgnum`]),
cooff: getValue(variableValue[`${prefix}_${dimKey}_cooff_orgnum`]),
af: getValue(variableValue[`${prefix}_${dimKey}_af_orgnum`]),
coon: getValue(variableValue[`${prefix}_${dimKey}_coon_orgnum`]),
oth: getValue(variableValue[`${prefix}_${dimKey}_oth_orgnum`]),
bank: getValue(variableValue[`${prefix}_${dimKey}_bank_orgnum`]),
tra: getValue(variableValue[`${prefix}_${dimKey}_bank_tra_orgnum`]),
ret: getValue(variableValue[`${prefix}_${dimKey}_bank_ret_orgnum`]),
};
}
/**
* 获取非银机构申请机构数详情
*/
export function getNBankOrgDetails(variableValue, period) {
export function getNBankOrgDetails(variableValue, period, dimension = "id") {
const { prefix } = PERIOD_MAP[period];
const dimKey = dimension === "cell" ? "cell" : "id";
return {
nbank: getValue(variableValue[`${prefix}_id_nbank_orgnum`]),
p2p: getValue(variableValue[`${prefix}_id_nbank_p2p_orgnum`]),
mc: getValue(variableValue[`${prefix}_id_nbank_mc_orgnum`]),
ca: getValue(variableValue[`${prefix}_id_nbank_ca_orgnum`]),
cf: getValue(variableValue[`${prefix}_id_nbank_cf_orgnum`]),
com: getValue(variableValue[`${prefix}_id_nbank_com_orgnum`]),
oth: getValue(variableValue[`${prefix}_id_nbank_oth_orgnum`]),
nsloan: getValue(variableValue[`${prefix}_id_nbank_nsloan_orgnum`]),
autofin: getValue(variableValue[`${prefix}_id_nbank_autofin_orgnum`]),
sloan: getValue(variableValue[`${prefix}_id_nbank_sloan_orgnum`]),
cons: getValue(variableValue[`${prefix}_id_nbank_cons_orgnum`]),
finlea: getValue(variableValue[`${prefix}_id_nbank_finlea_orgnum`]),
else: getValue(variableValue[`${prefix}_id_nbank_else_orgnum`]),
nbank: getValue(variableValue[`${prefix}_${dimKey}_nbank_orgnum`]),
p2p: getValue(variableValue[`${prefix}_${dimKey}_nbank_p2p_orgnum`]),
mc: getValue(variableValue[`${prefix}_${dimKey}_nbank_mc_orgnum`]),
ca: getValue(variableValue[`${prefix}_${dimKey}_nbank_ca_orgnum`]),
cf: getValue(variableValue[`${prefix}_${dimKey}_nbank_cf_orgnum`]),
com: getValue(variableValue[`${prefix}_${dimKey}_nbank_com_orgnum`]),
oth: getValue(variableValue[`${prefix}_${dimKey}_nbank_oth_orgnum`]),
nsloan: getValue(
variableValue[`${prefix}_${dimKey}_nbank_nsloan_orgnum`]
),
autofin: getValue(
variableValue[`${prefix}_${dimKey}_nbank_autofin_orgnum`]
),
sloan: getValue(
variableValue[`${prefix}_${dimKey}_nbank_sloan_orgnum`]
),
cons: getValue(variableValue[`${prefix}_${dimKey}_nbank_cons_orgnum`]),
finlea: getValue(
variableValue[`${prefix}_${dimKey}_nbank_finlea_orgnum`]
),
else: getValue(variableValue[`${prefix}_${dimKey}_nbank_else_orgnum`]),
};
}
@@ -235,3 +270,249 @@ export const FIELD_LABELS = {
else: "其他申请",
},
};
/**
* 根据申请次数计算风险等级
* @param {number} count 申请次数
* @returns {string} 风险等级:无风险、低风险、中风险、高风险
*/
export function calculateRiskLevel(count) {
const num = Number(count) || 0;
if (num === 0) {
return "无风险";
} else if (num >= 1 && num <= 3) {
return "低风险";
} else if (num >= 4 && num <= 8) {
return "中风险";
} else {
return "高风险";
}
}
/**
* 获取各机构类型的风险汇总近12个月
* @param {Object} variableValue 数据对象
* @param {string} dimension 维度id身份证 / cell手机号
* @returns {Array} 风险汇总列表,格式:[{label: '机构类型风险等级', value: '风险等级'}]
*/
export function getRiskSummary(variableValue, dimension = "id") {
const dimKey = dimension === "cell" ? "cell" : "id";
const prefix = "als_m12"; // 近12个月
// 银行类机构申请次数
const bankCount =
getValue(variableValue[`${prefix}_${dimKey}_bank_allnum`]) || 0;
// 非银行类机构申请次数
const nbankCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_allnum`]) || 0;
// 持牌网络小贷机构申请次数
const nsloanCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_nsloan_allnum`]) || 0;
// 持牌小贷机构申请次数
const sloanCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_sloan_allnum`]) || 0;
// 持牌消费金融机构申请次数
const consCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_cons_allnum`]) || 0;
// 持牌融资租赁机构申请次数
const finleaCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_finlea_allnum`]) || 0;
// 持牌汽车金融机构申请次数
const autofinCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_autofin_allnum`]) ||
0;
// 其他非银机构申请次数(包括 p2p, mc, ca, cf, com, oth, else
const p2pCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_p2p_allnum`]) || 0;
const mcCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_mc_allnum`]) || 0;
const caCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_ca_allnum`]) || 0;
const cfCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_cf_allnum`]) || 0;
const comCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_com_allnum`]) || 0;
const othCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_oth_allnum`]) || 0;
const elseCount =
getValue(variableValue[`${prefix}_${dimKey}_nbank_else_allnum`]) || 0;
const otherNbankCount =
p2pCount +
mcCount +
caCount +
cfCount +
comCount +
othCount +
elseCount;
return [
{
label: "银行类机构风险等级",
value: calculateRiskLevel(bankCount),
count: bankCount,
},
{
label: "非银行类机构风险等级",
value: calculateRiskLevel(nbankCount),
count: nbankCount,
},
{
label: "持牌网络小贷机构风险等级",
value: calculateRiskLevel(nsloanCount),
count: nsloanCount,
},
{
label: "持牌小贷机构风险等级",
value: calculateRiskLevel(sloanCount),
count: sloanCount,
},
{
label: "持牌消费金融机构风险等级",
value: calculateRiskLevel(consCount),
count: consCount,
},
{
label: "持牌融资租赁机构风险等级",
value: calculateRiskLevel(finleaCount),
count: finleaCount,
},
{
label: "持牌汽车金融机构风险等级",
value: calculateRiskLevel(autofinCount),
count: autofinCount,
},
{
label: "其他非银机构风险等级",
value: calculateRiskLevel(otherNbankCount),
count: otherNbankCount,
},
];
}
/**
* 生成风险汇总解读文本
* @param {Array} riskSummary 风险汇总列表
* @returns {string} 解读文本
*/
export function generateRiskRemark(riskSummary) {
if (!riskSummary || riskSummary.length === 0) {
return "暂无风险数据。";
}
// 按风险等级优先级排序:高风险 > 中风险 > 低风险 > 无风险
const riskPriority = { 高风险: 4, 中风险: 3, 低风险: 2, 无风险: 1 };
const sortedRisks = riskSummary
.filter((r) => r.value !== "无风险")
.sort(
(a, b) =>
(riskPriority[b.value] || 0) - (riskPriority[a.value] || 0)
);
if (sortedRisks.length === 0) {
return "经大数据分析,您在各机构类型的风险等级均为无风险,信用状况良好。请您继续保持良好的借还款履约行为,维护个人风险。";
}
// 取最高风险的机构类型
const highestRisk = sortedRisks[0];
const orgType = highestRisk.label.replace("风险等级", ""); // 去掉"风险等级"后缀
const riskLevel = highestRisk.value;
const count = highestRisk.count || 0;
// 生成解读文本
let remark = `经大数据分析,您命中${orgType}风险等级的${riskLevel}名单`;
if (count > 0) {
remark += `,历史命中 ${count}`;
}
remark += `,最近一次进入${orgType}风险等级的${riskLevel}名单在近 1 年内。请您注意对应机构的正常借还款履约行为,提高信用评价。`;
return remark;
}
/**
* 将风险等级映射为“贷款申请需求”文本
*/
function mapRiskToDemandText(level) {
switch (level) {
case "高风险":
return "贷款申请需求较高";
case "中风险":
return "贷款申请需求适中";
case "低风险":
case "无风险":
default:
return "贷款申请需求较低";
}
}
/**
* 将风险等级映射为“贷款申请频率”文本
*/
function mapRiskToFrequencyText(level) {
switch (level) {
case "高风险":
return "贷款申请频率较高";
case "中风险":
return "贷款申请频率适中";
case "低风险":
case "无风险":
default:
return "贷款申请频率较低";
}
}
/**
* 生成银行 / 非银申请情况解读近1年 / 近3个月
* @param {Object} variableValue
* @param {string} dimension
* @returns {{ bankSituation: string, bankAdvice: string, nbankSituation: string, nbankAdvice: string }}
*/
export function getApplyRemarks(variableValue, dimension = "id") {
const v = variableValue || {};
// 近12个月 & 近3个月 申请次数
const m12 = getApplicationCounts(v, "m12", dimension);
const m3 = getApplicationCounts(v, "m3", dimension);
const bankYearCount = m12.bank || 0;
const bank3mCount = m3.bank || 0;
const nbankYearCount = m12.nbank || 0;
const nbank3mCount = m3.nbank || 0;
// 使用风险等级来映射需求 / 频率文本
const bankYearRisk = calculateRiskLevel(bankYearCount);
const bank3mRisk = calculateRiskLevel(bank3mCount);
const nbankYearRisk = calculateRiskLevel(nbankYearCount);
const nbank3mRisk = calculateRiskLevel(nbank3mCount);
const bankDemandText = mapRiskToDemandText(bankYearRisk);
const bankFreqText = mapRiskToFrequencyText(bank3mRisk);
const nbankDemandText = mapRiskToDemandText(nbankYearRisk);
const nbankFreqText = mapRiskToFrequencyText(nbank3mRisk);
const advice =
"报告检测的是近12个月内的申请数据含同一机构。如果申请过于频繁会对评审有影响请保持良好的借贷习惯切勿频繁申请拒绝不明平台的审核邀请。";
const bankSituation =
`近一年申请次数:${bankYearCount}次,${bankDemandText}\n` +
`近3个月申请次数${bank3mCount}次,${bankFreqText}`;
const nbankSituation =
`近一年申请次数:${nbankYearCount}次,${nbankDemandText}\n` +
`近3个月申请次数${nbank3mCount}次,${nbankFreqText}`;
return {
bankSituation,
bankAdvice: advice,
nbankSituation,
nbankAdvice: advice,
};
}