Browse Source

fix:预警配置下拉框选择、点号显示

pull/119/head
xiaojinfei 3 days ago
parent
commit
16f001c3a1
  1. 6
      src/views/run/instant/instant.data.ts
  2. 12
      src/views/warn/alarm/alarm.data.ts
  3. 108
      src/views/warn/config/UpdateModal.vue
  4. 21
      src/views/warn/config/index.vue
  5. 231
      src/views/warn/config/warn.data.ts

6
src/views/run/instant/instant.data.ts

@ -407,6 +407,9 @@ const mpList = ref<any[]>([])
]
}
export const formSchema: FormSchema[] = [
{
@ -781,3 +784,6 @@ export const detailColumns: BasicColumn[] = [
width: 200,
},
]

12
src/views/warn/alarm/alarm.data.ts

@ -158,8 +158,16 @@ export const columns: BasicColumn[] = [
},
{
title: '偏差值',
dataIndex: 'biasValue',
width: 40
dataIndex: 'biasValue', // 可以写,也可以不写
width: 65,
customRender: ({ record }) => {
const real = Number(record.pointValue)
const target = Number(record.outputPointValue)
if (isNaN(real) || isNaN(target)) return '-'
return (real - target).toFixed(2)
},
},
{
title: '安全区间',

108
src/views/warn/config/UpdateModal.vue

@ -1,18 +1,20 @@
<script lang="ts" setup>
import { ref, unref,onMounted,nextTick } from 'vue'
import { updateWarnForm } 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 {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' })
defineOptions({name: 'UpdateModal'})
const emit = defineEmits(['success', 'register'])
const { t } = useI18n()
const { createMessage } = useMessage()
const {t} = useI18n()
const {createMessage} = useMessage()
const isUpdate = ref(true)
@ -24,62 +26,90 @@ 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({
const [registerForm, {setFieldsValue, resetFields, validate}] = useForm({
labelWidth: 120,
baseColProps: { span: 24 },
baseColProps: {span: 24},
schemas: updateWarnForm,
showActionButtonGroup: false,
actionColOptions: { span: 23 },
actionColOptions: {span: 23},
})
const pointInfo = ref<any>();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
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)
//inputNameinputName
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)) {
const res = await getWarn(data.record.warnId)
setFieldsValue({ ...res })
setFieldsValue({...res})
}
//
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))
await updateWarn(values)
setModalProps({confirmLoading: true})
if (unref(isUpdate)) {
await updateWarn(values)
closeModal()
emit('success')
createMessage.success(t('common.saveSuccessText'))
}
finally {
setModalProps({ confirmLoading: false })
else{
//
}
} finally {
setModalProps({confirmLoading: false})
}
}
</script>
<template>
<BasicModal v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal" @ok="handleSubmit">
<!--查询表单-->
<BasicForm @register="registerQueryForm" />
<!--查询出来的结果-->
<BasicForm @register="registerForm" />
<BasicModal v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')"
@register="registerModal" @ok="handleSubmit">
<!--查询表单-->
<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>

21
src/views/warn/config/index.vue

