接入结果总览模型卡片真实数据
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
getOverviewDashboard,
|
getOverviewDashboard,
|
||||||
getOverviewRiskPeople,
|
getOverviewRiskPeople,
|
||||||
|
getOverviewRiskModelCards,
|
||||||
} from "@/api/ccdi/projectOverview";
|
} from "@/api/ccdi/projectOverview";
|
||||||
import OverviewStats from "./OverviewStats";
|
import OverviewStats from "./OverviewStats";
|
||||||
import RiskPeopleSection from "./RiskPeopleSection";
|
import RiskPeopleSection from "./RiskPeopleSection";
|
||||||
@@ -102,21 +103,26 @@ export default {
|
|||||||
|
|
||||||
this.pageState = "loading";
|
this.pageState = "loading";
|
||||||
try {
|
try {
|
||||||
const [dashboardRes, riskPeopleRes] = await Promise.all([
|
const [dashboardRes, riskPeopleRes, riskModelCardsRes] = await Promise.all([
|
||||||
getOverviewDashboard(this.projectId),
|
getOverviewDashboard(this.projectId),
|
||||||
getOverviewRiskPeople(this.projectId),
|
getOverviewRiskPeople(this.projectId),
|
||||||
|
getOverviewRiskModelCards(this.projectId),
|
||||||
]);
|
]);
|
||||||
const dashboardData = (dashboardRes && dashboardRes.data) || {};
|
const dashboardData = (dashboardRes && dashboardRes.data) || {};
|
||||||
const riskPeopleData = (riskPeopleRes && riskPeopleRes.data) || {};
|
const riskPeopleData = (riskPeopleRes && riskPeopleRes.data) || {};
|
||||||
|
const riskModelCardsData = (riskModelCardsRes && riskModelCardsRes.data) || {};
|
||||||
|
|
||||||
this.realData = createOverviewLoadedData({
|
this.realData = createOverviewLoadedData({
|
||||||
|
projectId: this.projectId,
|
||||||
dashboardData,
|
dashboardData,
|
||||||
riskPeopleData,
|
riskPeopleData,
|
||||||
|
riskModelCardsData,
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasOverviewData = Boolean(
|
const hasOverviewData = Boolean(
|
||||||
(Array.isArray(dashboardData.stats) && dashboardData.stats.length) ||
|
(Array.isArray(dashboardData.stats) && dashboardData.stats.length) ||
|
||||||
(Array.isArray(riskPeopleData.overviewList) && riskPeopleData.overviewList.length)
|
(Array.isArray(riskPeopleData.overviewList) && riskPeopleData.overviewList.length) ||
|
||||||
|
(Array.isArray(riskModelCardsData.cardList) && riskModelCardsData.cardList.length)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.pageState = hasOverviewData ? "loaded" : "empty";
|
this.pageState = hasOverviewData ? "loaded" : "empty";
|
||||||
|
|||||||
@@ -54,20 +54,8 @@ export const mockOverviewData = {
|
|||||||
{ key: "salary", title: "可疑部门产薪异常", count: 32, peopleCount: 6 },
|
{ key: "salary", title: "可疑部门产薪异常", count: 32, peopleCount: 6 },
|
||||||
{ key: "transfer", title: "频繁转账交易", count: 28, peopleCount: 5 },
|
{ key: "transfer", title: "频繁转账交易", count: 28, peopleCount: 5 },
|
||||||
],
|
],
|
||||||
filterOptions: {
|
filterOptions: {},
|
||||||
modelOptions: [
|
filterValues: {},
|
||||||
{ label: "大额交易频繁", value: "large" },
|
|
||||||
{ label: "频繁转账交易", value: "transfer" },
|
|
||||||
],
|
|
||||||
warningTypeOptions: [
|
|
||||||
{ label: "高风险", value: "high" },
|
|
||||||
{ label: "中风险", value: "medium" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
filterValues: {
|
|
||||||
model: "large",
|
|
||||||
warningType: "high",
|
|
||||||
},
|
|
||||||
peopleList: [
|
peopleList: [
|
||||||
{
|
{
|
||||||
name: "黄明",
|
name: "黄明",
|
||||||
@@ -147,7 +135,19 @@ function normalizeSummaryStats(stats) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createOverviewLoadedData({ dashboardData, riskPeopleData } = {}) {
|
function normalizeRiskModelCards(cardList) {
|
||||||
|
if (!Array.isArray(cardList)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return cardList.map((item) => ({
|
||||||
|
key: item.modelCode,
|
||||||
|
title: item.modelName,
|
||||||
|
count: item.warningCount,
|
||||||
|
peopleCount: item.peopleCount,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createOverviewLoadedData({ projectId, dashboardData, riskPeopleData, riskModelCardsData } = {}) {
|
||||||
return {
|
return {
|
||||||
...mockOverviewData,
|
...mockOverviewData,
|
||||||
summary: {
|
summary: {
|
||||||
@@ -162,6 +162,13 @@ export function createOverviewLoadedData({ dashboardData, riskPeopleData } = {})
|
|||||||
? riskPeopleData.overviewList
|
? riskPeopleData.overviewList
|
||||||
: [],
|
: [],
|
||||||
},
|
},
|
||||||
|
riskModels: {
|
||||||
|
...mockOverviewData.riskModels,
|
||||||
|
projectId,
|
||||||
|
cardList: normalizeRiskModelCards(riskModelCardsData && riskModelCardsData.cardList),
|
||||||
|
peopleList: [],
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const preliminaryCheckSource = fs.readFileSync(
|
||||||
|
path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../src/views/ccdiProject/components/detail/PreliminaryCheck.vue"
|
||||||
|
),
|
||||||
|
"utf8"
|
||||||
|
);
|
||||||
|
|
||||||
|
const mockSource = fs.readFileSync(
|
||||||
|
path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../src/views/ccdiProject/components/detail/preliminaryCheck.mock.js"
|
||||||
|
),
|
||||||
|
"utf8"
|
||||||
|
);
|
||||||
|
|
||||||
|
[
|
||||||
|
"getOverviewRiskModelCards",
|
||||||
|
"riskModelCardsRes",
|
||||||
|
"riskModelCardsData",
|
||||||
|
"Promise.all",
|
||||||
|
"pageState === 'loading'",
|
||||||
|
"pageState === 'empty'",
|
||||||
|
'hasOverviewData ? "loaded" : "empty"',
|
||||||
|
].forEach((token) => assert(preliminaryCheckSource.includes(token), token));
|
||||||
|
|
||||||
|
[
|
||||||
|
"warningTypeOptions",
|
||||||
|
'model: "large"',
|
||||||
|
].forEach((token) => assert(!mockSource.includes(token), token));
|
||||||
Reference in New Issue
Block a user