style: code state
This commit is contained in:
@@ -14,7 +14,7 @@ import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderF
|
|||||||
import { downloadByData } from '@/utils';
|
import { downloadByData } from '@/utils';
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { NButton, NCol, NDataTable, NModal, NRow, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
import { NButton, NDataTable, NGrid, NGridItem, NModal, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
||||||
import { computed, h, reactive, ref, toRefs } from 'vue';
|
import { computed, h, reactive, ref, toRefs } from 'vue';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -125,7 +125,7 @@ const resetFilterFields = () => {
|
|||||||
filterFields.faultLevel_in = [];
|
filterFields.faultLevel_in = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const tablePagination = reactive<PaginationProps>({
|
const pagination = reactive<PaginationProps>({
|
||||||
size: 'small',
|
size: 'small',
|
||||||
showSizePicker: true,
|
showSizePicker: true,
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -135,27 +135,27 @@ const tablePagination = reactive<PaginationProps>({
|
|||||||
return h('div', {}, { default: () => `共${itemCount}条` });
|
return h('div', {}, { default: () => `共${itemCount}条` });
|
||||||
},
|
},
|
||||||
onUpdatePage: (page: number) => {
|
onUpdatePage: (page: number) => {
|
||||||
tablePagination.page = page;
|
pagination.page = page;
|
||||||
getStaionAlarmList();
|
getTableData();
|
||||||
},
|
},
|
||||||
onUpdatePageSize: (pageSize: number) => {
|
onUpdatePageSize: (pageSize: number) => {
|
||||||
tablePagination.pageSize = pageSize;
|
pagination.pageSize = pageSize;
|
||||||
tablePagination.page = 1;
|
pagination.page = 1;
|
||||||
getStaionAlarmList();
|
getTableData();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const tableData = ref<DataTableRowData[]>([]);
|
const tableData = ref<DataTableRowData[]>([]);
|
||||||
|
|
||||||
const onAfterModalEnter = () => {
|
const onAfterModalEnter = () => {
|
||||||
getStaionAlarmList();
|
getTableData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAfterModalLeave = () => {
|
const onAfterModalLeave = () => {
|
||||||
resetFilterFields();
|
resetFilterFields();
|
||||||
tablePagination.page = 1;
|
pagination.page = 1;
|
||||||
tablePagination.pageSize = 10;
|
pagination.pageSize = 10;
|
||||||
tablePagination.itemCount = 0;
|
pagination.itemCount = 0;
|
||||||
tableData.value = [];
|
tableData.value = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -168,10 +168,10 @@ const onUpdateFilters: DataTableProps['onUpdateFilters'] = (filterState) => {
|
|||||||
filterFields.alarmType_in = alarmTypeKeys;
|
filterFields.alarmType_in = alarmTypeKeys;
|
||||||
const faultLevelVals = filterState['faultLevel'];
|
const faultLevelVals = filterState['faultLevel'];
|
||||||
filterFields.faultLevel_in = faultLevelVals;
|
filterFields.faultLevel_in = faultLevelVals;
|
||||||
getStaionAlarmList();
|
getTableData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
const { mutate: getTableData, isPending: loading } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
const res = await pageDeviceAlarmLogApi(
|
const res = await pageDeviceAlarmLogApi(
|
||||||
@@ -188,8 +188,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
|||||||
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||||
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||||
},
|
},
|
||||||
current: tablePagination.page ?? 1,
|
current: pagination.page ?? 1,
|
||||||
size: tablePagination.pageSize ?? 10,
|
size: pagination.pageSize ?? 10,
|
||||||
order: 'descending',
|
order: 'descending',
|
||||||
sort: 'id',
|
sort: 'id',
|
||||||
},
|
},
|
||||||
@@ -201,8 +201,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
|||||||
},
|
},
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
const { records, size, total } = res;
|
const { records, size, total } = res;
|
||||||
tablePagination.pageSize = parseInt(size);
|
pagination.pageSize = parseInt(size);
|
||||||
tablePagination.itemCount = parseInt(total);
|
pagination.itemCount = parseInt(total);
|
||||||
tableData.value = records;
|
tableData.value = records;
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
@@ -226,8 +226,8 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
|||||||
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||||
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||||
},
|
},
|
||||||
current: tablePagination.page ?? 1,
|
current: pagination.page ?? 1,
|
||||||
size: tablePagination.pageSize ?? 10,
|
size: pagination.pageSize ?? 10,
|
||||||
order: 'descending',
|
order: 'descending',
|
||||||
sort: 'id',
|
sort: 'id',
|
||||||
},
|
},
|
||||||
@@ -264,11 +264,11 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
|||||||
</div>
|
</div>
|
||||||
<div v-else style="height: 100%; display: flex; flex-direction: column">
|
<div v-else style="height: 100%; display: flex; flex-direction: column">
|
||||||
<div style="flex: 0 0 auto; margin-bottom: 16px">
|
<div style="flex: 0 0 auto; margin-bottom: 16px">
|
||||||
<NRow>
|
<NGrid cols="9">
|
||||||
<NCol :span="3" v-for="item in classifiedAlarmCounts" :key="item.label">
|
<NGridItem v-for="item in classifiedAlarmCounts" :key="item.label" span="1">
|
||||||
<NStatistic :label="item.label + '告警'" :value="item.count" />
|
<NStatistic :label="item.label + '告警'" :value="item.count" />
|
||||||
</NCol>
|
</NGridItem>
|
||||||
</NRow>
|
</NGrid>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex: 0 0 auto; display: flex; align-items: center; padding: 8px 0">
|
<div style="flex: 0 0 auto; display: flex; align-items: center; padding: 8px 0">
|
||||||
<div style="font-size: medium">今日设备告警列表</div>
|
<div style="font-size: medium">今日设备告警列表</div>
|
||||||
@@ -278,10 +278,10 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
|||||||
</div>
|
</div>
|
||||||
<div style="flex: 1 1 auto; min-height: 0">
|
<div style="flex: 1 1 auto; min-height: 0">
|
||||||
<NDataTable
|
<NDataTable
|
||||||
:loading="tableLoading"
|
:loading="loading"
|
||||||
:columns="tableColumns"
|
:columns="tableColumns"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
:pagination="tablePagination"
|
:pagination="pagination"
|
||||||
:single-line="false"
|
:single-line="false"
|
||||||
remote
|
remote
|
||||||
flex-height
|
flex-height
|
||||||
|
|||||||
Reference in New Issue
Block a user