增加故障测试

This commit is contained in:
joylink_zhaoerwei 2023-09-21 14:09:40 +08:00
parent 5c081c99a8
commit 060b909a9f
5 changed files with 280 additions and 18 deletions

View File

@ -4,6 +4,21 @@ import { AlarmInfo } from './DecisionInfo';
const alertUriBase = '/api/alert/mock';
//故障测试
export function mockLocalDemoTestSet(
alertType: string,
data: {
lineId: number;
rtuId: number;
deviceInfos: { deviceName: string; deviceType: string }[];
status: string;
groupId?: string;
}
) {
return api.post(`${alertUriBase}/localDemoTest/${alertType}`, data);
}
//故障演练
export function mockAlertSet(data: {
lineId: number;
alertType: string;

View File

@ -0,0 +1,247 @@
<template>
<draggable-dialog
v-if="showsetAlartText"
seamless
title="设置故障测试"
:width="300"
:height="0"
>
<template v-slot:footer>
<div>
<q-card class="q-gutter-sm q-px-sm q-mt-sm">
<q-form ref="myForm" @submit="onSubmit" @reset="onReset">
<q-input
outlined
label="线路ID"
v-model.number="setAlartTextData.lineId"
type="number"
lazy-rules
:rules="[(val) => val || '请输入线路ID']"
/>
<q-input
outlined
label="集中站ID"
v-model.number="setAlartTextData.rtuId"
type="number"
lazy-rules
:rules="[(val) => val || '请输入集中站ID']"
/>
<q-select
outlined
label="故障类型"
v-model="setAlartTextData.alertType"
:options="optionsAlertType"
:rules="[(val) => val.length > 0 || '请选择故障类型!']"
/>
<q-input
v-if="setAlartTextData.alertType == '列车信号故障'"
outlined
label="车组号"
v-model.number="setAlartTextData.groupId"
type="number"
lazy-rules
:rules="[(val) => val || '请输入车组号!']"
/>
<q-select
outlined
label="故障测试状态"
v-model="setAlartTextData.status"
:options="optionsStatus"
:rules="[(val) => val.length > 0 || '请选择故障类型!']"
map-options
emit-value
/>
<q-list bordered separator class="rounded-borders">
<q-item>
<q-item-section no-wrap class="q-gutter-y-sm column">
<q-item-label> 框选的设备 </q-item-label>
<div class="q-gutter-sm row">
<q-chip
v-for="item in setAlartTextData.deviceInfos"
:key="item"
square
color="primary"
text-color="white"
removable
@remove="removeSelect(item)"
>
{{ item.deviceName }}
</q-chip>
</div>
<q-btn
v-show="setAlartTextData.deviceInfos.length > 0"
style="width: 120px"
label="清空框选的设备"
color="red"
@click="clearSelect"
/>
</q-item-section>
</q-item>
</q-list>
<div class="q-gutter-sm q-pa-md row justify-center">
<q-btn
label="提交"
type="submit"
color="primary"
class="q-mr-md"
/>
<q-btn label="重置" type="reset" color="primary" />
</div>
</q-form>
</q-card>
</div>
</template>
</draggable-dialog>
</template>
<script setup lang="ts">
import DraggableDialog from '../common/DraggableDialog.vue';
import { ref, watch } from 'vue';
import { JlGraphic } from 'src/jl-graphic';
import { Station } from 'src/graphics/station/Station';
import { useLineStore } from 'src/stores/line-store';
import { QForm, useQuasar } from 'quasar';
import { ApiError } from 'src/boot/axios';
import { mockLocalDemoTestSet } from 'src/api/AlertMock';
import { saveAlertTypeData } from './alarmInfoEnum';
const lineStore = useLineStore();
const setAlartTextData = ref<{
lineId: string;
rtuId: string;
alertType: string;
deviceInfos: { deviceName: string; deviceType: string }[];
status: string;
groupId: string;
}>({
lineId: '',
rtuId: '',
alertType: '',
deviceInfos: [],
status: '',
groupId: '',
});
const optionsAlertType = [
'蓝显',
'道岔失表',
'计轴红光带',
'计轴橙光带',
'列车信号故障',
];
const mapAlertType = new Map([
['蓝显', ['station']],
['道岔失表', ['Turnout']],
['计轴红光带', ['LogicSection', 'Turnout']],
['计轴橙光带', ['LogicSection', 'Turnout']],
['列车信号故障', ['LogicSection', 'Turnout']],
]);
enum DeviceType {
station = 'DEVICE_TYPE_RTU',
Turnout = 'DEVICE_TYPE_SWITCH',
LogicSection = 'DEVICE_TYPE_TRACK',
}
const optionsStatus = [
{ label: '正常', value: 'NORMAL' },
{ label: '设置', value: 'BEGIN' },
{ label: '报警', value: 'ALERT' },
];
let selectGraphic: JlGraphic[] = [];
watch(
() => lineStore.selectedGraphics,
(val) => {
if (val && val.length > 0) {
const deviceFilter = lineStore.selectedGraphics?.filter((g) => {
let select = false;
if (
g.type == Station.Type &&
(g as Station).datas.concentrationStations &&
setAlartTextData.value.alertType == '蓝显'
) {
select = true;
}
if (
g.type !== Station.Type &&
mapAlertType.get(setAlartTextData.value.alertType)?.includes(g.type)
) {
select = true;
}
return select;
}) as JlGraphic[];
selectGraphic.push(...deviceFilter);
selectGraphic = Array.from(new Set(selectGraphic));
lineStore.getLineApp().updateSelected(...selectGraphic);
setAlartTextData.value.deviceInfos = [];
selectGraphic.forEach((g) => {
setAlartTextData.value.deviceInfos.push({
deviceName: g.code,
deviceType: (DeviceType as never)[g.type + ''],
});
});
}
}
);
const myForm = ref<QForm | null>(null);
const showsetAlartText = ref(true);
const $q = useQuasar();
async function onSubmit() {
myForm.value?.validate().then(async (res) => {
if (res) {
try {
const params = {
lineId: +setAlartTextData.value.lineId,
rtuId: +setAlartTextData.value.rtuId,
deviceInfos: setAlartTextData.value.deviceInfos,
status: setAlartTextData.value.status,
groupId: setAlartTextData.value.groupId,
};
const alertType = (saveAlertTypeData as never)[
setAlartTextData.value.alertType + ''
];
await mockLocalDemoTestSet(alertType, params);
$q.notify({
type: 'positive',
message: '设置故障测试成功',
});
onReset();
} catch (err) {
const apiErr = err as ApiError;
$q.notify({
type: 'negative',
message: apiErr.title,
});
} finally {
showsetAlartText.value = false;
}
}
});
}
function removeSelect(code: { deviceName: string; deviceType: string }) {
const removeIndex = setAlartTextData.value.deviceInfos.findIndex(
(item) => item == code
);
selectGraphic.splice(removeIndex, 1);
setAlartTextData.value.deviceInfos.splice(removeIndex, 1);
lineStore.getLineApp().updateSelected(...selectGraphic);
}
function clearSelect() {
setAlartTextData.value.deviceInfos = [];
selectGraphic = [];
lineStore.getLineApp().updateSelected();
}
function onReset() {
setAlartTextData.value = {
lineId: '',
rtuId: '',
alertType: '',
deviceInfos: [],
status: '',
groupId: '',
};
}
</script>

View File

@ -19,10 +19,17 @@
<q-btn
v-show="route.path.includes('monitor')"
color="info"
label="故障设置"
label="故障演练"
class="q-mr-sm"
@click="alertSetShow = true"
/>
<q-btn
v-show="route.path.includes('monitor')"
color="info"
label="故障测试"
class="q-mr-sm"
@click="openSetAlarmTextDialog"
/>
<div class="q-gutter-sm row items-center no-wrap">
<q-btn
@ -84,7 +91,7 @@
>
<q-card style="width: 300px" class="q-pa-md">
<q-form ref="myForm" @submit="alarmMockSet" class="q-gutter-md">
<div class="text-h6">设置模拟故障</div>
<div class="text-h6">设置故障演练</div>
<q-input
outlined
label="线路ID"
@ -130,6 +137,7 @@ import {
mockAlertSet,
} from 'src/api/AlertMock';
import commonAlarm from 'src/components/alarm/commonAlarm.vue';
import setAlarmText from 'src/components/alarm/setAlarmText.vue';
import { saveAlertTypeData } from 'src/components/alarm/alarmInfoEnum';
import NCC from '/logo/NCC_白.png';
@ -233,4 +241,10 @@ async function alarmMockSet() {
});
}
}
function openSetAlarmTextDialog() {
$q.dialog({
component: setAlarmText,
});
}
</script>

