无人机管理后台前端(已迁走)
张含笑
2025-09-01 2ca94de8ede18ac07ccfd8dec7b6f6a707adde9b
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<template>
  <basic-container>
    <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" ref="crud" @row-del="rowDel"
      v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave" :before-open="beforeOpen"
      @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
      @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
      <template #menu-left>
        <!-- <el-button
          type="danger"
          icon="el-icon-delete"
          plain
          v-if="permission.odm_task_delete"
          @click="handleDelete"
          >删 除
        </el-button> -->
      </template>
      <template #runningProgress="{ row }">
        <el-progress :percentage="row.runningProgress * 100"></el-progress>
      </template>
      <template #processingTime="{ row }">
        {{ formatSeconds(row.processingTime) }}
      </template>
      <template #menu="scope">
        <el-button type="primary" text icon="el-icon-guide"
          v-if="permission.odm_task_handle && scope.row.taskId == null"
          @click.stop="atHandle(scope.row, scope.index)">立即启动
        </el-button>
        <el-button type="primary" text icon="el-icon-refresh-right"
          v-if="(permission.odm_task_handle && scope.row.status == 30) || scope.row.status == 50"
          @click.stop="restartHandle(scope.row, scope.index)">重新启动
        </el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
 
<script>
import { getList, remove, update, add, createOdmTask, restartOdmTask } from '@/api/odm/task'
import { tourStrategies } from 'element-plus'
import { mapGetters } from 'vuex'
 
