diff --git a/src/components/line-app/infos/TrainInfo.vue b/src/components/line-app/infos/TrainInfo.vue index 6b4edfb..7d55cdb 100644 --- a/src/components/line-app/infos/TrainInfo.vue +++ b/src/components/line-app/infos/TrainInfo.vue @@ -191,7 +191,7 @@ import { Dialog } from 'quasar'; import { state } from 'src/protos/device_state'; import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue'; import { useTccStore } from 'src/stores/tcc-store'; -import { cancelTrainConn } from 'src/api/Simulation'; +import { removeTrain, cancelTrainConn } from 'src/api/Simulation'; import { errorNotify, successNotify } from 'src/utils/CommonNotify'; interface KeyType { @@ -634,6 +634,10 @@ const options = [ label: '取消连接', value: 4, }, + { + label: '清除列车', + value: 5, + }, ]; function doTrainOperation(option: { label: string; value: number }) { @@ -645,6 +649,8 @@ function doTrainOperation(option: { label: string; value: number }) { openTccDialog(); } else if (option.value == 4) { cancelTrainLink(); + } else if (option.value == 5) { + clearTrain(); } } @@ -708,6 +714,28 @@ function openTccDialog() { trainInfo.value?.trainControlMapId as number ); } + +function clearTrain() { + if (!lineStore.selectedGraphics) return; + const train = lineStore.selectedGraphics[0] as Train; + Dialog.create({ + title: '确认', + message: `确认清除【${trainInfo.value?.id}】列车吗?`, + cancel: true, + }).onOk(async () => { + removeTrain({ + simulationId: lineStore.simulationId as string, + mapId: lineStore.mapId as number, + trainId: train.code, + }) + .then(() => { + successNotify('移除列车成功!'); + }) + .catch((err) => { + errorNotify('移除列车失败!', err); + }); + }); +}