吉安感知网项目-前端
shuishen
2026-01-16 b618191bab4e910744711fb4f2d6335d14aaa00a
applications/drone-command/src/views/detectionCountermeasure/deviceAppConfig/index.vue
@@ -29,6 +29,24 @@
            </el-select>
         </el-form-item>
         <el-form-item label="设备状态" prop="deviceStatus">
            <el-select
               class="ztzf-data-cockpit-select"
               popper-class="ztzf-data-cockpit-select-popper"
               v-model="searchParams.deviceStatus"
               placeholder="请选择"
               clearable
               @change="handleSearch"
            >
               <el-option
                  v-for="item in dictObj.deviceStatus"
                  :key="item.dictKey"
                  :label="item.dictValue"
                  :value="item.dictKey"
               />
            </el-select>
         </el-form-item>
         <el-form-item class="history-search-actions">
            <el-button :icon="RefreshRight" @click="resetForm"></el-button>
            <el-button class="search-btn" :icon="Search" @click="handleSearch"></el-button>
@@ -47,13 +65,28 @@
               <el-table-column prop="deviceModel" show-overflow-tooltip label="设备型号" />
               <el-table-column prop="deviceName" show-overflow-tooltip label="设备名称" />
               <el-table-column prop="deviceSn" show-overflow-tooltip label="设备编码" />
               <el-table-column prop="deployLocation" show-overflow-tooltip label="部署位置" />
               <el-table-column prop="deviceStatus" show-overflow-tooltip label="设备状态">
                  <template v-slot="{ row }">
                     {{ getDictLabel(row.status, dictObj.deviceStatus) }}
                  </template>
               </el-table-column>
               <el-table-column show-overflow-tooltip label="部署位置">
                  <template v-slot="{ row }">
                     {{ formatDeployLocation(row) }}
                  </template>
               </el-table-column>
               <el-table-column prop="manufacturer" show-overflow-tooltip label="厂商" />
               <el-table-column prop="contactPhone" show-overflow-tooltip label="联系方式" />
               <el-table-column prop="sceneName" show-overflow-tooltip label="所属场景" />
               <el-table-column label="操作" class-name="operation-btns">
               <el-table-column label="设置配置" class-name="operation-btns">
                  <template v-slot="{ row }">
                     <el-link @click="openForm('edit', row)" type="warning">配置接口</el-link>
                  </template>
               </el-table-column>
               <el-table-column label="操作" class-name="operation-btns">
                  <template v-slot="{ row }">
                     <el-link @click="handleEdit(row)">编辑</el-link>
                     <el-link @click="handleDelete(row)" type="danger">删除</el-link>
                  </template>
               </el-table-column>
            </el-table>
@@ -71,22 +104,27 @@
         </div>
      </div>
      <FormDiaLog v-if="dialogVisible" v-model="dialogVisible" ref="dialogRef" @success="getList" />
      <ConfigFormDiaLog v-if="dialogVisible" v-model="dialogVisible" ref="configDialogRef" @success="getList" />
      <DeviceFormDiaLog ref="deviceFormRef" @success="getList" />
   </basic-container>
</template>
<script setup>
import { RefreshRight, Search } from '@element-plus/icons-vue'
import { nextTick, onMounted, provide, ref } from 'vue'
import FormDiaLog from './FormDiaLog.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import ConfigFormDiaLog from './FormDiaLog.vue'
import DeviceFormDiaLog from '@/views/basicManage/deviceStock/FormDiaLog.vue'
import { getDictionaryByCode } from '@/api/system/dictbiz'
import { getDictLabel } from '@ztzf/utils'
import { fwDevicePageApi } from '@/views/basicManage/deviceStock/fwDevice'
import { fwDevicePageApi, fwDeviceRemoveApi } from '@/views/basicManage/deviceStock/fwDevice'
import { getDeptTree } from '@/api/system/dept'
// 初始化查询参数
const initSearchParams = () => ({
   deviceName: '', // 设备名称
   deviceType: '', // 设备类型
   deviceStatus: '', // 设备状态
   current: 1, // 当前页
   size: 10, // 每页大小
})
@@ -96,13 +134,18 @@
const loading = ref(true) // 列表加载中
const list = ref([]) // 列表数据
const queryParamsRef = ref(null) // 查询表单实例
const dialogRef = ref(null) // 弹框实例
const configDialogRef = ref(null) // 弹框实例
const deviceFormRef = ref(null) // 设备表单弹框实例
const dialogVisible = ref(false)
const deptTree = ref([])
const dictObj = ref({
   deviceType: [], //设备类型
   deviceStatus: [], //设备状态
   deviceAtt: [], //设备属性
})
provide('dictObj', dictObj)
provide('deptTree', deptTree)
// 获取列表
async function getList() {
@@ -131,8 +174,14 @@
// 获取字典
function getDictList() {
   getDictionaryByCode('deviceType').then(res => {
   getDictionaryByCode('deviceType,deviceStatus,deviceAtt').then(res => {
      dictObj.value = res.data.data
   })
}
function getDeptTreeFun() {
   getDeptTree().then(res => {
      deptTree.value = res.data.data
   })
}
@@ -140,13 +189,38 @@
function openForm(mode, row) {
   dialogVisible.value = true
   nextTick(() => {
      dialogRef.value?.open({ mode, row })
      configDialogRef.value?.open({ mode, row })
   })
}
function handleEdit(row) {
   deviceFormRef.value?.open({ mode: 'edit', row })
}
async function handleDelete(row) {
   await ElMessageBox.confirm('确认删除该设备吗?', '提示', {
      type: 'warning',
      customClass: 'ztzf-page-view-message-box',
      confirmButtonClass: 'ztzf-message-box-confirm',
      cancelButtonClass: 'ztzf-message-box-cancel',
   })
   await fwDeviceRemoveApi({ ids: row.id })
   ElMessage.success('删除成功')
   getList()
}
function formatDeployLocation(row) {
   if (!row) return ''
   const longitude = row.deployLongitude ?? row.longitude
   const latitude = row.deployLatitude ?? row.latitude
   if (longitude == null || latitude == null) return ''
   return `${longitude}, ${latitude}`
}
onMounted(() => {
   getList()
   getDictList()
   getDeptTreeFun()
})
</script>
<style scoped lang="scss"></style>