From 3e790728c7439d07b7cb28b7cdb1d29d7642db53 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Mon, 25 Sep 2023 14:25:29 +0800
Subject: [PATCH] Merge branch 'demo' of http://s16s652780.51mypc.cn:49896/r/yskj/iot_drone_web into demo
---
src/pages/page-web/projects/devices.vue | 240 ++++++++++++++++++++++++++++++++++++------------------------
1 files changed, 144 insertions(+), 96 deletions(-)
diff --git a/src/pages/page-web/projects/devices.vue b/src/pages/page-web/projects/devices.vue
index e22d6a7..8e267d3 100644
--- a/src/pages/page-web/projects/devices.vue
+++ b/src/pages/page-web/projects/devices.vue
@@ -1,4 +1,3 @@
-
<template>
<a-menu v-model:selectedKeys="current" mode="horizontal" @select="select">
<a-menu-item :key="EDeviceTypeName.Aircraft" class="ml20">
@@ -8,111 +7,114 @@
机场
</a-menu-item>
</a-menu>
- <div class="device-table-wrap table flex-display flex-column">
- <a-table :columns="columns" :data-source="data.device" :pagination="paginationProp" @change="refreshData" row-key="device_sn" :expandedRowKeys="expandRows"
- :row-selection="rowSelection" :rowClassName="rowClassName" :scroll="{ x: '100%', y: 600 }"
- :expandIcon="expandIcon" :loading="loading">
- <template v-for="col in ['nickname']" #[col]="{ text, record }" :key="col">
- <div>
- <a-input
- v-if="editableData[record.device_sn]"
- v-model:value="editableData[record.device_sn][col]"
- style="margin: -5px 0"
- />
- <template v-else>
- <a-tooltip :title="text">
- {{ text }}
- </a-tooltip>
- </template>
- </div>
- </template>
- <template v-for="col in ['sn', 'workspace']" #[col]="{ text }" :key="col">
- <a-tooltip :title="text">
+
+ <div class="device-table-wrap table flex-display flex-column">
+ <a-table :columns="columns" :data-source="data.device" :pagination="paginationProp" @change="refreshData"
+ row-key="device_sn" :expandedRowKeys="expandRows"
+ :row-selection="rowSelection" :rowClassName="rowClassName" :scroll="{ x: '100%', y: 600 }"
+ :expandIcon="expandIcon" :loading="loading">
+ <template v-for="col in ['nickname']" #[col]="{ text, record }" :key="col">
+ <div>
+ <a-input
+ v-if="editableData[record.device_sn]"
+ v-model:value="editableData[record.device_sn][col]"
+ style="margin: -5px 0"
+ />
+ <template v-else>
+ <a-tooltip :title="text">
+ {{ text }}
+ </a-tooltip>
+ </template>
+ </div>
+ </template>
+ <template v-for="col in ['sn', 'workspace']" #[col]="{ text }" :key="col">
+ <a-tooltip :title="text">
<span>{{ text }}</span>
- </a-tooltip>
- </template>
- <!-- 固件版本 -->
- <template #firmware_version="{ record }">
+ </a-tooltip>
+ </template>
+ <!-- 固件版本 -->
+ <template #firmware_version="{ record }">
<span v-if="judgeCurrentType(EDeviceTypeName.Dock)">
<DeviceFirmwareUpgrade :device="record"
- class="table-flex-col"
- @device-upgrade="onDeviceUpgrade"
- />
+ class="table-flex-col"
+ @device-upgrade="onDeviceUpgrade"
+ />
</span>
- <span v-else>
+ <span v-else>
{{ record.firmware_version }}
</span>
- </template>
- <!-- 状态 -->
- <template #status="{ text }">
+ </template>
+ <!-- 状态 -->
+ <template #status="{ text }">
<span v-if="text" class="flex-row flex-align-center">
- <span class="mr5" style="width: 12px; height: 12px; border-radius: 50%; background-color: green;" />
+ <span class="mr5" style="width: 12px; height: 12px; border-radius: 50%; background-color: green;"/>
<span>在线</span>
</span>
- <span class="flex-row flex-align-center" v-else>
- <span class="mr5" style="width: 12px; height: 12px; border-radius: 50%; background-color: red;" />
+ <span class="flex-row flex-align-center" v-else>
+ <span class="mr5" style="width: 12px; height: 12px; border-radius: 50%; background-color: red;"/>
<span>离线</span>
</span>
- </template>
- <!-- 操作 -->
- <template #action="{ record }">
- <div class="editable-row-operations">
- <!-- 编辑态操作 -->
- <div v-if="editableData[record.device_sn]">
- <a-tooltip title="保存">
- <span @click="save(record)" style="color: #28d445;"><CheckOutlined /></span>
- </a-tooltip>
- <a-tooltip title="取消">
- <span @click="() => delete editableData[record.device_sn]" style="color: #e70102;"><CloseOutlined /></span>
- </a-tooltip>
+ </template>
+ <!-- 操作 -->
+ <template #action="{ record }">
+ <div class="editable-row-operations">
+ <!-- 编辑态操作 -->
+ <div v-if="editableData[record.device_sn]">
+ <a-tooltip title="保存">
+ <span @click="save(record)" style="color: #28d445;"><CheckOutlined/></span>
+ </a-tooltip>
+ <a-tooltip title="取消">
+ <span @click="() => delete editableData[record.device_sn]" style="color: #e70102;"><CloseOutlined/></span>
+ </a-tooltip>
+ </div>
+ <!-- 非编辑态操作 -->
+ <div v-else class="flex-align-center flex-row" style="color: #2d8cf0">
+ <a-tooltip v-if="current.indexOf(EDeviceTypeName.Dock) !== -1" title="设备日志">
+ <CloudServerOutlined @click="showDeviceLogUploadRecord(record)"/>
+ </a-tooltip>
+ <a-tooltip v-if="current.indexOf(EDeviceTypeName.Dock) !== -1" title="Hms信息">
+ <FileSearchOutlined @click="showHms(record)"/>
+ </a-tooltip>
+ <a-tooltip title="编辑">
+ <EditOutlined @click="edit(record)"/>
+ </a-tooltip>
+ <a-tooltip title="删除">
+ <DeleteOutlined @click="() => { deleteTip = true, deleteSn = record.device_sn }"/>
+ </a-tooltip>
+ </div>
</div>
- <!-- 非编辑态操作 -->
- <div v-else class="flex-align-center flex-row" style="color: #2d8cf0">
- <a-tooltip v-if="current.indexOf(EDeviceTypeName.Dock) !== -1" title="设备日志">
- <CloudServerOutlined @click="showDeviceLogUploadRecord(record)"/>
- </a-tooltip>
- <a-tooltip v-if="current.indexOf(EDeviceTypeName.Dock) !== -1" title="Hms信息">
- <FileSearchOutlined @click="showHms(record)"/>
- </a-tooltip>
- <a-tooltip title="编辑">
- <EditOutlined @click="edit(record)"/>
- </a-tooltip>
- <a-tooltip title="删除">
- <DeleteOutlined @click="() => { deleteTip = true, deleteSn = record.device_sn }"/>
- </a-tooltip>
- </div>
- </div>
- </template>
+ </template>
- </a-table>
- <a-modal v-model:visible="deleteTip" width="450px" :closable="false" centered :okButtonProps="{ danger: true }" @ok="unbind">
+ </a-table>
+ <a-modal v-model:visible="deleteTip" width="450px" :closable="false" centered :okButtonProps="{ danger: true }"
+ @ok="unbind">
<p class="pt10 pl20" style="height: 50px;">确定从项目中删除该设备吗?</p>
<template #title>
- <div class="flex-row flex-justify-center">
- <span>确定</span>
- </div>
+ <div class="flex-row flex-justify-center">
+ <span>确定</span>
+ </div>
</template>
- </a-modal>
+ </a-modal>
- <!-- 设备升级 -->
- <DeviceFirmwareUpgradeModal title="设备升级"
- v-model:visible="deviceFirmwareUpgradeModalVisible"
- :device="selectedDevice"
- @ok="onUpgradeDeviceOk"
- ></DeviceFirmwareUpgradeModal>
+ <!-- 设备升级 -->
+ <DeviceFirmwareUpgradeModal title="设备升级"
+ v-model:visible="deviceFirmwareUpgradeModalVisible"
+ :device="selectedDevice"
+ @ok="onUpgradeDeviceOk"
+ ></DeviceFirmwareUpgradeModal>
- <!-- 设备日志上传记录 -->
- <DeviceLogUploadRecordDrawer
- v-model:visible="deviceLogUploadRecordVisible"
- :device="currentDevice"
- ></DeviceLogUploadRecordDrawer>
+ <!-- 设备日志上传记录 -->
+ <DeviceLogUploadRecordDrawer
+ v-model:visible="deviceLogUploadRecordVisible"
+ :device="currentDevice"
+ ></DeviceLogUploadRecordDrawer>
- <!-- hms 信息 -->
- <DeviceHmsDrawer
- v-model:visible="hmsVisible"
- :device="currentDevice">
- </DeviceHmsDrawer>
- </div>
+ <!-- hms 信息 -->
+ <DeviceHmsDrawer
+ v-model:visible="hmsVisible"
+ :device="currentDevice">
+ </DeviceHmsDrawer>
+ </div>
</template>
<script lang="ts" setup>
import { ColumnProps, TableState } from 'ant-design-vue/lib/table/interface'
@@ -120,7 +122,14 @@
import { IPage } from '/@/api/http/type'
import { BindBody, bindDevice, getBindingDevices, unbindDevice, updateDevice } from '/@/api/manage'
import { EDeviceTypeName, ELocalStorageKey } from '/@/types'
-import { EditOutlined, CheckOutlined, CloseOutlined, DeleteOutlined, FileSearchOutlined, CloudServerOutlined } from '@ant-design/icons-vue'
+import {
+ EditOutlined,
+ CheckOutlined,
+ CloseOutlined,
+ DeleteOutlined,
+ FileSearchOutlined,
+ CloudServerOutlined
+} from '@ant-design/icons-vue'
import { Device, DeviceFirmwareStatusEnum } from '/@/types/device'
import DeviceFirmwareUpgrade from '/@/components/devices/device-upgrade/DeviceFirmwareUpgrade.vue'
import DeviceFirmwareUpgradeModal from '/@/components/devices/device-upgrade/DeviceFirmwareUpgradeModal.vue'
@@ -131,16 +140,25 @@
import DeviceHmsDrawer from '/@/components/devices/device-hms/DeviceHmsDrawer.vue'
import { message, notification } from 'ant-design-vue'
import { useMyStore } from '/@/store'
+
interface DeviceData {
device: Device[]
}
+
const store = useMyStore()
const loading = ref(false)
const deleteTip = ref<boolean>(false)
const deleteSn = ref<string>()
const columns: ColumnProps[] = [
{ title: '设备型号', dataIndex: 'device_name', width: 100, className: 'titleStyle' },
- { title: '设备SN', dataIndex: 'device_sn', width: 100, className: 'titleStyle', ellipsis: true, slots: { customRender: 'sn' } },
+ {
+ title: '设备SN',
+ dataIndex: 'device_sn',
+ width: 100,
+ className: 'titleStyle',
+ ellipsis: true,
+ slots: { customRender: 'sn' }
+ },
{
title: '设备组织名称',
dataIndex: 'nickname',
@@ -150,7 +168,13 @@
ellipsis: true,
slots: { customRender: 'nickname' }
},
- { title: '固件版本', dataIndex: 'firmware_version', width: 150, className: 'titleStyle', slots: { customRender: 'firmware_version' } },
+ {
+ title: '固件版本',
+ dataIndex: 'firmware_version',
+ width: 150,
+ className: 'titleStyle',
+ slots: { customRender: 'firmware_version' }
+ },
{ title: '在线状态', dataIndex: 'status', width: 100, className: 'titleStyle', slots: { customRender: 'status' } },
{
title: '所属项目',
@@ -172,8 +196,20 @@
return obj
}
},
- { title: '加入组织时间', dataIndex: 'bound_time', width: 150, sorter: (a: Device, b: Device) => a.bound_time.localeCompare(b.bound_time), className: 'titleStyle' },
- { title: '在线时间', dataIndex: 'login_time', width: 150, sorter: (a: Device, b: Device) => a.login_time.localeCompare(b.login_time), className: 'titleStyle' },
+ {
+ title: '加入组织时间',
+ dataIndex: 'bound_time',
+ width: 150,
+ sorter: (a: Device, b: Device) => a.bound_time.localeCompare(b.bound_time),
+ className: 'titleStyle'
+ },
+ {
+ title: '在线时间',
+ dataIndex: 'login_time',
+ width: 150,
+ sorter: (a: Device, b: Device) => a.login_time.localeCompare(b.login_time),
+ className: 'titleStyle'
+ },
{
title: '操作',
dataIndex: 'actions',
@@ -367,6 +403,7 @@
const currentDevice = ref({} as Device)
// 设备日志
const deviceLogUploadRecordVisible = ref(false)
+
function showDeviceLogUploadRecord (dock: Device) {
deviceLogUploadRecordVisible.value = true
currentDevice.value = dock
@@ -386,8 +423,8 @@
</script>
<style lang="scss" scoped>
-.device-table-wrap{
- .editable-row-operations{
+.device-table-wrap {
+ .editable-row-operations {
div > span {
margin-right: 10px;
}
@@ -402,42 +439,53 @@
padding: 20px;
height: 88vh;
}
+
.table-striped {
background-color: #f7f9fa;
}
+
.ant-table {
- border-top: 1px solid rgb(0,0,0,0.06);
- border-bottom: 1px solid rgb(0,0,0,0.06);
+ border-top: 1px solid rgb(0, 0, 0, 0.06);
+ border-bottom: 1px solid rgb(0, 0, 0, 0.06);
}
+
.ant-table-tbody tr td {
border: 0;
}
+
.ant-table td {
white-space: nowrap;
}
+
.ant-table-thead tr th {
background: white !important;
border: 0;
}
+
th.ant-table-selection-column {
background-color: white !important;
}
+
.ant-table-header {
background-color: white !important;
}
+
.child-row {
height: 70px;
}
+
.notice {
background: $success;
overflow: hidden;
cursor: pointer;
}
+
.caution {
background: orange;
cursor: pointer;
overflow: hidden;
}
+
.warn {
background: red;
cursor: pointer;
--
Gitblit v1.9.3