无人机管理后台前端(已迁走)
chenyao
2025-11-28 cf55e57ac8e892c321cc9eeb79e14b39e7d80e82
src/views/tickets/component/SearchBox.vue
New file
@@ -0,0 +1,313 @@
<template>
  <div class="search-box-test">
    <el-form :model="searchForm" inline>
      <div class="search-first">
        <el-form-item label="关键字:">
          <el-input v-model="searchForm.key_word" placeholder="编号/名称/内容/姓名" clearable />
        </el-form-item>
        <el-form-item label="选择日期:" :style="{ width: pxToRem(460) }">
          <el-date-picker
            v-model="dateRange"
            type="daterange"
            range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-value="datePickerDefaultVal" @change="handleSearch" />
        </el-form-item>
        <el-form-item label="关联航线:">
          <el-select
            :teleported="false"
            v-model="searchForm.file_id"
            placeholder="请选择关联航线"
            clearable
            @change="handleSearch"
          >
            <el-option
              v-for="item in lineList"
              :key="item.wayline_id"
              :label="item.name"
              :value="item.wayline_id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="关联算法:">
          <el-select
            :teleported="false"
            v-model="searchForm.ai_typesValue"
            placeholder="请选择关联算法"
            clearable @change="handleSearch">
            <el-option
              v-for="item in aiTypeList"
              :key="item.dictKey"
              :label="item.dictValue"
              :value="item.dictKey"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="工单状态:">
          <el-select
            :teleported="false"
            :disabled="activeTab === 'WAIT_AUDIT' || activeTab === 'REJECTED' || activeTab === 'PASS'"
            v-model="searchForm.status"
            placeholder="请选择单状态"
            @change="handleSearch"
            clearable>
            <el-option
              v-for="item in orderStatus"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="工单周期:" :style="{ width: pxToRem(460) }">
          <el-date-picker
            v-model="cycleDateRange"
            type="daterange"
            range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-value="datePickerDefaultVal" @change="handleSearch"/>
        </el-form-item>
        <el-form-item label="选择频次:">
          <el-select v-model="searchForm.rep_fre_type" placeholder="请选择频次" clearable @change="handleSearch">
            <el-option v-for="item in cycles" :key="item" :label="item" :value="item" />
          </el-select>
        </el-form-item>
        <el-form-item label="执行时间:">
          <el-time-picker @change="handleSearch"
            v-model="searchForm.deal_time"
            placeholder="请选择执行时间"
            prop="deal_time"
            value-format="HH:mm"
            :picker-options="{ selectableRange: '00:00 - 23:59'}" />
        </el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="handleReset">清空</el-button>
      </div>
    </el-form>
  </div>
