吉安感知网项目-前端
张含笑
2026-01-17 39ec001f02bde6fd7b7a40bdf7b2313df87e8e76
applications/drone-command/src/views/dataCockpit/components/DeviceHistoryDialog.vue
@@ -16,15 +16,14 @@
         <el-form-item label="区域" prop="area">
            <el-tree-select class="command-data-cockpit-select" popper-class="command-data-cockpit-tree-select-popper"
               v-model="searchParams.area" :data="areaTree" :props="areaTreeProps" node-key="value" check-strictly
               clearable placeholder="请选择" @change="handleSearch" />
               v-model="searchParams.area" :data="areaTree" :props="areaTreeProps" node-key="value" check-strictly filterable :filter-node-method="filterAreaNode" clearable placeholder="请选择" @change="handleSearch" />
         </el-form-item>
         <el-form-item label="无人机类型" prop="droneType">
            <el-select class="command-data-cockpit-select" popper-class="command-data-cockpit-select-popper"
               v-model="searchParams.droneType" placeholder="请选择" clearable @change="handleSearch">
               <el-option v-for="item in droneTypeOptions" :key="item.value" :label="item.label"
                  :value="item.value" />
               <el-option v-for="item in dictObj.droneType" :key="item.dictKey" :label="item.dictValue"
                  :value="item.dictKey" />
            </el-select>
         </el-form-item>
@@ -74,7 +73,9 @@
<script setup>
import { Search, RefreshRight } from '@element-plus/icons-vue'
import { computed, ref, watch } from 'vue'
import { alarmLogApi } from '@/api/dataCockpit'
import { getDictionaryByCode } from '@/api/system/dictbiz'
import { alarmLogApi, areaDivideListApi } from '@/api/dataCockpit'
import { getDictLabel } from '@ztzf/utils'
const props = defineProps({
   modelValue: {
@@ -111,29 +112,41 @@
const loading = ref(true)
const list = ref([])
const total = ref(0)
const areaTree = ref([
   {
      label: '古村区',
      value: '古村区'
   },
   {
      label: '新区',
      value: '新区'
   },
   {
      label: '产业园',
      value: '产业园'
   }
])
const dictObj = ref({
   droneType: []
})
const areaTree = ref([])
const areaTreeProps = {
   label: 'label',
   children: 'children'
}
const droneTypeOptions = [
   { label: '微型机', value: '1' },
   { label: '植保机', value: '2' }
]
const fetchDictList = async () => {
   const res = await getDictionaryByCode('droneType')
   dictObj.value = res?.data?.data ?? { droneType: [] }
}
const filterAreaNode = (value, data) => {
   if (!value) return true
   return (data?.label || '').includes(value)
}
const fetchAreaTree = async () => {
   try {
      const res = await areaDivideListApi()
      const list = res?.data?.data ?? []
      areaTree.value = list
         .filter((item) => item?.areaName)
         .map((item) => ({
            label: item.areaName,
            value: item.areaName
         }))
   } catch (error) {
      areaTree.value = []
   }
}
const getList = async () => {
   if (!props.device?.id) {
@@ -188,9 +201,7 @@
}
const getDroneTypeText = (value) => {
   if (value === 1 || value === '1') return '微型机'
   if (value === 2 || value === '2') return '植保机'
   return value || '-'
   return getDictLabel(value, dictObj.value.droneType) || value || '-'
}
watch(
@@ -198,7 +209,11 @@
   (visible) => {
      if (visible) {
         searchParams.value.current = 1
         fetchDictList()
         fetchAreaTree()
         getList()
      } else {
         searchParams.value = initSearchParams()
      }
   }
)