|
|
@@ -0,0 +1,231 @@
|
|
|
+<script lang="ts" setup>
|
|
|
+import { IotDeviceApi } from '@/api/pms/device'
|
|
|
+import { useTableComponents } from '@/components/ZmTable/useTableComponents'
|
|
|
+import { useUserStore } from '@/store/modules/user'
|
|
|
+import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
|
|
+import { rangeShortcuts } from '@/utils/formatTime'
|
|
|
+import { useDebounceFn } from '@vueuse/core'
|
|
|
+
|
|
|
+const { t } = useI18n()
|
|
|
+
|
|
|
+const id = useUserStore().getUser.deptId ?? 157
|
|
|
+
|
|
|
+const deptId = id
|
|
|
+
|
|
|
+interface Query {
|
|
|
+ deptId?: number
|
|
|
+ deviceName?: string
|
|
|
+ deviceCode?: string
|
|
|
+ ifInline?: number
|
|
|
+ pageNo: number
|
|
|
+ pageSize: number
|
|
|
+ time: string[]
|
|
|
+}
|
|
|
+
|
|
|
+const query = ref<Query>({
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 12,
|
|
|
+ deptId: id,
|
|
|
+ time: []
|
|
|
+})
|
|
|
+
|
|
|
+interface OliDevice {
|
|
|
+ id: number
|
|
|
+ carId?: number
|
|
|
+ deviceName: string
|
|
|
+ deviceCode: string
|
|
|
+ assetClassName: string
|
|
|
+ deviceStatus: string
|
|
|
+ ifInline: number
|
|
|
+ lastInlineTime: string
|
|
|
+ carOnline: string
|
|
|
+ deptName: string
|
|
|
+ vehicleName: string
|
|
|
+}
|
|
|
+
|
|
|
+const list = ref<OliDevice[]>([])
|
|
|
+const total = ref(0)
|
|
|
+
|
|
|
+const loading = ref(false)
|
|
|
+
|
|
|
+const loadList = useDebounceFn(async function () {
|
|
|
+ loading.value = true
|
|
|
+ try {
|
|
|
+ const data = await IotDeviceApi.getIotDeviceOliConnectPage(query.value)
|
|
|
+ // const data = await IotDeviceApi.getIotDeviceTdPage(query.value)
|
|
|
+ list.value = data.list
|
|
|
+ total.value = data.total
|
|
|
+ } finally {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+function handleSizeChange(val: number) {
|
|
|
+ query.value.pageSize = val
|
|
|
+ handleQuery()
|
|
|
+}
|
|
|
+
|
|
|
+function handleCurrentChange(val: number) {
|
|
|
+ query.value.pageNo = val
|
|
|
+ loadList()
|
|
|
+}
|
|
|
+
|
|
|
+function handleQuery(setPage = true) {
|
|
|
+ if (setPage) {
|
|
|
+ query.value.pageNo = 1
|
|
|
+ }
|
|
|
+ loadList()
|
|
|
+}
|
|
|
+
|
|
|
+function resetQuery() {
|
|
|
+ query.value = {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 12,
|
|
|
+ deptId: id,
|
|
|
+ time: []
|
|
|
+ }
|
|
|
+
|
|
|
+ handleQuery()
|
|
|
+}
|
|
|
+
|
|
|
+watch(
|
|
|
+ [
|
|
|
+ () => query.value.deptId,
|
|
|
+ () => query.value.deviceName,
|
|
|
+ () => query.value.deviceCode,
|
|
|
+ () => query.value.ifInline
|
|
|
+ ],
|
|
|
+ () => {
|
|
|
+ handleQuery()
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+)
|
|
|
+
|
|
|
+const { ZmTable, ZmTableColumn } = useTableComponents<OliDevice>()
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div
|
|
|
+ class="grid grid-cols-[15%_1fr] grid-rows-[62px_1fr] gap-4 h-[calc(100vh-20px-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height))]"
|
|
|
+ >
|
|
|
+ <div class="p-4 bg-white dark:bg-[#1d1e1f] shadow rounded-lg row-span-2">
|
|
|
+ <DeptTreeSelect
|
|
|
+ :top-id="156"
|
|
|
+ :deptId="deptId"
|
|
|
+ v-model="query.deptId"
|
|
|
+ :init-select="false"
|
|
|
+ :show-title="false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <el-form
|
|
|
+ size="default"
|
|
|
+ class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow px-8 gap-8 flex items-center justify-between"
|
|
|
+ >
|
|
|
+ <div class="flex items-center gap-8">
|
|
|
+ <el-form-item :label="t('monitor.deviceName')">
|
|
|
+ <el-input
|
|
|
+ v-model="query.deviceName"
|
|
|
+ :placeholder="t('monitor.nameHolder')"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery()"
|
|
|
+ class="!w-240px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="t('monitor.deviceCode')">
|
|
|
+ <el-input
|
|
|
+ v-model="query.deviceCode"
|
|
|
+ :placeholder="t('monitor.codeHolder')"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery()"
|
|
|
+ class="!w-240px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item :label="t('monitor.ifInline')">
|
|
|
+ <el-select
|
|
|
+ v-model="query.ifInline"
|
|
|
+ :placeholder="t('monitor.ifInlineHolder')"
|
|
|
+ clearable
|
|
|
+ class="!w-240px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in getStrDictOptions(DICT_TYPE.IOT_DEVICE_STATUS)"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="时间">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="query.time"
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ type="daterange"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ :shortcuts="rangeShortcuts"
|
|
|
+ :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
|
|
+ class="!w-220px"
|
|
|
+ />
|
|
|
+ </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-form-item>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ <div class="bg-white dark:bg-[#1d1e1f] shadow rounded-lg flex flex-col p-4">
|
|
|
+ <div class="flex-1 relative">
|
|
|
+ <el-auto-resizer class="absolute">
|
|
|
+ <template #default="{ width, height }">
|
|
|
+ <zm-table
|
|
|
+ :data="list"
|
|
|
+ :loading="loading"
|
|
|
+ :width="width"
|
|
|
+ :max-height="height"
|
|
|
+ :height="height"
|
|
|
+ >
|
|
|
+ <zm-table-column type="index" :label="t('monitor.serial')" :width="60" />
|
|
|
+ <zm-table-column prop="deviceName" :label="t('monitor.deviceName')" />
|
|
|
+ <zm-table-column prop="deviceCode" :label="t('monitor.deviceCode')" />
|
|
|
+ <zm-table-column prop="assetClassName" :label="t('monitor.category')" />
|
|
|
+ <zm-table-column prop="deviceStatus" :label="t('monitor.status')">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :type="DICT_TYPE.PMS_DEVICE_STATUS" :value="scope.row.deviceStatus" />
|
|
|
+ </template>
|
|
|
+ </zm-table-column>
|
|
|
+ <zm-table-column prop="ifInline" :label="t('monitor.ifInline')">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :type="DICT_TYPE.IOT_DEVICE_STATUS" :value="scope.row.ifInline" />
|
|
|
+ </template>
|
|
|
+ </zm-table-column>
|
|
|
+ <zm-table-column prop="lastInlineTime" :label="t('monitor.latestDataTime')" />
|
|
|
+ </zm-table>
|
|
|
+ </template>
|
|
|
+ </el-auto-resizer>
|
|
|
+ </div>
|
|
|
+ <div class="h-10 mt-4 flex items-center justify-end">
|
|
|
+ <el-pagination
|
|
|
+ size="default"
|
|
|
+ v-show="total > 0"
|
|
|
+ v-model:current-page="query.pageNo"
|
|
|
+ v-model:page-size="query.pageSize"
|
|
|
+ :background="true"
|
|
|
+ :page-sizes="[12, 20, 30, 50, 100]"
|
|
|
+ :total="total"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+:deep(.el-form-item) {
|
|
|
+ margin-bottom: 0;
|
|
|
+}
|
|
|
+</style>
|