无人机管理后台前端(已迁走)
chenyao
2025-08-29 8a7bc685c7ba3a2d9cd69cfefc37fa9be4dead25
feat:更新设备管理和注册管理
6 files modified
366 ■■■■■ changed files
src/views/device/addDevice.vue 1 ●●●● patch | view | raw | blame | history
src/views/device/airport.vue 264 ●●●● patch | view | raw | blame | history
src/views/device/components/DeviceSettingBox.vue 69 ●●●●● patch | view | raw | blame | history
src/views/device/components/DeviceSettingPopover.vue 23 ●●●●● patch | view | raw | blame | history
src/views/device/components/DockControlPanel.vue 4 ●●●● patch | view | raw | blame | history
src/views/device/index.vue 5 ●●●●● patch | view | raw | blame | history
src/views/device/addDevice.vue
@@ -186,6 +186,7 @@
                        prop: 'create_time',
                        addDisplay: false,
                        editDisplay: false,
                        overHidden: true,
                        type: 'date',
                        labelWidth: 130,
                        width: 160,
src/views/device/airport.vue
@@ -45,16 +45,51 @@
            :percentage="row.firmware_progress"></el-progress>
        </div>
      </template>
      <template #domain="{ row }">
        <span class="text">
          {{ row.domain == 3 ? '机巢' : row.domain == 0 ? '无人机' : '其他' }}
        </span>
      </template>
      <template #mode_code="{ row }">
        <span class="text" v-if="row.domain == 3" :style="row.mode_code != '-1' ? 'color: #00ee8b' : 'color: #de5e5e'">
          {{ getDockModeText(row.mode_code) }}
        </span>
      </template>
      <template #menu="scope">
         <div class="more-container">
            <el-button type="primary" text icon="el-icon-paperclip" v-if="permission.oss_set" @click.stop="moreClick(scope, permission, $event)">更 多</el-button>
        </div>
        <el-dropdown>
              <el-button type="primary" text icon="el-icon-paperclip" v-if="permission.oss_set">更 多</el-button>
              <template #dropdown v-if="scope.row.domain == 3">
                <el-dropdown-menu teleported>
                  <el-dropdown-item command="a">
                    <el-button type="primary" text icon="el-icon-paperclip" v-if="permission.oss_set" @click.stop="handleOpenOssSet(scope.row, scope.index)">存储配置</el-button>
                  </el-dropdown-item>
                  <el-dropdown-item command="b">
                    <el-button type="primary" text icon="el-icon-share" v-if="permission.per_share && scope.row.domain == 3"
                      @click.stop="handleOpenDevicePerShare(scope.row, scope.index)">机场授权</el-button>
                  </el-dropdown-item>
                  <el-dropdown-item command="c"> <el-button type="primary" text icon="el-icon-position" :disabled="!scope.row.status"
                    v-if="permission.rang_con && scope.row.domain == 3"
                    @click.stop="handleOpenRemoteDebugging(scope.row, scope.index)">远程调试</el-button>
                  </el-dropdown-item>
                  <el-dropdown-item command="d"><el-button type="primary" text icon="el-icon-setting" v-if="permission.fly_device_offline"
                        @click.stop="rollFirmware(scope.row)">固件版本管理</el-button>
                  </el-dropdown-item>
                  <el-dropdown-item command="e"><el-button type="primary" text icon="el-icon-setting" v-if="permission.fly_device_offline"
                    @click.stop="handleDeviceOffline(scope.row)">注销</el-button>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </template>
              <template #dropdown v-else>
                <el-dropdown-menu teleported>
                  <el-dropdown-item command="a">
                    <el-button type="primary" text icon="el-icon-paperclip" @click.stop="rowDel(scope.row, scope.index)">删除</el-button>
                  </el-dropdown-item>
                  <el-dropdown-item command="a">
                    <el-button type="primary" text icon="el-icon-paperclip" v-if="permission.operate_password_set" @click.stop="handleOperatePassword(scope.row, scope.index)">操控密码设置</el-button>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
      </template>
      
      <!-- 添加行政区划显示模板 -->
