This commit is contained in:
joylink_fanyuhong 2024-04-26 15:50:12 +08:00
commit 5e51dcc295
7 changed files with 100 additions and 32 deletions

View File

@ -471,3 +471,11 @@ export async function xcjUpdateParams(data: {
}) {
return await api.put(`${UriBase}/xcj/operation`, data);
}
/** 列车取消连接 */
export async function cancelTrainConn(data: {
trainId: string;
id: string;
}) {
return await api.delete(`${UriBase}/train/unconn/${data.trainId}/${data.id}`);
}

View File

@ -16,34 +16,44 @@
}"
style="max-width: 2000px"
>
<q-bar
ref="headerRef"
class="non-selectable q-gutter-l"
style="
cursor: move;
border-top-right-radius: 0;
border-top-left-radius: 0;
"
:style="`height: ${props.titleHeight}px;background: ${props.titleColor}`"
>
<div
:style="`height: 100%; line-height: ${props.titleHeight}px; color:${props.fontColor};font-size: ${props.fontSize}px;`"
>
{{ props.title }}
</div>
<q-space />
<div style="margin-right: 10px"><slot name="titleButton"></slot></div>
<q-btn dense flat icon="sym_o_close" v-close-popup></q-btn>
</q-bar>
<!-- <q-scroll-area
:style="`width: ${props.width}px; height: ${props.height}px;`"
v-if="props.height"
id="draggable-dialog-scroll"
:style="`width: ${props.width}px;height: ${props.height}px`"
style="max-height: 90vh"
> -->
<slot></slot>
<!-- </q-scroll-area> -->
<div :style="`width: ${props.width}px`">
<slot name="footer"></slot>
<div style="position: sticky; top: 0px; z-index: 9">
<q-bar
ref="headerRef"
class="non-selectable q-gutter-l"
style="
cursor: move;
border-top-right-radius: 0;
border-top-left-radius: 0;
"
:style="`height: ${props.titleHeight}px;background: ${props.titleColor}`"
>
<div
:style="`height: 100%; line-height: ${props.titleHeight}px; color:${props.fontColor};font-size: ${props.fontSize}px;`"
>
{{ props.title }}
</div>
<q-space />
<div style="margin-right: 10px">
<slot name="titleButton"></slot>
</div>
<q-btn dense flat icon="sym_o_close" v-close-popup></q-btn>
</q-bar>
</div>
<q-scroll-area
v-if="props.height"
id="draggable-dialog-scroll"
:style="`width: ${props.width}px;height: ${props.height}px`"
style="max-height: calc(90vh - 100px)"
>
<slot></slot>
</q-scroll-area>
<slot name="footer"></slot>
<div
:style="`width: ${props.width}px`"
style="position: sticky; bottom: 0px"
@ -62,7 +72,7 @@ const emit = defineEmits({
...useDialogPluginComponent.emitsObject,
show: () => true,
});
const fixed = ref(false);
const props = withDefaults(
defineProps<{
title?: string;

View File

@ -68,8 +68,8 @@ onMounted(() => {
list.push({ label: '半实物', value: 1 });
} else if (element.connType === 2) {
list.push({ label: 'PC仿真', value: 2 });
} else if (element.connType === 1) {
list.push({ label: '取消连接', value: 0 });
// } else if (element.connType === 0) {
// list.push({ label: '', value: 0 });
}
});
connectOptions.value = list;

View File

@ -8,7 +8,7 @@
:height="722"
>
<q-card style="width: 1000px; height: auto">
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
<q-form ref="myForm" class="q-gutter-md">
<div class="row">
<div class="col-6">
<div class="float-text">1</div>
@ -455,7 +455,7 @@
@click="showTrainParamOperation = false"
v-close-popup
/>
<q-btn flat label="确认" type="submit" />
<q-btn flat label="确认" @click="onCreate" />
</div>
</template>
</draggable-dialog>

View File

@ -42,6 +42,7 @@ enum Type {
'未定义',
'动力学',
'半实物列车',
'列车PC仿真',
}
const columns: QTable['columns'] = [
{

View File

@ -191,6 +191,8 @@ 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 { errorNotify, successNotify } from 'src/utils/CommonNotify';
interface KeyType {
label: string;
@ -623,6 +625,10 @@ const options = [
label: '列车驾驶台',
value: 3,
},
{
label: '取消连接',
value: 4,
},
];
function doTrainOperation(option: { label: string; value: number }) {
@ -632,9 +638,31 @@ function doTrainOperation(option: { label: string; value: number }) {
linkTrain();
} else if (option.value == 3) {
openTccDialog();
} else if (option.value == 4) {
cancelTrainLink();
}
}
function cancelTrainLink() {
if (!lineStore.selectedGraphics) return;
const train = lineStore.selectedGraphics[0] as Train;
Dialog.create({
title: '确认',
message: `确认取消【${train.states.id}】列车的连接吗?`,
cancel: true,
}).onOk(async () => {
cancelTrainConn({
id: lineStore.simulationId || '',
trainId: train.code,
})
.then(() => {
successNotify('列车取消连接成功!');
})
.catch((err) => {
errorNotify('列车取消连接失败!', err);
});
});
}
function linkTrain() {
if (!lineStore.selectedGraphics) return;
if (lineStore.deviceOpreratDialogInstance) return;

View File

@ -10,7 +10,7 @@ import {
ContextMenu,
} from 'jl-graphic';
import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
import { removeTrain } from 'src/api/Simulation';
import { removeTrain, cancelTrainConn } from 'src/api/Simulation';
import { useLineStore } from 'src/stores/line-store';
import { successNotify, errorNotify } from '../../utils/CommonNotify';
import { Dialog } from 'quasar';
@ -696,6 +696,9 @@ const TrainParam: MenuItemOptions = {
const TrainLink: MenuItemOptions = {
name: '列车连接',
};
const CancelLink: MenuItemOptions = {
name: '取消连接',
};
const removeTrainConfig: MenuItemOptions = {
name: '清除列车',
};
@ -703,7 +706,7 @@ const TrainOperateMenu: ContextMenu = ContextMenu.init({
name: '列车操作菜单',
groups: [
{
items: [TrainParam, TrainLink, removeTrainConfig],
items: [TrainParam, TrainLink, CancelLink, removeTrainConfig],
},
],
});
@ -771,6 +774,24 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
persistent: true,
});
};
CancelLink.handler = () => {
Dialog.create({
title: '确认',
message: `确认取消【${train.states.id}】列车的连接吗?`,
cancel: true,
}).onOk(async () => {
cancelTrainConn({
id: simulationId,
trainId: train.code,
})
.then(() => {
successNotify('列车取消连接成功!');
})
.catch((err) => {
errorNotify('列车取消连接失败!', err);
});
});
};
removeTrainConfig.handler = () => {
Dialog.create({
title: '确认',