forked from drone/command-center-dashboard

罗广辉
2025-04-21 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7
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
<!-- 任务统计表格 -->
<template>
  <div class="task-intermediate-content">
    <SearchBox @search="searchClick" @addTask="handleAddTask"></SearchBox>
    <div class="task-table ztzf-table">
      <el-table :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).toString().padStart(2, '0') }}
            </template>
          </el-table-column>
        <el-table-column prop="job_info_num" label="任务编号" show-overflow-tooltip />
        <el-table-column prop="name" label="任务名称" show-overflow-tooltip />
        <el-table-column prop="dept_name" label="所属部门"  />
        <el-table-column prop="device_names" label="所属机巢"  />
        <el-table-column prop="ai_type_str" label="关联算法" show-overflow-tooltip />
        <el-table-column label="任务状态" >
          <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 ? '#ff8e8e':''
            }">
              {{ scope.row.status ? getStatusText(scope.row.status) : '' }}
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="industry_type_str" label="任务类型" />
        <el-table-column prop="event_number" label="关联事件">
                    <template #default="scope">
                        <span>{{ scope.row.event_number ? scope.row.event_number : '/' }}</span>
                    </template>
                </el-table-column>
        <el-table-column prop="create_time" label="任务时间" />
        <el-table-column prop="creator_name" label="创建人" />
        <el-table-column label="操作" >
          <template #default="scope">
            <el-button class="current-details" link type="primary" @click="handleDetail(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination">
      <el-pagination class="ztzf-pagination"
        v-model:current-page="jobListParams.current"
        v-model:page-size="jobListParams.size"
        :page-sizes="[10, 20, 30, 50]"
        layout="prev, pager, next, sizes, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
  <!-- 添加任务 -->
  <AddTask v-model:show="isShowAddTask" @refresh="searchClick"/>
  <!-- 当前任务详情 -->
  <CurrentTaskDetails
        v-if="isShowCurrentTaskDetails"
        v-model:show="isShowCurrentTaskDetails"
        :id="rowData.id"/>
    <!-- 历史任务详情 -->
  <DeviceJobDetails
        v-if="isShowDeviceJobDetails"
        v-model:show="isShowDeviceJobDetails"
        :wayLineJodInfoId="rowData.id"/>
</template>
 
<script setup>
import SearchBox from '../SearchBox.vue';
import AddTask from './AddTask.vue';
import CurrentTaskDetails from '@/components/CurrentTaskDetails/CurrentTaskDetails.vue';
import { jobList } from '@/api/home/task';
import { ElMessage } from 'element-plus'
import DeviceJobDetails from '@/components/DeviceJobDetails/DeviceJobDetails.vue'
 
const jobListParams = reactive({
  current: 1,
  size: 10,
  searchParams:{}
});
const jobListData = ref([]);
const total = ref(0);
let isShowDeviceJobDetails = ref(false);
let isShowCurrentTaskDetails = ref(false);
 
// 获取任务列表
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: '执行失败'
  };
  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;
    } 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 isShowAddTask = ref(false);
const handleAddTask = () => {
  isShowAddTask.value = true;
};
 
const tableRowClassName = ({ row, rowIndex }) => {
    if (rowIndex % 2 === 1) {
        return 'warning-row'
    } else {
        return 'success-row'
    }
}
 
onMounted(() => {
  getJobList();
});
</script>
 
<style lang="scss" scoped>
.task-intermediate-content {
  margin: 16px 38px 16px 38px;
  background: linear-gradient( 27deg, #1F3E7A 0%, rgba(31,62,122,0.35) 79%, rgba(31,62,122,0) 100%);
  padding: 14px 18px;
  // 表格
  .task-table {
    height: 528px;
    margin-top: 18px;
    overflow: auto;
  }
 
  .current-details {
    width: 53px;
    height: 27px;
    background: #001F4E;
    border-radius: 0px 0px 0px 0px;
    border: 1px solid #51A8FF;
  }
 
  // 分页
  :deep(.el-pagination) {
    display: flex;
    justify-content: center;
  }
  :deep(.el-pagination button) {
    background: center center no-repeat none !important;
    color: #8eb8ea !important;
  }
}
</style>