export default {
  data () {
    return {
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        viewBtn: true,
        selection: true,
        addBtn: false,
        editBtn: false,
        excelBtn: false,
        dialogClickModal: false,
        grid: false,
        menuWidth: 260,
 
        height: 'auto',
        calcHeight: 20,
 
        column: [
          {
            label: '任务名称',
            prop: 'taskName',
            search: true,
            searchSpan: 4,
            searchLabelWidth: 100,
            //labelWidth: 130,
            searchPlaceholder: "任务名称",
            rules: [
              {
                required: true,
                message: '请输入任务名称',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '地块编号',
            prop: 'dkbh',
            labelWidth: 130,
            // hide:true,
            rules: [
              {
                required: true,
                message: '请输入任务编号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '任务编号',
            prop: 'taskId',
            hide: true,
            labelWidth: 130,
            rules: [
              {
                required: true,
                message: '请输入任务编号',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '飞行任务编号',
            prop: 'waylineJobId',
            addDisplay: false,
            editDisplay: false,
            hide: true,
            labelWidth: 130,
            width: 160,
          },
          {
            label: '任务类型',
            prop: 'waylineType',
            type: 'select',
            search: true,
            searchSpan: 4,
            searchLabelWidth: 100,
            //width: 100,
            labelWidth: 130,
            searchPlaceholder: "任务类型",
            dicData: [
              {
                label: '航测',
                value: 2,
              },
              {
                label: '正射举证',
                value: 4,
              },
            ],
              change: (value) => {
               this.searchChange({ ...this.query,waylineType:value.value}, () => {});
          }
          },
          {
            label: '机场名称',
            prop: 'airportName',
            searchSpan: 4,
            searchLabelWidth: 100,
            //search: true,
          },
          {
            label: '图片数量',
            prop: 'imageCount',
            labelWidth: 130,
            width: 90,
          },
          {
            label: '拼图耗时',
            prop: 'processingTime',
            width: 90,
            labelWidth: 130,
          },
          {
            label: '进度',
            prop: 'runningProgress',
            width: 100,
            labelWidth: 130,
          },
          {
            label: '任务状态',
            prop: 'status',
            type: 'select',
            search: true,
            searchSpan: 4,
            searchLabelWidth: 100,
            searchPlaceholder: "任务状态",
            width: 90,
            dicData: [
              { label: '待启动', value: 0 },
              { label: '待处理', value: 10 },
              { label: '处理中', value: 20 },
              { label: '失败', value: 30 },
              { label: '已完成', value: 40 },
              { label: '已取消', value: 50 },
            ],
            change: (value) => {
              this.searchChange({ ...this.query,status:value.value}, () => {});
            }
          },
 
          {
            label: '任务创建时间',
            prop: 'createTime',
            type: 'date',
            addDisplay: false,
            editDisplay: false,
            labelWidth: 130,
            width: 160,
            format: 'YYYY-MM-DD HH:mm:ss',
            // valueFormat: 'YYYY-MM-DD HH:mm:ss',
          },
          {
            label: '完成时间',
            prop: 'completedTime',
            type: "date",
            addDisplay: false,
            editDisplay: false,
            searchPlaceholder: "任务完成时间",
            labelWidth: 130,
            search: true,
            searchSpan: 4,
            searchLabelWidth: 100,
            //valueFormat: 'YYYY-MM-DD',
            width: 160,
            change: (value) => {                   
             this.searchChange({ ...this.query,completedTime:value.value}, () => {});
            }
          },
        ],
      },
      data: [],
    }
  },
  computed: {
    ...mapGetters(['permission']),
    permissionList () {
      return {
        viewBtn: this.validData(this.permission.odm_task_view, true),
        delBtn: this.validData(this.permission.odm_task_delete, true),
        // editBtn: this.validData(this.permission.workspace_edit, true),
      }
    },
    ids () {
      let ids = []
      this.selectionList.forEach(ele => {
        ids.push(ele.id)
      })
      return ids.join(',')
    },
  },
  methods: {
    // 立即处理
    atHandle (row) {
      createOdmTask(row.waylineJobId, row.gsd).then(
        () => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
          done()
        },
        error => {
          window.console.log(error)
          loading()
        }
      )
    },
    // 重启启动
    restartHandle (row) {
      if (!row.taskName) {
        this.$message({
          type: 'error',
          message: '该航线任务已删除,无法进行重启启动!',
        })
        return
      }
      restartOdmTask(row.taskId).then(
        () => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
          done()
        },
        error => {
          window.console.log(error)
          loading()
        }
      )
    },
    // 时间格式化
    formatSeconds (value) {
      // 如果value不是数字或者小于0,则直接返回'00:00:00'
      if (isNaN(value) || value < 0) {
        return '00:00:00'
      }
 
      // 计算小时、分钟和秒
      let seconds = Math.floor(value / 1000)
      let minutes = Math.floor(seconds / 60)
      let hours = Math.floor(minutes / 60)
 
      // 格式化为两位数字的字符串
      seconds %= 60
      minutes %= 60
 
      const formattedTime = `${this.padZero(hours)}:${this.padZero(minutes)}:${this.padZero(
        seconds
      )}`
 
      // 返回格式化后的时间字符串
      return formattedTime
    },
    // 函数用于在数字不足两位数时,在前面补零
    padZero (value) {
      return String(value).padStart(2, '0')
    },
    rowSave (row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
          done()
        },
        error => {
          window.console.log(error)
          loading()
        }
      )
    },
    rowUpdate (row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
          done()
        },
        error => {
          window.console.log(error)
          loading()
        }
      )
    },
    rowDel (row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          return remove(row.id)
        })
        .then(() => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
        })
    },
    searchReset () {
      this.query = {}
      this.onLoad(this.page)
    },
    searchChange (params, done) { 
      this.query = params
      this.page.currentPage = 1
      this.onLoad(this.page, params)
      done()
    },
    selectionChange (list) {
      this.selectionList = list
    },
    selectionClear () {
      this.selectionList = []
      this.$refs.crud.toggleSelection()
    },
    handleDelete () {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据')
        return
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          return remove(this.ids)
        })
        .then(() => {
          this.onLoad(this.page)
          this.$message({
            type: 'success',
            message: '操作成功!',
          })
          this.$refs.crud.toggleSelection()
        })
    },
    beforeOpen (done, type) {
      // if (['edit', 'view'].includes(type)) {
      //   getDetail(this.form.id).then(res => {
      //     this.form = res.data.data;
      //   });
      // }
      done()
    },
    currentChange (currentPage) {
      this.page.currentPage = currentPage
    },
    sizeChange (pageSize) {
      this.page.pageSize = pageSize
    },
    refreshChange () {
      this.onLoad(this.page, this.query)
    },
    onLoad (page, params = {}) {
      const { releaseTimeRange } = this.query
      let values = {
        ...params,
        ...this.query,
      }
      if (releaseTimeRange) {
        values = {
          ...values,
          releaseTime_datege: releaseTimeRange[0],
          releaseTime_datelt: releaseTimeRange[1],
        }
        values.releaseTimeRange = null
      }
      this.loading = true
      getList(page.currentPage, page.pageSize, values).then(res => {
        const data = res.data.data
        this.page.total = data.total
        this.data = data.records
        this.loading = false
        this.selectionClear()
      })
    },
  },
}
</script>
 
<style scoped lang="scss"></style>