信号机故障操作
This commit is contained in:
parent
e08dfdefc1
commit
b82039db7e
@ -60,6 +60,7 @@ export async function setSignalState(data: {
|
||||
simulationId: string;
|
||||
mapId: number;
|
||||
id: string;
|
||||
operation: number;
|
||||
aspect: number;
|
||||
}) {
|
||||
return await api.post(`${UriBase}/signal/operation`, data);
|
||||
|
@ -1,7 +1,22 @@
|
||||
<template>
|
||||
<q-card flat bordered>
|
||||
<q-card-section>
|
||||
<q-card-section class="flex justify-between">
|
||||
<div class="text-h6">信号机状态</div>
|
||||
<q-btn-dropdown color="primary" label="操作">
|
||||
<q-list>
|
||||
<q-item
|
||||
v-for="(item, index) in options"
|
||||
:key="index"
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="doSignalOperation(item)"
|
||||
>
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.label }}</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
</q-card-section>
|
||||
<q-separator inset />
|
||||
<q-form>
|
||||
@ -37,15 +52,99 @@
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { Signal } from 'src/graphics/signal/Signal';
|
||||
import { request } from 'src/protos/request';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import { setSignalState } from 'src/api/Simulation';
|
||||
import { errorNotify } from 'src/utils/CommonNotify';
|
||||
|
||||
const lineStore = useLineStore();
|
||||
const signalState = ref({ id: '', index: 0, code: '' });
|
||||
|
||||
const options = [
|
||||
{
|
||||
label: '开红灯',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.Display,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '开绿灯',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.L,
|
||||
operation: request.Signal.Operation.Display,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '开黄灯',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.U,
|
||||
operation: request.Signal.Operation.Display,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '开引导',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.HU,
|
||||
operation: request.Signal.Operation.Display,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '关灯',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.OFF,
|
||||
operation: request.Signal.Operation.Display,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '设置红灯断丝故障',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.LightHFaultDs,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '设置绿灯断丝故障',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.LightLFaultDs,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '设置黄灯断丝故障',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.LightUFaultDs,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '取消红灯断丝故障',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.LightHCancelDs,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '取消绿灯断丝故障',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.LightLCancelDs,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '取消黄灯断丝故障',
|
||||
value: {
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.LightUCancelDs,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
watch(
|
||||
() => lineStore.selectedGraphics,
|
||||
(val) => {
|
||||
if (val?.length == 1 && val[0].type == Signal.Type) {
|
||||
setSignalState(val[0] as Signal);
|
||||
initSignalState(val[0] as Signal);
|
||||
} else {
|
||||
signalState.value = {
|
||||
id: '',
|
||||
@ -55,7 +154,7 @@ watch(
|
||||
}
|
||||
}
|
||||
);
|
||||
function setSignalState(signal: Signal) {
|
||||
function initSignalState(signal: Signal) {
|
||||
signalState.value = {
|
||||
id: signal.datas.id,
|
||||
index: signal.datas.index,
|
||||
@ -68,13 +167,29 @@ function submitState() {
|
||||
}
|
||||
function onReset() {
|
||||
if (lineStore.selectedGraphics) {
|
||||
setSignalState(lineStore.selectedGraphics[0] as Signal);
|
||||
initSignalState(lineStore.selectedGraphics[0] as Signal);
|
||||
}
|
||||
}
|
||||
function doSignalOperation(item: {
|
||||
label: string;
|
||||
value: { aspect: state.Signal.Aspect; operation: request.Signal.Operation };
|
||||
}) {
|
||||
const simulationId = useLineStore().simulationId || '';
|
||||
const mapId = useLineStore().mapId as number;
|
||||
setSignalState({
|
||||
simulationId,
|
||||
mapId,
|
||||
id: signalState.value.id,
|
||||
aspect: item.value.aspect,
|
||||
operation: item.value.operation,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (lineStore.selectedGraphics) {
|
||||
setSignalState(lineStore.selectedGraphics[0] as Signal);
|
||||
initSignalState(lineStore.selectedGraphics[0] as Signal);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -20,6 +20,7 @@ import { useLineStore } from 'src/stores/line-store';
|
||||
import { SignalGraphicHitArea } from 'src/graphics/signal/SignalDrawAssistant';
|
||||
import { setSignalState } from 'src/api/Simulation';
|
||||
import { errorNotify } from 'src/utils/CommonNotify';
|
||||
import { request } from 'src/protos/request';
|
||||
|
||||
export class SignalData extends GraphicDataBase implements ISignalData {
|
||||
constructor(data?: graphicData.Signal) {
|
||||
@ -237,6 +238,7 @@ export class SignalOperateInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
mapId,
|
||||
id: signal.datas.id,
|
||||
aspect: state.Signal.Aspect.OFF,
|
||||
operation: request.Signal.Operation.Display,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
@ -247,6 +249,7 @@ export class SignalOperateInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
mapId,
|
||||
id: signal.datas.id,
|
||||
aspect: state.Signal.Aspect.H,
|
||||
operation: request.Signal.Operation.Display,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
@ -257,6 +260,7 @@ export class SignalOperateInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
mapId,
|
||||
id: signal.datas.id,
|
||||
aspect: state.Signal.Aspect.L,
|
||||
operation: request.Signal.Operation.Display,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
@ -267,6 +271,7 @@ export class SignalOperateInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
mapId,
|
||||
id: signal.datas.id,
|
||||
aspect: state.Signal.Aspect.U,
|
||||
operation: request.Signal.Operation.Display,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
@ -277,6 +282,7 @@ export class SignalOperateInteraction extends GraphicInteractionPlugin<Signal> {
|
||||
mapId,
|
||||
id: signal.datas.id,
|
||||
aspect: state.Signal.Aspect.HU,
|
||||
operation: request.Signal.Operation.Display,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user