@ -30,9 +30,7 @@ const [registerTable, { setProps,getForm, reload, getDataSource, updateTableData
rowKey: 'warnId',
immediate: true,
columns,
formConfig: {
},
formConfig: {},
beforeFetch: (params) => ({
...params,
mpId: route.query.mpId ?? null,
@ -45,13 +43,8 @@ const [registerTable, { setProps,getForm, reload, getDataSource, updateTableData
title: t('common.action'),
dataIndex: 'action',
fixed: 'right',
},
}
})
async function updateStatus(record) {
await updateWarn(record)
createMessage.success(t('common.saveSuccessText'))
@ -62,11 +55,7 @@ function handleWarnConfig(record: Recordable) {
openUpdateModal(true, { record, isUpdate: true })
}
function handleCreate(record: Recordable) {
// openCreateModal(true, { isUpdate: false })
// isShow.value = true
openUpdateModal(true, { record, isUpdate: false })
console.log(234)
}
function handleDetail(record) {
console.log(record)
@ -75,14 +64,11 @@ function handleDetail(record) {
const warnId=ref<string>();
async function handleTrend(record: Recordable) {
console.log(record)
warnId.value=record.warnId;
openTrendModal(true, { record })
}
onMounted(async () => {
//
const searchSchema = await getSearchFormSchema(false, true,true,false,false,false) //
const searchForm = computed<FormSchema[]>(() => {
@ -114,7 +100,6 @@ onMounted(async () => {
<template>
<div>
<BasicTable @register="registerTable">
<template #form-advanceBefore>
<a-button type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
@ -127,8 +112,6 @@ onMounted(async () => {
{ icon: IconEnum.WARN, label: t('action.warnConfig'), onClick: handleWarnConfig.bind(null, record) },
{ auth:route.query.mpId,icon: IconEnum.TREND, label: t('action.trend'), onClick: handleTrend.bind(null, record) },
{ auth:route.query.mpId,icon: IconEnum.DETAIL, label: t('action.detail'), onClick: handleDetail.bind(null, record) }
]"
/>
</template>

231
src/views/warn/config/warn.data.ts

@ -1,5 +1,8 @@
import type { BasicColumn, FormSchema } from '@/components/Table'
import {getAlarmLevelList} from "@/api/alert/warn";
import {subSystemListApi} from "@/api/alert/model/select";
import {getInstantList,getInstantPoint} from "@/api/alert/run/instant";
import {ref} from "vue";
const alarmLevelList = await getAlarmLevelList();
@ -367,3 +370,231 @@ export const detailColumns: BasicColumn[] = [
width: 200,
},
]
interface SelectItem {
unitId: number
unitName: string
systemTypeId: number
systemTypeName: string
systemId: number
systemName: string
mpId: number
mpName: string
}
const selectList: SelectItem[] = await getInstantList()
//机组下拉框去重
const unitList=ref([]);
unitList.value = Array.from(
new Map(
selectList.map(item => [
item.unitId,
{
...item,
},
]),
).values(),
)
const typeList=ref([]);
typeList.value = Array.from(
new Map(
selectList
.filter(item => item.unitId === unitList.value[0].unitId)
.map(item => [
item.systemTypeId,
{
...item
},
]),
).values(),
)
const systemList=ref([]);
systemList.value = Array.from(
new Map(
selectList
.filter(item => item.systemTypeId === unitList.value[0].systemTypeId && item.unitId === unitList.value[0].unitId)
.map(item => [
item.systemId,
{
...item
},
]),
).values(),
)
const mpList=ref([]);
mpList.value = Array.from(
new Map(
selectList
.filter(item => item.systemId === unitList.value[0].systemId)
.map(item => [
item.mpId,
{
...item
},
]),
).values(),
)
console.log(unitList.value)
const pointList=ref([]);
pointList.value = await getInstantPoint(mpList.value[0].mpId)
export const InstantForm: FormSchema[] = [
{
label: '机组',
field: 'unit',
component: 'Select',
defaultValue: unitList.value?.[0]?.unitId,
colProps: { span: 8},
componentProps: ({ formModel, formActionType }) => ({
placeholder: '机组',
allowClear: false,
options: unitList.value.map(unit => ({
value: unit.unitId,
label: unit.unitName,
})),
onChange: (unit: number) => {
// ⭐ 根据 unitId 从 selectList 计算系统下拉
typeList.value = Array.from(
new Map(
selectList
.filter(item => item.unitId === unit)
.map(item => [
item.systemTypeId,
{
...item
},
]),
).values(),
)
// ✅ 默认选中第一个系统
formModel.type = typeList.value[0].systemTypeId
formActionType.setFieldsValue({
type: typeList.value[0].systemTypeId,
})
},
}),
},
{
label: '系统',
field: 'type',
component: 'Select',
defaultValue: typeList.value?.[0]?.systemTypeId,
colProps: { span: 8},
componentProps: ({ formModel, formActionType }) => ({
placeholder: '系统',
allowClear: false,
options: typeList.value.map(type => ({
value: type.systemTypeId,
label: type.systemTypeName,
})),
onChange: (type: number) => {
alert("系统改变事件")
// ⭐ 根据 unitId 和 system_type_id 从 selectList 计算系统下拉
systemList.value = Array.from(
new Map(
selectList
.filter(item => item.systemTypeId === type && item.unitId === formModel.unit)
.map(item => [
item.systemId,
{
...item
},
]),
).values(),
)
// ✅ 默认选中第一个系统
formModel.system = systemList.value[0].systemId
formActionType.setFieldsValue({
system: systemList.value[0].systemId,
})
},
}),
},
{
label: '子系统',
field: 'system',
component: 'Select',
defaultValue: systemList.value?.[0]?.systemId,
colProps: { span: 8},
componentProps: ({ formModel, formActionType }) => ({
placeholder: '子系统',
allowClear: false,
options: systemList.value.map(sys => ({
value: sys.systemId,
label: sys.systemName,
})),
onChange: (system: number) => {
alert("子系统改变事件")
console.log(111,system)
console.log(selectList)
console.log(system)
// ⭐ 根据 unitId 从 selectList 计算系统下拉
mpList.value = Array.from(
new Map(
selectList
.filter(item => item.systemId === system)
.map(item => [
item.mpId,
{
...item
},
]),
).values(),
)
console.log(mpList.value)
// ✅ 默认选中第一个系统
formModel.mpId = mpList.value[0].mpId
formActionType.setFieldsValue({
mpId: mpList.value[0].mpId,
})
},
})
},
{
label: '模型实例',
field: 'mpId',
component: 'Select',
defaultValue: mpList.value?.[0]?.mpId,
colProps: { span:10},
componentProps: () => ({
placeholder: '模型实例',
allowClear: false,
options:mpList.value.map(instant => ({
value: instant.mpId,
label: instant.mpName,
})),
onChange: async (mpId: number) => {
// alert("模型实例改变事件")
const res = await getInstantPoint(mpId)
console.log(res)
pointList.value=res;
formModel.inputName = res.data?.[0]?.inputName
formActionType.setFieldsValue({
inputName: res.data?.[0]?.inputName,
})
}
})},
{
label: '预警点号',
field: 'inputName',
component: 'Select',
defaultValue: pointList.value?.[0]?.inputName,
colProps: { span:11},
componentProps: () => ({
placeholder: '预警点号',
allowClear: false,
options:pointList.value.map(point => ({
value: point.inputName,
label: point.inputName,
})),
onChange: async (inputName: string) => {
// alert("预警点号改变事件")
}
})}
]

Loading…
Cancel
Save