From 74ec3701460f4e77cb6039fc2ac7dd9d8ec6a8b3 Mon Sep 17 00:00:00 2001 From: xjf <378266566@qq.com> Date: Mon, 15 Dec 2025 09:12:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=9B=9E=E7=AE=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/alert/run/instant/index.ts | 17 +++++++++ src/views/run/calc/calc.data.ts | 3 ++ src/views/run/calc/index.vue | 58 ++++++++++++++++++------------ 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/src/api/alert/run/instant/index.ts b/src/api/alert/run/instant/index.ts index a4747ce..fccbb4e 100644 --- a/src/api/alert/run/instant/index.ts +++ b/src/api/alert/run/instant/index.ts @@ -54,6 +54,16 @@ export interface EXAPoint { Comment?: string Note?: string } + +export interface InstantCalcReqVO { + startTime?: Date + endTime?: Date + interval?: string + mpId?: number +} + + + // 查询模型实例列表 export function getInstantPage(params: InstantPageReqVO) { return defHttp.get({ url: '/alert/instant/page', params }) @@ -92,3 +102,10 @@ export function getInstantPoint(mpId: number) { export function getInstantChart(data: InstantChartReqVO) { return defHttp.post({ url: `/alert/instant/getChart`, data }) } + +// 回算模型实例 +export function calcInstant(data: InstantCalcReqVO) { + return defHttp.post({ url: `/alert/instant/calc`, data }) +} + + diff --git a/src/views/run/calc/calc.data.ts b/src/views/run/calc/calc.data.ts index 071a08c..ada0c78 100644 --- a/src/views/run/calc/calc.data.ts +++ b/src/views/run/calc/calc.data.ts @@ -163,7 +163,10 @@ export const calcFormSchemas: FormSchema[] = [ onChange: (e: any) => { console.log(e) }, + + allowClear: false, // ← 必须用这个 }, + required: true, colProps: { diff --git a/src/views/run/calc/index.vue b/src/views/run/calc/index.vue index f5032e0..ebeecc9 100644 --- a/src/views/run/calc/index.vue +++ b/src/views/run/calc/index.vue @@ -8,7 +8,7 @@ import { calcFormSchemas, columns, searchFormSchema } from './calc.data' import { BasicTable, TableAction, useTable } from '@/components/Table' import { BasicForm, useForm } from '@/components/Form' -import { getInstantCount, getInstantPage, updateInstant } from '@/api/alert/run/instant' +import {calcInstant, getInstantCount, getInstantPage, updateInstant} from '@/api/alert/run/instant' import { getExaNow } from '@/api/alert/exa' import { useI18n } from '@/hooks/web/useI18n' import { router } from '@/router' @@ -63,7 +63,7 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] /** * BasicForm绑定注册; */ -const [registerForm] = useForm({ +const [registerForm,{getFieldsValue,validate,validateFields}] = useForm({ // 注册表单列 schemas: calcFormSchemas, // 是否显示展开收起按钮,默认false @@ -76,7 +76,7 @@ const [registerForm] = useForm({ model: { time: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')] }, fieldMapToTime: [ // data为时间组件在表单内的字段,startTime,endTime为转化后的开始时间于结束时间 - ['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'], + ['time', ['st', 'et'], 'YYYY-MM-DD HH:mm:ss'] ], actionColOptions: { span: 5,style: { textAlign: 'left' ,marginLeft: '10px',} }, @@ -97,21 +97,30 @@ function handleExport(values: any) { console.log('导出按钮数据::::', values) } -async function handlebeforeCalc() { - console.log("触发了回算按钮") - //获取选中的实例 - console.log('选中的实例:', selectedRowss.value) - const selectedRowIds = selectedRowss.value.map(row => row.mpId) +async function handlebeforeCalc(rowMpId?: string) { + console.log('点击回算按钮数据::::', rowMpId) + let targetMpIds: string[] = [] - //check selectedRows - if (selectedRowIds.length === 0) { - createMessage.error('请选择要回算的实例') - return + // 1. 行内按钮点击:直接使用当前行的mpId + if (rowMpId) { + alert("行内回算") + targetMpIds = [rowMpId] } - // 校验表单数据 - const formData = await getForm().validateFields() + // 2. 顶部按钮点击:使用选中的实例 + else { + alert("表单回算") + + targetMpIds = selectedRowss.value.map(row => row.mpId) + if (targetMpIds.length === 0) { + createMessage.error('请选择要回算的实例') + return + } + } + + // 校验表单数据 + const formData = await validate() // 给函数传递需要回算的实例id数组 - formData.mpIds = selectedRowIds; + formData.mpIds = targetMpIds; handleCalc(formData) } // 回算 @@ -124,12 +133,13 @@ async function handlebeforeCalc() { console.log('行内回算loading状态:', mpId, rowCalcLoading[mpId]) try { // 调用后端的回算接口 - 行内回算 - // 模拟3秒接口调用延迟 - await new Promise(resolve => { - setTimeout(() => { - resolve() - }, 3000) - }) + formData.mpId=mpId + // 调用后端的回算接口 - 行内回算 + console.log(formData) + const res = await calcInstant(formData) + console.log('回算结果:', res) + // 更新实例列表 + // updateTableDataRecord(res) createMessage.success(t('common.success')) } catch (error) { createMessage.error(t('common.fail')) @@ -155,7 +165,7 @@ async function handlebeforeCalc() {