From 5b73519a2c26fea97b4dfd7f56ee6c4e5ea27dde Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Thu, 11 Sep 2025 15:55:37 +0800
Subject: [PATCH] Merge branch 'feature/v5.0/5.0.5' into feature/v6.0/6.0.1

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

diff --git a/src/views/device/airport.vue b/src/views/device/airport.vue
index 8411b2e..a02e974 100644
--- a/src/views/device/airport.vue
+++ b/src/views/device/airport.vue
@@ -57,7 +57,7 @@
       </template>
       <template #menu="scope">
         <el-dropdown>
-              <el-button type="primary" text icon="el-icon-folder-opened" v-if="permission.oss_set">更 多</el-button>
+          <el-button type="primary" text v-if="permission.oss_set"><el-icon><MoreFilled /></el-icon>更多</el-button>
               <template #dropdown v-if="scope.row.domain == 3">
                 <el-dropdown-menu teleported>
                   <el-dropdown-item command="a">
@@ -74,9 +74,9 @@
                   <el-dropdown-item command="d"><el-button type="primary" text icon="el-icon-collection" v-if="permission.fly_device_offline"
                         @click.stop="rollFirmware(scope.row)">固件版本管理</el-button>
                   </el-dropdown-item>
-                  <el-dropdown-item command="d">
-                    <el-button type="primary" text icon="el-icon-collection" v-if="!scope.row.status" @click.stop="dockNotLine(scope.row)">
-                      {{ scope.row.hidden_flag == 1 ? '设备上线' : '设备下线'}}
+                 <el-dropdown-item command="d" v-if="!scope.row.status">
+                    <el-button type="primary" text icon="el-icon-collection" @click.stop="dockNotLine(scope.row)">
+                      {{ scope.row.hidden_flag === 1 ? '设备上线' : '设备下线'}}
                     </el-button>
                   </el-dropdown-item>
                   <el-dropdown-item command="e"><el-button type="primary" text icon="el-icon-document-delete" v-if="permission.fly_device_offline"
@@ -86,17 +86,19 @@
               </template>
               <template #dropdown v-else>
                 <el-dropdown-menu teleported>
-                  <el-dropdown-item command="a">
+                  <!-- <el-dropdown-item command="a">
                     <el-button type="primary" text icon="el-icon-circle-close" @click.stop="rowDel(scope.row, scope.index)">删除</el-button>
-                  </el-dropdown-item>
-                  <el-dropdown-item command="a">
+                  </el-dropdown-item> -->
+                  <!-- <el-dropdown-item command="a">
                     <el-button type="primary" text icon="el-icon-key" v-if="permission.operate_password_set" @click.stop="handleOperatePassword(scope.row, scope.index)">操控密码设置</el-button>
+                  </el-dropdown-item> -->
+                  <el-dropdown-item command="d"><el-button type="primary" text icon="el-icon-collection"  @click.stop="rollFirmware(scope.row)">固件版本管理</el-button>
                   </el-dropdown-item>
                 </el-dropdown-menu>
               </template>
             </el-dropdown>
       </template>
-      
+
       <!-- 添加行政区划显示模板 -->
       <template #area_code="{ row }">
         <span>{{ row.area_name }}</span>
@@ -122,6 +124,20 @@
 
     <el-dialog title="操控密码查看" append-to-body v-model="operatePasswordViewBox" width="455px">
       <el-input v-model="operate_password" disabled></el-input>
+    </el-dialog>
+
+    <el-dialog title="注销" class="zx-cancel" append-to-body v-model="cancenOperate" width="460px">
+      <div style="display: flex;justify-content: center;margin-bottom: 10px;">注销
+        <span style="color:cornflowerblue;font-weight: bolder;margin: 0px 4px;">
+          {{ cancelSNName }}
+        </span> 设备可能会影响相关数据,确认注销吗?</div>
+        <div style="display: flex;justify-content: center;color:red;font-size: 12px;">*删除相关图片、视频、事件</div>
+      <template #footer>
+        <span class="dialog-footer" style="display: flex;justify-content: center;">
+          <el-button @click="cancenOperate = false">取 消</el-button>
+          <el-button type="primary" @click="cancenOperateDo">确 定</el-button>
+        </span>
+      </template>
     </el-dialog>
 
     <el-dialog title="固件升级" append-to-body v-model="firmwareBox" width="455px">