@@ -63,27 +98,26 @@
      </template>
    </avue-crud>
    <div v-show="moreDialogVisible" class="show-more-do" :style="{ top: `${popupPosition.top}px`}">
      <el-button type="primary" text icon="el-icon-paperclip" v-if="permission.oss_set"
        @click.stop="handleOpenOssSet(moreDialogData.row, moreDialogData.index)">存储配置
      </el-button>
      <el-button type="primary" text icon="el-icon-share" v-if="morePermission.per_share && moreDialogData.row.domain == 3"
        @click.stop="handleOpenDevicePerShare(moreDialogData.row, moreDialogData.index)">机场授权
      </el-button>
      <el-button type="primary" text icon="el-icon-position" :disabled="!moreDialogData.row.status"
        v-if="morePermission.rang_con && moreDialogData.row.domain == 3"
        @click.stop="handleOpenRemoteDebugging(moreDialogData.row, moreDialogData.index)">远程调试
      </el-button>
      <!-- <el-button type="primary" text icon="el-icon-setting" v-if="morePermission.fly_device_offline"
        @click.stop="handleDeviceOffline(moreDialogData.row)">设备下线
      </el-button> -->
      <el-button type="primary" text icon="el-icon-setting" v-if="morePermission.fly_device_offline"
        @click.stop="rollFirmware(moreDialogData.row)">固件版本管理
      </el-button>
      <el-button type="primary" text icon="el-icon-setting" v-if="morePermission.fly_device_offline"
        @click.stop="handleDeviceOffline(moreDialogData.row)">注销
      </el-button>
    </div>
    <el-dialog title="操控密码设置" append-to-body v-model="operatePasswordSetBox" width="450px">
      <el-form :model="passwordForm" ref="passwordForm" label-width="80px" :rules="rules" v-loading="loadingForm">
        <el-form-item label="密码" prop="password">
          <el-input type="password" v-model="passwordForm.password" placeholder="请输入密码" show-password></el-input>
        </el-form-item>
        <el-form-item label="确认密码" prop="password2">
          <el-input type="password" v-model="passwordForm.password2" placeholder="请输入确认密码" show-password></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="operatePasswordSetBox = false">取 消</el-button>
          <el-button type="primary" @click="setOperatePasswordConfirm">确 定</el-button>
        </span>
      </template>
    </el-dialog>
    <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="固件升级" append-to-body v-model="firmwareBox" width="455px">
      <div>升级固件版本:{{ firmwareVersion }}</div>
