|
|
@@ -1,21 +1,77 @@
|
|
|
<template>
|
|
|
- <div class="deviceList">
|
|
|
- <Search :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
|
|
|
- <div class="deviceList-table">
|
|
|
- <a-table :scroll="{ x: '100%', y: 500 }" childrenColumnName="null" rowKey="device_sn" :loading="state.listLoading"
|
|
|
- :columns="columns" :dataSource="state.list" @change="refreshData" :rowClassName="rowClassName"
|
|
|
- :pagination="paginationConfig" :rowSelection="rowSelection">
|
|
|
+ <div class="taskList">
|
|
|
+ <div class="taskList-left">
|
|
|
+ <div v-for="(dock, index) in state.onlineDockList" :key="dock.sn">
|
|
|
+ <Airport :dock="dock" :look-info="false" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="taskList-right">
|
|
|
+ <Search :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
|
|
|
+ <a-table :scroll="{ x: '100%', y: 500 }" rowKey="job_id" :loading="state.listLoading" :columns="columns"
|
|
|
+ :dataSource="state.list" @change="refreshData" :rowClassName="rowClassName" :pagination="paginationConfig">
|
|
|
+ <!-- 计划|实际时间 -->
|
|
|
+ <template #duration="{ record }">
|
|
|
+ <div class="flex-row" style="white-space: pre-wrap">
|
|
|
+ <div>
|
|
|
+ <div>
|
|
|
+ {{ record.begin_time }}
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ {{ record.end_time }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="ml10">
|
|
|
+ <div>
|
|
|
+ {{ record.execute_time }}
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ {{ record.completed_time }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <!-- 执行状态 -->
|
|
|
+ <template #status="{ record }">
|
|
|
+ <div style="color: #2B85E4;" v-if="record.status === 1">
|
|
|
+ 待执行
|
|
|
+ </div>
|
|
|
+ <div style="color: #2B85E4;" v-else-if="record.status === 2">
|
|
|
+ 执行中
|
|
|
+ </div>
|
|
|
+ <div style="color: #19BE6B;" v-else-if="record.status === 3">
|
|
|
+ 完成
|
|
|
+ </div>
|
|
|
+ <div style="color: #E02020;" v-else-if="record.status === 4">
|
|
|
+ 取消
|
|
|
+ </div>
|
|
|
+ <div style="color: #E02020;" v-else-if="record.status === 5">
|
|
|
+ 失败
|
|
|
+ </div>
|
|
|
+ <div style="color: #2B85E4;" v-else-if="record.status === 6">
|
|
|
+ 暂停
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <!-- 媒体上传 -->
|
|
|
+ <template #media_upload="{ record }">
|
|
|
+ <div class="flex-display flex-align-center">
|
|
|
+ <span class="circle-icon" :style="{ backgroundColor: formatMediaTaskStatus(record).color }"></span>
|
|
|
+ {{ formatMediaTaskStatus(record).text }}
|
|
|
+ </div>
|
|
|
+ <div class="pl15">
|
|
|
+ {{ formatMediaTaskStatus(record).number }}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
<!-- 操作 -->
|
|
|
<template #action="{ record }">
|
|
|
<div class="flex-align-center flex-row" style="color: #2d8cf0">
|
|
|
<a-tooltip title="复制任务">
|
|
|
<CopyOutlined style="margin-right: 10px;" />
|
|
|
</a-tooltip>
|
|
|
- <a-tooltip title="查看轨迹">
|
|
|
+ <!-- <a-tooltip title="查看轨迹">
|
|
|
<GatewayOutlined style="margin-right: 10px;" />
|
|
|
- </a-tooltip>
|
|
|
+ </a-tooltip> -->
|
|
|
<a-tooltip title="删除">
|
|
|
- <DeleteOutlined />
|
|
|
+ <DeleteOutlined @click="onClickDelete(record.job_id, record.job_name)" />
|
|
|
</a-tooltip>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -26,40 +82,29 @@
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { reactive, onMounted } from 'vue';
|
|
|
-import { Modal } from 'ant-design-vue';
|
|
|
+import { Modal, message } from 'ant-design-vue';
|
|
|
import { CopyOutlined, GatewayOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
|
import Search from './components/Search.vue';
|
|
|
-import { getBindingDevices, updateDevice, unbindDevice } from '/@/api/manage';
|
|
|
+import Airport from '/@/components/airport/index.vue'
|
|
|
+import { useFormatTask } from '/@/components/task/use-format-task'
|
|
|
import { apis } from '/@/api/custom';
|
|
|
-import { getWorkspaceId } from '/@/utils/index';
|
|
|
+import { OnlineDevice } from '/@/types/device'
|
|
|
|
|
|
interface State {
|
|
|
- workspaceId: string,
|
|
|
- interval: number | null,
|
|
|
+ onlineDockList: OnlineDevice[],
|
|
|
query: any,
|
|
|
listLoading: boolean,
|
|
|
list: any[],
|
|
|
- selectedRowKeys: string[],
|
|
|
- currentDevice: any,
|
|
|
- editableData: {
|
|
|
- [key: string]: any,
|
|
|
- },
|
|
|
- feedbackDrawerVisible: boolean,
|
|
|
- deviceHmsDrawerVisible: boolean,
|
|
|
};
|
|
|
|
|
|
const state: State = reactive({
|
|
|
- workspaceId: getWorkspaceId(),
|
|
|
- interval: null,
|
|
|
+ onlineDockList: [],
|
|
|
query: undefined,
|
|
|
listLoading: false,
|
|
|
list: [],
|
|
|
- selectedRowKeys: [],
|
|
|
- currentDevice: {},
|
|
|
- editableData: {},
|
|
|
- feedbackDrawerVisible: false,
|
|
|
- deviceHmsDrawerVisible: false,
|
|
|
-})
|
|
|
+});
|
|
|
+
|
|
|
+const { formatMediaTaskStatus } = useFormatTask()
|
|
|
|
|
|
const paginationConfig = reactive({
|
|
|
pageSizeOptions: ['20', '50', '100'],
|
|
|
@@ -68,20 +113,22 @@ const paginationConfig = reactive({
|
|
|
pageSize: 20,
|
|
|
current: 1,
|
|
|
total: 0
|
|
|
-})
|
|
|
+});
|
|
|
|
|
|
const fetchList = async () => {
|
|
|
state.listLoading = true;
|
|
|
try {
|
|
|
- const res = await getBindingDevices(state.workspaceId, {
|
|
|
+ const res = await apis.fetchJobList({
|
|
|
...state.query,
|
|
|
page: paginationConfig.current,
|
|
|
- page_size: paginationConfig.pageSize,
|
|
|
+ page_size: paginationConfig.pageSize
|
|
|
});
|
|
|
- state.list = res.data.list;
|
|
|
- paginationConfig.total = res.data.pagination.total;
|
|
|
- paginationConfig.current = res.data.pagination.page;
|
|
|
- paginationConfig.pageSize = res.data.pagination.page_size;
|
|
|
+ if (res.code === 0) {
|
|
|
+ state.list = res.data.list;
|
|
|
+ paginationConfig.total = res.data.pagination.total
|
|
|
+ paginationConfig.current = res.data.pagination.page
|
|
|
+ paginationConfig.pageSize = res.data.pagination.page_size
|
|
|
+ }
|
|
|
} catch (e) {
|
|
|
console.error(e);
|
|
|
} finally {
|
|
|
@@ -96,61 +143,66 @@ onMounted(async () => {
|
|
|
const columns = [
|
|
|
{
|
|
|
title: '计划|实际时间',
|
|
|
- dataIndex: 'device_name',
|
|
|
- width: 150,
|
|
|
- ellipsis: true,
|
|
|
- sorter: (a: any, b: any) => a.device_name.localeCompare(b.device_name),
|
|
|
- slots: { customRender: 'device_name' }
|
|
|
+ dataIndex: 'duration',
|
|
|
+ width: 200,
|
|
|
+ slots: { customRender: 'duration' },
|
|
|
},
|
|
|
{
|
|
|
title: '执行状态',
|
|
|
- dataIndex: 'device_sn',
|
|
|
- width: 250,
|
|
|
- ellipsis: true,
|
|
|
- slots: { customRender: 'device_sn' }
|
|
|
+ dataIndex: 'status',
|
|
|
+ width: 100,
|
|
|
+ slots: { customRender: 'status' },
|
|
|
},
|
|
|
{
|
|
|
title: '类型',
|
|
|
- dataIndex: 'nickname',
|
|
|
- width: 150,
|
|
|
- ellipsis: true,
|
|
|
- sorter: (a: any, b: any) => a.nickname.localeCompare(b.nickname),
|
|
|
- slots: { customRender: 'nickname' }
|
|
|
+ dataIndex: 'task_type',
|
|
|
+ width: 120,
|
|
|
+ customRender: ({ text }: any) => {
|
|
|
+ let content = '';
|
|
|
+ switch (text) {
|
|
|
+ case 0:
|
|
|
+ content = '立即执行';
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ content = '单次定时';
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ content = '循环定时';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return content;
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
title: '计划名称',
|
|
|
- dataIndex: 'firmware_version',
|
|
|
+ dataIndex: 'job_name',
|
|
|
width: 150,
|
|
|
ellipsis: true,
|
|
|
- slots: { customRender: 'firmware_version' },
|
|
|
},
|
|
|
{
|
|
|
title: '航线名称',
|
|
|
- dataIndex: 'firmware_status',
|
|
|
+ dataIndex: 'file_name',
|
|
|
width: 150,
|
|
|
ellipsis: true,
|
|
|
- slots: { customRender: 'firmware_status' },
|
|
|
},
|
|
|
{
|
|
|
title: '设备名称',
|
|
|
- dataIndex: 'status',
|
|
|
- width: 100,
|
|
|
+ dataIndex: 'dock_name',
|
|
|
+ width: 200,
|
|
|
ellipsis: true,
|
|
|
- slots: { customRender: 'status' }
|
|
|
},
|
|
|
{
|
|
|
title: '创建人',
|
|
|
- dataIndex: 'bound_time',
|
|
|
- width: 200,
|
|
|
- sorter: (a: any, b: any) => a.bound_time.localeCompare(b.bound_time),
|
|
|
- slots: { customRender: 'bound_time' },
|
|
|
+ dataIndex: 'username',
|
|
|
+ width: 150,
|
|
|
},
|
|
|
{
|
|
|
title: '媒体上传',
|
|
|
- dataIndex: 'login_time',
|
|
|
+ dataIndex: 'media_upload',
|
|
|
width: 200,
|
|
|
- sorter: (a: any, b: any) => a.login_time.localeCompare(b.login_time),
|
|
|
- slots: { customRender: 'login_time' },
|
|
|
+ slots: { customRender: 'media_upload' },
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
|
@@ -159,7 +211,7 @@ const columns = [
|
|
|
width: 100,
|
|
|
slots: { customRender: 'action' },
|
|
|
},
|
|
|
-]
|
|
|
+];
|
|
|
|
|
|
const rowClassName = (record: any, index: number) => {
|
|
|
const className = []
|
|
|
@@ -175,12 +227,6 @@ const refreshData = async (page: any) => {
|
|
|
await fetchList();
|
|
|
}
|
|
|
|
|
|
-const rowSelection = {
|
|
|
- onChange: (selectedRowKeys: string[]) => {
|
|
|
- state.selectedRowKeys = selectedRowKeys;
|
|
|
- },
|
|
|
-}
|
|
|
-
|
|
|
// 点击搜索
|
|
|
const onClickSearch = async (query: any) => {
|
|
|
state.query = query;
|
|
|
@@ -194,24 +240,39 @@ const onClickReset = async (query: any) => {
|
|
|
}
|
|
|
|
|
|
// 点击删除
|
|
|
-const onClickDelete = (record: any) => {
|
|
|
+const onClickDelete = (id: string, name: string) => {
|
|
|
Modal.confirm({
|
|
|
- title: '提示',
|
|
|
- content: `确定删除${record.device_name}吗?`,
|
|
|
+ title: '删除任务',
|
|
|
+ content: `确定删除${name}吗?`,
|
|
|
+ okType: 'danger',
|
|
|
onOk: async () => {
|
|
|
- const res = await unbindDevice(record.device_sn);
|
|
|
- if (res.code !== 0) {
|
|
|
- return
|
|
|
+ try {
|
|
|
+ await apis.deleteJob({ job_id: id });
|
|
|
+ await fetchList();
|
|
|
+ message.success('删除成功');
|
|
|
+ } catch (error) {
|
|
|
+ message.error('删除失败: ' + error);
|
|
|
}
|
|
|
- await fetchList();
|
|
|
},
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
-.deviceList {
|
|
|
+.taskList {
|
|
|
padding: 20px;
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ &-left {
|
|
|
+ width: 240px;
|
|
|
+ height: calc(100vh - 146px);
|
|
|
+ background-color: #232323;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &-right {
|
|
|
+ width: calc(100% - 260px);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.ant-table {
|