From 8b1de79f87454f661aea38fe1d72e404b3ee640b Mon Sep 17 00:00:00 2001 From: xiaojinfei <378266566@qq.com> Date: Thu, 8 Jan 2026 08:26:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=A2=84=E8=AD=A6=E9=85=8D=E7=BD=AE&?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E8=A1=A8=E5=8D=95=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/alert/run/instant/index.ts | 9 ++ src/views/run/instant/index.vue | 34 ++++--- src/views/run/instant/instant.data.ts | 134 +++++++++++++++++++++----- src/views/warn/alarm/index.vue | 38 +++++--- src/views/warn/config/UpdateModal.vue | 42 +++----- src/views/warn/config/index.vue | 51 ++++++---- 6 files changed, 203 insertions(+), 105 deletions(-) diff --git a/src/api/alert/run/instant/index.ts b/src/api/alert/run/instant/index.ts index 8eb91d7..b3d42eb 100644 --- a/src/api/alert/run/instant/index.ts +++ b/src/api/alert/run/instant/index.ts @@ -5,6 +5,10 @@ export interface InstantPageReqVO extends PageParam { mpName?: string algorithmId?: number } +export interface InstantReqVO{ + mpName?: string + algorithmId?: number +} export interface InstantVO { mpId: number @@ -68,6 +72,11 @@ export interface InstantCalcReqVO { export function getInstantPage(params: InstantPageReqVO) { return defHttp.get({ url: '/alert/instant/page', params }) } + +// 查询模型实例列表 +export function getInstantList(params: InstantReqVO) { + return defHttp.get({ url: '/alert/instant/list', params }) +} // 查询模型实例详情 export function getInstant(id: number) { return defHttp.get({ url: `/alert/instant/get?id=${id}` }) diff --git a/src/views/run/instant/index.vue b/src/views/run/instant/index.vue index 36a2f6f..97e1f43 100644 --- a/src/views/run/instant/index.vue +++ b/src/views/run/instant/index.vue @@ -44,18 +44,7 @@ const [registerTable, { setProps,getForm, reload, getDataSource, updateTableData } }, - formConfig: { - labelWidth: 70, - schemas: searchSchema, - showResetButton: false, - actionColOptions: { - span: 3, - style: { - marginLeft: '5px', - }, - }, - - }, + formConfig: {}, useSearchForm: true, showTableSetting: true, showIndexColumn: false, @@ -67,6 +56,27 @@ const [registerTable, { setProps,getForm, reload, getDataSource, updateTableData }, }) + +onMounted(async () => { + // 等待表单配置加载完成 + const searchSchema = await getSearchFormSchema(true,true,true,false,false,false) // 显示算法,不设置默认值 + setProps({ formConfig: { + labelWidth: 70, + schemas: searchSchema, + showResetButton: false, + submitButtonOptions:{ + preIcon: IconEnum.SEARCH, + }, + actionColOptions: { + span: 3, + style: { + textAlign: 'left', + marginLeft: '5px', + } + } }}) + // 加载表格数据 + reload() +}) function handleDetail(record) { console.log(record) router.push(`/run/instant/detail?mpId=${record.mpId}`) diff --git a/src/views/run/instant/instant.data.ts b/src/views/run/instant/instant.data.ts index bdc7d82..34bb5f1 100644 --- a/src/views/run/instant/instant.data.ts +++ b/src/views/run/instant/instant.data.ts @@ -6,7 +6,9 @@ import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { getModelVersionList } from '@/api/alert/run/model/index' import { optionListApi, subSystemListApi } from '@/api/alert/model/select' import type { systemSelectParams } from '@/api/alert/model/model/optionsModel' + import {setObjToUrlParams} from "@/utils"; +import {getInstantList} from "@/api/alert/run/instant"; export const columns: BasicColumn[] = [ { @@ -203,29 +205,42 @@ export const columns: BasicColumn[] = [ * 获取搜索表单 schema(vben 标准版) */ -const optionList = await optionListApi() - -// 子系统 options 用普通变量维护(不是 ref) -const systemOptions = ref([]) - -// 非“全部”时,提前加载一次 -if (optionList.units?.length && optionList.types?.length) { - const param: systemSelectParams = { - unitId: optionList.units[0].id, - typeId: optionList.types[0].id, - } - systemOptions.value = await subSystemListApi(param) - console.log(systemOptions.value) +export interface selectParams { + unitId: number | null; + typeId: number | null; + systemId: number | null; } -export function getSearchFormSchema( + +export async function getSearchFormSchema( showAlgorithm = true, showAll = true, showName=true, - isModal=false + isModal=false, + haveMpId = true, + haveWarn = true, ): Promise { -if(showAll){ - systemOptions.value=[]; -} + + const optionList = await optionListApi() +const mpList = ref([]) +// 子系统 options 用普通变量维护(不是 ref) + const systemOptions = ref([]) + if (!showAll && optionList.units?.length && optionList.types?.length) { + const param: systemSelectParams = { + unitId: optionList.units[0].id, + typeId: optionList.types[0].id, + } + systemOptions.value = await subSystemListApi(param); + + //拿到该机组、该系统、该子系统的模型实例 + const param1: selectParams = { + unit: optionList.units[0].id, + type: optionList.types[0].id, + system: systemOptions.value[1].id, + } + mpList.value = await getInstantList(param1) + + } + console.log(systemOptions.value) return [ { label: '机组', @@ -233,7 +248,7 @@ if(showAll){ component: 'Select', defaultValue: showAll ? null : optionList.units?.[0]?.id, colProps: { span: isModal?8:4 }, - componentProps: ({ formModel }) => ({ + componentProps: ({ formModel, formActionType }) => ({ placeholder: '全部机组', options: optionList.units?.map(unit => ({ value: unit.id, @@ -248,6 +263,25 @@ if(showAll){ unitId, typeId: formModel.type, }) + // ✅ 给子系统赋默认值(第一个) + if (systemOptions.value.length) { + formActionType.setFieldsValue({system: systemOptions.value[1].id}) + } + else{ + formActionType.setFieldsValue({system: null}) + } + // //拿到该机组、该系统、该子系统的模型实例 + // mpList.value = await getInstantList({ + // unit: unitId, + // type: formModel.type, + // system: formModel.system, + // }) + // if (mpList.value.length) { + // formActionType.setFieldsValue({mpId: mpList.value[0].mpId}) + // } + // else{ + // formActionType.setFieldsValue({mpId: null}) + // } }, }), }, @@ -258,7 +292,7 @@ if(showAll){ component: 'Select', defaultValue: showAll ? null : optionList.types?.[0]?.id, colProps: { span: isModal?8:4 }, - componentProps: ({ formModel }) => ({ + componentProps: ({ formModel, formActionType }) => ({ placeholder: '全部系统', options: optionList.types?.map(type => ({ value: type.id, @@ -273,6 +307,24 @@ if(showAll){ unitId: formModel.unit, typeId, }) + if (!showAll&&systemOptions.value.length) { + formActionType.setFieldsValue({system: systemOptions.value[1].id}) + } + else{ + formActionType.setFieldsValue({system: null}) + } + // //拿到该机组、该系统、该子系统的模型实例 + // mpList.value = await getInstantList({ + // unit: formModel.unit, + // type: typeId, + // system: formModel.system, + // }) + // if (mpList.value.length) { + // formActionType.setFieldsValue({mpId: mpList.value[0].mpId}) + // } + // else{ + // formActionType.setFieldsValue({mpId: null}) + // } }, }), }, @@ -281,15 +333,33 @@ if(showAll){ label: '子系统', field: 'system', component: 'Select', - defaultValue: null, // ⚠️ 子系统永远不要给默认值 + defaultValue: showAll? null:systemOptions.value[1].id, // ⚠️ 子系统永远不要给默认值 colProps: { span: isModal?8:4 }, - componentProps: () => ({ + componentProps: ({ formModel, formActionType }) => ({ placeholder: '全部子系统', - options: systemOptions.value.map(system => ({ + options: systemOptions.value?.map(system => ({ value: system.id, label: system.name, - })), - })}, + })) || [], + onChange: async (system: number) => { + + if (!system || !formModel.unit) { + mpList.value = [] + return + } + mpList.value = await getInstantList({ + unit: formModel.unit, + type: formModel.type, + system: system, + }) + if (mpList.value.length) { + formModel.mpId=mpList.value[0].mpId + } else { + formModel.mpId=null + } + }, + }) + }, { label: '模型实例名称', field: 'mpName', @@ -316,6 +386,20 @@ if(showAll){ }, }, + { + label: '模型实例', + field: 'mpId', + component: 'Select', + defaultValue: mpList.value.length!=0?mpList.value[0].mpId:null, + colProps: { span: isModal?8:4 }, + show:haveMpId, + componentProps: () => ({ + placeholder: '全部实例', + options: mpList.value.map(instant => ({ + value: instant.mpId, + label: instant.mpName, + })), + })}, // 隐藏字段(用于后端透传) { label: '状态1', field: 'running', component: 'Input', show: false }, { label: '状态2', field: 'runningLog', component: 'Input', show: false }, diff --git a/src/views/warn/alarm/index.vue b/src/views/warn/alarm/index.vue index 34680df..8bde666 100644 --- a/src/views/warn/alarm/index.vue +++ b/src/views/warn/alarm/index.vue @@ -26,7 +26,6 @@ const { t } = useI18n() const [registerUpdateModal, { openModal: openUpdateModal }] = useModal() const [registerTrendModal, { openModal: openTrendModal }] = useModal() -const searchSchema = ref(getSearchFormSchema(false,true)) // 不显示算法 const [registerTable, { setProps,getForm,reload, getDataSource,setTableData,updateTableDataRecord }] = useTable({ title: '集中告警列表', api: getWarnPageReal, @@ -35,21 +34,7 @@ const [registerTable, { setProps,getForm,reload, getDataSource,setTableData,upda columns, //这个要写,不然不生效 useSearchForm: true, - formConfig: { - labelWidth: 80, - schemas: searchSchema, - showResetButton: false, - submitButtonOptions:{ - preIcon: IconEnum.SEARCH, - }, - actionColOptions: { - span: 2, - style: { - textAlign: 'left', - marginLeft: '10px', - }, - }, - }, + formConfig: {}, showTableSetting: true, showIndexColumn: false, actionColumn: { @@ -59,6 +44,27 @@ const [registerTable, { setProps,getForm,reload, getDataSource,setTableData,upda fixed: 'right', } }) + +onMounted(async () => { + // 等待表单配置加载完成 + const searchSchema = await getSearchFormSchema(false, true,true,false,false,false) // 显示算法,不设置默认值 +setProps({ formConfig: { + labelWidth: 80, + schemas: searchSchema, + showResetButton: false, + submitButtonOptions:{ + preIcon: IconEnum.SEARCH, + }, + actionColOptions: { + span: 3, + style: { + textAlign: 'left', + marginLeft: '10px', + } + } }}) + // 加载表格数据 + reload() +}) function handleUpdate(record: Recordable) { openUpdateModal(true, { record, isUpdate: true }) } diff --git a/src/views/warn/config/UpdateModal.vue b/src/views/warn/config/UpdateModal.vue index 50f064d..1656755 100644 --- a/src/views/warn/config/UpdateModal.vue +++ b/src/views/warn/config/UpdateModal.vue @@ -1,5 +1,5 @@