refactor: 移除互斥区相关的路段绑定逻辑,简化组件代码结构

This commit is contained in:
xudan 2025-08-26 14:42:25 +08:00
parent 240f602f29
commit ff4652e1c1
3 changed files with 3 additions and 50 deletions

View File

@ -36,13 +36,6 @@ const bindPoint = computed<string>(
.filter((v) => !!v)
.join('、') ?? '',
);
const bindRoute = computed<string>(
() =>
area.value?.routes
?.map((v) => editor.value.getRouteLabel(v))
.filter((v) => !!v)
.join('、') ?? '',
);
const ruleText = computed(() => {
if (area.value?.inoutflag === 1) return '先进先出';
@ -93,12 +86,6 @@ const ruleText = computed(() => {
<a-typography-text>{{ bindPoint || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item v-if="MapAreaType.互斥区 === area.type">
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('绑定路段') }}</a-typography-text>
<a-typography-text>{{ bindRoute || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
</a-list>
</template>
<a-empty v-else :image="sTheme.empty" />

View File

@ -1,7 +1,6 @@
<script setup lang="ts">
import { type MapAreaInfo, MapAreaType, type MapPen, MapPointType } from '@api/map';
import type { PointBindModalRef } from '@common/modal/point-bind-modal.vue';
import type { RouteBindModalRef } from '@common/modal/route-bind-modal.vue';
import type { EditorService } from '@core/editor.service';
import sTheme from '@core/theme.service';
import { ref, shallowRef } from 'vue';
@ -34,20 +33,10 @@ const points = computed<MapPen[]>(
),
);
const actions = computed<MapPen[]>(() => points.value?.filter(({ point }) => point?.type === MapPointType.动作点));
const refBindRoute = shallowRef<RouteBindModalRef>();
const routeKeyword = ref<string>('');
const routes = computed<string[]>(
() =>
<string[]>(
area.value?.routes?.map((v) => editor.value.getRouteLabel(v)).filter((v) => v?.includes(routeKeyword.value))
),
);
</script>
<template>
<PointBindModal ref="refBindPoint" :token="token" />
<RouteBindModal ref="refBindRoute" :token="token" />
<a-card class="full" :title="$t('属性')" :bordered="false">
<a-flex v-if="id && pen && area" :gap="24" vertical>
@ -166,26 +155,6 @@ const routes = computed<string[]>(
</template>
</a-list>
</a-collapse-panel>
<a-collapse-panel v-if="MapAreaType.互斥区 === area.type" :header="$t('绑定路段')">
<template #extra>
<a-button class="icon-btn" size="small" @click.stop="refBindRoute?.open(pen)">
<i class="mask plus" />
</a-button>
</template>
<a-input class="search mv-8" :placeholder="$t('请输入搜索关键字')" v-model:value="routeKeyword">
<template #suffix>
<i class="icon search size-16" />
</template>
</a-input>
<a-list rowKey="id" :data-source="routes">
<template #renderItem="{ item }">
<a-list-item class="ph-16" style="height: 36px">
<a-typography-text>{{ item }}</a-typography-text>
</a-list-item>
</template>
</a-list>
</a-collapse-panel>
</a-collapse>
</a-flex>
<a-empty v-else :image="sTheme.empty" />

View File

@ -471,7 +471,7 @@ export class EditorService extends Meta2d {
#mapSceneArea(pen: MapPen): StandardSceneArea | null {
if (!pen.id || isEmpty(pen.area)) return null;
const { id, label, desc, properties } = pen;
const { type, points, routes, maxAmr, inoutflag } = pen.area;
const { type, points, maxAmr, inoutflag } = pen.area;
const { x, y, width, height } = this.getPenRect(pen);
// 进行坐标转换:左上角原点 -> 中心点原点同时应用ratio缩放
const transformedCoords = this.#transformCoordinate(x, y);
@ -520,10 +520,7 @@ export class EditorService extends Meta2d {
return true;
});
}
if (MapAreaType. === type) {
// 互斥区直接保存路线ID不需要过滤
area.routes = routes;
}
// 互斥区不再保存路段信息
return area;
}
@ -1215,7 +1212,7 @@ export class EditorService extends Meta2d {
break;
case MapAreaType.:
selected?.filter(({ point }) => point?.type).forEach(({ id }) => points.push(id!));
selected?.filter(({ route }) => route?.type).forEach(({ id }) => routes.push(id!));
// 互斥区不再绑定路段
break;
case MapAreaType.:
selected?.filter(({ point }) => point?.type).forEach(({ id }) => points.push(id!));