2929
3030 <!-- 变更记录列表 -->
3131 <div class =" change-list" >
32- <ChangeCard
33- v-for =" item in filteredChangeItems"
34- :key =" item.id"
35- :item =" item"
36- />
37- <div v-if =" filteredChangeItems.length === 0" class =" no-results" >
38- 无匹配记录
32+ <!-- 加载状态 -->
33+ <div v-if =" deploymentLoading" class =" loading-container" >
34+ <el-icon class =" is-loading" ><Loading /></el-icon >
35+ <span >加载服务变更记录中...</span >
3936 </div >
37+ <!-- 数据列表 -->
38+ <template v-else >
39+ <ChangeCard
40+ v-for =" item in filteredChangeItems"
41+ :key =" item.id"
42+ :item =" item"
43+ />
44+ <div v-if =" filteredChangeItems.length === 0" class =" no-results" >
45+ 无匹配记录
46+ </div >
47+ </template >
4048 </div >
4149 </el-tab-pane >
4250
4351 <el-tab-pane label =" 告警变更记录" name =" alarm" >
4452 <div class =" change-list" >
45- <AlarmChangeCard
46- v-for =" item in alarmChangeItems"
47- :key =" item.id"
48- :item =" item"
49- />
53+ <!-- 加载状态 -->
54+ <div v-if =" alertRuleLoading" class =" loading-container" >
55+ <el-icon class =" is-loading" ><Loading /></el-icon >
56+ <span >加载告警变更记录中...</span >
57+ </div >
58+ <!-- 数据列表 -->
59+ <template v-else >
60+ <AlarmChangeCard
61+ v-for =" item in alarmChangeItems"
62+ :key =" item.id"
63+ :item =" item"
64+ />
65+ <div v-if =" alarmChangeItems.length === 0" class =" no-results" >
66+ 暂无告警变更记录
67+ </div >
68+ </template >
5069 </div >
5170 </el-tab-pane >
5271
6281</template >
6382
6483<script setup lang="ts">
65- import { ref , computed , onMounted } from ' vue'
84+ import { ref , computed , onMounted , watch } from ' vue'
6685import { useAppStore , type ChangeItem , type AlarmChangeItem } from ' @/stores/app'
6786import { mockApi } from ' @/mock/api'
6887import type { DeploymentChangelogResponse , DeploymentChangelogItem , AlertRuleChangelogResponse , AlertRuleChangeItem } from ' @/mock/services'
6988import ChangeCard from ' @/components/ChangeCard.vue'
7089import AlarmChangeCard from ' @/components/AlarmChangeCard.vue'
90+ import { ArrowLeft , Loading } from ' @element-plus/icons-vue'
7191
7292const appStore = useAppStore ()
7393
7494const activeTab = ref (' service' )
7595const searchKeyword = ref (' ' )
76- const loading = ref (false )
96+ const deploymentLoading = ref (false )
97+ const alertRuleLoading = ref (false )
7798const error = ref <string | null >(null )
7899
79100// 部署变更记录数据
@@ -158,8 +179,10 @@ const transformAlertRuleChangelogToAlarmChangeItems = (changelogData: AlertRuleC
158179
159180// 加载部署变更记录
160181const loadDeploymentChangelog = async (start ? : string , limit ? : number ) => {
182+ if (deploymentLoading .value ) return // 防止重复加载
183+
161184 try {
162- loading .value = true
185+ deploymentLoading .value = true
163186 error .value = null
164187
165188 const response = await mockApi .getDeploymentChangelog (start , limit )
@@ -173,14 +196,16 @@ const loadDeploymentChangelog = async (start?: string, limit?: number) => {
173196 error .value = ' 加载部署变更记录失败'
174197 console .error (' 加载部署变更记录失败:' , err )
175198 } finally {
176- loading .value = false
199+ deploymentLoading .value = false
177200 }
178201}
179202
180203// 加载告警规则变更记录
181204const loadAlertRuleChangelog = async (start ? : string , limit ? : number ) => {
205+ if (alertRuleLoading .value ) return // 防止重复加载
206+
182207 try {
183- loading .value = true
208+ alertRuleLoading .value = true
184209 error .value = null
185210
186211 const response = await mockApi .getAlertRuleChangelog (start , limit )
@@ -194,7 +219,7 @@ const loadAlertRuleChangelog = async (start?: string, limit?: number) => {
194219 error .value = ' 加载告警规则变更记录失败'
195220 console .error (' 加载告警规则变更记录失败:' , err )
196221 } finally {
197- loading .value = false
222+ alertRuleLoading .value = false
198223 }
199224}
200225
@@ -216,10 +241,18 @@ const handleSearch = () => {
216241 // 搜索逻辑已在计算属性中处理
217242}
218243
219- // 生命周期
244+ // 监听标签页切换,实现按需加载
245+ watch (activeTab , (newTab ) => {
246+ if (newTab === ' service' && ! changeItems .value .length ) {
247+ loadDeploymentChangelog ()
248+ } else if (newTab === ' alarm' && ! alarmChangeItems .value .length ) {
249+ loadAlertRuleChangelog ()
250+ }
251+ })
252+
253+ // 生命周期 - 只加载默认标签页数据
220254onMounted (() => {
221- loadDeploymentChangelog ()
222- loadAlertRuleChangelog ()
255+ loadDeploymentChangelog () // 只加载默认标签页
223256})
224257 </script >
225258
@@ -297,4 +330,14 @@ onMounted(() => {
297330 font-size : 14px ;
298331 padding : 32px ;
299332}
333+
334+ .loading-container {
335+ display : flex ;
336+ align-items : center ;
337+ justify-content : center ;
338+ gap : 8px ;
339+ padding : 32px ;
340+ color : #6b7280 ;
341+ font-size : 14px ;
342+ }
300343 </style >
0 commit comments