@@ -196,7 +212,8 @@
   getDeviceFirmwareList,
   getDevices,
   deviceOffline,
-  devicesUpdate
+  devicesUpdate,
+  devicesUpAndDown
 } from '@/api/device/device'
 import { deleteByOssId, addOrUpdate as addOrUpdateOssBind } from '@/api/device/ossBind'
 import { getListPage as getOssList } from '@/api/resource/oss'
@@ -232,10 +249,15 @@
       }
     }
     return {
+      treeResolveMap: new Map(),
       rules: {
         password: [{ required: true, validator: validatePass, trigger: 'blur' }],
         password2: [{ required: true, validator: validatePass2, trigger: 'blur' }],
       },
+      cancelSNName: '',
+      cancenOperate: false,
+      cancenOperateRow: {},
+      deleteFlag: false,
       passwordForm: {
         id: '',
         password: '',
@@ -310,7 +332,7 @@
             search: false,
             slot: true,
             searchSpan: 4,
-            labelWidth: 130,
+            labelWidth: 145,
             width: 120,
             // formatter: (row) => row.domain == 3 ? '机巢' : '无人机'
             // rules: [
@@ -327,7 +349,7 @@
             // editDisabled: true,
             editDisplay: false, //编辑显示
             viewDisplay: true, //查看显示
-            labelWidth: 130,
+            labelWidth: 145,
             width: 120,
             hide: true
           },
@@ -339,7 +361,7 @@
             viewDisplay: true, //查看显示
             search: false,
             searchSpan: 4,
-            labelWidth: 130,
+            labelWidth: 145,
             width: 120,
             // rules: [
             //   {
@@ -352,7 +374,7 @@
           {
             label: '设备SN',
             prop: 'device_sn',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 120,
             overHidden: true,
             searchSpan: 4,
@@ -369,7 +391,7 @@
           // {
           //   label: '机巢编号',
           //   prop: 'machine_nest_sn',
-          //   labelWidth: 130,
+          //   labelWidth: 145,
           //   editDisabled: true,
           //   rules: [
           //     {
@@ -386,25 +408,26 @@
             overHidden: true,
             editDisplay: false, //编辑显示
             viewDisplay: false, //查看显示
-            labelWidth: 130,
+            labelWidth: 145,
             width: 200,
           },
           {
             label: '设备位置',
             prop: 'area_code',
             type: 'cascader',
-            labelWidth: 130,
+            labelWidth: 145,
             searchSpan: 4,
             hide: true,
             search: true,
             // overHidden: true,
             editDisplay: true,
             viewDisplay: true,
+            checkStrictly: true,
+
             props: {
               label: 'title',
               value: 'value',
               emitPath: false,
-              checkStrictly: true,
               multiple: false,
               expandTrigger: 'hover',
             },
@@ -453,7 +476,7 @@
           {
             label: '设备名称',
             prop: 'nickname',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 160,
             searchSpan: 4,
             search: true,
@@ -467,11 +490,11 @@
               },
             ],
           },
-          
+
           // {
           //   label: '设备位置',
           //   prop: 'address',
-          //   labelWidth: 130,
+          //   labelWidth: 145,
           //   width: 100,
           //   overHidden: true,
           //   rules: [
