From 83aa27180531b67993158d37729efa9c5fc723bb Mon Sep 17 00:00:00 2001
From: betaqi <3188864257@qq.com>
Date: Mon, 16 Jun 2025 11:16:52 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=9F=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
global.types/components.d.ts | 7 +
src/api/module/firmware/index.ts | 3 -
src/api/module/taks/index.ts | 70 +++
src/components/Edfs-button.vue | 1 +
src/components/Edfs-table/index.vue | 47 +-
src/router/index.ts | 10 +
src/views/layout/index.vue | 7 +-
.../stationData/components/offTransferDlg.vue | 52 +-
.../components/onLineTransferDlg.vue | 94 +--
src/views/stationData/index.vue | 1 -
src/views/stationData/transferData.vue | 552 ++----------------
src/views/taskList/index.vue | 130 +++++
src/views/taskList/infoDrawer.vue | 107 ++++
13 files changed, 463 insertions(+), 618 deletions(-)
create mode 100644 src/api/module/taks/index.ts
create mode 100644 src/views/taskList/index.vue
create mode 100644 src/views/taskList/infoDrawer.vue
diff --git a/global.types/components.d.ts b/global.types/components.d.ts
index b6c94ef..e3c4b9f 100644
--- a/global.types/components.d.ts
+++ b/global.types/components.d.ts
@@ -21,17 +21,24 @@ declare module 'vue' {
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
+ ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
+ ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
+ ElDropdown: typeof import('element-plus/es')['ElDropdown']
+ ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
+ ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElInput: typeof import('element-plus/es')['ElInput']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
+ ElPagination: typeof import('element-plus/es')['ElPagination']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
+ ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree']
diff --git a/src/api/module/firmware/index.ts b/src/api/module/firmware/index.ts
index 4dba6ba..2e3180a 100644
--- a/src/api/module/firmware/index.ts
+++ b/src/api/module/firmware/index.ts
@@ -1,8 +1,5 @@
import { globalServer } from '../index'
-
-
-
export const uploadFirmwareFile = (params: FormData, abort: AbortController) =>
globalServer({
url: 'api/upload',
diff --git a/src/api/module/taks/index.ts b/src/api/module/taks/index.ts
new file mode 100644
index 0000000..dba2a06
--- /dev/null
+++ b/src/api/module/taks/index.ts
@@ -0,0 +1,70 @@
+import { globalServer } from '../index'
+
+interface Param {
+ page: number
+ size: number
+}
+
+export const getTaskList = (params: Param) =>
+ globalServer<{
+ tasks: TaskList[]
+ total: number
+ }>({
+ url: 'api/task/summary',
+ method: 'get',
+ data: params,
+
+ })
+
+
+export const getTaskInfo = (taskId: string) => globalServer<{ details: TaskInfo[] }>({
+ url: 'api/task/detail',
+ method: 'GET',
+ params: { task: taskId },
+})
+
+export interface TaskCreateParams {
+ site: string
+ devices: {
+ sn: string
+ disk?: string
+ host?: string
+ }[],
+ mode: 'import' | 'export' | 'update'
+ startTime?: string
+ endTime?: string
+}
+
+export const createTask = (params: TaskCreateParams) => globalServer({
+ url: 'api/task/apply',
+ method: 'POST',
+ data: params,
+})
+
+export const cancelTask = (taskId: string) => globalServer({
+ url: 'api/task/cancel',
+ method: 'POST',
+ data: { task: taskId },
+})
+
+export type TaskInfo = {
+ finish: number;
+ id: string;
+ info: string;
+ site: string;
+ sn: string;
+ status: -1 | 0 | 1 | 2; // -1 失败, 0 未开始, 1 进行中, 2 成功
+ task_id: string;
+ total: number;
+};
+
+export interface TaskList {
+ endTime: string; // 结束时间(可能是空字符串)
+ id: string; // "task759956"
+ info: string; // ""
+ mode: string; // "export"
+ site: string; // "test1"
+ startTime: string; // 开始时间(可能是空字符串)
+ status: -1 | 0 | 1 | 2 | 3; // -1 失败, 0 未开始, 1 进行中, 2 取消, 3 成功
+ loading?: boolean
+}
\ No newline at end of file
diff --git a/src/components/Edfs-button.vue b/src/components/Edfs-button.vue
index 646310d..5c3aad1 100644
--- a/src/components/Edfs-button.vue
+++ b/src/components/Edfs-button.vue
@@ -13,6 +13,7 @@
:color="color"
:class="className"
@click="onClick"
+ :link="link"
:text="text"
class="edfs-button"
>
diff --git a/src/components/Edfs-table/index.vue b/src/components/Edfs-table/index.vue
index 9d2b539..3f03986 100644
--- a/src/components/Edfs-table/index.vue
+++ b/src/components/Edfs-table/index.vue
@@ -1,36 +1,16 @@
-
+
@@ -59,6 +39,7 @@ const emit = defineEmits<{
// 'page-size-change': [pageSize: number]
'page-current-change': [currentPage: number]
'selection-change': [selection: any[]]
+ 'expand-change': [row: any, expandedRows: any[]]
}>()
function onCurrentChange(currentRow: any, oldCurrentRow: any) {
@@ -74,6 +55,9 @@ function onRowDblclick(row: any, column: any, event: Event) {
function handleSelectionChange(selection: any[]) {
emit('selection-change', selection)
}
+function expandChange(row: any, expandedRows: any[]) {
+ emit('expand-change', row, expandedRows)
+}
// 分页
const pageSize = ref()
@@ -125,6 +109,7 @@ defineExpose({
display: flex;
flex-direction: column;
box-sizing: border-box;
+
// background-color: #fff;
.edfs-table {
width: 100%;
@@ -155,21 +140,26 @@ defineExpose({
align-items: center;
justify-content: end;
height: 60px;
+
:deep(.el-pagination__editor.el-input) {
width: 66px;
}
+
:deep(.el-input__wrapper) {
height: 30px;
margin-left: 8px;
padding: 0 10px;
+
.el-input__inner {
font-size: 14px;
height: 100%;
}
}
+
:deep(.el-pagination) {
// width: cvw(200);
}
+
:deep(.el-pagination),
:deep(.el-pagination .el-icon),
:deep(.el-pagination li) {
@@ -181,6 +171,7 @@ defineExpose({
:deep(.el-pagination li) {
background-color: transparent;
}
+
:deep(.el-pager) {
height: 28px;
}
@@ -196,12 +187,14 @@ defineExpose({
color: #619925;
}
}
+
:deep(.is-active) {
color: #619925 !important;
background: rgba(97, 153, 37, 0.06) !important;
border: 1px solid rgba(97, 153, 37, 1) !important;
border-radius: 2px;
}
+
:deep(.el-input__wrapper) {
background-color: var(--pagination-bg);
}
diff --git a/src/router/index.ts b/src/router/index.ts
index 3761470..edb5d38 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -43,6 +43,16 @@ export const defaultRouter = [
icon: 'i-mingcute:transfer-2-line',
},
},
+ {
+ path: '/task',
+ name: 'task',
+ component: () => import('@/views/taskList/index.vue'),
+ meta: {
+ title: '任务列表',
+ isShow: true,
+ icon: 'i-mingcute:task-line',
+ }
+ }
],
},
]
diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue
index 26f4c39..ad55b0a 100644
--- a/src/views/layout/index.vue
+++ b/src/views/layout/index.vue
@@ -50,10 +50,6 @@
{{ currentTime }}
-
@@ -76,8 +72,9 @@ const { theme } = useTheme()
const menuList = computed(() => {
let data = defaultRouter[0].children
if (env.VITE_APP_ENV !== 'local') {
- data = data.filter(item => item.name != 'firmware-upload')
+ data = data.filter(item => !['firmware-upload', 'task'].includes(item.name))
}
+ console.log(data)
return data
}
)
diff --git a/src/views/stationData/components/offTransferDlg.vue b/src/views/stationData/components/offTransferDlg.vue
index 4b0122d..37f8fc6 100644
--- a/src/views/stationData/components/offTransferDlg.vue
+++ b/src/views/stationData/components/offTransferDlg.vue
@@ -6,8 +6,7 @@
*
云端IP:
-
+
@@ -20,11 +19,12 @@ import { cloneDeep } from 'lodash-es'
import { useMessage } from '@/composables/useMessage'
import type { IOfflineDevice } from '../type'
import type { ISite } from '@/api/module/transfer'
+import { createTask, type TaskCreateParams } from '@/api/module/taks'
const message = useMessage()
const emit = defineEmits<{
- 'on-save': [msg: PublishMsg<'import'>[], site: IOfflineDevice[]]
+ 'on-save': []
}>()
const props = defineProps<{
@@ -37,48 +37,40 @@ const fromData = {
clientIp: '',
}
-const curOffDeive = ref([])
const form = ref(cloneDeep(fromData))
+const paramsData = ref()
-
-const isBatchTransfer = ref(false)
-
-function open(item: IOfflineDevice[], isBatch: boolean = false) {
- curOffDeive.value = item
+function open(parmas: TaskCreateParams) {
+ paramsData.value = parmas
visible.value = true
- isBatchTransfer.value = isBatch
}
-function onSave() {
+async function onSave() {
if (verifyData()) return
- if (!curOffDeive.value.length) {
- message.error('请选择设备')
+ if (!paramsData.value) {
+ message.error('参数错误')
return
}
- const msgList: PublishMsg<"import">[] = []
- for (const device of curOffDeive.value) {
- const params = [
- `${form.value.clientIp}`,
- '',
- '',
- '',
- '',
- '',
- `${props.siteInfo!.name}/${device.sn}`,
- ]
- const msg = getPubInitData<'import'>('import', params)
- msgList.push(msg)
+
+ paramsData.value.devices.forEach((r) => {
+ r.host = form.value.clientIp
+ })
+
+ const res = await createTask(paramsData.value)
+ if (res.code !== 0) {
+ message.error(`任务创建失败`)
+ } else {
+ message.success('任务创建成功,请在任务列表中查看')
}
- emit('on-save', msgList, curOffDeive.value)
+ emit('on-save')
close()
}
function close() {
- form.value = cloneDeep(fromData)
- curOffDeive.value = []
visible.value = false
- isBatchTransfer.value = false
+ form.value = cloneDeep(fromData)
+ paramsData.value = undefined
}
const ipPattern =
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
diff --git a/src/views/stationData/components/onLineTransferDlg.vue b/src/views/stationData/components/onLineTransferDlg.vue
index bbdacfa..07a0d95 100644
--- a/src/views/stationData/components/onLineTransferDlg.vue
+++ b/src/views/stationData/components/onLineTransferDlg.vue
@@ -1,28 +1,15 @@
-
+
*
数据开始时间:
-
+
@@ -30,17 +17,9 @@
*
数据结束时间:
-
+
@@ -51,10 +30,11 @@ import dayjs from 'dayjs'
import { getPubInitData, type PublishMsg } from '@/utils/zmq'
import type { IOnlineDevice } from '../type'
import { useMessage } from '@/composables/useMessage'
+import { createTask, type TaskCreateParams } from '@/api/module/taks'
const message = useMessage()
const emit = defineEmits<{
- 'on-save': [PublishMsg<'export'>, IOnlineDevice]
+ 'on-save': []
}>()
const props = defineProps<{
@@ -115,40 +95,31 @@ function handleEndTimeChange(val: string) {
}
}
-const curDevice = ref()
+const paramsData = ref()
-const batchClientIp = ref('')
-const batchPath = ref('')
-
-function open(item: IOnlineDevice, clientIps: string, paths: string) {
- curDevice.value = item
+function open(parmas: TaskCreateParams) {
+ paramsData.value = parmas
visible.value = true
- batchClientIp.value = clientIps
- batchPath.value = paths
}
-function onSave() {
+async function onSave() {
if (!verifyData()) return
- if (!curDevice.value) {
- message.error('请选择设备')
+ if (!paramsData.value) {
+ message.error('任务参数未定义')
return
}
- const params = [
- `${props.isBatchTransfer ? batchClientIp.value : curDevice.value.clientIp}`,
- '',
- '',
- '',
- '',
- '',
- `${
- props.isBatchTransfer
- ? batchPath.value
- : `${curDevice.value.site_id}/${curDevice.value.sn}`
- }`,
- `${dayjs(startTime.value).valueOf()},${dayjs(endTime.value).valueOf()}`,
- ]
- const msg = getPubInitData<'export'>('export', params)
- emit('on-save', msg, curDevice.value as IOnlineDevice)
+ const params = paramsData.value
+ params.startTime = dayjs(startTime.value).format('YYYY-MM-DD HH:mm:ss')
+ params.endTime = dayjs(endTime.value).format('YYYY-MM-DD HH:mm:ss')
+ const res = await createTask(params)
+ if (res.code !== 0) {
+ message.error(`任务创建失败`)
+ } else {
+ message.success('任务创建成功,请在任务列表中查看')
+ }
+
+
+ emit('on-save')
close()
}
@@ -156,18 +127,16 @@ function close() {
startTime.value = ''
endTime.value = ''
visible.value = false
- curDevice.value = undefined
- batchClientIp.value = ''
- batchPath.value = ''
+ paramsData.value = undefined
}
function verifyData() {
- if(!startTime.value) {
+ if (!startTime.value) {
message.error('请选择开始时间')
return false
}
- if(!endTime.value) {
+ if (!endTime.value) {
message.error('请选择结束时间')
return false
}
@@ -190,6 +159,7 @@ defineExpose({
line-height: 33px;
text-align: right;
width: 110px;
+
.require {
color: red;
}
diff --git a/src/views/stationData/index.vue b/src/views/stationData/index.vue
index 8ca8c1c..e7e60df 100644
--- a/src/views/stationData/index.vue
+++ b/src/views/stationData/index.vue
@@ -78,7 +78,6 @@
-
diff --git a/src/views/stationData/transferData.vue b/src/views/stationData/transferData.vue
index 3fe21b4..aa0b039 100644
--- a/src/views/stationData/transferData.vue
+++ b/src/views/stationData/transferData.vue
@@ -37,7 +37,7 @@
+ @click="onBatchTransferSave([item])">
-
@@ -85,168 +84,35 @@
-
-
-
-
-
-
-
当前步骤:
-
{{item.upFirmwareStatus?.step === 4 && item.upFirmwareStatus?.progress === 100 ? '安装完成' :
- upgradeProgressStatusMap.find(r => r.status === item.upFirmwareStatus?.step)?.text ??
- '--'}}
-
-
-
-
-
-
-
-
-
-
-
-
-
错误发生步骤:
-
- {{
- upgradeProgressStatusMap.find(
- r => r.status == item.upFirmwareStatus?.step
- )?.text ?? '--'
- }}失败
-
-
-
-
错误信息:
-
{{ item.upFirmwareStatus?.errMsg ?? '--' }}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{
- transferStatusMap[transferStatus as keyof typeof transferStatusMap] ?? ''
- }}
-
-
-
-
停止迁移
-
-
-
迁移日志
-
-
- {{ i.msg }}
-
-
-
-
-
-
-
-
-
-
-
- {{ !!onOffDeviceTransferStatus ? onOffDeviceTransferStatus ===
- 'progress'
- ? '数据导入中' : `数据导入完成 (失败:${offLineTransferRes().error}个 超时:${offLineTransferRes().timeout}个) ` :
- '数据导入中'
- }}
-
-
-
-
-
-
迁移日志
-
-
- 【{{ i.device.sn }}】:{{ i.msg }}
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/views/taskList/infoDrawer.vue b/src/views/taskList/infoDrawer.vue
new file mode 100644
index 0000000..90e38f4
--- /dev/null
+++ b/src/views/taskList/infoDrawer.vue
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+ {{statusList.find(r => r.value ===
+ detail.status)?.label || '--'
+ }}
+ {{ detail.total }}
+ {{ detail.finish }}
+
+ {{ detail?.info ? detail.info : '暂无信息' }}
+
+
+
+ 暂无进度
+
+
+
+
+
+
+
+
+
+
+
+
+