From 2dfc8dc4bcd3d3cd4aed1b6054e073e140eba9c8 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 19 May 2025 16:05:50 +0800
Subject: [PATCH] Merge branch 'master' into jiangwu

---
 src/views/device/addDevice.vue |  208 +++++++++++++++------------------------------------
 1 files changed, 63 insertions(+), 145 deletions(-)

diff --git a/src/views/device/addDevice.vue b/src/views/device/addDevice.vue
index 7d34424..6bf203f 100644
--- a/src/views/device/addDevice.vue
+++ b/src/views/device/addDevice.vue
@@ -4,7 +4,7 @@
             v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave"
             :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset"
             @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
-            @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad">
+            @refresh-change="refreshChange" @on-load="onLoad">
 
             <template #menu="scope">
                 <el-button type="primary" text icon="el-icon-copy-document" @click.stop="copyInfo(scope.row, scope.index)"
@@ -30,6 +30,7 @@
 import { getWebsocketUrl } from '@/websocket/util/config';
 import ConnectWebSocket from '@/websocket';
 import { $Clipboard } from "@smallwei/avue";
+
 
 export default {
     components: {
@@ -64,9 +65,9 @@
                 menuWidth: 300,
                 lazy: true,
                 tree: true,
-                height: '460',
-                calcHeight: 32,
-                dialogWidth: 1050,
+                // height: '460',
+                // calcHeight: 32,
+                // dialogWidth: 1050,
                 tip: false,
                 searchShow: true,
                 searchMenuSpan: 6,
@@ -157,6 +158,30 @@
                         ],
                     },
                     {
+                        label: '设备类型',
+                        prop: 'type',
+                        type: 'radio',
+                        labelWidth: 130,
+                        value: 0,
+                        dicData: [
+                            {
+                                label: '机场',
+                                value: 0
+                            },
+                            {
+                                label: '遥控器',
+                                value: 1
+                            }
+                        ],
+                        rules: [
+                            {
+                                required: true,
+                                message: '请选择设备类型',
+                                trigger: 'change',
+                            },
+                        ],
+                    },
+                    {
                         label: '创建时间',
                         prop: 'create_time',
                         addDisplay: false,
@@ -171,18 +196,7 @@
                 ],
             },
             data: [],
