<!-- 任务统计表格 -->
|
<template>
|
<div class="task-intermediate-content">
|
<SearchBox @search="searchClick" @addTask="handleAddTask"></SearchBox>
|
<div class="task-table">
|
<el-table
|
stripe
|
:data="jobListData"
|
:row-class-name="tableRowClassName"
|
:row-style="{ height: '54px', fontSize: '14px', 'text-align': 'center' }"
|
:header-cell-style="{ 'text-align': 'center', height: '36px', fontSize: '14px' }"
|
>
|
<el-table-column label="序号" type="index" width="60">
|
<template #default="{ $index }">
|
{{ ($index + 1 + (jobListParams.current - 1) * jobListParams.size).toString().padStart(2, '0') }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="job_info_num" label="任务编号" show-overflow-tooltip align="center" />
|
<el-table-column prop="name" label="任务名称" show-overflow-tooltip align="center" />
|
<el-table-column prop="dept_name" label="所属部门" width="200" align="center" />
|
<el-table-column prop="device_names" label="所属机巢" />
|
<el-table-column prop="ai_type_str" label="关联算法" show-overflow-tooltip align="center" />
|
<el-table-column label="任务状态" align="center">
|
<template #default="scope">
|
<span
|
:style="{
|
color:
|
scope.row.status === 1
|
? '#ffe17e'
|
: scope.row.status === 2
|
? '#ffa768'
|
: scope.row.status === 3
|
? '#8effac'
|
: scope.row.status === 5
|
? '#FF4848'
|
: scope.row.status === 7
|
? '#A6A6A6'
|
: '',
|
}"
|
>
|
{{ scope.row.status ? getStatusText(scope.row.status) : '' }}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="is_circle_job" label="任务类型" align="center">
|
<template #default="scope">
|
<span>{{ scope.row.rep_rule_type ? '周期任务' : '临时任务' }}</span>
|
</template>
|
</el-table-column>
|
<!-- <el-table-column prop="job_num" label="执行次数" /> -->
|
<el-table-column prop="event_number" label="关联事件" align="center">
|
<template #default="scope">
|
<span>{{ scope.row.event_number ? scope.row.event_number : '/' }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="cycle_time_value" label="任务时间" />
|
<el-table-column prop="creator_name" label="创建人" align="center" />
|
<el-table-column label="操作" width="200" align="center">
|
<template #default="scope">
|
<div
|
v-if="scope.row.status === 2"
|
class="btnItem turnBack"
|
link
|
type="primary"
|
@click="turnBack(scope.row)"
|
>
|
返航
|
</div>
|
<div
|
v-if="scope.row.status === 1"
|
class="btnItem cancelTask"
|
link
|
type="primary"
|
@click="cancelTask(scope.row)"
|
>
|
取消任务
|
</div>
|
<div class="btnItem" link type="primary" @click="handleDetail(scope.row)">查看</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div class="pagination">
|
<el-pagination
|
class="ztzf-pagination"
|
popper-class="custom-pagination-dropdown"
|
v-model:current-page="jobListParams.current"
|
v-model:page-size="jobListParams.size"
|
:page-sizes="[10, 20, 30, 40]"
|
layout="prev, pager, next, sizes, jumper"
|
:total="total"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
</div>
|
<!-- 添加任务 -->
|
<AddTask v-model:show="isShowAddTask" @refresh="refreshGetJobList" />
|
<!-- 当前任务详情 -->
|
<!-- <CurrentTaskDetails
|
v-if="isShowCurrentTaskDetails"
|
v-model:show="isShowCurrentTaskDetails"
|
:wayLineJodInfoId="rowData.id"
|
/> -->
|
<!-- 历史任务详情 -->
|
<DeviceJobDetails
|
v-if="isShowDeviceJobDetails"
|
v-model:show="isShowDeviceJobDetails"
|
:wayLineJodInfoId="rowData.id"
|
:batchNo="rowData.batch_no"
|
/>
|
<CancelTaskDialog
|
ref="cancelTaskDialogRef"
|
v-model:isShowCancelTask="isShowCancelTask"
|
:row-data="rowData"
|
@refresh="getJobList"
|
/>
|
</template>
|
|
<script setup>
|
import SearchBox from '../SearchBox.vue'
|
import AddTask from './AddTask.vue'
|
// import CurrentTaskDetails from '@/components/CurrentTaskDetails/CurrentTaskDetails.vue'
|
import { jobList, cancelJobs, taskReturnLines } from '@/api/job/task'
|
import { ElMessage } from 'element-plus'
|
import DeviceJobDetails from '../DeviceJobDetails.vue'
|
import CancelTaskDialog from '../CancelTaskDialog.vue'
|
import { useStore } from 'vuex'
|
const store = useStore()
|
const singleUavHome = computed(() => store.state.home.singleUavHome)
|
const jobListParams = reactive({
|
current: 1,
|
size: 10,
|
searchParams: {},
|
})
|
const jobListData = ref([])
|
const total = ref(0)
|
let isShowDeviceJobDetails = ref(false)
|
let isShowCurrentTaskDetails = ref(false)
|
let isShowCancelTask = ref(false)
|
const cancelTaskDialogRef = ref(null)
|
|
// 获取任务列表
|
const getJobList = () => {
|
jobList(jobListParams).then(res => {
|
if (res.data.code !== 0) return
|
jobListData.value = res.data.data.records
|
total.value = res.data.data.total
|
})
|
}
|
// 状态文字
|
const getStatusText = status => {
|
const statusMap = {
|
1: '待执行',
|
2: '执行中',
|
3: '已执行',
|
4: '已取消',
|
5: '执行失败',
|
7: '取消执行',
|
}
|
return statusMap[status] || '-'
|
}
|
|
// 查看当前任务详情 如果是一台机则显示详情 如果是多台机则进入集群调度(暂未开发)
|
let rowData = ref({})
|
const handleDetail = row => {
|
if (!row.device_sns.length) return ElMessage.warning('没有device_sns')
|
if (row.device_sns.length !== 1) return ElMessage.success('即将跳转到集群调度')
|
rowData.value = row ? row : {}
|
if (row.status === 2 || row.status === 1) {
|
// isShowCurrentTaskDetails.value = true
|
// 跳转大屏当前任务详情
|
const adminUrl = `${import.meta.env.VITE_APP_AREA_NAME}/command-center-dashboard/#/taskManage`
|
const targetPath = `id=${encodeURIComponent(rowData.value.id)}&batchNo=${encodeURIComponent(rowData.value.batch_no)}`
|
window.open(`${adminUrl}?${targetPath}`, '_blank')
|
} else {
|
isShowDeviceJobDetails.value = true
|
}
|
}
|
|
// 分页大小改变
|
const handleSizeChange = val => {
|
jobListParams.size = val
|
getJobList()
|
}
|
|
// 页码改变
|
const handleCurrentChange = val => {
|
jobListParams.current = val
|
getJobList()
|
}
|
|
// 传参查询条件
|
const searchClick = params => {
|
jobListParams.current = 1
|
jobListParams.size = 10
|
jobListParams.searchParams = params
|
getJobList()
|
}
|
|
const refreshGetJobList = () => {
|
jobListParams.current = 1
|
jobListParams.size = 10
|
getJobList()
|
}
|
|
// 新建任务
|
const isShowAddTask = ref(false)
|
const handleAddTask = () => {
|
isShowAddTask.value = true
|
}
|
|
const tableRowClassName = ({ row, rowIndex }) => {
|
if (rowIndex % 2 === 1) {
|
return 'warning-row'
|
} else {
|
return 'success-row'
|
}
|
}
|
// 取消任务 0 取消全部 1取消单条
|
const cancelTask = row => {
|
if (row.execute_time_arr?.length && row.execute_time_arr?.length > 0) {
|
rowData.value = row
|
isShowCancelTask.value = true
|
} else {
|
cancelTaskDialogRef.value.submitCancelTask(row, 1)
|
}
|
}
|
// 返航
|
const turnBack = row => {
|
taskReturnLines(row.device_sns).then(res => {
|
if (res.data.code !== 0) return
|
ElMessage.success('返航操作成功')
|
getJobList()
|
})
|
}
|
|
onMounted(() => {
|
// getJobList()
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.task-intermediate-content {
|
margin: 0 30px 16px 40px;
|
background-color: #ffffff;
|
padding: 14px 18px;
|
// 表格
|
.task-table {
|
height: 520px;
|
margin-top: 18px;
|
overflow: auto;
|
}
|
.btnItem {
|
height: 27px;
|
line-height: 27px;
|
border-radius: 0px 0px 0px 0px;
|
border: 1px solid #51a8ff;
|
font-family: Segoe UI, Segoe UI;
|
font-weight: 400;
|
font-size: 14px;
|
color: #1C5CFF;
|
padding: 0 10px;
|
display: inline-block;
|
margin-right: 10px;
|
cursor: pointer;
|
|
&.turnBack {
|
border: 1px solid #ffa500;
|
color: #ffa500;
|
}
|
&.cancelTask {
|
border: 1px solid #3efe96;
|
color: #3efe96;
|
}
|
}
|
:deep(.el-table) {
|
--el-table-tr-bg-color: #ffffff;
|
--el-table-striped-bg-color: #EFEFEF;
|
|
.el-table__body tr.el-table__row--striped td {
|
background-color: var(--el-table-striped-bg-color);
|
}
|
}
|
// 分页
|
:deep(.el-pagination) {
|
display: flex;
|
justify-content: center;
|
}
|
:deep(.el-pagination button) {
|
background: center center no-repeat none !important;
|
color: #8eb8ea !important;
|
}
|
}
|
</style>
|