refactor: 移除互斥区相关的路段绑定逻辑,简化组件代码结构
This commit is contained in:
parent
240f602f29
commit
ff4652e1c1
@ -36,13 +36,6 @@ const bindPoint = computed<string>(
|
|||||||
.filter((v) => !!v)
|
.filter((v) => !!v)
|
||||||
.join('、') ?? '',
|
.join('、') ?? '',
|
||||||
);
|
);
|
||||||
const bindRoute = computed<string>(
|
|
||||||
() =>
|
|
||||||
area.value?.routes
|
|
||||||
?.map((v) => editor.value.getRouteLabel(v))
|
|
||||||
.filter((v) => !!v)
|
|
||||||
.join('、') ?? '',
|
|
||||||
);
|
|
||||||
|
|
||||||
const ruleText = computed(() => {
|
const ruleText = computed(() => {
|
||||||
if (area.value?.inoutflag === 1) return '先进先出';
|
if (area.value?.inoutflag === 1) return '先进先出';
|
||||||
@ -93,12 +86,6 @@ const ruleText = computed(() => {
|
|||||||
<a-typography-text>{{ bindPoint || $t('暂无') }}</a-typography-text>
|
<a-typography-text>{{ bindPoint || $t('暂无') }}</a-typography-text>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-list-item>
|
</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>
|
</a-list>
|
||||||
</template>
|
</template>
|
||||||
<a-empty v-else :image="sTheme.empty" />
|
<a-empty v-else :image="sTheme.empty" />
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type MapAreaInfo, MapAreaType, type MapPen, MapPointType } from '@api/map';
|
import { type MapAreaInfo, MapAreaType, type MapPen, MapPointType } from '@api/map';
|
||||||
import type { PointBindModalRef } from '@common/modal/point-bind-modal.vue';
|
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 type { EditorService } from '@core/editor.service';
|
||||||
import sTheme from '@core/theme.service';
|
import sTheme from '@core/theme.service';
|
||||||
import { ref, shallowRef } from 'vue';
|
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 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<PointBindModal ref="refBindPoint" :token="token" />
|
<PointBindModal ref="refBindPoint" :token="token" />
|
||||||
<RouteBindModal ref="refBindRoute" :token="token" />
|
|
||||||
|
|
||||||
<a-card class="full" :title="$t('属性')" :bordered="false">
|
<a-card class="full" :title="$t('属性')" :bordered="false">
|
||||||
<a-flex v-if="id && pen && area" :gap="24" vertical>
|
<a-flex v-if="id && pen && area" :gap="24" vertical>
|
||||||
@ -166,26 +155,6 @@ const routes = computed<string[]>(
|
|||||||
</template>
|
</template>
|
||||||
</a-list>
|
</a-list>
|
||||||
</a-collapse-panel>
|
</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-collapse>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
<a-empty v-else :image="sTheme.empty" />
|
<a-empty v-else :image="sTheme.empty" />
|
||||||
|
@ -471,7 +471,7 @@ export class EditorService extends Meta2d {
|
|||||||
#mapSceneArea(pen: MapPen): StandardSceneArea | null {
|
#mapSceneArea(pen: MapPen): StandardSceneArea | null {
|
||||||
if (!pen.id || isEmpty(pen.area)) return null;
|
if (!pen.id || isEmpty(pen.area)) return null;
|
||||||
const { id, label, desc, properties } = pen;
|
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);
|
const { x, y, width, height } = this.getPenRect(pen);
|
||||||
// 进行坐标转换:左上角原点 -> 中心点原点,同时应用ratio缩放
|
// 进行坐标转换:左上角原点 -> 中心点原点,同时应用ratio缩放
|
||||||
const transformedCoords = this.#transformCoordinate(x, y);
|
const transformedCoords = this.#transformCoordinate(x, y);
|
||||||
@ -520,10 +520,7 @@ export class EditorService extends Meta2d {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (MapAreaType.互斥区 === type) {
|
// 互斥区不再保存路段信息
|
||||||
// 互斥区直接保存路线ID,不需要过滤
|
|
||||||
area.routes = routes;
|
|
||||||
}
|
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1215,7 +1212,7 @@ export class EditorService extends Meta2d {
|
|||||||
break;
|
break;
|
||||||
case MapAreaType.互斥区:
|
case MapAreaType.互斥区:
|
||||||
selected?.filter(({ point }) => point?.type).forEach(({ id }) => points.push(id!));
|
selected?.filter(({ point }) => point?.type).forEach(({ id }) => points.push(id!));
|
||||||
selected?.filter(({ route }) => route?.type).forEach(({ id }) => routes.push(id!));
|
// 互斥区不再绑定路段
|
||||||
break;
|
break;
|
||||||
case MapAreaType.非互斥区:
|
case MapAreaType.非互斥区:
|
||||||
selected?.filter(({ point }) => point?.type).forEach(({ id }) => points.push(id!));
|
selected?.filter(({ point }) => point?.type).forEach(({ id }) => points.push(id!));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user