Parcourir la source

🎨 feat:电脑信息界面修改

xinyan il y a 8 mois
Parent
commit
ece1b17571
1 fichiers modifiés avec 13 ajouts et 7 suppressions
  1. 13 7
      src/views/computer-information/components/ComputerDetail.vue

+ 13 - 7
src/views/computer-information/components/ComputerDetail.vue

@@ -58,20 +58,26 @@ function pageChange({ pageSize, currentPage }: any) {
 }
 
 // 当前信息、历史记录
-async function fetchComputerData() {
+async function fetchComputerData(view) {
+	if (view === currentView.value) {
+		return;
+	}
+
 	const query = {
 		id: id,
 		page: gridOptions.pagerConfig.page,
 		limit: gridOptions.pagerConfig.limit,
 	};
-	switch (currentView.value) {
+
+	switch (view) {
 		case 'current':
+			currentView.value = 'current';
+			await useTableData(api.getCurrentTableData, query, gridOptions);
+			break;
+		case 'history':
 			currentView.value = 'history';
 			await useTableData(api.getPastTableData, query, gridOptions);
 			break;
-		case 'history':
-			currentView.value = 'current';
-			await useTableData(api.getCurrentTableData, query, gridOptions);
 	}
 }
 
@@ -161,8 +167,8 @@ onMounted(() => {
 		<el-card body-style="padding-top: 10px" class="mt-2.5" shadow="hover" style="border: none">
 			<vxe-grid :cell-style="cellStyle" :header-cell-style="headerCellStyle" v-bind="gridOptions">
 				<template #toolbar_buttons>
-					<el-button :type="currentView === 'current' ? 'primary' : 'default'" @click="fetchComputerData"> 当前信息 </el-button>
-					<el-button :type="currentView === 'history' ? 'primary' : 'default'" @click="fetchComputerData"> 历史记录 </el-button>
+					<el-button :type="currentView === 'current' ? 'primary' : 'default'" @click="fetchComputerData('current')"> 当前信息 </el-button>
+					<el-button :type="currentView === 'history' ? 'primary' : 'default'" @click="fetchComputerData('history')"> 历史记录 </el-button>
 				</template>
 				<template #pager>
 					<vxe-pager