@@ -486,7 +509,7 @@
           {
             label: '负载设备',
             prop: 'payload_str',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 160,
             overHidden: true,
             editDisplay: false, //编辑显示
@@ -503,7 +526,7 @@
             // hide: true,
             label: '保险有效期',
             prop: 'duration_of_insurance',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 200,
             type: 'daterange',
             format: 'YYYY-MM-DD',
@@ -512,7 +535,7 @@
             endPlaceholder: '保险结束日期',
             rules: [
               {
-                required: true,
+                required: false,
                 message: '请选择保险有效期',
                 trigger: 'blur',
               },
@@ -521,7 +544,7 @@
           // {
           //   label: '保险有效期',
           //   prop: 'insureExpiredTime',
-          //   labelWidth: 130,
+          //   labelWidth: 145,
           //   width: 110,
           //   rules: [
           //     {
@@ -534,7 +557,7 @@
           {
             label: '流量剩余',
             prop: 'traffic_remaining',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 100,
             // editDisabled: true,
             editDisplay: false, //编辑显示
@@ -549,7 +572,7 @@
           {
             label: '流量到期时间',
             prop: 'traffic_expire_time',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 120,
             type: 'date',
             format: 'YYYY-MM-DD',
@@ -566,7 +589,7 @@
           {
             label: '固件版本',
             prop: 'firmware_version',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 110,
             editDisplay: false, //编辑显示
             // editDisabled: true,
@@ -581,7 +604,7 @@
           {
             label: '固件升级',
             prop: 'firmware_status',
-            labelWidth: 130,
+            labelWidth: 145,
             width: 100,
             hide: true,
             viewDisabled: true,
@@ -605,7 +628,7 @@
             addDisplay: false,
             editDisplay: false,
             viewDisplay: false,
-            labelWidth: 130,
+            labelWidth: 145,
             width: 180,
             rules: [
               {
@@ -623,7 +646,7 @@
             defaultExpandAll: true,
             search: true,
             searchSpan: 4,
-            labelWidth: 130,
+            labelWidth: 145,
             dicUrl: '/blade-system/dept/getTree',
             props: {
               label: 'name',
@@ -643,7 +666,7 @@
           //   addDisplay: false,
           //   editDisplay: false,
           //   type: 'date',
-          //   labelWidth: 130,
+          //   labelWidth: 145,
           //   width: 160,
           //   format: 'YYYY-MM-DD HH:mm:ss',
           //   // valueFormat: 'YYYY-MM-DD HH:mm:ss',
@@ -657,7 +680,7 @@
           // },
 
 
-          
+
 
           {
             label: '在线时间',
@@ -666,9 +689,9 @@
             type: 'date',
             editDisplay: false, //编辑显示
             // editDisabled: true,
-            viewDisplay: true, //查看显示
+            viewDisplay: false, //查看显示
             addDisplay: true,
-            labelWidth: 130,
+            labelWidth: 145,
             width: 160,
             overHidden: true,
             format: 'YYYY-MM-DD HH:mm:ss',
@@ -683,16 +706,26 @@
             // ],
           },
           {
+            label: '设备最新在线时间',
+            hide: true,
+            prop: 'login_time',
+            type: 'date',
+            viewDisplay: true, //查看显示
+            labelWidth: 145,
+            overHidden: true,
+            format: 'YYYY-MM-DD HH:mm:ss',
+          },
+          {
             label: '注册时间',
             prop: 'create_time',
             type: 'date',
             hide: true,
             editDisplay: false, //编辑显示
             // editDisabled: true,
-            viewDisplay: true, //查看显示
+            viewDisplay: false, //查看显示
             addDisplay: true,
             overHidden: true,
-            labelWidth: 130,
+            labelWidth: 145,
             width: 160,
             format: 'YYYY-MM-DD HH:mm:ss',
             // valueFormat: 'YYYY-MM-DD HH:mm:ss',
@@ -706,13 +739,24 @@
             // ],
           },
           {
+            label: '设备注册时间',
+            prop: 'create_time',
+            type: 'date',
+            hide: true,
+            viewDisplay: true, //查看显示
+            overHidden: true,
+            labelWidth: 145,
+            width: 160,
+            format: 'YYYY-MM-DD HH:mm:ss',
+          },
+          {
             label: '设备状态',
             prop: 'cnstatus',
             hide: true,
             addDisplay: false,
             editDisplay: false,
             viewDisplay: false,
-            labelWidth: 130,
+            labelWidth: 145,
           },
           {
             label: '设备状态',
@@ -742,7 +786,7 @@
             addDisplay: false,
             editDisplay: false,
             viewDisplay: true,
-            labelWidth: 130,
+            labelWidth: 145,
             width: 110,
           },
           {
@@ -751,7 +795,7 @@
             addDisplay: false,
             editDisplay: false,
             viewDisplay: false,
-            labelWidth: 130,
+            labelWidth: 145,
             searchSpan: 4,
             search: true,
             type: 'select',
@@ -809,6 +853,7 @@
     },
   },
   destroyed () {
+    this.treeResolveMap.clear()
     this.websocketMap.forEach((k, v) => {
       if (null != v) {
         v.close()
@@ -913,25 +958,24 @@
       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.cancenOperate = true
+      this.cancelSNName = row.nickname
+      this.cancenOperateRow = row
+      
+    },
 
-              this.init()
-            })
-            .catch(error => {
-              ElMessage.error('注销失败')
-            })
-        })
-        .catch(() => { })
+    cancenOperateDo () {
+      this.cancenOperate = false
+      this.deleteFlag = false
+      deviceOffline(this.cancenOperateRow.device_sn, true).then(res => {
+        ElMessage.success('注销成功')
+        
+        this.init()
+      }).catch(error => {
+        ElMessage.error('注销失败')
+      })
     },
 
     // 打开存储对象配置页面
@@ -968,9 +1012,9 @@
       })
         .then(() => {
           let hidden_flag = row.hidden_flag === 1?0:1
-          devicesUpdate({id:row.id, hidden_flag:hidden_flag})
+          devicesUpAndDown({id:row.id, hiddenFlag:hidden_flag})
             .then(res => {
-              ElMessage.success('下线成功')
+              ElMessage.success(`${txt}成功`)
               this.init()
             })
             .catch(error => {
@@ -1254,8 +1298,10 @@
       const submitData = {
         ...row,
         area_code: row.area_code.split(',').pop(),
-        insure_start_time: row.duration_of_insurance[0],
-        insure_expired_time: row.duration_of_insurance[1],
+        insure_start_time: row.duration_of_insurance[0] || null,
+        insure_expired_time: row.duration_of_insurance[1] || null,
+        deptId: row.dept_id,
+        areaCode: row.area_code.split(',').pop(),
       }
       if (submitData.traffic_expire_time === '') {
         delete submitData.traffic_expire_time
@@ -1264,7 +1310,25 @@
 
       update(submitData).then(
         () => {
-          this.onLoad(this.page)
+          if (row.domain === 0) {
+            // 获取保存的 resolve 函数
+            const resolve = this.treeResolveMap.get(row.device_sn)
+            if (resolve) {
+              // 重新加载子节点数据
+              var params = {
+                childSn: row.device_sn,
+              }
+              getList(1, 10, params).then(res => {
+                const data = res.data.data.records
+                data.forEach(e => {
+                  e.duration_of_insurance = [e.insure_start_time || '', e.insure_expired_time || '']
+                })
+                resolve(data)
+              })
+            }
+          } else {
+            this.onLoad(this.page)
+          }
           this.$message({
             type: 'success',
             message: '操作成功!',
@@ -1416,11 +1480,16 @@
       })
     },
     treeLoad (tree, treeNode, resolve) {
+      // 保存resolve
+      this.treeResolveMap.set(tree.child_sn, resolve)
       var params = {
         childSn: tree.child_sn,
       }
       getList(1, 10, params).then(res => {
         const data = res.data.data.records
+        data.forEach(e => {
+          e.duration_of_insurance = [e.insure_start_time || '', e.insure_expired_time || '']
+        })
         resolve(data)
       })
     },
@@ -1559,5 +1628,11 @@
   right: 0;
 }
 
+:deep(.avue-crud__pagination) {
+  position: fixed;
+  bottom: 10px;
+  right: 30px;
+}
+
 
 </style>

--
Gitblit v1.9.3