From 2c2bc8614c8ea0ce386369eb4924da1e6aa052d1 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Wed, 27 Sep 2023 09:35:57 +0800
Subject: [PATCH] 添加环境配置区分
---
src/pages/page-web/projects/devices.vue | 310 ++++++++++++++++++++++++++++++---------------------
1 files changed, 182 insertions(+), 128 deletions(-)
diff --git a/src/pages/page-web/projects/devices.vue b/src/pages/page-web/projects/devices.vue
index 6f2f808..cde515a 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">
@@ -9,121 +8,128 @@
</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 }">
- <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>Online</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>Offline</span>
- </span>
- </template>
- <!-- 操作 -->
- <template #action="{ record }">
- <div class="editable-row-operations">
- <!-- 编辑态操作 -->
- <div v-if="editableData[record.device_sn]">
- <a-tooltip title="Confirm changes">
- <span @click="save(record)" style="color: #28d445;"><CheckOutlined /></span>
- </a-tooltip>
- <a-tooltip title="Modification canceled">
- <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 Info">
- <FileSearchOutlined @click="showHms(record)"/>
- </a-tooltip>
- <a-tooltip title="Edit">
- <EditOutlined @click="edit(record)"/>
- </a-tooltip>
- <a-tooltip title="Delete">
- <DeleteOutlined @click="() => { deleteTip = true, deleteSn = record.device_sn }"/>
- </a-tooltip>
- </div>
- </div>
- </template>
-
- </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;">Delete device from workspace?</p>
- <template #title>
- <div class="flex-row flex-justify-center">
- <span>Delete devices</span>
- </div>
</template>
- </a-modal>
+ <!-- 状态 -->
+ <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>在线</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>离线</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>
+ </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>
- <!-- 设备升级 -->
- <DeviceFirmwareUpgradeModal title="设备升级"
- v-model:visible="deviceFirmwareUpgradeModalVisible"
- :device="selectedDevice"
- @ok="onUpgradeDeviceOk"
- ></DeviceFirmwareUpgradeModal>
+ </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>
+ </template>
+ </a-modal>
- <!-- 设备日志上传记录 -->
- <DeviceLogUploadRecordDrawer
- v-model:visible="deviceLogUploadRecordVisible"
- :device="currentDevice"
- ></DeviceLogUploadRecordDrawer>
+ <!-- 设备升级 -->
+ <DeviceFirmwareUpgradeModal title="设备升级"
+ v-model:visible="deviceFirmwareUpgradeModalVisible"
+ :device="selectedDevice"
+ @ok="onUpgradeDeviceOk"
+ ></DeviceFirmwareUpgradeModal>
- <!-- hms 信息 -->
- <DeviceHmsDrawer
- v-model:visible="hmsVisible"
- :device="currentDevice">
- </DeviceHmsDrawer>
- </div>
+ <!-- 设备日志上传记录 -->
+ <DeviceLogUploadRecordDrawer
+ v-model:visible="deviceLogUploadRecordVisible"
+ :device="currentDevice"
+ ></DeviceLogUploadRecordDrawer>
+ <!-- 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'
import { h, onMounted, reactive, ref, UnwrapRef } from 'vue'
import { IPage } from '/@/api/http/type'
-import { BindBody, bindDevice, getBindingDevices, getDeviceList, unbindDevice, updateDevice } from '/@/api/manage'
+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'
@@ -133,17 +139,26 @@
import DeviceLogUploadRecordDrawer from '/@/components/devices/device-log/DeviceLogUploadRecordDrawer.vue'
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 loading = ref(true)
+const store = useMyStore()
+const loading = ref(false)
const deleteTip = ref<boolean>(false)
const deleteSn = ref<string>()
const columns: ColumnProps[] = [
- { title: '设备型号', dataIndex: 'deviceName', width: 100, className: 'titleStyle' },
- { title: '设备SN', dataIndex: 'deviceSn', width: 100, className: 'titleStyle', ellipsis: true, slots: { customRender: 'sn' } },
+ { title: '设备型号', dataIndex: 'device_name', width: 100, className: 'titleStyle' },
+ {
+ title: '设备SN',
+ dataIndex: 'device_sn',
+ width: 100,
+ className: 'titleStyle',
+ ellipsis: true,
+ slots: { customRender: 'sn' }
+ },
{
title: '设备组织名称',
dataIndex: 'nickname',
@@ -153,11 +168,17 @@
ellipsis: true,
slots: { customRender: 'nickname' }
},
- { title: '固件版本', dataIndex: 'firmwareVersion', 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: '所属项目',
- dataIndex: 'workspaceName',
+ dataIndex: 'workspace_name',
width: 100,
className: 'titleStyle',
ellipsis: true,
@@ -175,8 +196,20 @@
return obj
}
},
- { title: '加入组织时间', dataIndex: 'boundTime', width: 150, sorter: (a: Device, b: Device) => a.bound_time.localeCompare(b.bound_time), className: 'titleStyle' },
- { title: '在线时间', dataIndex: 'loginTime', 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',
@@ -224,8 +257,8 @@
// 获取分页信息
function getPaginationBody () {
return {
- current: paginationProp.current,
- size: paginationProp.pageSize
+ page: paginationProp.current,
+ page_size: paginationProp.pageSize
} as IPage
}
@@ -246,7 +279,7 @@
}
type Pagination = TableState['pagination']
-const workspaceId: string = localStorage.getItem(ELocalStorageKey.WorkspaceId) || ''
+const workspaceId = computed(() => store.state.common.projectId || localStorage.getItem(ELocalStorageKey.WorkspaceId))
const editableData: UnwrapRef<Record<string, Device>> = reactive({})
const current = ref([EDeviceTypeName.Aircraft])
@@ -260,7 +293,7 @@
selectedDevice,
onDeviceUpgrade,
onUpgradeDeviceOk
-} = useDeviceFirmwareUpgrade(workspaceId)
+} = useDeviceFirmwareUpgrade(workspaceId.value)
function onDeviceUpgradeWs (payload: DeviceCmdExecuteInfo) {
updateDevicesByWs(data.device, payload)
@@ -300,22 +333,31 @@
useDeviceUpgradeEvent(onDeviceUpgradeWs)
// 获取设备列表信息
-function getDevices (params:any) {
- loading.value = true
- const paginationBody = getPaginationBody()
-
- getDeviceList(Object.assign(params, paginationBody)).then(res => {
- if (res.code !== 5000) {
+function getDevices (domain: number, closeLoading?: boolean) {
+ if (!closeLoading) {
+ loading.value = true
+ }
+ getBindingDevices(workspaceId.value, getPaginationBody(), domain).then(res => {
+ if (res.code !== 0) {
+ loading.value = false
return
}
-
- console.log(res, '++++++++++')
- const list = res.data.records
- data.device = list
-
+ const resData: Device[] = res.data.list
+ expandRows.value = []
+ resData.forEach((val: any) => {
+ if (val.children) {
+ val.children = [val.children]
+ }
+ if (judgeCurrentType(EDeviceTypeName.Dock)) {
+ expandRows.value.push(val.device_sn)
+ }
+ })
+ data.device = resData
+ paginationProp.total = res.data.pagination.total
+ paginationProp.current = res.data.pagination.page
+ paginationProp.pageSize = res.data.pagination.page_size
loading.value = false
- }).catch(err => {
- console.log('错误:', err)
+ }).catch(e => {
loading.value = false
})
}
@@ -334,7 +376,7 @@
// 保存
function save (record: Device) {
delete editableData[record.device_sn]
- updateDevice({ nickname: record.nickname }, workspaceId, record.device_sn)
+ updateDevice({ nickname: record.nickname }, workspaceId.value, record.device_sn)
}
// 删除
@@ -361,6 +403,7 @@
const currentDevice = ref({} as Device)
// 设备日志
const deviceLogUploadRecordVisible = ref(false)
+
function showDeviceLogUploadRecord (dock: Device) {
deviceLogUploadRecordVisible.value = true
currentDevice.value = dock
@@ -380,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;
}
@@ -396,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