Browse Source

perf: 新增device菜单以及优化名字

曾坤森 1 week ago
parent
commit
c2d906b9f0

+ 1 - 1
.vscode/settings.json

@@ -3,7 +3,7 @@
     "src/locale",
     "src/components/message-box/locale",
     "src/views/login/locale",
-    "src/views/dashboard/workplace/locale",
+    "src/views/dashboard/alam/locale",
     "src/views/exception/403/locale",
     "src/views/exception/404/locale",
     "src/views/exception/500/locale",

+ 4 - 58
src/api/dashboard.ts

@@ -1,15 +1,5 @@
-import type { TableData } from '@arco-design/web-vue/es/table/interface';
 import instance from './interceptor';
-export interface RootObject {
-  pageIndex: number;
-  pageSize: number;
-  name: string;
-  address: string;
-  status: number;
-  startTime: string;
-  endTime: string;
-  entityType: number;
-}
+
 export interface DataList {
   id?: number;
   entityType: number | null;
@@ -21,14 +11,7 @@ export interface DataList {
   data?: string;
   routeInfoId?: number | null;
 }
-
-export interface ExportUrl {
-  success: boolean;
-  message: string;
-  code: string;
-  data: string;
-}
-export interface DashboardList {
+export interface DeviceList {
   success: boolean;
   message: string;
   code: string;
@@ -36,44 +19,7 @@ export interface DashboardList {
   totalCount: number;
   totalPage: number;
 }
-export interface DashboardParams {
-  pageIndex: number;
-  pageSize: number;
-  name: string | null;
-  address: string | null;
-  status: number | null;
-  time: [string, string];
-  startTime: string | null;
-  endTime: string | null;
-  entityType: number | null;
-  station?: string | null;
-}
-export interface LoginRes {
-  success: boolean;
-  data: DataList;
-  message: string;
-  code: string;
-}
-export async function queryDashboardList(
-  params: object
-): Promise<DashboardList> {
-  const res = await instance.post('/api/Author/GetDeviceList', params);
-  return res.data;
-}
-export async function exportDashboardList(params: object): Promise<ExportUrl> {
-  const res = await instance.post('/api/Author/Export', params);
-  return res.data;
-}
-
-export async function getDeviceDetails(params: object): Promise<LoginRes> {
-  const res = await instance.post('/api/Author/GetDevice', params);
-  return res.data;
-}
-export async function saveDeviceDetails(params: object): Promise<LoginRes> {
-  const res = await instance.post('/api/Author/SaveDevice', params);
-  return res.data;
-}
-export async function deleteDeviceDetails(params: object): Promise<LoginRes> {
-  const res = await instance.post('/api/Author/DeleteDevice', params);
+export async function fetchAlarmTotalList(params: object): Promise<DeviceList> {
+  const res = await instance.post('/api/Author/AlarmDeviceList', params);
   return res.data;
 }

+ 77 - 0
src/api/device.ts

@@ -0,0 +1,77 @@
+import type { TableData } from '@arco-design/web-vue/es/table/interface';
+import instance from './interceptor';
+export interface RootObject {
+  pageIndex: number;
+  pageSize: number;
+  name: string;
+  address: string;
+  status: number;
+  startTime: string;
+  endTime: string;
+  entityType: number;
+}
+export interface DataList {
+  id?: number;
+  entityType: number | null;
+  deviceType: number | null;
+  name: string;
+  address: string;
+  status?: number;
+  time?: string;
+  data?: string;
+  routeInfoId?: number | null;
+}
+
+export interface ExportUrl {
+  success: boolean;
+  message: string;
+  code: string;
+  data: string;
+}
+export interface DeviceList {
+  success: boolean;
+  message: string;
+  code: string;
+  data: DataList[];
+  totalCount: number;
+  totalPage: number;
+}
+export interface DeviceParams {
+  pageIndex: number;
+  pageSize: number;
+  name: string | null;
+  address: string | null;
+  status: number | null;
+  time: [string, string];
+  startTime: string | null;
+  endTime: string | null;
+  entityType: number | null;
+  station?: string | null;
+}
+export interface LoginRes {
+  success: boolean;
+  data: DataList;
+  message: string;
+  code: string;
+}
+export async function queryDeviceList(params: object): Promise<DeviceList> {
+  const res = await instance.post('/api/Author/GetDeviceList', params);
+  return res.data;
+}
+export async function exportDeviceList(params: object): Promise<ExportUrl> {
+  const res = await instance.post('/api/Author/Export', params);
+  return res.data;
+}
+
+export async function getDeviceDetails(params: object): Promise<LoginRes> {
+  const res = await instance.post('/api/Author/GetDevice', params);
+  return res.data;
+}
+export async function saveDeviceDetails(params: object): Promise<LoginRes> {
+  const res = await instance.post('/api/Author/SaveDevice', params);
+  return res.data;
+}
+export async function deleteDeviceDetails(params: object): Promise<LoginRes> {
+  const res = await instance.post('/api/Author/DeleteDevice', params);
+  return res.data;
+}

+ 6 - 3
src/locale/en-US.ts

@@ -1,7 +1,8 @@
 import localeMessageBox from '@/components/message-box/locale/en-US';
 import localeLogin from '@/views/login/locale/en-US';
 
-import localeWorkplace from '@/views/dashboard/workplace/locale/en-US';
+import localeDevice from '@/views/device/status/locale/en-US';
+import localeAlam from '@/views/dashboard/alam/locale/en-US';
 
 import locale403 from '@/views/exception/403/locale/en-US';
 import locale404 from '@/views/exception/404/locale/en-US';
@@ -16,8 +17,9 @@ import localeComponent from './en-US/component';
 
 export default {
   'menu.dashboard': 'Dashboard',
+  'menu.device': 'Device',
   'menu.exception': 'Exception',
-  'menu.system': 'System',
+  'menu.system': 'Setting',
   'menu.user': 'User Center',
   'menu.home': 'Home',
   'menu.arcoWebsite': 'Arco Design',
@@ -40,7 +42,7 @@ export default {
   ...localeSettings,
   ...localeMessageBox,
   ...localeLogin,
-  ...localeWorkplace,
+  ...localeDevice,
   ...locale403,
   ...locale404,
   ...locale500,
@@ -48,4 +50,5 @@ export default {
   ...localeManageSetting,
   ...localeComponent,
   ...localeDict,
+  ...localeAlam,
 };

+ 6 - 2
src/locale/zh-CN.ts

@@ -1,7 +1,9 @@
 import localeMessageBox from '@/components/message-box/locale/zh-CN';
 import localeLogin from '@/views/login/locale/zh-CN';
 
-import localeWorkplace from '@/views/dashboard/workplace/locale/zh-CN';
+import localeDevice from '@/views/device/status/locale/zh-CN';
+import localeAlam from '@/views/dashboard/alam/locale/zh-CN';
+
 import localeDict from '@/views/system/dict/locale/zh-CN';
 
 import locale403 from '@/views/exception/403/locale/zh-CN';
@@ -16,6 +18,7 @@ import localeComponent from './zh-CN/component';
 
 export default {
   'menu.dashboard': '仪表盘',
+  'menu.device': '设备',
   'menu.exception': '异常页',
   'menu.system': '系统设置',
   'menu.user': '个人中心',
@@ -39,7 +42,7 @@ export default {
   ...localeSettings,
   ...localeMessageBox,
   ...localeLogin,
-  ...localeWorkplace,
+  ...localeDevice,
   ...locale403,
   ...locale404,
   ...locale500,
@@ -47,4 +50,5 @@ export default {
   ...localeManageSetting,
   ...localeComponent,
   ...localeDict,
+  ...localeAlam,
 };

+ 4 - 14
src/router/routes/modules/dashboard.ts

@@ -13,21 +13,11 @@ const DASHBOARD: AppRouteRecordRaw = {
   },
   children: [
     {
-      path: 'device-status',
-      name: 'DeviceStatus',
-      component: () => import('@/views/dashboard/workplace/index.vue'),
+      path: 'alam',
+      name: 'AlamList',
+      component: () => import('@/views/dashboard/alam/index.vue'),
       meta: {
-        locale: 'menu.dashboard.status',
-        requiresAuth: true,
-        roles: ['*'],
-      },
-    },
-    {
-      path: 'device-manage',
-      name: 'DeviceManage',
-      component: () => import('@/views/dashboard/manage/index.vue'),
-      meta: {
-        locale: 'menu.dashboard.manage',
+        locale: 'menu.dashboard.alam',
         requiresAuth: true,
         roles: ['*'],
       },

+ 38 - 0
src/router/routes/modules/device.ts

@@ -0,0 +1,38 @@
+import { DEFAULT_LAYOUT } from '../base';
+import { AppRouteRecordRaw } from '../types';
+
+const DEVICE: AppRouteRecordRaw = {
+  path: '/device',
+  name: 'device',
+  component: DEFAULT_LAYOUT,
+  meta: {
+    locale: 'menu.device',
+    requiresAuth: true,
+    icon: 'icon-list',
+    order: 0,
+  },
+  children: [
+    {
+      path: 'status',
+      name: 'DeviceStatus',
+      component: () => import('@/views/device/status/index.vue'),
+      meta: {
+        locale: 'menu.device.status',
+        requiresAuth: true,
+        roles: ['*'],
+      },
+    },
+    {
+      path: 'manage',
+      name: 'DeviceManage',
+      component: () => import('@/views/device/manage/index.vue'),
+      meta: {
+        locale: 'menu.device.manage',
+        requiresAuth: true,
+        roles: ['*'],
+      },
+    },
+  ],
+};
+
+export default DEVICE;

+ 188 - 0
src/views/dashboard/alam/index.vue

@@ -0,0 +1,188 @@
+<template>
+  <div class="container">
+    <a-card class="general-card">
+      <a-table
+        row-key="name"
+        :loading="loading"
+        :pagination="pagination"
+        :columns="cloneColumns"
+        :data="tableData"
+        :bordered="false"
+        :size="size"
+        :scrollbar="true"
+        @page-change="onPageChange"
+        @row-dblclick="handleClick"
+      >
+        <template #index="{ rowIndex }">
+          {{ rowIndex + 1 + (pagination.current - 1) * pagination.pageSize }}
+        </template>
+
+        <template #entityType="{ record }">
+          <span>
+            {{
+              deviceTypeList.find(item => item.dictCode === record.entityType)
+                ?.name
+            }}
+          </span>
+        </template>
+        <template #status="{ record }">
+          <BTag :status="record.status" size="small">
+            {{
+              deviceStatusList.find(item => item.dictCode === record.status)
+                ?.name
+            }}
+          </BTag>
+        </template>
+        <template #time="{ record }">
+          <span>{{
+            record.time && dayjs(record.time).format('YYYY-MM-DD HH:mm:ss')
+          }}</span>
+        </template>
+      </a-table>
+    </a-card>
+  </div>
+</template>
+
+<script lang="ts" setup name="AlamList">
+import {
+  ref,
+  reactive,
+  shallowRef,
+  h,
+  getCurrentInstance,
+  computed,
+  onMounted,
+  watch,
+} from 'vue';
+import type { DeviceParams, DataList } from '@/api/device';
+import { fetchAlarmTotalList } from '@/api/dashboard';
+import { SizeProps, Pagination } from '@/types/global';
+import BTag from '@/components/business/b-tag/index.vue';
+import useLoading from '@/hooks/loading';
+import { useI18n } from 'vue-i18n';
+import dayjs from 'dayjs';
+import { DeviceInfo } from '@/utils/const';
+import type { AdditionalProp } from '@/api/dict';
+import useDictList from '@/hooks/dict-list';
+import router from '@/router';
+import { useStorage } from '@vueuse/core';
+import { STATIONKEY, StationKey } from '@/utils/const';
+
+const { t } = useI18n();
+
+const { loading, setLoading } = useLoading(true);
+const cloneColumns = computed(() => [
+  {
+    title: t('searchTable.table.number'),
+    dataIndex: 'index',
+    slotName: 'index',
+    ellipsis: true,
+    tooltip: true,
+    width: 60,
+  },
+  {
+    title: t('device.table.time'),
+    dataIndex: 'time',
+    slotName: 'time',
+    ellipsis: true,
+    tooltip: true,
+    width: 120,
+  },
+  {
+    title: t('device.form.status'),
+    dataIndex: 'status',
+    slotName: 'status',
+    width: 100,
+  },
+  {
+    title: t('device.form.name'),
+    dataIndex: 'name',
+    slotName: 'name',
+    width: 120,
+  },
+  {
+    title: t('device.form.entityType'),
+    dataIndex: 'entityType',
+    slotName: 'entityType',
+    width: 120,
+  },
+
+  {
+    title: t('device.form.address'),
+    dataIndex: 'address',
+    ellipsis: true,
+    tooltip: true,
+    width: 120,
+  },
+]);
+
+const basePagination: Pagination = {
+  current: 1,
+  pageSize: 20,
+};
+const pagination = reactive({
+  ...basePagination,
+});
+const generateFormModel = () => {
+  return {
+    pageIndex: 1,
+    pageSize: 1000,
+    station: null,
+  } as DeviceParams;
+};
+const tableData = ref<DataList[]>([] as DataList[]);
+const size = ref<SizeProps>('medium');
+const formModel = ref<DeviceParams>(generateFormModel());
+const visible = shallowRef<boolean>(false);
+const this_ = getCurrentInstance()?.appContext.config.globalProperties;
+const deviceInfo = ref<DeviceInfo[]>([] as DeviceInfo[]);
+const deviceTypeList = ref<AdditionalProp[]>([] as AdditionalProp[]);
+const deviceStatusList = ref<AdditionalProp[]>([] as AdditionalProp[]);
+const obj = useStorage<StationKey>(STATIONKEY, {
+  id: null,
+  station: null,
+});
+useDictList(['DeviceType', 'DeviceStatus']).then(res => {
+  deviceTypeList.value.push(...res['DeviceType']);
+  deviceStatusList.value.push(...res['DeviceStatus']);
+});
+formModel.value.station = obj.value.station;
+fetchAlarmTotalList(formModel.value).then(res => {
+  tableData.value.push(...res.data);
+  setLoading(false);
+});
+const onPageChange = (current: number) => {
+  formModel.value.pageIndex = current;
+};
+
+const handleClick = (value: DataList) => {
+  if (value.data) {
+    deviceInfo.value.length = 0;
+    const obj = JSON.parse(value.data);
+    for (const key in obj) {
+      deviceInfo.value.push({
+        label: key,
+        value: obj[key],
+      });
+    }
+    visible.value = true;
+  } else {
+    this_ &&
+      this_.$message.warning('No device information available at the moment');
+  }
+};
+</script>
+
+<style lang="less" scoped>
+.container {
+  padding: 10px 10px 20px;
+
+  .general-card {
+    padding-top: 20px;
+
+    .right-side {
+      margin-top: 20px;
+    }
+  }
+}
+</style>

+ 3 - 0
src/views/dashboard/alam/locale/en-US.ts

@@ -0,0 +1,3 @@
+export default {
+  'menu.dashboard.alam': 'Alam List',
+};

+ 3 - 0
src/views/dashboard/alam/locale/zh-CN.ts

@@ -0,0 +1,3 @@
+export default {
+  'menu.dashboard.alam': '问题列表',
+};

+ 0 - 11
src/views/dashboard/workplace/locale/en-US.ts

@@ -1,11 +0,0 @@
-export default {
-  'menu.dashboard.status': 'Device Status',
-  'menu.dashboard.manage': 'Device Manage',
-  'dashboard.dialog.title': 'Device Information',
-  'dashboard.form.address': 'Location',
-  'dashboard.form.name': 'Name',
-  'dashboard.form.entityType': 'DeviceType',
-  'dashboard.form.status': 'Status',
-  'dashboard.form.timeRange': 'TimeRange',
-  'dashboard.table.time': 'Time',
-};

+ 0 - 11
src/views/dashboard/workplace/locale/zh-CN.ts

@@ -1,11 +0,0 @@
-export default {
-  'menu.dashboard.status': '设备状态',
-  'menu.dashboard.manage': '设备管理',
-  'dashboard.dialog.title': '设备信息',
-  'dashboard.form.address': 'IP地址',
-  'dashboard.form.name': '名称',
-  'dashboard.form.entityType': '设备类型',
-  'dashboard.form.status': '状态',
-  'dashboard.form.timeRange': '时间范围',
-  'dashboard.table.time': '时间',
-};

+ 5 - 5
src/views/dashboard/manage/edit.vue → src/views/device/manage/edit.vue

@@ -12,7 +12,7 @@
           <a-col :span="12">
             <a-form-item
               field="name"
-              :label="t('dashboard.form.name')"
+              :label="t('device.form.name')"
               :rules="getRules(t).required"
             >
               <a-input v-model="form.name" />
@@ -21,7 +21,7 @@
           <a-col :span="12">
             <a-form-item
               field="address"
-              :label="t('dashboard.form.address')"
+              :label="t('device.form.address')"
               :rules="getRules(t).required"
             >
               <a-input v-model="form.address" />
@@ -30,7 +30,7 @@
           <a-col :span="12">
             <a-form-item
               field="deviceType"
-              :label="t('dashboard.form.entityType')"
+              :label="t('device.form.entityType')"
               :rules="getRules(t).required"
             >
               <a-select
@@ -53,8 +53,8 @@
 </template>
 <script setup lang="ts" name="EditDialog">
 import { reactive, ref, shallowRef, watch, getCurrentInstance } from 'vue';
-import { getDeviceDetails, saveDeviceDetails } from '@/api/dashboard';
-import type { DataList } from '@/api/dashboard';
+import { getDeviceDetails, saveDeviceDetails } from '@/api/device';
+import type { DataList } from '@/api/device';
 import type { AdditionalProp } from '@/api/dict';
 import { useI18n } from 'vue-i18n';
 import { getRules } from '@/utils/const';

+ 23 - 31
src/views/dashboard/manage/index.vue → src/views/device/manage/index.vue

@@ -13,12 +13,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="address"
-                  :label="t('dashboard.form.address')"
+                  :label="t('device.form.address')"
                   label-col-flex="50px"
                 >
                   <a-input
                     v-model="formModel.address"
-                    :placeholder="t('dashboard.form.address')"
+                    :placeholder="t('device.form.address')"
                     allow-clear
                   />
                 </a-form-item>
@@ -26,12 +26,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="name"
-                  :label="t('dashboard.form.name')"
+                  :label="t('device.form.name')"
                   label-col-flex="50px"
                 >
                   <a-input
                     v-model="formModel.name"
-                    :placeholder="t('dashboard.form.name')"
+                    :placeholder="t('device.form.name')"
                     allow-clear
                   />
                 </a-form-item>
@@ -39,12 +39,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="entityType"
-                  :label="t('dashboard.form.entityType')"
+                  :label="t('device.form.entityType')"
                   label-col-flex="60px"
                 >
                   <a-select
                     v-model="formModel.entityType"
-                    :placeholder="t('dashboard.form.entityType')"
+                    :placeholder="t('device.form.entityType')"
                     allow-clear
                     @clear="formModel.entityType = null"
                   >
@@ -59,12 +59,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="statusTypeList"
-                  :label="t('dashboard.form.status')"
+                  :label="t('device.form.status')"
                   label-col-flex="60px"
                 >
                   <a-select
                     v-model="formModel.status"
-                    :placeholder="t('dashboard.form.status')"
+                    :placeholder="t('device.form.status')"
                     allow-clear
                     @clear="formModel.status = null"
                   >
@@ -78,7 +78,7 @@
               </a-col>
               <a-col :span="6">
                 <a-form-item
-                  :label="t('dashboard.form.timeRange')"
+                  :label="t('device.form.timeRange')"
                   label-col-flex="60px"
                 >
                   <a-range-picker v-model="formModel.time" />
@@ -181,7 +181,7 @@
       title-align="start"
       @cancel="handleCancel"
     >
-      <template #title>{{ t('dashboard.dialog.title') }}</template>
+      <template #title>{{ t('device.dialog.title') }}</template>
       <div>
         <a-descriptions :data="deviceInfo" bordered :column="2" />
       </div>
@@ -198,7 +198,7 @@
   </div>
 </template>
 
-<script lang="ts" setup name="Dashboard">
+<script lang="ts" setup name="DeviceManage">
 import {
   ref,
   reactive,
@@ -209,11 +209,11 @@ import {
   onMounted,
 } from 'vue';
 import {
-  queryDashboardList,
-  exportDashboardList,
+  queryDeviceList,
+  exportDeviceList,
   deleteDeviceDetails,
-} from '@/api/dashboard';
-import type { DashboardParams, DataList } from '@/api/dashboard';
+} from '@/api/device';
+import type { DeviceParams, DataList } from '@/api/device';
 import { SizeProps, Pagination } from '@/types/global';
 import BTag from '@/components/business/b-tag/index.vue';
 import EditDialog from './edit.vue';
@@ -225,9 +225,6 @@ import { downLoadFun, DeviceInfo } from '@/utils/const';
 import { Modal } from '@arco-design/web-vue';
 import type { AdditionalProp } from '@/api/dict';
 import useDictList from '@/hooks/dict-list';
-import { useStorage } from '@vueuse/core';
-import { STATIONKEY, StationKey } from '@/utils/const';
-
 const { t } = useI18n();
 
 const { loading, setLoading } = useLoading(true);
@@ -241,30 +238,30 @@ const cloneColumns = computed(() => [
     width: 70,
   },
   {
-    title: t('dashboard.table.time'),
+    title: t('device.table.time'),
     dataIndex: 'time',
     slotName: 'time',
     ellipsis: true,
   },
   // {
-  //   title: t('dashboard.form.status'),
+  //   title: t('device.form.status'),
   //   dataIndex: 'status',
   //   slotName: 'status',
   //   width: 120,
   // },
   {
-    title: t('dashboard.form.name'),
+    title: t('device.form.name'),
     dataIndex: 'name',
     slotName: 'name',
   },
   {
-    title: t('dashboard.form.entityType'),
+    title: t('device.form.entityType'),
     dataIndex: 'entityType',
     slotName: 'entityType',
   },
 
   {
-    title: t('dashboard.form.address'),
+    title: t('device.form.address'),
     dataIndex: 'address',
     ellipsis: true,
     tooltip: true,
@@ -294,11 +291,11 @@ const generateFormModel = () => {
     endTime: null,
     time: ['', ''],
     entityType: null,
-  } as DashboardParams;
+  } as DeviceParams;
 };
 const renderData = ref<DataList[]>([] as DataList[]);
 const size = ref<SizeProps>('medium');
-const formModel = ref<DashboardParams>(generateFormModel());
+const formModel = ref<DeviceParams>(generateFormModel());
 const visible = shallowRef<boolean>(false);
 const showEditDialog = shallowRef<boolean>(false);
 const deviceId = ref<number | null>(null);
@@ -311,10 +308,6 @@ useDictList(['DeviceType', 'DeviceStatus']).then(res => {
   deviceTypeList.value.push(...res['DeviceType']);
   deviceStatusList.value.push(...res['DeviceStatus']);
 });
-const obj = useStorage<StationKey>(STATIONKEY, {
-  id: null,
-  station: null,
-});
 function searchTable() {
   // setLoading(true);
   const [startTime, endTime] = formModel.value.time
@@ -322,8 +315,7 @@ function searchTable() {
     : ['', ''];
   formModel.value.startTime = startTime ? startTime : null;
   formModel.value.endTime = endTime ? endTime : null;
-  formModel.value.station = obj.value.station;
-  queryDashboardList(formModel.value)
+  queryDeviceList(formModel.value)
     .then(res => {
       pagination.current = formModel.value.pageIndex;
       pagination.pageSize = pagination.pageSize;

+ 0 - 0
src/views/dashboard/workplace/conf.ts → src/views/device/status/conf.ts


+ 4 - 4
src/views/dashboard/workplace/device-info/index.vue → src/views/device/status/device-info/index.vue

@@ -6,7 +6,7 @@
       :title="id ? $t('searchTable.form.edit') : $t('searchTable.form.add')"
       @cancel="() => handleCancel()"
     >
-      <template #title>{{ t('dashboard.dialog.title') }}</template>
+      <template #title>{{ t('device.dialog.title') }}</template>
       <a-descriptions :data="deviceInfo" bordered :column="2" />
       <a-form
         :model="form"
@@ -18,7 +18,7 @@
           <a-col :span="10">
             <a-form-item
               field="timeRange"
-              :label="t('dashboard.form.timeRange')"
+              :label="t('device.form.timeRange')"
               :rules="getRules(t).required"
             >
               <a-range-picker
@@ -66,8 +66,8 @@
 </template>
 <script setup lang="ts" name="DeviceInfoDialog">
 import { reactive, ref, shallowRef, watch, getCurrentInstance } from 'vue';
-import { getDeviceDetails, saveDeviceDetails } from '@/api/dashboard';
-import type { DataList } from '@/api/dashboard';
+import { getDeviceDetails, saveDeviceDetails } from '@/api/device';
+import type { DataList } from '@/api/device';
 import { useI18n } from 'vue-i18n';
 import { getRules, DeviceInfo } from '@/utils/const';
 import VChart from 'vue-echarts';

+ 22 - 35
src/views/dashboard/workplace/index.vue → src/views/device/status/index.vue

@@ -13,12 +13,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="address"
-                  :label="t('dashboard.form.address')"
+                  :label="t('device.form.address')"
                   label-col-flex="50px"
                 >
                   <a-input
                     v-model="formModel.address"
-                    :placeholder="t('dashboard.form.address')"
+                    :placeholder="t('device.form.address')"
                     allow-clear
                   />
                 </a-form-item>
@@ -26,12 +26,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="name"
-                  :label="t('dashboard.form.name')"
+                  :label="t('device.form.name')"
                   label-col-flex="50px"
                 >
                   <a-input
                     v-model="formModel.name"
-                    :placeholder="t('dashboard.form.name')"
+                    :placeholder="t('device.form.name')"
                     allow-clear
                   />
                 </a-form-item>
@@ -39,12 +39,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="entityType"
-                  :label="t('dashboard.form.entityType')"
+                  :label="t('device.form.entityType')"
                   label-col-flex="60px"
                 >
                   <a-select
                     v-model="formModel.entityType"
-                    :placeholder="t('dashboard.form.entityType')"
+                    :placeholder="t('device.form.entityType')"
                     allow-clear
                     @clear="formModel.entityType = null"
                   >
@@ -59,12 +59,12 @@
               <a-col :span="6">
                 <a-form-item
                   field="status"
-                  :label="t('dashboard.form.status')"
+                  :label="t('device.form.status')"
                   label-col-flex="60px"
                 >
                   <a-select
                     v-model="formModel.status"
-                    :placeholder="t('dashboard.form.status')"
+                    :placeholder="t('device.form.status')"
                     allow-clear
                     @clear="formModel.status = null"
                   >
@@ -78,7 +78,7 @@
               </a-col>
               <a-col :span="6">
                 <a-form-item
-                  :label="t('dashboard.form.timeRange')"
+                  :label="t('device.form.timeRange')"
                   label-col-flex="60px"
                 >
                   <a-range-picker v-model="formModel.time" />
@@ -162,7 +162,7 @@
   </div>
 </template>
 
-<script lang="ts" setup name="Dashboard">
+<script lang="ts" setup name="DevicePage">
 import {
   ref,
   reactive,
@@ -171,28 +171,21 @@ import {
   getCurrentInstance,
   computed,
 } from 'vue';
-import { useRoute } from 'vue-router';
-import { queryDashboardList, exportDashboardList } from '@/api/dashboard';
-import type { DashboardParams, DataList } from '@/api/dashboard';
+import { queryDeviceList, exportDeviceList } from '@/api/device';
+import type { DeviceParams, DataList } from '@/api/device';
 import { SizeProps, Pagination } from '@/types/global';
 import BTag from '@/components/business/b-tag/index.vue';
 import type { TableColumnData } from '@arco-design/web-vue';
 import useLoading from '@/hooks/loading';
 import { useI18n } from 'vue-i18n';
-import { DeviceInfo } from '@/utils/const';
 import type { AdditionalProp } from '@/api/dict';
 import dayjs from 'dayjs';
-import { downLoadFun } from '@/utils/const';
 import { useIntervalFn } from '@vueuse/core';
 import DeviceInfoDialog from './device-info/index.vue';
 import useDictList from '@/hooks/dict-list';
-import { useStorage } from '@vueuse/core';
-import { STATIONKEY, StationKey } from '@/utils/const';
+import { downLoadFun, DeviceInfo } from '@/utils/const';
 
 const { t } = useI18n();
-const {
-  params: { station },
-} = useRoute();
 const { loading, setLoading } = useLoading(true);
 const cloneColumns = computed(() => [
   {
@@ -204,30 +197,30 @@ const cloneColumns = computed(() => [
     width: 70,
   },
   {
-    title: t('dashboard.table.time'),
+    title: t('device.table.time'),
     dataIndex: 'time',
     slotName: 'time',
     ellipsis: true,
   },
   {
-    title: t('dashboard.form.status'),
+    title: t('device.form.status'),
     dataIndex: 'status',
     slotName: 'status',
     width: 120,
   },
   {
-    title: t('dashboard.form.name'),
+    title: t('device.form.name'),
     dataIndex: 'name',
     slotName: 'name',
   },
   {
-    title: t('dashboard.form.entityType'),
+    title: t('device.form.entityType'),
     dataIndex: 'entityType',
     slotName: 'entityType',
   },
 
   {
-    title: t('dashboard.form.address'),
+    title: t('device.form.address'),
     dataIndex: 'address',
     ellipsis: true,
     tooltip: true,
@@ -251,12 +244,11 @@ const generateFormModel = () => {
     endTime: null,
     time: ['', ''],
     entityType: null,
-    station: null,
-  } as DashboardParams;
+  } as DeviceParams;
 };
 const renderData = ref<DataList[]>([] as DataList[]);
 const size = ref<SizeProps>('medium');
-const formModel = ref<DashboardParams>(generateFormModel());
+const formModel = ref<DeviceParams>(generateFormModel());
 const showDeviceInfoDialog = shallowRef<boolean>(false);
 const this_ = getCurrentInstance()?.appContext.config.globalProperties;
 const deviceInfo = ref<DeviceInfo[]>([] as DeviceInfo[]);
@@ -264,10 +256,6 @@ const deviceTypeList = ref<AdditionalProp[]>([] as AdditionalProp[]);
 const deviceStatusList = ref<AdditionalProp[]>([] as AdditionalProp[]);
 const deviceId = shallowRef<number>(0);
 const deviceType = shallowRef<number | null>(1);
-const obj = useStorage<StationKey>(STATIONKEY, {
-  id: null,
-  station: null,
-});
 useDictList(['DeviceType', 'DeviceStatus']).then(res => {
   deviceTypeList.value.push(...res['DeviceType']);
   deviceStatusList.value.push(...res['DeviceStatus']);
@@ -279,9 +267,8 @@ function searchTable() {
     : ['', ''];
   formModel.value.startTime = startTime ? startTime : null;
   formModel.value.endTime = endTime ? endTime : null;
-  formModel.value.station = obj.value.station;
 
-  queryDashboardList(formModel.value)
+  queryDeviceList(formModel.value)
     .then(res => {
       pagination.current = formModel.value.pageIndex;
       pagination.pageSize = pagination.pageSize;
@@ -309,7 +296,7 @@ const downloadExcel = () => {
   const [startTime, endTime] = formModel.value.time;
   formModel.value.startTime = startTime ? startTime : null;
   formModel.value.endTime = endTime ? endTime : null;
-  exportDashboardList(formModel.value)
+  exportDeviceList(formModel.value)
     .then(res => {
       if (!res.success) {
         return;

+ 11 - 0
src/views/device/status/locale/en-US.ts

@@ -0,0 +1,11 @@
+export default {
+  'menu.device.status': 'Device Status',
+  'menu.device.manage': 'Device Manage',
+  'device.dialog.title': 'Device Information',
+  'device.form.address': 'Location',
+  'device.form.name': 'Name',
+  'device.form.entityType': 'DeviceType',
+  'device.form.status': 'Status',
+  'device.form.timeRange': 'TimeRange',
+  'device.table.time': 'Time',
+};

+ 11 - 0
src/views/device/status/locale/zh-CN.ts

@@ -0,0 +1,11 @@
+export default {
+  'menu.device.status': '设备状态',
+  'menu.device.manage': '设备管理',
+  'device.dialog.title': '设备信息',
+  'device.form.address': 'IP地址',
+  'device.form.name': '名称',
+  'device.form.entityType': '设备类型',
+  'device.form.status': '状态',
+  'device.form.timeRange': '时间范围',
+  'device.table.time': '时间',
+};

+ 9 - 9
src/views/home/list/index.vue

@@ -54,7 +54,7 @@ import {
   onMounted,
   watch,
 } from 'vue';
-import type { DashboardParams, DataList } from '@/api/dashboard';
+import type { DeviceParams, DataList } from '@/api/device';
 import type { AlarmTotalRes, Data } from '@/api/home';
 import { SizeProps, Pagination } from '@/types/global';
 import BTag from '@/components/business/b-tag/index.vue';
@@ -87,7 +87,7 @@ const cloneColumns = computed(() => [
     width: 60,
   },
   {
-    title: t('dashboard.table.time'),
+    title: t('device.table.time'),
     dataIndex: 'time',
     slotName: 'time',
     ellipsis: true,
@@ -95,26 +95,26 @@ const cloneColumns = computed(() => [
     width: 120,
   },
   {
-    title: t('dashboard.form.status'),
+    title: t('device.form.status'),
     dataIndex: 'status',
     slotName: 'status',
     width: 100,
   },
   {
-    title: t('dashboard.form.name'),
+    title: t('device.form.name'),
     dataIndex: 'name',
     slotName: 'name',
     width: 120,
   },
   {
-    title: t('dashboard.form.entityType'),
+    title: t('device.form.entityType'),
     dataIndex: 'entityType',
     slotName: 'entityType',
     width: 120,
   },
 
   {
-    title: t('dashboard.form.address'),
+    title: t('device.form.address'),
     dataIndex: 'address',
     ellipsis: true,
     tooltip: true,
@@ -140,11 +140,11 @@ const generateFormModel = () => {
     endTime: null,
     time: ['', ''],
     entityType: null,
-  } as DashboardParams;
+  } as DeviceParams;
 };
 const tableData = ref<Data[]>([] as Data[]);
 const size = ref<SizeProps>('medium');
-const formModel = ref<DashboardParams>(generateFormModel());
+const formModel = ref<DeviceParams>(generateFormModel());
 const visible = shallowRef<boolean>(false);
 const this_ = getCurrentInstance()?.appContext.config.globalProperties;
 const deviceInfo = ref<DeviceInfo[]>([] as DeviceInfo[]);
@@ -200,7 +200,7 @@ const obj = useStorage<StationKey>(STATIONKEY, {
 const handleToDevice = (folder: Data) => {
   obj.value.id = folder.routeInfoId;
   obj.value.station = folder.station;
-  router.push({ name: 'DeviceStatus' });
+  router.push({ name: 'AlamList' });
 };
 </script>
 

+ 1 - 1
src/views/home/tree/index.vue

@@ -80,7 +80,7 @@ const obj = useStorage<StationKey>(STATIONKEY, {
 const handleChild = (folder: Tree) => {
   obj.value.id = folder.id;
   obj.value.station = folder.name;
-  router.push({ name: 'DeviceStatus' });
+  router.push({ name: 'AlamList' });
 };
 </script>
 <style lang="less" scoped>