@@ -145,7 +179,7 @@
<script>
import { ElMessage, ElMessageBox } from 'element-plus'
import { pxToRem } from '@/utils/rem'
import {
  getList,
  remove,
@@ -175,11 +209,35 @@
    DockControlPanel,
  },
  data () {
    const validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'))
      } else {
        callback()
      }
    }
    const validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'))
      } else if (value !== this.passwordForm.password) {
        callback(new Error('两次输入密码不一致!'))
      } else {
        callback()
      }
    }
    return {
      moreDialogVisible: false,
      popupPosition: { top: 0 }, // 弹出框位置
      moreDialogData: [],
      morePermission: {},
      rules: {
        password: [{ required: true, validator: validatePass, trigger: 'blur' }],
        password2: [{ required: true, validator: validatePass2, trigger: 'blur' }],
      },
      passwordForm: {
        id: '',
        password: '',
        password2: '',
      },
      operatePasswordSetBox: false,
      operatePasswordViewBox: false,
      operate_password: '',
      bindOssId: null,
      deviceSn: '',
      ossSetBox: false,
@@ -235,11 +293,30 @@
        column: [
          {
            label: '设备类型',
            prop: 'domain',
            editDisabled: true,
            editDisplay: false, //编辑显示
            viewDisplay: true, //查看显示
            search: false,
            slot: true,
            searchSpan: 4,
            labelWidth: 130,
            width: 120,
            // rules: [
            //   {
            //     required: true,
            //     message: '请输入设备类型',
            //     trigger: 'blur',
            //   },
            // ],
          },
          {
            label: '设备型号',
            prop: 'device_name',
            editDisabled: true,
            viewDisplay: true, //查看显示
            search: true,
            search: false,
            searchSpan: 4,
            labelWidth: 130,
            width: 120,
@@ -257,7 +334,6 @@
            labelWidth: 130,
            width: 120,
            overHidden: true,
            search: true,
            searchSpan: 4,
            editDisabled: true,
            // rules: [
@@ -286,6 +362,8 @@
            prop: 'nickname',
            labelWidth: 130,
            width: 100,
            searchSpan: 4,
            search: true,
            overHidden: true,
            editDisplay: true, //编辑显示
            rules: [
@@ -304,13 +382,16 @@
            editDisplay: false, //编辑显示
            viewDisplay: false, //查看显示
            labelWidth: 130,
            width: 100,
          },
          {
            label: '设备位置',
            prop: 'area_code',
            type: 'cascader',
            labelWidth: 130,
            searchSpan: 4,
            hide: true,
            search: true,
            // overHidden: true,
            editDisplay: true,
            viewDisplay: true,
@@ -384,6 +465,7 @@
            prop: 'payload_str',
            labelWidth: 130,
            width: 100,
            overHidden: true,
            editDisabled: true,
            // rules: [
            //   {
@@ -422,7 +504,7 @@
          },
          {
            label: '流量到期时间',
            prop: 'traffic_expire_time"',
            prop: 'traffic_expire_time',
            labelWidth: 130,
            width: 120,
            type: 'date',
@@ -492,6 +574,8 @@
            hide: true,
            type: 'tree',
            defaultExpandAll: true,
            search: true,
            searchSpan: 4,
            labelWidth: 130,
            dicUrl: '/blade-system/dept/getTree',
            props: {
@@ -555,6 +639,7 @@
            addDisplay: true,
            labelWidth: 130,
            width: 160,
            overHidden: true,
            format: 'YYYY-MM-DD HH:mm:ss',
            // valueFormat: 'YYYY-MM-DD HH:mm:ss',
            startPlaceholder: '任务开始时间',
@@ -574,6 +659,7 @@
            editDisabled: true,
            viewDisplay: true, //查看显示
            addDisplay: true,
            overHidden: true,
            labelWidth: 130,
            width: 160,
            format: 'YYYY-MM-DD HH:mm:ss',
@@ -593,7 +679,7 @@
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: true,
            viewDisplay: false,
            labelWidth: 130,
          },
          {
@@ -602,7 +688,9 @@
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            labelWidth: 130,
            labelWidth: 100,
            searchSpan: 4,
            search: true,
            slot: true,
            width: 100,
@@ -615,7 +703,7 @@
            ],
          },
          {
            label: '机场状态',
            label: '设备状态',
            prop: 'cnmode_code',
            hide: true,
            addDisplay: false,
@@ -624,24 +712,24 @@
            labelWidth: 130,
            width: 110,
          },
          {
            label: '机场状态',
            prop: 'mode_code',
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            labelWidth: 130,
            slot: true,
            width: 110,
          // {
          //   label: '设备状态',
          //   prop: 'mode_code',
          //   addDisplay: false,
          //   editDisplay: false,
          //   viewDisplay: false,
          //   labelWidth: 130,
          //   slot: true,
          //   width: 110,
            rules: [
              {
                required: true,
                message: '请输入机场状态',
                trigger: 'blur',
              },
            ],
          },
          //   rules: [
          //     {
          //       required: true,
          //       message: '请输入机场状态',
          //       trigger: 'blur',
          //     },
          //   ],
          // },
        ],
      },
      data: [],
@@ -759,7 +847,6 @@
    },
    // 打开权限分享页面
    handleOpenDevicePerShare (row) {
      this.moreDialogVisible = false
      var that = this
      this.devicePerShareVisible = true
      this.$nextTick(() => {
@@ -768,7 +855,6 @@
    },
    // 打开远程调试
    handleOpenRemoteDebugging (row) {
      this.moreDialogVisible = false
      this.curDeviceInfo = row
      this.remoteDebuggingShow = true
      this.operateTitle = row.nickname + ' - ' + row.device_sn
@@ -776,7 +862,6 @@
    // 设备下线
    handleDeviceOffline (row) {
      this.moreDialogVisible = false
      ElMessageBox.confirm('确定注销该设备吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
@@ -796,33 +881,16 @@
        .catch(() => { })
    },
    // 点击更多
    moreClick(value, permission, event) {
      this.moreDialogData = value
      this.morePermission = permission
      this.moreDialogVisible = true
      console.log('4444', this.moreDialogVisible)
      // 获取按钮位置
      const rect = event.target.getBoundingClientRect();
      console.log(event)
      this.popupPosition = {
        top: rect.bottom - 150, // 按钮底部位置
      };
    },
    handleClickOutside(event) {
      // 检查点击是否发生在 .more-container 内
      const moreContainer = document.querySelector('.more-container');
      if (moreContainer && moreContainer.contains(event.target)) {
        return; // 如果点击在容器内,什么都不做
      }
      this.moreDialogVisible = false; // 否则关闭下拉菜单
    },
    // 打开存储对象配置页面
    handleOpenOssSet (row) {
      this.moreDialogVisible = false
      var that = this
      this.deviceSn = row.device_sn
      this.ossSetBox = true
@@ -1225,6 +1293,7 @@
            area_code: await this.getFullAreaCode(data.area_code),
            area_name: this.form.area_name,
            cnmode_code: this.getDockModeText(this.form.mode_code),
            domain: data.domain === 0 ? '无人机' : data.domain === 3 ? '机巢' : '未知',
            cnstatus: this.form.status === false ? '离线' : '在线',
            duration_of_insurance: [data?.insure_start_time || '', data?.insure_expired_time || ''],
          }
@@ -1282,6 +1351,55 @@
        resolve(data)
      })
    },
    rowDel (row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          return remove(row.id)
        })
        .then(() => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
        })
    },
    // 设置无人机操作密码
    setOperatePasswordConfirm () {
      var that = this
      this.$refs.passwordForm.validate(valid => {
        if (valid) {
          this.loadingForm = true
          const data = {
            id: this.passwordForm.id,
            operate_password: this.passwordForm.password,
          }
          // 提交
          operatePasswordUpdate(data).then(res => {
            this.loadingForm = false
            this.operatePasswordSetBox = false
            that.passwordForm = {}
            this.onLoad(this.page)
            this.$message({
              type: 'success',
              message: '操作成功!',
            })
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    // 操作密码设置
    handleOperatePassword (row) {
      this.operatePasswordSetBox = true
      this.passwordForm.id = row.id
    },
  },
}
</script>
src/views/device/components/DeviceSettingBox.vue
@@ -57,15 +57,15 @@
                <span class="form-label"
                  >{{ deviceSetting[DeviceSettingKeyEnum.NIGHT_LIGHTS_MODE_SET].label }}:</span
                >
                <a-switch
                  checked-children="开"
                  un-checked-children="关"
                  v-model:checked="deviceSettingFormModel.nightLightsState"
                <el-switch
                  active-text="开"
                  inactive-text="关"
                  v-model="deviceSettingFormModel.nightLightsState"
                />
              </div>
            </template>
            <a
              @click="
              @click.stop="
                onShowPopConfirm(
                  deviceSetting[DeviceSettingKeyEnum.NIGHT_LIGHTS_MODE_SET].settingKey
                )
@@ -95,14 +95,15 @@
            <template #formContent>
              <div class="form-content">
                <span class="form-label"
                  >{{ deviceSetting[DeviceSettingKeyEnum.HEIGHT_LIMIT_SET].label }}:</span
                  >{{ deviceSetting[DeviceSettingKeyEnum.HEIGHT_LIMIT_SET].label }}:(m)</span
                >
                <a-input-number
                  v-model:value="deviceSettingFormModel.heightLimit"
                <el-input-number
                  size="small"
                  v-model="deviceSettingFormModel.heightLimit"
                  :min="20"
                  :max="1500"
                />
                m
              </div>
            </template>
            <a
@@ -136,14 +137,15 @@
                <span class="form-label"
                  >{{ deviceSetting[DeviceSettingKeyEnum.DISTANCE_LIMIT_SET].label }}:</span
                >
                <a-switch
                <el-switch
                  style="margin-right: 10px"
                  checked-children="开"
                  un-checked-children="关"
                  v-model:checked="deviceSettingFormModel.distanceLimitStatus.state"
                  active-text="开"
                  inactive-text="关"
                  v-model="deviceSettingFormModel.distanceLimitStatus.state"
                />
                <a-input-number
                  v-model:value="deviceSettingFormModel.distanceLimitStatus.distanceLimit"
                <el-input-number
                  size="small"
                  v-model="deviceSettingFormModel.distanceLimitStatus.distanceLimit"
                  :min="15"
                  :max="8000"
                />
@@ -189,10 +191,10 @@
                <span class="form-label"
                  >{{ deviceSetting[DeviceSettingKeyEnum.OBSTACLE_AVOIDANCE_HORIZON].label }}:</span
                >
                <a-switch
                  checked-children="开"
                  un-checked-children="关"
                  v-model:checked="deviceSettingFormModel.obstacleAvoidanceHorizon"
                <el-switch
                  active-text="开"
                  inactive-text="关"
                  v-model="deviceSettingFormModel.obstacleAvoidanceHorizon"
                />
              </div>
            </template>
@@ -237,10 +239,10 @@
                <span class="form-label"
                  >{{ deviceSetting[DeviceSettingKeyEnum.OBSTACLE_AVOIDANCE_UPSIDE].label }}:</span
                >
                <a-switch
                  checked-children="开"
                  un-checked-children="关"
                  v-model:checked="deviceSettingFormModel.obstacleAvoidanceUpside"
                <el-switch
                  active-text="开"
                  inactive-text="关"
                  v-model="deviceSettingFormModel.obstacleAvoidanceUpside"
                />
              </div>
            </template>
@@ -287,10 +289,10 @@
                    deviceSetting[DeviceSettingKeyEnum.OBSTACLE_AVOIDANCE_DOWNSIDE].label
                  }}:</span
                >
                <a-switch
                  checked-children="开"
                  un-checked-children="关"
                  v-model:checked="deviceSettingFormModel.obstacleAvoidanceDownside"
                <el-switch
                  active-text="开"
                  inactive-text="关"
                  v-model="deviceSettingFormModel.obstacleAvoidanceDownside"
                />
              </div>
            </template>
@@ -312,14 +314,16 @@
<script setup>
import { defineProps, ref, watch } from 'vue';
import { cloneDeep } from 'lodash';
import { initDeviceSetting, initDeviceSettingFormModel } from '@/types/device-setting';
import { initDeviceSetting, initDeviceSettingFormModel, DeviceSettingKeyEnum } from '@/types/device-setting';
import {
  updateDeviceSettingInfoByOsd,
  updateDeviceSettingFormModelByOsd,
} from '@/utils/device-setting';
import { useDeviceSetting } from './use-device-setting';
import DeviceSettingPopover from './DeviceSettingPopover.vue'
const props = defineProps();
// const props = defineProps();
const props = defineProps(['sn', 'deviceInfo'])
const deviceSetting = ref(cloneDeep(initDeviceSetting));
const deviceSettingFormModelFromOsd = ref(cloneDeep(initDeviceSettingFormModel));
@@ -351,6 +355,7 @@
async function onConfirm(settingKey) {
  deviceSetting.value[settingKey].popConfirm.loading = true;
  const body = genDevicePropsBySettingKey(settingKey, deviceSettingFormModel.value);
  console.log(body, '顶顶顶顶顶')
  await setDeviceProps(props.sn, body);
  deviceSetting.value[settingKey].popConfirm.loading = false;
  deviceSetting.value[settingKey].popConfirm.visible = false;
@@ -408,6 +413,12 @@
          font-weight: 700;
        }
      }
      .control-setting-item-right {
        .el-tooltip__trigger {
          color: #1C5CFF;
          cursor: pointer;
        }
      }
    }
  }
}
src/views/device/components/DeviceSettingPopover.vue
@@ -1,41 +1,38 @@
<template>
  <a-popover
  <el-popover
    :visible="state.sVisible"
    trigger="click"
    v-bind="$attrs"
    :overlay-class-name="overlayClassName"
    placement="bottom"
    @visibleChange=""
    v-on="$attrs"
    width="200"
  >
    <template #content>
    <template #default>
      <div class="title-content"></div>
      <slot name="formContent" />
      <div class="uranus-popconfirm-btns">
        <a-button size="sm" @click="onCancel">
        <el-button @click="onCancel">
          {{ cancelText || '取消' }}
        </a-button>
        <a-button
          size="sm"
        </el-button>
        <el-button
          :loading="loading"
          type="primary"
          class="confirm-btn"
          @click="onConfirm"
        >
          {{ okText || '确定' }}
        </a-button>
        </el-button>
      </div>
    </template>
    <template v-if="$slots.default">
    <template #reference>
      <slot></slot>
    </template>
  </a-popover>
  </el-popover>
