|
|
@@ -1,43 +1,39 @@
|
|
|
<template>
|
|
|
- <div class="deviceList">
|
|
|
+ <div class="waylineList">
|
|
|
<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">
|
|
|
- <!-- 航线名称 -->
|
|
|
- <template #name="{ record }">
|
|
|
- <a-tooltip :title="record.name">
|
|
|
- {{ record.name }}
|
|
|
+ <a-table :scroll="{ x: '100%', y: 500 }" rowKey="id" :loading="state.listLoading" :columns="columns"
|
|
|
+ :dataSource="state.list" @change="refreshData" :rowClassName="rowClassName" :pagination="paginationConfig">
|
|
|
+ <!-- 航线名称 -->
|
|
|
+ <template #name="{ record }">
|
|
|
+ <a-tooltip :title="record.name">
|
|
|
+ {{ record.name }}
|
|
|
+ </a-tooltip>
|
|
|
+ </template>
|
|
|
+ <!-- 操作 -->
|
|
|
+ <template #action="{ record }">
|
|
|
+ <div class="flex-align-center flex-row" style="color: #2d8cf0">
|
|
|
+ <a-tooltip title="下载">
|
|
|
+ <DownloadOutlined style="margin-right: 10px;" @click="onClickDownload(record.id, record.name)" />
|
|
|
</a-tooltip>
|
|
|
- </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="查看轨迹">
|
|
|
- <GatewayOutlined style="margin-right: 10px;" />
|
|
|
- </a-tooltip>
|
|
|
- <a-tooltip title="删除">
|
|
|
- <DeleteOutlined />
|
|
|
- </a-tooltip>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </a-table>
|
|
|
- </div>
|
|
|
+ <a-tooltip title="删除">
|
|
|
+ <DeleteOutlined @click="onClickDelete(record.id, record.name)" />
|
|
|
+ </a-tooltip>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { reactive, onMounted } from 'vue';
|
|
|
import { Modal } from 'ant-design-vue';
|
|
|
-import { CopyOutlined, GatewayOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
|
+import { DownloadOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
|
import Search from './components/Search.vue';
|
|
|
-import { getWaylineFiles, importKmzFile, deleteWaylineFile, downloadWaylineFile } from '/@/api/wayline'
|
|
|
+import { apis } from '/@/api/custom'
|
|
|
+import { importKmzFile, downloadWaylineFile, deleteWaylineFile } from '/@/api/wayline'
|
|
|
import { getWorkspaceId } from '/@/utils/index';
|
|
|
import moment from 'moment';
|
|
|
+import { downloadFile } from '/@/utils/common'
|
|
|
import { DEVICE_NAME } from '/@/types/device'
|
|
|
|
|
|
interface State {
|
|
|
@@ -66,7 +62,7 @@ const paginationConfig = reactive({
|
|
|
const fetchList = async () => {
|
|
|
state.listLoading = true;
|
|
|
try {
|
|
|
- const res = await getWaylineFiles(state.workspaceId, {
|
|
|
+ const res = await apis.fetchWaylineList({
|
|
|
...state.query,
|
|
|
order_by: 'update_time desc',
|
|
|
page: paginationConfig.current,
|
|
|
@@ -109,7 +105,7 @@ const columns = [
|
|
|
dataIndex: 'template_types',
|
|
|
width: 150,
|
|
|
customRender: ({ text }: any) => {
|
|
|
- let content = ''
|
|
|
+ let content = '--';
|
|
|
switch (text[0]) {
|
|
|
case 0:
|
|
|
content = '航点航线';
|
|
|
@@ -154,7 +150,8 @@ const columns = [
|
|
|
title: '操作',
|
|
|
dataIndex: 'actions',
|
|
|
fixed: 'right',
|
|
|
- width: 100,
|
|
|
+ align: 'center',
|
|
|
+ width: 60,
|
|
|
slots: { customRender: 'action' },
|
|
|
},
|
|
|
]
|
|
|
@@ -173,12 +170,6 @@ const refreshData = async (page: any) => {
|
|
|
await fetchList();
|
|
|
}
|
|
|
|
|
|
-const rowSelection = {
|
|
|
- onChange: (selectedRowKeys: string[]) => {
|
|
|
- state.selectedRowKeys = selectedRowKeys;
|
|
|
- },
|
|
|
-}
|
|
|
-
|
|
|
// 点击搜索
|
|
|
const onClickSearch = async (query: any) => {
|
|
|
state.query = query;
|
|
|
@@ -191,24 +182,39 @@ const onClickReset = async (query: any) => {
|
|
|
await fetchList();
|
|
|
}
|
|
|
|
|
|
+// 点击下载
|
|
|
+const onClickDownload = async (id: string, name: string) => {
|
|
|
+ state.listLoading = true;
|
|
|
+ try {
|
|
|
+ const res = await downloadWaylineFile(state.workspaceId, id);
|
|
|
+ if (!res) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = new Blob([res], { type: 'application/zip' });
|
|
|
+ downloadFile(data, name + '.kmz');
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error);
|
|
|
+ } finally {
|
|
|
+ state.listLoading = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 点击删除
|
|
|
-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
|
|
|
- }
|
|
|
+ await deleteWaylineFile(getWorkspaceId(), id);
|
|
|
await fetchList();
|
|
|
},
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
-.deviceList {
|
|
|
+.waylineList {
|
|
|
padding: 20px;
|
|
|
}
|
|
|
|