模拟故障增加故障设备
This commit is contained in:
parent
041052113a
commit
e35637524d
@ -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;
|
||||
@ -48,7 +70,7 @@ export function recordConfirmAlarmInfoByTipType(
|
||||
alertLocationId?: number
|
||||
): Promise<AlarmInfo<Item>> {
|
||||
return api.get(`/api/alertRecord/confirm/${id}/${tipType}`, {
|
||||
params: {alertLocationId:alertLocationId},
|
||||
params: { alertLocationId: alertLocationId },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user