</template>
<script setup>
import { defineProps, defineEmits, reactive, watch, computed } from 'vue';
const props = defineProps();
const props = defineProps(['visible', 'loading', 'disabled', 'title', 'cancelText', 'okText', 'width']);
const emit = defineEmits(['cancel', 'confirm']);
src/views/device/components/DockControlPanel.vue
@@ -3,7 +3,7 @@
    <!-- title -->
    <!-- setting -->
    <!-- <DeviceSettingBox :sn="props.sn" :deviceInfo="props.deviceInfo"></DeviceSettingBox> -->
    <DeviceSettingBox :sn="props.sn" :deviceInfo="props.deviceInfo"></DeviceSettingBox>
    <!-- cmd -->
    <div class="control-cmd-wrapper">
      <div class="control-cmd-header">
@@ -84,7 +84,7 @@
import { EDockModeCode } from '@/types/device'
import { updateDeviceCmdInfoByOsd, updateDeviceCmdInfoByExecuteInfo } from '@/utils/device-cmd'
import { setThermalCurrentPaletteStyle, setPhotoStorageSet, setVideoStorageSet, getLiveStatus, setStreamsSwitch, photoAndVideoCmd } from '@/api/device-setting'
import DeviceSettingBox from './DeviceSettingBox.vue'
import Store from '@/store'
import { useConnectWebSocket } from '@/utils/websocket/connect-websocket';
import { getWebsocketUrl } from '@/utils/websocket/config';
src/views/device/index.vue
@@ -10,14 +10,15 @@
-->
<template>
  <basic-container>
    <el-tabs v-model="activeName" @tab-click="handleClick">
    <airport ref="airport" />
    <!-- <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="机场" name="1">
        <airport ref="airport" />
      </el-tab-pane>
      <el-tab-pane label="飞行器" name="2">
        <fly ref="fly" />
      </el-tab-pane>
    </el-tabs>
    </el-tabs> -->
  </basic-container>
</template>