无人机管理后台前端(已迁走)
chenyao
2025-11-17 233e4fc4f35bd00a36ee34a7fbf5e47b41db26db
src/views/device/airport.vue
@@ -87,6 +87,12 @@
              <el-dropdown-item command="e"><el-button type="primary" text icon="el-icon-document-delete"
                  v-if="permission.fly_device_offline" @click.stop="handleDeviceOffline(scope.row)">注销</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"
                  :disabled="scope.row.dem_status === 1" @click.stop="handleStatus(scope.row)">
                  {{ scope.row.dem_status === 0 ? '初始化地形' : (scope.row.dem_status === 1 ? '初始化中' : '更新地形') }}
                </el-button>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
          <template #dropdown v-else>
@@ -222,7 +228,9 @@
  getDevices,
  deviceOffline,
  devicesUpdate,
  devicesUpAndDown
  devicesUpAndDown,
  initAirportTerrainHeight,
  deleteAirportTerrainHeight
} from '@/api/device/device'
import { deleteByOssId, addOrUpdate as addOrUpdateOssBind } from '@/api/device/ossBind'
import { getListPage as getOssList } from '@/api/resource/oss'
@@ -242,7 +250,7 @@
    DevicePerShare,
    DockControlPanel,
  },
  data () {
  data() {
    // const self = this
    const validatePass = (rule, value, callback) => {
@@ -580,7 +588,7 @@
            labelWidth: 145,
            width: 200,
            type: 'daterange',
            format: 'YYYY-MM-DD',
            format: 'YYYY-MM-DD ',
            valueFormat: 'YYYY-MM-DD',
            startPlaceholder: '保险开始日期',
            endPlaceholder: '保险结束日期',
@@ -779,7 +787,7 @@
  computed: {
    ...mapGetters(['permission', 'userInfo']),
    permissionList () {
    permissionList() {
      return {
        addBtn: this.validData(this.permission.air_add, true),
        viewBtn: this.validData(this.permission.air_view, true),
@@ -787,7 +795,7 @@
        editBtn: this.validData(this.permission.air_edit, true),
      }
    },
    ids () {
    ids() {
      let ids = []
      this.selectionList.forEach(ele => {
        ids.push(ele.id)
@@ -795,7 +803,7 @@
      return ids.join(',')
    },
  },
  destroyed () {
  destroyed() {
    this.treeResolveMap.clear()
    this.websocketMap.forEach((k, v) => {
      if (null != v) {
@@ -805,17 +813,17 @@
      }
    })
  },
  mounted () {
  mounted() {
    getRegionTreeAll({ parentCode: this.userInfo.detail.areaCode }).then(res => {
      const column = this.findObject(this.option.column, 'area_code')
      column.dicData = res.data.data ? [res.data.data] : []
    })
  },
  methods: {
    getDockModeText (value) {
    getDockModeText(value) {
      return EDockModeText[value] || ''
    },
    getModelText (value) {
    getModelText(value) {
      let txt = '离线'
      if (value === 0 || value === 4) {
        txt = '在线'
@@ -829,7 +837,7 @@
      return txt
    },
    // 关闭所有的webscoket
    closeAllWebsoket () {
    closeAllWebsoket() {
      this.websocketMap.forEach((k, v) => {
        if (null != v) {
          v.close()
@@ -839,7 +847,7 @@
      })
    },
    // 连接webSocket
    connectWebSocket (data) {
    connectWebSocket(data) {
      const webSocketId = data.workspace_id
      if (!this.webSocketIdSet.has(webSocketId)) {
        // 防止重复连接
@@ -849,14 +857,14 @@
        this.useConnectWebSocket1(webSocketId, webSorketUrl)
      }
    },
    useConnectWebSocket1 (webSocketId, url) {
    useConnectWebSocket1(webSocketId, url) {
      const websocket = new ConnectWebSocket(url)
      // 加入 webscoket map
      this.websocketMap.set(webSocketId, websocket)
      websocket?.registerMessageHandler(this.messageHandler)
      websocket?.initSocket()
    },
    async messageHandler (payload) {
    async messageHandler(payload) {
      if (!payload) {
        return
      }
@@ -881,7 +889,7 @@
        }
      })
    },
    init () {
    init() {
      (this.page = {
        pageSize: 10,
        currentPage: 1,
@@ -890,7 +898,7 @@
        this.onLoad(this.page)
    },
    // 打开权限分享页面
    handleOpenDevicePerShare (row) {
    handleOpenDevicePerShare(row) {
      var that = this
      this.devicePerShareVisible = true
      this.$nextTick(() => {
@@ -898,21 +906,38 @@
      })
    },
    // 打开远程调试
    handleOpenRemoteDebugging (row) {
    handleOpenRemoteDebugging(row) {
      this.curDeviceInfo = row
      this.remoteDebuggingShow = true
      this.operateTitle = row.nickname + ' - ' + row.device_sn
    },
    // 设备注销
    handleDeviceOffline (row) {
    handleDeviceOffline(row) {
      this.cancenOperate = true
      this.cancelSNName = row.nickname
      this.cancenOperateRow = row
    },
    cancenOperateDo () {
    // 设备
    handleStatus(row) {
      // dem_status
      if (row.dem_status === 2 || row.dem_status === 3) {
        deleteAirportTerrainHeight({ dockSn: row.device_sn }).then(res => {
          initAirportTerrainHeight({ dockSn: row.device_sn, centerLon: row.longitude, centerLat: row.latitude, }).then(res => {
            ElMessage.success('操作成功')
            this.init()
          })
        })
      } else {
        initAirportTerrainHeight({ dockSn: row.device_sn, centerLon: row.longitude, centerLat: row.latitude,  }).then(res => {
            ElMessage.success('操作成功')
            this.init()
        })
      }
    },
    cancenOperateDo() {
      this.cancenOperate = false
      this.deleteFlag = false
      deviceOffline(this.cancenOperateRow.device_sn, true).then(res => {
@@ -925,7 +950,7 @@
    },
    // 打开存储对象配置页面
    handleOpenOssSet (row) {
    handleOpenOssSet(row) {
      var that = this
      this.deviceSn = row.device_sn
      this.ossSetBox = true
@@ -941,7 +966,7 @@
      })
    },
    // 打开固件管理页面
    handleOpenFirmwarm (row) {
    handleOpenFirmwarm(row) {
      var that = this
      this.firmwareManageVisible = true
      this.$nextTick(() => {
@@ -949,7 +974,7 @@
      })
    },
    // 设备下线
    dockNotLine (row) {
    dockNotLine(row) {
      let txt = row.hidden_flag === 1 ? '上线' : '下线'
      ElMessageBox.confirm(`确定${txt}该设备吗?`, '提示', {
        confirmButtonText: '确定',
@@ -970,7 +995,7 @@
        .catch(() => { })
    },
    // 版本回退点击事件
    rollFirmware (row) {
    rollFirmware(row) {
      if (row.status == 0) {
        this.$message({
          type: 'warning',
@@ -1019,7 +1044,7 @@
      })
    },
    // 比较版本大小
    compare (version1, version2) {
    compare(version1, version2) {
      let arr1 = version1.split('.')
      let arr2 = version2.split('.')
      let length = Math.max(arr1.length, arr2.length)
@@ -1033,7 +1058,7 @@
      return 0
    },
    // 版本回退
    rollFirmwareConfirm () {
    rollFirmwareConfirm() {
      // 无人机升级/回滚
      if (this.rollFirmVersion == '') {
        this.$message({
@@ -1108,7 +1133,7 @@
      })
    },
    // 升级固件按钮事件
    updateFirmware (row) {
    updateFirmware(row) {
      if (row.status == 0) {
        this.$message({
          type: 'warning',
@@ -1140,7 +1165,7 @@
      })
    },
    // 确定升级固件版本
    updateFirmwareConfirm () {
    updateFirmwareConfirm() {
      var that = this
      var arr = []
      arr.push(that.firmwareInfo)
@@ -1156,13 +1181,13 @@
        done()
      })
    },
    handleOssSetClose () {
    handleOssSetClose() {
      this.ossEnd = ''
      this.deviceSn = ''
      this.bindOssId = null
    },
    // 存储对象配置确定
    ossSetConfirm () {
    ossSetConfirm() {
      var that = this
      // 判断是否已选择
      if (!this.ossEnd) {
@@ -1189,7 +1214,7 @@
      })
    },
    // 取消配置
    cancelOssSetConfirm () {
    cancelOssSetConfirm() {
      var that = this
      // 判断是否已有配置
      if (!this.bindOssId) {
@@ -1209,13 +1234,13 @@
      })
    },
    // 取消按钮 oss
    cancelOssSet () {
    cancelOssSet() {
      this.ossEnd = ''
      this.deviceSn = ''
      this.bindOssId = null
      this.ossSetBox = false
    },
    rowSave (row, done, loading) {
    rowSave(row, done, loading) {
      let areaCode = row.area_code
      if (Array.isArray(areaCode)) {
        areaCode = areaCode[areaCode.length - 1]
@@ -1240,12 +1265,12 @@
        }
      )
    },
    rowUpdate (row, index, done, loading) {
    rowUpdate(row, index, done, loading) {
      const submitData = {
        ...row,
        area_code: row.area_code.split(',').pop(),
        insure_start_time: row.duration_of_insurance[0] || null,
        insure_expired_time: row.duration_of_insurance[1] || null,
        insure_start_time: row.duration_of_insurance[0] + ' 00:00:00' || null,
        insure_expired_time: row.duration_of_insurance[1] + ' 23:59:59' || null,
        deptId: row.dept_id,
        areaCode: row.area_code.split(',').pop(),
      }
@@ -1267,7 +1292,7 @@
              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 || '']
                  e.duration_of_insurance = [e?.insure_start_time?.slice(0, 10) || '', e?.insure_expired_time?.slice(0, 10) || '']
                })
                resolve(data)
              })
@@ -1287,7 +1312,7 @@
        }
      )
    },
    rowDel (row) {
    rowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
@@ -1304,24 +1329,24 @@
          })
        })
    },
    searchReset () {
    searchReset() {
      this.query = {}
      this.onLoad(this.page)
    },
    searchChange (params, done) {
    searchChange(params, done) {
      this.query = params
      this.page.currentPage = 1
      this.onLoad(this.page, params)
      done()
    },
    selectionChange (list) {
    selectionChange(list) {
      this.selectionList = list
    },
    selectionClear () {
    selectionClear() {
      this.selectionList = []
      this.$refs.crud.toggleSelection()
    },
    handleDelete () {
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据')
        return
@@ -1343,7 +1368,7 @@
          this.$refs.crud.toggleSelection()
        })
    },
    async getFullAreaCode (areaCode) {
    async getFullAreaCode(areaCode) {
      console.log('getFullAreaCode', areaCode)
      if (!areaCode) return ''
@@ -1362,7 +1387,7 @@
        return `${provinceCode},${cityCode},${code}`
      }
    },
    beforeOpen (done, type) {
    beforeOpen(done, type) {
      if (['edit', 'view'].includes(type)) {
        getDetail(this.form.id).then(async res => {
          const data = res.data.data
@@ -1373,23 +1398,23 @@
            cnmode_code: this.getDockModeText(this.form.mode_code),
            domainTxt: data.domain === 0 ? '无人机' : data.domain === 3 ? '机巢' : '未知',
            cnstatus: this.form.status === false ? '离线' : '在线',
            duration_of_insurance: [data?.insure_start_time || '', data?.insure_expired_time || ''],
            duration_of_insurance: [data?.insure_start_time?.slice(0, 10) || '', data?.insure_expired_time?.slice(0, 10) || ''],
          }
          done()
        })
      }
    },
    currentChange (currentPage) {
    currentChange(currentPage) {
      this.page.currentPage = currentPage
    },
    sizeChange (pageSize) {
    sizeChange(pageSize) {
      this.page.pageSize = pageSize
    },
    refreshChange () {
    refreshChange() {
      this.onLoad(this.page, this.query)
    },
    onLoad (page, params = {}) {
    onLoad(page, params = {}) {
      // this.closeAllWebsoket();
      const { releaseTimeRange } = this.query
      let values = {
@@ -1417,14 +1442,14 @@
          if (e.firmware_status == 4) {
            this.connectWebSocket(e)
          }
          e.duration_of_insurance = [e.insure_start_time || '', e.insure_expired_time || '']
          e.duration_of_insurance = [e?.insure_start_time?.slice(0, 10) || '', e?.insure_expired_time?.slice(0, 10) || '']
        })
        this.data = data.records
        this.loading = false
        this.selectionClear()
      })
    },
    treeLoad (tree, treeNode, resolve) {
    treeLoad(tree, treeNode, resolve) {
      // 保存resolve
      this.treeResolveMap.set(tree.child_sn, resolve)
      var params = {
@@ -1433,7 +1458,7 @@
      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 || '']
          e.duration_of_insurance = [e?.insure_start_time?.slice(0, 10) || '', e?.insure_expired_time?.slice(0, 10) || '']
        })
        resolve(data)
      })
@@ -1456,7 +1481,7 @@
    //     })
    // },
    // 设置无人机操作密码
    setOperatePasswordConfirm () {
    setOperatePasswordConfirm() {
      var that = this
      this.$refs.passwordForm.validate(valid => {
        if (valid) {
@@ -1483,7 +1508,7 @@
      })
    },
    // 操作密码设置
    handleOperatePassword (row) {
    handleOperatePassword(row) {
      this.operatePasswordSetBox = true
      this.passwordForm.id = row.id
    },