From b6289756a0e034fd94fbe62d9ea4c48199717f36 Mon Sep 17 00:00:00 2001 From: betaqi <3188864257@qq.com> Date: Mon, 19 May 2025 17:50:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- global.types/components.d.ts | 6 + src/api/module/firmware/index.ts | 21 ++ src/api/module/transfer/index.ts | 35 ++- src/router/index.ts | 13 +- src/stores/transferData.ts | 55 +++- src/utils/zmq.ts | 2 +- src/views/firmwareUpload/index.vue | 186 +++++++++++++ .../stationData/components/deviceDrawer.vue | 77 +++++- .../components/siteTransferDlg.vue | 102 +++++++ .../stationData/components/transferDlg.vue | 2 +- src/views/stationData/index.vue | 194 +++++++++++-- src/views/stationData/transferData.vue | 257 +++++++++++++++--- src/views/stationData/type.ts | 14 + src/views/stationData/utils.ts | 29 ++ 14 files changed, 901 insertions(+), 92 deletions(-) create mode 100644 src/api/module/firmware/index.ts create mode 100644 src/views/firmwareUpload/index.vue create mode 100644 src/views/stationData/components/siteTransferDlg.vue diff --git a/global.types/components.d.ts b/global.types/components.d.ts index f68a145..0ad67ec 100644 --- a/global.types/components.d.ts +++ b/global.types/components.d.ts @@ -16,6 +16,7 @@ declare module 'vue' { EdfsWrap: typeof import('./../src/components/Edfs-wrap.vue')['default'] ElAside: typeof import('element-plus/es')['ElAside'] ElButton: typeof import('element-plus/es')['ElButton'] + ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] @@ -24,6 +25,7 @@ declare module 'vue' { ElDialog: typeof import('element-plus/es')['ElDialog'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] 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'] ElProgress: typeof import('element-plus/es')['ElProgress'] @@ -32,7 +34,11 @@ declare module 'vue' { ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElTag: typeof import('element-plus/es')['ElTag'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] + ElUpload: typeof import('element-plus/es')['ElUpload'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] } + export interface ComponentCustomProperties { + vLoading: typeof import('element-plus/es')['ElLoadingDirective'] + } } diff --git a/src/api/module/firmware/index.ts b/src/api/module/firmware/index.ts new file mode 100644 index 0000000..d4df2d6 --- /dev/null +++ b/src/api/module/firmware/index.ts @@ -0,0 +1,21 @@ +import { globalServer } from '../index' + + + + +export const uploadFirmwareFile = (params: File, abort: AbortController) => + globalServer({ + url: 'api/upload', + method: 'POST', + data: params, + signal: abort.signal, + headers: { + 'Content-Type': 'multipart/form-data', + }, + }) + + +export const getFirmwarePath = () => globalServer({ + url: 'api/package-path', + method: 'GET', +}) \ No newline at end of file diff --git a/src/api/module/transfer/index.ts b/src/api/module/transfer/index.ts index a23cd91..3230eb6 100644 --- a/src/api/module/transfer/index.ts +++ b/src/api/module/transfer/index.ts @@ -16,10 +16,7 @@ export const getDeviceDetails = (params: IGetDeviceDataParams) => data: params, }) - - - -export interface ISiteList { +export interface ISite { id: string name: string export_time: string @@ -28,7 +25,7 @@ export interface ISiteList { } export const getSiteList = () => - globalServer({ + globalServer({ url: `/api/sites`, method: 'get', }) @@ -43,11 +40,39 @@ export interface IPointsParams { site?: string sn?: string isLocal?: boolean + type: string host?: string } + export const getPoints = (params: IPointsParams) => globalServer({ url: `/api/points`, method: 'get', params, }) + +export interface IPointGroupParams { + site?: string + sn?: string + isLocal?: boolean + host?: string +} + + +export interface IPointGroupOV { + id: number, + ip: string, + name: string, + port: number, + slave_addr: number, + type: string, + children?: IPointGroupOV[] +} + +export const getPointGroup = (params: IPointGroupParams) => { + return globalServer({ + url: `/api/modules`, + method: 'get', + params, + }) +} \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index b5c8e41..0b20144 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -31,7 +31,18 @@ export const defaultRouter = [ isShow: false, icon: 'i-mingcute:transfer-2-line', }, - } + }, + // 固件上传 + { + path: '/firmware-upload', + name: 'firmware-upload', + component: () => import('@/views/firmwareUpload/index.vue'), + meta: { + title: '固件上传', + isShow: true, + icon: 'i-mingcute:transfer-2-line', + }, + }, ], }, ] diff --git a/src/stores/transferData.ts b/src/stores/transferData.ts index 850fece..f474d71 100644 --- a/src/stores/transferData.ts +++ b/src/stores/transferData.ts @@ -1,6 +1,6 @@ import { ref, computed } from 'vue' import { defineStore } from 'pinia' -import type { IOnlineDevice } from '@/views/stationData/type' +import type { IOnlineDevice, IUpFirmwareStatus } from '@/views/stationData/type' import ZMQWorker from '@/composables/useZMQJsonWorker' import { getSubTopic, type SubMsgData } from '@/utils/zmq' import { getDeviceTopic } from '@/views/stationData/utils' @@ -79,6 +79,55 @@ export const useTransferDataStore = defineStore('transfer', () => { }) + + function upFirmwareStatus(sn: string, feedback: any[]) { + const device = devicesMap.get(sn) + if (device) { + device.upFirmware = 'updating' + const step = feedback[0] + const progress = feedback[2] || undefined + const errMsg = feedback[3] || undefined + if (step < (device.upFirmwareStatus?.step ?? -100)) return + device.upFirmwareStatus = { + step, + progress, + errMsg + } + } + } + + function upFirmwarePending(snList: string[]) { + for (const sn of snList) { + const device = devicesMap.get(sn) + if (device) { + device.upFirmware = 'pending' + device.upFirmwareStatus = { + step: 0, + progress: undefined, + errMsg: undefined, + } + } + } + } + + function upFirmwareReset(snList: string[]) { + for (const sn of snList) { + const device = devicesMap.get(sn) + if (device) { + upFirmwareSucceed(sn) + } + } + } + + function upFirmwareSucceed(sn: string) { + const device = devicesMap.get(sn) + if (device) { + device.upFirmware = undefined + device.upFirmwareStatus = undefined + } + } + + return { isConnected, devicesMap, @@ -88,5 +137,9 @@ export const useTransferDataStore = defineStore('transfer', () => { offlineCount, checkDeviceStatus, initConnectSite, + upFirmwarePending, + upFirmwareReset, + upFirmwareStatus, + upFirmwareSucceed, } }) diff --git a/src/utils/zmq.ts b/src/utils/zmq.ts index 5924178..1867a72 100644 --- a/src/utils/zmq.ts +++ b/src/utils/zmq.ts @@ -1,7 +1,7 @@ import { v4 as uuidv4 } from 'uuid'; export type ManualAction = 'init' | 'release' | 'write' | 'report' | 'lock' | 'unlock' | - 'export' | 'cancel' | 'import' + 'export' | 'cancel' | 'import' | 'upgrade' export type ZmqStatus = 'disconnected' | 'connected' diff --git a/src/views/firmwareUpload/index.vue b/src/views/firmwareUpload/index.vue new file mode 100644 index 0000000..ad07d80 --- /dev/null +++ b/src/views/firmwareUpload/index.vue @@ -0,0 +1,186 @@ + + + + + diff --git a/src/views/stationData/components/deviceDrawer.vue b/src/views/stationData/components/deviceDrawer.vue index 22b3f74..3f7ca6c 100644 --- a/src/views/stationData/components/deviceDrawer.vue +++ b/src/views/stationData/components/deviceDrawer.vue @@ -9,6 +9,13 @@ :before-close="handleBeforeClose" >
+ + + + + diff --git a/src/views/stationData/components/transferDlg.vue b/src/views/stationData/components/transferDlg.vue index bedd112..12945e1 100644 --- a/src/views/stationData/components/transferDlg.vue +++ b/src/views/stationData/components/transferDlg.vue @@ -18,7 +18,7 @@ class="flex-1" start-placeholder="开始时间" end-placeholder="结束时间" - :default-value="defaultDateRange" + :default-value="(defaultDateRange as any)" :disabled-date="disabledAfterToday" /> diff --git a/src/views/stationData/index.vue b/src/views/stationData/index.vue index 0d405da..655efd6 100644 --- a/src/views/stationData/index.vue +++ b/src/views/stationData/index.vue @@ -1,12 +1,6 @@ - +