接入结果总览模型卡片真实数据
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
import {
|
||||
getOverviewDashboard,
|
||||
getOverviewRiskPeople,
|
||||
getOverviewRiskModelCards,
|
||||
} from "@/api/ccdi/projectOverview";
|
||||
import OverviewStats from "./OverviewStats";
|
||||
import RiskPeopleSection from "./RiskPeopleSection";
|
||||
@@ -102,21 +103,26 @@ export default {
|
||||
|
||||
this.pageState = "loading";
|
||||
try {
|
||||
const [dashboardRes, riskPeopleRes] = await Promise.all([
|
||||
const [dashboardRes, riskPeopleRes, riskModelCardsRes] = await Promise.all([
|
||||
getOverviewDashboard(this.projectId),
|
||||
getOverviewRiskPeople(this.projectId),
|
||||
getOverviewRiskModelCards(this.projectId),
|
||||
]);
|
||||
const dashboardData = (dashboardRes && dashboardRes.data) || {};
|
||||
const riskPeopleData = (riskPeopleRes && riskPeopleRes.data) || {};
|
||||
const riskModelCardsData = (riskModelCardsRes && riskModelCardsRes.data) || {};
|
||||
|
||||
this.realData = createOverviewLoadedData({
|
||||
projectId: this.projectId,
|
||||
dashboardData,
|
||||
riskPeopleData,
|
||||
riskModelCardsData,
|
||||
});
|
||||
|
||||
const hasOverviewData = Boolean(
|
||||
(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";
|
||||
|
||||
@@ -54,20 +54,8 @@ export const mockOverviewData = {
|
||||
{ key: "salary", title: "可疑部门产薪异常", count: 32, peopleCount: 6 },
|
||||
{ key: "transfer", title: "频繁转账交易", count: 28, peopleCount: 5 },
|
||||
],
|
||||
filterOptions: {
|
||||
modelOptions: [
|
||||
{ label: "大额交易频繁", value: "large" },
|
||||
{ label: "频繁转账交易", value: "transfer" },
|
||||
],
|
||||
warningTypeOptions: [
|
||||
{ label: "高风险", value: "high" },
|
||||
{ label: "中风险", value: "medium" },
|
||||
],
|
||||
},
|
||||
filterValues: {
|
||||
model: "large",
|
||||
warningType: "high",
|
||||
},
|
||||
filterOptions: {},
|
||||
filterValues: {},
|
||||
peopleList: [
|
||||
{
|
||||
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 {
|
||||
...mockOverviewData,
|
||||
summary: {
|
||||
@@ -162,6 +162,13 @@ export function createOverviewLoadedData({ dashboardData, riskPeopleData } = {})
|
||||
? 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