|
|
|
@ -5,7 +5,7 @@ import {useI18n} from '@/hooks/web/useI18n' |
|
|
|
import {useMessage} from '@/hooks/web/useMessage' |
|
|
|
import {BasicForm, useForm} from '@/components/Form' |
|
|
|
import {BasicModal, useModalInner} from '@/components/Modal' |
|
|
|
import {getWarn, updateWarn} from '@/api/alert/warn' |
|
|
|
import {getWarn, createWarn, updateWarn} from '@/api/alert/warn' |
|
|
|
import {getSearchFormSchema} from '@/views/run/instant/instant.data' |
|
|
|
import {Divider, Descriptions, DescriptionsItem} from 'ant-design-vue' |
|
|
|
import {getInstantPoint} from "@/api/alert/run/instant"; |
|
|
|
@ -16,7 +16,7 @@ const emit = defineEmits(['success', 'register']) |
|
|
|
const {t} = useI18n() |
|
|
|
const {createMessage} = useMessage() |
|
|
|
const isUpdate = ref(true) |
|
|
|
|
|
|
|
const pointLoading = ref(true) |
|
|
|
|
|
|
|
// 新增的时候增加查询表单 |
|
|
|
const [registerQueryForm, { |
|
|
|
@ -50,13 +50,43 @@ function getPointInfo(list, inputName) { |
|
|
|
} |
|
|
|
|
|
|
|
async function handleQuery() { |
|
|
|
setProps({ |
|
|
|
submitButtonOptions: { loading: true }, |
|
|
|
}) |
|
|
|
try { |
|
|
|
//先获取表单数据 |
|
|
|
const queryValues = await validateQueryForm() |
|
|
|
pointLoading.value = true |
|
|
|
//查询各种点号信息 |
|
|
|
const res = await getInstantPoint(queryValues.mpId) |
|
|
|
//从结果中筛选inputName等于选中的inputName的项 |
|
|
|
pointInfo.value = getPointInfo(res, queryValues?.inputName) |
|
|
|
// biasPointInfo:"XN.M00010001B" |
|
|
|
// faultVariablePointInfo:"XN.M00010001F" |
|
|
|
// id:1 |
|
|
|
// inputInfo:"HN_01_1RRA010MT_AVALUE" |
|
|
|
// inputName:"HN_01_1RRA010MT_AVALUE" |
|
|
|
// outPointInfo:"XN.M00010001R" |
|
|
|
// unit:"" |
|
|
|
const {inputInfo, inputName, outPointInfo, ...rest} = pointInfo.value |
|
|
|
//字段映射,后端字段和前端字段不一致,需要映射一下 |
|
|
|
pointInfo.value = { |
|
|
|
...rest, |
|
|
|
pointId: inputInfo, |
|
|
|
pointName: inputName, |
|
|
|
outputPoint: outPointInfo, |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
setProps({ |
|
|
|
submitButtonOptions: { loading: false }, |
|
|
|
}) |
|
|
|
pointLoading.value = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
|
|
|
resetFields() |
|
|
|
setModalProps({width: 800, useWrapper: true, minHeight: 180, confirmLoading: false}) |
|
|
|
@ -74,19 +104,35 @@ const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) |
|
|
|
await handleQuery() |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
async function handleSubmit() { |
|
|
|
try { |
|
|
|
const values = await validate() |
|
|
|
// ⭐ 条件校验(重点) |
|
|
|
if (values.inputName !== pointInfo.value.pointName) { |
|
|
|
createMessage.error('请确保点号信息与查询结果一致,如果不一致请重新查询') |
|
|
|
return |
|
|
|
} |
|
|
|
setModalProps({confirmLoading: true}) |
|
|
|
if (unref(isUpdate)) { |
|
|
|
await updateWarn(values) |
|
|
|
closeModal() |
|
|
|
emit('success') |
|
|
|
createMessage.success(t('common.saveSuccessText')) |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
// 新增预警 |
|
|
|
|
|
|
|
//先拿查询表单数据 |
|
|
|
const queryValues = await validateQueryForm() |
|
|
|
// 再拿输入的数据 |
|
|
|
const values = await validate() |
|
|
|
// 合并三个数据 |
|
|
|
const mergedValues = {...queryValues, ...values, ...pointInfo.value} |
|
|
|
//构造报警表达式 |
|
|
|
mergedValues.equation = `[${mergedValues.biasPointInfo}]>UPLIMIT or [${mergedValues.biasPointInfo}]<LOWLIMIT` |
|
|
|
await createWarn(mergedValues) |
|
|
|
closeModal() |
|
|
|
emit('success') |
|
|
|
createMessage.success(t('common.saveSuccessText')) |
|
|
|
} |
|
|
|
} finally { |
|
|
|
setModalProps({confirmLoading: false}) |
|
|
|
@ -101,14 +147,16 @@ async function handleSubmit() { |
|
|
|
<BasicForm v-if="!isUpdate" @register="registerQueryForm" @submit="handleQuery"/> |
|
|
|
<Divider v-if="!isUpdate" style="margin-top:0px"/> |
|
|
|
<!--查询出来的结果--> |
|
|
|
<spin :spinning="pointLoading"> |
|
|
|
<Descriptions v-if="!isUpdate" bordered size="small" :column="2"> |
|
|
|
<DescriptionsItem label="测点名">{{ pointInfo?.inputInfo }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="测点点号">{{ pointInfo?.inputName }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="重构点名">{{ pointInfo?.inputInfo + "-重构值" }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="重构点号">{{ pointInfo?.outPointInfo }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="残差点名">{{ pointInfo?.inputInfo + "-偏差值" }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="测点名">{{ pointInfo?.pointName }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="测点点号">{{ pointInfo?.pointId }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="重构点名">{{ pointInfo?.pointName + "-重构值" }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="重构点号">{{ pointInfo?.outputPoint }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="残差点名">{{ pointInfo?.pointName + "-偏差值" }}</DescriptionsItem> |
|
|
|
<DescriptionsItem label="残差点号">{{ pointInfo?.biasPointInfo }}</DescriptionsItem> |
|
|
|
</Descriptions> |
|
|
|
</spin> |
|
|
|
<Divider v-if="!isUpdate" style="margin-top:10px"/> |
|
|
|
<BasicForm @register="registerForm"/> |
|
|
|
</BasicModal> |
|
|
|
|