|
@@ -5,7 +5,7 @@
|
|
* @Author: xinyan
|
|
* @Author: xinyan
|
|
*/
|
|
*/
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
-import { ComputerColumns } from '/@/views/computer-information/useColumns';
|
|
|
|
|
|
+import { ComputerCurrentColumns, ComputerPastColumns } from '/@/views/computer-information/useColumns';
|
|
import * as api from '../api';
|
|
import * as api from '../api';
|
|
import { Picture as IconPicture } from '@element-plus/icons-vue';
|
|
import { Picture as IconPicture } from '@element-plus/icons-vue';
|
|
import { useTableData } from '/@/utils/useTableData';
|
|
import { useTableData } from '/@/utils/useTableData';
|
|
@@ -13,9 +13,10 @@ import { usePagination } from '/@/utils/usePagination';
|
|
|
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
const id = route.query.id;
|
|
const id = route.query.id;
|
|
|
|
+const computerNumber = route.query.computerNumber;
|
|
const computerOverview: any = ref([]);
|
|
const computerOverview: any = ref([]);
|
|
const overviewLoading = ref();
|
|
const overviewLoading = ref();
|
|
-const currentView = ref('history');
|
|
|
|
|
|
+const currentView = ref('current');
|
|
const { tableOptions, handlePageChange } = usePagination(fetchComputerData);
|
|
const { tableOptions, handlePageChange } = usePagination(fetchComputerData);
|
|
|
|
|
|
const gridOptions: any = reactive({
|
|
const gridOptions: any = reactive({
|
|
@@ -47,7 +48,7 @@ const gridOptions: any = reactive({
|
|
icon: 'vxe-icon-indicator roll',
|
|
icon: 'vxe-icon-indicator roll',
|
|
text: '正在拼命加载中...',
|
|
text: '正在拼命加载中...',
|
|
},
|
|
},
|
|
- columns: ComputerColumns,
|
|
|
|
|
|
+ columns: ComputerCurrentColumns,
|
|
data: [],
|
|
data: [],
|
|
});
|
|
});
|
|
|
|
|
|
@@ -58,27 +59,32 @@ function pageChange({ pageSize, currentPage }: any) {
|
|
}
|
|
}
|
|
|
|
|
|
// 当前信息、历史记录
|
|
// 当前信息、历史记录
|
|
-async function fetchComputerData(view) {
|
|
|
|
- if (view === currentView.value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+async function fetchComputerData(view) { // 默认为当前视图
|
|
|
|
+ const query = {
|
|
|
|
+ page: gridOptions.pagerConfig.page,
|
|
|
|
+ limit: gridOptions.pagerConfig.limit,
|
|
|
|
+ };
|
|
|
|
|
|
- const query = {
|
|
|
|
- id: id,
|
|
|
|
- page: gridOptions.pagerConfig.page,
|
|
|
|
- limit: gridOptions.pagerConfig.limit,
|
|
|
|
- };
|
|
|
|
|
|
+ switch (view) {
|
|
|
|
+ case 'current':
|
|
|
|
+ gridOptions.columns = ComputerCurrentColumns;
|
|
|
|
+ currentView.value = 'current';
|
|
|
|
+ query.computerNumber = computerNumber;
|
|
|
|
+ await useTableData(api.getCurrentTableData, query, gridOptions);
|
|
|
|
+ break;
|
|
|
|
+ case 'history':
|
|
|
|
+ gridOptions.columns = ComputerPastColumns;
|
|
|
|
+ currentView.value = 'history';
|
|
|
|
+ query.id = id;
|
|
|
|
+ await useTableData(api.getPastTableData, query, gridOptions);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
|
|
+function switchView(view) {
|
|
|
|
+ if (view !== currentView.value) { // 只有在不同的视图时才切换
|
|
|
|
+ fetchComputerData(view); // 调用 fetchComputerData 来加载新的视图数据
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
async function fetchComputerDetailOverview() {
|
|
async function fetchComputerDetailOverview() {
|
|
@@ -108,7 +114,7 @@ const headerCellStyle = () => {
|
|
};
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- fetchComputerData();
|
|
|
|
|
|
+ fetchComputerData(currentView.value);
|
|
fetchComputerDetailOverview();
|
|
fetchComputerDetailOverview();
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
@@ -167,8 +173,8 @@ onMounted(() => {
|
|
<el-card body-style="padding-top: 10px" class="mt-2.5" shadow="hover" style="border: none">
|
|
<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">
|
|
<vxe-grid :cell-style="cellStyle" :header-cell-style="headerCellStyle" v-bind="gridOptions">
|
|
<template #toolbar_buttons>
|
|
<template #toolbar_buttons>
|
|
- <el-button :type="currentView === 'current' ? 'primary' : 'default'" @click="fetchComputerData('current')"> 当前信息 </el-button>
|
|
|
|
- <el-button :type="currentView === 'history' ? 'primary' : 'default'" @click="fetchComputerData('history')"> 历史记录 </el-button>
|
|
|
|
|
|
+ <el-button :type="currentView === 'current' ? 'primary' : 'default'" @click="switchView('current')"> 当前信息 </el-button>
|
|
|
|
+ <el-button :type="currentView === 'history' ? 'primary' : 'default'" @click="switchView('history')"> 历史记录 </el-button>
|
|
</template>
|
|
</template>
|
|
<template #pager>
|
|
<template #pager>
|
|
<vxe-pager
|
|
<vxe-pager
|