|
|
|
@ -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() { |
|
|
|
<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> |
|
|
|
|