模拟故障增加故障设备

This commit is contained in:
joylink_zhaoerwei 2023-08-28 15:22:03 +08:00
parent 041052113a
commit e35637524d
2 changed files with 61 additions and 4 deletions

View File

@ -4,10 +4,32 @@ import { AlarmInfo } from './DecisionInfo';
const alertUriBase = '/api/alert/mock';
export function mockAlertSet(data: { lineId: number; alertType: string }) {
export function mockAlertSet(data: {
lineId: number;
alertType: string;
deviceCodes: string[];
}) {
return api.post(`${alertUriBase}/set`, data);
}
/**
*
* @param id 线id
* @param alertType
*/
export async function getDeviceByAlarmType(
id: number,
alertType: string
): Promise<DeviceConfigItem[]> {
const response = await api.post(`${alertUriBase}/find/${id}/${alertType}`);
return response.data;
}
export interface DeviceConfigItem {
name: string;
code: string;
}
export class PagingQueryParams extends PageQueryDto {
alertType?: string;
lineId?: number;

View File

@ -108,6 +108,14 @@
v-model="alertType"
:options="optionsAlertType"
:rules="[(val) => val.length > 0 || '请选择故障类型!']"
@blur="searchAlertDevice"
/>
<q-select
outlined
label="指定故障设备"
multiple
v-model="alertDevice"
:options="optionsAlertDevice"
/>
<q-card-actions align="right">
<q-btn color="primary" label="创建" type="submit" />
@ -125,7 +133,11 @@ import SysMenu from 'src/components/SysMenu.vue';
import { useRouter, useRoute } from 'vue-router';
import { Dialog, useQuasar } from 'quasar';
import { clearJwtToken } from 'src/configs/TokenManage';
import { mockAlertSet } from 'src/api/AlertMock';
import {
DeviceConfigItem,
getDeviceByAlarmType,
mockAlertSet,
} from 'src/api/AlertMock';
import alarmInfoList from 'src/components/alarm/alarmInfoList.vue';
import commonAlarm from 'src/components/alarm/commonAlarm.vue';
import { useLineNetStore } from 'src/stores/line-net-store';
@ -202,12 +214,35 @@ const optionsAlertType = [
'道岔大面积失表',
'列车信号故障',
];
let optionsAlertDevice = ref<string[]>([]);
const alertDevice = ref<string[]>([]);
let alertDeviceList: DeviceConfigItem[] = [];
async function searchAlertDevice() {
try {
const type = (saveAlertTypeData as never)[alertType.value];
alertDeviceList = await getDeviceByAlarmType(3, type);
optionsAlertDevice.value = alertDeviceList.map((item) => item.name);
} catch (err) {
$q.notify({
type: 'negative',
message: '无法获取指定故障的设备列表',
});
}
}
async function alarmMockSet() {
try {
const type = (saveAlertTypeData as never)[alertType.value];
const Id = lineId.value;
await mockAlertSet({ lineId: Id, alertType: type });
let deviceCodes: string[] = [];
for (let i = 0; i < alertDevice.value.length; i++) {
const index = alertDeviceList.findIndex(
(item) => item.name == alertDevice.value[i]
);
deviceCodes.push(alertDeviceList[index].code);
}
await mockAlertSet({ lineId: Id, alertType: type, deviceCodes });
alertSetShow.value = false;
} catch (err) {
$q.notify({