接入结果总览风险真实接口
This commit is contained in:
@@ -22,7 +22,16 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mockOverviewData, mockOverviewStateData } from "./preliminaryCheck.mock";
|
||||
import {
|
||||
createOverviewLoadedData,
|
||||
mockOverviewData,
|
||||
mockOverviewStateData,
|
||||
} from "./preliminaryCheck.mock";
|
||||
import {
|
||||
getOverviewDashboard,
|
||||
getOverviewRiskPeople,
|
||||
getOverviewTopRiskPeople,
|
||||
} from "@/api/ccdi/projectOverview";
|
||||
import OverviewStats from "./OverviewStats";
|
||||
import RiskPeopleSection from "./RiskPeopleSection";
|
||||
import RiskModelSection from "./RiskModelSection";
|
||||
@@ -52,14 +61,75 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pageState: "loaded",
|
||||
pageState: "loading",
|
||||
mockData: mockOverviewData,
|
||||
stateDataMap: mockOverviewStateData,
|
||||
realData: mockOverviewData,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
currentData() {
|
||||
return this.stateDataMap[this.pageState] || this.mockData;
|
||||
if (this.pageState === "loaded") {
|
||||
return this.realData;
|
||||
}
|
||||
return this.stateDataMap[this.pageState] || this.realData;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
projectId(newVal) {
|
||||
if (newVal) {
|
||||
this.loadOverviewData();
|
||||
return;
|
||||
}
|
||||
this.realData = this.stateDataMap.empty;
|
||||
this.pageState = "empty";
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.projectId) {
|
||||
this.loadOverviewData();
|
||||
return;
|
||||
}
|
||||
this.realData = this.stateDataMap.empty;
|
||||
this.pageState = "empty";
|
||||
},
|
||||
methods: {
|
||||
async loadOverviewData() {
|
||||
if (!this.projectId) {
|
||||
this.realData = this.stateDataMap.empty;
|
||||
this.pageState = "empty";
|
||||
return;
|
||||
}
|
||||
|
||||
this.pageState = "loading";
|
||||
try {
|
||||
const [dashboardRes, riskPeopleRes, topRiskPeopleRes] = await Promise.all([
|
||||
getOverviewDashboard(this.projectId),
|
||||
getOverviewRiskPeople(this.projectId),
|
||||
getOverviewTopRiskPeople(this.projectId),
|
||||
]);
|
||||
const dashboardData = (dashboardRes && dashboardRes.data) || {};
|
||||
const riskPeopleData = (riskPeopleRes && riskPeopleRes.data) || {};
|
||||
const topRiskPeopleData = (topRiskPeopleRes && topRiskPeopleRes.data) || {};
|
||||
|
||||
this.realData = createOverviewLoadedData({
|
||||
dashboardData,
|
||||
riskPeopleData,
|
||||
topRiskPeopleData,
|
||||
});
|
||||
|
||||
const hasOverviewData = Boolean(
|
||||
(Array.isArray(dashboardData.stats) && dashboardData.stats.length) ||
|
||||
(Array.isArray(riskPeopleData.overviewList) && riskPeopleData.overviewList.length) ||
|
||||
(Array.isArray(topRiskPeopleData.topRiskList) && topRiskPeopleData.topRiskList.length)
|
||||
);
|
||||
|
||||
this.pageState = hasOverviewData ? "loaded" : "empty";
|
||||
} catch (error) {
|
||||
this.realData = this.stateDataMap.empty;
|
||||
this.pageState = "empty";
|
||||
console.error("加载结果总览失败", error);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user