</template>
<script setup>
import { pxToRem } from '@/utils/rem';
import { calculateDefaultRange } from '@/utils/util'
import { newGetWorkspacesPage } from '@/api/resource/wayline'
import { getDictionaryByCode } from '@/api/system/dictbiz'
import dayjs from 'dayjs';
// 选择日期
const dateRange = ref('')
let datePickerDefaultVal = calculateDefaultRange()
// 选择周期
const cycleDateRange = ref('')
const searchForm = reactive({
  ai_types: [],
  ai_typesValue: '',
  deal_time: "",
  file_id: "",
  key_word: "",
  status: '',
  rep_fre_type: '',
})
const emit = defineEmits(['search']);
const rowObj = inject('rowObj')
const activeTab = inject('activeTab')
const lineList = inject('lineList')
const aiTypeList = inject('aiTypeList')
watch(activeTab, (newTab, oldTab) => {
  if (newTab === 'all') {
    searchForm.status = ''
  }
  if(newTab === 'WAIT_AUDIT') {
    searchForm.status = '1'
  }
  if(newTab === 'REJECTED') {
    searchForm.status = '2'
  }
  if(newTab === 'PASS') {
    searchForm.status = '3'
  }
  emit('search', searchForm);
})
// 周期
const cycles = ref(['每天', '周一', '周二', '周三', '周四', '周五', '周六', '周末', '周天', '工作日'])
// 工单状态
const orderStatus = ref([
  { label: '待审核', value: '1' },
  { label: '已驳回', value: '2' },
  { label: '已通过', value: '3' }
])
const timeFormat = 'YYYY-MM-DD HH:mm:ss';
// 搜索
const handleSearch = () => {
  if (!dateRange.value) {
    dateRange.value = [];
  }
  if (!cycleDateRange.value) {
    cycleDateRange.value = [];
  }
  // if (dateRange.value && dateRange.value.length) {
  //   checked.value = '';
  //   searchForm.date_enum = '';
  // }
  // 提交至store
  let params = {
    ...searchForm,
    create_start_date: dateRange.value.length
      ? dayjs(dateRange?.value[0]).startOf('day').format(timeFormat)
      : null,
    create_end_date: dateRange?.value.length
      ? dayjs(dateRange?.value[1]).endOf('day').format(timeFormat)
      : null,
    start_date: cycleDateRange?.value.length
      ? dayjs(cycleDateRange?.value[0]).startOf('day').format(timeFormat)
      : null,
    end_date: cycleDateRange?.value.length
      ? dayjs(cycleDateRange?.value[1]).startOf('day').format(timeFormat)
      : null,
  };
  emit('search', params);
};
function handleReset () {
  searchForm.ai_types = []
  searchForm.ai_typesValue = ''
  searchForm.deal_time = ""
  searchForm.file_id = ""
  searchForm.key_word = ""
  if (activeTab.value === 'all') {
    searchForm.status = ''
  }
  searchForm.rep_fre_type = ''
  dateRange.value = ''
  searchForm.create_start_date = null
  searchForm.create_end_date = null
  cycleDateRange.value = ''
  searchForm.start_date = null
  searchForm.emd_date = null
  emit('search', searchForm);
}
// onMounted(() => {
//   aitypeList()
//   getLines()
// });
</script>
<style lang="scss" scoped>
// .taskAlgorithm {
//    :deep() {
//       .task-algorithm > div {
//          width: 233px !important;
//       }
//    }
// }
.search-box-test {
  margin-bottom: 16px;
  transition: all 0.3s;
  .search-first {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 15px; // 设置行间距和列间距
    .more {
      cursor: pointer;
      width: 32px;
      height: 32px;
      color: #1c5cff;
      line-height: 32px;
      font-size: 16px;
      margin: 0 28px;
    }
    .search-btn {
      // position: absolute;
      // right: 0;
      display: flex;
      justify-content: space-between;
      cursor: pointer;
      font-size: 14px;
      .btn {
        width: 80px;
        height: 32px;
        border-radius: 4px 4px 4px 4px;
        line-height: 32px;
        display: flex;
        justify-content: center;
        align-items: center;
        // margin-left: px;
        img {
          width: 14px;
          height: 14px;
        }
      }
      .search {
        background: #409eff;
        color: #fff;
        margin-right: 10px;
      }
      .clear {
        border: 1px solid #d2d1d1;
        color: #676767;
        margin-right: 10px;
      }
      .add {
        background: #ff9243;
        color: #fff;
      }
    }
    .time-card {
      text-align: center;
      background: #ffffff;
      border-radius: 4px 0px 0px 4px;
      border: 1px solid #e5e5e5;
      font-family: Source Han Sans CN, Source Han Sans CN;
      font-weight: 400;
      font-size: 14px;
      color: #7c8091;
      display: flex;
      height: 32px;
      .card-item {
        width: 60px;
        height: 100%;
        line-height: 32px;
        cursor: pointer;
      }
      .active {
        background: #ffffff;
        border-radius: 0px 0px 0px 0px;
        border: 1px solid #1c5cff;
        color: #1441ff;
      }
    }
  }
  :deep(.el-form) {
    :deep(.el-input__wrapper.is-disabled) {
      box-shadow: 0 0 0 1px #026ad6;
    }
    .el-form-item__label {
      width: 80px;
    }
    .el-form-item {
      margin-bottom: 0;
      width: 280px;
      margin-right: 20px;
      .el-form-item__label {
        color: #363636;
        line-height: 32px;
      }
    }
  }
}
</style>