Compare commits

...

2 Commits

Author SHA1 Message Date
joylink_fanyuhong
34af6397ae Merge branch 'develop' of http://120.46.212.6:3000/joylink/rts-sim-testing-client into develop 2024-10-08 15:33:45 +08:00
joylink_fanyuhong
5aaec3388f 列车右键和面板操作同步 2024-10-08 15:33:44 +08:00
2 changed files with 46 additions and 2 deletions

View File

@ -191,7 +191,7 @@ import { Dialog } from 'quasar';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue'; import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue';
import { useTccStore } from 'src/stores/tcc-store'; 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'; import { errorNotify, successNotify } from 'src/utils/CommonNotify';
interface KeyType { interface KeyType {
@ -634,6 +634,10 @@ const options = [
label: '取消连接', label: '取消连接',
value: 4, value: 4,
}, },
{
label: '清除列车',
value: 5,
},
]; ];
function doTrainOperation(option: { label: string; value: number }) { function doTrainOperation(option: { label: string; value: number }) {
@ -645,6 +649,8 @@ function doTrainOperation(option: { label: string; value: number }) {
openTccDialog(); openTccDialog();
} else if (option.value == 4) { } else if (option.value == 4) {
cancelTrainLink(); cancelTrainLink();
} else if (option.value == 5) {
clearTrain();
} }
} }
@ -708,6 +714,28 @@ function openTccDialog() {
trainInfo.value?.trainControlMapId as number 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);
});
});
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.q-item { .q-item {

View File

@ -16,6 +16,7 @@ import { successNotify, errorNotify } from '../../utils/CommonNotify';
import { Dialog } from 'quasar'; import { Dialog } from 'quasar';
import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue'; import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue';
import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue'; import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue';
import { useTccStore } from 'src/stores/tcc-store';
export class TrainState extends GraphicStateBase implements ITrainState { export class TrainState extends GraphicStateBase implements ITrainState {
constructor(proto?: state.TrainMapState) { constructor(proto?: state.TrainMapState) {
let states; let states;
@ -708,11 +709,20 @@ const CancelLink: MenuItemOptions = {
const removeTrainConfig: MenuItemOptions = { const removeTrainConfig: MenuItemOptions = {
name: '清除列车', name: '清除列车',
}; };
const DrivingCabConfig: MenuItemOptions = {
name: '列车驾驶台',
};
const TrainOperateMenu: ContextMenu = ContextMenu.init({ const TrainOperateMenu: ContextMenu = ContextMenu.init({
name: '列车操作菜单', name: '列车操作菜单',
groups: [ groups: [
{ {
items: [TrainParam, TrainLink, CancelLink, removeTrainConfig], items: [
TrainParam,
TrainLink,
CancelLink,
DrivingCabConfig,
removeTrainConfig,
],
}, },
], ],
}); });
@ -817,6 +827,12 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
}); });
}); });
}; };
DrivingCabConfig.handler = () => {
useTccStore().setTccParam(
parseInt(train.states.id),
train.states.trainControlMapId
);
};
TrainOperateMenu.open(e.global); TrainOperateMenu.open(e.global);
} }