Browse Source

fix:回算功能

pull/83/head
xjf 4 weeks ago
parent
commit
74ec370146
  1. 17
      src/api/alert/run/instant/index.ts
  2. 3
      src/views/run/calc/calc.data.ts
  3. 58
      src/views/run/calc/index.vue

17
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 })
}

3
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: {

58
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: [
// datastartTimeendTime
['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() {
<BasicForm @register="registerForm">
<template #advanceBefore>
<Space>
<a-button type="primary" :loading="calcLoading" :pre-icon="IconEnum.BACK_CALC" @click="handlebeforeCalc">
<a-button type="primary" :loading="calcLoading" :pre-icon="IconEnum.BACK_CALC" @click="handlebeforeCalc()">
{{ t('action.backCalc') }}
</a-button>
<a-button type="primary" :pre-icon="IconEnum.EXPORT" @click="handleExport">
@ -174,9 +184,11 @@ async function handlebeforeCalc() {
<!-- />-->
<TableAction
:actions="[
{ icon: IconEnum.BACK_CALC,label: rowCalcLoading[record.mpId] ? t('action.calcIng') : t('action.backCalc'), onClick: handlebeforeCalc,
{ icon: IconEnum.BACK_CALC,label: rowCalcLoading[record.mpId] ? t('action.calcIng') : t('action.backCalc'),
onClick: () => handlebeforeCalc(record.mpId),
disabled: rowCalcLoading[record.mpId]},
]"
@click.stop
/>
</template>
</template>

Loading…
Cancel
Save