车站状态面板增加ibp按钮 && 启动项目列表项目过长优化

This commit is contained in:
Yuan 2023-12-07 16:48:22 +08:00
parent 729f0a9ec1
commit 57a8dca8be
4 changed files with 70 additions and 38 deletions

View File

@ -142,7 +142,7 @@ export function checkMapData(data: { mapProto: string }) {
return api.post(`${UriBase}/check/data`, data);
}
export interface SimulationIem {
export interface SimulationItem {
mapId: number;
projectId: number;
simulationId: string;
@ -155,7 +155,7 @@ export interface SimulationIem {
* @param
* @returns
*/
export async function getSimulationList(): Promise<Array<SimulationIem>> {
export async function getSimulationList(): Promise<Array<SimulationItem>> {
const response = await api.get(`${UriBase}/list`);
return response.data;
}
@ -171,7 +171,7 @@ export interface createByProject {
*/
export async function createSimulationByProject(
data: createByProject
): Promise<SimulationIem> {
): Promise<SimulationItem> {
const response = await api.post(`${UriBase}/createByProject`, data);
return response.data;
}

View File

@ -1,34 +1,39 @@
<template>
<q-card flat bordered>
<q-card-section>
<q-card-section class="row justify-between items-center q-pb-none">
<div class="text-h6">车站状态</div>
<q-btn v-if="isIbpBtnShow" color="primary" @click="openIbp"
>打开IBP</q-btn
>
</q-card-section>
<q-separator inset />
<q-form>
<q-input outlined readonly v-model="stationState.id" label="id" hint="" />
<q-input
outlined
readonly
v-model="stationState.index"
label="索引"
hint=""
/>
<q-input
outlined
readonly
v-model.number="stationState.code"
label="名称"
/>
</q-form>
<q-card-section>
<q-form>
<q-input
outlined
readonly
v-model="stationState.id"
label="id"
hint=""
/>
<q-input
outlined
readonly
v-model.number="stationState.code"
label="名称"
/>
</q-form>
</q-card-section>
</q-card>
</template>
<script setup lang="ts">
import { useLineStore } from 'src/stores/line-store';
import { ref, watch, onMounted } from 'vue';
import { ref, watch, onMounted, computed } from 'vue';
import { Station } from 'src/graphics/station/Station';
import { useIbpStore } from 'src/stores/ibp-store';
const lineStore = useLineStore();
const stationState = ref({ id: '', index: 0, code: '' });
const stationState = ref({ id: '', code: '' });
watch(
() => lineStore.selectedGraphics,
@ -38,28 +43,34 @@ watch(
} else {
stationState.value = {
id: '',
index: 0,
code: '',
};
}
}
);
const isIbpBtnShow = computed(() => {
const selected = lineStore.selectedGraphics;
if (!selected) return;
const station = selected[0] as Station;
if (!station) return;
return station.getPlatforms().some((p) => p.states.spksState?.length !== 0);
});
function openIbp() {
const selected = lineStore.selectedGraphics;
if (!selected) return;
const station = selected[0] as Station;
if (!station) return;
useIbpStore().openIbpScene(station);
}
function setStationState(station: Station) {
stationState.value = {
id: station.datas.id,
index: station.datas.index,
code: station.datas.code,
};
}
function submitState() {
if (lineStore.simulationId) {
}
}
function onReset() {
if (lineStore.selectedGraphics) {
setStationState(lineStore.selectedGraphics[0] as Station);
}
}
onMounted(() => {
if (lineStore.selectedGraphics) {

View File

@ -6,6 +6,7 @@ import {
VectorText,
} from 'src/jl-graphic';
import { KilometerSystem } from '../signal/Signal';
import { Platform } from '../platform/Platform';
export interface IStationData extends GraphicData {
get code(): string; // 车站站名
@ -80,6 +81,14 @@ export class Station extends JlGraphic {
kilometerGraph.anchor.set(0.5);
kilometerGraph.position.set(0, stationConsts.kilometerCodeOffsetY);
}
getPlatforms(): Platform[] {
const relations = this.relationManage.getRelationsOfGraphicAndOtherType(
this,
Platform.Type
);
return relations.map((r) => r.getOtherGraphic(this));
}
}
export class StationTemplate extends JlGraphicTemplate<Station> {

View File

@ -28,7 +28,7 @@
<q-btn color="primary" label="启动" @click="createFormShow = true" />
</template>
<template v-slot:body-cell-operations="props">
<template #body-cell-operations="props">
<q-td :props="props">
<div class="q-gutter-sm row justify-center">
<q-btn
@ -46,6 +46,18 @@
</div>
</q-td>
</template>
<template #body-cell="props">
<td class="text-center" v-if="props.col.name === 'mapIds'">
<q-tooltip>{{ props.value }} </q-tooltip>
{{
props.value.length > 40
? props.value.slice(0, 40) + '…'
: props.value
}}
</td>
<td class="text-center" v-else>{{ props.value }}</td>
</template>
</q-table>
<q-dialog
@ -99,7 +111,7 @@ import { useQuasar, type QTableColumn, QForm } from 'quasar';
import { getProjectList } from '../api/ProjectApi';
import { ApiError } from 'src/boot/axios';
import {
SimulationIem,
SimulationItem,
createByProject,
createSimulationByProject,
getSimulationList,
@ -168,7 +180,7 @@ const columnDefs: QTableColumn[] = [
const operateDisabled = ref(false);
const tableRef = ref();
const rows = reactive<SimulationIem[]>([]);
const rows = reactive<SimulationItem[]>([]);
const filter = reactive({
name: '',
});
@ -317,7 +329,7 @@ function getProjectName(id: number): string {
return name;
}
function joinTest(val: SimulationIem) {
function joinTest(val: SimulationItem) {
const query = {
defaultMapId: val.mapId,
simulationId: val.simulationId,
@ -325,7 +337,7 @@ function joinTest(val: SimulationIem) {
};
router.push({ path: '/linemap', query });
}
function endTest(val: SimulationIem) {
function endTest(val: SimulationItem) {
operateDisabled.value = true;
const name = getProjectName(val.projectId);
$q.dialog({