|
@@ -1,3 +1,103 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
+
|
|
|
+import { useRequest } from '@/hooks/request';
|
|
|
+import { getDevWorkRealTimeData, getDevWorkTypeCount, queryDevicesList } from '@/api';
|
|
|
+
|
|
|
+import { deviceCardData, DeviceType } from './device-card';
|
|
|
+
|
|
|
+import type { DevicesListItem, DeviceTypeCount, PageParams } from '@/types';
|
|
|
+
|
|
|
+const { handleRequest } = useRequest();
|
|
|
+const deviceTypes = ref<DeviceTypeCount[]>([]);
|
|
|
+const activeDeviceType = ref<DeviceType>(DeviceType.空);
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ handleRequest(async () => {
|
|
|
+ deviceTypes.value = await getDevWorkTypeCount(7);
|
|
|
+
|
|
|
+ if (deviceTypes.value.length) {
|
|
|
+ activeDeviceType.value = deviceTypes.value[0].deviceType;
|
|
|
+ getDeviceList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+const deviceList = ref<DevicesListItem[]>([]);
|
|
|
+const deviceTotal = ref(0);
|
|
|
+const pageParams = ref<PageParams>({
|
|
|
+ pageIndex: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ pageSorts: [
|
|
|
+ {
|
|
|
+ column: 'id',
|
|
|
+ asc: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+});
|
|
|
+
|
|
|
+const getDeviceList = () => {
|
|
|
+ handleRequest(async () => {
|
|
|
+ const { records, total } = await queryDevicesList({
|
|
|
+ ...pageParams.value,
|
|
|
+ deviceType: activeDeviceType.value,
|
|
|
+ });
|
|
|
+
|
|
|
+ const deviceIds = records.map((item) => item.id);
|
|
|
+ const deviceParamCode = deviceCardData[activeDeviceType.value]?.paramCodes || [];
|
|
|
+
|
|
|
+ await getDevWorkRealTimeData(deviceIds, deviceParamCode);
|
|
|
+
|
|
|
+ deviceList.value = records;
|
|
|
+ deviceTotal.value = total;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleTabClick = () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ pageParams.value.pageIndex = 1;
|
|
|
+ getDeviceList();
|
|
|
+ }, 0);
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
<template>
|
|
|
- <div>设备工况</div>
|
|
|
+ <div>
|
|
|
+ <ATabs class="button-tabs-card" v-model:active-key="activeDeviceType" type="card" @tab-click="handleTabClick">
|
|
|
+ <ATabPane v-for="item in deviceTypes" :key="item.deviceType" :tab="`${item.deviceTypeName}(${item.count})`" />
|
|
|
+ </ATabs>
|
|
|
+ <ARow :gutter="[22, 24]">
|
|
|
+ <ACol v-for="item in deviceList" :key="item.id" :xs="24" :sm="24" :md="24" :lg="12" :xl="12" :xxl="8">
|
|
|
+ <div class="device-card-container">
|
|
|
+ <div class="device-card-header">
|
|
|
+ <div class="device-card-header-title">{{ item.deviceName }}</div>
|
|
|
+ </div>
|
|
|
+ <component :is="deviceCardData[activeDeviceType]?.component" />
|
|
|
+ </div>
|
|
|
+ </ACol>
|
|
|
+ </ARow>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.device-card-container {
|
|
|
+ height: 328px;
|
|
|
+ padding: 16px 24px;
|
|
|
+ background-color: #fff;
|
|
|
+ border-radius: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.device-card-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.device-card-header-title {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 28px;
|
|
|
+ color: var(--antd-color-text);
|
|
|
+}
|
|
|
+</style>
|