无人机管理后台前端(已迁走)
张含笑
2025-08-27 ab65906ce525c07d6b614e63e573155d91078708
src/views/job/components/SearchBox.vue
@@ -23,6 +23,7 @@
            v-model="searchForm.device_sn"
            placeholder="请选择"
            clearable
            @change="handleSearch"
          >
            <el-option
              v-for="item in machineData"
@@ -69,11 +70,24 @@
          <!-- <div class="btn add" @click="addTask"><img src="@/assets/images/task/add.png"/>新增</div> -->
        </div>
        <el-form-item label="任务算法:" v-if="isExpand" class="taskAlgorithm">
          <TaskAlgorithmBusiness
          <!-- <TaskAlgorithmBusiness
          ref="algorithmRef"
            :setWidth="160"
            :showAlgorithm="true"
            @algorithmChange="algorithmChange"
          /> -->
          <el-tree-select
              popper-class="custom-tree-select"
              :style="{ width: pxToRem(186) }"
              v-model="dictKey"
              :data="dataList"
              :default-expanded-keys="[dictKey]"
              check-strictly
              node-key="id"
              :props="treePropsSF"
              @node-click="handleSFNodeClick"
              clearable
              @clear="handleClear"
          />
        </el-form-item>
        <!-- <el-form-item label="所属部门:" v-if="isExpand">
@@ -100,6 +114,7 @@
            multiple
            collapse-tags
            collapse-tags-tooltip
              @change="handleSearch"
          >
            <el-option
              v-for="item in statusOptions"
@@ -115,6 +130,7 @@
            v-model="searchForm.is_circle_job"
            placeholder="请选择"
            clearable
            @change="handleSearch"
          >
            <el-option label="周期任务" :value="1" />
            <el-option label="临时任务" :value="0" />
@@ -127,8 +143,8 @@
<script setup>
import { pxToRem } from '@/utils/rem';
import { ElMessage } from 'element-plus';
import { deptsByAreaCode } from '@/api/job/task';
import TaskAlgorithmBusiness from './TaskAlgorithmBusiness.vue';
import { deptsByAreaCode, getSFDictionaryTree  } from '@/api/job/task';
// import TaskAlgorithmBusiness from './TaskAlgorithmBusiness.vue';
import dayjs from 'dayjs';
import { useStore } from 'vuex';
import { getRegionTreeAll } from '@/api/job/task';
@@ -182,6 +198,7 @@
const algorithmChange = val => {
  searchForm.ai_types = val;
  handleSearch()
};
const businessChange = val => {
@@ -212,6 +229,52 @@
  });
};
// 算法
const treePropsSF = {
    label: 'dictValue',
    value: 'id',
    children: 'children',
}
const dictKey = ref('')
const dataList = ref([])
function getAlgorithmList() {
  getSFDictionaryTree({code:'SF'}).then((res) => {
      if (res.data.code === 200) {
          const result = res.data.data[0].children
          // 过滤第一层数据
          const filteredData = result.map(item => {
              // 过滤第二层数据
              const children = item.children?.map(child => ({
                  ...child,
                  children: [] // 清空第三层数据
              }))
              return {
                  ...item,
                  children: children || []
              }
          })
          dataList.value = filteredData
      }
  })
}
function handleSFNodeClick(data) {
    if (data.children && data.children.length) {
        // 获取子节点dictKey
        const childDictKeys = data.children.map(child => child.dictKey)
        searchForm.ai_types = childDictKeys
    } else {
        searchForm.ai_types = [data.dictKey]
    }
    // 更新列表
    handleSearch()
}
function handleClear() {
    dictKey.value = ''
    searchForm.ai_types = []
    handleSearch()
}
const handleNodeClick = async data => {
  // 处理机巢数据
  searchForm.device_sn = '';
@@ -228,6 +291,7 @@
  searchForm.create_dept = '';
  deptData.value = [];
  getDeptsByAreaCode();
  handleSearch();
};
// 日期 和周期
@@ -273,6 +337,7 @@
const handleDateChange = val => {
  checked.value = null
  searchForm.date_enum = undefined
  handleSearch()
};
// 重置
@@ -286,7 +351,9 @@
  searchForm.area_code = userAreaCode.value;
  checked.value = 'month';
  signDevice_sn.value = ''
   algorithmRef.value?.clear()
  // 清除算法
  dictKey.value = '';
   // algorithmRef.value?.clear()
  handleNodeClick({ id: userAreaCode.value });
  handleSearch();
};
@@ -334,6 +401,7 @@
onMounted(() => {
  requestDockInfo();
  getAlgorithmList();
  // 日历传值
  const calendarday = ref(route.query.day);