无人机管理后台前端(已迁走)
chenyao
2025-08-29 8a7bc685c7ba3a2d9cd69cfefc37fa9be4dead25
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>