forked from drone/command-center-dashboard

chenyao
2025-04-12 df4e3452ecdc510faa09c7310ba4857ed432553d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<template>
  <div class="search-box-test" :class="{ 'is-expand': isExpand }">
    <el-form :model="searchForm" inline>
      <div class="search-first">
        <el-form-item>
          <el-input v-model="searchForm.key_word" placeholder="请输入任务/机巢名称" clearable />
        </el-form-item>
        <el-form-item label="行政区划:">
          <el-select v-model="searchForm.area_code" @change="deptChange" placeholder="请选择部门" clearable>
            <el-option v-for="item in deptTreeData" :key="item.area_code" :label="item.area_name" :value="item.area_code" />
          </el-select>
        </el-form-item>
        <el-form-item label="所属机巢:">
          <el-select v-model="searchForm.device_sn" placeholder="请选择机巢" clearable>
            <el-option v-for="item in machineData" :key="item.device_sn" :label="item.nickname" :value="item.device_sn" />
          </el-select>
        </el-form-item>
        <el-form-item style="width: 520px;">
          <CommonDateTime style="width: 520px;" v-model="newTime" @change="getData" />
        </el-form-item>
        <el-form-item label="任务算法:" v-if="isExpand">
          <TaskAlgorithmBusiness :setWidth="200" :showAlgorithm="true" @algorithmChange="algorithmChange"/>
        </el-form-item>
        <el-form-item label="所属部门:" v-if="isExpand">
          <el-select v-model="searchForm.create_dept" placeholder="请选择部门" clearable>
            <el-option v-for="item in deptData" :key="item.id" :label="item.deptName" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="任务状态:" v-if="isExpand">
          <el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
            <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="任务类型:" v-if="isExpand">
          <TaskAlgorithmBusiness :setWidth="200" :showBusiness="true" @businessChange="businessChange"/>
        </el-form-item>
        <div class="more"  v-if="isExpand" @click="toggleExpand">收起</div>
        <div class="more" v-else @click="toggleExpand">更多</div>
        <div class="search-btn">
          <img @click="handleReset" src="@/assets/images/task/reset.png" alt="">
          <img @click="handleSearch" src="@/assets/images/task/search.png" alt="">
          <img @click="addTask" src="@/assets/images/task/create.png" alt="">
        </div>
      </div>
    </el-form>
  </div>
</template>
<script setup>
import { pxToRem } from '@/utils/rem'
import CommonDateTime from '@/components/CommonDateTime.vue'
import { deptsByAreaCode, getDockInfo } from '@/api/home/common';
import TaskAlgorithmBusiness from './components/TaskAlgorithmBusiness.vue';
 
const isExpand = ref(false);
const toggleExpand = () => {
  isExpand.value = !isExpand.value;
};
 
const dateRange = ref([]);
const searchForm = reactive({
  ai_types: [], // 算法类型
  area_code: '', // 区域code
  create_dept: '', // 创建部门
  date_enum: '', // 日期枚举,可用值:TODAY,CURRENT_WEEK,CURRENT_MONTH,CURRENT_YEAR
  device_sn: '', // 设备编号
  end_date: null, // 结束时间
  industry_type: '', // 行业key
  key_word: '', // 模糊搜索关键词(匹配名称/昵称/设备sn)
  start_date: null, // 开始时间
  status: '' // 作业状态
});
 
const statusOptions = [
  { label: '待执行', value: 1 },
  { label: '执行中', value: 2 },
  { label: '已完成', value: 3 },
  { label: '已取消', value: 4 },
  { label: '执行失败', value: 5 }
];
 
const emit = defineEmits(['search','addTask']);
 
const handleSearch = () => {
  emit('search', {
    ...searchForm,
    start_date: dateRange.value.length ? `${dateRange.value[0]} 00:00:00` : null,
    end_date: dateRange.value.length ? `${dateRange.value[1]} 23:59:59` : null
  });
};
 
const handleReset = () => {
  dateRange.value = null;
  Object.keys(searchForm).forEach(key => {
    searchForm[key] = '';
  });
  handleSearch();
};
 
// 新增任务
const addTask = () => {
  emit('addTask');
};
 
const algorithmChange = (val) => {
  searchForm.ai_types = val;
};
 
const businessChange = (val) => {
  searchForm.industry_type = val;
};
 
let deptData = ref([]);
// 所属部门信息
const getDeptsByAreaCode = () => {
  deptsByAreaCode(searchForm.area_code).then((res) => {
    if (res.code !== 0) {
      deptData.value = res.data.data;
    }
  });
};
 
// 部门
let deptTreeData = ref([]);
// 机巢
let machineData = ref([]);
 
// 部门下得机巢
const requestDockInfo = () => {
  getDockInfo().then((res) => {
    if (res.data.code !== 0) return;
    // handleDeptData(res.data.data);
    deptTreeData.value = res.data.data;
  });
};
const deptChange = (value) => {
  // 处理机巢数据
  machineData.value = '';
  machineData.value = deptTreeData.value.find(item => item.area_code === value)?.devices || [];
  // 所属部门重新请求值
  searchForm.create_dept = '';
  deptData.value = [];
  getDeptsByAreaCode();
};
 
 
onMounted(() => {
  // requestDictionary();
  getDeptsByAreaCode();
  requestDockInfo();
});
</script>
 
<style lang="scss" scoped>
.search-box-test {
  transition: all 0.3s;
  .search-first {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 0;  // 设置行间距和列间距
    .more {
      cursor: pointer;
      width: 32px;
      height: 32px;
      color: #60B2FF;
      line-height: 32px;
      font-size: 16px;
      margin-right: 10px;
    }
    .search-btn {
      position: absolute;
      right: 0;
      bottom: 2px;
      cursor: pointer;
      img {
        width: 82px;
        height: 32px;
        margin-right: 10px;
      }
    }
  }
  :deep(.el-form) {
    :deep(.el-input__wrapper),
    :deep(.el-select),
    :deep(.el-select__wrapper) {
      
      background-color: #021740;
      box-shadow: 0 0 0 1px #026AD6;
      
      &.is-focus {
        box-shadow: 0 0 0 1px #026AD6;
      }
    }
    
    :deep(.el-input__wrapper.is-disabled) {
      background-color: #021740;
      box-shadow: 0 0 0 1px #026AD6;
    }
    .el-form-item {
      margin-bottom: 0;
      margin-right: 20px;
      width: 260px;
      
      .el-form-item__label {
        color: #fff;
        line-height: 32px;
      }
      
      .el-input,
      .el-select,
      .el-date-editor {
        width: 100%;
        height: 32px;
        --el-input-bg-color: transparent;
        --el-input-border-color: #178BFF;
        --el-input-text-color: #296ACA;
        --el-input-placeholder-color: rgba(255, 255, 255, 0.5);
 
        .el-input__wrapper {
          height: 32px;
        }
 
        .el-input__inner {
          height: 32px;
          line-height: 32px;
        }
      }
    }
  }
  :deep() {
    .el-select__wrapper {
      background: transparent;
      box-shadow: none;
      box-shadow: 0 0 0 1px #026AD6;
      height: 32px;
      padding-left: 20px;
    }
  }
  :deep(.el-pagination) {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(31, 62, 122, 0.95);
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  }
}
</style>