|
|
@@ -1,114 +1,99 @@
|
|
|
<template>
|
|
|
- <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: 'max-content', 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 }">
|
|
|
- <span v-if="judgeCurrentType(EDeviceTypeName.Dock)">
|
|
|
- <DeviceFirmwareUpgrade :device="record" class="table-flex-col" @device-upgrade="onDeviceUpgrade" />
|
|
|
- </span>
|
|
|
- <span v-else>
|
|
|
- {{ record.firmware_version }}
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- <!-- 固件升级 -->
|
|
|
- <template #firmware_status="{ text }">
|
|
|
- <div v-if="text === -1">
|
|
|
- 不支持
|
|
|
- </div>
|
|
|
- <div v-else>
|
|
|
- {{ DeviceFirmwareStatus[text] }}
|
|
|
- </div>
|
|
|
- </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>在线</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 class="deviceList">
|
|
|
+ <Search :onClickSearch="async () => { }" :onClickReset="async () => { }" />
|
|
|
+ <div class="deviceList-table">
|
|
|
+ <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]" />
|
|
|
+ <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 }">
|
|
|
+ <span v-if="judgeCurrentType(EDeviceTypeName.Dock)">
|
|
|
+ <DeviceFirmwareUpgrade :device="record" class="table-flex-col" @device-upgrade="onDeviceUpgrade" />
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ {{ record.firmware_version }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ <!-- 固件升级 -->
|
|
|
+ <template #firmware_status="{ text }">
|
|
|
+ <div v-if="text === -1">
|
|
|
+ 不支持
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ {{ DeviceFirmwareStatus[text] }}
|
|
|
+ </div>
|
|
|
+ </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>在线</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 v-if="editableData[record.device_sn]">
|
|
|
<a-tooltip title="确定">
|
|
|
- <span @click="save(record)" style="color: #28d445;">
|
|
|
- <CheckOutlined />
|
|
|
- </span>
|
|
|
+ <CheckOutlined style="color: #28d445;margin-right: 10px;" @click="save(record)" />
|
|
|
</a-tooltip>
|
|
|
<a-tooltip title="取消">
|
|
|
- <span @click="() => delete editableData[record.device_sn]" style="color: #e70102;">
|
|
|
- <CloseOutlined />
|
|
|
- </span>
|
|
|
+ <CloseOutlined style="color: #e70102;" @click="() => delete editableData[record.device_sn]" />
|
|
|
</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)" />
|
|
|
+ <CloudServerOutlined style="margin-right: 10px;" @click="showDeviceLogUploadRecord(record)" />
|
|
|
</a-tooltip>
|
|
|
<a-tooltip v-if="current.indexOf(EDeviceTypeName.Dock) !== -1" title="告警信息">
|
|
|
- <FileSearchOutlined @click="showHms(record)" />
|
|
|
+ <FileSearchOutlined style="margin-right: 10px;" @click="showHms(record)" />
|
|
|
</a-tooltip>
|
|
|
<a-tooltip title="编辑">
|
|
|
- <EditOutlined @click="edit(record)" />
|
|
|
+ <EditOutlined style="margin-right: 10px;" @click="edit(record)" />
|
|
|
</a-tooltip>
|
|
|
<a-tooltip title="删除">
|
|
|
- <DeleteOutlined @click="() => { deleteTip = true, deleteSn = record.device_sn }" />
|
|
|
+ <DeleteOutlined @click="onClickDelete(record)" />
|
|
|
</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;">从工作区中删除设备吗?</p>
|
|
|
- <template #title>
|
|
|
- <div class="flex-row flex-justify-center">
|
|
|
- <span>删除设备</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </a-modal>
|
|
|
- <!-- 设备升级 -->
|
|
|
- <DeviceFirmwareUpgradeModal title="设备升级" v-model:visible="deviceFirmwareUpgradeModalVisible"
|
|
|
- :device="selectedDevice" @ok="onUpgradeDeviceOk"></DeviceFirmwareUpgradeModal>
|
|
|
- <!-- 设备日志上传记录 -->
|
|
|
- <DeviceLogUploadRecordDrawer v-model:visible="deviceLogUploadRecordVisible" :device="currentDevice">
|
|
|
- </DeviceLogUploadRecordDrawer>
|
|
|
- <!-- hms 信息 -->
|
|
|
- <DeviceHmsDrawer v-model:visible="hmsVisible" :device="currentDevice">
|
|
|
- </DeviceHmsDrawer>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
+ <!-- 设备升级 -->
|
|
|
+ <DeviceFirmwareUpgradeModal title="设备升级" v-model:visible="deviceFirmwareUpgradeModalVisible"
|
|
|
+ :device="selectedDevice" @ok="onUpgradeDeviceOk" />
|
|
|
+ <!-- 设备日志上传记录 -->
|
|
|
+ <DeviceLogUploadRecordDrawer v-model:visible="deviceLogUploadRecordVisible" :device="currentDevice" />
|
|
|
+ <!-- hms 信息 -->
|
|
|
+ <DeviceHmsDrawer v-model:visible="hmsVisible" :device="currentDevice" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { h, onMounted, reactive, ref, UnwrapRef } from 'vue'
|
|
|
-import { notification } from 'ant-design-vue'
|
|
|
-import { ColumnProps, TableState } from 'ant-design-vue/lib/table/interface'
|
|
|
-import { getBindingDevices, unbindDevice, updateDevice } from '/@/api/manage'
|
|
|
+import { Modal, notification } from 'ant-design-vue'
|
|
|
import { EditOutlined, CheckOutlined, CloseOutlined, DeleteOutlined, FileSearchOutlined, CloudServerOutlined } from '@ant-design/icons-vue'
|
|
|
+import Search from './components/Search.vue'
|
|
|
+import { getBindingDevices, unbindDevice, updateDevice } from '/@/api/manage'
|
|
|
import { Device, DeviceFirmwareStatus, DeviceFirmwareStatusEnum } from '/@/types/device'
|
|
|
import DeviceFirmwareUpgrade from '/@/components/devices/device-upgrade/DeviceFirmwareUpgrade.vue'
|
|
|
import DeviceFirmwareUpgradeModal from '/@/components/devices/device-upgrade/DeviceFirmwareUpgradeModal.vue'
|
|
|
@@ -120,47 +105,75 @@ import DeviceHmsDrawer from '/@/components/devices/device-hms/DeviceHmsDrawer.vu
|
|
|
import { IPage } from '/@/api/http/type'
|
|
|
import { EDeviceTypeName, ELocalStorageKey } from '/@/types'
|
|
|
|
|
|
-interface DeviceData {
|
|
|
- device: Device[]
|
|
|
-}
|
|
|
-
|
|
|
const loading = ref(true)
|
|
|
-const deleteTip = ref<boolean>(false)
|
|
|
-const deleteSn = ref<string>()
|
|
|
|
|
|
-const columns: ColumnProps[] = [
|
|
|
+const columns = [
|
|
|
+ {
|
|
|
+ title: '设备型号',
|
|
|
+ dataIndex: 'device_name',
|
|
|
+ width: 150,
|
|
|
+ ellipsis: true,
|
|
|
+ sorter: (a: any, b: any) => a.nickname.localeCompare(b.nickname),
|
|
|
+ },
|
|
|
{
|
|
|
- title: '设备型号', dataIndex: 'device_name', width: 150,
|
|
|
- sorter: (a: Device, b: Device) => a.nickname.localeCompare(b.nickname),
|
|
|
- className: 'titleStyle'
|
|
|
+ title: '设备SN',
|
|
|
+ dataIndex: 'device_sn',
|
|
|
+ width: 200,
|
|
|
+ ellipsis: true,
|
|
|
+ slots: { customRender: 'sn' }
|
|
|
},
|
|
|
- { title: '设备SN', dataIndex: 'device_sn', width: 100, className: 'titleStyle', ellipsis: true, slots: { customRender: 'sn' } },
|
|
|
{
|
|
|
title: '设备名称',
|
|
|
dataIndex: 'nickname',
|
|
|
width: 150,
|
|
|
- sorter: (a: Device, b: Device) => a.nickname.localeCompare(b.nickname),
|
|
|
- className: 'titleStyle',
|
|
|
ellipsis: true,
|
|
|
+ sorter: (a: any, b: any) => a.nickname.localeCompare(b.nickname),
|
|
|
slots: { customRender: 'nickname' }
|
|
|
},
|
|
|
- { title: '固件版本', dataIndex: 'firmware_version', width: 150, className: 'titleStyle', slots: { customRender: 'firmware_version' } },
|
|
|
- { title: '固件升级', dataIndex: 'firmware_status', width: 150, className: 'titleStyle', slots: { customRender: 'firmware_status' } },
|
|
|
- { title: '当前状态', dataIndex: 'status', width: 100, className: 'titleStyle', slots: { customRender: 'status' } },
|
|
|
- { 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: 'firmware_version',
|
|
|
+ width: 150,
|
|
|
+ ellipsis: true,
|
|
|
+ slots: { customRender: 'firmware_version' },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '固件升级',
|
|
|
+ dataIndex: 'firmware_status',
|
|
|
+ width: 150,
|
|
|
+ ellipsis: true,
|
|
|
+ slots: { customRender: 'firmware_status' },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '当前状态',
|
|
|
+ dataIndex: 'status',
|
|
|
+ width: 100,
|
|
|
+ ellipsis: true,
|
|
|
+ slots: { customRender: 'status' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '加入项目时间',
|
|
|
+ dataIndex: 'bound_time',
|
|
|
+ width: 200,
|
|
|
+ sorter: (a: any, b: any) => a.bound_time.localeCompare(b.bound_time),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '最后在线时间',
|
|
|
+ dataIndex: 'login_time',
|
|
|
+ width: 200,
|
|
|
+ sorter: (a: any, b: any) => a.login_time.localeCompare(b.login_time),
|
|
|
+ },
|
|
|
{
|
|
|
title: '操作',
|
|
|
dataIndex: 'actions',
|
|
|
fixed: 'right',
|
|
|
width: 150,
|
|
|
- className: 'titleStyle',
|
|
|
- slots: { customRender: 'action' }
|
|
|
+ slots: { customRender: 'action' },
|
|
|
},
|
|
|
]
|
|
|
|
|
|
const expandIcon = (props: any) => {
|
|
|
- if (judgeCurrentType(EDeviceTypeName.Dock) && !props.expanded) {
|
|
|
+ if (!props.expanded) {
|
|
|
return h('div',
|
|
|
{
|
|
|
style: 'border-left: 2px solid rgb(200,200,200); border-bottom: 2px solid rgb(200,200,200); height: 16px; width: 16px; float: left;',
|
|
|
@@ -181,7 +194,10 @@ const rowClassName = (record: any, index: number) => {
|
|
|
}
|
|
|
|
|
|
const expandRows = ref<string[]>([])
|
|
|
-const data = reactive<DeviceData>({
|
|
|
+
|
|
|
+const data: {
|
|
|
+ device: Device[]
|
|
|
+} = reactive({
|
|
|
device: []
|
|
|
})
|
|
|
|
|
|
@@ -189,7 +205,7 @@ const paginationProp = reactive({
|
|
|
pageSizeOptions: ['20', '50', '100'],
|
|
|
showQuickJumper: true,
|
|
|
showSizeChanger: true,
|
|
|
- pageSize: 50,
|
|
|
+ pageSize: 20,
|
|
|
current: 1,
|
|
|
total: 0
|
|
|
})
|
|
|
@@ -218,9 +234,8 @@ const rowSelection = {
|
|
|
}),
|
|
|
}
|
|
|
|
|
|
-type Pagination = TableState['pagination']
|
|
|
-
|
|
|
const workspaceId: string = localStorage.getItem(ELocalStorageKey.WorkspaceId) || ''
|
|
|
+
|
|
|
const editableData: UnwrapRef<Record<string, Device>> = reactive({})
|
|
|
|
|
|
const current = ref([EDeviceTypeName.Dock])
|
|
|
@@ -288,12 +303,10 @@ function getDevices(domain: number, closeLoading?: boolean) {
|
|
|
resData.forEach((val: any) => {
|
|
|
if (val.children) {
|
|
|
val.children = [val.children]
|
|
|
- }
|
|
|
- if (judgeCurrentType(EDeviceTypeName.Dock)) {
|
|
|
- expandRows.value.push(val.device_sn)
|
|
|
+ expandRows.value.push(val.device_sn);
|
|
|
}
|
|
|
})
|
|
|
- data.device = resData
|
|
|
+ data.device = resData;
|
|
|
paginationProp.total = res.data.pagination.total
|
|
|
paginationProp.current = res.data.pagination.page
|
|
|
paginationProp.pageSize = res.data.pagination.page_size
|
|
|
@@ -301,7 +314,7 @@ function getDevices(domain: number, closeLoading?: boolean) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function refreshData(page: Pagination) {
|
|
|
+function refreshData(page: any) {
|
|
|
paginationProp.current = page?.current!
|
|
|
paginationProp.pageSize = page?.pageSize!
|
|
|
getDevices(current.value[0])
|
|
|
@@ -318,15 +331,20 @@ function save(record: Device) {
|
|
|
updateDevice({ nickname: record.nickname }, workspaceId, record.device_sn)
|
|
|
}
|
|
|
|
|
|
-// 解绑
|
|
|
-function unbind() {
|
|
|
- deleteTip.value = false
|
|
|
- unbindDevice(deleteSn.value?.toString()!).then(res => {
|
|
|
- if (res.code !== 0) {
|
|
|
- return
|
|
|
- }
|
|
|
- getDevices(current.value[0])
|
|
|
- })
|
|
|
+// 点击删除
|
|
|
+const onClickDelete = (record: Device) => {
|
|
|
+ Modal.confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: `确定删除${record.device_name}吗?`,
|
|
|
+ onOk: async () => {
|
|
|
+ unbindDevice(record.device_sn).then(res => {
|
|
|
+ if (res.code !== 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ getDevices(current.value[0])
|
|
|
+ })
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
const currentDevice = ref({} as Device)
|
|
|
@@ -350,25 +368,9 @@ onMounted(() => {
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
-.device-table-wrap {
|
|
|
- .editable-row-operations {
|
|
|
- div>span {
|
|
|
- margin-right: 10px;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|
|
|
-
|
|
|
<style lang="scss">
|
|
|
-.table {
|
|
|
- background-color: white;
|
|
|
- margin: 20px;
|
|
|
- padding: 0 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.table-striped {
|
|
|
- background-color: #f7f9fa;
|
|
|
+.deviceList {
|
|
|
+ padding: 20px;
|
|
|
}
|
|
|
|
|
|
.ant-table {
|
|
|
@@ -380,42 +382,11 @@ onMounted(() => {
|
|
|
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;
|
|
|
+.table-striped {
|
|
|
+ background-color: #f7f9fa;
|
|
|
}
|
|
|
|
|
|
.child-row {
|
|
|
height: 70px;
|
|
|
}
|
|
|
-
|
|
|
-.notice {
|
|
|
- background: $success;
|
|
|
- overflow: hidden;
|
|
|
- cursor: pointer;
|
|
|
-}
|
|
|
-
|
|
|
-.caution {
|
|
|
- background: orange;
|
|
|
- cursor: pointer;
|
|
|
- overflow: hidden;
|
|
|
-}
|
|
|
-
|
|
|
-.warn {
|
|
|
- background: red;
|
|
|
- cursor: pointer;
|
|
|
- overflow: hidden;
|
|
|
-}
|
|
|
</style>
|