View File

@ -1,12 +1,6 @@
import { defineStore } from 'pinia';
import { destroyDrawApp, getDrawApp, initDrawApp } from 'src/drawApp';
import {
DrawAssistant,
IJlCanvas,
IDrawApp,
JlGraphic,
GraphicData,
} from 'src/jl-graphic';
import { DrawAssistant, IJlCanvas, IDrawApp, JlGraphic } from 'src/jl-graphic';
import { markRaw } from 'vue';
export const useDrawStore = defineStore('draw', {
@ -78,14 +72,6 @@ export const useDrawStore = defineStore('draw', {
this.selectedGraphics = [];
return app;
},
bindFormData(form: GraphicData): void {
const app = this.getDrawApp();
app.bindFormData(form);
},
unbindFormData(form: GraphicData): void {
const app = this.getDrawApp();
app.unbindFormData(form);
},
destroy() {
// console.log('绘制状态清空,绘制应用销毁');
this.drawAssistant = null;

View File

@ -57,7 +57,7 @@ export const useLineNetStore = defineStore('lineNet', {
},
initLineNetApp() {
const app = initLineNetApp();
app.on('graphicselectedchange', () => {
app.on('graphicselected', () => {
this.selectedGraphics = app.selectedGraphics;
});
this.selectedGraphics = [];