feat:添加设备运行报表页面
parent
45a5c57728
commit
3e1c6ea398
@ -0,0 +1,31 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export interface DeviceOperationRecordVO {
|
||||
id: number
|
||||
deviceCode: string
|
||||
deviceName: string
|
||||
totalRunningTime: number
|
||||
totalStandbyTime: number
|
||||
totalFaultTime: number
|
||||
totalWarningTime: number
|
||||
utilizationRate: string
|
||||
}
|
||||
|
||||
export interface DeviceOperationRecordPageParams {
|
||||
pageNo: number
|
||||
pageSize: number
|
||||
deviceCode?: string
|
||||
deviceName?: string
|
||||
startTime?: string
|
||||
endTime?: string
|
||||
ids?: string
|
||||
}
|
||||
|
||||
export const DeviceOperationRecordApi = {
|
||||
getDeviceOperationRecordPage: async (params: DeviceOperationRecordPageParams) => {
|
||||
return await request.get({ url: `/iot/device-operation-record/deviceOperationPage`, params })
|
||||
},
|
||||
exportDeviceOperationReport: async (params: DeviceOperationRecordPageParams) => {
|
||||
return await request.download({ url: `/iot/device-operation-record/export-device-operation-report`, params })
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="120px">
|
||||
<el-form-item label="设备编码" prop="deviceCode">
|
||||
<el-input
|
||||
v-model="queryParams.deviceCode"
|
||||
placeholder="请输入设备编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="deviceName">
|
||||
<el-input
|
||||
v-model="queryParams.deviceName"
|
||||
placeholder="请输入设备名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备运行时间" prop="timeRange">
|
||||
<el-date-picker
|
||||
v-model="queryParams.timeRange"
|
||||
type="datetimerange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-360px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">
|
||||
<Icon icon="ep:search" class="mr-5px" /> 搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<Icon icon="ep:refresh" class="mr-5px" /> 重置
|
||||
</el-button>
|
||||
<el-button type="success" plain @click="handleExport" :loading="exportLoading">
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id">
|
||||
<el-table-column label="设备编码" align="left" prop="deviceCode" min-width="140px" />
|
||||
<el-table-column label="设备名称" align="left" prop="deviceName" min-width="160px" />
|
||||
<el-table-column label="运行时间(小时)" align="center" prop="totalRunningTime" min-width="140px" />
|
||||
<el-table-column label="待机时间(小时)" align="center" prop="totalStandbyTime" min-width="140px" />
|
||||
<el-table-column label="故障时间(小时)" align="center" prop="totalFaultTime" min-width="140px" />
|
||||
<el-table-column label="警告时间(小时)" align="center" prop="totalWarningTime" min-width="140px" />
|
||||
<el-table-column label="稼动率" align="center" prop="utilizationRate" min-width="120px" />
|
||||
<el-table-column label="设备运行开始时间" align="center" prop="startTime" min-width="120px" />
|
||||
<el-table-column label="设备运行结束时间" align="center" prop="endTime" min-width="120px" />
|
||||
</el-table>
|
||||
<Pagination
|
||||
:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import download from '@/utils/download'
|
||||
import { DeviceOperationRecordApi, type DeviceOperationRecordVO, type DeviceOperationRecordPageParams } from '@/api/iot/deviceOperationRecord'
|
||||
|
||||
defineOptions({ name: 'IotRunReport' })
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<DeviceOperationRecordVO[]>([])
|
||||
const total = ref(0)
|
||||
const exportLoading = ref(false)
|
||||
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
deviceCode: undefined as string | undefined,
|
||||
deviceName: undefined as string | undefined,
|
||||
timeRange: [] as string[] | [],
|
||||
startTime: undefined as string | undefined,
|
||||
endTime: undefined as string | undefined,
|
||||
ids: undefined as string | undefined
|
||||
})
|
||||
|
||||
const queryFormRef = ref()
|
||||
const getList = async () => {
|
||||
const range = (queryParams.timeRange || []) as string[]
|
||||
queryParams.startTime = range[0]
|
||||
queryParams.endTime = range[1]
|
||||
loading.value = true
|
||||
try {
|
||||
const params = queryParams as unknown as DeviceOperationRecordPageParams
|
||||
const data = await DeviceOperationRecordApi.getDeviceOperationRecordPage(params)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields?.()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await useMessage().exportConfirm()
|
||||
exportLoading.value = true
|
||||
const range = (queryParams.timeRange || []) as string[]
|
||||
queryParams.startTime = range[0]
|
||||
queryParams.endTime = range[1]
|
||||
const params = queryParams as unknown as DeviceOperationRecordPageParams
|
||||
const data = await DeviceOperationRecordApi.exportDeviceOperationReport(params)
|
||||
download.excel(data, '设备运行报表.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue