|
|
|
@ -1,12 +1,14 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
import { ref, unref,onMounted,nextTick } from 'vue' |
|
|
|
import { updateWarnForm } from './warn.data' |
|
|
|
import {ref, unref, nextTick} from 'vue' |
|
|
|
import {updateWarnForm, InstantForm} from './warn.data' |
|
|
|
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 {getSearchFormSchema} from '@/views/run/instant/instant.data' |
|
|
|
import {Divider, Descriptions, DescriptionsItem} from 'ant-design-vue' |
|
|
|
import {getInstantPoint} from "@/api/alert/run/instant"; |
|
|
|
|
|
|
|
defineOptions({name: 'UpdateModal'}) |
|
|
|
|
|
|
|
@ -24,13 +26,15 @@ const [registerQueryForm, { |
|
|
|
validate: validateQueryForm, |
|
|
|
}] = useForm({ |
|
|
|
labelWidth: 80, |
|
|
|
baseColProps: { span: 12 }, |
|
|
|
schemas: [], |
|
|
|
showSubmitButton:false, |
|
|
|
showActionButtonGroup: false, |
|
|
|
actionColOptions: { span: 3 }, |
|
|
|
baseColProps: {span: 24}, |
|
|
|
schemas: InstantForm, |
|
|
|
showResetButton: false, |
|
|
|
showSubmitButton: true, |
|
|
|
showActionButtonGroup: true, |
|
|
|
actionColOptions: {span: 2, style: {textAlign: 'left', marginLeft: '10px'}}, |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const [registerForm, {setFieldsValue, resetFields, validate}] = useForm({ |
|
|
|
labelWidth: 120, |
|
|
|
baseColProps: {span: 24}, |
|
|
|
@ -38,10 +42,24 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
|
|
|
showActionButtonGroup: false, |
|
|
|
actionColOptions: {span: 23}, |
|
|
|
}) |
|
|
|
const pointInfo = ref<any>(); |
|
|
|
|
|
|
|
function getPointInfo(list, inputName) { |
|
|
|
if (!Array.isArray(list) || !inputName) return undefined |
|
|
|
return list.find(item => item.inputName === inputName) |
|
|
|
} |
|
|
|
|
|
|
|
async function handleQuery() { |
|
|
|
//先获取表单数据 |
|
|
|
const queryValues = await validateQueryForm() |
|
|
|
//查询各种点号信息 |
|
|
|
const res = await getInstantPoint(queryValues.mpId) |
|
|
|
//从结果中筛选inputName等于选中的inputName的项 |
|
|
|
pointInfo.value = getPointInfo(res, queryValues?.inputName) |
|
|
|
} |
|
|
|
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
|
|
|
resetFields() |
|
|
|
setModalProps({ useWrapper: true, minHeight: 180, confirmLoading: false }) |
|
|
|
setModalProps({width: 800, useWrapper: true, minHeight: 180, confirmLoading: false}) |
|
|
|
// 如果是修改modal,则赋值给表单 |
|
|
|
isUpdate.value = !!data?.isUpdate |
|
|
|
if (unref(isUpdate)) { |
|
|
|
@ -50,36 +68,48 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data |
|
|
|
} |
|
|
|
//如果是新增 |
|
|
|
else { |
|
|
|
const queryForm = await getSearchFormSchema(false, false, false, true,true,true) // 不显示算法 |
|
|
|
// 等 Vue 渲染完成 form 实例 |
|
|
|
await nextTick() |
|
|
|
await setProps({schemas: queryForm}) |
|
|
|
// 2. 等待下一次 DOM 更新(确保表单已渲染) |
|
|
|
await nextTick(); |
|
|
|
//查询各种点号信息 |
|
|
|
await handleQuery() |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
async function handleSubmit() { |
|
|
|
try { |
|
|
|
const values = await validate() |
|
|
|
setModalProps({confirmLoading: true}) |
|
|
|
if (unref(isUpdate)) |
|
|
|
if (unref(isUpdate)) { |
|
|
|
await updateWarn(values) |
|
|
|
|
|
|
|
closeModal() |
|
|
|
emit('success') |
|
|
|
createMessage.success(t('common.saveSuccessText')) |
|
|
|
} |
|
|
|
finally { |
|
|
|
else{ |
|
|
|
// 新增预警 |
|
|
|
|
|
|
|
} |
|
|
|
} finally { |
|
|
|
setModalProps({confirmLoading: false}) |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<BasicModal v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal" @ok="handleSubmit"> |
|
|
|
<BasicModal v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" |
|
|
|
@register="registerModal" @ok="handleSubmit"> |
|
|
|
<!--查询表单--> |
|
|
|
<BasicForm @register="registerQueryForm" /> |
|
|
|
<BasicForm v-if="!isUpdate" @register="registerQueryForm" @submit="handleQuery"/> |
|
|
|
<Divider style="margin-top:0px"/> |
|
|
|
<!--查询出来的结果--> |
|
|
|
|
|
|
|
<Descriptions 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?.biasPointInfo }}</DescriptionsItem> |
|
|
|
</Descriptions> |
|
|
|
<Divider style="margin-top:10px"/> |
|
|
|
<BasicForm @register="registerForm"/> |
|
|
|
</BasicModal> |
|
|
|
</template> |
|
|
|
|