From c832bf2e80ac465e71b7a1c1f7a59d4252030989 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 05 Aug 2025 17:33:08 +0800
Subject: [PATCH] feat:事件工单滚动条

---
 src/views/device/airport.vue |   80 ++++++++++++++++++++++++++++++---------
 1 files changed, 61 insertions(+), 19 deletions(-)

diff --git a/src/views/device/airport.vue b/src/views/device/airport.vue
index 5174735..eb61ea9 100644
--- a/src/views/device/airport.vue
+++ b/src/views/device/airport.vue
@@ -62,6 +62,10 @@
           v-if="permission.rang_con && scope.row.domain == 3"
           @click.stop="handleOpenRemoteDebugging(scope.row, scope.index)">远程调试
         </el-button>
+
+        <el-button type="primary" text icon="el-icon-setting" v-if="permission.fly_device_offline"
+          @click.stop="handleDeviceOffline(scope.row)">设备下线
+        </el-button>
       </template>
       <!-- 添加行政区划显示模板 -->
       <template #area_code="{ row }">
@@ -128,6 +132,8 @@
 </template>
 
 <script>
+import { ElMessage, ElMessageBox } from 'element-plus'
+
 import {
   getList,
   remove,
@@ -138,6 +144,7 @@
   ota,
   getDeviceFirmwareList,
   getDevices,
+  deviceOffline
 } from '@/api/device/device'
 import { deleteByOssId, addOrUpdate as addOrUpdateOssBind } from '@/api/device/ossBind'
 import { getListPage as getOssList } from '@/api/resource/oss'
@@ -383,18 +390,6 @@
                 trigger: 'change',
               },
             ],
-            change: ({ value }) => {
-              if (!value) {
-                this.form.area_code = null
-              } else {
-                if (typeof value === 'string' && value.includes(',')) {
-                  const codes = value.split(',')
-                  this.form.area_code = codes[codes.length - 1]
-                } else {
-                  this.form.area_code = value
-                }
-              }
-            },
             lazy: true,
             lazyLoad (node, resolve) {
               let level = node.level
@@ -435,7 +430,7 @@
             label: '保险有效期',
             prop: 'duration_of_insurance',
             labelWidth: 130,
-            type: "daterange",
+            type: 'daterange',
             format: 'YYYY-MM-DD',
             valueFormat: 'YYYY-MM-DD HH:mm:ss',
             startPlaceholder: '保险开始日期',
@@ -470,12 +465,23 @@
           },
           {
             label: '在线状态',
+            prop: 'cnstatus',
+            hide: true,
+            addDisplay: false,
+            editDisplay: false,
+            viewDisplay: true,
+            labelWidth: 130,
+          },
+          {
+            label: '在线状态',
             prop: 'status',
             addDisplay: false,
             editDisplay: false,
+            viewDisplay: false,
             labelWidth: 130,
             slot: true,
             width: 100,
+
             rules: [
               {
                 required: true,
@@ -486,12 +492,24 @@
           },
           {
             label: '机场状态',
-            prop: 'mode_code',
+            prop: 'cnmode_code',
+            hide: true,
             addDisplay: false,
             editDisplay: false,
+            viewDisplay: true,
+            labelWidth: 130,
+          },
+          {
+            label: '机场状态',
+            prop: 'mode_code',
+
+            addDisplay: false,
+            editDisplay: false,
+            viewDisplay: false,
             labelWidth: 130,
             slot: true,
             width: 100,
+
             rules: [
               {
                 required: true,
@@ -623,6 +641,28 @@
       this.remoteDebuggingShow = true
       this.operateTitle = row.nickname + ' - ' + row.device_sn
     },
+
+    // 设备下线
+    handleDeviceOffline (row) {
+      ElMessageBox.confirm('确定下线该设备吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      })
+        .then(() => {
+          deviceOffline(row.device_sn)
+            .then(res => {
+              ElMessage.success('下线成功')
+
+              this.init()
+            })
+            .catch(error => {
+              ElMessage.error('下线失败')
+            })
+        })
+        .catch(() => { })
+    },
+
     // 打开存储对象配置页面
     handleOpenOssSet (row) {
       var that = this
@@ -999,7 +1039,7 @@
           this.$refs.crud.toggleSelection()
         })
     },
-    getFullAreaCode (areaCode) {
+    async getFullAreaCode (areaCode) {
       if (!areaCode) return ''
 
       const code = areaCode.toString()
@@ -1019,15 +1059,17 @@
     },
     beforeOpen (done, type) {
       if (['edit', 'view'].includes(type)) {
-        getDetail(this.form.id).then(res => {
+        getDetail(this.form.id).then(async res => {
           const data = res.data.data
+
           this.form = {
             ...data,
-            area_code: this.getFullAreaCode(data.area_code),
+            area_code: await this.getFullAreaCode(data.area_code),
             area_name: this.form.area_name,
-            duration_of_insurance: [data?.insure_start_time || '', data?.insure_expired_time || '']
+            cnmode_code: this.getDockModeText(this.form.mode_code),
+            cnstatus: this.form.status === false ? '离线' : '在线',
+            duration_of_insurance: [data?.insure_start_time || '', data?.insure_expired_time || ''],
           }
-          console.log('this.form', this.form)
 
           done()
         })

--
Gitblit v1.9.3