-            DeviceFirmwareTypeEnum: {
-                // 普通升级
-                ToUpgraded: 3,
-                // 一致性升级
-                ConsistencyUpgrade: 2,
-            },
-            DeviceFirmwareStatusEnum: {
-                None: 1, // 无需升级
-                ToUpgraded: 2, // 待升级
-                ConsistencyUpgrade: 3, // 一致性升级
-                DuringUpgrade: 4, // 升级中
-            },
+
         };
     },
     computed: {
@@ -215,7 +229,16 @@
     methods: {
 
         copyInfo(row, index) {
-            let params = `host: tcp://139.196.74.78:1883   账号:drone  密码:123456  组织id:${row.bing_id}  设备码:${row.bind_code}  机场名称:${row.workspace_name}   aircrattName:${row.workspace_desc}`;
+            if(import.meta.env.VITE_APP_ENV==='development'){
+                // alert('地址'+import.meta.env.VITE_APP_ENV);
+                let params = `
+            host: tcp://139.196.74.78:1883
+            账号:drone  
+            密码:123456  
+            组织id:${row.bing_id}  
+            设备码:${row.bind_code}  
+            机场名称:${row.workspace_name}   
+            aircrattName:${row.workspace_desc}`;
             $Clipboard({
                 text: params,
             }).then(() => {
@@ -223,73 +246,26 @@
             }).catch(() => {
                 this.$message.error("复制失败");
             });
-        },
-
-        // 关闭所有的webscoket
-        closeAllWebsoket() {
-            this.websocketMap.forEach((k, v) => {
-                if (null != v) {
-                    v.close()
-                    this.websocketMap.delete(k)
-                    this.webSocketIdSet.delete(k)
-                }
-            });
-        },
-        // 连接webSocket
-        connectWebSocket(data) {
-            const webSocketId = data.workspace_id
-            if (!this.webSocketIdSet.has(webSocketId)) {
-                // 防止重复连接
-                this.webSocketIdSet.add(webSocketId);
-                const webSorketUrl = getWebsocketUrl() + '&workspace-id=' + data.workspace_id;
-                // 监听ws 消息
-                this.useConnectWebSocket(webSocketId, webSorketUrl);
-            }
-        },
-        useConnectWebSocket(webSocketId, url) {
-            const websocket = new ConnectWebSocket(url);
-            // 加入 webscoket map
-            this.websocketMap.set(webSocketId, websocket)
-            websocket?.registerMessageHandler(this.messageHandler);
-            websocket?.initSocket();
-        },
-        async messageHandler(payload) {
-            console.log(payload, 7777);
-
-            if (!payload) {
-                return;
-            }
-            if (payload.biz_code != "ota_progress") {
-                return;
-            }
-            var data = payload.data;
-            this.data.forEach(e => {
-                if (e.device_sn == data.sn && data.output.status == 'in_progress') {
-                    e.firmware_progress = data.output.progress.percent;
-                }
-
-                if (e.device_sn == data.sn && data.output.status == 'ok') {
-                    // 升级完成修改状态
-                    e.firmware_status = 1
-                    const webscoket = this.websocketMap.get(e.workspace_id);
-                    // 关闭
-                    webscoket?.close();
-                    //删除对应的webscoket
-                    this.websocketMap.delete(e.workspace_id);
-                    this.webSocketIdSet.delete(e.workspace_id);
-                }
-            });
+        }else{
+            // alert('地址'+import.meta.env.VITE_APP_ENV);
+            let params = `
+            host: tcp://101.132.85.201:1883 
+            账号:drone  
+            密码:drone@123
+            组织id:${row.bing_id}  
+            设备码:${row.bind_code}  
+            机场名称:${row.workspace_name}   
+            aircrattName:${row.workspace_desc}`;
+            $Clipboard({
+                text: params,
+            }).then(() => {
+                this.$message.success("复制成功");
+            }).catch(() => {
+                this.$message.error("复制失败");
+            });}
         },
         init() {
             this.onLoad(this.page);
-        },
-        // 打开权限分享页面
-        handleOpenDevicePerShare(row) {
-            var that = this;
-            this.devicePerShareVisible = true;
-            this.$nextTick(() => {
-                that.$refs.devicePerShare.init(row);
-            });
         },
 
         handleOpenRemoteDebugging(row) {
@@ -297,63 +273,6 @@
             this.remoteDebuggingShow = true;
         },
 
-        // 打开固件管理页面
-        handleOpenFirmwarm(row) {
-            var that = this;
-            this.firmwareManageVisible = true;
-            this.$nextTick(() => {
-                that.$refs.firmwareManage.init(row);
-            });
-        },
-        // 升级固件按钮事件
-        updateFirmware(row) {
-            if (row.status == 0) {
-                this.$message({
-                    type: 'warning',
-                    message: '设备不在线!',
-                });
-                return;
-            }
-            var that = this;
-            this.firmwareBox = true;
-            const param = {
-                device_name: row.device_name,
-            };
-            // 获取固件最新版本信息
-            getDeviceUpgradeInfo(param).then(res => {
-                const data = res.data.data;
-                if (data.length === 0) {
-                    return;
-                }
-                that.firmwareVersion = data[0].product_version;
-                that.firmwareInfo['device_name'] = row.device_name;
-                that.firmwareInfo['sn'] = row.device_sn;
-                that.firmwareInfo['product_version'] = data[0].product_version;
-                // 1-普通升级,2-一致性升级;
-                that.firmwareInfo['firmware_upgrade_type'] =
-                    row.firmware_status === that.DeviceFirmwareStatusEnum.ToUpgraded
-                        ? that.DeviceFirmwareTypeEnum.ToUpgraded
-                        : that.DeviceFirmwareTypeEnum.ConsistencyUpgrade;
-                that.firmwareInfo['workspaceId'] = row.workspace_id;
-            });
-        },
-        // 确定升级固件版本
-        updateFirmwareConfirm() {
-            var that = this;
-            var arr = [];
-            arr.push(that.firmwareInfo);
-            ota(that.firmwareInfo.workspaceId, arr).then(res => {
-                that.firmwareVersion = '';
-                that.firmwareInfo = {};
-                that.firmwareBox = false;
-                this.$message({
-                    type: 'success',
-                    message: '操作成功!',
-                });
-                this.onLoad(this.page);
-                done();
-            });
-        },
         rowSave(row, done, loading) {
             add(row).then(
                 () => {
@@ -460,7 +379,6 @@
             this.onLoad(this.page, this.query);
         },
         onLoad(page, params = {}) {
-            this.closeAllWebsoket()
             const { releaseTimeRange } = this.query;
             let values = {
                 ...params,
@@ -479,12 +397,12 @@
             getList(page.currentPage, page.pageSize, values).then(res => {
                 const data = res.data.data;
                 this.page.total = data.total;
-                data.records.forEach(e => {
-                    e['hasChildren'] = e.has_children;
-                    if (e.firmware_status == 4) {
-                        this.connectWebSocket(e);
-                    }
-                });
+                // data.records.forEach(e => {
+                //     e['hasChildren'] = e.has_children;
+                //     if (e.firmware_status == 4) {
+                //         this.connectWebSocket(e);
+                //     }
+                // });
                 this.data = data.records;
                 this.loading = false;
                 this.selectionClear();

--
Gitblit v1.9.3