diff --git a/frontend/src/api/device/interface/devType.ts b/frontend/src/api/device/interface/devType.ts index ed5584e..a250bd9 100644 --- a/frontend/src/api/device/interface/devType.ts +++ b/frontend/src/api/device/interface/devType.ts @@ -19,6 +19,7 @@ export namespace DevType { id: string; //设备类型ID name: string;//设备类型名称 icd: string| null;//设备关联的ICD + pqdif: string| null;//设备关联的PQDIF power: string| null;//工作电源 devVolt: number; //额定电压(V) devCurr: number; //额定电流(A) @@ -38,4 +39,4 @@ export namespace DevType { export interface ResPqDevTypePage extends ResPage { } -} \ No newline at end of file +} diff --git a/frontend/src/api/device/interface/pqdif.ts b/frontend/src/api/device/interface/pqdif.ts new file mode 100644 index 0000000..7bf2aa2 --- /dev/null +++ b/frontend/src/api/device/interface/pqdif.ts @@ -0,0 +1,26 @@ +import type { ReqPage, ResPage } from '@/api/interface' + +export namespace PQDIF { + export interface ReqPQDIFParams extends ReqPage { + name?: string + result?: number + } + + export interface ResPQDIF { + id: string + name: string + filePath?: string | null + recordCount?: number | null + observationCount?: number | null + sampleValueCount?: number | null + result?: number | null + msg?: string | null + state: number + createBy?: string | null + createTime?: string | null + updateBy?: string | null + updateTime?: string | null + } + + export interface ResPQDIFPage extends ResPage {} +} diff --git a/frontend/src/api/device/pqdif/index.ts b/frontend/src/api/device/pqdif/index.ts new file mode 100644 index 0000000..21f4f56 --- /dev/null +++ b/frontend/src/api/device/pqdif/index.ts @@ -0,0 +1,14 @@ +import type { PQDIF } from '@/api/device/interface/pqdif' +import http from '@/api' + +export const getPQDIFList = (params: PQDIF.ReqPQDIFParams) => { + return http.post('/pqdif/list', params) +} + +export const getPQDIFAllList = () => { + return http.get('/pqdif/listAll') +} + +export const importPQDIFJson = (params: FormData) => { + return http.upload('/pqdif/import/json', params, { loading: false }) +} diff --git a/frontend/src/components/JsonImportDialog/index.vue b/frontend/src/components/JsonImportDialog/index.vue new file mode 100644 index 0000000..06d39ea --- /dev/null +++ b/frontend/src/components/JsonImportDialog/index.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/frontend/src/utils/webSocketClient.ts b/frontend/src/utils/webSocketClient.ts index 887ddfa..3718e50 100644 --- a/frontend/src/utils/webSocketClient.ts +++ b/frontend/src/utils/webSocketClient.ts @@ -192,7 +192,7 @@ export default class SocketService { * WebSocket连接配置 */ private config: SocketConfig = { - url: `ws://127.0.0.1:7778/hello`, + url: `ws://127.0.0.1:7777/hello`, heartbeatInterval: 9000, // 9秒心跳间隔 reconnectDelay: 5000, // 5秒重连延迟 maxReconnectAttempts: 5, // 最多重连5次 diff --git a/frontend/src/views/machine/devType/components/devTypePopup.vue b/frontend/src/views/machine/devType/components/devTypePopup.vue index 64350dc..5f1364c 100644 --- a/frontend/src/views/machine/devType/components/devTypePopup.vue +++ b/frontend/src/views/machine/devType/components/devTypePopup.vue @@ -65,6 +65,16 @@ :value="item.id" /> + + + + + @@ -89,6 +99,7 @@ import { ref,computed, Ref } from 'vue' import { type DevType } from '@/api/device/interface/devType' import { type ICD } from '@/api/device/interface/icd' + import { type PQDIF } from '@/api/device/interface/pqdif' import {dialogMiddle} from '@/utils/elementBind' import { useDictStore } from '@/stores/modules/dict' import {addDevType,updateDevType} from '@/api/device/devType' @@ -100,6 +111,7 @@ const dialogFormRef = ref() const scene = ref('') const icdOptions = ref([]) + const pqdifOptions = ref([]) function useMetaInfo() { const dialogVisible = ref(false) const titleType = ref('add') @@ -107,6 +119,7 @@ id: '', //设备类型ID name: '',//设备类型名称 icd: '',//设备关联的ICD + pqdif: '',//设备关联的PQDIF power: 'AC/DC 110V-220V',//工作电源 devVolt: 57.74, //额定电压(V) devCurr: 5, //额定电流(A) @@ -127,6 +140,7 @@ const resetFormContent = () => { id: '', //设备类型ID name: '',//设备类型名称 icd: '',//设备关联的ICD + pqdif: '',//设备关联的PQDIF power: 'AC/DC 110V-220V',//工作电源 devVolt: 57.74, //额定电压(V) devCurr: 5, //额定电流(A) @@ -174,6 +188,9 @@ const resetFormContent = () => { ], icd: [ { required: true, message: '设备关联ICD必选!', trigger: 'change' } + ], + pqdif: [ + { required: true, message: '设备关联PQDIF必选!', trigger: 'change' } ] }; @@ -209,13 +226,14 @@ const close = () => { } // 打开弹窗,可能是新增,也可能是编辑 - const open = async (sign: string, data: DevType.ResPqDevType,icd: ICD.StandardOption[],currentScene: string) => { + const open = async (sign: string, data: DevType.ResPqDevType,icd: ICD.StandardOption[],pqdif: PQDIF.ResPQDIF[],currentScene: string) => { // 重置表单 dialogFormRef.value?.resetFields() titleType.value = sign dialogVisible.value = true scene.value = currentScene icdOptions.value = icd + pqdifOptions.value = pqdif if (data.id) { formContent.value = { ...data } diff --git a/frontend/src/views/machine/devType/index.vue b/frontend/src/views/machine/devType/index.vue index a55cbe9..12261bf 100644 --- a/frontend/src/views/machine/devType/index.vue +++ b/frontend/src/views/machine/devType/index.vue @@ -45,6 +45,8 @@ import { onBeforeMount, reactive, ref } from 'vue' import { useModeStore, useAppSceneStore } from '@/stores/modules/mode' import { getICDAllList } from '@/api/device/icd' import type { ICD } from '@/api/device/interface/icd' +import { getPQDIFAllList } from '@/api/device/pqdif' +import type { PQDIF } from '@/api/device/interface/pqdif' // defineOptions({ // name: 'devType', @@ -56,6 +58,7 @@ import type { ICD } from '@/api/device/interface/icd' const proTable = ref() const devTypePopup = ref() const icdOptions = ref([]) + const pqdifOptions = ref([]) const getTableList = async (params: any) => { let newParams = JSON.parse(JSON.stringify(params)) @@ -111,6 +114,15 @@ import type { ICD } from '@/api/device/interface/icd' return {name?.name} }, }, + { + prop: 'pqdif', + label: '设备关联PQDIF', + minWidth: 200, + render: (scope) => { + const name = pqdifOptions.value.find(option => option.id === scope.row.pqdif) + return {name?.name || '--'} + }, + }, { prop: 'createTime', label: '创建时间', @@ -136,7 +148,7 @@ import type { ICD } from '@/api/device/interface/icd' // 打开 drawer(新增、编辑) const openDialog = (titleType: string, row: Partial = {}) => { - devTypePopup.value?.open(titleType, row,icdOptions.value,appSceneStore.currentScene) + devTypePopup.value?.open(titleType, row,icdOptions.value,pqdifOptions.value,appSceneStore.currentScene) } @@ -156,11 +168,12 @@ import type { ICD } from '@/api/device/interface/icd' onBeforeMount(async () => { - const response = await getICDAllList() + const [response, pqdifResponse] = await Promise.all([getICDAllList(), getPQDIFAllList()]) icdOptions.value = (response.data as ICD.ResICD[]).map(item => ({ id: item.id, name: item.name })) + pqdifOptions.value = pqdifResponse.data as PQDIF.ResPQDIF[] }) diff --git a/frontend/src/views/machine/icd/index.vue b/frontend/src/views/machine/icd/index.vue index 51b3a2c..b2134f7 100644 --- a/frontend/src/views/machine/icd/index.vue +++ b/frontend/src/views/machine/icd/index.vue @@ -33,50 +33,20 @@ - -
- - 选择文件 - - -
导入中,请稍候...
-
- -
+ :request-api="importICDJson" + @success="handleImportSuccess" + /> - - diff --git a/frontend/src/views/machine/pqdif/index.vue b/frontend/src/views/machine/pqdif/index.vue new file mode 100644 index 0000000..f95c956 --- /dev/null +++ b/frontend/src/views/machine/pqdif/index.vue @@ -0,0 +1,142 @@ + + + diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts new file mode 100644 index 0000000..c70d4b7 --- /dev/null +++ b/frontend/vitest.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from "vitest/config"; +import path from "path"; + +export default defineConfig({ + test: { + environment: "jsdom", + include: ["frontend/src/**/*.spec.ts"] + }, + resolve: { + alias: { + "@": path.resolve(__dirname, "src") + } + } +});